2020-02-10 03:21:19 +01:00
|
|
|
#if !defined(NO_CUSTOM_LEVELS)
|
2020-02-10 01:53:01 +01:00
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#ifndef EDITOR_H
|
|
|
|
#define EDITOR_H
|
|
|
|
|
2020-07-19 21:05:41 +02:00
|
|
|
#include <SDL.h>
|
2020-07-19 21:43:29 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-01 08:17:26 +02:00
|
|
|
// Text entry field type
|
|
|
|
enum textmode {
|
|
|
|
TEXT_NONE,
|
|
|
|
|
|
|
|
// In-editor text fields
|
|
|
|
TEXT_LOAD,
|
|
|
|
TEXT_SAVE,
|
|
|
|
TEXT_ROOMNAME,
|
|
|
|
TEXT_SCRIPT,
|
|
|
|
TEXT_ROOMTEXT,
|
2020-07-01 08:35:59 +02:00
|
|
|
TEXT_GOTOROOM,
|
|
|
|
LAST_EDTEXT = TEXT_GOTOROOM,
|
2020-07-01 08:17:26 +02:00
|
|
|
|
|
|
|
// Settings-mode text fields
|
|
|
|
TEXT_TITLE,
|
|
|
|
TEXT_DESC,
|
|
|
|
TEXT_WEBSITE,
|
|
|
|
TEXT_CREATOR,
|
|
|
|
NUM_TEXTMODES,
|
|
|
|
|
|
|
|
// Text modes with an entity
|
|
|
|
FIRST_ENTTEXT = TEXT_SCRIPT,
|
|
|
|
LAST_ENTTEXT = TEXT_ROOMTEXT
|
|
|
|
};
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
class edentities{
|
|
|
|
public:
|
2020-06-12 02:57:04 +02:00
|
|
|
int x, y, t;
|
|
|
|
//parameters
|
|
|
|
int p1, p2, p3, p4, p5, p6;
|
|
|
|
std::string scriptname;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-03-24 19:59:36 +01:00
|
|
|
#define ROOM_PROPERTIES \
|
|
|
|
FOREACH_PROP(tileset, int) \
|
|
|
|
FOREACH_PROP(tilecol, int) \
|
|
|
|
FOREACH_PROP(roomname, std::string) \
|
|
|
|
FOREACH_PROP(warpdir, int) \
|
|
|
|
FOREACH_PROP(platx1, int) \
|
|
|
|
FOREACH_PROP(platy1, int) \
|
|
|
|
FOREACH_PROP(platx2, int) \
|
|
|
|
FOREACH_PROP(platy2, int) \
|
|
|
|
FOREACH_PROP(platv, int) \
|
|
|
|
FOREACH_PROP(enemyx1, int) \
|
|
|
|
FOREACH_PROP(enemyy1, int) \
|
|
|
|
FOREACH_PROP(enemyx2, int) \
|
|
|
|
FOREACH_PROP(enemyy2, int) \
|
|
|
|
FOREACH_PROP(enemytype, int) \
|
|
|
|
FOREACH_PROP(directmode, int)
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
class edlevelclass{
|
|
|
|
public:
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
edlevelclass(void);
|
2021-03-24 19:59:36 +01:00
|
|
|
#define FOREACH_PROP(NAME, TYPE) TYPE NAME;
|
|
|
|
ROOM_PROPERTIES
|
|
|
|
#undef FOREACH_PROP
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LevelMetaData
|
|
|
|
{
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string title;
|
|
|
|
std::string creator;
|
|
|
|
std::string Desc1;
|
|
|
|
std::string Desc2;
|
|
|
|
std::string Desc3;
|
|
|
|
std::string website;
|
|
|
|
std::string filename;
|
|
|
|
|
|
|
|
std::string modifier;
|
|
|
|
std::string timeCreated;
|
|
|
|
std::string timeModified;
|
|
|
|
|
|
|
|
int version;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-03-01 21:24:43 +01:00
|
|
|
extern std::vector<edentities> edentity;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
class EditorData
|
|
|
|
{
|
2020-06-12 02:57:04 +02:00
|
|
|
public:
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
static EditorData& GetInstance(void)
|
2020-06-12 02:57:04 +02:00
|
|
|
{
|
|
|
|
static EditorData instance; // Guaranteed to be destroyed.
|
|
|
|
// Instantiated on first use.
|
|
|
|
return instance;
|
|
|
|
}
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string title;
|
|
|
|
std::string creator;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string modifier;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
struct GhostInfo {
|
|
|
|
int rx; // game.roomx-100
|
|
|
|
int ry; // game.roomy-100
|
|
|
|
int x; // .xp
|
|
|
|
int y; // .yp
|
|
|
|
int col; // .colour
|
2020-06-13 02:34:19 +02:00
|
|
|
Uint32 realcol;
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
int frame; // .drawframe
|
|
|
|
};
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
class editorclass{
|
|
|
|
//Special class to handle ALL editor variables locally
|
|
|
|
public:
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
editorclass(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
std::string Desc1;
|
|
|
|
std::string Desc2;
|
|
|
|
std::string Desc3;
|
2020-06-12 02:57:04 +02:00
|
|
|
std::string website;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
std::vector<LevelMetaData> ListOfMetaData;
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void loadZips(void);
|
|
|
|
void getDirectoryData(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
bool getLevelMetaData(std::string& filename, LevelMetaData& _data );
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void reset(void);
|
2020-07-01 08:17:26 +02:00
|
|
|
void getlin(const enum textmode mode, const std::string& prompt, std::string* ptr);
|
2020-07-19 06:06:35 +02:00
|
|
|
const short* loadlevel(int rxi, int ryi);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2021-03-24 19:26:19 +01:00
|
|
|
int gettileidx(
|
|
|
|
const int rx,
|
|
|
|
const int ry,
|
|
|
|
const int x,
|
|
|
|
const int y
|
|
|
|
);
|
|
|
|
void settile(
|
|
|
|
const int rx,
|
|
|
|
const int ry,
|
|
|
|
const int x,
|
|
|
|
const int y,
|
|
|
|
const int t
|
|
|
|
);
|
|
|
|
int gettile(
|
|
|
|
const int rx,
|
|
|
|
const int ry,
|
|
|
|
const int x,
|
|
|
|
const int y
|
|
|
|
);
|
|
|
|
int getabstile(const int x, const int y);
|
|
|
|
|
2021-03-24 19:59:36 +01:00
|
|
|
int getroompropidx(const int rx, const int ry);
|
|
|
|
const edlevelclass* getroomprop(const int rx, const int ry);
|
|
|
|
#define FOREACH_PROP(NAME, TYPE) \
|
|
|
|
void setroom##NAME(const int rx, const int ry, const TYPE NAME);
|
|
|
|
ROOM_PROPERTIES
|
|
|
|
#undef FOREACH_PROP
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
void placetilelocal(int x, int y, int t);
|
|
|
|
|
|
|
|
int getenemyframe(int t);
|
|
|
|
int base(int x, int y);
|
|
|
|
|
|
|
|
int backbase(int x, int y);
|
|
|
|
|
|
|
|
int at(int x, int y);
|
|
|
|
|
|
|
|
int freewrap(int x, int y);
|
|
|
|
|
|
|
|
int backonlyfree(int x, int y);
|
|
|
|
|
|
|
|
int backfree(int x, int y);
|
|
|
|
|
|
|
|
int spikefree(int x, int y);
|
|
|
|
int free(int x, int y);
|
|
|
|
int absfree(int x, int y);
|
|
|
|
|
|
|
|
int match(int x, int y);
|
|
|
|
int outsidematch(int x, int y);
|
|
|
|
|
|
|
|
int backmatch(int x, int y);
|
|
|
|
|
2020-07-01 06:39:10 +02:00
|
|
|
void switch_tileset(const bool reversed = false);
|
|
|
|
void switch_tilecol(const bool reversed = false);
|
|
|
|
void clamp_tilecol(const int rx, const int ry, const bool wrap = false);
|
|
|
|
void switch_enemy(const bool reversed = false);
|
|
|
|
|
2020-06-02 12:59:54 +02:00
|
|
|
bool load(std::string& _path);
|
|
|
|
bool save(std::string& _path);
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void generatecustomminimap(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
int edgetile(int x, int y);
|
|
|
|
int outsideedgetile(int x, int y);
|
|
|
|
|
|
|
|
int backedgetile(int x, int y);
|
|
|
|
|
|
|
|
int labspikedir(int x, int y, int t);
|
|
|
|
int spikedir(int x, int y);
|
|
|
|
int findtrinket(int t);
|
|
|
|
int findcrewmate(int t);
|
|
|
|
int findwarptoken(int t);
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void findstartpoint(void);
|
2021-03-24 19:59:36 +01:00
|
|
|
int getlevelcol(const int tileset, const int tilecol);
|
2020-01-01 21:29:24 +01:00
|
|
|
int getenemycol(int t);
|
|
|
|
int entcol;
|
2020-05-02 22:53:19 +02:00
|
|
|
Uint32 entcolreal;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
//Colouring stuff
|
|
|
|
int getwarpbackground(int rx, int ry);
|
|
|
|
|
|
|
|
std::vector<std::string> getLevelDirFileNames( );
|
2020-07-03 11:54:31 +02:00
|
|
|
static const int maxwidth = 20, maxheight = 20; //Special; the physical max the engine allows
|
|
|
|
static const int numrooms = maxwidth * maxheight;
|
2020-07-19 06:06:35 +02:00
|
|
|
short contents[40 * 30 * numrooms];
|
2020-07-03 11:54:31 +02:00
|
|
|
int vmult[30 * maxheight];
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
int numtrinkets(void);
|
|
|
|
int numcrewmates(void);
|
2020-07-03 11:54:31 +02:00
|
|
|
edlevelclass level[numrooms]; //Maxwidth*maxheight
|
|
|
|
int kludgewarpdir[numrooms]; //Also maxwidth*maxheight
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int notedelay;
|
2020-05-02 19:42:39 +02:00
|
|
|
int oldnotedelay;
|
2020-01-01 21:29:24 +01:00
|
|
|
std::string note;
|
|
|
|
std::string keybuffer;
|
|
|
|
std::string filename;
|
2020-11-03 18:55:26 +01:00
|
|
|
std::string loaded_filepath;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int drawmode;
|
|
|
|
int tilex, tiley;
|
|
|
|
int keydelay, lclickdelay;
|
|
|
|
bool savekey, loadkey;
|
|
|
|
int levx, levy;
|
|
|
|
int entframe, entframedelay;
|
|
|
|
|
|
|
|
int scripttexttype;
|
2020-01-27 11:15:25 +01:00
|
|
|
std::string oldenttext;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-07-01 08:17:26 +02:00
|
|
|
enum textmode textmod; // In text entry
|
|
|
|
std::string* textptr; // Pointer to text we're changing
|
|
|
|
std::string textdesc; // Description (for editor mode text fields)
|
|
|
|
union {
|
|
|
|
int desc; // Which description row we're changing
|
|
|
|
int textent; // Entity ID for text prompt
|
|
|
|
};
|
Axe manual state trackers and use SDL_IsTextInputActive()
After looking at pull request #446, I got a bit annoyed that we have TWO
variables, key.textentrymode and ed.textentry, that we rolled ourselves
to track the state of something SDL already provides us a function to
easily query: SDL_IsTextInputActive(). We don't need to have either of
these two variables, and we shouldn't.
So that's what I do in this patch. Both variables have been axed in
favor of using this function, and I just made a wrapper out of it, named
key.textentry().
For bonus points, this gets rid of the ugly NO_CUSTOM_LEVELS and
NO_EDITOR ifdef in main.cpp, since text entry is enabled when entering
the script list and disabled when exiting it. This makes the code there
easier to read, too.
Furthermore, apparently key.textentrymode was initialized to *true*
instead of false... for whatever reason. But that's gone now, too.
Now, you'd think there wouldn't be any downside to using
SDL_IsTextInputActive(). After all, it's a function that SDL itself
provides, right?
Wrong. For whatever reason, it seems like text input is active *from the
start of the program*, meaning that what would happen is I would go into
the editor, and find that I can't move around nor place tiles nor
anything else. Then I would press Esc, and then suddenly become able to
do those things I wanted to do before.
I have no idea why the above happens, but all I can do is to just insert
an SDL_StopTextInput() immediately after the SDL_Init() in main.cpp. Of
course, I have to surround it with an SDL_IsTextInputActive() check to
make sure I don't do anything extraneous by stopping input when it's
already stopped.
2020-08-13 08:43:25 +02:00
|
|
|
bool xmod, zmod, cmod, vmod, bmod, hmod, spacemod, warpmod;
|
2020-01-01 21:29:24 +01:00
|
|
|
bool titlemod, creatormod, desc1mod, desc2mod, desc3mod, websitemod;
|
|
|
|
|
|
|
|
int roomnamehide;
|
|
|
|
bool saveandquit;
|
|
|
|
bool shiftmenu, shiftkey;
|
|
|
|
int spacemenu;
|
|
|
|
bool settingsmod, settingskey;
|
|
|
|
int warpent;
|
|
|
|
bool updatetiles, changeroom;
|
|
|
|
int deletekeyheld;
|
|
|
|
|
|
|
|
int boundarymod, boundarytype;
|
|
|
|
int boundx1, boundx2, boundy1, boundy2;
|
|
|
|
|
|
|
|
int levmusic;
|
|
|
|
int mapwidth, mapheight; //Actual width and height of stage
|
|
|
|
|
|
|
|
int version;
|
|
|
|
|
|
|
|
//Script editor stuff
|
|
|
|
void removeline(int t);
|
|
|
|
void insertline(int t);
|
|
|
|
|
|
|
|
bool scripteditmod;
|
|
|
|
int scripthelppage, scripthelppagedelay;
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
std::vector<std::string> sb;
|
2020-01-01 21:29:24 +01:00
|
|
|
std::string sbscript;
|
|
|
|
int sbx, sby;
|
|
|
|
int pagey;
|
|
|
|
|
|
|
|
//Functions for interfacing with the script:
|
|
|
|
void addhook(std::string t);
|
|
|
|
void removehook(std::string t);
|
|
|
|
void addhooktoscript(std::string t);
|
|
|
|
void removehookfromscript(std::string t);
|
|
|
|
void loadhookineditor(std::string t);
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void clearscriptbuffer(void);
|
|
|
|
void gethooks(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
bool checkhook(std::string t);
|
Make `commands`, `sb`, and `hooklist` not use separate length-trackers
This is a refactor that turns the script-related arrays `ed.sb`, and
`ed.hooklist` into C++ vectors (`script.commands` was already a vector, it was
just misused). The code handling these vectors now looks more like idiomatic
C++ than sloppily-pasted pseudo-ActionScript. This removes the variables
`script.scriptlength`, `ed.sblength`, and `ed.numhooks`, too.
This reduces the amount of code needed to e.g. simply remove something from
any of these vectors. Previously the code had to manually shift the rest of
the elements down one-by-one, and doing it manually is definitely error-prone
and tedious.
But now we can just use fancy functions like `std::vector::erase()` and
`std::remove()` to do it all in one line!
Don't worry, I checked and `std::remove()` is in the C++ standard since at least
1998.
This patch makes it so the `commands` vector gets cleared when
`scriptclass::load()` is ran. Previously, the `commands` vector never actually
properly got cleared, so there could potentially be glitches that rely on the
game indexing past the bounds set by `scriptlength` but still in-bounds in the
eyes of C++, and people could potentially rely on such an exploit...
However, I checked, and I'm pretty sure that no such glitch previously existed
at all, because the only times the vector gets indexed are when `scriptlength`
is either being incremented after starting from 0 (`add()`) or when it's
underneath a `position < scriptlength` conditional.
Furthermore, I'm unaware of anyone who has actually found or used such an
exploit, and I've been in the custom level community for 6 years.
So I think it's fine.
2020-02-20 18:43:52 +01:00
|
|
|
std::vector<std::string> hooklist;
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
int hookmenupage, hookmenu;
|
|
|
|
|
|
|
|
//Direct Mode variables
|
|
|
|
int dmtile;
|
|
|
|
int dmtileeditor;
|
2020-02-10 03:23:12 +01:00
|
|
|
|
2020-06-30 20:47:22 +02:00
|
|
|
Uint32 getonewaycol(const int rx, const int ry);
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
Uint32 getonewaycol(void);
|
2020-06-30 23:08:14 +02:00
|
|
|
bool onewaycol_override;
|
2020-06-30 20:47:22 +02:00
|
|
|
|
2020-02-11 06:34:01 +01:00
|
|
|
int returneditoralpha;
|
2020-05-02 19:49:41 +02:00
|
|
|
int oldreturneditoralpha;
|
Add a player trail to the editor (ghosts)
A few months ago, I added ghosts to the VVVVVV: Community Edition editor. I was told recently I should think
about upstreaming it, and with Terry saying go ahead I finally ported them into VVVVVV. There's one slight
difference however--you can choose whether you have them or not in the editor's settings menu. They're off by
default, and this is saved to the save file.
Anyway, when you're playtesting, the game saves the players position, color, room coordinates and sprite every 3
frames. The max is 100, where if it tries to add more, the oldest one gets removed.
When you exit playtesting, the saved positions appear one at a time, and you can use the Z key to speed it up.
[Here's a video of them in action.](https://o.lol-sa.me/4H21zCv.mp4)
2020-06-13 00:04:35 +02:00
|
|
|
|
|
|
|
std::vector<GhostInfo> ghosts;
|
2020-06-13 00:27:21 +02:00
|
|
|
int currentghosts;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
2020-06-20 00:23:28 +02:00
|
|
|
#if !defined(NO_EDITOR)
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorrender(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorrenderfixed(void);
|
2020-11-08 00:47:49 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorlogic(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void editorinput(void);
|
2020-06-20 00:23:28 +02:00
|
|
|
#endif
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2020-09-28 04:15:06 +02:00
|
|
|
#ifndef ED_DEFINITION
|
2020-05-18 19:14:12 +02:00
|
|
|
extern editorclass ed;
|
2020-09-28 04:15:06 +02:00
|
|
|
#endif
|
2020-05-18 19:14:12 +02:00
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
#endif /* EDITOR_H */
|
2020-02-10 01:53:01 +01:00
|
|
|
|
2020-03-01 21:24:43 +01:00
|
|
|
#endif /* NO_CUSTOM_LEVELS */
|