# ai_gamesettings.cpp

Go to the documentation of this file.

    00001 /* $Id: ai_gamesettings.cpp 15410 2009-02-08 12:25:13Z rubidium $ */
    00002
    00005 #include "ai_gamesettings.hpp"
    00006 #include "../../settings_internal.h"
    00007
    00008 /* static */ bool AIGameSettings::IsValid(const char *setting)
    00009 {
    00010   uint i;
    00011   const SettingDesc *sd = GetSettingFromName(setting, &i);
    00012   return sd != NULL && sd->desc.cmd != SDT_STRING;
    00013 }
    00014
    00015 /* static */ int32 AIGameSettings::GetValue(const char *setting)
    00016 {
    00017   if (!IsValid(setting)) return -1;
    00018
    00019   uint i;
    00020   const SettingDesc *sd = GetSettingFromName(setting, &i);
    00021
    00022   void *ptr = GetVariableAddress(&_settings_game, &sd->save);
    00023   if (sd->desc.cmd == SDT_BOOLX) return *(bool*)ptr;
    00024
    00025   return (int32)ReadValue(ptr, sd->save.conv);
    00026 }
    00027
    00028 /* static */ bool AIGameSettings::IsDisabledVehicleType(AIVehicle::VehicleType vehicle_type)
    00029 {
    00030   switch (vehicle_type) {
    00031     case AIVehicle::VT_RAIL:  return _settings_game.ai.ai_disable_veh_train;
    00032     case AIVehicle::VT_ROAD:  return _settings_game.ai.ai_disable_veh_roadveh;
    00033     case AIVehicle::VT_WATER: return _settings_game.ai.ai_disable_veh_ship;
    00034     case AIVehicle::VT_AIR:   return _settings_game.ai.ai_disable_veh_aircraft;
    00035     default:                       return true;
    00036   }
    00037 }