Index: src/cube.h ================================================================== --- src/cube.h +++ src/cube.h @@ -18,12 +18,12 @@ @property (readonly, nonatomic) OFIRI *gameDataIRI, *userDataIRI; @property (nonatomic) bool repeatsKeys; @property (nonatomic) int framesInMap; @end -enum // block types, order matters! -{ +// block types, order matters! +enum { SOLID = 0, // entirely solid cube [only specifies wtex] CORNER, // half full corner of a wall FHF, // floor heightfield using neighbour vdelta values CHF, // idem ceiling SPACE, // entirely empty cube @@ -42,21 +42,21 @@ char occluded; // true when occluded uchar utex; // upper wall tex id uchar tag; // used by triggers }; -enum // hardcoded texture numbers -{ +// hardcoded texture numbers +enum { DEFAULT_SKY = 0, DEFAULT_LIQUID, DEFAULT_WALL, DEFAULT_FLOOR, DEFAULT_CEIL }; -enum // static entity types -{ +// static entity types +enum { NOTUSED = 0, // entity slot not in use in map LIGHT, // lightsource, attr1 = radius, attr2 = intensity PLAYERSTART, // attr1 = angle I_SHELLS, I_BULLETS, @@ -74,12 +74,12 @@ CARROT, // attr1 = tag, attr2 = type JUMPPAD, // attr1 = zpush, attr2 = ypush, attr3 = xpush MAXENTTYPES }; -struct persistent_entity // map entity -{ +// map entity +struct persistent_entity { short x, y, z; // cube aligned position short attr1; uchar type; // type is one of the above uchar attr2, attr3, attr4; }; @@ -88,12 +88,12 @@ bool spawned; // the only dynamic state of a map entity }; #define MAPVERSION 5 // bump if map format changes, see worldio.cpp -struct header // map file format header -{ +// map file format header +struct header { char head[4]; // "CUBE" int version; // any >8bit quantity is a little indian int headersize; // sizeof(header) int sfactor; // in bits int numents; @@ -342,12 +342,12 @@ #define m_sp (gamemode < 0) #define m_dmsp (gamemode == -1) #define m_classicsp (gamemode == -2) #define isteam(a, b) (m_teammode && [a isEqual:b]) -enum // function signatures for script functions, see command.cpp -{ +// function signatures for script functions, see command.mm +enum { ARG_1INT, ARG_2INT, ARG_3INT, ARG_4INT, ARG_NONE, Index: src/worldlight.mm ================================================================== --- src/worldlight.mm +++ src/worldlight.mm @@ -187,19 +187,20 @@ setvar(@"fullbright", 0); } VARP(dynlight, 0, 16, 32); -vector dlights; +static OFMutableData *dlights; void cleardlights() { - while (!dlights.empty()) { - block *backup = dlights.pop(); + while (dlights.count > 0) { + block *backup = *(block **)[dlights lastItem]; + [dlights removeLastItem]; blockpaste(*backup); - free(backup); + OFFreeMemory(backup); } } void dodynlight(const OFVector3D &vold, const OFVector3D &v, int reach, int strength, @@ -225,11 +226,17 @@ if (b.xs + b.x > ssize - 2) b.xs = ssize - 2 - b.x; if (b.ys + b.y > ssize - 2) b.ys = ssize - 2 - b.y; - dlights.add(blockcopy(b)); // backup area before rendering in dynlight + if (dlights == nil) + dlights = + [[OFMutableData alloc] initWithItemSize:sizeof(block *)]; + + // backup area before rendering in dynlight + block *copy = blockcopy(b); + [dlights addItem:©]; persistent_entity l = { (short)v.x, (short)v.y, (short)v.z, (short)reach, LIGHT, (uchar)strength, 0, 0 }; calclightsource(l); postlightarea(b);