$treeview $search $mathjax
Stratagus
2.2.6
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1998-2005 by Lutz Sammer and Jimmy Salmon 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 00030 #ifndef __PLAYER_H__ 00031 #define __PLAYER_H__ 00032 00034 00035 /*---------------------------------------------------------------------------- 00036 -- Documentation 00037 ----------------------------------------------------------------------------*/ 00038 00280 /*---------------------------------------------------------------------------- 00281 -- Includes 00282 ----------------------------------------------------------------------------*/ 00283 00284 #include <string> 00285 #include "upgrade_structs.h" 00286 #include "video.h" 00287 00288 #ifndef __MAP_TILE_H__ 00289 #include "tile.h" 00290 #endif 00291 00292 /*---------------------------------------------------------------------------- 00293 -- Declarations 00294 ----------------------------------------------------------------------------*/ 00295 00296 class CUnit; 00297 class CUnitType; 00298 class PlayerAi; 00299 class CFile; 00300 00301 /*---------------------------------------------------------------------------- 00302 -- Player type 00303 ----------------------------------------------------------------------------*/ 00304 00306 class CPlayer 00307 { 00308 public: 00309 int Index; 00310 std::string Name; 00311 00312 int Type; 00313 int Race; 00314 std::string AiName; 00315 00316 // friend enemy detection 00317 int Team; 00318 unsigned int Enemy; 00319 unsigned int Allied; 00320 unsigned int SharedVision; 00321 00322 int StartX; 00323 int StartY; 00324 inline void SetStartView(int x, int y) { StartX = x; StartY = y; } 00325 00326 int Resources[MaxCosts]; 00327 int LastResources[MaxCosts]; 00328 int Incomes[MaxCosts]; 00329 int Revenue[MaxCosts]; 00330 00331 // FIXME: shouldn't use the constant 00332 int UnitTypesCount[UnitTypeMax]; 00333 00334 int AiEnabled; 00335 PlayerAi *Ai; 00336 00337 CUnit *Units[UnitMax]; 00338 int TotalNumUnits; 00339 int NumBuildings; 00340 int Supply; 00341 int Demand; 00342 00343 int UnitLimit; 00344 int BuildingLimit; 00345 int TotalUnitLimit; 00346 00347 int Score; 00348 int TotalUnits; 00349 int TotalBuildings; 00350 int TotalResources[MaxCosts]; 00351 int TotalRazings; 00352 int TotalKills; 00353 00354 Uint32 Color; 00355 00356 CUnitColors UnitColors; 00357 00358 // Upgrades/Allows: 00359 CAllow Allow; 00360 CUpgradeTimers UpgradeTimers; 00361 CUnitCache AutoAttackTargets; 00362 00364 void SetSide(int side); 00366 void SetName(const std::string &name); 00367 00369 void Clear(); 00370 00372 void SetResource(int resource, int value); 00373 00375 int CheckLimits(const CUnitType &type) const; 00376 00378 int CheckCosts(const int *costs) const; 00380 int CheckUnitType(const CUnitType &type) const; 00381 00383 void AddCosts(const int *costs); 00385 void AddUnitType(const CUnitType &type); 00387 void AddCostsFactor(const int *costs, int factor); 00389 void SubCosts(const int *costs); 00391 void SubUnitType(const CUnitType &type); 00393 void SubCostsFactor(const int *costs, int factor); 00394 00396 int HaveUnitTypeByType(const CUnitType &type) const; 00398 int HaveUnitTypeByIdent(const std::string &ident) const; 00399 00401 void Notify(int type, int x, int y, const char *fmt, ...) const; 00402 00406 bool IsEnemy(const int index) const 00407 { 00408 return (Index != index && (Enemy & (1 << index)) != 0); 00409 } 00410 00411 bool IsEnemy(const CPlayer &player) const; 00412 bool IsEnemy(const CUnit &unit) const; 00413 bool IsAllied(const CPlayer &player) const; 00414 bool IsAllied(const CUnit &unit) const; 00415 bool IsSharedVision(const CPlayer &player) const; 00416 bool IsSharedVision(const CUnit &unit) const; 00417 bool IsBothSharedVision(const CPlayer &player) const; 00418 bool IsBothSharedVision(const CUnit &unit) const; 00419 bool IsTeamed(const CPlayer &player) const; 00420 bool IsTeamed(const CUnit &unit) const; 00421 }; 00422 00427 #define MAX_RACES 8 00428 class PlayerRace { 00429 public: 00430 PlayerRace() : Count(0) { 00431 memset(Visible, 0, sizeof(Visible)); 00432 } 00433 00434 bool Visible[MAX_RACES]; 00435 std::string Name[MAX_RACES]; 00436 std::string Display[MAX_RACES]; 00437 unsigned int Count; 00438 }; 00439 00440 00441 enum PlayerRacesOld { 00442 PlayerRaceHuman = 0, 00443 PlayerRaceOrc = 1 00444 }; 00445 00484 enum PlayerTypes { 00485 PlayerNeutral = 2, 00486 PlayerNobody = 3, 00487 PlayerComputer = 4, 00488 PlayerPerson = 5, 00489 PlayerRescuePassive = 6, 00490 PlayerRescueActive = 7 00491 }; 00492 00493 #define PlayerNumNeutral (PlayerMax - 1) 00494 00495 00498 enum NotifyType { 00499 NotifyRed, 00500 NotifyYellow, 00501 NotifyGreen 00502 }; 00503 00504 /*---------------------------------------------------------------------------- 00505 -- Variables 00506 ----------------------------------------------------------------------------*/ 00507 00508 extern int NumPlayers; 00509 extern CPlayer Players[PlayerMax]; 00510 extern CPlayer *ThisPlayer; 00511 extern bool NoRescueCheck; 00512 extern SDL_Color *PlayerColorsRGB[PlayerMax]; 00513 extern Uint32 *PlayerColors[PlayerMax]; 00514 extern std::string PlayerColorNames[PlayerMax]; 00515 00516 extern PlayerRace PlayerRaces; 00517 00521 extern int PlayerColorIndexStart; 00522 extern int PlayerColorIndexCount; 00523 00524 /*---------------------------------------------------------------------------- 00525 -- Functions 00526 ----------------------------------------------------------------------------*/ 00527 00529 extern void InitPlayers(); 00531 extern void CleanPlayers(); 00533 extern void CleanRaces(); 00535 extern void SavePlayers(CFile *file); 00536 00538 extern void CreatePlayer(int type); 00539 00540 00542 extern void PlayersInitAi(); 00544 extern void PlayersEachCycle(); 00546 extern void PlayersEachSecond(int player); 00547 00549 extern void GraphicPlayerPixels(CPlayer &player, const CGraphic *sprite); 00550 00552 extern void DebugPlayers(); 00553 00554 #ifdef DEBUG 00555 void FreePlayerColors(); 00556 #endif 00557 00559 extern void PlayerCclRegister(); 00560 00562 #define CanSelectMultipleUnits(player) \ 00563 (&(player) == ThisPlayer || ThisPlayer->IsTeamed(player)) 00564 00566 00567 #endif // !__PLAYER_H__