mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* added support for serialization arrays of non-primitive types
* improved switching between fullscreen and windowed mode * fixed crashbug occuring on closing adv options tab in pregame * fixed crashbug on loading maps with events giving resources * fixed data bug * version set to 0.68b
This commit is contained in:
parent
302b5d9427
commit
5a36e61c32
8
CMT.cpp
8
CMT.cpp
@ -199,8 +199,12 @@ int main(int argc, char** argv)
|
|||||||
else if(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4)
|
else if(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4)
|
||||||
{
|
{
|
||||||
LOCPLINT->pim->lock();
|
LOCPLINT->pim->lock();
|
||||||
screen = SDL_SetVideoMode(screen->w,screen->h,screen->format->BitsPerPixel,
|
bool full = !(screen->flags&SDL_FULLSCREEN);
|
||||||
SDL_SWSURFACE|SDL_DOUBLEBUF|((screen->flags&SDL_FULLSCREEN) ? 0 : SDL_FULLSCREEN));
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
screen = SDL_SetVideoMode(conf.cc.resx,conf.cc.resy,conf.cc.bpp,SDL_SWSURFACE|SDL_DOUBLEBUF|(full?SDL_FULLSCREEN:0)); //initializing important global surface
|
||||||
|
SDL_WM_SetCaption(NAME.c_str(),""); //set window title
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
LOCPLINT->curint->show();
|
LOCPLINT->curint->show();
|
||||||
if(LOCPLINT->curint != LOCPLINT->adventureInt)
|
if(LOCPLINT->curint != LOCPLINT->adventureInt)
|
||||||
LOCPLINT->adventureInt->show();
|
LOCPLINT->adventureInt->show();
|
||||||
|
54
CPreGame.cpp
54
CPreGame.cpp
@ -48,17 +48,42 @@ HighButton::HighButton( SDL_Rect Pos, CDefHandler* Imgs, bool Sel, int id)
|
|||||||
pos=Pos;
|
pos=Pos;
|
||||||
ID=id;
|
ID=id;
|
||||||
highlightable=false;
|
highlightable=false;
|
||||||
|
freeimgs = false;
|
||||||
};
|
};
|
||||||
HighButton::HighButton()
|
HighButton::HighButton()
|
||||||
{
|
{
|
||||||
|
freeimgs = true;
|
||||||
state=0;
|
state=0;
|
||||||
}
|
}
|
||||||
|
HighButton::~HighButton()
|
||||||
|
{
|
||||||
|
if(freeimgs)
|
||||||
|
delete imgs;
|
||||||
|
}
|
||||||
void HighButton::show()
|
void HighButton::show()
|
||||||
{
|
{
|
||||||
blitAt(imgs->ourImages[state].bitmap,pos.x,pos.y);
|
blitAt(imgs->ourImages[state].bitmap,pos.x,pos.y);
|
||||||
updateRect(&pos);
|
updateRect(&pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HighButton::hover(bool on)
|
||||||
|
{
|
||||||
|
if (!highlightable) return;
|
||||||
|
int i;
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
state=i=3;
|
||||||
|
highlighted=true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state=i=0;
|
||||||
|
highlighted=false;
|
||||||
|
}
|
||||||
|
SDL_BlitSurface(imgs->ourImages[i].bitmap,NULL,screen,&pos);
|
||||||
|
updateRect(&pos);
|
||||||
|
}
|
||||||
|
|
||||||
void HighButton::press(bool down)
|
void HighButton::press(bool down)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -93,28 +118,6 @@ void SetrButton::press(bool down)
|
|||||||
#endif
|
#endif
|
||||||
HighButton::press(down);
|
HighButton::press(down);
|
||||||
}
|
}
|
||||||
void HighButton::hover(bool on)
|
|
||||||
{
|
|
||||||
if (!highlightable) return;
|
|
||||||
int i;
|
|
||||||
if (on)
|
|
||||||
{
|
|
||||||
state=i=3;
|
|
||||||
highlighted=true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
state=i=0;
|
|
||||||
highlighted=false;
|
|
||||||
}
|
|
||||||
SDL_BlitSurface(imgs->ourImages[i].bitmap,NULL,screen,&pos);
|
|
||||||
updateRect(&pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
HighButton::~HighButton()
|
|
||||||
{
|
|
||||||
delete imgs;
|
|
||||||
}
|
|
||||||
void Button::hover(bool on)
|
void Button::hover(bool on)
|
||||||
{
|
{
|
||||||
HighButton::hover(on);
|
HighButton::hover(on);
|
||||||
@ -835,6 +838,7 @@ int MapSel::countWL()
|
|||||||
}
|
}
|
||||||
void MapSel::printMaps(int from, int to, int at, bool abs)
|
void MapSel::printMaps(int from, int to, int at, bool abs)
|
||||||
{
|
{
|
||||||
|
if (!slid->positionsAmnt) return; //no maps to print
|
||||||
if(slid->positionsAmnt < slid->capacity)
|
if(slid->positionsAmnt < slid->capacity)
|
||||||
from = 0;
|
from = 0;
|
||||||
int help=-1;
|
int help=-1;
|
||||||
@ -1182,6 +1186,11 @@ void MapSel::init()
|
|||||||
{
|
{
|
||||||
if (boost::ends_with(dir->path().filename(),".vlgm1"))
|
if (boost::ends_with(dir->path().filename(),".vlgm1"))
|
||||||
{
|
{
|
||||||
|
if( fs::file_size(dir->path()) < 16000 )
|
||||||
|
{
|
||||||
|
tlog3 << "Savegame " << dir->path() << " seems to be corrupted and will be ommited.\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pliczkiTemp.push_back("Games/"+(dir->path().leaf()));
|
pliczkiTemp.push_back("Games/"+(dir->path().leaf()));
|
||||||
std::time_t time = fs::last_write_time(dir->path());
|
std::time_t time = fs::last_write_time(dir->path());
|
||||||
datestemp.push_back(std::asctime(std::gmtime(&time)));
|
datestemp.push_back(std::asctime(std::gmtime(&time)));
|
||||||
@ -1219,6 +1228,7 @@ void MapSel::moveByOne(bool up)
|
|||||||
}
|
}
|
||||||
void MapSel::select(int which, bool updateMapsList, bool forceSettingsUpdate)
|
void MapSel::select(int which, bool updateMapsList, bool forceSettingsUpdate)
|
||||||
{
|
{
|
||||||
|
if(!curVector().size()) return;
|
||||||
if(which < 0)
|
if(which < 0)
|
||||||
return;
|
return;
|
||||||
bool dontSaveSettings = ((selected!=which) || (CPG->ret.playerInfos.size()==0) || forceSettingsUpdate);
|
bool dontSaveSettings = ((selected!=which) || (CPG->ret.playerInfos.size()==0) || forceSettingsUpdate);
|
||||||
|
@ -27,9 +27,10 @@ struct HighButton
|
|||||||
SDL_Rect pos;
|
SDL_Rect pos;
|
||||||
CDefHandler* imgs;
|
CDefHandler* imgs;
|
||||||
int state;
|
int state;
|
||||||
|
bool freeimgs;
|
||||||
HighButton( SDL_Rect Pos, CDefHandler* Imgs, bool Sel=false, int id=-1);
|
HighButton( SDL_Rect Pos, CDefHandler* Imgs, bool Sel=false, int id=-1);
|
||||||
HighButton();
|
HighButton();
|
||||||
~HighButton();
|
virtual ~HighButton();
|
||||||
bool selectable, selected;
|
bool selectable, selected;
|
||||||
bool highlightable, highlighted;
|
bool highlightable, highlighted;
|
||||||
virtual void show();
|
virtual void show();
|
||||||
|
2
global.h
2
global.h
@ -19,7 +19,7 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
|
|||||||
#define THC
|
#define THC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NAME_VER ("VCMI 0.68a")
|
#define NAME_VER ("VCMI 0.68b")
|
||||||
#define CONSOLE_LOGGING_LEVEL 5
|
#define CONSOLE_LOGGING_LEVEL 5
|
||||||
#define FILE_LOGGING_LEVEL 6
|
#define FILE_LOGGING_LEVEL 6
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ class CConnection;
|
|||||||
|
|
||||||
namespace mpl = boost::mpl;
|
namespace mpl = boost::mpl;
|
||||||
|
|
||||||
|
template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
|
||||||
|
#define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr)))
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace asio
|
namespace asio
|
||||||
@ -47,6 +50,7 @@ enum SerializationLvl
|
|||||||
{
|
{
|
||||||
Wrong=0,
|
Wrong=0,
|
||||||
Primitive,
|
Primitive,
|
||||||
|
Array,
|
||||||
Pointer,
|
Pointer,
|
||||||
Serializable
|
Serializable
|
||||||
};
|
};
|
||||||
@ -92,6 +96,22 @@ struct LoadPointer
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename Ser,typename T>
|
template<typename Ser,typename T>
|
||||||
|
struct SaveArray
|
||||||
|
{
|
||||||
|
static void invoke(Ser &s, const T &data)
|
||||||
|
{
|
||||||
|
s.saveArray(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename Ser,typename T>
|
||||||
|
struct LoadArray
|
||||||
|
{
|
||||||
|
static void invoke(Ser &s, T &data)
|
||||||
|
{
|
||||||
|
s.loadArray(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename Ser,typename T>
|
||||||
struct LoadSerializable
|
struct LoadSerializable
|
||||||
{
|
{
|
||||||
static void invoke(Ser &s, T &data)
|
static void invoke(Ser &s, T &data)
|
||||||
@ -105,7 +125,7 @@ struct SaveWrong
|
|||||||
{
|
{
|
||||||
static void invoke(Ser &s, const T &data)
|
static void invoke(Ser &s, const T &data)
|
||||||
{
|
{
|
||||||
throw std::exception("Wrong save serialization call!");
|
throw std::string("Wrong save serialization call!");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename Ser,typename T>
|
template<typename Ser,typename T>
|
||||||
@ -113,7 +133,7 @@ struct LoadWrong
|
|||||||
{
|
{
|
||||||
static void invoke(Ser &s, const T &data)
|
static void invoke(Ser &s, const T &data)
|
||||||
{
|
{
|
||||||
throw std::exception("Wrong load serialization call!");
|
throw std::string("Wrong load serialization call!");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -132,7 +152,7 @@ struct SerializationLevel
|
|||||||
//else
|
//else
|
||||||
typename mpl::eval_if<
|
typename mpl::eval_if<
|
||||||
boost::is_array<T>,
|
boost::is_array<T>,
|
||||||
mpl::int_<Primitive>,
|
mpl::int_<Array>,
|
||||||
//else
|
//else
|
||||||
typename mpl::eval_if<
|
typename mpl::eval_if<
|
||||||
boost::is_pointer<T>,
|
boost::is_pointer<T>,
|
||||||
@ -191,6 +211,13 @@ public:
|
|||||||
*this << *data;
|
*this << *data;
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
void saveArray(const T &data)
|
||||||
|
{
|
||||||
|
ui32 size = ARRAY_COUNT(data);
|
||||||
|
for(ui32 i=0; i < size; i++)
|
||||||
|
*this << data[i];
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
void save(const T &data)
|
void save(const T &data)
|
||||||
{
|
{
|
||||||
typedef
|
typedef
|
||||||
@ -201,12 +228,16 @@ public:
|
|||||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
|
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
|
||||||
mpl::identity<SavePointer<Serializer,T> >,
|
mpl::identity<SavePointer<Serializer,T> >,
|
||||||
//else if
|
//else if
|
||||||
|
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Array> >,
|
||||||
|
mpl::identity<SaveArray<Serializer,T> >,
|
||||||
|
//else if
|
||||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
|
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
|
||||||
mpl::identity<SaveSerializable<Serializer,T> >,
|
mpl::identity<SaveSerializable<Serializer,T> >,
|
||||||
//else
|
//else
|
||||||
mpl::identity<SaveWrong<Serializer,T> >
|
mpl::identity<SaveWrong<Serializer,T> >
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
|
>
|
||||||
>::type typex;
|
>::type typex;
|
||||||
typex::invoke(* this->This(), data);
|
typex::invoke(* this->This(), data);
|
||||||
}
|
}
|
||||||
@ -285,12 +316,16 @@ public:
|
|||||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
|
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Pointer> >,
|
||||||
mpl::identity<LoadPointer<Serializer,T> >,
|
mpl::identity<LoadPointer<Serializer,T> >,
|
||||||
//else if
|
//else if
|
||||||
|
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Array> >,
|
||||||
|
mpl::identity<LoadArray<Serializer,T> >,
|
||||||
|
//else if
|
||||||
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
|
typename mpl::eval_if<mpl::equal_to<SerializationLevel<T>,mpl::int_<Serializable> >,
|
||||||
mpl::identity<LoadSerializable<Serializer,T> >,
|
mpl::identity<LoadSerializable<Serializer,T> >,
|
||||||
//else
|
//else
|
||||||
mpl::identity<LoadWrong<Serializer,T> >
|
mpl::identity<LoadWrong<Serializer,T> >
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
|
>
|
||||||
>::type typex;
|
>::type typex;
|
||||||
typex::invoke(* this->This(), data);
|
typex::invoke(* this->This(), data);
|
||||||
}
|
}
|
||||||
@ -305,6 +340,13 @@ public:
|
|||||||
data.serialize(*this,version);
|
data.serialize(*this,version);
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
void loadArray(T &data)
|
||||||
|
{
|
||||||
|
ui32 size = ARRAY_COUNT(data);
|
||||||
|
for(ui32 i=0; i < size; i++)
|
||||||
|
*this >> data[i];
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
void loadPointer(T &data)
|
void loadPointer(T &data)
|
||||||
{
|
{
|
||||||
ui8 hlp;
|
ui8 hlp;
|
||||||
|
2
map.cpp
2
map.cpp
@ -775,7 +775,7 @@ void Mapa::loadTown( CGObjectInstance * &nobj, unsigned char * bufor, int &i )
|
|||||||
CCastleEvent nce;
|
CCastleEvent nce;
|
||||||
nce.name = readString(bufor,i);
|
nce.name = readString(bufor,i);
|
||||||
nce.message = readString(bufor,i);
|
nce.message = readString(bufor,i);
|
||||||
|
nce.resources.resize(RESOURCE_QUANTITY);
|
||||||
for(int x=0; x < 7; x++)
|
for(int x=0; x < 7; x++)
|
||||||
{
|
{
|
||||||
nce.resources[x] = readNormalNr(bufor,i);
|
nce.resources[x] = readNormalNr(bufor,i);
|
||||||
|
@ -1702,21 +1702,7 @@ customactionend:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
HANDLE_EXCEPTION(end2 = true);
|
||||||
{
|
|
||||||
tlog1 << "Exception during handling connection: " << e.what() << std::endl;
|
|
||||||
end2 = true;
|
|
||||||
}
|
|
||||||
catch (const std::exception * e)
|
|
||||||
{
|
|
||||||
tlog1 << "Exception during handling connection: " << e->what()<< std::endl;
|
|
||||||
end2 = true;
|
|
||||||
delete e;
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
end2 = true;
|
|
||||||
}
|
|
||||||
handleConEnd:
|
handleConEnd:
|
||||||
tlog1 << "Ended handling connection\n";
|
tlog1 << "Ended handling connection\n";
|
||||||
}
|
}
|
||||||
@ -1948,6 +1934,10 @@ void CGameHandler::run(bool resume)
|
|||||||
|
|
||||||
while (!end2)
|
while (!end2)
|
||||||
{
|
{
|
||||||
|
if(!resume)
|
||||||
|
newTurn();
|
||||||
|
else
|
||||||
|
resume = false;
|
||||||
|
|
||||||
std::map<ui8,PlayerState>::iterator i;
|
std::map<ui8,PlayerState>::iterator i;
|
||||||
if(!resume)
|
if(!resume)
|
||||||
@ -1957,10 +1947,6 @@ void CGameHandler::run(bool resume)
|
|||||||
|
|
||||||
for(; i != gs->players.end(); i++)
|
for(; i != gs->players.end(); i++)
|
||||||
{
|
{
|
||||||
if(!resume)
|
|
||||||
newTurn();
|
|
||||||
else
|
|
||||||
resume = false;
|
|
||||||
|
|
||||||
if((i->second.towns.size()==0 && i->second.heroes.size()==0) || i->second.color<0 || i->first>=PLAYER_LIMIT ) continue; //players has not towns/castle - loser
|
if((i->second.towns.size()==0 && i->second.heroes.size()==0) || i->second.color<0 || i->first>=PLAYER_LIMIT ) continue; //players has not towns/castle - loser
|
||||||
states.setFlag(i->first,&PlayerStatus::makingTurn,true);
|
states.setFlag(i->first,&PlayerStatus::makingTurn,true);
|
||||||
|
Loading…
Reference in New Issue
Block a user