From 8139604f6d9f7014ef516371895c72fabd55f828 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Sun, 5 Feb 2017 21:57:18 +0100 Subject: [PATCH] Moved creatures skins to PersonType class --- Source/Devtools/ConsoleCmds.cpp | 4 ++-- Source/Game.hpp | 7 ------- Source/GameTick.cpp | 23 +---------------------- Source/Objects/Person.cpp | 19 ++++++++++++++++++- Source/Objects/Person.hpp | 2 ++ 5 files changed, 23 insertions(+), 32 deletions(-) diff --git a/Source/Devtools/ConsoleCmds.cpp b/Source/Devtools/ConsoleCmds.cpp index 94cb002..fba2400 100644 --- a/Source/Devtools/ConsoleCmds.cpp +++ b/Source/Devtools/ConsoleCmds.cpp @@ -121,7 +121,7 @@ static void set_noclothes(int pnum, const char*) { Person::players[pnum]->numclothes = 0; Person::players[pnum]->skeleton.drawmodel.textureptr.load( - creatureskin[Person::players[pnum]->creature][Person::players[pnum]->whichskin], 1, + PersonType::types[Person::players[pnum]->creature].skins[Person::players[pnum]->whichskin], 1, &Person::players[pnum]->skeleton.skinText[0], &Person::players[pnum]->skeleton.skinsize); } @@ -648,7 +648,7 @@ void ch_default(const char*) Person::players[0]->numclothes = 0; Person::players[0]->skeleton.drawmodel.textureptr.load( - creatureskin[Person::players[0]->creature][Person::players[0]->whichskin], 1, + PersonType::types[Person::players[0]->creature].skins[Person::players[0]->whichskin], 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); editoractive = typeactive; diff --git a/Source/Game.hpp b/Source/Game.hpp index 6307092..c5a3632 100644 --- a/Source/Game.hpp +++ b/Source/Game.hpp @@ -201,16 +201,9 @@ enum editortypes {typeactive, typesitting, typesittingwall, typesleeping, extern const char *editortypenames[8]; -extern const char *rabbitskin[10]; - -extern const char *wolfskin[3]; - -extern const char **creatureskin[2]; - SDL_bool sdlEventProc(const SDL_Event &e); - enum optionIndex { UNKNOWN, VERSION, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS, DEVTOOLS }; /* Number of options + 1 */ const int commandLineOptionsNumber = 10; diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index a0bb4b3..c1b0386 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -148,27 +148,6 @@ float musicvolume[4] = {}; float oldmusicvolume[4] = {}; int musicselected = 0; -const char* rabbitskin[] = { - "Textures/Fur3.jpg", - "Textures/Fur.jpg", - "Textures/Fur2.jpg", - "Textures/Lynx.jpg", - "Textures/Otter.jpg", - "Textures/Opal.jpg", - "Textures/Sable.jpg", - "Textures/Chocolate.jpg", - "Textures/BW2.jpg", - "Textures/WB2.jpg" -}; - -const char* wolfskin[] = { - "Textures/Wolf.jpg", - "Textures/DarkWolf.jpg", - "Textures/SnowWolf.jpg" -}; - -const char** creatureskin[] = { rabbitskin, wolfskin }; - #define STATIC_ASSERT(x) extern int s_a_dummy[2 * (!!(x)) - 1]; STATIC_ASSERT(rabbittype == 0 && wolftype == 1) @@ -1213,7 +1192,7 @@ void Game::ProcessDevInput() } Person::players[closest]->skeleton.drawmodel.textureptr.load( - creatureskin[Person::players[closest]->creature][Person::players[closest]->whichskin], 1, + PersonType::types[Person::players[closest]->creature].skins[Person::players[closest]->whichskin], 1, &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize); } diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 0d4fa9a..6c4bbbb 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -114,6 +114,11 @@ void PersonType::Load() types[wolftype].lowModelFileName = "Models/WolfLow.solid"; types[wolftype].modelClothesFileName = "Models/Belt.solid"; + types[wolftype].skins.resize(3); + types[wolftype].skins[0] = "Textures/Wolf.jpg"; + types[wolftype].skins[1] = "Textures/DarkWolf.jpg"; + types[wolftype].skins[2] = "Textures/SnowWolf.jpg"; + /* Rabbit */ types[rabbittype].proportions[0] = 1.2; types[rabbittype].proportions[1] = 1.05; @@ -147,6 +152,18 @@ void PersonType::Load() types[rabbittype].modelFileNames[6] = "Models/Body7.solid"; types[rabbittype].lowModelFileName = "Models/BodyLow.solid"; types[rabbittype].modelClothesFileName = "Models/Belt.solid"; + + types[rabbittype].skins.resize(10); + types[rabbittype].skins[0] = "Textures/Fur3.jpg"; + types[rabbittype].skins[1] = "Textures/Fur.jpg"; + types[rabbittype].skins[2] = "Textures/Fur2.jpg"; + types[rabbittype].skins[3] = "Textures/Lynx.jpg"; + types[rabbittype].skins[4] = "Textures/Otter.jpg"; + types[rabbittype].skins[5] = "Textures/Opal.jpg"; + types[rabbittype].skins[6] = "Textures/Sable.jpg"; + types[rabbittype].skins[7] = "Textures/Chocolate.jpg"; + types[rabbittype].skins[8] = "Textures/BW2.jpg"; + types[rabbittype].skins[9] = "Textures/WB2.jpg"; } Person::Person() @@ -541,7 +558,7 @@ void Person::skeletonLoad(bool clothes) PersonType::types[creature].modelClothesFileName, clothes); - skeleton.drawmodel.textureptr.load(creatureskin[creature][whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize); + skeleton.drawmodel.textureptr.load(PersonType::types[creature].skins[whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize); } void Person::setProportions(float head, float body, float arms, float legs) diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index 1b9a01c..d67c503 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -77,6 +77,8 @@ public: std::string lowModelFileName; std::string modelClothesFileName; + std::vector skins; + static std::vector types; static void Load(); }; -- 2.39.5