mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed problems with accessing shared memory sometimes occurring after application has previously crashed.
This commit is contained in:
parent
cc79f1e2bd
commit
d037bec1be
@ -90,10 +90,11 @@ void CClient::init()
|
||||
gs = NULL;
|
||||
cb = NULL;
|
||||
terminate = false;
|
||||
boost::interprocess::shared_memory_object::remove("vcmi_memory"); //if the application has previously crashed, the memory may not have been removed. to avoid problems - try to destroy it
|
||||
try
|
||||
{
|
||||
shared = new SharedMem();
|
||||
} HANDLE_EXCEPTION
|
||||
} HANDLE_EXCEPTIONC(tlog1 << "Cannot open interprocess memory: ";)
|
||||
}
|
||||
|
||||
CClient::CClient(void)
|
||||
|
4
int3.h
4
int3.h
@ -78,7 +78,7 @@ public:
|
||||
TCreature id = slots[preferable].first;
|
||||
for(TSlots::const_iterator j=slots.begin(); j!=slots.end(); ++j)
|
||||
{
|
||||
if(id == j->second.first)
|
||||
if(id == j->second.first && j->first != preferable)
|
||||
{
|
||||
out.first = preferable;
|
||||
out.second = j->first;
|
||||
@ -91,7 +91,7 @@ public:
|
||||
{
|
||||
for(TSlots::const_iterator j=slots.begin(); j!=slots.end(); ++j)
|
||||
{
|
||||
if(i->second.first == j->second.first)
|
||||
if(i->second.first == j->second.first && i->first != j->first)
|
||||
{
|
||||
out.first = i->first;
|
||||
out.second = j->first;
|
||||
|
@ -2011,6 +2011,7 @@ bool CGameState::getPath(int3 src, int3 dest, const CGHeroInstance * hero, CPath
|
||||
void CGameState::calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src, int movement)
|
||||
{
|
||||
assert(hero);
|
||||
boost::shared_lock<boost::shared_mutex> lock(*mx);
|
||||
if(src.x < 0)
|
||||
src = hero->getPosition(false);
|
||||
if(movement < 0)
|
||||
|
@ -2217,7 +2217,7 @@ bool CGameHandler::upgradeCreature( ui32 objid, ui8 pos, ui32 upgID )
|
||||
bool CGameHandler::garrisonSwap( si32 tid )
|
||||
{
|
||||
CGTownInstance *town = gs->getTown(tid);
|
||||
if(!town->garrisonHero && town->visitingHero) //visiting => garrison, merge armies
|
||||
if(!town->garrisonHero && town->visitingHero) //visiting => garrison, merge armies: town army => hero army
|
||||
{
|
||||
CCreatureSet csn = town->visitingHero->army, cso = town->army;
|
||||
while(!cso.slots.empty())//while there are unmoved creatures
|
||||
|
Loading…
Reference in New Issue
Block a user