Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added net id functions for ACS #2793

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/g_levellocals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
21 changes: 21 additions & 0 deletions src/playsim/p_acs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4806,6 +4806,8 @@ enum EACSFunctions
ACSF_GetSectorHealth,
ACSF_GetLineHealth,
ACSF_SetSubtitleNumber,
ACSF_GetNetID,
ACSF_SetActivatorByNetID,

// Eternity's
ACSF_GetLineX = 300,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<AActor>(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);
Expand Down