____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stratagus.h"
#include <vector>
#include "video.h"
#include "editor.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "unit_cache.h"
#include "map.h"
#include "construct.h"
#include "cursor.h"
#include "interface.h"
#include "font.h"
#include "ui.h"
#include "script.h"
Go to the source code of this file.
Classes | |
| class | Decoration |
| class | DecoSpriteType |
Functions | |
| void | DrawUnitSelection (const CUnit *unit) |
| void | DrawSelection (Uint32 color, int x1, int y1, int x2, int y2) |
| int | GetSpriteIndex (const std::string &spriteName) |
| static int | CclDefineSprites (lua_State *l) |
| void | DecorationCclRegister (void) |
| < Register CCL decorations features | |
| void | LoadDecorations (void) |
| Clean the decorations (health,mana) of units. | |
| void | CleanDecorations (void) |
| Draw unit's shadow. | |
| void | UpdateUnitVariables (const CUnit *unit) |
| static void | DrawDecoration (const CUnit *unit, const CUnitType *type, int x, int y) |
| void | DrawShadow (const CUnit *unit, const CUnitType *type, int frame, int x, int y) |
| Draw all units visible on map in viewport. | |
| static void | GetOrderPosition (const CUnit *unit, const COrder *order, int *x, int *y) |
| static void | ShowSingleOrder (const CUnit *unit, int x1, int y1, const COrder *order) |
| void | ShowOrder (const CUnit *unit) |
| static void | DrawInformations (const CUnit *unit, const CUnitType *type, int x, int y) |
| static void | DrawConstructionShadow (const CUnit *unit, const CConstructionFrame *cframe, int frame, int x, int y) |
| static void | DrawConstruction (const CUnit *unit, const CConstructionFrame *cframe, const CUnitType *type, int frame, int x, int y) |
| static int | DrawLevelCompare (const void *v1, const void *v2) |
| int | FindAndSortUnits (const CViewport *vp, CUnit **table, int tablesize) |
| Show a unit's orders. | |
Variables | |
| static DecoSpriteType | DecoSprite |
| All sprite's infos. | |
| unsigned long | ShowOrdersCount |
| Show orders for some time. | |
| const CViewport * | CurrentViewport |
| FIXME: quick hack for split screen. | |
Definition in file unit_draw.cpp.
| static int CclDefineSprites | ( | lua_State * | l | ) | [static] |
Define the sprite to show variables.
| l | Lua_state |
Definition at line 215 of file unit_draw.cpp.
References _C_, Decoration::File, GetSpriteIndex(), Decoration::Height, Decoration::HotX, Decoration::HotY, LuaError, LuaToNumber(), LuaToString(), DecoSpriteType::Name, DecoSpriteType::SpriteArray, and Decoration::Width.
Referenced by DecorationCclRegister().
| void CleanDecorations | ( | void | ) |
Draw unit's shadow.
Clean decorations.
Definition at line 300 of file unit_draw.cpp.
References CGraphic::Free(), DecoSpriteType::Name, and DecoSpriteType::SpriteArray.
Referenced by CleanModules().
| void DecorationCclRegister | ( | void | ) |
< Register CCL decorations features
Register CCL features for decorations.
Definition at line 279 of file unit_draw.cpp.
References CclDefineSprites(), and Lua.
Referenced by InitCcl().
| static void DrawConstruction | ( | const CUnit * | unit, | |
| const CConstructionFrame * | cframe, | |||
| const CUnitType * | type, | |||
| int | frame, | |||
| int | x, | |||
| int | y | |||
| ) | [static] |
Draw construction.
| unit | Unit pointer. | |
| cframe | Construction frame to draw. | |
| type | Unit type. | |
| frame | Frame number. | |
| x | X position. | |
| y | Y position. |
Definition at line 764 of file unit_draw.cpp.
References CUnitType::Construction, ConstructionFileConstruction, CPlayerColorGraphic::DrawPlayerColorFrameClip(), CPlayerColorGraphic::DrawPlayerColorFrameClipX(), CConstructionFrame::File, CUnitType::Height, CConstruction::Height, CPlayer::Index, CUnitType::OffsetX, CUnitType::OffsetY, CUnit::Player, CUnit::RescuedFrom, CUnitType::Sprite, CConstruction::Sprite, CUnitType::Width, and CConstruction::Width.
Referenced by CUnit::Draw().
| static void DrawConstructionShadow | ( | const CUnit * | unit, | |
| const CConstructionFrame * | cframe, | |||
| int | frame, | |||
| int | x, | |||
| int | y | |||
| ) | [static] |
Draw construction shadow.
| unit | Unit pointer. | |
| cframe | Construction frame | |
| frame | Frame number to draw. | |
| x | X position. | |
| y | Y position. |
Definition at line 722 of file unit_draw.cpp.
References CUnitType::Construction, ConstructionFileConstruction, CGraphic::DrawFrameClip(), CGraphic::DrawFrameClipX(), CConstructionFrame::File, CConstruction::Height, CUnitType::OffsetX, CUnitType::OffsetY, CUnitType::ShadowHeight, CUnitType::ShadowOffsetX, CUnitType::ShadowOffsetY, CUnitType::ShadowSprite, CConstruction::ShadowSprite, CUnitType::ShadowWidth, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, and CConstruction::Width.
Referenced by CUnit::Draw().
Draw decoration (invis, for the unit.)
| unit | Pointer to the unit. | |
| type | Type of the unit. | |
| x | Screen X position of the unit. | |
| y | Screen Y position of the unit. |
Definition at line 354 of file unit_draw.cpp.
References Assert, CUnitType::BoxHeight, CUnitType::BoxWidth, CUnitTypeVar::DecoVar, CVariable::Enable, GameFont, CUnit::GroupId, CFont::Height(), CPlayer::IsAllied(), CPlayer::IsEnemy(), CVariable::Max, CUnit::Player, PlayerNeutral, CUnit::Selected, ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, CPlayer::Type, UnitTypeVar, UpdateUnitVariables(), CVariable::Value, CUnit::Variable, VideoDrawNumberClip(), and CFont::Width().
Referenced by DrawInformations().
Draw additional informations of a unit.
| unit | Unit pointer of drawn unit. | |
| type | Unit-type pointer. | |
| x | X screen pixel position of unit. | |
| y | Y screen pixel position of unit. |
Definition at line 659 of file unit_draw.cpp.
References ATTACKRANGE_INDEX, CUnit::_unit_seen_::ByPlayer, CUnitType::CanAttack, ColorBlue, ColorGreen, ColorRed, CUnit::_unit_seen_::Destroyed, CVideo::DrawCircleClip(), DrawDecoration(), CPlayer::Index, CUnit::IsVisible(), CVariable::Max, NumSelected, CUnit::Orders, CUnit::Player, PlayerPerson, Preference, CUnitType::ReactRangeComputer, CUnitType::ReactRangePerson, CUnit::Refs, CUnit::Seen, CUnit::Selected, CPreference::ShowAttackRange, CPreference::ShowReactionRange, CPreference::ShowSightRange, SIGHTRANGE_INDEX, sprintf_s(), CUnit::Stats, ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CPlayer::Type, UnitActionDie, CUnitStats::Variables, Video, VideoDrawTextClip(), and CUnit::VisCount.
Referenced by CUnit::Draw().
| static int DrawLevelCompare | ( | const void * | v1, | |
| const void * | v2 | |||
| ) | [static] |
Compare what order 2 units should be drawn on the map
| v1 | First Unit to compare (**Unit) | |
| v2 | Second Unit to compare (**Unit) |
Definition at line 892 of file unit_draw.cpp.
References CUnitType::CorpseType, CUnitType::DrawLevel, CUnitType::Height, CUnit::IY, CUnit::Orders, CUnit::Slot, TileSizeY, CUnit::Type, UnitActionDie, CUnit::X, and CUnit::Y.
Referenced by FindAndSortUnits().
| void DrawSelection | ( | Uint32 | color, | |
| int | x1, | |||
| int | y1, | |||
| int | x2, | |||
| int | y2 | |||
| ) |
Draw selected corners around the unit.
| color | Color to draw corners. | |
| x1,y1 | Coordinates of the top left corner. | |
| x2,y2 | Coordinates of the bottom right corner. |
Definition at line 172 of file unit_draw.cpp.
References CVideo::DrawHLineClip(), CVideo::DrawVLineClip(), and Video.
Referenced by DrawUnitSelection(), and ShowSingleOrder().
Draw all units visible on map in viewport.
Draw unit's shadow.
| unit | Pointer to the unit. | |
| type | Pointer to the unit type. | |
| frame | Frame number | |
| x | Screen X position of the unit. | |
| y | Screen Y position of the unit. |
Definition at line 410 of file unit_draw.cpp.
References Assert, CGraphic::DrawFrameClip(), CGraphic::DrawFrameClipX(), CUnitType::Flip, CUnitType::NumDirections, CUnitType::OffsetX, CUnitType::OffsetY, CUnit::Orders, CUnitType::ShadowHeight, CUnitType::ShadowOffsetX, CUnitType::ShadowOffsetY, CUnitType::ShadowSprite, CUnitType::ShadowWidth, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, and UnitActionDie.
Referenced by CUnit::Draw(), and DrawBuildingCursor().
| void DrawUnitSelection | ( | const CUnit * | unit | ) |
Show selection marker around a unit.
| unit | Pointer to unit. |
Definition at line 113 of file unit_draw.cpp.
References CUnit::Blink, CUnitType::BoxHeight, CUnitType::BoxWidth, CUnitType::Building, CPlayer::Color, ColorGray, ColorGreen, ColorRed, ColorWhite, ColorYellow, CursorBuilding, DrawSelection(), Editor, EditorSelecting, CGraphic::Height, CUnitType::Height, CPlayer::Index, CPlayer::IsEnemy(), CPlayer::IsTeamed(), CUnit::IX, CUnit::IY, CViewport::Map2ViewportX(), CViewport::Map2ViewportY(), CUnit::Orders, CUnit::Player, PlayerMax, PlayerNumNeutral, Players, CEditor::Running, CUnit::Selected, CUnitType::Sprite, CEditor::State, CUnit::TeamSelected, ThisPlayer, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, UnitActionDie, UnitUnderCursor, CGraphic::Width, CUnitType::Width, CUnit::X, CUnit::Y, and y.
Referenced by CUnit::Draw().
Show a unit's orders.
Find all units to draw in viewport.
| vp | Viewport to be drawn. | |
| table | Table of units to return in sorted order | |
| tablesize | Size of table array |
Definition at line 930 of file unit_draw.cpp.
References DrawLevelCompare(), CUnit::IsVisibleInViewport(), CViewport::MapHeight, CViewport::MapWidth, CViewport::MapX, CViewport::MapY, CUnitCache::Select(), and UnitCache.
Referenced by CViewport::Draw().
| static void GetOrderPosition | ( | const CUnit * | unit, | |
| const COrder * | order, | |||
| int * | x, | |||
| int * | y | |||
| ) | [static] |
Get the location of a unit's order.
| unit | Pointer to unit. | |
| order | Pointer to order. | |
| x | Resulting screen X cordinate. | |
| y | Resulting screen Y cordinate. |
Definition at line 458 of file unit_draw.cpp.
References COrder::Action, COrder::Goal, CUnit::IX, CUnit::IY, CViewport::Map2ViewportX(), CViewport::Map2ViewportY(), CUnit::Removed, CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, COrder::Type, CUnit::Type, UnitActionBuild, COrder::X, CUnit::X, COrder::Y, and CUnit::Y.
Referenced by ShowOrder(), and ShowSingleOrder().
| int GetSpriteIndex | ( | const std::string & | spriteName | ) |
Return the index of the sprite.
| spriteName | Name of the sprite. |
Definition at line 197 of file unit_draw.cpp.
References int(), and DecoSpriteType::Name.
Referenced by CclDefineDecorations(), and CclDefineSprites().
| void LoadDecorations | ( | void | ) |
Clean the decorations (health,mana) of units.
Load decoration.
Definition at line 287 of file unit_draw.cpp.
References CGraphic::New(), ShowLoadProgress(), and DecoSpriteType::SpriteArray.
Referenced by CreateGame(), and LoadModules().
| void ShowOrder | ( | const CUnit * | unit | ) |
Show the current order of a unit.
| unit | Pointer to the unit. |
Definition at line 613 of file unit_draw.cpp.
References CanMove(), CUnit::Destroyed, GetOrderPosition(), CUnit::IX, CUnit::IY, CViewport::Map2ViewportX(), CViewport::Map2ViewportY(), CUnit::NewOrder, CUnit::OrderCount, CUnit::OrderFlush, CUnit::Orders, ShowSingleOrder(), CUnitType::TileHeight, TileSizeX, TileSizeY, CUnitType::TileWidth, CUnit::Type, CUnit::X, and CUnit::Y.
Referenced by CViewport::Draw().
Show the order on map.
| unit | Unit pointer. | |
| x1 | X pixel coordinate. | |
| y1 | Y pixel coordinate. | |
| order | Order to display. |
Definition at line 497 of file unit_draw.cpp.
References _C_, COrder::Action, COrder::Arg1, CUnitType::BoxHeight, CUnitType::BoxWidth, ColorBlue, ColorGray, ColorGreen, ColorRed, ColorYellow, DebugPrint, CVideo::DrawLineClip(), DrawSelection(), CVideo::FillCircleClip(), GetOrderPosition(), CViewport::Map2ViewportX(), CViewport::Map2ViewportY(), COrder::Patrol, CUnit::SubAction, TileSizeX, TileSizeY, COrder::Type, UnitActionAttack, UnitActionAttackGround, UnitActionBoard, UnitActionBuild, UnitActionBuilt, UnitActionDie, UnitActionFollow, UnitActionMove, UnitActionNone, UnitActionPatrol, UnitActionRepair, UnitActionResource, UnitActionSpellCast, UnitActionStandGround, UnitActionStill, UnitActionTrain, UnitActionUnload, Video, COrder::X, and COrder::Y.
Referenced by ShowOrder().
| void UpdateUnitVariables | ( | const CUnit * | unit | ) |
Update unit variables which are not user defined.
Definition at line 1250 of file script_unittype.cpp.
References _C_, ARMOR_INDEX, Assert, ATTACKRANGE_INDEX, BASICDAMAGE_INDEX, CUnit::BoardCount, BUILD_INDEX, CUnit::_order_data_::Built, CUnitType::CanHarvestFrom, CYCLES_PER_SECOND, CUnit::Data, DebugPrint, CVariable::Enable, EnergyCost, GIVERESOURCE_INDEX, HP_INDEX, CUnitType::Ident, CMap::Info, KILL_INDEX, MagmaCost, MANA_INDEX, Map, CMapInfo::MapHeight, CMapInfo::MapWidth, CVariable::Max, MaxCosts, CUnitType::MaxOnBoard, NVARALREADYDEFINED, CUnit::Orders, PIERCINGDAMAGE_INDEX, POSX_INDEX, POSY_INDEX, CUnitType::ProductionCosts, CUnit::_order_data_::_order_built_::Progress, RADAR_INDEX, RADARJAMMER_INDEX, CUnit::ResourcesHeld, SIGHTRANGE_INDEX, CUnit::Slot, SLOT_INDEX, CUnit::Stats, CUnit::_order_data_::_order_train_::Ticks, CUnit::_order_data_::Train, TRAINING_INDEX, TRANSPORT_INDEX, CUnit::Type, UnitActionBuilt, UnitActionTrain, UnitSlotFree, CVariable::Value, CUnitType::Variable, CUnit::Variable, CUnitTypeVar::VariableName, CUnitStats::Variables, CUnit::X, and CUnit::Y.
| const CViewport* CurrentViewport |
FIXME: quick hack for split screen.
CurrentViewport.
Definition at line 104 of file unit_draw.cpp.
Referenced by CViewport::Draw(), and Missile::DrawMissile().
DecoSpriteType DecoSprite [static] |
| unsigned long ShowOrdersCount |
Show orders for some time.
Definition at line 90 of file unit_draw.cpp.
Referenced by DoRightButton(), CViewport::Draw(), and SendCommand().
1.5.6