2
* Copyright (C) 2002-2004 by the Widelands Development Team
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
#include "editor_game_base.h"
26
#define WLGF_SUFFIX ".wgf"
27
#define WLGF_MAGIC "WLgf"
31
* This class manages the entire lifetime of a game session, from creating the
32
* game and setting options, selecting maps to the actual playing phase and the
33
* final statistics screen(s).
36
gs_none = 0, // not connected, nothing
37
gs_menu, // in the setup menu(s)
38
gs_paused, // in-game but paused
43
class Interactive_Player;
44
class Computer_Player;
50
class Game : public Editor_Game_Base {
51
friend class Cmd_Queue; // this class handles the commands
52
friend class Game_Game_Class_Data_Packet;
53
friend class Game_Player_Info_Data_Packet;
60
bool run_splayer_map_direct(const char* mapname, bool scenario);
61
bool run_single_player ();
62
bool run_multi_player (NetGame*);
63
bool run_load_game(bool);
65
void load_map (const char*);
73
void cleanup_for_load(bool t1, bool t2);
76
inline Cmd_Queue *get_cmdqueue() { return cmdqueue; }
78
// Start using logic_rand() for the actual gamelogic (e.g. critter).
79
// Do NOT use for random events in the UI or other display code.
80
// This will allow us to plug another PRNG in here for game playbacks
81
// and other fancy stuff.
82
inline uint logic_rand() { return rng->rand(); }
84
void logic_rand_seed (uint seed) { rng->seed (seed); }
86
int get_speed() const { return m_speed; }
87
void set_speed(int speed);
89
bool get_allow_cheats();
91
virtual void player_immovable_notification (PlayerImmovable*, losegain_t);
92
virtual void player_field_notification (const FCoords&, losegain_t);
94
void enqueue_command (BaseCommand*);
96
void send_player_command (PlayerCommand*);
98
void send_player_bulldoze (PlayerImmovable*);
99
void send_player_build (int, const Coords&, int);
100
void send_player_build_flag (int, const Coords&);
101
void send_player_build_road (int, Path*);
102
void send_player_flagaction (Flag*, int);
103
void send_player_start_stop_building (Building*);
104
void send_player_enhance_building (Building*, int);
105
void send_player_change_training_options(Building*, int, int);
106
void send_player_drop_soldier(Building*, int);
107
void send_player_change_soldier_capacity(Building*, int);
108
void send_player_enemyflagaction (Flag*, int, int, int, int);
110
// is this base a game
111
inline bool is_game() { return true; }
113
Interactive_Player* get_ipl(void) { return ipl; }
115
// If this has a netgame, return it
116
NetGame* get_netgame( void ) { return m_netgame; }
119
void init_player_controllers ();
120
bool run (bool = false);
122
Map_Loader* m_maploader;
127
int m_speed; // frametime multiplier
131
Interactive_Player* ipl;
132
std::vector<Computer_Player*> cpl;
135
int m_realtime; // the real time (including) pauses in milliseconds
138
#endif // __S__GAME_H