From c9bc9b427ca3238324b3f89b690c1c1dbf4be1cf Mon Sep 17 00:00:00 2001 From: ChillyDoom Date: Tue, 21 Oct 2014 19:31:11 +0100 Subject: [PATCH] - Removed p_leader. --- src/b_bot.h | 1 + src/b_func.cpp | 33 ++++++++++++++------------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/b_bot.h b/src/b_bot.h index 7844597cd..51fe64129 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -125,6 +125,7 @@ private: //(B_Func.c) bool Reachable (AActor *actor, AActor *target); void Dofire (AActor *actor, ticcmd_t *cmd); + bool IsLeader (player_t *player); AActor *Choose_Mate (AActor *bot); AActor *Find_enemy (AActor *bot); void SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum); diff --git a/src/b_func.cpp b/src/b_func.cpp index 0c0ab1ebd..0303de8c6 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -270,6 +270,19 @@ shootmissile: //actor->angle = R_PointToAngle2(actor->x, actor->y, actor->player->enemy->x, actor->player->enemy->y); } +bool FCajunMaster::IsLeader (player_t *player) +{ + for (int count = 0; count < MAXPLAYERS; count++) + { + if (players[count].Bot != NULL + && players[count].Bot->mate == player->mo) + { + return true; + } + } + + return false; +} //This function is called every //tick (for each bot) to set @@ -277,11 +290,9 @@ shootmissile: AActor *FCajunMaster::Choose_Mate (AActor *bot) { int count; - int count2; fixed_t closest_dist, test; AActor *target; AActor *observer; - bool p_leader[MAXPLAYERS]; //is mate alive? if (bot->player->Bot->mate) @@ -299,22 +310,6 @@ AActor *FCajunMaster::Choose_Mate (AActor *bot) if (bot->player->Bot->last_mate->health <= 0) bot->player->Bot->last_mate = NULL; - for (count = 0; count < MAXPLAYERS; count++) - { - if (!playeringame[count]) - continue; - p_leader[count] = false; - for (count2 = 0; count2 < MAXPLAYERS; count2++) - { - if (players[count2].Bot != NULL - && players[count2].Bot->mate == players[count].mo) - { - p_leader[count] = true; - break; - } - } - } - target = NULL; closest_dist = FIXED_MAX; if (bot_observer) @@ -334,7 +329,7 @@ AActor *FCajunMaster::Choose_Mate (AActor *bot) && client->mo->health > 0 && client->mo != observer && ((bot->health/2) <= client->mo->health || !deathmatch) - && !p_leader[count]) //taken? + && !IsLeader(client)) //taken? { if (P_CheckSight (bot, client->mo, SF_IGNOREVISIBILITY)) {