1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

AI: removed redundant checks

The pointers "up" and "down" were checked against nullptr
but it's always non-null
Also added curly braces for if statement. It's good practice
for avoiding shooting yourself to the foot

Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
This commit is contained in:
Maxim Korotkov 2023-09-26 15:48:21 +03:00
parent e8fdf46a29
commit f874d27797

View File

@ -702,8 +702,8 @@ void AIGateway::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstan
LOG_TRACE_PARAMS(logAi, "removableUnits '%i', queryID '%i'", removableUnits % queryID); LOG_TRACE_PARAMS(logAi, "removableUnits '%i', queryID '%i'", removableUnits % queryID);
NET_EVENT_HANDLER; NET_EVENT_HANDLER;
std::string s1 = up ? up->nodeName() : "NONE"; std::string s1 = up->nodeName();
std::string s2 = down ? down->nodeName() : "NONE"; std::string s2 = down->nodeName();
status.addQuery(queryID, boost::str(boost::format("Garrison dialog with %s and %s") % s1 % s2)); status.addQuery(queryID, boost::str(boost::format("Garrison dialog with %s and %s") % s1 % s2));
@ -711,7 +711,9 @@ void AIGateway::showGarrisonDialog(const CArmedInstance * up, const CGHeroInstan
requestActionASAP([=]() requestActionASAP([=]()
{ {
if(removableUnits && up->tempOwner == down->tempOwner) if(removableUnits && up->tempOwner == down->tempOwner)
{
pickBestCreatures(down, up); pickBestCreatures(down, up);
}
answerQuery(queryID, 0); answerQuery(queryID, 0);
}); });