This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
neofx-zoomedit/level.c

49 lines
789 B
C
Raw Normal View History

2007-06-21 19:52:03 +00:00
#include "level.h"
#include <stdlib.h>
static LEVEL *level = NULL;
LEVEL *getLevel() {
return level;
}
void setLevel(LEVEL *l) {
level = l;
}
2007-06-21 19:52:03 +00:00
void addRoom(LEVEL *lvl, ROOM *room) {
lvl->nRooms++;
lvl->rooms = 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 = 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].vertices)
free(lvl->rooms[i].vertices);
}
free(lvl->rooms);
}
free(lvl);
}
}