Cube  Check-in [d751d8b0b7]

Overview
Comment:Clean up user data vs. game data
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d751d8b0b7ca39f458acf12116633d5ebdae0976c8241cf419b49510990f3268
User & Date: js on 2025-03-09 00:39:50
Other Links: manifest | tags
Context
2025-03-09
00:56
More string cleanups check-in: 3e5cb10d19 user: js tags: trunk
00:39
Clean up user data vs. game data check-in: d751d8b0b7 user: js tags: trunk
00:27
commands.mm: Remove stray break check-in: b8dd9a3d27 user: js tags: trunk
Changes

Modified src/Cube.mm from [4d1b18c94e] to [97e527d1c0].

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

	log(@"gl");
	gl_init(_width, _height);

	log(@"basetex");
	int xs, ys;
	if (!installtex(2,
	        [_userDataIRI IRIByAppendingPathComponent:@"data/newchars.png"],
	        &xs, &ys, false) ||
	    !installtex(3,
	        [_userDataIRI
	            IRIByAppendingPathComponent:@"data/martin/base.png"],
	        &xs, &ys, false) ||
	    !installtex(6,
	        [_userDataIRI
	            IRIByAppendingPathComponent:@"data/martin/ball1.png"],
	        &xs, &ys, false) ||
	    !installtex(7,
	        [_userDataIRI
	            IRIByAppendingPathComponent:@"data/martin/smoke.png"],
	        &xs, &ys, false) ||
	    !installtex(8,
	        [_userDataIRI
	            IRIByAppendingPathComponent:@"data/martin/ball2.png"],
	        &xs, &ys, false) ||
	    !installtex(9,
	        [_userDataIRI
	            IRIByAppendingPathComponent:@"data/martin/ball3.png"],
	        &xs, &ys, false) ||
	    !installtex(4,
	        [_userDataIRI
	            IRIByAppendingPathComponent:@"data/explosion.jpg"],
	        &xs, &ys, false) ||
	    !installtex(5,
	        [_userDataIRI IRIByAppendingPathComponent:@"data/items.png"],
	        &xs, &ys, false) ||
	    !installtex(1,
	        [_userDataIRI
	            IRIByAppendingPathComponent:@"data/crosshair.png"],
	        &xs, &ys, false))
		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");
	exec(@"data/keymap.cfg");
	exec(@"data/menus.cfg");
	exec(@"data/prefabs.cfg");
	exec(@"data/sounds.cfg");
	exec(@"servers.cfg");

	if (!execfile(@"config.cfg"))
		execfile(@"data/defaults.cfg");
	exec(@"autoexec.cfg");

	log(@"localconnect");
	localconnect();
	// if this map is changed, also change depthcorrect()
	changemap(@"metl3");








|


|



|



|



|



|



|



|


|
















>
|
|







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

	log(@"gl");
	gl_init(_width, _height);

	log(@"basetex");
	int xs, ys;
	if (!installtex(2,
	        [_gameDataIRI IRIByAppendingPathComponent:@"data/newchars.png"],
	        &xs, &ys, false) ||
	    !installtex(3,
	        [_gameDataIRI
	            IRIByAppendingPathComponent:@"data/martin/base.png"],
	        &xs, &ys, false) ||
	    !installtex(6,
	        [_gameDataIRI
	            IRIByAppendingPathComponent:@"data/martin/ball1.png"],
	        &xs, &ys, false) ||
	    !installtex(7,
	        [_gameDataIRI
	            IRIByAppendingPathComponent:@"data/martin/smoke.png"],
	        &xs, &ys, false) ||
	    !installtex(8,
	        [_gameDataIRI
	            IRIByAppendingPathComponent:@"data/martin/ball2.png"],
	        &xs, &ys, false) ||
	    !installtex(9,
	        [_gameDataIRI
	            IRIByAppendingPathComponent:@"data/martin/ball3.png"],
	        &xs, &ys, false) ||
	    !installtex(4,
	        [_gameDataIRI
	            IRIByAppendingPathComponent:@"data/explosion.jpg"],
	        &xs, &ys, false) ||
	    !installtex(5,
	        [_gameDataIRI IRIByAppendingPathComponent:@"data/items.png"],
	        &xs, &ys, false) ||
	    !installtex(1,
	        [_gameDataIRI
	            IRIByAppendingPathComponent:@"data/crosshair.png"],
	        &xs, &ys, false))
		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");
	exec(@"data/keymap.cfg");
	exec(@"data/menus.cfg");
	exec(@"data/prefabs.cfg");
	exec(@"data/sounds.cfg");
	exec(@"servers.cfg");
	if (!execfile([_userDataIRI IRIByAppendingPathComponent:@"config.cfg"]))
		execfile([_gameDataIRI
		    IRIByAppendingPathComponent:@"data/defaults.cfg"]);
	exec(@"autoexec.cfg");

	log(@"localconnect");
	localconnect();
	// if this map is changed, also change depthcorrect()
	changemap(@"metl3");

Modified src/commands.mm from [0afcae2b92] to [e9d197474b].

334
335
336
337
338
339
340
341
342
343
344
345
346


347
348
349
350
351
352
353
354
355
356
357
358
359
360




361
362
363
364
365
366
367
368
369

		if (completeidx >= idx)
			completeidx = 0;
	}
}

bool
execfile(OFString *cfgfile)
{
	@autoreleasepool {
		OFString *command;
		@try {
			command = [OFString stringWithContentsOfFile:cfgfile];


		} @catch (id e) {
			return false;
		}

		execute(command);
		return true;
	}
}

void
exec(OFString *cfgfile)
{
	if (!execfile(cfgfile)) {
		@autoreleasepool {




			conoutf(@"could not read \"%@\"", cfgfile);
		}
	}
}

void
writecfg()
{
	OFStream *stream;







|




|
>
>
|











<
|
>
>
>
>

<







334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360

361
362
363
364
365
366

367
368
369
370
371
372
373

		if (completeidx >= idx)
			completeidx = 0;
	}
}

bool
execfile(OFIRI *cfgfile)
{
	@autoreleasepool {
		OFString *command;
		@try {
			command = [OFString stringWithContentsOfIRI:cfgfile];
		} @catch (OFOpenItemFailedException *e) {
			return false;
		} @catch (OFReadFailedException *e) {
			return false;
		}

		execute(command);
		return true;
	}
}

void
exec(OFString *cfgfile)
{

	@autoreleasepool {
		if (!execfile([Cube.sharedInstance.userDataIRI
		        IRIByAppendingPathComponent:cfgfile]) &&
		    !execfile([Cube.sharedInstance.gameDataIRI
		        IRIByAppendingPathComponent:cfgfile]))
			conoutf(@"could not read \"%@\"", cfgfile);

	}
}

void
writecfg()
{
	OFStream *stream;

Modified src/protos.h from [10883ae4ba] to [ad3320c1d0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// protos for ALL external functions in cube...

// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
    void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(OFString *p, bool down = true);
extern void exec(OFString *cfgfile);
extern bool execfile(OFString *cfgfile);
extern void resetcomplete();
extern void complete(OFString *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();

// console











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// protos for ALL external functions in cube...

// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
    void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(OFString *p, bool down = true);
extern void exec(OFString *cfgfile);
extern bool execfile(OFIRI *cfgfile);
extern void resetcomplete();
extern void complete(OFString *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();

// console

Modified src/worldio.mm from [abb1a9a463] to [764e555a48].

380
381
382
383
384
385
386


387
388
389
390
391
		{
			// can this be done smarter?
			OFString *aliasname =
			    [OFString stringWithFormat:@"level_trigger_%d", l];
			if (identexists(aliasname))
				alias(aliasname, @"");
		}


		execfile(@"data/default_map_settings.cfg");
		execfile(pcfname);
		execfile(mcfname);
	}
}







>
>
|
|
|


380
381
382
383
384
385
386
387
388
389
390
391
392
393
		{
			// can this be done smarter?
			OFString *aliasname =
			    [OFString stringWithFormat:@"level_trigger_%d", l];
			if (identexists(aliasname))
				alias(aliasname, @"");
		}
		OFIRI *gameDataIRI = Cube.sharedInstance.gameDataIRI;
		execfile([gameDataIRI IRIByAppendingPathComponent:
		                          @"data/default_map_settings.cfg"]);
		execfile([gameDataIRI IRIByAppendingPathComponent:pcfname]);
		execfile([gameDataIRI IRIByAppendingPathComponent:mcfname]);
	}
}