Clean up user data vs. game data
FossilOrigin-Name: d751d8b0b7ca39f458acf12116633d5ebdae0976c8241cf419b49510990f3268
This commit is contained in:
parent
2cd917c394
commit
095af0a1e7
4 changed files with 28 additions and 21 deletions
23
src/Cube.mm
23
src/Cube.mm
|
@ -135,37 +135,37 @@ VARP(minmillis, 0, 5, 1000);
|
||||||
log(@"basetex");
|
log(@"basetex");
|
||||||
int xs, ys;
|
int xs, ys;
|
||||||
if (!installtex(2,
|
if (!installtex(2,
|
||||||
[_userDataIRI IRIByAppendingPathComponent:@"data/newchars.png"],
|
[_gameDataIRI IRIByAppendingPathComponent:@"data/newchars.png"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(3,
|
!installtex(3,
|
||||||
[_userDataIRI
|
[_gameDataIRI
|
||||||
IRIByAppendingPathComponent:@"data/martin/base.png"],
|
IRIByAppendingPathComponent:@"data/martin/base.png"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(6,
|
!installtex(6,
|
||||||
[_userDataIRI
|
[_gameDataIRI
|
||||||
IRIByAppendingPathComponent:@"data/martin/ball1.png"],
|
IRIByAppendingPathComponent:@"data/martin/ball1.png"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(7,
|
!installtex(7,
|
||||||
[_userDataIRI
|
[_gameDataIRI
|
||||||
IRIByAppendingPathComponent:@"data/martin/smoke.png"],
|
IRIByAppendingPathComponent:@"data/martin/smoke.png"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(8,
|
!installtex(8,
|
||||||
[_userDataIRI
|
[_gameDataIRI
|
||||||
IRIByAppendingPathComponent:@"data/martin/ball2.png"],
|
IRIByAppendingPathComponent:@"data/martin/ball2.png"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(9,
|
!installtex(9,
|
||||||
[_userDataIRI
|
[_gameDataIRI
|
||||||
IRIByAppendingPathComponent:@"data/martin/ball3.png"],
|
IRIByAppendingPathComponent:@"data/martin/ball3.png"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(4,
|
!installtex(4,
|
||||||
[_userDataIRI
|
[_gameDataIRI
|
||||||
IRIByAppendingPathComponent:@"data/explosion.jpg"],
|
IRIByAppendingPathComponent:@"data/explosion.jpg"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(5,
|
!installtex(5,
|
||||||
[_userDataIRI IRIByAppendingPathComponent:@"data/items.png"],
|
[_gameDataIRI IRIByAppendingPathComponent:@"data/items.png"],
|
||||||
&xs, &ys, false) ||
|
&xs, &ys, false) ||
|
||||||
!installtex(1,
|
!installtex(1,
|
||||||
[_userDataIRI
|
[_gameDataIRI
|
||||||
IRIByAppendingPathComponent:@"data/crosshair.png"],
|
IRIByAppendingPathComponent:@"data/crosshair.png"],
|
||||||
&xs, &ys, false))
|
&xs, &ys, false))
|
||||||
fatal(@"could not find core textures (hint: run cube from the "
|
fatal(@"could not find core textures (hint: run cube from the "
|
||||||
|
@ -182,8 +182,9 @@ VARP(minmillis, 0, 5, 1000);
|
||||||
exec(@"data/prefabs.cfg");
|
exec(@"data/prefabs.cfg");
|
||||||
exec(@"data/sounds.cfg");
|
exec(@"data/sounds.cfg");
|
||||||
exec(@"servers.cfg");
|
exec(@"servers.cfg");
|
||||||
if (!execfile(@"config.cfg"))
|
if (!execfile([_userDataIRI IRIByAppendingPathComponent:@"config.cfg"]))
|
||||||
execfile(@"data/defaults.cfg");
|
execfile([_gameDataIRI
|
||||||
|
IRIByAppendingPathComponent:@"data/defaults.cfg"]);
|
||||||
exec(@"autoexec.cfg");
|
exec(@"autoexec.cfg");
|
||||||
|
|
||||||
log(@"localconnect");
|
log(@"localconnect");
|
||||||
|
|
|
@ -338,13 +338,15 @@ complete(OFString *s_)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
execfile(OFString *cfgfile)
|
execfile(OFIRI *cfgfile)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
OFString *command;
|
OFString *command;
|
||||||
@try {
|
@try {
|
||||||
command = [OFString stringWithContentsOfFile:cfgfile];
|
command = [OFString stringWithContentsOfIRI:cfgfile];
|
||||||
} @catch (id e) {
|
} @catch (OFOpenItemFailedException *e) {
|
||||||
|
return false;
|
||||||
|
} @catch (OFReadFailedException *e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,11 +358,13 @@ execfile(OFString *cfgfile)
|
||||||
void
|
void
|
||||||
exec(OFString *cfgfile)
|
exec(OFString *cfgfile)
|
||||||
{
|
{
|
||||||
if (!execfile(cfgfile)) {
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
if (!execfile([Cube.sharedInstance.userDataIRI
|
||||||
|
IRIByAppendingPathComponent:cfgfile]) &&
|
||||||
|
!execfile([Cube.sharedInstance.gameDataIRI
|
||||||
|
IRIByAppendingPathComponent:cfgfile]))
|
||||||
conoutf(@"could not read \"%@\"", cfgfile);
|
conoutf(@"could not read \"%@\"", cfgfile);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -9,7 +9,7 @@ extern bool identexists(OFString *name);
|
||||||
extern bool addcommand(OFString *name, void (*fun)(), int narg);
|
extern bool addcommand(OFString *name, void (*fun)(), int narg);
|
||||||
extern int execute(OFString *p, bool down = true);
|
extern int execute(OFString *p, bool down = true);
|
||||||
extern void exec(OFString *cfgfile);
|
extern void exec(OFString *cfgfile);
|
||||||
extern bool execfile(OFString *cfgfile);
|
extern bool execfile(OFIRI *cfgfile);
|
||||||
extern void resetcomplete();
|
extern void resetcomplete();
|
||||||
extern void complete(OFString *s);
|
extern void complete(OFString *s);
|
||||||
extern void alias(OFString *name, OFString *action);
|
extern void alias(OFString *name, OFString *action);
|
||||||
|
|
|
@ -384,8 +384,10 @@ load_world(OFString *mname) // still supports all map formats that have existed
|
||||||
if (identexists(aliasname))
|
if (identexists(aliasname))
|
||||||
alias(aliasname, @"");
|
alias(aliasname, @"");
|
||||||
}
|
}
|
||||||
execfile(@"data/default_map_settings.cfg");
|
OFIRI *gameDataIRI = Cube.sharedInstance.gameDataIRI;
|
||||||
execfile(pcfname);
|
execfile([gameDataIRI IRIByAppendingPathComponent:
|
||||||
execfile(mcfname);
|
@"data/default_map_settings.cfg"]);
|
||||||
|
execfile([gameDataIRI IRIByAppendingPathComponent:pcfname]);
|
||||||
|
execfile([gameDataIRI IRIByAppendingPathComponent:mcfname]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue