From 140adc8f5046fe6b59c8a3e0aa3e00155c7fbf41 Mon Sep 17 00:00:00 2001 From: vl Date: Fri, 28 May 2010 17:17:12 +0200 Subject: [PATCH] Fixed: #847 downcast the groupid in 32b on 64b platform. --- .../server/src/ai_service/ai_outpost.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/code/ryzom/server/src/ai_service/ai_outpost.cpp b/code/ryzom/server/src/ai_service/ai_outpost.cpp index 5c6f3af6b..fb2090617 100644 --- a/code/ryzom/server/src/ai_service/ai_outpost.cpp +++ b/code/ryzom/server/src/ai_service/ai_outpost.cpp @@ -894,7 +894,9 @@ void COutpost::createSquad(CGroupDesc const* groupDesc, COu COutpostSquadCreatedMsg params; params.Outpost = this->getAlias(); params.CreateOrder = createOrder; - params.GroupId = reinterpret_cast(grp); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //params.GroupId = reinterpret_cast(grp); + params.GroupId = (uint32)(size_t)(void*)grp; sendOutpostMessage("OUTPOST_SQUAD_CREATED", params); } @@ -911,7 +913,9 @@ void COutpost::spawnSquad(uint32 groupId) { CGroup* group = *itGroup; CGroupNpc* groupNpc = static_cast(group); - uint32 thisGroupId = reinterpret_cast(groupNpc); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //uint32 thisGroupId = reinterpret_cast(groupNpc); + uint32 thisGroupId = (uint32)(size_t)(void*)groupNpc; if (groupId==thisGroupId) { group->getSpawnObj()->spawnBots(); @@ -932,7 +936,9 @@ void COutpost::spawnSquad(uint32 groupId) { CGroup* group = *itGroup; CGroupNpc* groupNpc = static_cast(group); - uint32 thisGroupId = reinterpret_cast(groupNpc); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //uint32 thisGroupId = reinterpret_cast(groupNpc); + uint32 thisGroupId = (uint32)(size_t)(void*)groupNpc; OUTPOST_WRN("- 0x%08x", thisGroupId); } } @@ -948,7 +954,9 @@ void COutpost::despawnSquad(uint32 groupId) { CGroup* group = *itGroup; CGroupNpc* groupNpc = static_cast(group); - uint32 thisGroupId = reinterpret_cast(groupNpc); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //uint32 thisGroupId = reinterpret_cast(groupNpc); + uint32 thisGroupId = (uint32)(size_t)(void*)groupNpc; if (groupId==thisGroupId) { group->despawnBots(); @@ -973,7 +981,9 @@ void COutpost::deleteSquad(uint32 groupId) { CGroup* group = *itGroup; CGroupNpc* groupNpc = static_cast(group); - uint32 thisGroupId = reinterpret_cast(groupNpc); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //uint32 thisGroupId = reinterpret_cast(groupNpc); + uint32 thisGroupId = (uint32)(size_t)(void*)groupNpc; if (groupId==thisGroupId) { manager->groups().removeChildByIndex(group->getChildIndex()); @@ -988,7 +998,9 @@ void COutpost::deleteSquad(uint32 groupId) void COutpost::sendOutpostSquadStatus(CGroupNpc* group) { uint32 alias = this->getAlias(); - uint32 groupId = reinterpret_cast(group); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //uint32 groupId = reinterpret_cast(group); + uint32 groupId = (uint32)(size_t)(void*)group; bool groupAlive = false; bool leaderAlive = group->getSquadLeader()!=NULL; uint32 botCount = 0; @@ -1011,7 +1023,9 @@ void COutpost::sendOutpostSquadStatus(CGroupNpc* group) void COutpost::squadLeaderDied(CGroupNpc* group) { uint32 alias = this->getAlias(); - uint32 groupId = reinterpret_cast(group); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //uint32 groupId = reinterpret_cast(group); + uint32 groupId = (uint32)(size_t)(void*)group; NLNET::CMessage msgout("OUTPOST_SQUAD_LEADER_DIED"); msgout.serial(alias); msgout.serial(groupId); @@ -1021,7 +1035,9 @@ void COutpost::squadLeaderDied(CGroupNpc* group) void COutpost::squadDied(CGroupNpc* group) { uint32 alias = this->getAlias(); - uint32 groupId = reinterpret_cast(group); + // Bug #847: Just downcast the pointer to make the groupId, the collision in 64b is negligible + //uint32 groupId = reinterpret_cast(group); + uint32 groupId = (uint32)(size_t)(void*)group; NLNET::CMessage msgout("OUTPOST_SQUAD_DIED"); msgout.serial(alias); msgout.serial(groupId);