____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"
#include "stratagus.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <string>
#include <map>
#include "video.h"
#include "map.h"
#include "sound.h"
#include "unitsound.h"
#include "construct.h"
#include "unittype.h"
#include "animation.h"
#include "player.h"
#include "missile.h"
#include "script.h"
#include "spells.h"
#include "iolib.h"
#include "luacallback.h"
Go to the source code of this file.
Functions | |
| void | UpdateStats (int reset) |
| Update unit stats. | |
| CAnimations * | AnimationsByIdent (const std::string &ident) |
| < Get the animations structure by ident | |
| CUnitType * | UnitTypeByIdent (const std::string &ident) |
| Get unit-type by ident. | |
| CUnitType * | NewUnitTypeSlot (const std::string &ident) |
| Draw the sprite frame of unit-type. | |
| void | DrawUnitType (const CUnitType *type, CPlayerColorGraphic *sprite, int player, int frame, int x, int y) |
| static int | GetStillFrame (CUnitType *type) |
| void | InitUnitTypes (int reset_player_stats) |
| Init unit-type table. | |
| void | LoadUnitTypeSprite (CUnitType *type) |
| Load the sprite for a unittype. | |
| void | LoadUnitTypes (void) |
| Load the unit-type data. | |
| static void | CleanAnimation (CAnimation *anim) |
| void | CleanUnitTypes (void) |
| Cleanup unit-type module. | |
Variables | |
| std::vector< CUnitType * > | UnitTypes |
| unit-types definition | |
| std::map< std::string, CUnitType * > | UnitTypeMap |
| std::string | DefaultResourceNames [MaxCosts] |
Definition in file unittype.cpp.
| CAnimations* AnimationsByIdent | ( | const std::string & | ident | ) |
< Get the animations structure by ident
Get the animations structure by ident.
| ident | Identifier for the animation. |
Definition at line 240 of file unittype.cpp.
References AnimationMap.
Referenced by CclDefineAnimations(), and CclDefineUnitType().
| static void CleanAnimation | ( | CAnimation * | anim | ) | [static] |
Clean animation
Definition at line 440 of file unittype.cpp.
References AnimationNone, AnimationRandomSound, AnimationSound, CAnimation::D, CAnimation::RandomSound, CAnimation::Sound, and CAnimation::Type.
Referenced by CleanUnitTypes().
| void CleanUnitTypes | ( | void | ) |
Cleanup unit-type module.
Cleanup the unit-type module.
Definition at line 464 of file unittype.cpp.
References AnimationMap, AnimationsArray, CleanAnimation(), CUnitTypeVar::DecoVar, NumAnimations, CUnitTypeVar::NumberVariable, UnitTypeMap, UnitTypes, UnitTypeVar, CUnitTypeVar::Variable, and CUnitTypeVar::VariableName.
Referenced by CleanModules().
| void DrawUnitType | ( | const CUnitType * | type, | |
| CPlayerColorGraphic * | sprite, | |||
| int | player, | |||
| int | frame, | |||
| int | x, | |||
| int | y | |||
| ) |
Draw unit-type on map.
| type | Unit-type pointer. | |
| sprite | Sprite to use for drawing | |
| player | Player number for color substitution. | |
| frame | Animation frame of unit-type. | |
| x | Screen X pixel postion to draw unit-type. | |
| y | Screen Y pixel postion to draw unit-type. |
Definition at line 297 of file unittype.cpp.
References CPlayerColorGraphic::DrawPlayerColorFrameClip(), CPlayerColorGraphic::DrawPlayerColorFrameClipX(), CUnitType::Flip, CUnitType::Height, CUnitType::NumDirections, CUnitType::OffsetX, CUnitType::OffsetY, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, and CUnitType::Width.
Referenced by CUnit::Draw(), DrawBuildingCursor(), and DrawStartLocations().
| static int GetStillFrame | ( | CUnitType * | type | ) | [static] |
Get the still animation frame
Definition at line 328 of file unittype.cpp.
References AnimationExactFrame, AnimationFrame, CUnitType::Animations, CAnimation::D, CAnimation::Frame, CAnimation::Next, CUnitType::NumDirections, CAnimations::Still, and CAnimation::Type.
Referenced by InitUnitTypes().
| void InitUnitTypes | ( | int | reset_player_stats | ) |
Init unit-type table.
Init unit types.
Definition at line 348 of file unittype.cpp.
References Assert, CUnitType::BuildingRules, GetStillFrame(), CUnitType::Ident, CUnitType::Slot, CUnitType::StillFrame, UnitTypeMap, UnitTypes, and UpdateStats().
Referenced by CreateGame(), CEditor::Init(), InitModules(), and LoadGame().
| void LoadUnitTypes | ( | void | ) |
Load the unit-type data.
Load the graphics for the unit-types.
Definition at line 402 of file unittype.cpp.
References CUnitType::CorpseName, CUnitType::CorpseType, CUnitType::Explosion, CUnitType::Icon, IconConfig::Load(), LoadUnitTypeSprite(), MissileConfig::Missile, CUnitType::Missile, MissileTypeByIdent(), CUnitType::Name, MissileConfig::Name, ShowLoadProgress(), CUnitType::Sprite, UnitTypeByIdent(), and UnitTypes.
Referenced by CreateGame(), and LoadModules().
| void LoadUnitTypeSprite | ( | CUnitType * | type | ) |
Load the sprite for a unittype.
Loads the Sprite for a unit type
| type | type of unit to load |
Definition at line 378 of file unittype.cpp.
References CUnitType::File, CGraphic::Flip(), CUnitType::Flip, CGraphic::ForceNew(), CUnitType::Height, CGraphic::Load(), CGraphic::MakeShadow(), CPlayerColorGraphic::New(), CUnitType::ShadowFile, CUnitType::ShadowHeight, CUnitType::ShadowSprite, CUnitType::ShadowWidth, CUnitType::Sprite, and CUnitType::Width.
Referenced by LoadUnitTypes().
| CUnitType* NewUnitTypeSlot | ( | const std::string & | ident | ) |
Draw the sprite frame of unit-type.
Allocate an empty unit-type slot.
| ident | Identifier to identify the slot (malloced by caller!). |
Definition at line 264 of file unittype.cpp.
References ExitFatal(), CUnitType::Ident, CUnitTypeVar::NumberVariable, CUnitType::Slot, UnitTypeMap, UnitTypes, UnitTypeVar, CUnitTypeVar::Variable, and CUnitType::Variable.
Referenced by CclDefineUnitType().
| CUnitType* UnitTypeByIdent | ( | const std::string & | ident | ) |
Get unit-type by ident.
Find unit-type by identifier.
| ident | The unit-type identifier. |
Definition at line 252 of file unittype.cpp.
References UnitTypeMap.
Referenced by CalculateMaxIconSize(), CclDefineAiHelper(), CclDefineAiPlayer(), CclDefineUnitType(), CclGetUnitType(), CclParseOrder(), CclSpellAction(), CclUnit(), DoNextReplay(), getUnitTypeFromString(), CPlayer::HaveUnitTypeByIdent(), CBuildRestrictionDistance::Init(), CBuildRestrictionOnTop::Init(), CBuildRestrictionAddOn::Init(), CEditor::Init(), InitAiHelper(), LoadUnitTypes(), RecalculateShownUnits(), tolua_stratagus_UnitTypeByIdent00(), and UnitTypeIdByIdent().
| void UpdateStats | ( | int | reset | ) |
Update unit stats.
Update the player stats for changed unit types.
| reset | indicates wether default value should be set to each stat (level, upgrades) |
Definition at line 133 of file unittype.cpp.
References CUnitType::Building, CUnitType::CanTransport, DebugPrint, CUnitType::FieldFlags, HP_INDEX, MapFieldAirUnit, MapFieldBuilding, MapFieldCoastAllowed, MapFieldLandAllowed, MapFieldLandUnit, MapFieldNoBuilding, MapFieldSeaUnit, MapFieldUnpassable, MapFieldWaterAllowed, CVariable::Max, CUnitType::MovementMask, CUnitTypeVar::NumberVariable, PlayerMax, CUnitType::ShoreBuilding, CUnitType::Stats, CUnitType::UnitType, UnitTypeFly, UnitTypeLand, UnitTypeNaval, UnitTypes, UnitTypeVar, CUnitType::Variable, and CUnitStats::Variables.
Referenced by InitUnitTypes().
| std::string DefaultResourceNames[MaxCosts] |
Default names for the resources.
Definition at line 68 of file unittype.cpp.
Referenced by CclDefineDefaultResourceNames(), CclGetResourceByName(), CclPlayer(), DefaultResourceNumber(), DrawUnitInfo(), SaveAiPlayer(), SavePlayers(), and ShowUnitInfo().
| std::map<std::string, CUnitType *> UnitTypeMap |
Definition at line 63 of file unittype.cpp.
Referenced by CleanUnitTypes(), InitUnitTypes(), NewUnitTypeSlot(), and UnitTypeByIdent().
unit-types definition
All unit-types.
Definition at line 62 of file unittype.cpp.
Referenced by AiAssignHarvester(), AiFindAvailableUnitTypeEquiv(), AiMakeUnit(), AiReduceMadeInBuilt(), AiRemoveFromBuilt(), CclAiForce(), CclDefineSpell(), CleanUnitTypes(), CButtonPanel::DoClicked(), DrawPopup(), getReparableUnits(), getUnitTypeFromString(), InitUnitTypes(), LoadUnitTypes(), MapUnitSounds(), NewUnitTypeSlot(), ParseCommand(), SaveUpgrades(), UpdateStats(), and UpdateStatusLineForButton().
1.5.6