(svn r12430) [NoAI] -Fix: safeguard, don't allow AI_Event calls to players that are not AIs noai
authortruebrain
Wed, 26 Mar 2008 15:16:40 +0000
branchnoai
changeset 9822 e2f83940bc52
parent 9821 4ee8e5126dd1
child 9823 0b7f816cf46f
(svn r12430) [NoAI] -Fix: safeguard, don't allow AI_Event calls to players that are not AIs
src/ai/ai.cpp
--- a/src/ai/ai.cpp	Wed Mar 26 14:27:04 2008 +0000
+++ b/src/ai/ai.cpp	Wed Mar 26 15:16:40 2008 +0000
@@ -49,7 +49,7 @@
 	/* Check for AI-client (so joining a network with an AI) */
 	if (!_networking || _network_server) {
 		/* Check if we want to run AIs (server or SP only) */
-		const Player* p;
+		const Player *p;
 
 		FOR_ALL_PLAYERS(p) {
 			if (p->is_active && p->is_ai) {
@@ -66,6 +66,7 @@
 
 void AI_Event(PlayerID player, AIEvent *event)
 {
+	if (player >= MAX_PLAYERS || !GetPlayer(player)->is_active || !GetPlayer(player)->is_ai) return;
 	DEBUG(ai, 4, "Event (%d) for player %d\n", event->GetEventType(), player);
 
 	PlayerID old_player = _current_player;