____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       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"

unittype.cpp File Reference

The unit types. More...

#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.
CAnimationsAnimationsByIdent (const std::string &ident)
 < Get the animations structure by ident
CUnitTypeUnitTypeByIdent (const std::string &ident)
 Get unit-type by ident.
CUnitTypeNewUnitTypeSlot (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]


Detailed Description

The unit types.

Definition in file unittype.cpp.


Function Documentation

CAnimations* AnimationsByIdent ( const std::string &  ident  ) 

< Get the animations structure by ident

Get the animations structure by ident.

Parameters:
ident Identifier for the animation.
Returns:
Pointer to the animation structure.

Definition at line 240 of file unittype.cpp.

References AnimationMap.

Referenced by CclDefineAnimations(), and CclDefineUnitType().

static void CleanAnimation ( CAnimation anim  )  [static]

void CleanUnitTypes ( void   ) 

void DrawUnitType ( const CUnitType type,
CPlayerColorGraphic sprite,
int  player,
int  frame,
int  x,
int  y 
)

Draw unit-type on map.

Parameters:
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.
Todo:
Do screen position caculation in high level. Better way to handle in x mirrored sprites.

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]

void InitUnitTypes ( int  reset_player_stats  ) 

void LoadUnitTypes ( void   ) 

void LoadUnitTypeSprite ( CUnitType type  ) 

CUnitType* NewUnitTypeSlot ( const std::string &  ident  ) 

Draw the sprite frame of unit-type.

Allocate an empty unit-type slot.

Parameters:
ident Identifier to identify the slot (malloced by caller!).
Returns:
New allocated (zeroed) unit-type pointer.

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  ) 

void UpdateStats ( int  reset  ) 


Variable Documentation

std::string DefaultResourceNames[MaxCosts]

std::map<std::string, CUnitType *> UnitTypeMap

Definition at line 63 of file unittype.cpp.

Referenced by CleanUnitTypes(), InitUnitTypes(), NewUnitTypeSlot(), and UnitTypeByIdent().

std::vector<CUnitType *> UnitTypes


Generated on Sat Feb 21 00:28:22 2009 for Bos Wars by  doxygen 1.5.6