$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1999-2007 by Vladi Belperchinov-Shabanski and 00014 // Jimmy Salmon 00015 // 00016 // This program is free software; you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation; only version 2 of the License. 00019 // 00020 // This program is distributed in the hope that it will be useful, 00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 // GNU General Public License for more details. 00024 // 00025 // You should have received a copy of the GNU General Public License 00026 // along with this program; if not, write to the Free Software 00027 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00028 // 02111-1307, USA. 00029 // 00030 00031 #ifndef __UPGRADE_STRUCTS_H__ 00032 #define __UPGRADE_STRUCTS_H__ 00033 00035 00036 /*---------------------------------------------------------------------------- 00037 -- Includes 00038 ----------------------------------------------------------------------------*/ 00039 00040 #include <vector> 00041 00042 /*---------------------------------------------------------------------------- 00043 -- Defines 00044 ----------------------------------------------------------------------------*/ 00045 00046 /*---------------------------------------------------------------------------- 00047 -- Declarations 00048 ----------------------------------------------------------------------------*/ 00049 00050 class CUnitType; 00051 class CVariable; 00052 class CIcon; 00053 struct lua_State; 00054 00058 enum CostType { 00059 TimeCost, 00060 00061 // standard 00062 GoldCost, 00063 WoodCost, 00064 OilCost, 00065 // extensions 00066 Cost4, 00067 Cost5, 00068 Cost6, 00069 00070 MaxCosts 00071 }; 00072 00073 #define FoodCost MaxCosts 00074 #define ScoreCost (MaxCosts + 1) 00075 #define ManaResCost (MaxCosts + 2) 00076 00080 extern int DefaultResources[MaxCosts]; 00081 00085 extern int DefaultResourcesLow[MaxCosts]; 00086 00090 extern int DefaultResourcesMedium[MaxCosts]; 00091 00095 extern int DefaultResourcesHigh[MaxCosts]; 00096 00100 extern int DefaultIncomes[MaxCosts]; 00101 00105 extern std::string DefaultActions[MaxCosts]; 00106 00110 extern std::string DefaultResourceNames[MaxCosts]; 00111 00115 extern int DefaultResourceAmounts[MaxCosts]; 00116 00120 extern int DefaultResourceMaxAmounts[MaxCosts]; 00121 00122 extern int GetResourceIdByName(const char *resourceName); 00123 extern int GetResourceIdByName(lua_State *l, const char *resourceName); 00124 00128 class CUnitStats 00129 { 00130 public: 00131 CUnitStats() : Variables(NULL) { 00132 memset(Costs, 0, sizeof(Costs)); 00133 memset(Storing, 0, sizeof(Storing)); 00134 } 00135 ~CUnitStats(); 00136 00137 const CUnitStats &operator = (const CUnitStats &rhs); 00138 00139 bool operator == (const CUnitStats &rhs) const; 00140 bool operator != (const CUnitStats &rhs) const; 00141 public: 00142 CVariable *Variables; 00143 int Costs[MaxCosts]; 00144 int Storing[MaxCosts]; 00145 }; 00146 00150 class CUpgrade 00151 { 00152 public: 00153 CUpgrade(const std::string &ident); 00154 ~CUpgrade(); 00155 00156 static CUpgrade *New(const std::string &ident); 00157 static CUpgrade *Get(const std::string &ident); 00158 00159 void SetIcon(CIcon *icon); 00160 00161 std::string Ident; 00162 int ID; 00163 int Costs[MaxCosts]; 00164 // TODO: not used by buttons 00165 CIcon *Icon; 00166 }; 00167 00168 /*---------------------------------------------------------------------------- 00169 -- upgrades and modifiers 00170 ----------------------------------------------------------------------------*/ 00171 00177 class CUpgradeModifier 00178 { 00179 public: 00180 CUpgradeModifier() : UpgradeId(0), ModifyPercent(NULL), ConvertTo(NULL) { 00181 memset(ChangeUnits, 0, sizeof(ChangeUnits)); 00182 memset(ChangeUpgrades, 0, sizeof(ChangeUpgrades)); 00183 memset(ApplyTo, 0, sizeof(ApplyTo)); 00184 } 00185 ~CUpgradeModifier() { 00186 delete [] this->ModifyPercent; 00187 } 00188 00189 int UpgradeId; 00190 00191 CUnitStats Modifier; 00192 int *ModifyPercent; 00193 00194 // allow/forbid bitmaps -- used as chars for example: 00195 // `?' -- leave as is, `F' -- forbid, `A' -- allow 00196 // TODO: see below allow more semantics? 00197 // TODO: pointers or ids would be faster and less memory use 00198 int ChangeUnits[UnitTypeMax]; 00199 char ChangeUpgrades[UpgradeMax]; 00200 char ApplyTo[UnitTypeMax]; 00201 00202 CUnitType *ConvertTo; 00203 }; 00204 00218 class CAllow 00219 { 00220 public: 00221 CAllow() { this->Clear(); } 00222 00223 void Clear() { 00224 memset(Units, 0, sizeof(Units)); 00225 memset(Upgrades, 0, sizeof(Upgrades)); 00226 } 00227 00228 int Units[UnitTypeMax]; 00229 char Upgrades[UpgradeMax]; 00230 }; 00231 00236 class CUpgradeTimers 00237 { 00238 public: 00239 CUpgradeTimers() { this->Clear(); } 00240 00241 void Clear() { 00242 memset(Upgrades, 0, sizeof(Upgrades)); 00243 } 00244 00249 int Upgrades[UpgradeMax]; 00250 }; 00251 00252 /*---------------------------------------------------------------------------- 00253 -- Variables 00254 ----------------------------------------------------------------------------*/ 00255 00256 extern std::vector<CUpgrade *> AllUpgrades; 00257 00259 00260 #endif // !__UPGRADE_STRUCTS_H__