From 2bdbece75f9dcc9b98d7f9d5794c4b5e5f441b26 Mon Sep 17 00:00:00 2001 From: neoraider Date: Sun, 16 Sep 2007 12:52:01 +0000 Subject: zoomedit: Kompiliert jetzt als C++-Programm --- level.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 level.cpp (limited to 'level.cpp') 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 + + +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); + } +} -- cgit v1.2.3