mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Proper initialization of the first turn.
This commit is contained in:
@@ -1,14 +1,25 @@
|
||||
#include "../global.h"
|
||||
|
||||
struct NewTurn
|
||||
struct IPack
|
||||
{
|
||||
virtual ui16 getType()=0;
|
||||
};
|
||||
template <typename T> struct CPack
|
||||
:public IPack
|
||||
{
|
||||
ui16 type;
|
||||
ui16 getType(){return type;}
|
||||
T* This(){return static_cast<T*>(this);};
|
||||
};
|
||||
struct NewTurn : public CPack<NewTurn> //101
|
||||
{
|
||||
struct Hero
|
||||
{
|
||||
ui32 id, move, mana; //id is a general serial id
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h -= id -= move -= mana;
|
||||
h & id & move & mana;
|
||||
}
|
||||
bool operator<(const Hero&h)const{return id < h.id;}
|
||||
};
|
||||
struct Resources
|
||||
{
|
||||
@@ -16,17 +27,20 @@ struct NewTurn
|
||||
si32 resources[RESOURCE_QUANTITY];
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h -= resources;
|
||||
h & player & resources;
|
||||
}
|
||||
bool operator<(const Resources&h)const{return player < h.player;}
|
||||
};
|
||||
|
||||
std::set<Hero> heroes;
|
||||
std::set<Resources> res;
|
||||
|
||||
std::set<Hero> heroes; //updates movement and mana points
|
||||
std::set<Resources> res;//resource list
|
||||
ui32 day;
|
||||
bool resetBuilded;
|
||||
|
||||
NewTurn(){type = 101;};
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h += heroes += res;
|
||||
h & heroes & res & day & resetBuilded;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user