Index: common/WorldMap.cpp
===================================================================
--- common/WorldMap.cpp	(revision 60017fc77171d89da05e3eaab5eb4a9c3d0a0f6e)
+++ common/WorldMap.cpp	(revision 093c141baf9734648d61a380eb59f797b189014a)
@@ -1,3 +1,8 @@
 #include "WorldMap.h"
+
+#include <string>
+#include <iostream>
+#include <fstream>
+#include <sstream>
 
 using namespace std;
@@ -57,2 +62,78 @@
    return m;
 }
+
+WorldMap* WorldMap::loadMapFromFile(string filename)
+{
+   WorldMap* m = new WorldMap(12l, 12);
+
+   ifstream file(filename);
+
+   if (file.is_open())
+   {
+      string line;
+      int width, height;
+
+      // read the map dimensions
+      getline(file, line);
+      if (line.size() > 0)
+      {
+         istringstream iss(line);
+         string token;
+         getline(iss, token, 'x');
+         width = atoi(token.c_str());
+         getline(iss, token, 'x');
+         height = atoi(token.c_str());
+      }
+
+      cout << "width: " << width << endl;
+      cout << "height: " << height << endl;
+
+      // read the map contents
+      int row = 0;
+      while ( file.good() )
+      {
+         getline(file, line);
+         if (line.size() > 0)
+         {
+            cout << "line: " << line << endl;
+
+            istringstream iss(line);
+            string token;
+            int type;
+            TerrainType terrain;
+
+            for(int x=0; x<width; x++)
+            {
+               getline(iss, token, ',');
+               cout << "token: " << token << endl;
+               type = atoi(token.c_str());
+               cout << "type: " << type << endl;
+
+               switch(type) {
+               case 1:
+                  terrain = TERRAIN_GRASS;
+                  break;
+               case 2:
+                  terrain = TERRAIN_OCEAN;
+                  break;
+               case 3:
+                  terrain = TERRAIN_ROCK;
+                  break;
+               }
+
+               cout << "About to set element" << endl;
+               cout << "x: " << x << endl;
+               cout << "row: " << row << endl;
+               m->setElement(x, row, terrain);
+            }
+         }
+
+         row++;
+      }
+      file.close();
+   }
+   else
+      cout << "Could not open the file" << endl;
+
+   return m;
+}
Index: common/WorldMap.h
===================================================================
--- common/WorldMap.h	(revision 60017fc77171d89da05e3eaab5eb4a9c3d0a0f6e)
+++ common/WorldMap.h	(revision 093c141baf9734648d61a380eb59f797b189014a)
@@ -26,4 +26,5 @@
 
    static WorldMap* createDefaultMap();
+   static WorldMap* loadMapFromFile(string filename);
 };
 
