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
|
|
|
*/
|
|
|
|
|
2013-04-15 20:18:04 +03:00
|
|
|
class CMapGenOptions;
|
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
|
|
|
|
};
|
|
|
|
|
2013-02-02 01:04:25 +03:00
|
|
|
Ebonus bonus;
|
2012-12-02 15:21:44 +03:00
|
|
|
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;
|
2013-03-03 20:06:03 +03:00
|
|
|
PlayerColor color; //from 0 -
|
2013-02-02 01:04:25 +03:00
|
|
|
enum EHandicap {NO_HANDICAP, MILD, SEVERE};
|
|
|
|
EHandicap handicap;//0-no, 1-mild, 2-severe
|
2013-03-03 20:06:03 +03:00
|
|
|
TeamID 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),
|
2013-02-02 01:04:25 +03:00
|
|
|
color(0), handicap(NO_HANDICAP), 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
|
|
|
|
2013-11-12 13:45:42 +03:00
|
|
|
EMode mode;
|
|
|
|
ui8 difficulty; //0=easy; 4=impossible
|
|
|
|
|
|
|
|
typedef std::map<PlayerColor, PlayerSettings> TPlayerInfos;
|
|
|
|
TPlayerInfos playerInfos; //color indexed
|
|
|
|
|
|
|
|
ui32 seedToBeUsed; //0 if not sure (client requests server to decide, will be send in reply pack)
|
2012-04-14 05:20:22 +03:00
|
|
|
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
|
2013-05-21 22:08:06 +03:00
|
|
|
bool createRandomMap() const { return mapGenOptions.get() != nullptr; }
|
|
|
|
shared_ptr<CMapGenOptions> mapGenOptions;
|
2012-09-21 20:59:54 +03:00
|
|
|
|
|
|
|
shared_ptr<CCampaignState> campState;
|
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
PlayerSettings & getIthPlayersSettings(PlayerColor 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];
|
2013-04-09 17:31:36 +03:00
|
|
|
logGlobal->errorStream() << "Cannot find info about player " << no <<". Throwing...";
|
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
|
|
|
}
|
2013-06-21 23:59:32 +03:00
|
|
|
const PlayerSettings & getIthPlayersSettings(PlayerColor no) const
|
|
|
|
{
|
|
|
|
return const_cast<StartInfo&>(*this).getIthPlayersSettings(no);
|
|
|
|
}
|
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
|
|
|
|
2013-06-26 14:18:27 +03:00
|
|
|
return nullptr;
|
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 & 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),
|
2013-05-21 22:08:06 +03:00
|
|
|
mapfileChecksum(0), turnTime(0)
|
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
|
|
|
};
|