mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
63a487d20d
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`.
78 lines
1.3 KiB
C++
78 lines
1.3 KiB
C++
#ifndef SCRIPT_H
|
|
#define SCRIPT_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <SDL.h>
|
|
|
|
#define filllines(lines) commands.insert(commands.end(), lines, lines + SDL_arraysize(lines))
|
|
|
|
|
|
struct Script
|
|
{
|
|
std::string name;
|
|
std::vector<std::string> contents;
|
|
};
|
|
|
|
#define NUM_SCRIPT_ARGS 40
|
|
|
|
class scriptclass
|
|
{
|
|
public:
|
|
|
|
|
|
scriptclass(void);
|
|
|
|
void load(const std::string& name);
|
|
void loadother(const char* t);
|
|
void loadcustom(const std::string& t);
|
|
|
|
void inline add(const std::string& t)
|
|
{
|
|
commands.push_back(t);
|
|
}
|
|
|
|
void clearcustom(void);
|
|
|
|
void tokenize(const std::string& t);
|
|
|
|
void run(void);
|
|
|
|
void resetgametomenu(void);
|
|
|
|
void startgamemode(int t);
|
|
|
|
void teleport(void);
|
|
|
|
void hardreset(void);
|
|
|
|
//Script contents
|
|
std::vector<std::string> commands;
|
|
std::string words[NUM_SCRIPT_ARGS];
|
|
std::vector<std::string> txt;
|
|
std::string scriptname;
|
|
int position;
|
|
int looppoint, loopcount;
|
|
|
|
int scriptdelay;
|
|
bool running;
|
|
|
|
//Textbox stuff
|
|
int textx;
|
|
int texty;
|
|
int r,g,b;
|
|
bool textflipme;
|
|
|
|
//Misc
|
|
int i, j, k;
|
|
|
|
//Custom level stuff
|
|
std::vector<Script> customscripts;
|
|
};
|
|
|
|
#ifndef SCRIPT_DEFINITION
|
|
extern scriptclass script;
|
|
#endif
|
|
|
|
#endif /* SCRIPT_H */
|