createentity command: Actually have p1/p2/p3/p4 defaults

Since createentity() started accepting p1/p2/p3/p4 arguments, it now
unconditionally passes in whatever arguments were present there
previously, when there weren't any before.

This can lead to unexpected behavior when selectively using and then
omitting p1/p2/p3/p4 arguments.

Also, plenty of existing levels already only use the 5-argument version
of createentity(). And createcrewman() can take up to 6 arguments at
once. It's not far-fetched that an existing level could createentity()
right after doing a 6-argument createcrewman(), which would lead to a
different behavior than in 2.2 and previous.

So instead, instead of checking if `words[index]` is an empty string (it
only sets the string to be empty if there are enough argument separators
on the line), ACTUALLY check if it's empty. I've added a static array
(no need for it to be exported) that keeps track of this. createentity()
now checks for that instead of `words`.
This commit is contained in:
Misa
2021-08-11 19:32:36 -07:00
committed by Ethan Lee
parent 87ec35eb45
commit 63a487d20d
2 changed files with 17 additions and 7 deletions

View File

@@ -15,6 +15,8 @@ struct Script
std::vector<std::string> contents;
};
#define NUM_SCRIPT_ARGS 40
class scriptclass
{
public:
@@ -47,7 +49,7 @@ public:
//Script contents
std::vector<std::string> commands;
std::string words[40];
std::string words[NUM_SCRIPT_ARGS];
std::vector<std::string> txt;
std::string scriptname;
int position;