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

       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.cpp File Reference

The players. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <algorithm>
#include "stratagus.h"
#include "video.h"
#include "sound.h"
#include "unitsound.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
#include "map.h"
#include "ai.h"
#include "network.h"
#include "netconnect.h"
#include "interface.h"
#include "iolib.h"
#include "ui.h"

Go to the source code of this file.

Functions

void InitPlayers (void)
 < Init players
void CleanPlayers (void)
 Save players.
void CalculateRequestedAmount (CUnitType *utype, int bcosts[MaxCosts], int costs[MaxCosts])
 Output debug informations for players.
static int AvailableResourcesRate (int type, CPlayer *p)
static int SpecificEfficiency (int type, CPlayer *p)
static int BaseEfficiency (CPlayer *p)
static int ExtraProduction (int type, CPlayer *p, int be)
static int UniqueNeeds (int type, CPlayer *p)
static int UniqueEfficiency (int type, CPlayer *p)
static int MaxRate (CUnit *unit, int res)
static void CalculateCosts (CUnit *unit, int costs[MaxCosts])
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 SetPlayersPalette (void)
 The SDL screen.
void DebugPlayers (void)
 register ccl features

Variables

int NumPlayers
 How many player slots used.
CPlayer Players [PlayerMax]
 All players in play.
CPlayerThisPlayer
 Player on this 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 players.

Definition in file player.cpp.


Function Documentation

static int AvailableResourcesRate ( int  type,
CPlayer p 
) [static]

Definition at line 271 of file player.cpp.

References CPlayer::ProductionRate, and CPlayer::StoredResources.

Referenced by ExtraProduction(), and SpecificEfficiency().

static int BaseEfficiency ( CPlayer p  )  [static]

Definition at line 289 of file player.cpp.

References EnergyCost, MagmaCost, and SpecificEfficiency().

Referenced by CalculateCosts(), and UniqueEfficiency().

static void CalculateCosts ( CUnit unit,
int  costs[MaxCosts] 
) [static]

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

static int ExtraProduction ( int  type,
CPlayer p,
int  be 
) [static]

Definition at line 295 of file player.cpp.

References AvailableResourcesRate(), and CPlayer::RequestedUtilizationRate.

Referenced by UniqueEfficiency().

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   ) 

static int MaxRate ( CUnit unit,
int  res 
) [static]

Definition at line 324 of file player.cpp.

References CUnit::Player, and CPlayer::UnitsConsumingResourcesRequested.

Referenced by CalculateCosts().

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  ) 

void SetPlayersPalette ( void   ) 

The SDL screen.

Setup the player colors for the current palette.

Todo:
FIXME: could be called before PixelsXX is setup.

Definition at line 852 of file player.cpp.

References CUnitColors::Colors, PlayerColorIndexCount, PlayerColorsRGB, PlayerMax, and CPlayer::UnitColors.

Referenced by CclNewPlayerColors(), CreateGame(), and LoadModules().

static int SpecificEfficiency ( int  type,
CPlayer p 
) [static]

Definition at line 279 of file player.cpp.

References AvailableResourcesRate(), and CPlayer::RequestedUtilizationRate.

Referenced by BaseEfficiency().

static int UniqueEfficiency ( int  type,
CPlayer p 
) [static]

Definition at line 318 of file player.cpp.

References BaseEfficiency(), ExtraProduction(), and UniqueNeeds().

Referenced by CalculateCosts().

static int UniqueNeeds ( int  type,
CPlayer p 
) [static]

Definition at line 301 of file player.cpp.

References EnergyCost, MagmaCost, and CPlayer::UnitsConsumingResourcesRequested.

Referenced by UniqueEfficiency().


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