1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Actually finally fix createentity default args

Third time's the charm.

The fundamental problem with the previous attempts was that they ended
up saying arguments existed due to stale `words` anyway. So to actually
know if an argument exists or not, we need to assign to `argexists` _as_
we parse the line.

And make sure to take care of that last argument too.

Also I thoroughly tested this this time around. I'm done pulling my hair
out over this.
This commit is contained in:
Misa 2021-08-21 19:55:16 -07:00
parent 01ae5c6c70
commit 749a885d9a

View file

@ -46,12 +46,15 @@ void scriptclass::tokenize( const std::string& t )
std::string tempword; std::string tempword;
char currentletter; char currentletter;
SDL_zeroa(argexists);
for (size_t i = 0; i < t.length(); i++) for (size_t i = 0; i < t.length(); i++)
{ {
currentletter = t[i]; currentletter = t[i];
if (currentletter == '(' || currentletter == ')' || currentletter == ',') if (currentletter == '(' || currentletter == ')' || currentletter == ',')
{ {
words[j] = tempword; words[j] = tempword;
argexists[j] = words[j] != "";
for (size_t ii = 0; ii < words[j].length(); ii++) for (size_t ii = 0; ii < words[j].length(); ii++)
{ {
words[j][ii] = SDL_tolower(words[j][ii]); words[j][ii] = SDL_tolower(words[j][ii]);
@ -73,16 +76,14 @@ void scriptclass::tokenize( const std::string& t )
} }
} }
if (tempword != "" && j < (int) SDL_arraysize(words)) if (j < (int) SDL_arraysize(words))
{
const bool lastargexists = tempword != "";
if (lastargexists)
{ {
words[j] = tempword; words[j] = tempword;
} }
argexists[j] = lastargexists;
SDL_zeroa(argexists);
for (size_t ii = 0; ii < NUM_SCRIPT_ARGS; ++ii)
{
argexists[ii] = words[ii] != "";
} }
} }