X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FDevtools%2FConsoleCmds.cpp;h=84252e3040a92a84943bb0a30411550d9092cb97;hb=58e2a577c2ea4cf639a07fc792122c288d4bc2a5;hp=cfb2efdcd3842eaf56c187026786f36cba632694;hpb=b9a46d8e2b7e7e22c706e7dd3734f31015db4408;p=lugaru.git diff --git a/Source/Devtools/ConsoleCmds.cpp b/Source/Devtools/ConsoleCmds.cpp index cfb2efd..84252e3 100644 --- a/Source/Devtools/ConsoleCmds.cpp +++ b/Source/Devtools/ConsoleCmds.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. @@ -84,18 +84,7 @@ static void set_proportion(int pnum, const char* args) sscanf(args, "%f%f%f%f", &headprop, &bodyprop, &armprop, &legprop); - if (Person::players[pnum]->creature == wolftype) { - Person::players[pnum]->proportionhead = 1.1 * headprop; - Person::players[pnum]->proportionbody = 1.1 * bodyprop; - Person::players[pnum]->proportionarms = 1.1 * armprop; - Person::players[pnum]->proportionlegs = 1.1 * legprop; - } else if (Person::players[pnum]->creature == rabbittype) { - Person::players[pnum]->proportionhead = 1.2 * headprop; - Person::players[pnum]->proportionbody = 1.05 * bodyprop; - Person::players[pnum]->proportionarms = 1.00 * armprop; - Person::players[pnum]->proportionlegs = 1.1 * legprop; - Person::players[pnum]->proportionlegs.y = 1.05 * legprop; - } + Person::players[pnum]->setProportions(headprop, bodyprop, armprop, legprop); } static void set_protection(int pnum, const char* args) @@ -141,6 +130,22 @@ static void set_clothes(int pnum, const char* args) char buf[64]; snprintf(buf, 63, "Textures/%s.png", args); + const std::string file_path = Folders::getResourcePath(buf); + FILE* tfile; + tfile = fopen(file_path.c_str(), "rb"); + if (tfile == NULL) { + perror((std::string("Couldn't find file ") + file_path + " to assign as clothes").c_str()); + + // FIXME: Reduce code duplication with GameTick (should come from a Console class) + for (int k = 14; k >= 1; k--) { + consoletext[k] = consoletext[k - 1]; + } + consoletext[0] = std::string("Could not load the requested texture '") + args + "', aborting."; + consoleselected = 0; + + return; + } + int id = Person::players[pnum]->numclothes; strncpy(Person::players[pnum]->clothes[id], buf, 64); Person::players[pnum]->clothestintr[id] = tintr; @@ -275,22 +280,7 @@ void ch_save(const char* args) fpackf(tfile, "Bf Bf Bf", Person::players[j]->protectionhead, Person::players[j]->protectionhigh, Person::players[j]->protectionlow); fpackf(tfile, "Bf Bf Bf", Person::players[j]->metalhead, Person::players[j]->metalhigh, Person::players[j]->metallow); fpackf(tfile, "Bf Bf", Person::players[j]->power, Person::players[j]->speedmult); - - float headprop, bodyprop, armprop, legprop; - if (Person::players[j]->creature == wolftype) { - headprop = Person::players[j]->proportionhead.x / 1.1; - bodyprop = Person::players[j]->proportionbody.x / 1.1; - armprop = Person::players[j]->proportionarms.x / 1.1; - legprop = Person::players[j]->proportionlegs.x / 1.1; - } else { - // rabbittype - headprop = Person::players[j]->proportionhead.x / 1.2; - bodyprop = Person::players[j]->proportionbody.x / 1.05; - armprop = Person::players[j]->proportionarms.x / 1.00; - legprop = Person::players[j]->proportionlegs.x / 1.1; - } - - fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop); + fpackf(tfile, "Bf Bf Bf Bf", Person::players[j]->getProportion(0), Person::players[j]->getProportion(1), Person::players[j]->getProportion(2), Person::players[j]->getProportion(3)); fpackf(tfile, "Bi", Person::players[j]->numclothes); if (Person::players[j]->numclothes) { @@ -456,14 +446,6 @@ void ch_belt(const char*) void ch_cellophane(const char*) { cellophane = !cellophane; - float mul = (cellophane ? 0 : 1); - - for (auto player : Person::players) { - player->proportionhead.z = player->proportionhead.x * mul; - player->proportionbody.z = player->proportionbody.x * mul; - player->proportionarms.z = player->proportionarms.x * mul; - player->proportionlegs.z = player->proportionlegs.x * mul; - } } void ch_funnybunny(const char*) @@ -480,15 +462,11 @@ void ch_wolfie(const char*) { Person::players[0]->creature = wolftype; Person::players[0]->skeletonLoad(); + Person::players[0]->scale = .23; Person::players[0]->damagetolerance = 300; set_proportion(0, "1 1 1 1"); } -void ch_wolfieisgod(const char* args) -{ - ch_wolfie(args); -} - void ch_wolf(const char*) { Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize); @@ -662,18 +640,7 @@ void ch_default(const char*) Person::players[0]->speedmult = 1; Person::players[0]->scale = 1; - if (Person::players[0]->creature == wolftype) { - Person::players[0]->proportionhead = 1.1; - Person::players[0]->proportionbody = 1.1; - Person::players[0]->proportionarms = 1.1; - Person::players[0]->proportionlegs = 1.1; - } else if (Person::players[0]->creature == rabbittype) { - Person::players[0]->proportionhead = 1.2; - Person::players[0]->proportionbody = 1.05; - Person::players[0]->proportionarms = 1.00; - Person::players[0]->proportionlegs = 1.1; - Person::players[0]->proportionlegs.y = 1.05; - } + Person::players[0]->setProportions(1, 1, 1, 1); Person::players[0]->numclothes = 0; Person::players[0]->skeleton.drawmodel.textureptr.load(