mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Optimization for CGameInfoCallback:getPlayer function. It also seems to be called more often than needed.
This commit is contained in:
parent
cdad9f88b7
commit
70801309bd
@ -61,17 +61,26 @@ bool CGameInfoCallback::isAllowed( int type, int id )
|
|||||||
|
|
||||||
const PlayerState * CGameInfoCallback::getPlayer(PlayerColor color, bool verbose) const
|
const PlayerState * CGameInfoCallback::getPlayer(PlayerColor color, bool verbose) const
|
||||||
{
|
{
|
||||||
ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!hasAccess(color), verbose, "Cannot access player " << color << "info!", nullptr);
|
//funtion written from scratch since it's accessed A LOT by AI
|
||||||
//if (!vstd::contains(gs->players, color))
|
|
||||||
//{
|
auto player = gs->players.find(color);
|
||||||
// logGlobal->errorStream() << "Cannot access player " << color << "info!";
|
if (player != gs->players.end())
|
||||||
// return nullptr; //macros are not really useful when debugging :?
|
{
|
||||||
//}
|
if (hasAccess(color))
|
||||||
//else
|
return &player->second;
|
||||||
//{
|
else
|
||||||
ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!vstd::contains(gs->players,color), verbose, "Cannot find player " << color << "info!", nullptr);
|
{
|
||||||
return &gs->players[color];
|
if (verbose)
|
||||||
//}
|
logGlobal->errorStream() << boost::format("Cannot access player %d info!") % color;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
logGlobal->errorStream() << boost::format("Cannot find player %d info!") % color;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CTown * CGameInfoCallback::getNativeTown(PlayerColor color) const
|
const CTown * CGameInfoCallback::getNativeTown(PlayerColor color) const
|
||||||
|
Loading…
Reference in New Issue
Block a user