Refactor edentities to not use separate length-trackers

This turns the array 'edentity' into a proper vector, and removes the need to
use a separate length-tracking variable and manually keep track of the actual
amount of edentities in the level by using the long-winded
'EditorData::GetInstance().numedentities'. This manual tracking was more
error-prone and much less maintainable.

editorclass::naddedentity() has been removed due to now functionally being the
same as editorclass::addedentity() (there's no more
'EditorData::GetInstance().numedentities' to not increment) and for also being
unused in the first place.

editorclass::copyedentity() has been removed because it was only used to shift
the rest of the edentities up manually, but now that we let C++ do all the
hard work it's no longer necessary.
This commit is contained in:
Misa
2020-03-01 12:24:43 -08:00
committed by Ethan Lee
parent a4d7fc017c
commit 8d44d9387b
4 changed files with 52 additions and 96 deletions

View File

@@ -48,7 +48,7 @@ struct LevelMetaData
};
extern edentities edentity[3000];
extern std::vector<edentities> edentity;
extern scriptclass script;
class EditorData
@@ -63,7 +63,6 @@ class EditorData
}
int numedentities;
std::string title;
std::string creator;
@@ -74,8 +73,7 @@ class EditorData
private:
EditorData():
numedentities(0)
EditorData()
{
}
@@ -242,10 +240,6 @@ class editorclass{
void addedentity(int xp, int yp, int tp, int p1=0, int p2=0, int p3=0, int p4=0, int p5=320, int p6=240);
void naddedentity(int xp, int yp, int tp, int p1=0, int p2=0, int p3=0, int p4=0, int p5=320, int p6=240);
void copyedentity(int a, int b);
void removeedentity(int t);
int edentat(int xp, int yp);
@@ -266,4 +260,4 @@ void editorinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
#endif /* EDITOR_H */
#endif /* NO_CUSTOM_LEVELS */
#endif /* NO_CUSTOM_LEVELS */