Cube  Check-in [853e760619]

Overview
Comment:Migrate vectors
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 853e760619bc8b16ee0262c55740ba82bd7efdc508357d544a6f59f450a155a7
User & Date: js on 2025-03-16 00:05:52
Other Links: manifest | tags
Context
2025-03-16
10:11
Use one autorelease pool per frame check-in: 489124a92f user: js tags: trunk
00:05
Migrate vectors check-in: 853e760619 user: js tags: trunk
2025-03-15
23:42
Migrate last strings check-in: b81e2948d7 user: js tags: trunk
Changes

Modified src/cube.h from [8cc717f782] to [63027fcfcd].

16
17
18
19
20
21
22
23

24

25
26
27
28
29
30
31
16
17
18
19
20
21
22

23

24
25
26
27
28
29
30
31







-
+
-
+







@property (class, readonly, nonatomic) Cube *sharedInstance;
@property (readonly, nonatomic) SDL_Window *window;
@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
	SEMISOLID, // generated by mipmapping
	MAXTYPE
40
41
42
43
44
45
46
47

48

49
50
51
52
53
54
55
56

57

58
59
60
61
62
63
64
40
41
42
43
44
45
46

47

48
49
50
51
52
53
54
55

56

57
58
59
60
61
62
63
64







-
+
-
+







-
+
-
+







	char defer; // used in mipmapping, when true this cube is not a perfect
	            // mip
	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,
	I_ROCKETS,
	I_ROUNDS,
72
73
74
75
76
77
78

79

80
81
82
83
84
85
86
87
88
89
90
91
92
93

94

95
96
97
98
99
100
101
72
73
74
75
76
77
78
79

80

81
82
83
84
85
86
87
88
89
90
91
92

93

94
95
96
97
98
99
100
101







+
-
+
-












-
+
-
+







	MAPMODEL, // attr1 = angle, attr2 = idx
	MONSTER,  // attr1 = angle, attr2 = monstertype
	CARROT,   // attr1 = tag, attr2 = type
	JUMPPAD,  // attr1 = zpush, attr2 = ypush, attr3 = xpush
	MAXENTTYPES
};

// map entity
struct persistent_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;
};

struct entity: public persistent_entity {
	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;
	char maptitle[128];
	uchar texlists[3][256];
340
341
342
343
344
345
346
347

348

349
350
351
352
353
354
355
340
341
342
343
344
345
346

347

348
349
350
351
352
353
354
355







-
+
-
+







#define m_tarena (gamemode >= 10)
#define m_teammode (gamemode & 1 && gamemode > 2)
#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,
	ARG_1STR,
	ARG_2STR,

Modified src/worldlight.mm from [9b1a521652] to [05fab5d192].

185
186
187
188
189
190
191
192

193
194
195
196
197
198



199
200

201
202
203
204
205
206
207
185
186
187
188
189
190
191

192
193
194
195
196


197
198
199
200

201
202
203
204
205
206
207
208







-
+




-
-
+
+
+

-
+







	block b = { 1, 1, ssize - 2, ssize - 2 };
	postlightarea(b);
	setvar(@"fullbright", 0);
}

VARP(dynlight, 0, 16, 32);

vector<block *> 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,
    DynamicEntity *owner)
{
223
224
225
226
227
228
229




230



231
232
233
234
235
236
237
224
225
226
227
228
229
230
231
232
233
234

235
236
237
238
239
240
241
242
243
244







+
+
+
+
-
+
+
+







	if (b.y < 1)
		b.y = 1;
	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;

	if (dlights == nil)
		dlights =
		    [[OFMutableData alloc] initWithItemSize:sizeof(block *)];

	dlights.add(blockcopy(b)); // backup area before rendering in dynlight
	// backup area before rendering in dynlight
	block *copy = blockcopy(b);
	[dlights addItem:&copy];

	persistent_entity l = { (short)v.x, (short)v.y, (short)v.z,
		(short)reach, LIGHT, (uchar)strength, 0, 0 };
	calclightsource(l);
	postlightarea(b);
}