~lewiscawte/+junk/openttd-stable

« back to all changes in this revision

Viewing changes to src/ai/ai_storage.hpp

  • Committer: Lewis Cawte
  • Date: 2011-06-11 09:45:09 UTC
  • Revision ID: lewis@dev.lewiscawte.info-20110611094509-c5dqw2ot6pb9t10i
Adding stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: ai_storage.hpp 21890 2011-01-22 14:52:20Z rubidium $ */
 
2
 
 
3
/*
 
4
 * This file is part of OpenTTD.
 
5
 * 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.
 
6
 * 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.
 
7
 * 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/>.
 
8
 */
 
9
 
 
10
/** @file ai_storage.hpp Defines AIStorage and includes all files required for it. */
 
11
 
 
12
#ifndef AI_STORAGE_HPP
 
13
#define AI_STORAGE_HPP
 
14
 
 
15
#include "../signs_func.h"
 
16
#include "../vehicle_func.h"
 
17
#include "../road_type.h"
 
18
#include "../group.h"
 
19
 
 
20
#include "table/strings.h"
 
21
#include <vector>
 
22
 
 
23
/**
 
24
 * The callback function for Mode-classes.
 
25
 */
 
26
typedef bool (AIModeProc)();
 
27
 
 
28
/**
 
29
 * The storage for each AI. It keeps track of important information.
 
30
 */
 
31
class AIStorage {
 
32
friend class AIObject;
 
33
private:
 
34
        AIModeProc *mode;                ///< The current build mode we are int.
 
35
        class AIObject *mode_instance;   ///< The instance belonging to the current build mode.
 
36
 
 
37
        uint delay;                      ///< The ticks of delay each DoCommand has.
 
38
        bool allow_do_command;           ///< Is the usage of DoCommands restricted?
 
39
 
 
40
        CommandCost costs;               ///< The costs the AI is tracking.
 
41
        Money last_cost;                 ///< The last cost of the command.
 
42
        uint last_error;                 ///< The last error of the command.
 
43
        bool last_command_res;           ///< The last result of the command.
 
44
 
 
45
        VehicleID new_vehicle_id;        ///< The ID of the new Vehicle.
 
46
        SignID new_sign_id;              ///< The ID of the new Sign.
 
47
        TileIndex new_tunnel_endtile;    ///< The TileIndex of the new Tunnel.
 
48
        GroupID new_group_id;            ///< The ID of the new Group.
 
49
 
 
50
        std::vector<int> callback_value; ///< The values which need to survive a callback.
 
51
 
 
52
        RoadType road_type;              ///< The current roadtype we build.
 
53
        RailType rail_type;              ///< The current railtype we build.
 
54
 
 
55
        void *event_data;                ///< Pointer to the event data storage.
 
56
        void *log_data;                  ///< Pointer to the log data storage.
 
57
 
 
58
public:
 
59
        AIStorage() :
 
60
                mode              (NULL),
 
61
                mode_instance     (NULL),
 
62
                delay             (1),
 
63
                allow_do_command  (true),
 
64
                /* costs (can't be set) */
 
65
                last_cost         (0),
 
66
                last_error        (STR_NULL),
 
67
                last_command_res  (true),
 
68
                new_vehicle_id    (0),
 
69
                new_sign_id       (0),
 
70
                new_tunnel_endtile(INVALID_TILE),
 
71
                new_group_id      (0),
 
72
                /* calback_value (can't be set) */
 
73
                road_type         (INVALID_ROADTYPE),
 
74
                rail_type         (INVALID_RAILTYPE),
 
75
                event_data        (NULL),
 
76
                log_data          (NULL)
 
77
        { }
 
78
 
 
79
        ~AIStorage();
 
80
};
 
81
 
 
82
#endif /* AI_STORAGE_HPP */