_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          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-2015 by Vladi Belperchinov-Shabanski,
14 // Jimmy Salmon and Andrettin
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  memset(ImproveIncomes, 0, sizeof(ImproveIncomes));
137  }
138  ~CUnitStats();
139 
140  const CUnitStats &operator = (const CUnitStats &rhs);
141 
142  bool operator == (const CUnitStats &rhs) const;
143  bool operator != (const CUnitStats &rhs) const;
144 public:
149 };
150 
154 class CUpgrade
155 {
156 public:
157  CUpgrade(const std::string &ident);
158  ~CUpgrade();
159 
160  static CUpgrade *New(const std::string &ident);
161  static CUpgrade *Get(const std::string &ident);
162 
163  void SetIcon(CIcon *icon);
164 
165  std::string Ident;
166  std::string Name;
167  int ID;
169  // TODO: not used by buttons
171 };
172 
173 /*----------------------------------------------------------------------------
174 -- upgrades and modifiers
175 ----------------------------------------------------------------------------*/
176 
183 {
184 public:
186  {
187  memset(ChangeUnits, 0, sizeof(ChangeUnits));
188  memset(ChangeUpgrades, 0, sizeof(ChangeUpgrades));
189  memset(ApplyTo, 0, sizeof(ApplyTo));
190  }
192  {
193  delete [] this->ModifyPercent;
194  }
195 
196  int UpgradeId;
197 
202 
203  // allow/forbid bitmaps -- used as chars for example:
204  // `?' -- leave as is, `F' -- forbid, `A' -- allow
205  // TODO: see below allow more semantics?
206  // TODO: pointers or ids would be faster and less memory use
210 
212 };
213 
227 class CAllow
228 {
229 public:
230  CAllow() { this->Clear(); }
231 
232  void Clear()
233  {
234  memset(Units, 0, sizeof(Units));
235  memset(Upgrades, 0, sizeof(Upgrades));
236  }
237 
240 };
241 
247 {
248 public:
249  CUpgradeTimers() { this->Clear(); }
250 
251  void Clear()
252  {
253  memset(Upgrades, 0, sizeof(Upgrades));
254  }
255 
261 };
262 
263 /*----------------------------------------------------------------------------
264 -- Variables
265 ----------------------------------------------------------------------------*/
266 
267 extern std::vector<CUpgrade *> AllUpgrades;
268 
270 
271 #endif // !__UPGRADE_STRUCTS_H__
CAllow
Definition: upgrade_structs.h:227
DefaultResourceNames
std::string DefaultResourceNames[MaxCosts]
Definition: unittype.cpp:479
CUpgrade::Costs
int Costs[MaxCosts]
numerical id
Definition: upgrade_structs.h:168
OilCost
@ OilCost
wood resource
Definition: upgrade_structs.h:64
UpgradeMax
constexpr unsigned short UpgradeMax
How many unit types supported.
Definition: settings.h:64
MaxCosts
@ MaxCosts
resource 6
Definition: upgrade_structs.h:70
CAllow::Units
int Units[UnitTypeMax]
Definition: upgrade_structs.h:238
CUpgrade::SetIcon
void SetIcon(CIcon *icon)
DefaultResourcesHigh
int DefaultResourcesHigh[MaxCosts]
CUpgrade::New
static CUpgrade * New(const std::string &ident)
Definition: upgrade.cpp:143
DefaultResourcesMedium
int DefaultResourcesMedium[MaxCosts]
DefaultIncomes
int DefaultIncomes[MaxCosts]
Orc wall.
Definition: unittype.cpp:469
CVariable
Definition: unittype.h:118
CUpgradeModifier::ConvertTo
CUnitType * ConvertTo
which unit types are affected
Definition: upgrade_structs.h:211
CUpgradeModifier::ApplyTo
char ApplyTo[UnitTypeMax]
allow/forbid upgrades
Definition: upgrade_structs.h:209
CUpgradeModifier::ModifyPercent
int * ModifyPercent
modifier of unit stats.
Definition: upgrade_structs.h:199
Cost4
@ Cost4
oil resource
Definition: upgrade_structs.h:66
CUnitStats::Storing
int Storing[MaxCosts]
current costs of the unit
Definition: upgrade_structs.h:147
CUnitStats::~CUnitStats
~CUnitStats()
Definition: upgrade.cpp:82
CAllow::CAllow
CAllow()
Definition: upgrade_structs.h:230
CIcon
Icon: rectangle image used in menus.
Definition: icons.h:109
CUnitType
Definition: unittype.h:508
CUnitStats::CUnitStats
CUnitStats()
Definition: upgrade_structs.h:132
CUpgradeModifier::ChangeUnits
int ChangeUnits[UnitTypeMax]
improve incomes
Definition: upgrade_structs.h:207
CUnitStats::Variables
CVariable * Variables
Definition: upgrade_structs.h:145
Cost6
@ Cost6
resource 5
Definition: upgrade_structs.h:68
CAllow::Clear
void Clear()
Definition: upgrade_structs.h:232
DefaultResourceMaxAmounts
int DefaultResourceMaxAmounts[MaxCosts]
Definition: unittype.cpp:489
CUnitStats::ImproveIncomes
int ImproveIncomes[MaxCosts]
storage increasing
Definition: upgrade_structs.h:148
CUpgrade::CUpgrade
CUpgrade(const std::string &ident)
Definition: upgrade.cpp:128
CUpgrade
Definition: upgrade_structs.h:154
CUpgrade::Icon
CIcon * Icon
costs for the upgrade
Definition: upgrade_structs.h:170
DefaultResourceAmounts
int DefaultResourceAmounts[MaxCosts]
Definition: unittype.cpp:484
DefaultActions
std::string DefaultActions[MaxCosts]
Definition: unittype.cpp:474
CUpgrade::Name
std::string Name
identifier
Definition: upgrade_structs.h:166
CUpgradeTimers::Clear
void Clear()
Definition: upgrade_structs.h:251
CUnitStats::operator=
const CUnitStats & operator=(const CUnitStats &rhs)
Definition: upgrade.cpp:87
Cost5
@ Cost5
resource 4
Definition: upgrade_structs.h:67
GoldCost
@ GoldCost
time in game cycles
Definition: upgrade_structs.h:62
CUpgradeModifier::ImproveIncomes
int ImproveIncomes[MaxCosts]
speed factor for researching
Definition: upgrade_structs.h:201
CUpgrade::~CUpgrade
~CUpgrade()
Definition: upgrade.cpp:134
CUpgradeTimers::Upgrades
int Upgrades[UpgradeMax]
Definition: upgrade_structs.h:260
CUnitStats::operator==
bool operator==(const CUnitStats &rhs) const
Definition: upgrade.cpp:102
DefaultResourcesLow
int DefaultResourcesLow[MaxCosts]
DefaultResources
int DefaultResources[MaxCosts]
CUpgrade::Get
static CUpgrade * Get(const std::string &ident)
Definition: upgrade.cpp:164
CUpgradeModifier::UpgradeId
int UpgradeId
Definition: upgrade_structs.h:196
CUpgradeModifier::~CUpgradeModifier
~CUpgradeModifier()
Definition: upgrade_structs.h:191
CUnitStats
Definition: upgrade_structs.h:129
CUnitStats::operator!=
bool operator!=(const CUnitStats &rhs) const
Definition: upgrade.cpp:123
CUpgrade::ID
int ID
upgrade label
Definition: upgrade_structs.h:167
CAllow::Upgrades
char Upgrades[UpgradeMax]
maximum amount of units allowed
Definition: upgrade_structs.h:239
CUnitStats::Costs
int Costs[MaxCosts]
user defined variable.
Definition: upgrade_structs.h:146
CUpgradeModifier
Definition: upgrade_structs.h:182
TimeCost
@ TimeCost
Definition: upgrade_structs.h:59
CUpgradeTimers::CUpgradeTimers
CUpgradeTimers()
Definition: upgrade_structs.h:249
UnitTypeMax
constexpr unsigned short UnitTypeMax
How many players are supported.
Definition: settings.h:63
AllUpgrades
std::vector< CUpgrade * > AllUpgrades
Definition: upgrade.cpp:68
CUpgradeTimers
Definition: upgrade_structs.h:246
GetResourceIdByName
int GetResourceIdByName(const char *resourceName)
Definition: unittype.cpp:500
WoodCost
@ WoodCost
gold resource
Definition: upgrade_structs.h:63
CostType
CostType
Definition: upgrade_structs.h:58
CUpgradeModifier::ChangeUpgrades
char ChangeUpgrades[UpgradeMax]
add/remove allowed units
Definition: upgrade_structs.h:208
CUpgradeModifier::CUpgradeModifier
CUpgradeModifier()
Definition: upgrade_structs.h:185
CUpgradeModifier::SpeedResearch
int SpeedResearch
use for percent modifiers
Definition: upgrade_structs.h:200
CUpgrade::Ident
std::string Ident
Definition: upgrade_structs.h:165
CUpgradeModifier::Modifier
CUnitStats Modifier
used to filter required modifier
Definition: upgrade_structs.h:198
(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.