00001 /* $Id$ */ 00002 00003 /* 00004 * This file is part of OpenTTD. 00005 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. 00006 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00007 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. 00008 */ 00009 00012 #include "ai_gamesettings.hpp" 00013 #include "../../settings_internal.h" 00014 00015 /* static */ bool AIGameSettings::IsValid(const char *setting) 00016 { 00017 uint i; 00018 const SettingDesc *sd = GetSettingFromName(setting, &i); 00019 return sd != NULL && sd->desc.cmd != SDT_STRING; 00020 } 00021 00022 /* static */ int32 AIGameSettings::GetValue(const char *setting) 00023 { 00024 if (!IsValid(setting)) return -1; 00025 00026 uint i; 00027 const SettingDesc *sd = GetSettingFromName(setting, &i); 00028 00029 void *ptr = GetVariableAddress(&_settings_game, &sd->save); 00030 if (sd->desc.cmd == SDT_BOOLX) return *(bool*)ptr; 00031 00032 return (int32)ReadValue(ptr, sd->save.conv); 00033 } 00034 00035 /* static */ bool AIGameSettings::IsDisabledVehicleType(AIVehicle::VehicleType vehicle_type) 00036 { 00037 switch (vehicle_type) { 00038 case AIVehicle::VT_RAIL: return _settings_game.ai.ai_disable_veh_train; 00039 case AIVehicle::VT_ROAD: return _settings_game.ai.ai_disable_veh_roadveh; 00040 case AIVehicle::VT_WATER: return _settings_game.ai.ai_disable_veh_ship; 00041 case AIVehicle::VT_AIR: return _settings_game.ai.ai_disable_veh_aircraft; 00042 default: return true; 00043 } 00044 }