Cube  Check-in [f642e9dfbf]

Overview
Comment:Migrate to OFOptionsParser
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f642e9dfbf67a6be7bf37d9df2cf3b037537a29c74387f49b0a0e82d6816d616
User & Date: js on 2025-03-02 14:42:43
Other Links: manifest | tags
Context
2025-03-02
14:56
Clean up enqueueInit check-in: d4f57c85c4 user: js tags: trunk
14:42
Migrate to OFOptionsParser check-in: f642e9dfbf user: js tags: trunk
14:02
Migrate to OFApplicationDelegate check-in: 9432e52ca0 user: js tags: trunk
Changes

Modified src/.clang-format from [c1e6bd9906] to [a045e80592].

11
12
13
14
15
16
17


    class, direct,
    readonly, readwrite,
    nullable, nonnull, null_resettable, null_unspecified,
    assign, retain, strong, copy, weak, unsafe_unretained,
    atomic, nonatomic,
    getter, setter
]









>
>
11
12
13
14
15
16
17
18
19
    class, direct,
    readonly, readwrite,
    nullable, nonnull, null_resettable, null_unspecified,
    assign, retain, strong, copy, weak, unsafe_unretained,
    atomic, nonatomic,
    getter, setter
]
IndentPPDirectives: AfterHash
PPIndentWidth: 1

Modified src/Cube.mm from [73cd19e8dc] to [d73ec16894].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// main.cpp: initialisation & main loop

#include "cube.h"

OF_APPLICATION_DELEGATE(Cube)

@implementation Cube
- (void)showMessage: (OFString *)msg
{
#ifdef _WIN32
	MessageBoxW(NULL, msg.UTF16String, L"cube fatal error",
	    MB_OK | MB_SYSTEMMODAL);
#else
	[OFStdOut writeString: msg];
#endif
}

- (void)applicationWillTerminate: (OFNotification *)notification
{
	stop();
	disconnect(true);
	writecfg();
	cleangl();
	cleansound();
	cleanupserver();
	SDL_ShowCursor(1);
	SDL_Quit();
}

void
quit() // normal exit
{
	writeservercfg();
	[OFApplication.sharedApplication terminateWithStatus: 0];
}

void
fatal(char *s, char *o) // failure exit
{
	sprintf_sd(msg)("%s%s (%s)\n", s, o, SDL_GetError());
	OFApplication *app = OFApplication.sharedApplication;
	[(Cube *)app.delegate showMessage: @(msg)];
	[app terminateWithStatus: 1];
}

void *
alloc(int s) // for some big chunks... most other allocs use the memory pool
{
	void *b = calloc(1, s);
	if (!b)







|


|
|

|



|















|







|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// main.cpp: initialisation & main loop

#include "cube.h"

OF_APPLICATION_DELEGATE(Cube)

@implementation Cube
- (void)showMessage:(OFString *)msg
{
#ifdef _WIN32
	MessageBoxW(
	    NULL, msg.UTF16String, L"cube fatal error", MB_OK | MB_SYSTEMMODAL);
#else
	[OFStdOut writeString:msg];
#endif
}

- (void)applicationWillTerminate:(OFNotification *)notification
{
	stop();
	disconnect(true);
	writecfg();
	cleangl();
	cleansound();
	cleanupserver();
	SDL_ShowCursor(1);
	SDL_Quit();
}

void
quit() // normal exit
{
	writeservercfg();
	[OFApplication.sharedApplication terminateWithStatus:0];
}

void
fatal(char *s, char *o) // failure exit
{
	sprintf_sd(msg)("%s%s (%s)\n", s, o, SDL_GetError());
	OFApplication *app = OFApplication.sharedApplication;
	[(Cube *)app.delegate showMessage:@(msg)];
	[app terminateWithStatus:1];
}

void *
alloc(int s) // for some big chunks... most other allocs use the memory pool
{
	void *b = calloc(1, s);
	if (!b)
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123







124
125

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158

159
160
161
162
163
164

165

166
167

168
169
170
171
172
173
174
175
176

177
178
179
180
181
182
183
184
185
186
187
188
189

190
191
192
193
194
195
196
	SDL_EnableKeyRepeat(
	    on ? SDL_DEFAULT_REPEAT_DELAY : 0, SDL_DEFAULT_REPEAT_INTERVAL);
}

VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
VARP(minmillis, 0, 5, 1000);

int islittleendian = 1;
int framesinmap = 0;

- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
	bool dedicated = false;
	int fs = SDL_FULLSCREEN, par = 0, uprate = 0, maxcl = 4;
	char *sdesc = "", *ip = "", *master = NULL, *passwd = "";
	islittleendian = *((char *)&islittleendian);
	int argc, *argcPtr;
	char **argv, ***argvPtr;

	[OFApplication.sharedApplication getArgumentCount: &argcPtr
					andArgumentValues: &argvPtr];
	argc = *argcPtr;
	argv = *argvPtr;

	processInitQueue();

#define log(s) conoutf(@"init: %s", s)
	log("sdl");

	for (int i = 1; i < argc; i++) {







		char *a = &argv[i][2];
		if (argv[i][0] == '-')

			switch (argv[i][1]) {
			case 'd':
				dedicated = true;
				break;
			case 't':
				fs = 0;
				break;
			case 'w':
				scr_w = atoi(a);
				break;
			case 'h':
				scr_h = atoi(a);
				break;
			case 'u':
				uprate = atoi(a);
				break;
			case 'n':
				sdesc = a;
				break;
			case 'i':
				ip = a;
				break;
			case 'm':
				master = a;
				break;
			case 'p':
				passwd = a;
				break;
			case 'c':
				maxcl = atoi(a);
				break;
			default:
				conoutf(@"unknown commandline option");

			}
		else
			conoutf(@"unknown commandline argument");
	};

#ifdef _DEBUG

	par = SDL_INIT_NOPARACHUTE;

	fs = 0;
#endif


	if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | par) < 0)
		fatal("Unable to initialize SDL");

	log("net");
	if (enet_initialize() < 0)
		fatal("Unable to initialise network module");

	initclient();

	initserver(dedicated, uprate, sdesc, ip, master, passwd,
	    maxcl); // never returns if dedicated

	log("world");
	empty_world(7, true);

	log("video: sdl");
	if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
		fatal("Unable to initialize SDL Video");

	log("video: mode");
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	if (SDL_SetVideoMode(scr_w, scr_h, 0, SDL_OPENGL | fs) == NULL)

		fatal("Unable to create OpenGL screen");

	log("video: misc");
	SDL_WM_SetCaption("cube engine", NULL);
	SDL_WM_GrabInput(SDL_GRAB_ON);
	keyrepeat(false);
	SDL_ShowCursor(0);







<


|

|
|
<
<
|
<
|
<
<
<
<






|
>
>
>
>
>
>
>
|
<
>
|
<
<
<
<
<
<
|
|
|
|
|
|
<
<
<
<
<
<
|
|
|
|
|
|
|
|
<
|
<
<
<
|
>
|
<
<
<
|
|
>
|
>
|
|
>









>
|
|










|
>







94
95
96
97
98
99
100

101
102
103
104
105
106


107

108




109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125






126
127
128
129
130
131






132
133
134
135
136
137
138
139

140



141
142
143



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
	SDL_EnableKeyRepeat(
	    on ? SDL_DEFAULT_REPEAT_DELAY : 0, SDL_DEFAULT_REPEAT_INTERVAL);
}

VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
VARP(minmillis, 0, 5, 1000);


int framesinmap = 0;

- (void)applicationDidFinishLaunching:(OFNotification *)notification
{
	bool dedicated, windowed;
	int par = 0, uprate = 0, maxcl = 4;


	OFString *__autoreleasing sdesc, *__autoreleasing ip;

	OFString *__autoreleasing master, *__autoreleasing passwd;





	processInitQueue();

#define log(s) conoutf(@"init: %s", s)
	log("sdl");

	const OFOptionsParserOption options[] = {
	    {'d', nil, 0, &dedicated, NULL}, {'t', nil, 0, &windowed, NULL},
	    {'w', nil, 1, NULL, NULL}, {'h', nil, 1, NULL, NULL},
	    {'u', nil, 1, NULL, NULL}, {'n', nil, 1, NULL, &sdesc},
	    {'i', nil, 1, NULL, &ip}, {'m', nil, 1, NULL, &master},
	    {'p', nil, 1, NULL, &passwd}, {'c', nil, 1, NULL, NULL}};
	OFOptionsParser *optionsParser =
	    [OFOptionsParser parserWithOptions:options];
	OFUnichar option;

	while ((option = [optionsParser nextOption]) != '\0') {
		switch (option) {






		case 'w':
			scr_w = optionsParser.argument.longLongValue;
			break;
		case 'h':
			scr_h = optionsParser.argument.longLongValue;
			break;






		case 'u':
			uprate = optionsParser.argument.longLongValue;
			break;
		case 'c':
			maxcl = optionsParser.argument.longLongValue;
			break;
		case ':':
		case '=':

		case '?':



			conoutf(@"unknown commandline option");
			[OFApplication terminateWithStatus:1];
		}



	}

	if (sdesc == nil)
		sdesc = @"";
	if (ip == nil)
		ip = @"";
	if (passwd == nil)
		passwd = @"";

	if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | par) < 0)
		fatal("Unable to initialize SDL");

	log("net");
	if (enet_initialize() < 0)
		fatal("Unable to initialise network module");

	initclient();
	// never returns if dedicated
	initserver(dedicated, uprate, sdesc.UTF8String, ip.UTF8String,
	    master.UTF8String, passwd, maxcl);

	log("world");
	empty_world(7, true);

	log("video: sdl");
	if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
		fatal("Unable to initialize SDL Video");

	log("video: mode");
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	if (SDL_SetVideoMode(scr_w, scr_h, 0,
	        SDL_OPENGL | (!windowed ? SDL_FULLSCREEN : 0)) == NULL)
		fatal("Unable to create OpenGL screen");

	log("video: misc");
	SDL_WM_SetCaption("cube engine", NULL);
	SDL_WM_GrabInput(SDL_GRAB_ON);
	keyrepeat(false);
	SDL_ShowCursor(0);

Modified src/console.mm from [1df29be187] to [74e953a174].

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
	strn0cpy(hdr.maptitle, s, 128);
};

COMMAND(saycommand, ARG_VARI);
COMMAND(mapmsg, ARG_1STR);

#ifndef _WIN32
#include <SDL_syswm.h>
#include <X11/Xlib.h>
#endif

void
pasteconsole()
{
#ifdef _WIN32
	if (!IsClipboardFormatAvailable(CF_TEXT))







|
|







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
	strn0cpy(hdr.maptitle, s, 128);
};

COMMAND(saycommand, ARG_VARI);
COMMAND(mapmsg, ARG_1STR);

#ifndef _WIN32
# include <SDL_syswm.h>
# include <X11/Xlib.h>
#endif

void
pasteconsole()
{
#ifdef _WIN32
	if (!IsClipboardFormatAvailable(CF_TEXT))

Modified src/cube.h from [7ef12d6e13] to [9f2d7242ba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// one big bad include file for the whole engine... nasty!

#import <ObjFW/ObjFW.h>

#include "tools.h"

@interface Cube: OFObject <OFApplicationDelegate>
@end

enum // block types, order matters!
{
	SOLID = 0, // entirely solid cube [only specifies wtex]
	CORNER,    // half full corner of a wall
	FHF,       // floor heightfield using neighbour vdelta values






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
// one big bad include file for the whole engine... nasty!

#import <ObjFW/ObjFW.h>

#include "tools.h"

@interface Cube : OFObject <OFApplicationDelegate>
@end

enum // block types, order matters!
{
	SOLID = 0, // entirely solid cube [only specifies wtex]
	CORNER,    // half full corner of a wall
	FHF,       // floor heightfield using neighbour vdelta values
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
		});                                                            \
	}                                                                      \
	void var_##name() { body; }

#define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers

#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#define _WINDOWS
#define ZLIB_DLL
#else
#include <dlfcn.h>
#endif

#include <time.h>

#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>







|
|
|
|

|







442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
		});                                                            \
	}                                                                      \
	void var_##name() { body; }

#define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers

#ifdef WIN32
# define WIN32_LEAN_AND_MEAN
# include "windows.h"
# define _WINDOWS
# define ZLIB_DLL
#else
# include <dlfcn.h>
#endif

#include <time.h>

#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>

Modified src/protos.h from [93475710ee] to [615b9acb31].

210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// rendermd2
extern void rendermodel(char *mdl, int frame, int range, int tex, float rad,
    float x, float y, float z, float yaw, float pitch, bool teammate,
    float scale, float speed, int snap = 0, int basetime = 0);
extern mapmodelinfo *getmminfo(int i);

// server
extern void initserver(bool dedicated, int uprate, char *sdesc, char *ip,
    char *master, char *passwd, int maxcl);
extern void cleanupserver();
extern void localconnect();
extern void localdisconnect();
extern void localclienttoserver(struct _ENetPacket *);
extern void serverslice(int seconds, unsigned int timeout);
extern void putint(uchar *&p, int n);
extern int getint(uchar *&p);
extern void sendstring(char *t, uchar *&p);
extern void startintermission();
extern void restoreserverstate(vector<entity> &ents);
extern uchar *retrieveservers(uchar *buf, int buflen);
extern char msgsizelookup(int msg);
extern void serverms(int mode, int numplayers, int minremain, char *smapname,
    int seconds, bool isfull);
extern void servermsinit(const char *master, char *sdesc, bool listen);
extern void sendmaps(int n, string mapname, int mapsize, uchar *mapdata);
extern ENetPacket *recvmap(int n);

// weapon
extern void selectgun(int a = -1, int b = -1, int c = -1);
extern void shoot(dynent *d, vec &to);
extern void shootv(







|
|







|






|







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
// rendermd2
extern void rendermodel(char *mdl, int frame, int range, int tex, float rad,
    float x, float y, float z, float yaw, float pitch, bool teammate,
    float scale, float speed, int snap = 0, int basetime = 0);
extern mapmodelinfo *getmminfo(int i);

// server
extern void initserver(bool dedicated, int uprate, const char *sdesc,
    const char *ip, const char *master, OFString *passwd, int maxcl);
extern void cleanupserver();
extern void localconnect();
extern void localdisconnect();
extern void localclienttoserver(struct _ENetPacket *);
extern void serverslice(int seconds, unsigned int timeout);
extern void putint(uchar *&p, int n);
extern int getint(uchar *&p);
extern void sendstring(const char *t, uchar *&p);
extern void startintermission();
extern void restoreserverstate(vector<entity> &ents);
extern uchar *retrieveservers(uchar *buf, int buflen);
extern char msgsizelookup(int msg);
extern void serverms(int mode, int numplayers, int minremain, char *smapname,
    int seconds, bool isfull);
extern void servermsinit(const char *master, const char *sdesc, bool listen);
extern void sendmaps(int n, string mapname, int mapsize, uchar *mapdata);
extern ENetPacket *recvmap(int n);

// weapon
extern void selectgun(int a = -1, int b = -1, int c = -1);
extern void shoot(dynent *d, vec &to);
extern void shootv(

Modified src/rendergl.mm from [155f47c457] to [a9494ec649].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// rendergl.cpp: core opengl rendering stuff

#include "cube.h"

#ifdef DARWIN
#define GL_COMBINE_EXT GL_COMBINE_ARB
#define GL_COMBINE_RGB_EXT GL_COMBINE_RGB_ARB
#define GL_SOURCE0_RBG_EXT GL_SOURCE0_RGB_ARB
#define GL_SOURCE1_RBG_EXT GL_SOURCE1_RGB_ARB
#define GL_RGB_SCALE_EXT GL_RGB_SCALE_ARB
#endif

extern int curvert;

bool hasoverbright = false;

void purgetextures();





|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// rendergl.cpp: core opengl rendering stuff

#include "cube.h"

#ifdef DARWIN
# define GL_COMBINE_EXT GL_COMBINE_ARB
# define GL_COMBINE_RGB_EXT GL_COMBINE_RGB_ARB
# define GL_SOURCE0_RBG_EXT GL_SOURCE0_RGB_ARB
# define GL_SOURCE1_RBG_EXT GL_SOURCE1_RGB_ARB
# define GL_RGB_SCALE_EXT GL_RGB_SCALE_ARB
#endif

extern int curvert;

bool hasoverbright = false;

void purgetextures();

Modified src/savegamedemo.mm from [5f329655d6] to [7d18bd49dc].

1
2
3
4
5

6



7
8
9
10
11
12
13
// loading and saving of savegames & demos, dumps the spawn state of all
// mapents, the full state of all dynents (monsters + player)

#include "cube.h"


extern int islittleendian;




gzFile f = NULL;
bool demorecording = false;
bool demoplayback = false;
bool demoloading = false;
dvector playerhistory;
int democlientnum = 0;





>
|
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// loading and saving of savegames & demos, dumps the spawn state of all
// mapents, the full state of all dynents (monsters + player)

#include "cube.h"

#ifdef OF_BIG_ENDIAN
static const int islittleendian = 0;
#else
static const int islittleendian = 1;
#endif

gzFile f = NULL;
bool demorecording = false;
bool demoplayback = false;
bool demoloading = false;
dvector playerhistory;
int democlientnum = 0;

Modified src/server.mm from [d64f08d11a] to [9a377d37ce].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
		sents[i].spawnsecs = 0;
	};
};

int interm = 0, minremain = 0, mapend = 0;
bool mapreload = false;

char *serverpassword = "";

bool isdedicated;
ENetHost *serverhost = NULL;
int bsend = 0, brec = 0, laststatus = 0, lastsec = 0;

#define MAXOBUF 100000








|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
		sents[i].spawnsecs = 0;
	};
};

int interm = 0, minremain = 0, mapend = 0;
bool mapreload = false;

static OFString *serverpassword = @"";

bool isdedicated;
ENetHost *serverhost = NULL;
int bsend = 0, brec = 0, laststatus = 0, lastsec = 0;

#define MAXOBUF 100000

304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
	    enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
	uchar *start = packet->data;
	uchar *p = start + 2;
	putint(p, SV_INITS2C);
	putint(p, n);
	putint(p, PROTOCOL_VERSION);
	putint(p, smapname[0]);
	sendstring(serverpassword, p);
	putint(p, clients.length() > maxclients);
	if (smapname[0]) {
		putint(p, SV_MAPCHANGE);
		sendstring(smapname, p);
		putint(p, mode);
		putint(p, SV_ITEMLIST);
		loopv(sents) if (sents[i].spawned) putint(p, i);







|







304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
	    enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
	uchar *start = packet->data;
	uchar *p = start + 2;
	putint(p, SV_INITS2C);
	putint(p, n);
	putint(p, PROTOCOL_VERSION);
	putint(p, smapname[0]);
	sendstring(serverpassword.UTF8String, p);
	putint(p, clients.length() > maxclients);
	if (smapname[0]) {
		putint(p, SV_MAPCHANGE);
		sendstring(smapname, p);
		putint(p, mode);
		putint(p, SV_ITEMLIST);
		loopv(sents) if (sents[i].spawned) putint(p, i);
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
	client &c = addclient();
	c.type = ST_LOCAL;
	strcpy_s(c.hostname, "local");
	send_welcome(&c - &clients[0]);
};

void
initserver(bool dedicated, int uprate, char *sdesc, char *ip, char *master,
    char *passwd, int maxcl)
{
	serverpassword = passwd;
	maxclients = maxcl;
	servermsinit(master ? master : "wouter.fov120.com/cube/masterserver/",
	    sdesc, dedicated);

	if (isdedicated = dedicated) {







|
|







505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
	client &c = addclient();
	c.type = ST_LOCAL;
	strcpy_s(c.hostname, "local");
	send_welcome(&c - &clients[0]);
};

void
initserver(bool dedicated, int uprate, const char *sdesc, const char *ip,
    const char *master, OFString *passwd, int maxcl)
{
	serverpassword = passwd;
	maxclients = maxcl;
	servermsinit(master ? master : "wouter.fov120.com/cube/masterserver/",
	    sdesc, dedicated);

	if (isdedicated = dedicated) {

Modified src/serverms.mm from [c3c33d8055] to [f8b6105f9f].

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
		sendstring(serverdesc, p);
		buf.dataLength = p - pong;
		enet_socket_send(pongsock, &addr, &buf, 1);
	};
};

void
servermsinit(const char *master, char *sdesc, bool listen)
{
	const char *mid = strstr(master, "/");
	if (!mid)
		mid = master;
	strcpy_s(masterpath, mid);
	strn0cpy(masterbase, master, mid - master + 1);
	strcpy_s(serverdesc, sdesc);







|







143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
		sendstring(serverdesc, p);
		buf.dataLength = p - pong;
		enet_socket_send(pongsock, &addr, &buf, 1);
	};
};

void
servermsinit(const char *master, const char *sdesc, bool listen)
{
	const char *mid = strstr(master, "/");
	if (!mid)
		mid = master;
	strcpy_s(masterpath, mid);
	strn0cpy(masterbase, master, mid - master + 1);
	strcpy_s(serverdesc, sdesc);

Modified src/serverutil.mm from [5e922bff35] to [8452aaaef1].

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
		n |= *p++ << 16;
		return n | (*p++ << 24);
	} else
		return c;
};

void
sendstring(char *t, uchar *&p)
{
	while (*t)
		putint(p, *t++);
	putint(p, 0);
};

const char *modenames[] = {







|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
		n |= *p++ << 16;
		return n | (*p++ << 24);
	} else
		return c;
};

void
sendstring(const char *t, uchar *&p)
{
	while (*t)
		putint(p, *t++);
	putint(p, 0);
};

const char *modenames[] = {
180
181
182
183
184
185
186
187
188
189

190
			default:
				printf("WARNING: unknown commandline option\n");
			};
	};

	if (enet_initialize() < 0)
		fatal("Unable to initialise network module");
	initserver(true, uprate, sdesc, ip, master, passwd, maxcl);
	return 0;
};

#endif







|

<
>

180
181
182
183
184
185
186
187
188

189
190
			default:
				printf("WARNING: unknown commandline option\n");
			};
	};

	if (enet_initialize() < 0)
		fatal("Unable to initialise network module");
	initserver(true, uprate, sdesc, ip, master, @(passwd), maxcl);
	return 0;

}
#endif

Modified src/sound.mm from [da17c5965d] to [1b753dcafe].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

struct soundloc {
	vec loc;
	bool inuse;
} soundlocs[MAXCHAN];

#ifdef USE_MIXER
#include "SDL_mixer.h"
#define MAXVOL MIX_MAX_VOLUME
Mix_Music *mod = NULL;
void *stream = NULL;
#else
#include "fmod.h"
#define MAXVOL 255
FMUSIC_MODULE *mod = NULL;
FSOUND_STREAM *stream = NULL;
#endif

void
stopsound()
{







|
|



|
|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

struct soundloc {
	vec loc;
	bool inuse;
} soundlocs[MAXCHAN];

#ifdef USE_MIXER
# include "SDL_mixer.h"
# define MAXVOL MIX_MAX_VOLUME
Mix_Music *mod = NULL;
void *stream = NULL;
#else
# include "fmod.h"
# define MAXVOL 255
FMUSIC_MODULE *mod = NULL;
FSOUND_STREAM *stream = NULL;
#endif

void
stopsound()
{

Modified src/tools.h from [5a12c43f73] to [900cc870ab].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// generic useful stuff for any C++ program

#ifndef _TOOLS_H
#define _TOOLS_H

#ifdef __GNUC__
#define gamma __gamma
#endif

#include <math.h>

#ifdef __GNUC__
#undef gamma
#endif

#include <assert.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __GNUC__
#include <new>
#else
#include <new.h>
#endif

#ifdef NULL
#undef NULL
#endif
#define NULL 0

typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;







|





|









|

|



|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// generic useful stuff for any C++ program

#ifndef _TOOLS_H
#define _TOOLS_H

#ifdef __GNUC__
# define gamma __gamma
#endif

#include <math.h>

#ifdef __GNUC__
# undef gamma
#endif

#include <assert.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __GNUC__
# include <new>
#else
# include <new.h>
#endif

#ifdef NULL
# undef NULL
#endif
#define NULL 0

typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define loop(v, m) for (int v = 0; v < (m); v++)
#define loopi(m) loop(i, m)
#define loopj(m) loop(j, m)
#define loopk(m) loop(k, m)
#define loopl(m) loop(l, m)

#ifdef WIN32
#pragma warning(3 : 4189)
// #pragma comment(linker,"/OPT:NOWIN98")
#define PATHDIV '\\'
#else
#define __cdecl
#define _vsnprintf vsnprintf
#define PATHDIV '/'
#endif

// easy safe strings

#define _MAXDEFSTR 260
typedef char string[_MAXDEFSTR];








|

|

|
|
|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define loop(v, m) for (int v = 0; v < (m); v++)
#define loopi(m) loop(i, m)
#define loopj(m) loop(j, m)
#define loopk(m) loop(k, m)
#define loopl(m) loop(l, m)

#ifdef WIN32
# pragma warning(3 : 4189)
// #pragma comment(linker,"/OPT:NOWIN98")
# define PATHDIV '\\'
#else
# define __cdecl
# define _vsnprintf vsnprintf
# define PATHDIV '/'
#endif

// easy safe strings

#define _MAXDEFSTR 260
typedef char string[_MAXDEFSTR];

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	int retval;

	__asm fld a __asm fsub fhalf __asm fistp retval // perf regalloc?

	    return retval;
};
#else
#define fast_f2nat(val) ((int)(val))
#endif

extern char *path(char *s);
extern char *loadfile(char *fn, int *size);
extern void endianswap(void *, int, int);

// memory pool that uses buckets and linear allocation for small objects







|







126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	int retval;

	__asm fld a __asm fsub fhalf __asm fistp retval // perf regalloc?

	    return retval;
};
#else
# define fast_f2nat(val) ((int)(val))
#endif

extern char *path(char *s);
extern char *loadfile(char *fn, int *size);
extern void endianswap(void *, int, int);

// memory pool that uses buckets and linear allocation for small objects