mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-27 22:47:48 +02:00
Fixed #1679.
This commit is contained in:
parent
b8b809bd50
commit
f5d945d1b2
@ -238,11 +238,24 @@ void CCallback::setFormation(const CGHeroInstance * hero, bool tight)
|
|||||||
|
|
||||||
void CCallback::setSelection(const CArmedInstance * obj)
|
void CCallback::setSelection(const CArmedInstance * obj)
|
||||||
{
|
{
|
||||||
|
if(!player || obj->getOwner() != *player)
|
||||||
|
{
|
||||||
|
logGlobal->errorStream() << boost::format("Cannot set selection to the object that is not owned. Object owner is %s, callback player %s") % obj->getOwner() % player;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetSelection ss;
|
SetSelection ss;
|
||||||
ss.player = *player;
|
ss.player = *player;
|
||||||
ss.id = obj->id;
|
ss.id = obj->id;
|
||||||
sendRequest(&(CPackForClient&)ss);
|
sendRequest(&(CPackForClient&)ss);
|
||||||
|
|
||||||
|
if(obj->getOwner() != *player)
|
||||||
|
{
|
||||||
|
// Cf. bug #1679 http://bugs.vcmi.eu/view.php?id=1679
|
||||||
|
logGlobal->warnStream() << "The selection request became invalid because of event that occurred after it was made. Object owner is now " << obj->getOwner();
|
||||||
|
throw std::runtime_error("setSelection not allowed");
|
||||||
|
}
|
||||||
|
|
||||||
if(obj->ID == Obj::HERO)
|
if(obj->ID == Obj::HERO)
|
||||||
{
|
{
|
||||||
if(cl->pathInfo->hero != obj) //calculate new paths only if we selected a different hero
|
if(cl->pathInfo->hero != obj) //calculate new paths only if we selected a different hero
|
||||||
|
Loading…
x
Reference in New Issue
Block a user