Skip to content

Commit

Permalink
Strip modified event propagation
Browse files Browse the repository at this point in the history
Revert changes to example plugin
  • Loading branch information
KitRifty committed Aug 23, 2023
1 parent 1554d71 commit 1dadaf5
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 35 deletions.
10 changes: 0 additions & 10 deletions extension/cbasenpc_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ QueryResultType CBaseNPCPluginAction:: funcName ( const INextBot *me, ##__VA_ARG

#define BEGINEVENTCALLBACKEX(funcName, typeName, ...) \
EventDesiredResult< INextBot > CBaseNPCPluginAction:: funcName (INextBot* me, ##__VA_ARGS__) { \
if (m_skipEvents) { return TryContinue(); } \
m_inEventCallback++; \
ResetPluginEventResult(); \
IPluginFunction* pCallback = m_pFactory->GetEventCallback( CBaseNPCPluginActionFactory::EventResponderCallbackType::typeName ); \
Expand Down Expand Up @@ -101,7 +100,6 @@ CBaseNPCPluginAction::CBaseNPCPluginAction(CBaseNPCPluginActionFactory* pFactory

m_bInActionCallback = false;
m_inEventCallback = 0;
m_skipEvents = false;

pFactory->OnActionCreated(this);
}
Expand Down Expand Up @@ -203,21 +201,13 @@ BEGINACTIONCALLBACK(OnResume, Action< INextBot > *interruptingAction)
ENDACTIONCALLBACK()

void CBaseNPCPluginAction::OnEnd( INextBot * me, Action< INextBot > *nextAction ) {
bool oldStarted = m_isStarted;

// Allow events in OnEnd to propagate to buried actions.
m_isStarted = true;
m_skipEvents = true; // pass over myself since I'm ending

IPluginFunction* pCallback = m_pFactory->GetCallback( CBaseNPCPluginActionFactory::CallbackType::OnEnd );
if (pCallback && pCallback->IsRunnable()) {
CBPUSHCELL(PtrToPawnAddress(this))
CBPUSHENTITY(me->GetEntity())
CBPUSHCELL(PtrToPawnAddress(nextAction))
pCallback->Execute(nullptr);
}

m_isStarted = oldStarted;
}

Action< INextBot >* CBaseNPCPluginAction::InitialContainedAction( INextBot * me )
Expand Down
1 change: 0 additions & 1 deletion extension/cbasenpc_behavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class CBaseNPCPluginAction : public Action <INextBot>

bool m_bInActionCallback;
int m_inEventCallback;
bool m_skipEvents;

public:
CBaseNPCPluginAction(CBaseNPCPluginActionFactory * pFactory);
Expand Down
10 changes: 0 additions & 10 deletions scripting/cbasenpc/actiontest/nb_test_scout/behavior/baitaction.sp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ methodmap TestScoutBotBaitAction < NextBotAction
ActionFactory.SetCallback(NextBotActionCallbackType_OnEnd, OnEnd);
ActionFactory.SetCallback(NextBotActionCallbackType_OnSuspend, OnSuspend);
ActionFactory.SetEventCallback(EventResponderType_OnInjured, OnInjured);
ActionFactory.SetEventCallback(EventResponderType_OnCommandString, OnCommandString);
}

public TestScoutBotBaitAction()
Expand Down Expand Up @@ -58,8 +57,6 @@ methodmap TestScoutBotBaitAction < NextBotAction

static int OnStart(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction prevAction)
{
actor.MyNextBotPointer().GetIntentionInterface().OnCommandString("started baiting");

for (int i = 0; i < sizeof(g_sStartSounds); i++)
{
PrecacheSound(g_sStartSounds[i]);
Expand Down Expand Up @@ -138,7 +135,6 @@ static int Update(TestScoutBotBaitAction action, TestScoutBot actor, float inter

static void OnEnd(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction nextAction)
{
actor.MyNextBotPointer().GetIntentionInterface().OnCommandString("stopped baiting");
}

static int OnSuspend(TestScoutBotBaitAction action, TestScoutBot actor, NextBotAction interruptingAction)
Expand All @@ -158,10 +154,4 @@ static int OnInjured(TestScoutBotBaitAction action,
const float damagePosition[3], int damageCustom )
{
return action.TryDone();
}

static void OnCommandString(TestScoutBotBaitAction action, TestScoutBot actor, const char[] command) {
if (strcmp(command, "started baiting") == 0 || strcmp(command, "stopped baiting") == 0) {
LogError("You shouldn't be seeing this.");
}
}
14 changes: 0 additions & 14 deletions scripting/cbasenpc/actiontest/nb_test_scout/behavior/mainaction.sp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ methodmap TestScoutBotMainAction < NextBotAction
ActionFactory.SetCallback(NextBotActionCallbackType_OnEnd, OnEnd);
ActionFactory.SetEventCallback(EventResponderType_OnInjured, OnInjured);
ActionFactory.SetEventCallback(EventResponderType_OnKilled, OnKilled);
ActionFactory.SetEventCallback(EventResponderType_OnCommandString, OnCommandString);
}

public static NextBotActionFactory GetFactory()
Expand Down Expand Up @@ -152,17 +151,4 @@ static int OnKilled(TestScoutBotMainAction action,
const float damagePosition[3], int damageCustom)
{
return action.TryChangeTo(TestScoutBotDeathAction(damagetype), RESULT_CRITICAL);
}

static void OnCommandString(TestScoutBotMainAction action, TestScoutBot actor, const char[] command) {
if (strcmp(command, "started baiting") == 0) {
if (actor.MyNextBotPointer().IsDebugging(DEBUG_BEHAVIOR)) {
PrintToChatAll("The Scout #%d: I started taunting!", actor.index);
}
}
else if (strcmp(command, "stopped baiting") == 0) {
if (actor.MyNextBotPointer().IsDebugging(DEBUG_BEHAVIOR)) {
PrintToChatAll("The Scout #%d: I stopped taunting!", actor.index);
}
}
}

0 comments on commit 1dadaf5

Please sign in to comment.