Skip to content

Commit

Permalink
Fix #4890 and Fix #4888 again
Browse files Browse the repository at this point in the history
Apparently there are projectiles which start with deleteMe=true and hence
got the ProjectileDestroyed event before the ProectileCreated
  • Loading branch information
ashdnazg committed Jul 7, 2015
1 parent 6c36d0b commit 8b50289
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
5 changes: 3 additions & 2 deletions rts/Sim/Projectiles/Projectile.cpp
Expand Up @@ -24,6 +24,7 @@ CR_REG_METADATA(CProjectile,
CR_MEMBER(checkCol),
CR_MEMBER(ignoreWater),
CR_MEMBER(deleteMe),
CR_MEMBER(callEvent),

CR_MEMBER(castShadow),
CR_MEMBER(drawSorted),
Expand Down Expand Up @@ -66,7 +67,7 @@ CProjectile::CProjectile()
, checkCol(true)
, ignoreWater(false)
, deleteMe(false)

, callEvent(true)
, castShadow(false)
, drawSorted(true)

Expand Down Expand Up @@ -102,7 +103,7 @@ CProjectile::CProjectile(
, checkCol(true)
, ignoreWater(false)
, deleteMe(false)

, callEvent(true)
, castShadow(false)
, drawSorted(true)

Expand Down
3 changes: 2 additions & 1 deletion rts/Sim/Projectiles/Projectile.h
Expand Up @@ -108,7 +108,8 @@ class CProjectile: public CExpGenSpawnable
bool checkCol;
bool ignoreWater;
bool deleteMe;

bool callEvent; //do we need to call the ProjectileCreated event

bool castShadow;
bool drawSorted;

Expand Down
18 changes: 13 additions & 5 deletions rts/Sim/Projectiles/ProjectileHandler.cpp
Expand Up @@ -194,7 +194,18 @@ void CProjectileHandler::UpdateProjectileContainer(ProjectileContainer& pc, bool
assert(p);
assert(p->synced == synced);
assert(p->synced == !!(p->GetClass()->binder->flags & creg::CF_Synced));

if (p->callEvent) {
#if UNSYNCED_PROJ_NOEVENT
if (synced) {
eventHandler.ProjectileCreated(p, p->GetAllyteamID());
} else {
eventHandler.UnsyncedProjectileCreated(p);
}
#else
eventHandler.ProjectileCreated(p, p->GetAllyteamID());
#endif
p->callEvent = false;
}
if (!p->deleteMe) {
++pci;
continue;
Expand Down Expand Up @@ -303,7 +314,7 @@ void CProjectileHandler::AddProjectile(CProjectile* p)
{
// already initialized?
assert(p->id < 0);

assert(p->callEvent);
std::deque<int>* freeIDs = NULL;
ProjectileMap* proIDs = NULL;

Expand All @@ -315,7 +326,6 @@ void CProjectileHandler::AddProjectile(CProjectile* p)
} else {
unsyncedProjectiles.push_back(p);
#if UNSYNCED_PROJ_NOEVENT
eventHandler.UnsyncedProjectileCreated(p);
return;
#endif
freeIDs = &freeUnsyncedIDs;
Expand Down Expand Up @@ -351,8 +361,6 @@ void CProjectileHandler::AddProjectile(CProjectile* p)
tracefile << ", type: " << p->GetProjectileType() << " pos: <" << p->pos.x << ", " << p->pos.y << ", " << p->pos.z << ">\n";
#endif
}

eventHandler.ProjectileCreated(p, p->GetAllyteamID());
}


Expand Down

0 comments on commit 8b50289

Please sign in to comment.