AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ServerScript Class Reference

#include "ServerScript.h"

Inheritance diagram for ServerScript:
ScriptObject

Public Member Functions

virtual void OnNetworkStart ()
 
virtual void OnNetworkStop ()
 
virtual void OnSocketOpen (std::shared_ptr< WorldSocket >)
 
virtual void OnSocketClose (std::shared_ptr< WorldSocket >)
 
virtual bool CanPacketSend (WorldSession *, WorldPacket &)
 This hook called when a packet is sent to a client. The packet object is a copy of the original packet, so reading and modifying it is safe. More...
 
virtual bool CanPacketReceive (WorldSession *, WorldPacket &)
 Called when a (valid) packet is received by a client. The packet object is a copy of the original packet, so reading and modifying it is safe. Make sure to check WorldSession pointer before usage, it might be null in case of auth packets. More...
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Protected Member Functions

 ServerScript (const char *name, std::vector< uint16 > enabledHooks=std::vector< uint16 >())
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ ServerScript()

ServerScript::ServerScript ( const char *  name,
std::vector< uint16 enabledHooks = std::vector<uint16>() 
)
protected
70{
71 // If empty - enable all available hooks.
72 if (enabledHooks.empty())
73 for (uint16 i = 0; i < SERVERHOOK_END; ++i)
74 enabledHooks.emplace_back(i);
75
76 ScriptRegistry<ServerScript>::AddScript(this, std::move(enabledHooks));
77}
std::uint16_t uint16
Definition: Define.h:108
@ SERVERHOOK_END
Definition: ServerScript.h:32
static void AddScript(TScript *const script, std::vector< uint16 > enabledHooks={})
Definition: ScriptMgr.h:737
Definition: ScriptObject.h:44

References ScriptRegistry< TScript >::AddScript(), and SERVERHOOK_END.

Member Function Documentation

◆ CanPacketReceive()

virtual bool ServerScript::CanPacketReceive ( WorldSession ,
WorldPacket  
)
inlinevirtual

Called when a (valid) packet is received by a client. The packet object is a copy of the original packet, so reading and modifying it is safe. Make sure to check WorldSession pointer before usage, it might be null in case of auth packets.

Parameters
sessionContains information about the WorldSession
packetContains information about the WorldPacket
Returns
True if you want to continue receive the packet, false if you want to disallow receive the packet
71{ return true; }

◆ CanPacketSend()

virtual bool ServerScript::CanPacketSend ( WorldSession ,
WorldPacket  
)
inlinevirtual

This hook called when a packet is sent to a client. The packet object is a copy of the original packet, so reading and modifying it is safe.

Parameters
sessionContains information about the WorldSession
packetContains information about the WorldPacket
Returns
True if you want to continue sending the packet, false if you want to disallow sending the packet
61{ return true; }

◆ OnNetworkStart()

virtual void ServerScript::OnNetworkStart ( )
inlinevirtual
42{ }

◆ OnNetworkStop()

virtual void ServerScript::OnNetworkStop ( )
inlinevirtual
45{ }

◆ OnSocketClose()

virtual void ServerScript::OnSocketClose ( std::shared_ptr< WorldSocket )
inlinevirtual
52{ }

◆ OnSocketOpen()

virtual void ServerScript::OnSocketOpen ( std::shared_ptr< WorldSocket )
inlinevirtual
48{ }