diff --git a/Aquaria/Game.h b/Aquaria/Game.h index 38d3c4b..6782622 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -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); diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index 8c7d295..a8aa78b 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -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: