1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

First part of support for victory & loss conditions.

Implemented and tested are
victory:
Defeat hero
Capture town
Defeat monster
Flag dwellings
Flag mines

Lose:
Loss hero
Time expire

**

Some others may work but not has been tested yet.
I've added a new page in VCMI Status spreadsheet with status of various victory/loss conditions.
This commit is contained in:
Michał W. Urbańczyk
2010-01-29 20:52:45 +00:00
parent 8447e58c39
commit 5279e2e9fc
23 changed files with 643 additions and 105 deletions

View File

@@ -147,22 +147,40 @@ CConnection::CConnection(boost::asio::basic_socket_acceptor<boost::asio::ip::tcp
int CConnection::write(const void * data, unsigned size)
{
//LOG("Sending " << size << " byte(s) of data" <<std::endl);
int ret;
ret = asio::write(*socket,asio::const_buffers_1(asio::const_buffer(data,size)));
return ret;
try
{
int ret;
ret = asio::write(*socket,asio::const_buffers_1(asio::const_buffer(data,size)));
return ret;
}
catch(...)
{
//connection has been lost
connected = false;
throw;
}
}
int CConnection::read(void * data, unsigned size)
{
//LOG("Receiving " << size << " byte(s) of data" <<std::endl);
int ret = asio::read(*socket,asio::mutable_buffers_1(asio::mutable_buffer(data,size)));
return ret;
try
{
int ret = asio::read(*socket,asio::mutable_buffers_1(asio::mutable_buffer(data,size)));
return ret;
}
catch(...)
{
//connection has been lost
connected = false;
throw;
}
}
CConnection::~CConnection(void)
{
close();
delete io_service;
delete wmx;
delete rmx;
delete io_service;
delete wmx;
delete rmx;
}
template<class T>
@@ -205,6 +223,11 @@ void CConnection::setGS( CGameState *state )
gs = state;
}
bool CConnection::isOpen() const
{
return socket && connected;
}
CSaveFile::CSaveFile( const std::string &fname )
:sfile(new std::ofstream(fname.c_str(),std::ios::binary))
{