summaryrefslogtreecommitdiffstats
path: root/level.cpp
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-09-16 14:52:01 +0200
committerneoraider <devnull@localhost>2007-09-16 14:52:01 +0200
commit2bdbece75f9dcc9b98d7f9d5794c4b5e5f441b26 (patch)
treeb7ee606f338a6f0bae32f34af6ed801c2281a083 /level.cpp
parent61145c32c94d7b3e30c0016ea47f9e2dcb9ebbae (diff)
downloadzoomedit-2bdbece75f9dcc9b98d7f9d5794c4b5e5f441b26.tar
zoomedit-2bdbece75f9dcc9b98d7f9d5794c4b5e5f441b26.zip
zoomedit: Kompiliert jetzt als C++-Programm
Diffstat (limited to 'level.cpp')
-rw-r--r--level.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/level.cpp b/level.cpp
new file mode 100644
index 0000000..6483066
--- /dev/null
+++ b/level.cpp
@@ -0,0 +1,51 @@
+#include "level.h"
+#include <stdlib.h>
+
+
+static LEVEL *level = NULL;
+
+
+LEVEL *getLevel() {
+ return level;
+}
+
+void setLevel(LEVEL *l) {
+ level = l;
+}
+
+void addRoom(LEVEL *lvl, const ROOM *room) {
+ lvl->nRooms++;
+ lvl->rooms = (ROOM*)realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM));
+ lvl->rooms[lvl->nRooms-1] = *room;
+}
+
+void deleteRoom(LEVEL *lvl, unsigned int n) {
+ int i;
+
+ lvl->nRooms--;
+
+ for(i = n; i < lvl->nRooms; i++)
+ lvl->rooms[i] = lvl->rooms[i+1];
+
+ lvl->rooms = (ROOM*)realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM));
+}
+
+void freeLevel(LEVEL *lvl) {
+ int i;
+
+ 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);
+ }
+
+ free(lvl->rooms);
+ }
+
+ free(lvl);
+ }
+}