mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Prioritize loading processed script names
This makes it so that whenever the game loads a script as directed by a script command, it will first try to load the script from the processed argument, and if that fails only then will it try to load the script from the raw argument. This fixes a regression reported by Dav999 in the custom level "Vungeon" created by Dynaboom, where a script `ifflag`s to `aselectP1.1` even though the actual script name is `aselectp1.1`. In 2.3, it would lowercase `aselectP1.1` and load the script properly, but previous to this commit it would try to load the script with a capital name and then fail.
This commit is contained in:
parent
fbe613ce5c
commit
6665f4f8f6
3 changed files with 32 additions and 20 deletions
|
@ -231,7 +231,7 @@ void scriptclass::run(void)
|
|||
const RoomProperty* const room = cl.getroomprop(ss_toi(words[1])-1, ss_toi(words[2])-1);
|
||||
if (room->warpdir == ss_toi(words[3]))
|
||||
{
|
||||
load("custom_" + raw_words[4]);
|
||||
loadalts("custom_" + words[4], "custom_" + raw_words[4]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (game.trinkets() >= ss_toi(words[1]))
|
||||
{
|
||||
load("custom_" + raw_words[2]);
|
||||
loadalts("custom_" + words[2], "custom_" + raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (game.trinkets() < ss_toi(words[1]))
|
||||
{
|
||||
load("custom_" + raw_words[2]);
|
||||
loadalts("custom_" + words[2], "custom_" + raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ void scriptclass::run(void)
|
|||
int flag = ss_toi(words[1]);
|
||||
if (INBOUNDS_ARR(flag, obj.flags) && obj.flags[flag])
|
||||
{
|
||||
load("custom_" + raw_words[2]);
|
||||
loadalts("custom_" + words[2], "custom_" + raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1189,7 +1189,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (map.isexplored(ss_toi(words[1]), ss_toi(words[2])))
|
||||
{
|
||||
load(raw_words[3]);
|
||||
loadalts(words[3], raw_words[3]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1197,7 +1197,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (game.lastsaved==ss_toi(words[1]))
|
||||
{
|
||||
load(raw_words[2]);
|
||||
loadalts(words[2], raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1205,7 +1205,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (game.nocutscenes)
|
||||
{
|
||||
load(raw_words[1]);
|
||||
loadalts(words[1], raw_words[1]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1214,7 +1214,7 @@ void scriptclass::run(void)
|
|||
int flag = ss_toi(words[1]);
|
||||
if (INBOUNDS_ARR(flag, obj.flags) && obj.flags[flag])
|
||||
{
|
||||
load(raw_words[2]);
|
||||
loadalts(words[2], raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1223,7 +1223,7 @@ void scriptclass::run(void)
|
|||
int crewmate = ss_toi(words[1]);
|
||||
if (INBOUNDS_ARR(crewmate, game.crewstats) && !game.crewstats[crewmate])
|
||||
{
|
||||
load(raw_words[2]);
|
||||
loadalts(words[2], raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (game.trinkets() >= ss_toi(words[1]))
|
||||
{
|
||||
load(raw_words[2]);
|
||||
loadalts(words[2], raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1239,7 +1239,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (game.stat_trinkets < ss_toi(words[1]))
|
||||
{
|
||||
load(raw_words[2]);
|
||||
loadalts(words[2], raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -1413,7 +1413,7 @@ void scriptclass::run(void)
|
|||
}
|
||||
else if (words[0] == "loadscript")
|
||||
{
|
||||
load(raw_words[1]);
|
||||
loadalts(words[1], raw_words[1]);
|
||||
position--;
|
||||
}
|
||||
else if (words[0] == "rollcredits")
|
||||
|
@ -2414,7 +2414,7 @@ void scriptclass::run(void)
|
|||
{
|
||||
if (loc::lang == words[1])
|
||||
{
|
||||
load("custom_" + raw_words[2]);
|
||||
loadalts("custom_" + words[2], "custom_" + raw_words[2]);
|
||||
position--;
|
||||
}
|
||||
}
|
||||
|
@ -3226,7 +3226,7 @@ void scriptclass::hardreset(void)
|
|||
obj.customactivitypositiony = -1;
|
||||
}
|
||||
|
||||
void scriptclass::loadcustom(const std::string& t)
|
||||
bool scriptclass::loadcustom(const std::string& t)
|
||||
{
|
||||
//this magic function breaks down the custom script and turns into real scripting!
|
||||
std::string cscriptname="";
|
||||
|
@ -3246,7 +3246,7 @@ void scriptclass::loadcustom(const std::string& t)
|
|||
}
|
||||
}
|
||||
if(contents == NULL){
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string>& lines = *contents;
|
||||
|
@ -3514,6 +3514,17 @@ void scriptclass::loadcustom(const std::string& t)
|
|||
add("endcutscene()");
|
||||
add("untilbars()");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void scriptclass::loadalts(const std::string& processed, const std::string& raw)
|
||||
{
|
||||
const bool exists = load(processed);
|
||||
if (!exists)
|
||||
{
|
||||
load(raw);
|
||||
}
|
||||
}
|
||||
|
||||
void scriptclass::add_test_line(const std::string& speaker, const std::string& english, char textcase)
|
||||
|
|
|
@ -63,9 +63,10 @@ public:
|
|||
|
||||
scriptclass(void);
|
||||
|
||||
void load(const std::string& name);
|
||||
bool load(const std::string& name);
|
||||
void loadother(const char* t);
|
||||
void loadcustom(const std::string& t);
|
||||
bool loadcustom(const std::string& t);
|
||||
void loadalts(const std::string& processed, const std::string& raw);
|
||||
|
||||
void add_test_line(const std::string& speaker, const std::string& english, char textcase);
|
||||
void loadtest(const std::string& name);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
void scriptclass::load(const std::string& name)
|
||||
bool scriptclass::load(const std::string& name)
|
||||
{
|
||||
//loads script name t into the array
|
||||
position = 0;
|
||||
|
@ -14,7 +14,7 @@ void scriptclass::load(const std::string& name)
|
|||
|
||||
if (SDL_strncmp(t, "custom_", 7) == 0)
|
||||
{
|
||||
loadcustom(name);
|
||||
return loadcustom(name);
|
||||
}
|
||||
else if (SDL_strcmp(t, "intro") == 0)
|
||||
{
|
||||
|
@ -420,7 +420,6 @@ void scriptclass::load(const std::string& name)
|
|||
"untilbars()",
|
||||
};
|
||||
filllines(lines);
|
||||
return;
|
||||
}
|
||||
if (SDL_strcmp(t, "communicationstation") == 0)
|
||||
{
|
||||
|
@ -6763,4 +6762,5 @@ void scriptclass::load(const std::string& name)
|
|||
loadother(t);
|
||||
}
|
||||
|
||||
return !commands.empty();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue