command.c
changeset 2759 c2a6fd12b41f
parent 2749 46aba09ca365
child 2767 3282c77ffc27
equal deleted inserted replaced
2758:9cd8a21e9a7b 2759:c2a6fd12b41f
   401 	bool notest;
   401 	bool notest;
   402 
   402 
   403 	int x = TileX(tile) * 16;
   403 	int x = TileX(tile) * 16;
   404 	int y = TileY(tile) * 16;
   404 	int y = TileY(tile) * 16;
   405 
   405 
       
   406 	AI_GetCommandUID(cmd, p1, p2, tile);
       
   407 
   406 	/* Do not even think about executing out-of-bounds tile-commands */
   408 	/* Do not even think about executing out-of-bounds tile-commands */
   407 	if (tile > MapSize()) {
   409 	if (tile > MapSize()) {
   408 		_cmd_text = NULL;
   410 		_cmd_text = NULL;
   409 		return false;
   411 		return false;
   410 	}
   412 	}
   475 		res = proc(x,y, flags, p1, p2);
   477 		res = proc(x,y, flags, p1, p2);
   476 		if (CmdFailed(res)) {
   478 		if (CmdFailed(res)) {
   477 			if (res & 0xFFFF) _error_message = res & 0xFFFF;
   479 			if (res & 0xFFFF) _error_message = res & 0xFFFF;
   478 			/* Trigger an event special for the AI, so it knows the build has failed
   480 			/* Trigger an event special for the AI, so it knows the build has failed
   479 			 *  Because the commands are always delayed, this is the only way. */
   481 			 *  Because the commands are always delayed, this is the only way. */
   480 			AI_CommandResult(cmd, p1, p2, tile, false);
   482 			AI_CommandResult(false);
   481 			goto show_error;
   483 			goto show_error;
   482 		}
   484 		}
   483 		// no money? Only check if notest is off
   485 		// no money? Only check if notest is off
   484 		if (!notest && res != 0 && !CheckPlayerHasMoney(res)) {
   486 		if (!notest && res != 0 && !CheckPlayerHasMoney(res)) {
   485 			AI_CommandResult(cmd, p1, p2, tile, false);
   487 			AI_CommandResult(false);
   486 			goto show_error;
   488 			goto show_error;
   487 		}
   489 		}
   488 	}
   490 	}
   489 
   491 
   490 #ifdef ENABLE_NETWORK
   492 #ifdef ENABLE_NETWORK
   517 	if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
   519 	if (!notest && !((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
   518 		assert(res == res2); // sanity check
   520 		assert(res == res2); // sanity check
   519 	} else {
   521 	} else {
   520 		if (CmdFailed(res2)) {
   522 		if (CmdFailed(res2)) {
   521 			if (res2 & 0xFFFF) _error_message = res2 & 0xFFFF;
   523 			if (res2 & 0xFFFF) _error_message = res2 & 0xFFFF;
   522 			AI_CommandResult(cmd, p1, p2, tile, false);
   524 			AI_CommandResult(false);
   523 			goto show_error;
   525 			goto show_error;
   524 		}
   526 		}
   525 	}
   527 	}
   526 
   528 
   527 	AI_CommandResult(cmd, p1, p2, tile, true);
   529 	AI_CommandResult(true);
   528 
   530 
   529 	SubtractMoneyFromPlayer(res2);
   531 	SubtractMoneyFromPlayer(res2);
   530 
   532 
   531 	if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
   533 	if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
   532 		if (res2 != 0)
   534 		if (res2 != 0)