From: Côme Chilliet Date: Fri, 6 Jan 2017 13:44:44 +0000 (+0100) Subject: Added .at usage to have clearer crash when dialogue contains invalid participant X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=475fb97fd19a8bc2c58c603d0bc5dcf8cc63b40d;p=lugaru.git Added .at usage to have clearer crash when dialogue contains invalid participant --- diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 58fb64a..9b98e78 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -214,7 +214,7 @@ inline float stepTowardf(float from, float to, float by) void Game::playdialoguescenesound() { XYZ temppos; - temppos = Person::players[Dialog::currentScene().participantfocus]->coords; + temppos = Person::players.at(Dialog::currentScene().participantfocus)->coords; temppos = temppos - viewer; Normalise(&temppos); temppos += viewer; @@ -3229,7 +3229,7 @@ void Game::Tick() hostile = 1; } - if (Person::players[Dialog::currentScene().participantfocus]->dead) { + if (Person::players.at(Dialog::currentScene().participantfocus)->dead) { Dialog::indialogue = -1; Dialog::directing = false; cameramode = 0; diff --git a/Source/Level/Dialog.cpp b/Source/Level/Dialog.cpp index 680e584..64d3015 100644 --- a/Source/Level/Dialog.cpp +++ b/Source/Level/Dialog.cpp @@ -173,7 +173,7 @@ void Dialog::play() { for (unsigned i = 0; i < scenes.size(); i++) { int playerId = scenes[i].participantfocus; - Person::players[playerId]->coords = participantlocation[playerId]; + Person::players.at(playerId)->coords = participantlocation[playerId]; Person::players[playerId]->yaw = participantyaw[playerId]; Person::players[playerId]->targetyaw = participantyaw[playerId]; Person::players[playerId]->velocity = 0; diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index 8534186..874194b 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -565,8 +565,8 @@ int Person::getIdle() { if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype)) return talkidleanim; - if (hasvictim && (victim != this->shared_from_this())/*||(id==0&&attackkeydown)*/) - if (/*(id==0&&attackkeydown)||*/(!victim->dead && victim->aitype != passivetype && + if (hasvictim && (victim != this->shared_from_this())) { + if ((!victim->dead && victim->aitype != passivetype && victim->aitype != searchtype && aitype != passivetype && aitype != searchtype && victim->id < Person::players.size())) { if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) { @@ -588,6 +588,7 @@ int Person::getIdle() if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause) return fightsidestep; } + } if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype) return hurtidleanim; if (howactive == typesitting) return sitanim;