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-07 13:48:07 +03:00
|
|
|
#include "rmg/CMapGenOptions.h"
|
2012-11-20 20:53:45 +03:00
|
|
|
|
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-02-02 01:04:25 +03:00
|
|
|
EMode mode;
|
2009-04-16 14:14:13 +03:00
|
|
|
ui8 difficulty; //0=easy; 4=impossible
|
2012-01-19 17:33:22 +03:00
|
|
|
|
2013-03-03 20:06:03 +03:00
|
|
|
typedef bmap<PlayerColor, 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;
|
|
|
|
|
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
|
|
|
}
|
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
|
|
|
};
|