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

       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"

player.h File Reference

The player headerfile. More...

#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.
CPlayerThisPlayer
 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


Detailed Description

The player headerfile.

Definition in file player.h.


Define Documentation

#define CanSelectMultipleUnits ( player   )     ((player) == ThisPlayer || ThisPlayer->IsTeamed((player)))

#define PlayerNumNeutral   (PlayerMax - 1)


Enumeration Type Documentation

enum NotifyType

Notify types. Noties are send to the player.

Enumerator:
NotifyRed  Red alram.
NotifyYellow  Yellow alarm.
NotifyGreen  Green alarm.

Definition at line 425 of file player.h.

Types for the player

PlayerNeutral

This player is controlled by the computer doing nothing.

PlayerNobody

This player is unused. Nobody controlls this player.

PlayerComputer

This player is controlled by the computer. CPlayer::AiNum selects the AI strategy.

PlayerPerson

This player is contolled by a person. This can be the player sitting on the local computer or player playing over the network.

PlayerRescuePassive

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.

PlayerRescueActive

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.

Enumerator:
PlayerNeutral  neutral
PlayerNobody  unused slot
PlayerComputer  computer player
PlayerPerson  human player
PlayerRescuePassive  rescued passive
PlayerRescueActive  rescued active

Definition at line 411 of file player.h.


Function Documentation

void CalculateRequestedAmount ( CUnitType utype,
int  bcosts[MaxCosts],
int  costs[MaxCosts] 
)

Output debug informations for players.

Calculate how many resources the unit needs to request

Parameters:
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  ) 

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

void GraphicPlayerPixels ( CPlayer player,
const CGraphic sprite 
)

Calculate how many resources the unit needs to request.

Change current color set to new player.

FIXME: use function pointer here.

Parameters:
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   ) 

void PlayersEachCycle ( void   ) 

void PlayersEachSecond ( int  player  ) 

Change current color set to new player of the sprite.

Handle AI of a player each second.

Parameters:
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  ) 


Variable Documentation

Disable rescue check.

Definition at line 64 of file player.cpp.

Referenced by CleanPlayers(), and RescueUnits().

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

CPlayer Players[PlayerMax]


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