Cube  Diff

Differences From Artifact [1c90efecc5]:

To Artifact [f393e63c6d]:


31
32
33
34
35
36
37
38

39

40


41
42

43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
31
32
33
34
35
36
37

38
39
40

41
42
43

44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60







-
+

+
-
+
+

-
+








-
+







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

void
fatal(char *s, char *o) // failure exit
fatal(OFString *s, OFString *o) // failure exit
{
	OFString *msg =
	sprintf_sd(msg)("%s%s (%s)\n", s, o, SDL_GetError());
	    [OFString stringWithFormat:@"%@%@ (%s)\n", s, o, SDL_GetError()];

	OFApplication *app = OFApplication.sharedApplication;
	[(Cube *)app.delegate showMessage:@(msg)];
	[(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)
		fatal("out of memory!");
		fatal(@"out of memory!");
	return b;
}

int scr_w = 640;
int scr_h = 480;

void
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
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







-
+



-
+











-
+





-
+







		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");
		fatal(@"Unable to initialize SDL");

	log("net");
	if (enet_initialize() < 0)
		fatal("Unable to initialise network module");
		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");
		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");
		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);

191
192
193
194
195
196
197
198
199


200
201
202
203
204
205
206
193
194
195
196
197
198
199


200
201
202
203
204
205
206
207
208







-
-
+
+







	    !installtex(6, path(newstring("data/martin/ball1.png")), xs, ys) ||
	    !installtex(7, path(newstring("data/martin/smoke.png")), xs, ys) ||
	    !installtex(8, path(newstring("data/martin/ball2.png")), xs, ys) ||
	    !installtex(9, path(newstring("data/martin/ball3.png")), xs, ys) ||
	    !installtex(4, path(newstring("data/explosion.jpg")), xs, ys) ||
	    !installtex(5, path(newstring("data/items.png")), xs, ys) ||
	    !installtex(1, path(newstring("data/crosshair.png")), xs, ys))
		fatal("could not find core textures (hint: run cube from the "
		      "parent of the bin directory)");
		fatal(@"could not find core textures (hint: run cube from the "
		      @"parent of the bin directory)");

	log("sound");
	initsound();

	log("cfg");
	newmenu(@"frags\tpj\tping\tteam\tname");
	newmenu(@"ping\tplr\tserver");