]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Environment/Terrain.cpp
Cleaned up TextureRes lifecycle to make sure it’s destroyed by RAII
[lugaru.git] / Source / Environment / Terrain.cpp
index 8c79cd42a3c91132bef988ab3060ed3d783b1b38..806bb4be7541b30f4f5b0cda08011ac5451db80d 100644 (file)
@@ -18,10 +18,11 @@ You should have received a copy of the GNU General Public License
 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "Game.h"
-#include "Environment/Terrain.h"
-#include "Objects/Objects.h"
-#include "Utils/Folders.h"
+#include "Environment/Terrain.hpp"
+
+#include "Game.hpp"
+#include "Objects/Object.hpp"
+#include "Utils/Folders.hpp"
 
 extern XYZ viewer;
 extern float viewdistance;
@@ -36,7 +37,6 @@ extern int detail;
 extern bool decals;
 extern float blurness;
 extern float targetblurness;
-extern Objects objects;
 extern bool visibleloading;
 extern bool skyboxtexture;
 extern int tutoriallevel;
@@ -1386,10 +1386,10 @@ void Terrain::DoShadows()
             if (patchobjectnum[patchx][patchz]) {
                 for (k = 0; k < patchobjectnum[patchx][patchz]; k++) {
                     l = patchobjects[patchx][patchz][k];
-                    if (objects.type[l] != treetrunktype) {
+                    if (Object::objects[l]->type != treetrunktype) {
                         testpoint = terrainpoint;
                         testpoint2 = terrainpoint + lightloc * 50 * (1 - shadowed);
-                        if (objects.model[l].LineCheck(&testpoint, &testpoint2, &col, &objects.position[l], &objects.yaw[l]) != -1) {
+                        if (Object::objects[l]->model.LineCheck(&testpoint, &testpoint2, &col, &Object::objects[l]->position, &Object::objects[l]->yaw) != -1) {
                             shadowed = 1 - (findDistance(&terrainpoint, &col) / 50);
                         }
                     }
@@ -1515,14 +1515,3 @@ Terrain::Terrain()
     memset(decalposition, 0, sizeof(decalposition));
     numdecals = 0;
 }
-Terrain::~Terrain()
-{
-    terraintexture.destroy();
-    shadowtexture.destroy();
-    bodyprinttexture.destroy();
-    footprinttexture.destroy();
-    bloodtexture.destroy();
-    bloodtexture2.destroy();
-    breaktexture.destroy();
-}
-