src/ai/ai.cpp
changeset 9413 7042a8ec3fa8
parent 9358 2e1e4d2f71dd
child 9652 0405e98d8e96
equal deleted inserted replaced
9412:163c465bf250 9413:7042a8ec3fa8
   152 	extern void AiNewDoGameLoop(Player *p);
   152 	extern void AiNewDoGameLoop(Player *p);
   153 
   153 
   154 	Player *p = GetPlayer(player);
   154 	Player *p = GetPlayer(player);
   155 	_current_player = player;
   155 	_current_player = player;
   156 
   156 
   157 	if (_settings.ai.ainew_active) {
   157 	if (_settings_game.ai.ainew_active) {
   158 		AiNewDoGameLoop(p);
   158 		AiNewDoGameLoop(p);
   159 	} else {
   159 	} else {
   160 		/* Enable all kind of cheats the old AI needs in order to operate correctly... */
   160 		/* Enable all kind of cheats the old AI needs in order to operate correctly... */
   161 		_is_old_ai_player = true;
   161 		_is_old_ai_player = true;
   162 		AiDoGameLoop(p);
   162 		AiDoGameLoop(p);
   176 {
   176 {
   177 	/* Don't do anything if ai is disabled */
   177 	/* Don't do anything if ai is disabled */
   178 	if (!_ai.enabled) return;
   178 	if (!_ai.enabled) return;
   179 
   179 
   180 	/* Don't do anything if we are a network-client, or the AI has been disabled */
   180 	/* Don't do anything if we are a network-client, or the AI has been disabled */
   181 	if (_networking && (!_network_server || !_settings.ai.ai_in_multiplayer)) return;
   181 	if (_networking && (!_network_server || !_settings_game.ai.ai_in_multiplayer)) return;
   182 
   182 
   183 	/* New tick */
   183 	/* New tick */
   184 	_ai.tick++;
   184 	_ai.tick++;
   185 
   185 
   186 	/* Make sure the AI follows the difficulty rule.. */
   186 	/* Make sure the AI follows the difficulty rule.. */
   187 	assert(_settings.difficulty.competitor_speed <= 4);
   187 	assert(_settings_game.difficulty.competitor_speed <= 4);
   188 	if ((_ai.tick & ((1 << (4 - _settings.difficulty.competitor_speed)) - 1)) != 0) return;
   188 	if ((_ai.tick & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
   189 
   189 
   190 	/* Check for AI-client (so joining a network with an AI) */
   190 	/* Check for AI-client (so joining a network with an AI) */
   191 	if (!_networking || _network_server) {
   191 	if (!_networking || _network_server) {
   192 		/* Check if we want to run AIs (server or SP only) */
   192 		/* Check if we want to run AIs (server or SP only) */
   193 		const Player* p;
   193 		const Player* p;