summary refs log tree commit diff stats
path: root/src/map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/map.cpp b/src/map.cpp index 73eb2b4..6b83442 100644 --- a/src/map.cpp +++ b/src/map.cpp
@@ -50,9 +50,9 @@ Map::Map(const std::string name)
50 } else if (!xmlStrcmp(node->name, (const xmlChar*) "environment")) 50 } else if (!xmlStrcmp(node->name, (const xmlChar*) "environment"))
51 { 51 {
52 xmlChar* key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1); 52 xmlChar* key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
53 mapdata = (int*) malloc(MAP_WIDTH*(MAP_HEIGHT-1)*sizeof(int)); 53 mapdata = (int*) malloc(MAP_WIDTH*MAP_HEIGHT*sizeof(int));
54 mapdata[0] = atoi(strtok((char*) key, ",\n")); 54 mapdata[0] = atoi(strtok((char*) key, ",\n"));
55 for (int i=1; i<(MAP_WIDTH*(MAP_HEIGHT-1)); i++) 55 for (int i=1; i<(MAP_WIDTH*MAP_HEIGHT); i++)
56 { 56 {
57 mapdata[i] = atoi(strtok(NULL, ",\n")); 57 mapdata[i] = atoi(strtok(NULL, ",\n"));
58 } 58 }
@@ -100,8 +100,8 @@ Map::Map(const std::string name)
100 100
101Map::Map(const Map& map) 101Map::Map(const Map& map)
102{ 102{
103 mapdata = (int*) malloc(MAP_WIDTH*(MAP_HEIGHT-1)*sizeof(int)); 103 mapdata = (int*) malloc(MAP_WIDTH*MAP_HEIGHT*sizeof(int));
104 memcpy(mapdata, map.mapdata, MAP_WIDTH*(MAP_HEIGHT-1)*sizeof(int)); 104 memcpy(mapdata, map.mapdata, MAP_WIDTH*MAP_HEIGHT*sizeof(int));
105 105
106 title = (char*) malloc((MAP_WIDTH+1)*sizeof(char)); 106 title = (char*) malloc((MAP_WIDTH+1)*sizeof(char));
107 strncpy(title, map.title, MAP_WIDTH+1); 107 strncpy(title, map.title, MAP_WIDTH+1);