____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
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 <map>
#include <string>
#include "upgrade_structs.h"
#include "video.h"
Go to the source code of this file.
Classes | |
| class | CPlayer |
| < Player structure More... | |
Defines | |
| #define | PlayerNumNeutral (PlayerMax - 1) |
| this is the neutral player slot | |
| #define | CanSelectMultipleUnits(player) ((player) == ThisPlayer || ThisPlayer->IsTeamed((player))) |
Enumerations | |
| enum | PlayerTypes { PlayerNeutral = 2, PlayerNobody = 3, PlayerComputer = 4, PlayerPerson = 5, PlayerRescuePassive = 6, PlayerRescueActive = 7 } |
| enum | NotifyType { NotifyRed, NotifyYellow, NotifyGreen } |
Functions | |
| void | InitPlayers (void) |
| < Init players | |
| void | CleanPlayers (void) |
| Save players. | |
| void | SavePlayers (CFile *file) |
| Create a new player. | |
| void | CreatePlayer (int type) |
| Initialize the computer opponent AI. | |
| void | PlayersInitAi (void) |
| Called each game cycle for player handlers (AI). | |
| void | PlayersEachCycle (void) |
| Called each second for a given player handler (AI). | |
| void | PlayersEachSecond (int player) |
| Change current color set to new player of the sprite. | |
| void | GraphicPlayerPixels (CPlayer *player, const CGraphic *sprite) |
| Calculate how many resources the unit needs to request. | |
| void | CalculateRequestedAmount (CUnitType *utype, int bcosts[MaxCosts], int costs[MaxCosts]) |
| Output debug informations for players. | |
| void | DebugPlayers (void) |
| register ccl features | |
| void | PlayerCclRegister (void) |
| Allowed to select multiple units, maybe not mine. | |
Variables | |
| int | NumPlayers |
| How many player slots used. | |
| CPlayer | Players [PlayerMax] |
| All players. | |
| CPlayer * | ThisPlayer |
| Player on local computer. | |
| int | NoRescueCheck |
| Disable rescue check. | |
| SDL_Color * | PlayerColorsRGB [PlayerMax] |
| Player colors. | |
| Uint32 * | PlayerColors [PlayerMax] |
| Player colors. | |
| std::string | PlayerColorNames [PlayerMax] |
| Player color names. | |
| int | PlayerColorIndexStart |
| int | PlayerColorIndexCount |
Definition in file player.h.
| #define CanSelectMultipleUnits | ( | player | ) | ((player) == ThisPlayer || ThisPlayer->IsTeamed((player))) |
Definition at line 487 of file player.h.
Referenced by AddSelectedAirUnitsInRectangle(), AddSelectedGroundUnitsInRectangle(), AddSelectedUnitsInRectangle(), DoRightButton(), SelectAirUnitsInRectangle(), SelectGroundUnitsInRectangle(), SelectOrganicUnitsInTable(), SelectUnitsByType(), SelectUnitsInRectangle(), and ToggleUnitsByType().
| #define PlayerNumNeutral (PlayerMax - 1) |
this is the neutral player slot
Definition at line 420 of file player.h.
Referenced by Polymorph::Cast(), SpawnPortal::Cast(), DoRightButton(), DrawUnitOn(), DrawUnitSelection(), EditorActionPlaceUnit(), CEditor::Init(), tolua_stratagus_open(), UIHandleMouseMove(), and UnitLost().
| enum NotifyType |
| enum PlayerTypes |
Types for the player
This player is controlled by the computer doing nothing.
This player is unused. Nobody controlls this player.
This player is controlled by the computer. CPlayer::AiNum selects the AI strategy.
This player is contolled by a person. This can be the player sitting on the local computer or player playing over the network.
This player does nothing, the game pieces just sit in the game (being passive)... when a person player moves next to a PassiveRescue unit/building, then it is "rescued" and becomes part of that persons team. If the city center is rescued, than all units of this player are rescued.
This player is controlled by the computer. CPlayer::AiNum selects the AI strategy. Until it is rescued it plays like an ally. The first person which reaches units of this player, can rescue them. If the city center is rescued, than all units of this player are rescued.
| void CalculateRequestedAmount | ( | CUnitType * | utype, | |
| int | bcosts[MaxCosts], | |||
| int | costs[MaxCosts] | |||
| ) |
Output debug informations for players.
Calculate how many resources the unit needs to request
| utype | builder unit type | |
| bcosts | costs of unit type being built or harvested | |
| costs | returns the resource amount |
Definition at line 192 of file player.cpp.
References EnergyCost, MagmaCost, and CUnitType::MaxUtilizationRate.
Referenced by GatherResource(), HandleActionTrain(), MoveToLocation(), CPlayer::RebuildUnitsConsumingResourcesList(), and StartBuilding().
| void CleanPlayers | ( | void | ) |
Save players.
Clean up players.
Definition at line 105 of file player.cpp.
References CPlayer::Clear(), NoRescueCheck, NumPlayers, and PlayerMax.
Referenced by CleanModules(), StartEditor(), StartMap(), StartReplay(), and StartSavedGame().
| void CreatePlayer | ( | int | type | ) |
Initialize the computer opponent AI.
Create a new player.
| type | Player type (Computer,Human,...). |
Definition at line 490 of file player.cpp.
References _C_, CPlayer::AiEnabled, CPlayer::AiName, CPlayer::Allied, CPlayer::Color, DebugPrint, CPlayer::Enemy, CPlayer::Index, CPlayer::Name, NetLocalPlayerNumber, NetPlayers, CPlayer::NumBuildings, NumPlayers, PlayerColors, PlayerComputer, PlayerMax, PlayerNeutral, PlayerNobody, PlayerPerson, PlayerRescueActive, PlayerRescuePassive, CPlayer::Score, CPlayer::SetName(), CPlayer::Team, CPlayer::TotalNumUnits, CPlayer::Type, CPlayer::Units, and CPlayer::UnitTypesCount.
Referenced by CreateGame(), and CEditor::Init().
| void DebugPlayers | ( | void | ) |
register ccl features
Output debug informations for players.
Definition at line 865 of file player.cpp.
References _C_, CPlayer::AiEnabled, CPlayer::AiName, DebugPrint, CPlayer::Name, PlayerColorNames, PlayerMax, PlayerNobody, and CPlayer::Type.
Referenced by CreateGame().
Calculate how many resources the unit needs to request.
Change current color set to new player.
FIXME: use function pointer here.
| player | Pointer to player. | |
| sprite | The sprite in which the colors should be changed. |
Definition at line 833 of file player.cpp.
References Assert, CUnitColors::Colors, PlayerColorIndexCount, PlayerColorIndexStart, CGraphic::Surface, CGraphic::SurfaceFlip, and CPlayer::UnitColors.
Referenced by CPlayerColorGraphic::DrawPlayerColorFrameClip(), and CPlayerColorGraphic::DrawPlayerColorFrameClipX().
| void InitPlayers | ( | void | ) |
< Init players
Clean up players
Init players.
Definition at line 87 of file player.cpp.
References CPlayer::Index, CVideo::MapRGB(), PlayerColorIndexCount, PlayerColors, PlayerColorsRGB, PlayerMax, PlayerNobody, TheScreen, CPlayer::Type, CUnit::Type, and Video.
Referenced by CreateGame(), CEditor::Init(), InitModules(), and LoadStratagusMap().
| void PlayerCclRegister | ( | void | ) |
Allowed to select multiple units, maybe not mine.
Register CCL features for players.
Definition at line 567 of file script_player.cpp.
References CclChangeUnitsOwner(), CclDefinePlayerColorIndex(), CclDefinePlayerColors(), CclDiplomacy(), CclNewPlayerColors(), CclPlayer(), CclSetAllPlayersBuildingLimit(), CclSetAllPlayersTotalUnitLimit(), CclSetAllPlayersUnitLimit(), CclSetDiplomacy(), CclSetMaxSelectable(), CclSetSharedVision(), CclSharedVision(), and Lua.
Referenced by InitCcl().
| void PlayersEachCycle | ( | void | ) |
Called each second for a given player handler (AI).
Handle AI of all players each game cycle.
Definition at line 772 of file player.cpp.
References CPlayer::ActualUtilizationRate, AiEachCycle(), CPlayer::AiEnabled, CalculateCosts(), MaxCosts, NumPlayers, CPlayer::ProductionRate, CPlayer::StorageCapacity, CPlayer::StoredResources, CPlayer::TotalResources, CPlayer::UnitsConsumingResourcesActual, and CPlayer::UpdateUnitsConsumingResources().
Referenced by GameMainLoop().
| void PlayersEachSecond | ( | int | player | ) |
Change current color set to new player of the sprite.
Handle AI of a player each second.
| player | the player to update AI |
Definition at line 818 of file player.cpp.
References AiEachSecond(), and CPlayer::AiEnabled.
Referenced by GameMainLoop().
| void PlayersInitAi | ( | void | ) |
Called each game cycle for player handlers (AI).
Initialize the Ai for all players.
Definition at line 760 of file player.cpp.
References CPlayer::AiEnabled, AiInit(), and NumPlayers.
Referenced by CreateGame().
| void SavePlayers | ( | CFile * | file | ) |
Create a new player.
Save state of players to file.
| file | Output file. |
Definition at line 368 of file player.cpp.
References CPlayer::AiEnabled, CPlayer::AiName, CPlayer::Allied, CPlayer::BuildingLimit, CPlayer::Color, DebugPrint, DefaultResourceNames, CPlayer::Enemy, CPlayer::Index, MaxCosts, CPlayer::Name, NumPlayers, PlayerComputer, PlayerMax, PlayerNeutral, PlayerNobody, PlayerPerson, PlayerRescueActive, PlayerRescuePassive, CFile::printf(), CPlayer::ProductionRate, CPlayer::Score, CPlayer::SharedVision, CPlayer::StartX, CPlayer::StartY, CPlayer::StorageCapacity, CPlayer::StoredResources, CPlayer::Team, TheScreen, CPlayer::TotalBuildings, CPlayer::TotalKills, CPlayer::TotalRazings, CPlayer::TotalResources, CPlayer::TotalUnitLimit, CPlayer::TotalUnits, CPlayer::Type, and CPlayer::UnitLimit.
Referenced by SaveGame().
| int NoRescueCheck |
Disable rescue check.
Definition at line 64 of file player.cpp.
Referenced by CleanPlayers(), and RescueUnits().
| int NumPlayers |
How many player slots used.
Definition at line 60 of file player.cpp.
Referenced by CclAiDebugPlayer(), CclPlayer(), CleanPlayers(), CommandQuit(), CreatePlayer(), GameMainLoop(), LoadGame(), main1(), NetworkEvent(), NetworkExecCommands(), PlayersEachCycle(), PlayersInitAi(), RescueUnits(), and SavePlayers().
Definition at line 78 of file player.cpp.
Referenced by CclDefinePlayerColorIndex(), CclDefinePlayerColors(), GraphicPlayerPixels(), InitPlayers(), MakeTextures2(), and SetPlayersPalette().
Which indexes to replace with player color
Definition at line 77 of file player.cpp.
Referenced by CclDefinePlayerColorIndex(), GraphicPlayerPixels(), and MakeTextures2().
| std::string PlayerColorNames[PlayerMax] |
Player color names.
Definition at line 72 of file player.cpp.
Referenced by CclDefinePlayerColors(), DebugPlayers(), and InputKey().
| Uint32* PlayerColors[PlayerMax] |
Player colors.
Definition at line 70 of file player.cpp.
Referenced by CclDefinePlayerColorIndex(), CreatePlayer(), and InitPlayers().
| SDL_Color* PlayerColorsRGB[PlayerMax] |
Player colors.
Colors used for minimap.
Definition at line 69 of file player.cpp.
Referenced by CclDefinePlayerColorIndex(), CclDefinePlayerColors(), InitPlayers(), and SetPlayersPalette().
All players.
Definition at line 61 of file player.cpp.
Referenced by Polymorph::Cast(), SpawnPortal::Cast(), CclAiDebugPlayer(), CclChangeUnitsOwner(), CclCreateUnit(), CclDefineAiPlayer(), CclDefineAllow(), CclDefineUnitAllow(), CclGetUnits(), CclKillUnit(), CclPlayer(), CclSetAllPlayersBuildingLimit(), CclSetAllPlayersTotalUnitLimit(), CclSetAllPlayersUnitLimit(), CclUnit(), CleanAi(), CommandDiplomacy(), CommandQuit(), CommandSharedVision(), DrawEditorPanel(), DrawInfoPanelNoneSelected(), CPlayerColorGraphic::DrawPlayerColorFrameClip(), CPlayerColorGraphic::DrawPlayerColorFrameClipX(), DrawPlayers(), DrawStartLocations(), DrawUnitIcons(), DrawUnitSelection(), EditorActionPlaceUnit(), EditorCallbackButtonDown(), EditorCallbackKeyDown(), EditorCallbackMouse(), GameTypeLeftVsRight(), GameTypeManTeamVsMachine(), GameTypeManVsMachine(), GameTypeTopVsBottom(), GetNumOpponents(), CEditor::Init(), InputKey(), IsTileRadarVisible(), CMap::IsTileVisible(), CUnit::IsVisible(), LoadGame(), MakePlayerColorTexture(), NetworkConnectSetupGame(), NetworkEvent(), NetworkProcessSelection(), NetworkSendSelection(), ReplayEachCycle(), RescueUnits(), CMap::Reveal(), SaveAiPlayers(), SaveUpgrades(), StartReplay(), tolua_get_stratagus_Players(), tolua_set_stratagus_Players(), UnitCountSeen(), UnitLost(), UnitsOnTileMarkSeen(), UnitsOnTileUnmarkSeen(), and WriteMapSetup().
Player on local computer.
Definition at line 62 of file player.cpp.
Referenced by AddToGroup(), AiRemoveFromBuilt(), CclAiDebugPlayer(), CclDiplomacy(), CclSharedVision(), CommandCancelTraining(), CommandLog(), CreateGame(), DoActionMove(), CButtonPanel::DoClicked(), DoNextReplay(), DoRightButton(), CUnit::Draw(), DrawBuildingCursor(), DrawDecoration(), DrawInfoPanelMultipleSelected(), DrawInfoPanelNoneSelected(), DrawInformations(), CViewport::DrawMapFogOfWar(), DrawResources(), DrawUnitInfo(), DrawUnitOn(), DrawUnitSelection(), EditorCallbackButtonDown(), HandleActionBuilt(), HandleActionTrain(), HandleCheats(), HitUnit(), CEditor::Init(), InputKey(), CUnit::IsVisibleInViewport(), CUnit::IsVisibleOnMinimap(), LoadStratagusMap(), main1(), MissileVisibleInViewport(), NetworkChatMessage(), NetworkConnectSetupGame(), NetworkEvent(), NetworkQuit(), NetworkSendCommands(), NetworkSendSelection(), SaveReplay(), SelectUnitsInRectangle(), SendRepair(), StartReplay(), tolua_get_ThisPlayer_ptr(), tolua_set_ThisPlayer_ptr(), TriggerGetPlayer(), UiFindIdleWorker(), UIHandleButtonDown(), UIHandleButtonUp(), UIHandleMouseMove(), UnitActions(), UnitGoesUnderFog(), UnitOnScreen(), UnitShowAnimationScaled(), CMinimap::Update(), and CButtonPanel::Update().
1.5.6