X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FEnvironment%2FTerrain.cpp;h=2530f0a873f5b156fc2c4b8c8a9c1b815a3c2ae1;hb=88961157fe4a88fb10320b4ce211ca697f639e7e;hp=9ef47187e4b49a8fa04fa0285d6bb33a98c8db5c;hpb=b9a46d8e2b7e7e22c706e7dd3734f31015db4408;p=lugaru.git diff --git a/Source/Environment/Terrain.cpp b/Source/Environment/Terrain.cpp index 9ef4718..2530f0a 100644 --- a/Source/Environment/Terrain.cpp +++ b/Source/Environment/Terrain.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) +Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -1241,6 +1241,26 @@ void Terrain::AddObject(XYZ where, float radius, int id) } } +void Terrain::DeleteObject(unsigned int id) +{ + for (int i = 0; i < subdivision; i++) { + for (int j = 0; j < subdivision; j++) { + for (unsigned int k = 0; k < patchobjects[i][j].size();) { + if (patchobjects[i][j][k] == id) { + /* Remove all occurences of id (there should never be more than 1 though) */ + patchobjects[i][j].erase(patchobjects[i][j].begin() + k); + } else { + /* Update id of other objects if needed */ + if (patchobjects[i][j][k] > id) { + patchobjects[i][j][k]--; + } + k++; + } + } + } + } +} + void Terrain::DeleteDecal(int which) { if (decalstoggle) {