Commit 11f2edb4 authored by alistert's avatar alistert

JJ1 levels can now have any file name.

parent 583c31c2
......@@ -209,7 +209,7 @@ int Game::play () {
}
planet = NULL;
fileName = createFileName(F_PLANET, levelFile + strlen(levelFile) - 3);
fileName = createFileName(F_PLANET, level->getWorld());
try {
......
......@@ -176,6 +176,13 @@ bool Level::checkSpikes (fixed x, fixed y) {
}
int Level::getWorld() {
return worldNum;
}
void Level::setNext (int nextLevel, int nextWorld) {
......
......@@ -142,7 +142,8 @@ class Level : public BaseLevel {
bool checkMaskUp (fixed x, fixed y);
bool checkMaskDown (fixed x, fixed y);
bool checkSpikes (fixed x, fixed y);
bool checkSpikes (fixed x, fixed y);
int getWorld ();
void setNext (int nextLevel, int nextWorld);
void setTile (unsigned char gridX, unsigned char gridY, unsigned char tile);
Event* getEvents ();
......
......@@ -469,21 +469,25 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
file = new File(string, false);
} catch (int e) {
delete[] string;
deletePanel();
delete font;
return e;
file = NULL;
}
delete[] string;
if (file) {
file->seek(2, true);
string = file->loadString();
file->seek(2, true);
string = file->loadString();
delete file;
delete file;
} else {
string = createString("CUSTOM");
}
}
......@@ -580,20 +584,13 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
// Load tile set extension
file->seek(8, false);
ext = file->loadString();
// Create tile set file name
if (!strcmp(ext, "999")) string = createFileName(F_BLOCKS, worldNum);
else string = createFileName(F_BLOCKS, ext);
if (!strcmp(ext, "999")) {
// Use the level file's extension instead
delete[] ext;
ext = createString(fileName + strlen(fileName) - 3);
}
// Allocate space for file names
string = createFileName(F_BLOCKS, ext);
delete[] ext;
delete[] ext;
tiles = loadTiles(string);
delete[] string;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment