]> git.jsancho.org Git - lugaru.git/blobdiff - Source/ConsoleCmds.cpp
Moved clothes loop to Person, got rid of globals tintr,tintg,tintb
[lugaru.git] / Source / ConsoleCmds.cpp
index 279efb6dfe4e84b5005ae8cd24645a7ff911a148..32e9c1cb6a8a3f174f48a52bb39a2177c53c14e1 100644 (file)
@@ -1,5 +1,6 @@
 /*
 Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
 
 This file is part of Lugaru.
 
@@ -69,6 +70,8 @@ extern float viewdistance;
 
 extern int whichlevel;
 
+float tintr = 1, tintg = 1, tintb = 1;
+
 /* Helpers used in console commands */
 
 /* Return true if PFX is a prefix of STR (case-insensitive).  */
@@ -140,15 +143,17 @@ static void set_clothes(int pnum, const char *args)
     char buf[64];
     snprintf(buf, 63, ":Data:Textures:%s.png", args);
 
-    if (!AddClothes(buf, &Person::players[pnum]->skeleton.skinText[pnum]))
+    int id = Person::players[pnum]->numclothes;
+    strcpy(Person::players[pnum]->clothes[id], buf);
+    Person::players[pnum]->clothestintr[id] = tintr;
+    Person::players[pnum]->clothestintg[id] = tintg;
+    Person::players[pnum]->clothestintb[id] = tintb;
+    Person::players[pnum]->numclothes++;
+
+    if (!Person::players[pnum]->addClothes(id))
         return;
 
     Person::players[pnum]->DoMipmaps();
-    strcpy(Person::players[pnum]->clothes[Person::players[pnum]->numclothes], buf);
-    Person::players[pnum]->clothestintr[Person::players[pnum]->numclothes] = tintr;
-    Person::players[pnum]->clothestintg[Person::players[pnum]->numclothes] = tintg;
-    Person::players[pnum]->clothestintb[Person::players[pnum]->numclothes] = tintb;
-    Person::players[pnum]->numclothes++;
 }
 
 /* Console commands themselves */