From: Côme Chilliet Date: Wed, 7 Dec 2016 11:56:42 +0000 (+0700) Subject: Moved as much as possible init in Person constructor X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=f38eb24f446b94d592d97b24b315bb44bed7b12c;p=lugaru.git Moved as much as possible init in Person constructor --- diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 9078672..9afacce 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -939,10 +939,12 @@ void Game::Loadlevel(const std::string& name) skyboxlightg = skyboxg; skyboxlightb = skyboxb; } - if (!stealthloading) - funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &Person::players[0]->coords.x, &Person::players[0]->coords.y, &Person::players[0]->coords.z, &Person::players[0]->yaw, &Person::players[0]->targetyaw, &Person::players[0]->num_weapons); - if (stealthloading) + /* TODO - This should be done in an other way so that we can rebuild main player as well (so coords would need to be copied from old ones after rebuilding) */ + if (stealthloading) { funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat, &lamefloat, &lamefloat, &lamefloat, &lamefloat, &Person::players[0]->num_weapons); + } else { + funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &Person::players[0]->coords.x, &Person::players[0]->coords.y, &Person::players[0]->coords.z, &Person::players[0]->yaw, &Person::players[0]->targetyaw, &Person::players[0]->num_weapons); + } if (Person::players[0]->num_weapons > 0 && Person::players[0]->num_weapons < 5) for (int j = 0; j < Person::players[0]->num_weapons; j++) { Person::players[0]->weaponids[j] = weapons.size(); @@ -1093,15 +1095,17 @@ void Game::Loadlevel(const std::string& name) for (unsigned i = 0; i < Person::players.size(); i++) { if (visibleloading) LoadingScreen(); - Person::players[i]->burnt = 0; - Person::players[i]->bled = 0; - Person::players[i]->onfire = 0; - if (i == 0 || Person::players[i]->scale < 0) + if (i == 0) { + Person::players[i]->burnt = 0; + Person::players[i]->bled = 0; + Person::players[i]->onfire = 0; Person::players[i]->scale = .2; + } Person::players[i]->skeleton.free = 0; Person::players[i]->skeleton.id = i; - if (i == 0 && mapvers < 9) + if (i == 0 && mapvers < 9) { Person::players[i]->creature = rabbittype; + } if (Person::players[i]->creature != wolftype) { Person::players[i]->skeleton.Load( (char *)"Skeleton/BasicFigure", @@ -1136,49 +1140,48 @@ void Game::Loadlevel(const std::string& name) Person::players[i]->addClothes(); - Person::players[i]->animCurrent = bounceidleanim; - Person::players[i]->animTarget = bounceidleanim; - Person::players[i]->frameCurrent = 0; - Person::players[i]->frameTarget = 1; - Person::players[i]->target = 0; + if (i == 0) { + Person::players[i]->animCurrent = bounceidleanim; + Person::players[i]->animTarget = bounceidleanim; + Person::players[i]->frameCurrent = 0; + Person::players[i]->frameTarget = 1; + Person::players[i]->target = 0; + } Person::players[i]->speed = 1 + (float)(Random() % 100) / 1000; if (difficulty == 0) Person::players[i]->speed -= .2; if (difficulty == 1) Person::players[i]->speed -= .1; - Person::players[i]->velocity = 0; - Person::players[i]->oldcoords = Person::players[i]->coords; - Person::players[i]->realoldcoords = Person::players[i]->coords; - - Person::players[i]->id = i; - Person::players[i]->skeleton.id = i; - Person::players[i]->updatedelay = 0; - Person::players[i]->normalsupdatedelay = 0; + if (i == 0) { + Person::players[i]->velocity = 0; + Person::players[i]->oldcoords = Person::players[i]->coords; + Person::players[i]->realoldcoords = Person::players[i]->coords; - Person::players[i]->aitype = passivetype; + Person::players[i]->id = i; + Person::players[i]->updatedelay = 0; + Person::players[i]->normalsupdatedelay = 0; - if (i == 0) { Person::players[i]->proportionhead = 1.2; Person::players[i]->proportionbody = 1.05; Person::players[i]->proportionarms = 1.00; Person::players[i]->proportionlegs = 1.1; Person::players[i]->proportionlegs.y = 1.05; - } - Person::players[i]->headless = 0; - Person::players[i]->currentoffset = 0; - Person::players[i]->targetoffset = 0; - - Person::players[i]->damagetolerance = 200; - - if (Person::players[i]->creature == wolftype) { - if (i == 0 || Person::players[i]->scale < 0) + Person::players[i]->headless = 0; + Person::players[i]->currentoffset = 0; + Person::players[i]->targetoffset = 0; + if (Person::players[i]->creature == wolftype) { Person::players[i]->scale = .23; - Person::players[i]->damagetolerance = 300; + Person::players[i]->damagetolerance = 300; + } else { + Person::players[i]->damagetolerance = 200; + } } + if (visibleloading) LoadingScreen(); + if (cellophane) { Person::players[i]->proportionhead.z = 0; Person::players[i]->proportionbody.z = 0; @@ -1188,41 +1191,42 @@ void Game::Loadlevel(const std::string& name) Person::players[i]->tempanimation.Load((char *)"Tempanim", 0, 0); - Person::players[i]->headmorphness = 0; - Person::players[i]->targetheadmorphness = 1; - Person::players[i]->headmorphstart = 0; - Person::players[i]->headmorphend = 0; - - Person::players[i]->pausetime = 0; - - Person::players[i]->dead = 0; - Person::players[i]->jumppower = 5; - Person::players[i]->damage = 0; - Person::players[i]->permanentdamage = 0; - Person::players[i]->superpermanentdamage = 0; - - Person::players[i]->forwardkeydown = 0; - Person::players[i]->leftkeydown = 0; - Person::players[i]->backkeydown = 0; - Person::players[i]->rightkeydown = 0; - Person::players[i]->jumpkeydown = 0; - Person::players[i]->crouchkeydown = 0; - Person::players[i]->throwkeydown = 0; - - Person::players[i]->collided = -10; - Person::players[i]->loaded = 1; - Person::players[i]->bloodloss = 0; - Person::players[i]->weaponactive = -1; - Person::players[i]->weaponstuck = -1; - Person::players[i]->bleeding = 0; - Person::players[i]->deathbleeding = 0; - Person::players[i]->stunned = 0; - Person::players[i]->hasvictim = 0; - Person::players[i]->wentforweapon = 0; + if (i == 0) { + Person::players[i]->headmorphness = 0; + Person::players[i]->targetheadmorphness = 1; + Person::players[i]->headmorphstart = 0; + Person::players[i]->headmorphend = 0; + + Person::players[i]->pausetime = 0; + + Person::players[i]->dead = 0; + Person::players[i]->jumppower = 5; + Person::players[i]->damage = 0; + Person::players[i]->permanentdamage = 0; + Person::players[i]->superpermanentdamage = 0; + + Person::players[i]->forwardkeydown = 0; + Person::players[i]->leftkeydown = 0; + Person::players[i]->backkeydown = 0; + Person::players[i]->rightkeydown = 0; + Person::players[i]->jumpkeydown = 0; + Person::players[i]->crouchkeydown = 0; + Person::players[i]->throwkeydown = 0; + + Person::players[i]->collided = -10; + Person::players[i]->loaded = 1; + Person::players[i]->bloodloss = 0; + Person::players[i]->weaponactive = -1; + Person::players[i]->weaponstuck = -1; + Person::players[i]->bleeding = 0; + Person::players[i]->deathbleeding = 0; + Person::players[i]->stunned = 0; + Person::players[i]->hasvictim = 0; + Person::players[i]->wentforweapon = 0; + } } Person::players[0]->aitype = playercontrolled; - Person::players[0]->weaponactive = -1; if (difficulty == 1) { Person::players[0]->power = 1 / .9; diff --git a/Source/Person.cpp b/Source/Person.cpp index 59994f8..3729c4f 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -74,10 +74,10 @@ std::vector> Person::players(1, std::shared_ptr( Person::Person() : whichpatchx(0), whichpatchz(0), - animCurrent(0), - animTarget(0), + animCurrent(bounceidleanim), + animTarget(bounceidleanim), frameCurrent(0), - frameTarget(0), + frameTarget(1), oldanimCurrent(0), oldanimTarget(0), oldframeCurrent(0), @@ -127,14 +127,14 @@ Person::Person() : deathbleeding(0), tempdeltav(0), - damagetolerance(0), + damagetolerance(200), damage(0), permanentdamage(0), superpermanentdamage(0), lastcollide(0), dead(0), - jumppower(0), + jumppower(5), onground(false), wentforweapon(0), @@ -187,12 +187,12 @@ Person::Person() : turnspeed(0), - aitype(0), + aitype(passivetype), aiupdatedelay(0), losupdatedelay(0), ally(0), collide(0), - collided(0), + collided(-10), avoidcollided(0), loaded(false), whichdirection(false), @@ -213,7 +213,7 @@ Person::Person() : tailmorphness(0), targetlefthandmorphness(0), targetrighthandmorphness(0), - targetheadmorphness(0), + targetheadmorphness(1), targetchestmorphness(0), targettailmorphness(0), lefthandmorphstart(0), lefthandmorphend(0), @@ -262,7 +262,7 @@ Person::Person() : num_weapons(0), weaponactive(-1), - weaponstuck(0), + weaponstuck(-1), weaponstuckwhere(0), numwaypoints(0), @@ -399,6 +399,20 @@ Person::Person(FILE *tfile, int mapvers, unsigned i) : Person() clothes[k][templength] = '\0'; funpackf(tfile, "Bf Bf Bf", &clothestintr[k], &clothestintg[k], &clothestintb[k]); } + + loaded = true; + + if (scale < 0) { + if (creature == wolftype) { + scale = .23; + damagetolerance = 300; + } else { + scale = .2; + } + } + + oldcoords = coords; + realoldcoords = coords; } /* EFFECT