summaryrefslogtreecommitdiffstats
path: root/level.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'level.cpp')
-rw-r--r--level.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/level.cpp b/level.cpp
index 6483066..a8d3fdb 100644
--- a/level.cpp
+++ b/level.cpp
@@ -15,7 +15,10 @@ void setLevel(LEVEL *l) {
void addRoom(LEVEL *lvl, const ROOM *room) {
lvl->nRooms++;
- lvl->rooms = (ROOM*)realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM));
+ if(lvl->nRooms > 1)
+ lvl->rooms = (ROOM*)realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM));
+ else
+ lvl->rooms = (ROOM*)calloc(1, sizeof(ROOM));
lvl->rooms[lvl->nRooms-1] = *room;
}
@@ -36,9 +39,6 @@ void freeLevel(LEVEL *lvl) {
if(lvl) {
if(lvl->rooms) {
for(i = 0; i < lvl->nRooms; i++) {
- if(lvl->rooms[i].polygon.vertices)
- free(lvl->rooms[i].polygon.vertices);
-
if(lvl->rooms[i].name)
free(lvl->rooms[i].name);
}