_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

upgrade_structs.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1999-2007 by Vladi Belperchinov-Shabanski and
14 // Jimmy Salmon
15 //
16 // This program is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; only version 2 of the License.
19 //
20 // This program is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU General Public License for more details.
24 //
25 // You should have received a copy of the GNU General Public License
26 // along with this program; if not, write to the Free Software
27 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 // 02111-1307, USA.
29 //
30 
31 #ifndef __UPGRADE_STRUCTS_H__
32 #define __UPGRADE_STRUCTS_H__
33 
35 
36 /*----------------------------------------------------------------------------
37 -- Includes
38 ----------------------------------------------------------------------------*/
39 
40 #include <vector>
41 
42 /*----------------------------------------------------------------------------
43 -- Defines
44 ----------------------------------------------------------------------------*/
45 
46 /*----------------------------------------------------------------------------
47 -- Declarations
48 ----------------------------------------------------------------------------*/
49 
50 class CUnitType;
51 class CVariable;
52 class CIcon;
53 struct lua_State;
54 
58 enum CostType {
60 
61  // standard
65  // extensions
69 
71 };
72 
73 #define FoodCost MaxCosts
74 #define ScoreCost (MaxCosts + 1)
75 #define ManaResCost (MaxCosts + 2)
76 #define FreeWorkersCount (MaxCosts + 3)
77 
81 extern int DefaultResources[MaxCosts];
82 
86 extern int DefaultResourcesLow[MaxCosts];
87 
92 
96 extern int DefaultResourcesHigh[MaxCosts];
97 
101 extern int DefaultIncomes[MaxCosts];
102 
106 extern std::string DefaultActions[MaxCosts];
107 
111 extern std::string DefaultResourceNames[MaxCosts];
112 
116 extern int DefaultResourceAmounts[MaxCosts];
117 
122 
123 extern int GetResourceIdByName(const char *resourceName);
124 extern int GetResourceIdByName(lua_State *l, const char *resourceName);
125 
130 {
131 public:
133  {
134  memset(Costs, 0, sizeof(Costs));
135  memset(Storing, 0, sizeof(Storing));
136  }
137  ~CUnitStats();
138 
139  const CUnitStats &operator = (const CUnitStats &rhs);
140 
141  bool operator == (const CUnitStats &rhs) const;
142  bool operator != (const CUnitStats &rhs) const;
143 public:
147 };
148 
152 class CUpgrade
153 {
154 public:
155  CUpgrade(const std::string &ident);
156  ~CUpgrade();
157 
158  static CUpgrade *New(const std::string &ident);
159  static CUpgrade *Get(const std::string &ident);
160 
161  void SetIcon(CIcon *icon);
162 
163  std::string Ident;
164  std::string Name;
165  int ID;
167  // TODO: not used by buttons
169 };
170 
171 /*----------------------------------------------------------------------------
172 -- upgrades and modifiers
173 ----------------------------------------------------------------------------*/
174 
181 {
182 public:
184  {
185  memset(ChangeUnits, 0, sizeof(ChangeUnits));
186  memset(ChangeUpgrades, 0, sizeof(ChangeUpgrades));
187  memset(ApplyTo, 0, sizeof(ApplyTo));
188  }
190  {
191  delete [] this->ModifyPercent;
192  }
193 
194  int UpgradeId;
195 
199 
200  // allow/forbid bitmaps -- used as chars for example:
201  // `?' -- leave as is, `F' -- forbid, `A' -- allow
202  // TODO: see below allow more semantics?
203  // TODO: pointers or ids would be faster and less memory use
207 
209 };
210 
224 class CAllow
225 {
226 public:
227  CAllow() { this->Clear(); }
228 
229  void Clear()
230  {
231  memset(Units, 0, sizeof(Units));
232  memset(Upgrades, 0, sizeof(Upgrades));
233  }
234 
237 };
238 
244 {
245 public:
246  CUpgradeTimers() { this->Clear(); }
247 
248  void Clear()
249  {
250  memset(Upgrades, 0, sizeof(Upgrades));
251  }
252 
258 };
259 
260 /*----------------------------------------------------------------------------
261 -- Variables
262 ----------------------------------------------------------------------------*/
263 
264 extern std::vector<CUpgrade *> AllUpgrades;
265 
267 
268 #endif // !__UPGRADE_STRUCTS_H__
int UpgradeId
Definition: upgrade_structs.h:194
~CUpgradeModifier()
Definition: upgrade_structs.h:189
void SetIcon(CIcon *icon)
std::string Ident
Definition: upgrade_structs.h:163
wood resource
Definition: upgrade_structs.h:64
int DefaultResources[MaxCosts]
Definition: unittype.h:117
resource 6
Definition: upgrade_structs.h:70
CUpgradeTimers()
Definition: upgrade_structs.h:246
bool operator==(const CUnitStats &rhs) const
Definition: upgrade.cpp:102
void Clear()
Definition: upgrade_structs.h:248
void Clear()
Definition: upgrade_structs.h:229
char ChangeUpgrades[UpgradeMax]
add/remove allowed units
Definition: upgrade_structs.h:205
int DefaultResourcesLow[MaxCosts]
oil resource
Definition: upgrade_structs.h:66
~CUnitStats()
Definition: upgrade.cpp:83
static CUpgrade * New(const std::string &ident)
Definition: upgrade.cpp:140
CUnitStats Modifier
used to filter required modifier
Definition: upgrade_structs.h:196
bool operator!=(const CUnitStats &rhs) const
Definition: upgrade.cpp:120
resource 5
Definition: upgrade_structs.h:68
Definition: upgrade_structs.h:180
CUpgrade(const std::string &ident)
Definition: upgrade.cpp:125
int Upgrades[UpgradeMax]
Definition: upgrade_structs.h:257
CAllow()
Definition: upgrade_structs.h:227
int GetResourceIdByName(const char *resourceName)
Definition: unittype.cpp:591
Definition: unittype.h:430
int DefaultResourcesHigh[MaxCosts]
int Storing[MaxCosts]
current costs of the unit
Definition: upgrade_structs.h:146
CIcon * Icon
costs for the upgrade
Definition: upgrade_structs.h:168
resource 4
Definition: upgrade_structs.h:67
Definition: upgrade_structs.h:243
std::string Name
identifier
Definition: upgrade_structs.h:164
#define UpgradeMax
Definition: stratagus.h:160
std::string DefaultResourceNames[MaxCosts]
Definition: unittype.cpp:570
CostType
Definition: upgrade_structs.h:58
int DefaultResourcesMedium[MaxCosts]
const CUnitStats & operator=(const CUnitStats &rhs)
Definition: upgrade.cpp:88
int Costs[MaxCosts]
user defined variable.
Definition: upgrade_structs.h:145
CVariable * Variables
Definition: upgrade_structs.h:144
int * ModifyPercent
modifier of unit stats.
Definition: upgrade_structs.h:197
time in game cycles
Definition: upgrade_structs.h:62
CUpgradeModifier()
Definition: upgrade_structs.h:183
std::vector< CUpgrade * > AllUpgrades
Definition: upgrade.cpp:67
int DefaultResourceMaxAmounts[MaxCosts]
Definition: unittype.cpp:580
~CUpgrade()
Definition: upgrade.cpp:131
CUnitStats()
Definition: upgrade_structs.h:132
static CUpgrade * Get(const std::string &ident)
Definition: upgrade.cpp:161
int SpeedResearch
use for percent modifiers
Definition: upgrade_structs.h:198
Definition: upgrade_structs.h:59
Icon: rectangle image used in menus.
Definition: icons.h:107
int DefaultResourceAmounts[MaxCosts]
Definition: unittype.cpp:575
std::string DefaultActions[MaxCosts]
Definition: unittype.cpp:565
Definition: upgrade_structs.h:152
char ApplyTo[UnitTypeMax]
allow/forbid upgrades
Definition: upgrade_structs.h:206
int ID
upgrade label
Definition: upgrade_structs.h:165
Definition: upgrade_structs.h:129
int DefaultIncomes[MaxCosts]
Orc wall.
Definition: unittype.cpp:560
int Units[UnitTypeMax]
Definition: upgrade_structs.h:235
CUnitType * ConvertTo
which unit types are affected
Definition: upgrade_structs.h:208
char Upgrades[UpgradeMax]
maximum amount of units allowed
Definition: upgrade_structs.h:236
Definition: upgrade_structs.h:224
int Costs[MaxCosts]
numerical id
Definition: upgrade_structs.h:166
int ChangeUnits[UnitTypeMax]
speed factor for researching
Definition: upgrade_structs.h:204
#define UnitTypeMax
Definition: stratagus.h:159
gold resource
Definition: upgrade_structs.h:63
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.