mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
fix(editor): object ID reset on load, zone name validation
- ObjectPlacer::loadFromFile() now resets uniqueIdCounter_ and clears selectedIndices_ to prevent ID collisions on repeated loads - Zone rename validates against path traversal and special characters (rejects slashes, dots, colons, control chars, empty strings) - UI shows error toast for invalid zone names
This commit is contained in:
parent
16a34afbf6
commit
acb519a243
3 changed files with 16 additions and 3 deletions
|
|
@ -54,7 +54,16 @@ public:
|
|||
QuestEditor& getQuestEditor() { return questEditor_; }
|
||||
AssetBrowser& getAssetBrowser() { return assetBrowser_; }
|
||||
EditorViewport& getViewport() { return viewport_; }
|
||||
void setMapName(const std::string& name) { loadedMap_ = name; }
|
||||
bool setMapName(const std::string& name) {
|
||||
if (name.empty()) return false;
|
||||
for (char c : name) {
|
||||
if (c == '/' || c == '\\' || c == '.' || c == ':' ||
|
||||
c == '*' || c == '?' || c == '"' || c == '<' ||
|
||||
c == '>' || c == '|' || c < 32) return false;
|
||||
}
|
||||
loadedMap_ = name;
|
||||
return true;
|
||||
}
|
||||
rendering::TerrainRenderer* getTerrainRenderer();
|
||||
rendering::M2Renderer* getM2Renderer() { return viewport_.getM2Renderer(); }
|
||||
pipeline::AssetManager* getAssetManager() { return assetManager_.get(); }
|
||||
|
|
|
|||
|
|
@ -2254,8 +2254,10 @@ void EditorUI::renderPropertiesPanel(EditorApp& app) {
|
|||
ImGui::SetNextItemWidth(140);
|
||||
if (ImGui::InputText("##mapname", renameBuf, sizeof(renameBuf),
|
||||
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
app.setMapName(renameBuf);
|
||||
app.showToast("Zone renamed: " + std::string(renameBuf));
|
||||
if (app.setMapName(renameBuf))
|
||||
app.showToast("Zone renamed: " + std::string(renameBuf));
|
||||
else
|
||||
app.showToast("Invalid name (no slashes or special chars)");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("[%d, %d]", app.getLoadedTileX(), app.getLoadedTileY());
|
||||
|
|
|
|||
|
|
@ -244,6 +244,8 @@ bool ObjectPlacer::loadFromFile(const std::string& path) {
|
|||
objects_.clear();
|
||||
undoStack_.clear();
|
||||
selectedIdx_ = -1;
|
||||
selectedIndices_.clear();
|
||||
uniqueIdCounter_ = 1;
|
||||
|
||||
for (const auto& jo : arr) {
|
||||
PlacedObject obj;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue