~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/ai/api/ai_gamesettings.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: ai_gamesettings.cpp 15410 2009-02-08 12:25:13Z rubidium $ */
 
2
 
 
3
/** @file ai_gamesettings.cpp Implementation of AIGameSettings. */
 
4
 
 
5
#include "ai_gamesettings.hpp"
 
6
#include "../../settings_internal.h"
 
7
 
 
8
/* static */ bool AIGameSettings::IsValid(const char *setting)
 
9
{
 
10
        uint i;
 
11
        const SettingDesc *sd = GetSettingFromName(setting, &i);
 
12
        return sd != NULL && sd->desc.cmd != SDT_STRING;
 
13
}
 
14
 
 
15
/* static */ int32 AIGameSettings::GetValue(const char *setting)
 
16
{
 
17
        if (!IsValid(setting)) return -1;
 
18
 
 
19
        uint i;
 
20
        const SettingDesc *sd = GetSettingFromName(setting, &i);
 
21
 
 
22
        void *ptr = GetVariableAddress(&_settings_game, &sd->save);
 
23
        if (sd->desc.cmd == SDT_BOOLX) return *(bool*)ptr;
 
24
 
 
25
        return (int32)ReadValue(ptr, sd->save.conv);
 
26
}
 
27
 
 
28
/* static */ bool AIGameSettings::IsDisabledVehicleType(AIVehicle::VehicleType vehicle_type)
 
29
{
 
30
        switch (vehicle_type) {
 
31
                case AIVehicle::VT_RAIL:  return _settings_game.ai.ai_disable_veh_train;
 
32
                case AIVehicle::VT_ROAD:  return _settings_game.ai.ai_disable_veh_roadveh;
 
33
                case AIVehicle::VT_WATER: return _settings_game.ai.ai_disable_veh_ship;
 
34
                case AIVehicle::VT_AIR:   return _settings_game.ai.ai_disable_veh_aircraft;
 
35
                default:                       return true;
 
36
        }
 
37
}