diff --git a/src/Cube.mm b/src/Cube.mm index 6621caa..a91d05c 100644 --- a/src/Cube.mm +++ b/src/Cube.mm @@ -135,37 +135,37 @@ VARP(minmillis, 0, 5, 1000); log(@"basetex"); int xs, ys; if (!installtex(2, - [_userDataIRI IRIByAppendingPathComponent:@"data/newchars.png"], + [_gameDataIRI IRIByAppendingPathComponent:@"data/newchars.png"], &xs, &ys, false) || !installtex(3, - [_userDataIRI + [_gameDataIRI IRIByAppendingPathComponent:@"data/martin/base.png"], &xs, &ys, false) || !installtex(6, - [_userDataIRI + [_gameDataIRI IRIByAppendingPathComponent:@"data/martin/ball1.png"], &xs, &ys, false) || !installtex(7, - [_userDataIRI + [_gameDataIRI IRIByAppendingPathComponent:@"data/martin/smoke.png"], &xs, &ys, false) || !installtex(8, - [_userDataIRI + [_gameDataIRI IRIByAppendingPathComponent:@"data/martin/ball2.png"], &xs, &ys, false) || !installtex(9, - [_userDataIRI + [_gameDataIRI IRIByAppendingPathComponent:@"data/martin/ball3.png"], &xs, &ys, false) || !installtex(4, - [_userDataIRI + [_gameDataIRI IRIByAppendingPathComponent:@"data/explosion.jpg"], &xs, &ys, false) || !installtex(5, - [_userDataIRI IRIByAppendingPathComponent:@"data/items.png"], + [_gameDataIRI IRIByAppendingPathComponent:@"data/items.png"], &xs, &ys, false) || !installtex(1, - [_userDataIRI + [_gameDataIRI IRIByAppendingPathComponent:@"data/crosshair.png"], &xs, &ys, false)) 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/sounds.cfg"); exec(@"servers.cfg"); - if (!execfile(@"config.cfg")) - execfile(@"data/defaults.cfg"); + if (!execfile([_userDataIRI IRIByAppendingPathComponent:@"config.cfg"])) + execfile([_gameDataIRI + IRIByAppendingPathComponent:@"data/defaults.cfg"]); exec(@"autoexec.cfg"); log(@"localconnect"); diff --git a/src/commands.mm b/src/commands.mm index 0ff794a..914074f 100644 --- a/src/commands.mm +++ b/src/commands.mm @@ -338,13 +338,15 @@ complete(OFString *s_) } bool -execfile(OFString *cfgfile) +execfile(OFIRI *cfgfile) { @autoreleasepool { OFString *command; @try { - command = [OFString stringWithContentsOfFile:cfgfile]; - } @catch (id e) { + command = [OFString stringWithContentsOfIRI:cfgfile]; + } @catch (OFOpenItemFailedException *e) { + return false; + } @catch (OFReadFailedException *e) { return false; } @@ -356,10 +358,12 @@ execfile(OFString *cfgfile) void 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); - } } } diff --git a/src/protos.h b/src/protos.h index 441dae7..e9f2ff5 100644 --- a/src/protos.h +++ b/src/protos.h @@ -9,7 +9,7 @@ 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 bool execfile(OFIRI *cfgfile); extern void resetcomplete(); extern void complete(OFString *s); extern void alias(OFString *name, OFString *action); diff --git a/src/worldio.mm b/src/worldio.mm index dc9f70b..78cf767 100644 --- a/src/worldio.mm +++ b/src/worldio.mm @@ -384,8 +384,10 @@ load_world(OFString *mname) // still supports all map formats that have existed if (identexists(aliasname)) alias(aliasname, @""); } - execfile(@"data/default_map_settings.cfg"); - execfile(pcfname); - execfile(mcfname); + OFIRI *gameDataIRI = Cube.sharedInstance.gameDataIRI; + execfile([gameDataIRI IRIByAppendingPathComponent: + @"data/default_map_settings.cfg"]); + execfile([gameDataIRI IRIByAppendingPathComponent:pcfname]); + execfile([gameDataIRI IRIByAppendingPathComponent:mcfname]); } }