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
1 changed files with 10 additions and 9 deletions

View File

@ -46,12 +46,15 @@ void scriptclass::tokenize( const std::string& t )
std::string tempword;
char currentletter;
SDL_zeroa(argexists);
for (size_t i = 0; i < t.length(); i++)
{
currentletter = t[i];
if (currentletter == '(' || currentletter == ')' || currentletter == ',')
{
words[j] = tempword;
argexists[j] = words[j] != "";
for (size_t ii = 0; ii < words[j].length(); 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))
{
words[j] = tempword;
}
SDL_zeroa(argexists);
for (size_t ii = 0; ii < NUM_SCRIPT_ARGS; ++ii)
{
argexists[ii] = words[ii] != "";
const bool lastargexists = tempword != "";
if (lastargexists)
{
words[j] = tempword;
}
argexists[j] = lastargexists;
}
}