1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-01-24 17:26:41 +00:00

fix some editor crashes when switching edit modes while dragging a thing

This commit is contained in:
fgenesis 2023-10-26 00:17:33 +02:00
parent 03eeb7f4e9
commit 3972983c72
2 changed files with 6 additions and 3 deletions

View file

@ -251,7 +251,7 @@ public:
void removePath(size_t idx);
void clearPaths();
size_t getNumPaths() const {return paths.size();}
Path *getPath(size_t idx) const {return paths[idx];}
Path *getPath(size_t idx) const {return idx < paths.size() ? paths[idx] : NULL;}
Path *getFirstPathOfType(PathType type) const {return firstPathOfType[type];}
Path *getPathByName(std::string name);
size_t getIndexOfPath(Path *p);

View file

@ -291,7 +291,7 @@ void SceneEditor::setBackgroundGradient()
void SceneEditor::updateSelectedElementPosition(Vector dist)
{
if (state == ES_MOVING)
if (state == ES_MOVING && multi)
{
// the actual tile position is updated when we release the mouse
multi->position = oldPosition + dist;
@ -2621,7 +2621,10 @@ void SceneEditor::update(float dt)
}
break;
case ES_MOVING:
game->getPath(selectedIdx)->nodes[selectedNode].position = dsq->getGameCursorPosition() + cursorOffset;
{
if(Path *p = game->getPath(selectedIdx))
p->nodes[selectedNode].position = dsq->getGameCursorPosition() + cursorOffset;
}
break;
case ES_ROTATING:
case ES_MAX: