2
0
DjWarmonger 11 жил өмнө
parent
commit
d9273b3b2a

+ 8 - 0
lib/CGameInfoCallback.cpp

@@ -73,8 +73,16 @@ bool CGameInfoCallback::isAllowed( int type, int id )
 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);
+	//if (!vstd::contains(gs->players, color))
+	//{
+	//	logGlobal->errorStream() << "Cannot access player " << color << "info!";
+	//	return nullptr; //macros are not really useful when debugging :?
+	//}
+	//else
+	//{
 	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!vstd::contains(gs->players,color), verbose, "Cannot find player " << color << "info!", nullptr);
 	return &gs->players[color];
+	//}
 }
 
 const CTown * CGameInfoCallback::getNativeTown(PlayerColor color) const

+ 1 - 1
lib/CGameState.cpp

@@ -3521,6 +3521,6 @@ CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance
 
 CRandomGenerator & CGameState::getRandomGenerator()
 {
-	logGlobal->traceStream() << "Fetching CGameState::rand with seed " << rand.nextInt();
+	//logGlobal->traceStream() << "Fetching CGameState::rand with seed " << rand.nextInt();
 	return rand;
 }

+ 4 - 2
server/CGameHandler.cpp

@@ -4757,9 +4757,11 @@ void CGameHandler::handleTimeEvents()
 	while(gs->map->events.size() && gs->map->events.front().firstOccurence+1 == gs->day)
 	{
 		CMapEvent ev = gs->map->events.front();
-		for(int player = 0; player < PlayerColor::PLAYER_LIMIT_I; player++)
+		
+		for (auto p : gs->players)
 		{
-			PlayerState *pinfo = gs->getPlayer(PlayerColor(player));
+			auto player = p.first.getNum();
+			auto pinfo = &p.second;
 
 			if( pinfo  //player exists
 				&& (ev.players & 1<<player) //event is enabled to this player