1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Added serializer-based class able to make deep copies of objects — CMemorySerializer.

CGameState::init will work on the deep copy of StartInfo.
Some casts to reduce warnings.
This commit is contained in:
Michał W. Urbańczyk
2014-02-08 21:54:35 +00:00
parent e6f433795b
commit 43ef565e7e
9 changed files with 77 additions and 20 deletions

View File

@ -40,7 +40,7 @@ namespace Res
ResourceSet operator OPSIGN(const TResource &rhs) const \
{ \
ResourceSet ret = *this; \
for(int i = 0; i < size(); i++) \
for(int i = 0; i < (int)size(); i++) \
ret[i] = at(i) OPSIGN rhs; \
\
return ret; \
@ -52,7 +52,7 @@ namespace Res
ResourceSet operator OPSIGN(const ResourceSet &rhs) const \
{ \
ResourceSet ret = *this; \
for(int i = 0; i < size(); i++) \
for(int i = 0; i < (int)size(); i++) \
ret[i] = at(i) OPSIGN rhs[i]; \
\
return ret; \
@ -85,7 +85,7 @@ namespace Res
int operator/(const ResourceSet &rhs)
{
int ret = INT_MAX;
for(int i = 0; i < size(); i++)
for(int i = 0; i < (int)size(); i++)
if(rhs[i])
vstd::amin(ret, at(i) / rhs[i]);
@ -94,7 +94,7 @@ namespace Res
ResourceSet & operator=(const TResource &rhs)
{
for(int i = 0; i < size(); i++)
for(int i = 0; i < (int)size(); i++)
at(i) = rhs;
return *this;
@ -103,7 +103,7 @@ namespace Res
ResourceSet operator-() const
{
ResourceSet ret;
for(int i = 0; i < size(); i++)
for(int i = 0; i < (int)size(); i++)
ret[i] = -at(i);
return ret;
}