source-sdk-2013-mapbase/sp/src/game/server/eventqueue.h

95 lines
2.9 KiB
C
Raw Normal View History

2013-12-03 07:31:46 +04:00
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A global class that holds a prioritized queue of entity I/O events.
// Events can be posted with a nonzero delay, which determines how long
// they are held before being dispatched to their recipients.
//
// The queue is serviced once per server frame.
//
//=============================================================================//
#ifndef EVENTQUEUE_H
#define EVENTQUEUE_H
#ifdef _WIN32
#pragma once
#endif
#include "mempool.h"
struct EventQueuePrioritizedEvent_t
{
float m_flFireTime;
string_t m_iTarget;
string_t m_iTargetInput;
EHANDLE m_pActivator;
EHANDLE m_pCaller;
int m_iOutputID;
EHANDLE m_pEntTarget; // a pointer to the entity to target; overrides m_iTarget
variant_t m_VariantValue; // variable-type parameter
EventQueuePrioritizedEvent_t *m_pNext;
EventQueuePrioritizedEvent_t *m_pPrev;
DECLARE_SIMPLE_DATADESC();
DECLARE_FIXEDSIZE_ALLOCATOR( PrioritizedEvent_t );
};
class CEventQueue
{
public:
// pushes an event into the queue, targeting a string name (m_iName), or directly by a pointer
vscript additions and fixes: baseanimating.h baseanimating.cpp - Added CBaseAnimating::SequenceDuration (ScriptSequenceDuration) - Added CBaseAnimating::GetPlaybackRate - Added CBaseAnimating::SetPlaybackRate - Added CBaseAnimating::GetCycle - Added CBaseAnimating::SetCycle triggers.h triggers.cpp - Fixed CTriggerCamera::ScriptSetFov setting player FOV while disabled - Added CBaseTrigger::Enable - Added CBaseTrigger::Disable - Added CBaseTrigger::TouchTest - Added CBaseTrigger::IsTouching (ScriptIsTouching) vscript_server.nut vscript_server.cpp - Added CEntities::FindByClassnameWithinBox - Added ::SendToConsoleServer - Added ::CancelEntityIOEvent - Added ::GetEntityIOEventTimeLeft - Moved ScriptDispatchParticleEffect to shared code eventqueue.h cbase.h cbase.cpp - Set entity I/O con output colour - Added (CEventQueue::CancelEventsByInput) - Added (CEventQueue::RemoveEvent) - Added (CEventQueue::GetTimeLeft) baseentity.h baseentity.cpp - Added CBaseEntity::SetTransmitState - Added CBaseEntity::GetTransmitState - Added CBaseEntity::AcceptInput (ScriptAcceptInput) - Added CBaseEntity::FireOutput (ScriptFireOutput) - Added CBaseEntity::GetMaxOutputDelay - Added CBaseEntity::CancelEventsByInput - Added player_use event on InputUse - Fixed InputKill on players ivscript.h vscript_squirrel.cpp - Added IScriptVM::ArrayAppend - Fixed buffer overflow crash - Increased print buffer to 2048 from 256 - Set vscript print output colour vscript_funcs_shared.cpp - Added CNetMsgScriptHelper (CScriptGameEventListener) - Added ::ListenToGameEvent - Added ::StopListeningToGameEvent - Added ::StopListeningToAllGameEvents - Added ::FireGameEvent - Added ::FireGameEventLocal (CScriptSaveRestoreUtil) - Added ::SaveTable - Added ::RestoreTable - Added ::ClearSavedTable - Added callbacks ::OnSave, ::OnRestore (CScriptReadWriteFile) - Added ::StringToFile - Added ::FileToString - Added GlobalSys::GetCommandLine - Added GlobalSys::CommandLineCheck - Added GlobalSys::CommandLineCheckStr - Added GlobalSys::CommandLineCheckFloat - Added GlobalSys::CommandLineCheckInt - Added ::GetCPUUsage - Added ::NXPrint - Added ::Msg (ScriptMsg) - Removed misplaced condition checks - Fixed ScriptEntitiesInBox, *AtPoint, *InSphere logic_eventlistener.cpp - Removed redundant dev msg gamestringpool.cpp - Fixed string pool dump sort
2020-10-27 02:22:18 +03:00
#ifdef MAPBASE_VSCRIPT
vscript additions and fixes: baseentity_shared.cpp baseentity.cpp c_baseentity.h c_baseentity.cpp c_world.h - Fixed critical ScriptSetContextThink bugs - Added C_BaseEntity::SetContextThink (ScriptSetContextThink) - Added C_BaseEntity::SetSize - Added C_BaseEntity::SetModel - Added C_BaseEntity::Destroy baseentity.h baseentity.cpp - Removed duplicate functions ScriptSetSize and ScriptUtilRemove player.cpp - Moved player script instance registration before player_spawn event vscript_server.cpp - Added CEntities::FindByClassNearestFacing vscript_funcs_shared.cpp - Added GetFrameCount - Added IntervalPerTick vscript_singletons.cpp - Better game event descriptors for CScriptGameEventListener - Added ::effects (CEffectsScriptHelper) - Added ::Convars (CScriptConvarAccessor) vscript_shared.cpp - Fixed clientside entity printing in script VM mapbase_con_groups.h mapbase_con_groups.cpp - Improved performance by changing string comparisons to direct array access vscript_bindings_base.h vscript_bindings_base.cpp - Added CScriptKeyValues::SubKeysToTable vscript_bindings_math.cpp - Added ::SimpleSplineRemapVal - Added ::SimpleSplineRemapValClamped - Added ::Bias - Added ::Gain - Added ::SmoothCurve - Added ::SmoothCurve_Tweak - Added ::ExponentialDecay vscript_squirrel.nut - Added ::Lerp - Added ::FLerp - Added ::SimpleSpline vscript_squirrel.cpp - Added Vector::_unm - Added Vector::Set - Added Vector::Add - Added Vector::Subtract - Added Vector::Multiply - Added Vector::Divide - Added Vector::DistTo - Added Vector::DistToSqr - Added Vector::IsEqualTo - Added Vector::WithinAABox - Added Vector::FromKVString - Changed vector print syntax
2021-03-06 02:11:43 +03:00
int AddEvent( const char *target, const char *action, variant_t Value, float fireDelay, CBaseEntity *pActivator, CBaseEntity *pCaller, int outputID = 0 );
int AddEvent( CBaseEntity *target, const char *action, variant_t Value, float fireDelay, CBaseEntity *pActivator, CBaseEntity *pCaller, int outputID = 0 );
vscript additions and fixes: baseanimating.h baseanimating.cpp - Added CBaseAnimating::SequenceDuration (ScriptSequenceDuration) - Added CBaseAnimating::GetPlaybackRate - Added CBaseAnimating::SetPlaybackRate - Added CBaseAnimating::GetCycle - Added CBaseAnimating::SetCycle triggers.h triggers.cpp - Fixed CTriggerCamera::ScriptSetFov setting player FOV while disabled - Added CBaseTrigger::Enable - Added CBaseTrigger::Disable - Added CBaseTrigger::TouchTest - Added CBaseTrigger::IsTouching (ScriptIsTouching) vscript_server.nut vscript_server.cpp - Added CEntities::FindByClassnameWithinBox - Added ::SendToConsoleServer - Added ::CancelEntityIOEvent - Added ::GetEntityIOEventTimeLeft - Moved ScriptDispatchParticleEffect to shared code eventqueue.h cbase.h cbase.cpp - Set entity I/O con output colour - Added (CEventQueue::CancelEventsByInput) - Added (CEventQueue::RemoveEvent) - Added (CEventQueue::GetTimeLeft) baseentity.h baseentity.cpp - Added CBaseEntity::SetTransmitState - Added CBaseEntity::GetTransmitState - Added CBaseEntity::AcceptInput (ScriptAcceptInput) - Added CBaseEntity::FireOutput (ScriptFireOutput) - Added CBaseEntity::GetMaxOutputDelay - Added CBaseEntity::CancelEventsByInput - Added player_use event on InputUse - Fixed InputKill on players ivscript.h vscript_squirrel.cpp - Added IScriptVM::ArrayAppend - Fixed buffer overflow crash - Increased print buffer to 2048 from 256 - Set vscript print output colour vscript_funcs_shared.cpp - Added CNetMsgScriptHelper (CScriptGameEventListener) - Added ::ListenToGameEvent - Added ::StopListeningToGameEvent - Added ::StopListeningToAllGameEvents - Added ::FireGameEvent - Added ::FireGameEventLocal (CScriptSaveRestoreUtil) - Added ::SaveTable - Added ::RestoreTable - Added ::ClearSavedTable - Added callbacks ::OnSave, ::OnRestore (CScriptReadWriteFile) - Added ::StringToFile - Added ::FileToString - Added GlobalSys::GetCommandLine - Added GlobalSys::CommandLineCheck - Added GlobalSys::CommandLineCheckStr - Added GlobalSys::CommandLineCheckFloat - Added GlobalSys::CommandLineCheckInt - Added ::GetCPUUsage - Added ::NXPrint - Added ::Msg (ScriptMsg) - Removed misplaced condition checks - Fixed ScriptEntitiesInBox, *AtPoint, *InSphere logic_eventlistener.cpp - Removed redundant dev msg gamestringpool.cpp - Fixed string pool dump sort
2020-10-27 02:22:18 +03:00
#else
void AddEvent( const char *target, const char *action, variant_t Value, float fireDelay, CBaseEntity *pActivator, CBaseEntity *pCaller, int outputID = 0 );
void AddEvent( CBaseEntity *target, const char *action, variant_t Value, float fireDelay, CBaseEntity *pActivator, CBaseEntity *pCaller, int outputID = 0 );
#endif
2013-12-03 07:31:46 +04:00
void AddEvent( CBaseEntity *target, const char *action, float fireDelay, CBaseEntity *pActivator, CBaseEntity *pCaller, int outputID = 0 );
void CancelEvents( CBaseEntity *pCaller );
void CancelEventOn( CBaseEntity *pTarget, const char *sInputName );
bool HasEventPending( CBaseEntity *pTarget, const char *sInputName );
// services the queue, firing off any events who's time hath come
void ServiceEvents( void );
// debugging
void ValidateQueue( void );
// serialization
int Save( ISave &save );
int Restore( IRestore &restore );
CEventQueue();
~CEventQueue();
void Init( void );
void Clear( void ); // resets the list
void Dump( void );
vscript additions and fixes: baseanimating.h baseanimating.cpp - Added CBaseAnimating::SequenceDuration (ScriptSequenceDuration) - Added CBaseAnimating::GetPlaybackRate - Added CBaseAnimating::SetPlaybackRate - Added CBaseAnimating::GetCycle - Added CBaseAnimating::SetCycle triggers.h triggers.cpp - Fixed CTriggerCamera::ScriptSetFov setting player FOV while disabled - Added CBaseTrigger::Enable - Added CBaseTrigger::Disable - Added CBaseTrigger::TouchTest - Added CBaseTrigger::IsTouching (ScriptIsTouching) vscript_server.nut vscript_server.cpp - Added CEntities::FindByClassnameWithinBox - Added ::SendToConsoleServer - Added ::CancelEntityIOEvent - Added ::GetEntityIOEventTimeLeft - Moved ScriptDispatchParticleEffect to shared code eventqueue.h cbase.h cbase.cpp - Set entity I/O con output colour - Added (CEventQueue::CancelEventsByInput) - Added (CEventQueue::RemoveEvent) - Added (CEventQueue::GetTimeLeft) baseentity.h baseentity.cpp - Added CBaseEntity::SetTransmitState - Added CBaseEntity::GetTransmitState - Added CBaseEntity::AcceptInput (ScriptAcceptInput) - Added CBaseEntity::FireOutput (ScriptFireOutput) - Added CBaseEntity::GetMaxOutputDelay - Added CBaseEntity::CancelEventsByInput - Added player_use event on InputUse - Fixed InputKill on players ivscript.h vscript_squirrel.cpp - Added IScriptVM::ArrayAppend - Fixed buffer overflow crash - Increased print buffer to 2048 from 256 - Set vscript print output colour vscript_funcs_shared.cpp - Added CNetMsgScriptHelper (CScriptGameEventListener) - Added ::ListenToGameEvent - Added ::StopListeningToGameEvent - Added ::StopListeningToAllGameEvents - Added ::FireGameEvent - Added ::FireGameEventLocal (CScriptSaveRestoreUtil) - Added ::SaveTable - Added ::RestoreTable - Added ::ClearSavedTable - Added callbacks ::OnSave, ::OnRestore (CScriptReadWriteFile) - Added ::StringToFile - Added ::FileToString - Added GlobalSys::GetCommandLine - Added GlobalSys::CommandLineCheck - Added GlobalSys::CommandLineCheckStr - Added GlobalSys::CommandLineCheckFloat - Added GlobalSys::CommandLineCheckInt - Added ::GetCPUUsage - Added ::NXPrint - Added ::Msg (ScriptMsg) - Removed misplaced condition checks - Fixed ScriptEntitiesInBox, *AtPoint, *InSphere logic_eventlistener.cpp - Removed redundant dev msg gamestringpool.cpp - Fixed string pool dump sort
2020-10-27 02:22:18 +03:00
#ifdef MAPBASE_VSCRIPT
void CancelEventsByInput( CBaseEntity *pTarget, const char *szInput );
vscript additions and fixes: baseentity_shared.cpp baseentity.cpp c_baseentity.h c_baseentity.cpp c_world.h - Fixed critical ScriptSetContextThink bugs - Added C_BaseEntity::SetContextThink (ScriptSetContextThink) - Added C_BaseEntity::SetSize - Added C_BaseEntity::SetModel - Added C_BaseEntity::Destroy baseentity.h baseentity.cpp - Removed duplicate functions ScriptSetSize and ScriptUtilRemove player.cpp - Moved player script instance registration before player_spawn event vscript_server.cpp - Added CEntities::FindByClassNearestFacing vscript_funcs_shared.cpp - Added GetFrameCount - Added IntervalPerTick vscript_singletons.cpp - Better game event descriptors for CScriptGameEventListener - Added ::effects (CEffectsScriptHelper) - Added ::Convars (CScriptConvarAccessor) vscript_shared.cpp - Fixed clientside entity printing in script VM mapbase_con_groups.h mapbase_con_groups.cpp - Improved performance by changing string comparisons to direct array access vscript_bindings_base.h vscript_bindings_base.cpp - Added CScriptKeyValues::SubKeysToTable vscript_bindings_math.cpp - Added ::SimpleSplineRemapVal - Added ::SimpleSplineRemapValClamped - Added ::Bias - Added ::Gain - Added ::SmoothCurve - Added ::SmoothCurve_Tweak - Added ::ExponentialDecay vscript_squirrel.nut - Added ::Lerp - Added ::FLerp - Added ::SimpleSpline vscript_squirrel.cpp - Added Vector::_unm - Added Vector::Set - Added Vector::Add - Added Vector::Subtract - Added Vector::Multiply - Added Vector::Divide - Added Vector::DistTo - Added Vector::DistToSqr - Added Vector::IsEqualTo - Added Vector::WithinAABox - Added Vector::FromKVString - Changed vector print syntax
2021-03-06 02:11:43 +03:00
bool RemoveEvent( int event );
float GetTimeLeft( int event );
vscript additions and fixes: baseanimating.h baseanimating.cpp - Added CBaseAnimating::SequenceDuration (ScriptSequenceDuration) - Added CBaseAnimating::GetPlaybackRate - Added CBaseAnimating::SetPlaybackRate - Added CBaseAnimating::GetCycle - Added CBaseAnimating::SetCycle triggers.h triggers.cpp - Fixed CTriggerCamera::ScriptSetFov setting player FOV while disabled - Added CBaseTrigger::Enable - Added CBaseTrigger::Disable - Added CBaseTrigger::TouchTest - Added CBaseTrigger::IsTouching (ScriptIsTouching) vscript_server.nut vscript_server.cpp - Added CEntities::FindByClassnameWithinBox - Added ::SendToConsoleServer - Added ::CancelEntityIOEvent - Added ::GetEntityIOEventTimeLeft - Moved ScriptDispatchParticleEffect to shared code eventqueue.h cbase.h cbase.cpp - Set entity I/O con output colour - Added (CEventQueue::CancelEventsByInput) - Added (CEventQueue::RemoveEvent) - Added (CEventQueue::GetTimeLeft) baseentity.h baseentity.cpp - Added CBaseEntity::SetTransmitState - Added CBaseEntity::GetTransmitState - Added CBaseEntity::AcceptInput (ScriptAcceptInput) - Added CBaseEntity::FireOutput (ScriptFireOutput) - Added CBaseEntity::GetMaxOutputDelay - Added CBaseEntity::CancelEventsByInput - Added player_use event on InputUse - Fixed InputKill on players ivscript.h vscript_squirrel.cpp - Added IScriptVM::ArrayAppend - Fixed buffer overflow crash - Increased print buffer to 2048 from 256 - Set vscript print output colour vscript_funcs_shared.cpp - Added CNetMsgScriptHelper (CScriptGameEventListener) - Added ::ListenToGameEvent - Added ::StopListeningToGameEvent - Added ::StopListeningToAllGameEvents - Added ::FireGameEvent - Added ::FireGameEventLocal (CScriptSaveRestoreUtil) - Added ::SaveTable - Added ::RestoreTable - Added ::ClearSavedTable - Added callbacks ::OnSave, ::OnRestore (CScriptReadWriteFile) - Added ::StringToFile - Added ::FileToString - Added GlobalSys::GetCommandLine - Added GlobalSys::CommandLineCheck - Added GlobalSys::CommandLineCheckStr - Added GlobalSys::CommandLineCheckFloat - Added GlobalSys::CommandLineCheckInt - Added ::GetCPUUsage - Added ::NXPrint - Added ::Msg (ScriptMsg) - Removed misplaced condition checks - Fixed ScriptEntitiesInBox, *AtPoint, *InSphere logic_eventlistener.cpp - Removed redundant dev msg gamestringpool.cpp - Fixed string pool dump sort
2020-10-27 02:22:18 +03:00
#endif // MAPBASE_VSCRIPT
2013-12-03 07:31:46 +04:00
private:
void AddEvent( EventQueuePrioritizedEvent_t *event );
void RemoveEvent( EventQueuePrioritizedEvent_t *pe );
DECLARE_SIMPLE_DATADESC();
EventQueuePrioritizedEvent_t m_Events;
int m_iListCount;
};
extern CEventQueue g_EventQueue;
#endif // EVENTQUEUE_H