Skip to content

Commit 97d270d

Browse files
committed
Fix #2971: Revert "Allow multiple ignored elements to be passed to processLineOfSight (#2032)"
This reverts commit 076c7fe.
1 parent 57d5be3 commit 97d270d

File tree

3 files changed

+16
-52
lines changed

3 files changed

+16
-52
lines changed

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6311,32 +6311,20 @@ bool CStaticFunctionDefinitions::SetTime(unsigned char ucHour, unsigned char ucM
63116311
}
63126312

63136313
bool CStaticFunctionDefinitions::ProcessLineOfSight(const CVector& vecStart, const CVector& vecEnd, bool& bCollision, CColPoint** pColPoint,
6314-
CClientEntity** pColEntity, const SLineOfSightFlags& flags, std::vector<CClientEntity*> vecIgnoredElements,
6314+
CClientEntity** pColEntity, const SLineOfSightFlags& flags, CEntity* pIgnoredEntity,
63156315
SLineOfSightBuildingResult* pBuildingResult)
63166316
{
63176317
assert(pColPoint);
63186318
assert(pColEntity);
63196319

6320-
vecIgnoredElements.erase(std::remove_if(vecIgnoredElements.begin(), vecIgnoredElements.end(),
6321-
[](CClientEntity* pIgnoredElement) {
6322-
// Remove entities that already have their colision disabled.
6323-
// This prevents us from re-enabling them.
6324-
if (!CStaticFunctionDefinitions::GetElementCollisionsEnabled(*pIgnoredElement))
6325-
return true;
6326-
6327-
// Otherwise disable collision and keep it in the array
6328-
CStaticFunctionDefinitions::SetElementCollisionsEnabled(*pIgnoredElement, false);
6329-
6330-
return false;
6331-
}),
6332-
vecIgnoredElements.end());
6320+
if (pIgnoredEntity)
6321+
g_pGame->GetWorld()->IgnoreEntity(pIgnoredEntity);
63336322

63346323
CEntity* pColGameEntity = 0;
63356324
bCollision = g_pGame->GetWorld()->ProcessLineOfSight(&vecStart, &vecEnd, pColPoint, &pColGameEntity, flags, pBuildingResult);
63366325

6337-
// Re-enable collisions
6338-
for (CClientEntity* pIgnoredElement : vecIgnoredElements)
6339-
CStaticFunctionDefinitions::SetElementCollisionsEnabled(*pIgnoredElement, true);
6326+
if (pIgnoredEntity)
6327+
g_pGame->GetWorld()->IgnoreEntity(NULL);
63406328

63416329
CPools* pPools = g_pGame->GetPools();
63426330
*pColEntity = pColGameEntity ? pPools->GetClientEntity((DWORD*)pColGameEntity->GetInterface()) : nullptr;

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ class CStaticFunctionDefinitions
560560
// World functions
561561
static bool GetTime(unsigned char& ucHour, unsigned char& ucMin);
562562
static bool ProcessLineOfSight(const CVector& vecStart, const CVector& vecEnd, bool& bCollision, CColPoint** pColPoint, CClientEntity** pColEntity,
563-
const SLineOfSightFlags& flags = SLineOfSightFlags(), std::vector<CClientEntity*> vecIgnoredElements = {},
563+
const SLineOfSightFlags& flags = SLineOfSightFlags(), CEntity* pIgnoredEntity = NULL,
564564
SLineOfSightBuildingResult* pBuildingResult = NULL);
565565
static bool IsLineOfSightClear(const CVector& vecStart, const CVector& vecEnd, bool& bIsClear, const SLineOfSightFlags& flags = SLineOfSightFlags(),
566566
CEntity* pIgnoredEntity = NULL);

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -232,23 +232,13 @@ int CLuaWorldDefs::ProcessLineOfSight(lua_State* luaVM)
232232
// bool float float float element float float float int int int processLineOfSight ( float startX, float startY, float startZ, float endX, float endY,
233233
// float endZ,
234234
// [ bool checkBuildings = true, bool checkVehicles = true, bool checkPlayers = true, bool checkObjects = true, bool checkDummies = true,
235-
// bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, element ignoredElement = nil [,
236-
// element ignoredElement2,
237-
// element ignoredElement3,
238-
// ... etc
239-
// ], bool returnBuildingInfo = false, bCheckCarTires = false ] )
240-
241-
// bool float float float element float float float int int int processLineOfSight ( float startX, float startY, float startZ, float endX, float endY,
242-
// float endZ,
243-
// [ bool checkBuildings = true, bool checkVehicles = true, bool checkPlayers = true, bool checkObjects = true, bool checkDummies = true,
244-
// bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, table ignoredElements = nil,
245-
// bool returnBuildingInfo = false, bCheckCarTires = false ] )
246-
247-
CVector vecStart;
248-
CVector vecEnd;
249-
SLineOfSightFlags flags;
250-
std::vector<CClientEntity*> vecIgnoredElements;
251-
bool bIncludeBuildingInfo;
235+
// bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, element ignoredElement = nil, bool
236+
// returnBuildingInfo = false, bCheckCarTires = false ] )
237+
CVector vecStart;
238+
CVector vecEnd;
239+
SLineOfSightFlags flags;
240+
CClientEntity* pIgnoredElement;
241+
bool bIncludeBuildingInfo;
252242

253243
CScriptArgReader argStream(luaVM);
254244
argStream.ReadVector3D(vecStart);
@@ -261,32 +251,18 @@ int CLuaWorldDefs::ProcessLineOfSight(lua_State* luaVM)
261251
argStream.ReadBool(flags.bSeeThroughStuff, false);
262252
argStream.ReadBool(flags.bIgnoreSomeObjectsForCamera, false);
263253
argStream.ReadBool(flags.bShootThroughStuff, false);
264-
265-
if (argStream.NextIsTable()) // Is the next value a table? Read it as a user data table (will error if table contains invalid type)
266-
{
267-
argStream.ReadUserDataTable(vecIgnoredElements);
268-
}
269-
else
270-
{
271-
CClientEntity* pIgnoredElement;
272-
argStream.ReadUserData(pIgnoredElement, NULL);
273-
274-
if (pIgnoredElement != NULL)
275-
{
276-
vecIgnoredElements.push_back(pIgnoredElement);
277-
}
278-
}
279-
254+
argStream.ReadUserData(pIgnoredElement, NULL);
280255
argStream.ReadBool(bIncludeBuildingInfo, false);
281256
argStream.ReadBool(flags.bCheckCarTires, false);
282257

283258
if (!argStream.HasErrors())
284259
{
260+
CEntity* pIgnoredEntity = pIgnoredElement ? pIgnoredElement->GetGameEntity() : NULL;
285261
CColPoint* pColPoint = NULL;
286262
CClientEntity* pColEntity = NULL;
287263
bool bCollision;
288264
SLineOfSightBuildingResult buildingResult;
289-
if (CStaticFunctionDefinitions::ProcessLineOfSight(vecStart, vecEnd, bCollision, &pColPoint, &pColEntity, flags, vecIgnoredElements,
265+
if (CStaticFunctionDefinitions::ProcessLineOfSight(vecStart, vecEnd, bCollision, &pColPoint, &pColEntity, flags, pIgnoredEntity,
290266
bIncludeBuildingInfo ? &buildingResult : NULL))
291267
{
292268
// Got a collision?

0 commit comments

Comments
 (0)