mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
(svn r2948) -Fix: the old AI needs a special flag that triggers all kind of special
abilities you really don't want to know about (free bridges, etc..) I removed this flag some revisions ago, but the Aircraft part depends on it, so I re-enabled it again..
This commit is contained in:
parent
42813c5426
commit
2e87864d0b
6
ai/ai.c
6
ai/ai.c
@ -126,8 +126,12 @@ void AI_RunTick(byte player)
|
|||||||
|
|
||||||
if (_patches.ainew_active)
|
if (_patches.ainew_active)
|
||||||
AiNewDoGameLoop(p);
|
AiNewDoGameLoop(p);
|
||||||
else
|
else {
|
||||||
|
/* Enable all kind of cheats the old AI needs in order to operate correctly... */
|
||||||
|
_is_old_ai_player = true;
|
||||||
AiDoGameLoop(p);
|
AiDoGameLoop(p);
|
||||||
|
_is_old_ai_player = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,10 +253,9 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
_new_aircraft_id = v->index;
|
_new_aircraft_id = v->index;
|
||||||
|
|
||||||
// the AI doesn't click on a tile to build airplanes, so the below code will
|
// the old AI doesn't click on a tile to build airplanes, so the below code will
|
||||||
// never work. Therefore just assume the AI's planes always come from Hangar0
|
// never work. Therefore just assume the AI's planes always come from Hangar0
|
||||||
// On hold for NewAI
|
v->u.air.pos = _is_old_ai_player ? 0 : MAX_ELEMENTS;
|
||||||
v->u.air.pos = (!_patches.ainew_active && _is_ai_player) ? 0:MAX_ELEMENTS;
|
|
||||||
|
|
||||||
/* When we click on hangar we know the tile (it is in var 'tile')it is on. By that we know
|
/* When we click on hangar we know the tile (it is in var 'tile')it is on. By that we know
|
||||||
its position in the array of depots the airport has.....we can search
|
its position in the array of depots the airport has.....we can search
|
||||||
|
@ -247,8 +247,7 @@ static uint32 CheckRailSlope(uint tileh, TrackBits rail_bits, TrackBits existing
|
|||||||
)) { // partly up
|
)) { // partly up
|
||||||
if (existing != 0) {
|
if (existing != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!_patches.build_on_slopes ||
|
} else if (!_patches.build_on_slopes || _is_old_ai_player) {
|
||||||
(_is_ai_player && !_patches.ainew_active)) {
|
|
||||||
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
|
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
} else {
|
} else {
|
||||||
return _price.terraform;
|
return _price.terraform;
|
||||||
@ -679,7 +678,7 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (tileh != 0 && (
|
if (tileh != 0 && (
|
||||||
(!_patches.ainew_active && _is_ai_player) ||
|
_is_old_ai_player ||
|
||||||
!_patches.build_on_slopes ||
|
!_patches.build_on_slopes ||
|
||||||
IsSteepTileh(tileh) ||
|
IsSteepTileh(tileh) ||
|
||||||
!CanBuildDepotByTileh(p2, tileh)
|
!CanBuildDepotByTileh(p2, tileh)
|
||||||
|
@ -457,7 +457,7 @@ do_clear:;
|
|||||||
cost = CheckRoadSlope(ti.tileh, &pieces, existing);
|
cost = CheckRoadSlope(ti.tileh, &pieces, existing);
|
||||||
if (CmdFailed(cost)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION);
|
if (CmdFailed(cost)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
|
|
||||||
if (cost && (!_patches.build_on_slopes || (!_patches.ainew_active && _is_ai_player)))
|
if (cost && (!_patches.build_on_slopes || _is_old_ai_player))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
if (!(ti.type == MP_STREET && (ti.map5 & 0xF0) == 0)) {
|
if (!(ti.type == MP_STREET && (ti.map5 & 0xF0) == 0)) {
|
||||||
|
@ -779,7 +779,7 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
|
|||||||
b) the build_on_slopes switch is disabled
|
b) the build_on_slopes switch is disabled
|
||||||
*/
|
*/
|
||||||
if (IsSteepTileh(tileh) ||
|
if (IsSteepTileh(tileh) ||
|
||||||
(((!_patches.ainew_active && _is_ai_player) || !_patches.build_on_slopes)
|
((_is_old_ai_player || !_patches.build_on_slopes)
|
||||||
&& tileh != 0)) {
|
&& tileh != 0)) {
|
||||||
|
|
||||||
_error_message = STR_0007_FLAT_LAND_REQUIRED;
|
_error_message = STR_0007_FLAT_LAND_REQUIRED;
|
||||||
@ -1009,7 +1009,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
if (st->train_tile != 0) {
|
if (st->train_tile != 0) {
|
||||||
// check if we want to expanding an already existing station?
|
// check if we want to expanding an already existing station?
|
||||||
if ((!_patches.ainew_active && _is_ai_player) || !_patches.join_stations)
|
if (_is_old_ai_player || !_patches.join_stations)
|
||||||
return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD);
|
return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD);
|
||||||
if (!CanExpandRailroadStation(st, finalvalues, direction))
|
if (!CanExpandRailroadStation(st, finalvalues, direction))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
@ -265,7 +265,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
|
|
||||||
// Towns are not allowed to use bridges on slopes.
|
// Towns are not allowed to use bridges on slopes.
|
||||||
allow_on_slopes = ((!_is_ai_player || _patches.ainew_active)
|
allow_on_slopes = (!_is_old_ai_player
|
||||||
&& _current_player != OWNER_TOWN && _patches.build_on_slopes);
|
&& _current_player != OWNER_TOWN && _patches.build_on_slopes);
|
||||||
|
|
||||||
/* Try and clear the start landscape */
|
/* Try and clear the start landscape */
|
||||||
@ -410,7 +410,7 @@ not_valid_below:;
|
|||||||
|
|
||||||
bridge_len += 2; // begin and end tiles/ramps
|
bridge_len += 2; // begin and end tiles/ramps
|
||||||
|
|
||||||
if (_current_player < MAX_PLAYERS && !(_is_ai_player && !_patches.ainew_active))
|
if (_current_player < MAX_PLAYERS && !_is_old_ai_player)
|
||||||
bridge_len = CalcBridgeLenCostFactor(bridge_len);
|
bridge_len = CalcBridgeLenCostFactor(bridge_len);
|
||||||
|
|
||||||
cost += ((int64)bridge_len * _price.build_bridge * b->price) >> 8;
|
cost += ((int64)bridge_len * _price.build_bridge * b->price) >> 8;
|
||||||
|
@ -252,7 +252,7 @@ VARDEF byte _cur_month;
|
|||||||
|
|
||||||
VARDEF uint32 _frame_counter;
|
VARDEF uint32 _frame_counter;
|
||||||
|
|
||||||
VARDEF bool _is_ai_player; // current player is an AI player? - Can be removed if new AI is done
|
VARDEF bool _is_old_ai_player; // current player is an oldAI player? (enables a lot of cheats..)
|
||||||
|
|
||||||
VARDEF bool _do_autosave;
|
VARDEF bool _do_autosave;
|
||||||
VARDEF int _autosave_ctr;
|
VARDEF int _autosave_ctr;
|
||||||
|
Loading…
Reference in New Issue
Block a user