network_client.c
changeset 2684 4df784e4be66
parent 2373 e073ec69bf56
child 2702 9172e3030a35
equal deleted inserted replaced
2683:ca9645a21734 2684:4df784e4be66
    17 #include "gfx.h"
    17 #include "gfx.h"
    18 #include "window.h"
    18 #include "window.h"
    19 #include "settings.h"
    19 #include "settings.h"
    20 #include "console.h"
    20 #include "console.h"
    21 #include "variables.h"
    21 #include "variables.h"
       
    22 #include "ai/ai.h"
    22 
    23 
    23 
    24 
    24 // This file handles all the client-commands
    25 // This file handles all the client-commands
    25 
    26 
    26 
    27 
   340 
   341 
   341 	if (MY_CLIENT->quited)
   342 	if (MY_CLIENT->quited)
   342 		return NETWORK_RECV_STATUS_CONN_LOST;
   343 		return NETWORK_RECV_STATUS_CONN_LOST;
   343 
   344 
   344 	/* Do we receive a change of data? Most likely we changed playas */
   345 	/* Do we receive a change of data? Most likely we changed playas */
   345 	if (index == _network_own_client_index)
   346 	if (index == _network_own_client_index) {
   346 		_network_playas = playas;
   347 		_network_playas = playas;
       
   348 
       
   349 		/* Are we a ai-network-client? */
       
   350 		if (_ai.network_client) {
       
   351 			if (_ai.network_playas == OWNER_SPECTATOR)
       
   352 				AI_StartNewAI(playas - 1);
       
   353 
       
   354 			_ai.network_playas = playas - 1;
       
   355 		}
       
   356 	}
   347 
   357 
   348 	ci = NetworkFindClientInfoFromIndex(index);
   358 	ci = NetworkFindClientInfoFromIndex(index);
   349 	if (ci != NULL) {
   359 	if (ci != NULL) {
   350 		if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
   360 		if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
   351 			// Client name changed, display the change
   361 			// Client name changed, display the change
   529 			_local_player = _network_playas - 1;
   539 			_local_player = _network_playas - 1;
   530 			_patches.autorenew = GetPlayer(_local_player)->engine_renew;
   540 			_patches.autorenew = GetPlayer(_local_player)->engine_renew;
   531 			_patches.autorenew_months = GetPlayer(_local_player)->engine_renew_months;
   541 			_patches.autorenew_months = GetPlayer(_local_player)->engine_renew_months;
   532 			_patches.autorenew_money = GetPlayer(_local_player)->engine_renew_money;
   542 			_patches.autorenew_money = GetPlayer(_local_player)->engine_renew_money;
   533 			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
   543 			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
       
   544 		}
       
   545 
       
   546 		/* Check if we are an ai-network-client, and if so, disable GUI */
       
   547 		if (_ai.network_client) {
       
   548 			_ai.network_playas = _local_player;
       
   549 			_local_player      = OWNER_SPECTATOR;
       
   550 
       
   551 			if (_ai.network_playas != OWNER_SPECTATOR) {
       
   552 				/* If we didn't join the game as a spectator, activate the AI */
       
   553 				AI_StartNewAI(_ai.network_playas);
       
   554 			}
   534 		}
   555 		}
   535 	}
   556 	}
   536 
   557 
   537 	return NETWORK_RECV_STATUS_OKAY;
   558 	return NETWORK_RECV_STATUS_OKAY;
   538 }
   559 }