$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

src/unit/upgrade.cpp File Reference

#include <string>
#include <vector>
#include <map>
#include "stratagus.h"
#include "upgrade.h"
#include "action/action_train.h"
#include "commands.h"
#include "depend.h"
#include "interface.h"
#include "iolib.h"
#include "map.h"
#include "player.h"
#include "script.h"
#include "unit.h"
#include "unit_find.h"
#include "unittype.h"
#include "util.h"

upgrade.cpp - The upgrade/allow functions.

#define UPGRADE_MODIFIERS_MAX   (UpgradeMax * 4)
 The main user useable upgrades.
std::vector< CUpgrade * > AllUpgrades
static CUpgradeModifierUpgradeModifiers [UPGRADE_MODIFIERS_MAX]
 Upgrades modifiers.
static int NumUpgradeModifiers
 Number of upgrades modifiers used.
std::map< std::string, CUpgrade * > Upgrades
static void AllowUnitId (CPlayer &player, int id, int units)
static void AllowUpgradeId (CPlayer &player, int id, char af)
void InitUpgrades ()
 init upgrade/allow structures
void CleanUpgrades ()
 cleanup upgrade module
void SaveUpgrades (CFile &file)
 save the upgrades
static int CclDefineModifier (lua_State *l)
static int CclDefineUnitAllow (lua_State *l)
static int CclDefineAllow (lua_State *l)
void UpgradesCclRegister ()
 Register CCL features for upgrades.
int UnitTypeIdByIdent (const std::string &ident)
int UpgradeIdByIdent (const std::string &ident)
static void ConvertUnitTypeTo (CPlayer &player, const CUnitType &src, CUnitType &dst)
static void ApplyUpgradeModifier (CPlayer &player, const CUpgradeModifier *um)
void UpgradeAcquire (CPlayer &player, const CUpgrade *upgrade)
 Upgrade will be acquired.
int UnitIdAllowed (const CPlayer &player, int id)
char UpgradeIdAllowed (const CPlayer &player, int id)
char UpgradeIdentAllowed (const CPlayer &player, const std::string &ident)

Define Documentation

#define UPGRADE_MODIFIERS_MAX   (UpgradeMax * 4)

The main user useable upgrades.

How many upgrades modifiers supported


Function Documentation

static void AllowUnitId ( CPlayer player,
int  id,
int  units 
) [static]

Change allow for an unit-type.

Parameters:
player Player to change
id unit type id
units maximum amount of units allowed

static void AllowUpgradeId ( CPlayer player,
int  id,
char  af 
) [static]

Change allow for an upgrade.

Parameters:
player Player to change
id upgrade id
af `A'llow/`F'orbid/`R'eseached

static void ApplyUpgradeModifier ( CPlayer player,
const CUpgradeModifier um 
) [static]

Apply the modifiers of an upgrade.

This function will mark upgrade done and do all required modifications to unit types and will modify allow/forbid maps

Parameters:
player Player that get all the upgrades.
um Upgrade modifier that do the effects

static int CclDefineAllow ( lua_State *  l  )  [static]

Define which units/upgrades are allowed.

How many units supported

static int CclDefineModifier ( lua_State *  l  )  [static]

Define a new upgrade modifier.

Parameters:
l List of modifiers.

static int CclDefineUnitAllow ( lua_State *  l  )  [static]

Define which units are allowed and how much.

void CleanUpgrades (  ) 

cleanup upgrade module

Cleanup the upgrade module.

static void ConvertUnitTypeTo ( CPlayer player,
const CUnitType src,
CUnitType dst 
) [static]

Convert unit-type to.

Parameters:
player For this player.
src From this unit-type.
dst To this unit-type.

void InitUpgrades (  ) 

init upgrade/allow structures

Init upgrade/allow structures

void SaveUpgrades ( CFile file  ) 

save the upgrades

Save state of the dependencies to file.

Parameters:
file Output file.

int UnitIdAllowed ( const CPlayer player,
int  id 
)

Return the allow state of the unit.

Parameters:
player Check state of this player.
id Unit identifier.
Returns:
the allow state of the unit.

int UnitTypeIdByIdent ( const std::string &  ident  ) 

UnitType ID by identifier.

Parameters:
ident The unit-type identifier.
Returns:
Unit-type ID (int) or -1 if not found.

void UpgradeAcquire ( CPlayer player,
const CUpgrade upgrade 
)

Upgrade will be acquired.

Handle that an upgrade was acquired.

Parameters:
player Player researching the upgrade.
upgrade Upgrade ready researched.

char UpgradeIdAllowed ( const CPlayer player,
int  id 
)

Return the allow state of an upgrade.

Parameters:
player Check state for this player.
id Upgrade identifier.
Returns:
the allow state of the upgrade.

int UpgradeIdByIdent ( const std::string &  ident  ) 

Upgrade ID by identifier.

Parameters:
ident The upgrade identifier.
Returns:
Upgrade ID (int) or -1 if not found.

char UpgradeIdentAllowed ( const CPlayer player,
const std::string &  ident 
)

Return the allow state of an upgrade.

Parameters:
player Check state for this player.
ident Upgrade identifier.
Note:
This function shouldn't be used during runtime, it is only for setup.

void UpgradesCclRegister (  ) 

Register CCL features for upgrades.

Register CCL features for upgrades.


Variable Documentation

std::vector<CUpgrade *> AllUpgrades

int NumUpgradeModifiers [static]

Number of upgrades modifiers used.

CUpgradeModifier* UpgradeModifiers[UPGRADE_MODIFIERS_MAX] [static]

Upgrades modifiers.

std::map<std::string, CUpgrade *> Upgrades

(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.