2011-12-14 00:35:28 +03:00
|
|
|
#pragma once
|
2009-04-16 14:14:13 +03:00
|
|
|
|
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-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
|
|
|
|
{
|
2010-07-31 16:55:05 +03:00
|
|
|
enum Ebonus {brandom=-1,bartifact, bgold, bresource};
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
si32 castle, hero, //ID, if -1 then random, if -2 then none
|
|
|
|
heroPortrait; //-1 if default, else ID
|
|
|
|
std::string heroName;
|
2012-09-18 20:47:52 +03:00
|
|
|
si8 bonus; //uses enum type Ebonus
|
2009-04-16 14:14:13 +03:00
|
|
|
ui8 color; //from 0 -
|
|
|
|
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;
|
2010-10-24 14:35:14 +03:00
|
|
|
ui8 human; //0 - AI, non-0 serves as player id
|
2009-04-16 14:14:13 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & castle;
|
|
|
|
h & hero;
|
|
|
|
h & heroPortrait;
|
|
|
|
h & heroName;
|
|
|
|
h & bonus;
|
|
|
|
h & color;
|
|
|
|
h & handicap;
|
|
|
|
h & name;
|
|
|
|
h & human;
|
2012-01-19 17:33:22 +03:00
|
|
|
h & team;
|
2009-04-16 14:14:13 +03:00
|
|
|
}
|
2009-08-17 11:50:31 +03:00
|
|
|
|
|
|
|
PlayerSettings()
|
|
|
|
{
|
|
|
|
bonus = brandom;
|
|
|
|
castle = -2;
|
|
|
|
heroPortrait = -1;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
typedef bmap<int, PlayerSettings> TPlayerInfos;
|
|
|
|
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
|
|
|
|
std::string mapname;
|
2012-09-21 20:59:54 +03:00
|
|
|
|
|
|
|
shared_ptr<CCampaignState> campState;
|
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
PlayerSettings & getIthPlayersSettings(int no)
|
|
|
|
{
|
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
|
|
|
{
|
2010-12-20 23:22:53 +02:00
|
|
|
for(bmap<int, PlayerSettings>::iterator it=playerInfos.begin(); it != playerInfos.end(); ++it)
|
2010-10-24 14:35:14 +03:00
|
|
|
if(it->second.human == 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
|
|
|
|
2009-04-16 14:14:13 +03:00
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
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-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
|
|
|
|
|
|
|
StartInfo()
|
|
|
|
{
|
2012-04-14 05:20:22 +03:00
|
|
|
mapfileChecksum = seedPostInit = seedToBeUsed = 0;
|
2010-10-24 14:35:14 +03:00
|
|
|
mode = INVALID;
|
2012-09-21 20:59:54 +03:00
|
|
|
campState = nullptr;
|
2010-10-24 14:35:14 +03:00
|
|
|
}
|
2009-04-16 14:14:13 +03:00
|
|
|
};
|