2011-12-14 00:35:28 +03:00
|
|
|
#pragma once
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2012-09-24 19:14:53 +03:00
|
|
|
#include "GameConstants.h"
|
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* StartInfo.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
#include "RMG/CMapGenOptions.h"
|
|
|
|
|
2012-09-18 20:47:52 +03:00
|
|
|
class CCampaignState;
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Struct which describes the name, the color, the starting bonus of a player
|
2009-04-16 14:14:13 +03:00
|
|
|
struct PlayerSettings
|
|
|
|
{
|
2012-12-02 15:21:44 +03:00
|
|
|
enum { PLAYER_AI = 0 }; // for use in playerID
|
|
|
|
|
|
|
|
enum Ebonus {
|
|
|
|
NONE = -2,
|
|
|
|
RANDOM = -1,
|
|
|
|
ARTIFACT = 0,
|
|
|
|
GOLD = 1,
|
|
|
|
RESOURCE = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
//uses enum type Ebonus
|
|
|
|
si8 bonus;
|
|
|
|
si16 castle;
|
|
|
|
si32 hero,
|
|
|
|
heroPortrait; //-1 if default, else ID
|
2010-07-31 16:55:05 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
std::string heroName;
|
2012-09-24 19:14:53 +03:00
|
|
|
TPlayerColor color; //from 0 -
|
2009-04-16 14:14:13 +03:00
|
|
|
ui8 handicap;//0-no, 1-mild, 2-severe
|
2012-01-19 17:33:22 +03:00
|
|
|
ui8 team;
|
2010-10-24 14:35:14 +03:00
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
std::string name;
|
2012-12-02 15:21:44 +03:00
|
|
|
ui8 playerID; //0 - AI, non-0 serves as player id
|
2013-01-06 22:30:12 +03:00
|
|
|
bool compOnly; //true if this player is a computer only player; required for RMG
|
2012-12-02 15:21:44 +03:00
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler &h, const int version)
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
h & castle;
|
|
|
|
h & hero;
|
|
|
|
h & heroPortrait;
|
|
|
|
h & heroName;
|
|
|
|
h & bonus;
|
|
|
|
h & color;
|
|
|
|
h & handicap;
|
|
|
|
h & name;
|
2012-12-02 15:21:44 +03:00
|
|
|
h & playerID;
|
2012-01-19 17:33:22 +03:00
|
|
|
h & team;
|
2013-01-06 22:30:12 +03:00
|
|
|
h & compOnly;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2009-08-17 11:50:31 +03:00
|
|
|
|
2013-01-20 17:43:58 +03:00
|
|
|
PlayerSettings() : bonus(RANDOM), castle(NONE), hero(RANDOM), heroPortrait(RANDOM),
|
|
|
|
color(0), handicap(0), team(0), playerID(PLAYER_AI), compOnly(false)
|
2009-08-17 11:50:31 +03:00
|
|
|
{
|
2013-01-06 22:30:12 +03:00
|
|
|
|
2009-08-17 11:50:31 +03:00
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|
|
|
|
|
2011-02-22 13:52:36 +02:00
|
|
|
/// Struct which describes the difficulty, the turn time,.. of a heroes match.
|
2009-04-16 14:14:13 +03:00
|
|
|
struct StartInfo
|
|
|
|
{
|
2010-12-22 22:14:40 +02:00
|
|
|
enum EMode {NEW_GAME, LOAD_GAME, CAMPAIGN, DUEL, INVALID = 255};
|
2010-08-18 12:50:25 +03:00
|
|
|
|
2010-10-24 14:35:14 +03:00
|
|
|
ui8 mode; //uses EMode enum
|
2009-04-16 14:14:13 +03:00
|
|
|
ui8 difficulty; //0=easy; 4=impossible
|
2012-01-19 17:33:22 +03:00
|
|
|
|
2012-09-24 19:14:53 +03:00
|
|
|
typedef bmap<TPlayerColor, PlayerSettings> TPlayerInfos;
|
2012-01-19 17:33:22 +03:00
|
|
|
TPlayerInfos playerInfos; //color indexed
|
|
|
|
|
2012-04-14 05:20:22 +03:00
|
|
|
ui32 seedToBeUsed; //0 if not sure (client requests server to decide, will be send in reply pack)
|
|
|
|
ui32 seedPostInit; //so we know that game is correctly synced at the start; 0 if not known yet
|
|
|
|
ui32 mapfileChecksum; //0 if not relevant
|
2009-04-16 14:14:13 +03:00
|
|
|
ui8 turnTime; //in minutes, 0=unlimited
|
2012-11-20 20:53:45 +03:00
|
|
|
std::string mapname; // empty for random map, otherwise name of the map or savegame
|
|
|
|
bool createRandomMap; // true if a random map should be created
|
|
|
|
shared_ptr<CMapGenOptions> mapGenOptions; // needs to be not nullptr if createRandomMap=true
|
2012-09-21 20:59:54 +03:00
|
|
|
|
|
|
|
shared_ptr<CCampaignState> campState;
|
|
|
|
|
2012-09-24 19:14:53 +03:00
|
|
|
PlayerSettings & getIthPlayersSettings(TPlayerColor no)
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
2010-08-03 14:36:52 +03:00
|
|
|
if(playerInfos.find(no) != playerInfos.end())
|
|
|
|
return playerInfos[no];
|
2009-04-16 14:14:13 +03:00
|
|
|
tlog1 << "Cannot find info about player " << no <<". Throwing...\n";
|
2012-04-22 10:32:45 +03:00
|
|
|
throw std::runtime_error("Cannot find info about player");
|
2010-02-16 18:35:24 +02:00
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2010-10-24 14:35:14 +03:00
|
|
|
PlayerSettings *getPlayersSettings(const ui8 nameID)
|
2010-02-16 18:35:24 +02:00
|
|
|
{
|
2012-09-24 19:14:53 +03:00
|
|
|
for(auto it=playerInfos.begin(); it != playerInfos.end(); ++it)
|
2012-12-02 15:21:44 +03:00
|
|
|
if(it->second.playerID == nameID)
|
2010-08-03 14:36:52 +03:00
|
|
|
return &it->second;
|
2010-02-16 18:35:24 +02:00
|
|
|
|
|
|
|
return NULL;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2010-02-16 18:35:24 +02:00
|
|
|
|
2012-12-02 15:21:44 +03:00
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler &h, const int version)
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
h & mode;
|
|
|
|
h & difficulty;
|
|
|
|
h & playerInfos;
|
2012-04-14 05:20:22 +03:00
|
|
|
h & seedToBeUsed & seedPostInit;
|
|
|
|
h & mapfileChecksum;
|
2009-04-16 14:14:13 +03:00
|
|
|
h & turnTime;
|
|
|
|
h & mapname;
|
2012-11-20 20:53:45 +03:00
|
|
|
h & createRandomMap;
|
|
|
|
h & mapGenOptions;
|
2012-09-21 20:59:54 +03:00
|
|
|
h & campState;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2010-10-24 14:35:14 +03:00
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
StartInfo() : mode(INVALID), difficulty(0), seedToBeUsed(0), seedPostInit(0),
|
|
|
|
mapfileChecksum(0), turnTime(0), createRandomMap(false)
|
2010-10-24 14:35:14 +03:00
|
|
|
{
|
2012-11-20 20:53:45 +03:00
|
|
|
|
2010-10-24 14:35:14 +03:00
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|