From 67d313cf25855fa3bb9c9a916b67a02740f88f4b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 26 May 2017 11:54:42 +0300 Subject: [PATCH] Fixed megasphere item selection in bot code https://forum.zdoom.org/viewtopic.php?t=56604 --- src/b_think.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/b_think.cpp b/src/b_think.cpp index f0b4380c00..696af9c15f 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -395,10 +395,12 @@ void DBot::WhatToGet (AActor *item) else if (item->GetClass()->TypeName == NAME_Megasphere || item->IsKindOf(NAME_Health)) { // do the test with the health item that's actually given. - if (item->GetClass()->TypeName == NAME_Megasphere) item = GetDefaultByName("MegasphereHealth"); - if (item != nullptr) + AActor* const testItem = NAME_Megasphere == item->GetClass()->TypeName + ? GetDefaultByName("MegasphereHealth") + : item; + if (nullptr != testItem) { - int maxhealth = P_GetRealMaxHealth(player->mo, item->IntVar(NAME_MaxAmount)); + const int maxhealth = P_GetRealMaxHealth(player->mo, testItem->IntVar(NAME_MaxAmount)); if (player->mo->health >= maxhealth) return; }