Skip to content

Commit db368c5

Browse files
committed
Syntax update
1 parent c230fa8 commit db368c5

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

Client/game_sa/CWorldSA.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,6 @@ bool CWorldSA::ResetSurfaceInfo(short sSurfaceID)
7777
return false;
7878
}
7979

80-
CEntity* CWorldSA::TestSphereAgainstWorld(const CVector& sphereCenter, float radius, CEntity* ignoredEntity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool cameraIgnore, STestSphereAgainstWorldResult& result)
81-
{
82-
auto entity = ((CEntitySAInterface*(__cdecl*)(CVector, float, CEntitySAInterface*, bool, bool, bool, bool, bool, bool))FUNC_CWorld_TestSphereAgainstWorld)(sphereCenter, radius, ignoredEntity ? ignoredEntity->GetInterface() : nullptr, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, cameraIgnore);
83-
if (!entity)
84-
return nullptr;
85-
86-
result.collisionDetected = true;
87-
result.hitPosition = entity->Placeable.matrix->vPos;
88-
result.modelID = entity->m_nModelIndex;
89-
result.type = entity->nType;
90-
result.lodID = entity->m_pLod ? entity->m_pLod->m_nModelIndex : 0;
91-
92-
return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(entity));
93-
}
94-
9580
void HOOK_FallenPeds();
9681
void HOOK_FallenCars();
9782

@@ -543,6 +528,23 @@ bool CWorldSA::ProcessLineOfSight(const CVector* vecStart, const CVector* vecEnd
543528
return bReturn;
544529
}
545530

531+
CEntity* CWorldSA::TestSphereAgainstWorld(const CVector& sphereCenter, float radius, CEntity* ignoredEntity, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool cameraIgnore, STestSphereAgainstWorldResult& result)
532+
{
533+
auto entity = ((CEntitySAInterface*(__cdecl*)(CVector, float, CEntitySAInterface*, bool, bool, bool, bool, bool, bool))FUNC_CWorld_TestSphereAgainstWorld)(sphereCenter, radius, ignoredEntity ? ignoredEntity->GetInterface() : nullptr, checkBuildings, checkVehicles, checkPeds, checkObjects, checkDummies, cameraIgnore);
534+
if (!entity)
535+
return nullptr;
536+
537+
result.collisionDetected = true;
538+
result.modelID = entity->m_nModelIndex;
539+
result.entityPosition = entity->Placeable.matrix->vPos;
540+
ConvertMatrixToEulerAngles(*entity->Placeable.matrix, result.entityRotation.fX, result.entityRotation.fY, result.entityRotation.fZ);
541+
result.entityRotation = -result.entityRotation;
542+
result.lodID = entity->m_pLod ? entity->m_pLod->m_nModelIndex : 0;
543+
result.type = entity->nType;
544+
545+
return pGame->GetPools()->GetEntity(reinterpret_cast<DWORD*>(entity));
546+
}
547+
546548
void CWorldSA::IgnoreEntity(CEntity* pEntity)
547549
{
548550
CEntitySA* pEntitySA = dynamic_cast<CEntitySA*>(pEntity);

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,16 @@ ADD_ENUM(PreloadAreaOption::COLLISIONS, "collisions")
910910
ADD_ENUM(PreloadAreaOption::ALL, "all")
911911
IMPLEMENT_ENUM_CLASS_END("preload-area-option")
912912

913+
IMPLEMENT_ENUM_BEGIN(eEntityType)
914+
ADD_ENUM(ENTITY_TYPE_NOTHING, "unknown")
915+
ADD_ENUM(ENTITY_TYPE_BUILDING, "building")
916+
ADD_ENUM(ENTITY_TYPE_VEHICLE, "vehicle")
917+
ADD_ENUM(ENTITY_TYPE_PED, "ped")
918+
ADD_ENUM(ENTITY_TYPE_OBJECT, "object")
919+
ADD_ENUM(ENTITY_TYPE_DUMMY, "dummy")
920+
ADD_ENUM(ENTITY_TYPE_NOTINPOOLS, "unknown")
921+
IMPLEMENT_ENUM_END("entity-type")
922+
913923
//
914924
// CResource from userdata
915925
//

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ DECLARE_ENUM(ePools);
8888
DECLARE_ENUM(eWorldProperty);
8989
DECLARE_ENUM_CLASS(eModelLoadState);
9090
DECLARE_ENUM_CLASS(PreloadAreaOption);
91+
DECLARE_ENUM(eEntityType);
9192

9293
class CRemoteCall;
9394

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,7 @@ void CLuaWorldDefs::ResetWorldProperties(std::optional<bool> resetSpecialWorldPr
22802280
g_pClientGame->ResetWorldProperties(ResetWorldPropsInfo{resetSpecialWorldProperties.value_or(true), resetWorldProperties.value_or(true), resetWeatherProperties.value_or(true), resetLODs.value_or(true), resetSounds.value_or(true)});
22812281
}
22822282

2283-
CLuaMultiReturn<bool, CClientEntity*, float, float, float, int, int, int> CLuaWorldDefs::TestSphereAgainstWorld(CVector sphereCenter, float radius, std::optional<CClientEntity*> ignoredEntity, std::optional<bool> checkBuildings, std::optional<bool> checkVehicles, std::optional<bool> checkPeds, std::optional<bool> checkObjects, std::optional<bool> checkDummies, std::optional<bool> cameraIgnore)
2283+
CLuaMultiReturn<bool, CClientEntity*, int, float, float, float, float, float, float, int, eEntityType> CLuaWorldDefs::TestSphereAgainstWorld(CVector sphereCenter, float radius, std::optional<CClientEntity*> ignoredEntity, std::optional<bool> checkBuildings, std::optional<bool> checkVehicles, std::optional<bool> checkPeds, std::optional<bool> checkObjects, std::optional<bool> checkDummies, std::optional<bool> cameraIgnore)
22842284
{
22852285
STestSphereAgainstWorldResult result;
22862286
CClientEntity* collidedEntity = nullptr;
@@ -2289,5 +2289,5 @@ CLuaMultiReturn<bool, CClientEntity*, float, float, float, int, int, int> CLuaWo
22892289
if (entity)
22902290
collidedEntity = reinterpret_cast<CClientEntity*>(entity->GetStoredPointer());
22912291

2292-
return {result.collisionDetected, collidedEntity, result.hitPosition.fX, result.hitPosition.fY, result.hitPosition.fZ, result.modelID, result.lodID, result.type};
2292+
return {result.collisionDetected, collidedEntity, result.modelID, result.entityPosition.fX, result.entityPosition.fY, result.entityPosition.fZ, ConvertRadiansToDegrees(result.entityRotation.fX), ConvertRadiansToDegrees(result.entityRotation.fY), ConvertRadiansToDegrees(result.entityRotation.fZ), result.lodID, static_cast<eEntityType>(result.type)};
22932293
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class CLuaWorldDefs : public CLuaDefs
141141

142142
static void ResetWorldProperties(std::optional<bool> resetSpecialWorldProperties, std::optional<bool> resetWorldProperties, std::optional<bool> resetWeatherProperties, std::optional<bool> resetLODs, std::optional<bool> resetSounds) noexcept;
143143

144-
static CLuaMultiReturn<bool, CClientEntity*, float, float, float, int, int, int> TestSphereAgainstWorld(CVector sphereCenter, float radius, std::optional<CClientEntity*> ignoredEntity, std::optional<bool> checkBuildings, std::optional<bool> checkVehicles, std::optional<bool> checkPeds, std::optional<bool> checkObjects, std::optional<bool> checkDummies, std::optional<bool> cameraIgnore);
144+
static CLuaMultiReturn<bool, CClientEntity*, int, float, float, float, float, float, float, int, eEntityType> TestSphereAgainstWorld(CVector sphereCenter, float radius, std::optional<CClientEntity*> ignoredEntity, std::optional<bool> checkBuildings, std::optional<bool> checkVehicles, std::optional<bool> checkPeds, std::optional<bool> checkObjects, std::optional<bool> checkDummies, std::optional<bool> cameraIgnore);
145145

146146
};
147147

Client/sdk/game/CWorld.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ struct SProcessLineOfSightMaterialInfoResult {
6464
struct STestSphereAgainstWorldResult
6565
{
6666
bool collisionDetected{false};
67-
CVector hitPosition{};
6867
std::uint32_t modelID{0};
68+
CVector entityPosition{};
69+
CVector entityRotation{};
6970
std::uint32_t lodID{0};
7071
std::uint8_t type{0};
7172
};

0 commit comments

Comments
 (0)