From 728e422e724ba9463bad20fdad0f80192331374a Mon Sep 17 00:00:00 2001 From: Boondorl Date: Wed, 30 Oct 2024 18:59:25 -0400 Subject: [PATCH 1/2] Added net id functions for ACS Includes net id getter and activator setter functionality. Essentially acts as a pseudo pointer system for Actors within ACS. --- src/g_levellocals.h | 17 +++++++++++++++++ src/playsim/p_acs.cpp | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/g_levellocals.h b/src/g_levellocals.h index cf63f81b2da..86476d1a757 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -316,6 +316,23 @@ struct FLevelLocals { return tid == 0 ? defactor : GetActorIterator(tid).Next(); } + AActor* SelectActorFromTID(int tid, size_t index, AActor *defactor) + { + if (tid == 0) + return defactor; + + AActor* actor = nullptr; + size_t cur = 0u; + auto it = GetActorIterator(tid); + while ((actor = it.Next()) != nullptr) + { + if (cur == index) + return actor; + ++cur; + } + + return nullptr; + } bool SectorHasTags(sector_t *sector) { diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index d05f5dae3b5..89aee643d2d 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -4806,6 +4806,8 @@ enum EACSFunctions ACSF_GetSectorHealth, ACSF_GetLineHealth, ACSF_SetSubtitleNumber, + ACSF_GetNetID, + ACSF_SetActivatorByNetID, // Eternity's ACSF_GetLineX = 300, @@ -5380,6 +5382,13 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args, int & actor = Level->SingleActorFromTID(args[0], activator); return actor != NULL? DoubleToACS(actor->Vel.Z) : 0; + case ACSF_GetNetID: + MIN_ARG_COUNT(2); + actor = Level->SelectActorFromTID(args[0], args[1], activator); + if (argCount > 2) + actor = COPY_AAPTREX(Level, actor, args[2]); + return actor != nullptr ? actor->GetNetworkID() : NetworkEntityManager::WorldNetID; + case ACSF_SetPointer: MIN_ARG_COUNT(2); if (activator) @@ -5431,6 +5440,18 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args, int & } return 0; + case ACSF_SetActivatorByNetID: + MIN_ARG_COUNT(1); + actor = dyn_cast(NetworkEntityManager::GetNetworkEntity(args[0])); + if (argCount > 1) + actor = COPY_AAPTREX(Level, actor, args[1]); + if (actor != nullptr) + { + activator = actor; + return 1; + } + return 0; + case ACSF_GetActorViewHeight: MIN_ARG_COUNT(1); actor = Level->SingleActorFromTID(args[0], activator); From 4435e8325c9790ec727b9d65fc5eca7f1770c46d Mon Sep 17 00:00:00 2001 From: Boondorl Date: Thu, 31 Oct 2024 13:42:52 -0400 Subject: [PATCH 2/2] Moved Actor TID selector out of header --- src/g_level.cpp | 18 ++++++++++++++++++ src/g_levellocals.h | 18 +----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index 1278494b245..d82c6835809 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2400,6 +2400,24 @@ void FLevelLocals::ApplyCompatibility2() i_compatflags2 = GetCompatibility2(compatflags2) | ii_compatflags2; } +AActor* FLevelLocals::SelectActorFromTID(int tid, size_t index, AActor* defactor) +{ + if (tid == 0) + return defactor; + + AActor* actor = nullptr; + size_t cur = 0u; + auto it = GetActorIterator(tid); + while ((actor = it.Next()) != nullptr) + { + if (cur == index) + return actor; + ++cur; + } + + return nullptr; +} + //========================================================================== // IsPointInMap // diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 86476d1a757..bb975e0eb4c 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -149,6 +149,7 @@ struct FLevelLocals int GetCompatibility2(int mask); void ApplyCompatibility(); void ApplyCompatibility2(); + AActor* SelectActorFromTID(int tid, size_t index, AActor* defactor); void Init(); @@ -316,23 +317,6 @@ struct FLevelLocals { return tid == 0 ? defactor : GetActorIterator(tid).Next(); } - AActor* SelectActorFromTID(int tid, size_t index, AActor *defactor) - { - if (tid == 0) - return defactor; - - AActor* actor = nullptr; - size_t cur = 0u; - auto it = GetActorIterator(tid); - while ((actor = it.Next()) != nullptr) - { - if (cur == index) - return actor; - ++cur; - } - - return nullptr; - } bool SectorHasTags(sector_t *sector) {