1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Really fixed the evil bug.

This commit is contained in:
Michał W. Urbańczyk 2009-01-30 22:23:13 +00:00
parent 8868105fac
commit f28c76984c
3 changed files with 10 additions and 5 deletions

View File

@ -34,7 +34,10 @@ void CClient::init()
serv = NULL;
gs = NULL;
cb = NULL;
shared = new SharedMem();
try
{
shared = new SharedMem();
} HANDLE_EXCEPTION
}
CClient::CClient(void)

View File

@ -26,18 +26,19 @@ struct ServerReady
struct SharedMem
{
boost::interprocess::shared_memory_object smo;
boost::interprocess::mapped_region mr;
boost::interprocess::mapped_region *mr;
ServerReady *sr;
SharedMem()
:smo(boost::interprocess::open_or_create,"vcmi_memory",boost::interprocess::read_write),
mr(smo,boost::interprocess::read_write)
:smo(boost::interprocess::open_or_create,"vcmi_memory",boost::interprocess::read_write)
{
smo.truncate(sizeof(ServerReady));
sr = new(mr.get_address())ServerReady();
mr = new boost::interprocess::mapped_region(smo,boost::interprocess::read_write);
sr = new(mr->get_address())ServerReady();
};
~SharedMem()
{
delete mr;
boost::interprocess::shared_memory_object::remove("vcmi_memory");
}
};

View File

@ -109,6 +109,7 @@ void CVCMIServer::start()
try
{
intpr::shared_memory_object smo(intpr::open_only,"vcmi_memory",intpr::read_write);
smo.truncate(sizeof(ServerReady));
mr = new intpr::mapped_region(smo,intpr::read_write);
sr = (ServerReady*)mr->get_address();
}