diff options
author | rubidium <rubidium@openttd.org> | 2008-05-29 15:13:28 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-05-29 15:13:28 +0000 |
commit | 923e21129c94c36bb403e955a1f334ef34722e8b (patch) | |
tree | 59059f0a1aba0794fa770e8c9a19312e4ce300af /src/ai | |
parent | 2a816fb685b373e38347f809bcdc7f2fdef0139c (diff) | |
download | openttd-923e21129c94c36bb403e955a1f334ef34722e8b.tar.xz |
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/ai.cpp | 8 | ||||
-rw-r--r-- | src/ai/ai.h | 4 | ||||
-rw-r--r-- | src/ai/default/default.cpp | 26 | ||||
-rw-r--r-- | src/ai/trolly/trolly.cpp | 22 |
4 files changed, 30 insertions, 30 deletions
diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp index b72efc921..fafafbc21 100644 --- a/src/ai/ai.cpp +++ b/src/ai/ai.cpp @@ -154,7 +154,7 @@ static void AI_RunTick(PlayerID player) Player *p = GetPlayer(player); _current_player = player; - if (_settings.ai.ainew_active) { + if (_settings_game.ai.ainew_active) { AiNewDoGameLoop(p); } else { /* Enable all kind of cheats the old AI needs in order to operate correctly... */ @@ -178,14 +178,14 @@ void AI_RunGameLoop() if (!_ai.enabled) return; /* Don't do anything if we are a network-client, or the AI has been disabled */ - if (_networking && (!_network_server || !_settings.ai.ai_in_multiplayer)) return; + if (_networking && (!_network_server || !_settings_game.ai.ai_in_multiplayer)) return; /* New tick */ _ai.tick++; /* Make sure the AI follows the difficulty rule.. */ - assert(_settings.difficulty.competitor_speed <= 4); - if ((_ai.tick & ((1 << (4 - _settings.difficulty.competitor_speed)) - 1)) != 0) return; + assert(_settings_game.difficulty.competitor_speed <= 4); + if ((_ai.tick & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return; /* Check for AI-client (so joining a network with an AI) */ if (!_networking || _network_server) { diff --git a/src/ai/ai.h b/src/ai/ai.h index 373cae191..e7c1b1f64 100644 --- a/src/ai/ai.h +++ b/src/ai/ai.h @@ -67,14 +67,14 @@ static inline bool AI_AllowNewAI() /* If in network, and server, possible AI */ if (_networking && _network_server) { /* Do we want AIs in multiplayer? */ - if (!_settings.ai.ai_in_multiplayer) + if (!_settings_game.ai.ai_in_multiplayer) return false; /* Only the NewAI is allowed... sadly enough the old AI just doesn't support this * system, because all commands are delayed by at least 1 tick, which causes * a big problem, because it uses variables that are only set AFTER the command * is really executed... */ - if (!_settings.ai.ainew_active) + if (!_settings_game.ai.ainew_active) return false; } diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 14fc43392..1e5fcbcb8 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -1570,21 +1570,21 @@ static void AiStateWantNewRoute(Player *p) for (;;) { r = (uint16)Random(); - if (_settings.ai.ai_disable_veh_train && - _settings.ai.ai_disable_veh_roadveh && - _settings.ai.ai_disable_veh_aircraft && - _settings.ai.ai_disable_veh_ship) { + if (_settings_game.ai.ai_disable_veh_train && + _settings_game.ai.ai_disable_veh_roadveh && + _settings_game.ai.ai_disable_veh_aircraft && + _settings_game.ai.ai_disable_veh_ship) { return; } if (r < 0x7626) { - if (_settings.ai.ai_disable_veh_train) continue; + if (_settings_game.ai.ai_disable_veh_train) continue; AiWantTrainRoute(p); } else if (r < 0xC4EA) { - if (_settings.ai.ai_disable_veh_roadveh) continue; + if (_settings_game.ai.ai_disable_veh_roadveh) continue; AiWantRoadRoute(p); } else if (r < 0xD89B) { - if (_settings.ai.ai_disable_veh_aircraft) continue; + if (_settings_game.ai.ai_disable_veh_aircraft) continue; AiWantAircraftRoute(p); } else { /* Ships are not implemented in this (broken) AI */ @@ -1603,7 +1603,7 @@ static void AiStateWantNewRoute(Player *p) static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo) { - uint rad = (_settings.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; + uint rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; for (; p->mode != 4; p++) { AcceptedCargo values; @@ -2550,7 +2550,7 @@ handle_nocash: bool is_pass = ( _players_ai[p->index].cargo_type == CT_PASSENGERS || _players_ai[p->index].cargo_type == CT_MAIL || - (_settings.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) + (_settings_game.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) ); Order order; @@ -2599,7 +2599,7 @@ static bool AiCheckRoadResources(TileIndex tile, const AiDefaultBlockData *p, by uint values[NUM_CARGO]; int rad; - if (_settings.station.modified_catchment) { + if (_settings_game.station.modified_catchment) { rad = CA_TRUCK; // Same as CA_BUS at the moment? } else { // change that at some point? rad = 4; @@ -3285,7 +3285,7 @@ static void AiStateBuildRoadVehicles(Player *p) bool is_pass = ( _players_ai[p->index].cargo_type == CT_PASSENGERS || _players_ai[p->index].cargo_type == CT_MAIL || - (_settings.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) + (_settings_game.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES) ); Order order; @@ -3423,7 +3423,7 @@ static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p, const AirportFTAClass* airport = GetAirport(p->attr); uint w = airport->size_x; uint h = airport->size_y; - uint rad = _settings.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED; + uint rad = _settings_game.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED; if (cargo & 0x80) { GetProductionAroundTiles(values, tile2, w, h, rad); @@ -3975,7 +3975,7 @@ void AiDoGameLoop(Player *p) // to the patch-setting // Also, it takes into account the setting if the service-interval is in days // or in % - _ai_service_interval = _settings.vehicle.servint_ispercent ? 80 : 180; + _ai_service_interval = _settings_game.vehicle.servint_ispercent ? 80 : 180; if (IsHumanPlayer(_current_player)) return; diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp index cb572e486..849afb318 100644 --- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -130,9 +130,9 @@ static void AiNew_State_WakeUp(Player *p) // Check all vehicles once in a while _players_ainew[p->index].action = AI_ACTION_CHECK_ALL_VEHICLES; _players_ainew[p->index].last_vehiclecheck_date = _date; - } else if (c < 100 && !_settings.ai.ai_disable_veh_roadveh) { + } else if (c < 100 && !_settings_game.ai.ai_disable_veh_roadveh) { // Do we have any spots for road-vehicles left open? - if (GetFreeUnitNumber(VEH_ROAD) <= _settings.vehicle.max_roadveh) { + if (GetFreeUnitNumber(VEH_ROAD) <= _settings_game.vehicle.max_roadveh) { if (c < 85) { _players_ainew[p->index].action = AI_ACTION_TRUCK_ROUTE; } else { @@ -140,8 +140,8 @@ static void AiNew_State_WakeUp(Player *p) } } #if 0 - } else if (c < 200 && !_settings.ai.ai_disable_veh_train) { - if (GetFreeUnitNumber(VEH_TRAIN) <= _settings.vehicle.max_trains) { + } else if (c < 200 && !_settings_game.ai.ai_disable_veh_train) { + if (GetFreeUnitNumber(VEH_TRAIN) <= _settings_game.vehicle.max_trains) { _players_ainew[p->index].action = AI_ACTION_TRAIN_ROUTE; } #endif @@ -155,7 +155,7 @@ static void AiNew_State_WakeUp(Player *p) return; } - if (_settings.ai.ai_disable_veh_roadveh && ( + if (_settings_game.ai.ai_disable_veh_roadveh && ( _players_ainew[p->index].action == AI_ACTION_BUS_ROUTE || _players_ainew[p->index].action == AI_ACTION_TRUCK_ROUTE )) { @@ -179,7 +179,7 @@ static void AiNew_State_WakeUp(Player *p) // to build the route anyway.. if (_players_ainew[p->index].action == AI_ACTION_BUS_ROUTE && money > AI_MINIMUM_BUS_ROUTE_MONEY) { - if (GetFreeUnitNumber(VEH_ROAD) > _settings.vehicle.max_roadveh) { + if (GetFreeUnitNumber(VEH_ROAD) > _settings_game.vehicle.max_roadveh) { _players_ainew[p->index].action = AI_ACTION_NONE; return; } @@ -190,7 +190,7 @@ static void AiNew_State_WakeUp(Player *p) } if (_players_ainew[p->index].action == AI_ACTION_TRUCK_ROUTE && money > AI_MINIMUM_TRUCK_ROUTE_MONEY) { - if (GetFreeUnitNumber(VEH_ROAD) > _settings.vehicle.max_roadveh) { + if (GetFreeUnitNumber(VEH_ROAD) > _settings_game.vehicle.max_roadveh) { _players_ainew[p->index].action = AI_ACTION_NONE; return; } @@ -1017,7 +1017,7 @@ static void AiNew_State_BuildPath(Player *p) if (_players_ainew[p->index].temp == -1) { DEBUG(ai, 1, "Starting to build new path"); // Init the counter - _players_ainew[p->index].counter = (4 - _settings.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1; + _players_ainew[p->index].counter = (4 - _settings_game.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1; // Set the position to the startingplace (-1 because in a minute we do ++) _players_ainew[p->index].path_info.position = -1; // And don't do this again @@ -1026,7 +1026,7 @@ static void AiNew_State_BuildPath(Player *p) // Building goes very fast on normal rate, so we are going to slow it down.. // By let the counter count from AI_BUILDPATH_PAUSE to 0, we have a nice way :) if (--_players_ainew[p->index].counter != 0) return; - _players_ainew[p->index].counter = (4 - _settings.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1; + _players_ainew[p->index].counter = (4 - _settings_game.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1; // Increase the building position _players_ainew[p->index].path_info.position++; @@ -1035,7 +1035,7 @@ static void AiNew_State_BuildPath(Player *p) if (_players_ainew[p->index].path_info.position == -2) { // This means we are done building! - if (_players_ainew[p->index].tbt == AI_TRUCK && !_settings.pf.roadveh_queue) { + if (_players_ainew[p->index].tbt == AI_TRUCK && !_settings_game.pf.roadveh_queue) { // If they not queue, they have to go up and down to try again at a station... // We don't want that, so try building some road left or right of the station DiagDirection dir1, dir2, dir3; @@ -1186,7 +1186,7 @@ static void AiNew_State_GiveOrders(Player *p) } // Very handy for AI, goto depot.. but yeah, it needs to be activated ;) - if (_settings.order.gotodepot) { + if (_settings_game.order.gotodepot) { idx = 0; order.MakeGoToDepot(GetDepotByTile(_players_ainew[p->index].depot_tile)->index, ODTFB_PART_OF_ORDERS); AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER); |