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 () { ...@@ -209,7 +209,7 @@ int Game::play () {
} }
planet = NULL; planet = NULL;
fileName = createFileName(F_PLANET, levelFile + strlen(levelFile) - 3); fileName = createFileName(F_PLANET, level->getWorld());
try { try {
......
...@@ -176,6 +176,13 @@ bool Level::checkSpikes (fixed x, fixed y) { ...@@ -176,6 +176,13 @@ bool Level::checkSpikes (fixed x, fixed y) {
} }
int Level::getWorld() {
return worldNum;
}
void Level::setNext (int nextLevel, int nextWorld) { void Level::setNext (int nextLevel, int nextWorld) {
......
...@@ -142,7 +142,8 @@ class Level : public BaseLevel { ...@@ -142,7 +142,8 @@ class Level : public BaseLevel {
bool checkMaskUp (fixed x, fixed y); bool checkMaskUp (fixed x, fixed y);
bool checkMaskDown (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 setNext (int nextLevel, int nextWorld);
void setTile (unsigned char gridX, unsigned char gridY, unsigned char tile); void setTile (unsigned char gridX, unsigned char gridY, unsigned char tile);
Event* getEvents (); Event* getEvents ();
......
...@@ -469,21 +469,25 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) { ...@@ -469,21 +469,25 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
file = new File(string, false); file = new File(string, false);
} catch (int e) { } catch (int e) {
delete[] string; file = NULL;
deletePanel();
delete font;
return e;
} }
delete[] string; delete[] string;
if (file) {
file->seek(2, true); file->seek(2, true);
string = file->loadString(); 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) { ...@@ -580,20 +584,13 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
// Load tile set extension // Load tile set extension
file->seek(8, false); file->seek(8, false);
ext = file->loadString(); 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")) { delete[] ext;
// 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;
tiles = loadTiles(string); tiles = loadTiles(string);
delete[] 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