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.
20
#ifndef __S__EDITOR_GAME_BASE_H
21
#define __S__EDITOR_GAME_BASE_H
27
#include "constants.h"
28
#include "descr_maintainer.h"
37
class Interactive_Base;
43
class Editor_Game_Base {
44
friend class Interactive_Base;
45
friend class Game_Game_Class_Data_Packet;
49
virtual ~Editor_Game_Base();
51
void set_map(Map* map);
52
inline Map *get_map() { return m_map; }
53
inline Object_Manager* get_objects() { return m_objects; }
55
void unconquer_area(uchar playernr, Coords coords);
56
void conquer_area(uchar playernr, Coords coords, Building_Descr*);
57
void conquer_area_no_building(uchar playernr, Coords coords, int radius);
60
virtual void think() = 0;
63
void remove_player(int plnum);
64
void add_player(int plnum, int type, const char* tribe, const char* name);
65
inline Player* get_player(int n) { assert(n>=1 && n<=MAX_PLAYERS); return m_players[n-1]; }
66
Player* get_safe_player(int n);
68
virtual bool is_game() = 0;
73
virtual void cleanup_for_load(bool flush_graphics=true, bool flush_animations=true);
75
// warping stuff. instantly creating map_objects
76
Building* warp_building(Coords, char owner, int idx);
77
Building* warp_constructionsite(Coords c, char owner, int idx, int oldid=-1);
78
Bob *create_bob(Coords c, int idx, Tribe_Descr* = 0);
79
Immovable* create_immovable(Coords c, int idx, Tribe_Descr*);
80
Immovable* create_immovable(Coords c, std::string name, Tribe_Descr*);
81
Battle* create_battle ();
83
std::vector<int> get_battle_serials() { return m_battle_serials; }
84
inline int get_gametime(void) { return m_gametime; }
85
Interactive_Base* get_iabase() { return m_iabase; }
87
// safe system for storing pointers to non-Map_Object C++ objects
88
// unlike objects in the Object_Manager, these pointers need not be
89
// synchronized across the network, and they are not saved in savegames
90
uint add_trackpointer(void* ptr);
91
void* get_trackpointer(uint serial);
92
void remove_trackpointer(uint serial);
94
// Manually load a tribe into memory. Used by the editor
95
void manually_load_tribe(const char* tribe);
96
// Get a tribe from the loaded list, when available
97
Tribe_Descr* get_tribe(const char* tribe);
99
enum losegain_t { LOSE=0, GAIN };
100
virtual void player_immovable_notification (PlayerImmovable*, losegain_t)=0;
101
virtual void player_field_notification (const FCoords&, losegain_t)=0;
104
std::vector<Coords>* get_attack_points(uchar player);
106
virtual void make_influence_map ();
108
/// Returns the influence value of one position (a) with the radius (radius) about (b)
109
virtual int calc_influence (Coords a, Coords b, int radius);
112
// next function is used to update the current gametime,
113
// for queue runs e.g.
114
inline int* get_game_time_pointer(void) { return &m_gametime; }
115
inline void set_iabase(Interactive_Base* b) { m_iabase=b; }
118
struct Conquer_Info {
123
std::vector<Conquer_Info> m_conquer_info;
124
void do_conquer_area(uchar playernr, Coords coords, int radius, bool conquer);
127
void cleanup_playerimmovables_area(Coords coords, int radius);
130
Player* m_players[MAX_PLAYERS];
131
Object_Manager* m_objects;
132
std::vector<Tribe_Descr*> m_tribes;
133
Interactive_Base* m_iabase;
136
uint m_lasttrackserial;
137
std::map<uint, void*> m_trackpointers;
138
// I know that this fucks, ideas ?
142
int m_conquer_map[MAX_PLAYERS+1][MAX_X][MAX_Y]; // m_conquer_map[playernr][x][y] = [quantity of influence]
143
// The playernr 0 is the REAL OWNER
144
std::vector<int> m_battle_serials; // The serials of the battles only used to load/save
147
extern const uchar g_playercolors[MAX_PLAYERS][12];
149
#endif // __S__EDITOR_GAME_BASE_H