]> git.jsancho.org Git - lugaru.git/commitdiff
Added .at usage to have clearer crash when dialogue contains invalid participant
authorCôme Chilliet <come@chilliet.eu>
Fri, 6 Jan 2017 13:44:44 +0000 (14:44 +0100)
committerCôme Chilliet <come@chilliet.eu>
Fri, 6 Jan 2017 13:44:44 +0000 (14:44 +0100)
Source/GameTick.cpp
Source/Level/Dialog.cpp
Source/Objects/Person.cpp

index 58fb64aac4fd7a467e01cbb9cf14ce390c7a4ee5..9b98e78c9e90a3817ddb209cb871adb538efaf6f 100644 (file)
@@ -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;
index 680e5845581e40880a5076e421b888b321d22936..64d30155bce7eb10e5f93452f6720196a86543e6 100644 (file)
@@ -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;
index 85341867ff47754986f6f3caccf750d3ddb073e0..874194b4a53419537c177aaf15352f9bf65002dd 100644 (file)
@@ -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;