mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Code cleanup.
This commit is contained in:
parent
33f057ac15
commit
453eff0037
@ -3,7 +3,6 @@
|
||||
#include "Logger.hpp"
|
||||
#include "Misc/Signal.hpp"
|
||||
#include "Misc/Areas.hpp"
|
||||
#include "Misc/Signal.hpp"
|
||||
#include "Base/Buffer.hpp"
|
||||
#include "Library/Utils/Buffer.hpp"
|
||||
|
||||
@ -68,7 +67,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
ScriptLoader(CSimpleIniA & conf)
|
||||
explicit ScriptLoader(CSimpleIniA & conf)
|
||||
: m_Config(conf)
|
||||
{
|
||||
/* ... */
|
||||
@ -137,7 +136,7 @@ public:
|
||||
Core Core::s_Inst;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Core::Core()
|
||||
Core::Core() noexcept
|
||||
: m_State(0)
|
||||
, m_VM(nullptr)
|
||||
, m_Scripts()
|
||||
|
505
module/Core.hpp
505
module/Core.hpp
@ -20,8 +20,8 @@ namespace SqMod {
|
||||
*/
|
||||
enum CoreCircularLocks
|
||||
{
|
||||
CCL_RELOAD_SCRIPTS = (1 << 0),
|
||||
CCL_EMIT_SERVER_OPTION = (1 << 1)
|
||||
CCL_RELOAD_SCRIPTS = (1u << 0u),
|
||||
CCL_EMIT_SERVER_OPTION = (1u << 1u)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -37,33 +37,13 @@ private:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Core();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
Core(const Core & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
Core(Core && o) = delete;
|
||||
Core() noexcept;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~Core();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Core & operator = (const Core & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Core & operator = (Core && o) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
@ -77,11 +57,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
BlipInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
|
||||
BlipInst() = default;
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
@ -114,28 +90,28 @@ protected:
|
||||
void DropEvents();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mID; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags; // Various options and states that can be toggled on the instance.
|
||||
CBlip * mInst; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj; // Script object of the instance used to interact this entity.
|
||||
Int32 mID{-1}; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
|
||||
CBlip * mInst{nullptr}; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj{}; // Script object of the instance used to interact this entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mWorld; // The identifier of the world in which this blip was created.
|
||||
Int32 mScale; // The scale of the blip.
|
||||
Int32 mWorld{-1}; // The identifier of the world in which this blip was created.
|
||||
Int32 mScale{-1}; // The scale of the blip.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mSprID;
|
||||
Int32 mSprID{-1};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
LightObj mEvents; // Table containing the emitted entity events.
|
||||
LightObj mEvents{}; // Table containing the emitted entity events.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Vector3 mPosition;
|
||||
Color4 mColor;
|
||||
Vector3 mPosition{};
|
||||
Color4 mColor{};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnDestroyed;
|
||||
SignalPair mOnCustom;
|
||||
SignalPair mOnDestroyed{};
|
||||
SignalPair mOnCustom{};
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -146,10 +122,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
CheckpointInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
CheckpointInst() = default;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
@ -183,25 +156,25 @@ protected:
|
||||
void DropEvents();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mID; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags; // Various options and states that can be toggled on the instance.
|
||||
CCheckpoint * mInst; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj; // Script object of the instance used to interact this entity.
|
||||
Int32 mID{-1}; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
|
||||
CCheckpoint * mInst{nullptr}; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj{}; // Script object of the instance used to interact this entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
LightObj mEvents; // Table containing the emitted entity events.
|
||||
LightObj mEvents{}; // Table containing the emitted entity events.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnDestroyed;
|
||||
SignalPair mOnCustom;
|
||||
SignalPair mOnDestroyed{};
|
||||
SignalPair mOnCustom{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnStream;
|
||||
SignalPair mOnStream{};
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnEntered;
|
||||
SignalPair mOnExited;
|
||||
SignalPair mOnWorld;
|
||||
SignalPair mOnRadius;
|
||||
SignalPair mOnEntered{};
|
||||
SignalPair mOnExited{};
|
||||
SignalPair mOnWorld{};
|
||||
SignalPair mOnRadius{};
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -212,10 +185,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
KeybindInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
KeybindInst() = default;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
@ -249,27 +219,27 @@ protected:
|
||||
void DropEvents();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mID; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags; // Various options and states that can be toggled on the instance.
|
||||
CKeybind * mInst; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj; // Script object of the instance used to interact this entity.
|
||||
Int32 mID{-1}; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
|
||||
CKeybind * mInst{nullptr}; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj{}; // Script object of the instance used to interact this entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mFirst; // Key-code of the first button from the triggering combination.
|
||||
Int32 mSecond; // Key-code of the second button from the triggering combination.
|
||||
Int32 mThird; // Key-code of the third button from the triggering combination.
|
||||
Int32 mRelease; // Whether the key-bind reacts to button press or release.
|
||||
Int32 mFirst{-1}; // Key-code of the first button from the triggering combination.
|
||||
Int32 mSecond{-1}; // Key-code of the second button from the triggering combination.
|
||||
Int32 mThird{-1}; // Key-code of the third button from the triggering combination.
|
||||
Int32 mRelease{-1}; // Whether the key-bind reacts to button press or release.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
LightObj mEvents; // Table containing the emitted entity events.
|
||||
LightObj mEvents{}; // Table containing the emitted entity events.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnDestroyed;
|
||||
SignalPair mOnCustom;
|
||||
SignalPair mOnDestroyed{};
|
||||
SignalPair mOnCustom{};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnKeyPress;
|
||||
SignalPair mOnKeyRelease;
|
||||
SignalPair mOnKeyPress{};
|
||||
SignalPair mOnKeyRelease{};
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -280,10 +250,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
ObjectInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
ObjectInst() = default;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
@ -317,26 +284,26 @@ protected:
|
||||
void DropEvents();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mID; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags; // Various options and states that can be toggled on the instance.
|
||||
CObject * mInst; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj; // Script object of the instance used to interact this entity.
|
||||
Int32 mID{-1}; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
|
||||
CObject * mInst{nullptr}; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj{}; // Script object of the instance used to interact this entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
LightObj mEvents; // Table containing the emitted entity events.
|
||||
LightObj mEvents{}; // Table containing the emitted entity events.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnDestroyed;
|
||||
SignalPair mOnCustom;
|
||||
SignalPair mOnDestroyed{};
|
||||
SignalPair mOnCustom{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnStream;
|
||||
SignalPair mOnStream{};
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnShot;
|
||||
SignalPair mOnTouched;
|
||||
SignalPair mOnWorld;
|
||||
SignalPair mOnAlpha;
|
||||
SignalPair mOnReport;
|
||||
SignalPair mOnShot{};
|
||||
SignalPair mOnTouched{};
|
||||
SignalPair mOnWorld{};
|
||||
SignalPair mOnAlpha{};
|
||||
SignalPair mOnReport{};
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -347,10 +314,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
PickupInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
PickupInst() = default;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
@ -384,29 +348,29 @@ protected:
|
||||
void DropEvents();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mID; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags; // Various options and states that can be toggled on the instance.
|
||||
CPickup * mInst; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj; // Script object of the instance used to interact this entity.
|
||||
Int32 mID{-1}; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
|
||||
CPickup * mInst{nullptr}; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj{}; // Script object of the instance used to interact this entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
LightObj mEvents; // Table containing the emitted entity events.
|
||||
LightObj mEvents{}; // Table containing the emitted entity events.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnDestroyed;
|
||||
SignalPair mOnCustom;
|
||||
SignalPair mOnDestroyed{};
|
||||
SignalPair mOnCustom{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnStream;
|
||||
SignalPair mOnStream{};
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnRespawn;
|
||||
SignalPair mOnClaimed;
|
||||
SignalPair mOnCollected;
|
||||
SignalPair mOnWorld;
|
||||
SignalPair mOnAlpha;
|
||||
SignalPair mOnAutomatic;
|
||||
SignalPair mOnAutoTimer;
|
||||
SignalPair mOnOption;
|
||||
SignalPair mOnRespawn{};
|
||||
SignalPair mOnClaimed{};
|
||||
SignalPair mOnCollected{};
|
||||
SignalPair mOnWorld{};
|
||||
SignalPair mOnAlpha{};
|
||||
SignalPair mOnAutomatic{};
|
||||
SignalPair mOnAutoTimer{};
|
||||
SignalPair mOnOption{};
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -417,10 +381,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
PlayerInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
PlayerInst() = default;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
@ -454,122 +415,122 @@ protected:
|
||||
void DropEvents();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mID; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags; // Various options and states that can be toggled on the instance.
|
||||
CPlayer * mInst; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj; // Script object of the instance used to interact this entity.
|
||||
Int32 mID{-1}; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
|
||||
CPlayer * mInst{nullptr}; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj{}; // Script object of the instance used to interact this entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
AreaList mAreas; // Areas the player is currently in.
|
||||
AreaList mAreas{}; // Areas the player is currently in.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SQInteger mTrackPosition; // The number of times to track position changes.
|
||||
SQInteger mTrackHeading; // The number of times to track heading changes.
|
||||
SQInteger mTrackPosition{0}; // The number of times to track position changes.
|
||||
SQInteger mTrackHeading{0}; // The number of times to track heading changes.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mTrackPositionHeader; // Header to send when triggering position callback.
|
||||
LightObj mTrackPositionPayload; // Payload to send when triggering position callback.
|
||||
Int32 mTrackPositionHeader{0}; // Header to send when triggering position callback.
|
||||
LightObj mTrackPositionPayload{}; // Payload to send when triggering position callback.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mKickBanHeader; // Header to send when triggering kick/ban callback.
|
||||
LightObj mKickBanPayload; // Payload to send when triggering kick/ban callback.
|
||||
Int32 mKickBanHeader{0}; // Header to send when triggering kick/ban callback.
|
||||
LightObj mKickBanPayload{}; // Payload to send when triggering kick/ban callback.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mLastWeapon; // Last known weapon of the player entity.
|
||||
Float32 mLastHealth; // Last known health of the player entity.
|
||||
Float32 mLastArmour; // Last known armor of the player entity.
|
||||
Float32 mLastHeading; // Last known heading of the player entity.
|
||||
Vector3 mLastPosition; // Last known position of the player entity.
|
||||
Int32 mLastWeapon{-1}; // Last known weapon of the player entity.
|
||||
Float32 mLastHealth{0}; // Last known health of the player entity.
|
||||
Float32 mLastArmour{0}; // Last known armor of the player entity.
|
||||
Float32 mLastHeading{0}; // Last known heading of the player entity.
|
||||
Vector3 mLastPosition{}; // Last known position of the player entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mAuthority; // The authority level of the managed player.
|
||||
Int32 mAuthority{0}; // The authority level of the managed player.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
LightObj mEvents; // Table containing the emitted entity events.
|
||||
LightObj mEvents{}; // Table containing the emitted entity events.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnDestroyed;
|
||||
SignalPair mOnCustom;
|
||||
SignalPair mOnDestroyed{};
|
||||
SignalPair mOnCustom{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnStream;
|
||||
SignalPair mOnStream{};
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnRequestClass;
|
||||
SignalPair mOnRequestSpawn;
|
||||
SignalPair mOnSpawn;
|
||||
SignalPair mOnWasted;
|
||||
SignalPair mOnKilled;
|
||||
SignalPair mOnEmbarking;
|
||||
SignalPair mOnEmbarked;
|
||||
SignalPair mOnDisembark;
|
||||
SignalPair mOnRename;
|
||||
SignalPair mOnState;
|
||||
SignalPair mOnStateNone;
|
||||
SignalPair mOnStateNormal;
|
||||
SignalPair mOnStateAim;
|
||||
SignalPair mOnStateDriver;
|
||||
SignalPair mOnStatePassenger;
|
||||
SignalPair mOnStateEnterDriver;
|
||||
SignalPair mOnStateEnterPassenger;
|
||||
SignalPair mOnStateExit;
|
||||
SignalPair mOnStateUnspawned;
|
||||
SignalPair mOnAction;
|
||||
SignalPair mOnActionNone;
|
||||
SignalPair mOnActionNormal;
|
||||
SignalPair mOnActionAiming;
|
||||
SignalPair mOnActionShooting;
|
||||
SignalPair mOnActionJumping;
|
||||
SignalPair mOnActionLieDown;
|
||||
SignalPair mOnActionGettingUp;
|
||||
SignalPair mOnActionJumpVehicle;
|
||||
SignalPair mOnActionDriving;
|
||||
SignalPair mOnActionDying;
|
||||
SignalPair mOnActionWasted;
|
||||
SignalPair mOnActionEmbarking;
|
||||
SignalPair mOnActionDisembarking;
|
||||
SignalPair mOnBurning;
|
||||
SignalPair mOnCrouching;
|
||||
SignalPair mOnGameKeys;
|
||||
SignalPair mOnStartTyping;
|
||||
SignalPair mOnStopTyping;
|
||||
SignalPair mOnAway;
|
||||
SignalPair mOnMessage;
|
||||
SignalPair mOnCommand;
|
||||
SignalPair mOnPrivateMessage;
|
||||
SignalPair mOnKeyPress;
|
||||
SignalPair mOnKeyRelease;
|
||||
SignalPair mOnSpectate;
|
||||
SignalPair mOnUnspectate;
|
||||
SignalPair mOnCrashreport;
|
||||
SignalPair mOnModuleList;
|
||||
SignalPair mOnObjectShot;
|
||||
SignalPair mOnObjectTouched;
|
||||
SignalPair mOnPickupClaimed;
|
||||
SignalPair mOnPickupCollected;
|
||||
SignalPair mOnCheckpointEntered;
|
||||
SignalPair mOnCheckpointExited;
|
||||
SignalPair mOnClientScriptData;
|
||||
SignalPair mOnRequestClass{};
|
||||
SignalPair mOnRequestSpawn{};
|
||||
SignalPair mOnSpawn{};
|
||||
SignalPair mOnWasted{};
|
||||
SignalPair mOnKilled{};
|
||||
SignalPair mOnEmbarking{};
|
||||
SignalPair mOnEmbarked{};
|
||||
SignalPair mOnDisembark{};
|
||||
SignalPair mOnRename{};
|
||||
SignalPair mOnState{};
|
||||
SignalPair mOnStateNone{};
|
||||
SignalPair mOnStateNormal{};
|
||||
SignalPair mOnStateAim{};
|
||||
SignalPair mOnStateDriver{};
|
||||
SignalPair mOnStatePassenger{};
|
||||
SignalPair mOnStateEnterDriver{};
|
||||
SignalPair mOnStateEnterPassenger{};
|
||||
SignalPair mOnStateExit{};
|
||||
SignalPair mOnStateUnspawned{};
|
||||
SignalPair mOnAction{};
|
||||
SignalPair mOnActionNone{};
|
||||
SignalPair mOnActionNormal{};
|
||||
SignalPair mOnActionAiming{};
|
||||
SignalPair mOnActionShooting{};
|
||||
SignalPair mOnActionJumping{};
|
||||
SignalPair mOnActionLieDown{};
|
||||
SignalPair mOnActionGettingUp{};
|
||||
SignalPair mOnActionJumpVehicle{};
|
||||
SignalPair mOnActionDriving{};
|
||||
SignalPair mOnActionDying{};
|
||||
SignalPair mOnActionWasted{};
|
||||
SignalPair mOnActionEmbarking{};
|
||||
SignalPair mOnActionDisembarking{};
|
||||
SignalPair mOnBurning{};
|
||||
SignalPair mOnCrouching{};
|
||||
SignalPair mOnGameKeys{};
|
||||
SignalPair mOnStartTyping{};
|
||||
SignalPair mOnStopTyping{};
|
||||
SignalPair mOnAway{};
|
||||
SignalPair mOnMessage{};
|
||||
SignalPair mOnCommand{};
|
||||
SignalPair mOnPrivateMessage{};
|
||||
SignalPair mOnKeyPress{};
|
||||
SignalPair mOnKeyRelease{};
|
||||
SignalPair mOnSpectate{};
|
||||
SignalPair mOnUnspectate{};
|
||||
SignalPair mOnCrashreport{};
|
||||
SignalPair mOnModuleList{};
|
||||
SignalPair mOnObjectShot{};
|
||||
SignalPair mOnObjectTouched{};
|
||||
SignalPair mOnPickupClaimed{};
|
||||
SignalPair mOnPickupCollected{};
|
||||
SignalPair mOnCheckpointEntered{};
|
||||
SignalPair mOnCheckpointExited{};
|
||||
SignalPair mOnClientScriptData{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnEntityStream;
|
||||
SignalPair mOnEntityStream{};
|
||||
#endif
|
||||
SignalPair mOnUpdate;
|
||||
SignalPair mOnHealth;
|
||||
SignalPair mOnArmour;
|
||||
SignalPair mOnWeapon;
|
||||
SignalPair mOnHeading;
|
||||
SignalPair mOnPosition;
|
||||
SignalPair mOnOption;
|
||||
SignalPair mOnAdmin;
|
||||
SignalPair mOnWorld;
|
||||
SignalPair mOnTeam;
|
||||
SignalPair mOnSkin;
|
||||
SignalPair mOnMoney;
|
||||
SignalPair mOnScore;
|
||||
SignalPair mOnWantedLevel;
|
||||
SignalPair mOnImmunity;
|
||||
SignalPair mOnAlpha;
|
||||
SignalPair mOnEnterArea;
|
||||
SignalPair mOnLeaveArea;
|
||||
SignalPair mOnUpdate{};
|
||||
SignalPair mOnHealth{};
|
||||
SignalPair mOnArmour{};
|
||||
SignalPair mOnWeapon{};
|
||||
SignalPair mOnHeading{};
|
||||
SignalPair mOnPosition{};
|
||||
SignalPair mOnOption{};
|
||||
SignalPair mOnAdmin{};
|
||||
SignalPair mOnWorld{};
|
||||
SignalPair mOnTeam{};
|
||||
SignalPair mOnSkin{};
|
||||
SignalPair mOnMoney{};
|
||||
SignalPair mOnScore{};
|
||||
SignalPair mOnWantedLevel{};
|
||||
SignalPair mOnImmunity{};
|
||||
SignalPair mOnAlpha{};
|
||||
SignalPair mOnEnterArea{};
|
||||
SignalPair mOnLeaveArea{};
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -580,10 +541,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
VehicleInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
VehicleInst() = default;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
@ -617,55 +575,55 @@ protected:
|
||||
void DropEvents();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mID; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags; // Various options and states that can be toggled on the instance.
|
||||
CVehicle * mInst; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj; // Script object of the instance used to interact this entity.
|
||||
Int32 mID{-1}; // The unique number that identifies this entity on the server.
|
||||
Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
|
||||
CVehicle * mInst{nullptr}; // Pointer to the actual instance used to interact this entity.
|
||||
LightObj mObj{}; // Script object of the instance used to interact this entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
AreaList mAreas; // Areas the vehicle is currently in.
|
||||
AreaList mAreas{}; // Areas the vehicle is currently in.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SQInteger mTrackPosition; // The number of times to track position changes.
|
||||
SQInteger mTrackRotation; // The number of times to track rotation changes.
|
||||
SQInteger mTrackPosition{0}; // The number of times to track position changes.
|
||||
SQInteger mTrackRotation{0}; // The number of times to track rotation changes.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mLastPrimaryColor; // Last known secondary-color of the player entity.
|
||||
Int32 mLastSecondaryColor; // Last known primary-color of the player entity.
|
||||
Float32 mLastHealth; // Last known health of the player entity.
|
||||
Vector3 mLastPosition; // Last known position of the player entity.
|
||||
Quaternion mLastRotation; // Last known rotation of the player entity.
|
||||
Int32 mLastPrimaryColor{-1}; // Last known secondary-color of the player entity.
|
||||
Int32 mLastSecondaryColor{-1}; // Last known primary-color of the player entity.
|
||||
Float32 mLastHealth{0}; // Last known health of the player entity.
|
||||
Vector3 mLastPosition{}; // Last known position of the player entity.
|
||||
Quaternion mLastRotation{}; // Last known rotation of the player entity.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
LightObj mEvents; // Table containing the emitted entity events.
|
||||
LightObj mEvents{}; // Table containing the emitted entity events.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnDestroyed;
|
||||
SignalPair mOnCustom;
|
||||
SignalPair mOnDestroyed{};
|
||||
SignalPair mOnCustom{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnStream;
|
||||
SignalPair mOnStream{};
|
||||
#endif
|
||||
// ----------------------------------------------------------------------------------------
|
||||
SignalPair mOnEmbarking;
|
||||
SignalPair mOnEmbarked;
|
||||
SignalPair mOnDisembark;
|
||||
SignalPair mOnExplode;
|
||||
SignalPair mOnRespawn;
|
||||
SignalPair mOnUpdate;
|
||||
SignalPair mOnColor;
|
||||
SignalPair mOnHealth;
|
||||
SignalPair mOnPosition;
|
||||
SignalPair mOnRotation;
|
||||
SignalPair mOnOption;
|
||||
SignalPair mOnWorld;
|
||||
SignalPair mOnImmunity;
|
||||
SignalPair mOnPartStatus;
|
||||
SignalPair mOnTyreStatus;
|
||||
SignalPair mOnDamageData;
|
||||
SignalPair mOnRadio;
|
||||
SignalPair mOnHandlingRule;
|
||||
SignalPair mOnEnterArea;
|
||||
SignalPair mOnLeaveArea;
|
||||
SignalPair mOnEmbarking{};
|
||||
SignalPair mOnEmbarked{};
|
||||
SignalPair mOnDisembark{};
|
||||
SignalPair mOnExplode{};
|
||||
SignalPair mOnRespawn{};
|
||||
SignalPair mOnUpdate{};
|
||||
SignalPair mOnColor{};
|
||||
SignalPair mOnHealth{};
|
||||
SignalPair mOnPosition{};
|
||||
SignalPair mOnRotation{};
|
||||
SignalPair mOnOption{};
|
||||
SignalPair mOnWorld{};
|
||||
SignalPair mOnImmunity{};
|
||||
SignalPair mOnPartStatus{};
|
||||
SignalPair mOnTyreStatus{};
|
||||
SignalPair mOnDamageData{};
|
||||
SignalPair mOnRadio{};
|
||||
SignalPair mOnHandlingRule{};
|
||||
SignalPair mOnEnterArea{};
|
||||
SignalPair mOnLeaveArea{};
|
||||
};
|
||||
|
||||
public:
|
||||
@ -739,6 +697,26 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
Core(const Core & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
Core(Core && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Core & operator = (const Core & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Core & operator = (Core && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the core instance.
|
||||
*/
|
||||
@ -846,12 +824,12 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the script source associated with a certain path in the scripts list.
|
||||
*/
|
||||
Scripts::iterator FindScript(const CSStr src);
|
||||
Scripts::iterator FindScript(CSStr src);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the script source associated with a certain path in the pending scripts list.
|
||||
*/
|
||||
Scripts::iterator FindPendingScript(const CSStr src);
|
||||
Scripts::iterator FindPendingScript(CSStr src);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the scripts list. Should not be modified directly! Information purposes only.
|
||||
@ -922,7 +900,7 @@ public:
|
||||
*/
|
||||
bool IsCircularLock(Uint32 lock) const
|
||||
{
|
||||
return (m_CircularLocks & lock);
|
||||
return static_cast< bool >(m_CircularLocks & lock);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -1058,13 +1036,6 @@ public:
|
||||
Float32 x, Float32 y, Float32 z, Int32 alpha, bool automatic,
|
||||
Int32 header, LightObj & payload);
|
||||
|
||||
LightObj & NewSprite(Int32 index, CSStr file, Int32 xp, Int32 yp,
|
||||
Int32 xr, Int32 yr, Float32 angle, Int32 alpha, bool rel,
|
||||
Int32 header, LightObj & payload);
|
||||
|
||||
LightObj & NewTextdraw(Int32 index, CSStr text, Int32 xp, Int32 yp,
|
||||
Uint32 color, bool rel, Int32 header, LightObj & payload);
|
||||
|
||||
LightObj & NewVehicle(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z,
|
||||
Float32 angle, Int32 primary, Int32 secondary,
|
||||
Int32 header, LightObj & payload);
|
||||
@ -1082,13 +1053,13 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Entity retrievers.
|
||||
*/
|
||||
BlipInst & GetBlip(Int32 id) { return m_Blips.at(id); }
|
||||
CheckpointInst & GetCheckpoint(Int32 id) { return m_Checkpoints.at(id); }
|
||||
KeybindInst & GetKeybind(Int32 id) { return m_Keybinds.at(id); }
|
||||
ObjectInst & GetObject(Int32 id) { return m_Objects.at(id); }
|
||||
PickupInst & GetPickup(Int32 id) { return m_Pickups.at(id); }
|
||||
PlayerInst & GetPlayer(Int32 id) { return m_Players.at(id); }
|
||||
VehicleInst & GetVehicle(Int32 id) { return m_Vehicles.at(id); }
|
||||
BlipInst & GetBlip(Int32 id) { return m_Blips.at(static_cast< size_t >(id)); }
|
||||
CheckpointInst & GetCheckpoint(Int32 id) { return m_Checkpoints.at(static_cast< size_t >(id)); }
|
||||
KeybindInst & GetKeybind(Int32 id) { return m_Keybinds.at(static_cast< size_t >(id)); }
|
||||
ObjectInst & GetObject(Int32 id) { return m_Objects.at(static_cast< size_t >(id)); }
|
||||
PickupInst & GetPickup(Int32 id) { return m_Pickups.at(static_cast< size_t >(id)); }
|
||||
PlayerInst & GetPlayer(Int32 id) { return m_Players.at(static_cast< size_t >(id)); }
|
||||
VehicleInst & GetVehicle(Int32 id) { return m_Vehicles.at(static_cast< size_t >(id)); }
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Pool retrievers.
|
||||
@ -1471,7 +1442,7 @@ struct CoreState
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Backup the current core state and set the given state.
|
||||
*/
|
||||
CoreState(int s)
|
||||
explicit CoreState(int s)
|
||||
: m_State(Core::Get().GetState())
|
||||
{
|
||||
Core::Get().SetState(s);
|
||||
|
@ -232,6 +232,8 @@ void Core::EmitServerFrame(Float32 elapsed_time)
|
||||
//SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ServerFrame")
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "MemberFunctionCanBeStatic"
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::EmitPluginCommand(Uint32 command_identifier, CCStr message)
|
||||
{
|
||||
@ -245,6 +247,7 @@ void Core::EmitPluginCommand(Uint32 command_identifier, CCStr message)
|
||||
(void)message;
|
||||
#endif
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::EmitIncomingConnection(CStr player_name, size_t name_buffer_size, CCStr user_password, CCStr ip_address)
|
||||
@ -1819,9 +1822,9 @@ void Core::EmitClientScriptData(Int32 player_id, const uint8_t * data, size_t si
|
||||
return;
|
||||
}
|
||||
// Allocate a buffer with the received size
|
||||
Buffer b(size);
|
||||
Buffer b(static_cast< Buffer::SzType >(size));
|
||||
// Replicate the data to the allocated buffer
|
||||
b.Write(0, reinterpret_cast< Buffer::ConstPtr >(data), size);
|
||||
b.Write(0, reinterpret_cast< Buffer::ConstPtr >(data), static_cast< Buffer::SzType >(size));
|
||||
// Prepare an object for the obtained buffer
|
||||
LightObj o;
|
||||
// Attempt to create the requested buffer
|
||||
|
@ -1,7 +1,6 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Logger.hpp"
|
||||
#include "Core.hpp"
|
||||
#include "Base/Utility.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <ctime>
|
||||
@ -20,7 +19,8 @@
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace {
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Common windows colors.
|
||||
*/
|
||||
@ -42,7 +42,7 @@ enum
|
||||
LC_LIGHT_MAGENTA = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE,
|
||||
LC_DARK_MAGENTA = FOREGROUND_RED | FOREGROUND_BLUE
|
||||
};
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Logging colors.
|
||||
*/
|
||||
@ -209,7 +209,7 @@ static inline CCStr GetTimeStampStr()
|
||||
Logger Logger::s_Inst;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Logger::Logger()
|
||||
Logger::Logger() noexcept
|
||||
: m_Buffer()
|
||||
, m_ConsoleLevels(LOGL_ANY)
|
||||
, m_LogFileLevels(~LOGL_DBG)
|
||||
@ -332,9 +332,9 @@ void Logger::Terminate()
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Logger::Release()
|
||||
{
|
||||
for (Uint8 i = 0; i < 7; ++i)
|
||||
for (auto & f : m_LogCb)
|
||||
{
|
||||
m_LogCb[i].ReleaseGently();
|
||||
f.ReleaseGently();
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,7 +362,8 @@ SQBool Logger::ProcessCb(Uint8 level, bool sub)
|
||||
// Specify whether this is a sub message
|
||||
sq_pushbool(vm, static_cast< SQBool >(sub));
|
||||
// Make the function call and store the result
|
||||
SQRESULT res = sq_call(vm, 3, true, ErrorHandling::IsEnabled());
|
||||
SQRESULT res = sq_call(vm, 3, static_cast< SQBool >(true),
|
||||
static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Default to non greedy callback
|
||||
SQBool ret = SQFalse;
|
||||
// Did the function succeeded and is the returned value not null?
|
||||
@ -385,7 +386,7 @@ void Logger::Proccess(Uint8 level, bool sub)
|
||||
// Lock the logger to prevent a cyclic dependency
|
||||
m_CyclicLock = true;
|
||||
// Attempt to process the script callback first
|
||||
const bool greedy = ProcessCb(level, sub);
|
||||
const bool greedy = static_cast< bool >(ProcessCb(level, sub));
|
||||
// Unlock the logger after the callback was invoked
|
||||
m_CyclicLock = false;
|
||||
// Is the callback for this level greedy?
|
||||
@ -483,7 +484,7 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
// Valid line of code?
|
||||
if (!code.empty())
|
||||
{
|
||||
m_Buffer.WriteF(ret, "\n[\n=>Location: %s\n=>Line: %d\n=>Function: %s\n=>Code: %s\n]"
|
||||
m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "\n[\n=>Location: %s\n=>Line: %d\n=>Function: %s\n=>Code: %s\n]"
|
||||
, si.source, si.line, si.funcname ? si.funcname : _SC("unknown"), code.c_str());
|
||||
fall_back = false; // No need to fall back to normal message!
|
||||
}
|
||||
@ -491,7 +492,7 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
// Should the regular message be shown instead?
|
||||
if (fall_back)
|
||||
{
|
||||
m_Buffer.WriteF(ret, "\n[\n=>Location: %s\n=>Line: %d\n=>Function: %s\n]"
|
||||
m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "\n[\n=>Location: %s\n=>Line: %d\n=>Function: %s\n]"
|
||||
, si.source ? si.source : _SC("unknown")
|
||||
, si.line
|
||||
, si.funcname ? si.funcname : _SC("unknown"));
|
||||
@ -499,7 +500,8 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Buffer.WriteF(ret, "\n[\n=>Location: unknown\n=>Line: unknown\n=>Function: unknown\n]");
|
||||
m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "\n[\n=>Location: unknown\n=>Line: unknown\n=>Function: unknown\n]");
|
||||
}
|
||||
// Process the message in the buffer
|
||||
Proccess(LOGL_ERR, true);
|
||||
@ -508,17 +510,17 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
// Traceback the function call
|
||||
for (Int32 level = 1; SQ_SUCCEEDED(sq_stackinfos(vm, level, &si)); ++level)
|
||||
{
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] %s (%d) [%s]\n", level
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] %s (%d) [%s]\n", level
|
||||
, si.source ? si.source : _SC("unknown")
|
||||
, si.line
|
||||
, si.funcname ? si.funcname : _SC("unknown"));
|
||||
}
|
||||
// End the function call traceback
|
||||
m_Buffer.WriteF(ret, "]");
|
||||
m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "]");
|
||||
// Process the message in the buffer
|
||||
Proccess(LOGL_INF, true);
|
||||
// Temporary variables to retrieve stack information
|
||||
CSStr s_ = 0, name = 0;
|
||||
CSStr s_ = nullptr, name = nullptr;
|
||||
SQInteger i_, seq = 0;
|
||||
SQFloat f_;
|
||||
SQUserPointer p_;
|
||||
@ -530,41 +532,47 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
{
|
||||
seq = 0;
|
||||
// Display all locals in the current stack level
|
||||
while((name = sq_getlocal(vm, level, seq)))
|
||||
while((name = sq_getlocal(vm, static_cast< SQUnsignedInteger >(level), static_cast< SQUnsignedInteger >(seq))))
|
||||
{
|
||||
++seq;
|
||||
switch(sq_gettype(vm, -1))
|
||||
{
|
||||
case OT_NULL:
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] NULL [%s]\n", level, name);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] NULL [%s]\n", level, name);
|
||||
break;
|
||||
case OT_INTEGER:
|
||||
sq_getinteger(vm, -1, &i_);
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] INTEGER [%s] with value: %" PRINT_INT_FMT "\n", level, name, i_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] INTEGER [%s] with value: %" PRINT_INT_FMT "\n", level, name, i_);
|
||||
break;
|
||||
case OT_FLOAT:
|
||||
sq_getfloat(vm, -1, &f_);
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] FLOAT [%s] with value: %f\n", level, name, f_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] FLOAT [%s] with value: %f\n", level, name, f_);
|
||||
break;
|
||||
case OT_USERPOINTER:
|
||||
sq_getuserpointer(vm, -1, &p_);
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] USERPOINTER [%s] pointing at: %p\n", level, name, p_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] USERPOINTER [%s] pointing at: %p\n", level, name, p_);
|
||||
break;
|
||||
case OT_STRING:
|
||||
sq_getstringandsize(vm, -1, &s_, &i_);
|
||||
if (i_ > 0) {
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] STRING [%s] of %" PRINT_INT_FMT " characters: %.*s\n", level, name, i_, m_StringTruncate, s_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] STRING [%s] of %" PRINT_INT_FMT " characters: %.*s\n", level, name, i_, m_StringTruncate, s_);
|
||||
} else {
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] STRING [%s] empty\n", level, name);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] STRING [%s] empty\n", level, name);
|
||||
}
|
||||
break;
|
||||
case OT_TABLE:
|
||||
i_ = sq_getsize(vm, -1);
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] TABLE [%s] with %" PRINT_INT_FMT " elements\n", level, name, i_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] TABLE [%s] with %" PRINT_INT_FMT " elements\n", level, name, i_);
|
||||
break;
|
||||
case OT_ARRAY:
|
||||
i_ = sq_getsize(vm, -1);
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] ARRAY [%s] with %" PRINT_INT_FMT " elements\n", level, name, i_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] ARRAY [%s] with %" PRINT_INT_FMT " elements\n", level, name, i_);
|
||||
break;
|
||||
case OT_CLOSURE:
|
||||
s_ = _SC("@anonymous");
|
||||
@ -574,7 +582,7 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
}
|
||||
sq_poptop(vm);
|
||||
}
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] CLOSURE [%s] with name: %s\n", level, name, s_);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] CLOSURE [%s] with name: %s\n", level, name, s_);
|
||||
break;
|
||||
case OT_NATIVECLOSURE:
|
||||
s_ = _SC("@unknown");
|
||||
@ -584,16 +592,17 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
}
|
||||
sq_poptop(vm);
|
||||
}
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] NATIVECLOSURE [%s] with name: %s\n", level, name, s_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] NATIVECLOSURE [%s] with name: %s\n", level, name, s_);
|
||||
break;
|
||||
case OT_GENERATOR:
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] GENERATOR [%s]\n", level, name);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] GENERATOR [%s]\n", level, name);
|
||||
break;
|
||||
case OT_USERDATA:
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] USERDATA [%s]\n", level, name);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] USERDATA [%s]\n", level, name);
|
||||
break;
|
||||
case OT_THREAD:
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] THREAD [%s]\n", level, name);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] THREAD [%s]\n", level, name);
|
||||
break;
|
||||
case OT_CLASS:
|
||||
// Brute force our way into getting the name of this class without blowing up
|
||||
@ -611,7 +620,7 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
// Pop the dummy instance
|
||||
sq_poptop(vm);
|
||||
}
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] CLASS [%s] of type: %s\n", level, name, s_);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] CLASS [%s] of type: %s\n", level, name, s_);
|
||||
break;
|
||||
case OT_INSTANCE:
|
||||
s_ = _SC("@unknown");
|
||||
@ -621,7 +630,8 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
}
|
||||
sq_poptop(vm);
|
||||
}
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] INSTANCE [%s] of type: %s\n", level, name, s_);
|
||||
ret += m_Buffer.WriteF(
|
||||
static_cast< Buffer::SzType >(ret), "=> [%d] INSTANCE [%s] of type: %s\n", level, name, s_);
|
||||
break;
|
||||
case OT_WEAKREF:
|
||||
s_ = _SC("@unknown");
|
||||
@ -638,21 +648,21 @@ void Logger::Debug(CCStr fmt, va_list args)
|
||||
// Pop the referenced value
|
||||
sq_poptop(vm);
|
||||
}
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] WEAKREF [%s] of type: %s\n", level, name, s_);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] WEAKREF [%s] of type: %s\n", level, name, s_);
|
||||
break;
|
||||
case OT_BOOL:
|
||||
sq_getinteger(vm, -1, &i_);
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] BOOL [%s] with value: %s\n", level, name, i_ ? _SC("true") : _SC("false"));
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] BOOL [%s] with value: %s\n", level, name, i_ ? _SC("true") : _SC("false"));
|
||||
break;
|
||||
default:
|
||||
ret += m_Buffer.WriteF(ret, "=> [%d] UNKNOWN [%s]\n", level, name);
|
||||
ret += m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "=> [%d] UNKNOWN [%s]\n", level, name);
|
||||
break;
|
||||
}
|
||||
sq_pop(vm, 1);
|
||||
}
|
||||
}
|
||||
// End the variables information
|
||||
m_Buffer.WriteF(ret, "]");
|
||||
m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "]");
|
||||
// Process the message in the buffer
|
||||
Proccess(LOGL_INF, true);
|
||||
}
|
||||
@ -723,7 +733,7 @@ SQMOD_CLOG(cLogSFtl, LOGL_FTL, true)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = sq_gettop(vm);
|
||||
// Was the message value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
|
@ -19,15 +19,15 @@ namespace SqMod {
|
||||
*/
|
||||
enum LogLvl
|
||||
{
|
||||
LOGL_NIL = (1 << 0),
|
||||
LOGL_DBG = (1 << 1),
|
||||
LOGL_USR = (1 << 2),
|
||||
LOGL_SCS = (1 << 3),
|
||||
LOGL_INF = (1 << 4),
|
||||
LOGL_WRN = (1 << 5),
|
||||
LOGL_ERR = (1 << 6),
|
||||
LOGL_FTL = (1 << 7),
|
||||
LOGL_ANY = 0xFF
|
||||
LOGL_NIL = (1u << 0u),
|
||||
LOGL_DBG = (1u << 1u),
|
||||
LOGL_USR = (1u << 2u),
|
||||
LOGL_SCS = (1u << 3u),
|
||||
LOGL_INF = (1u << 4u),
|
||||
LOGL_WRN = (1u << 5u),
|
||||
LOGL_ERR = (1u << 6u),
|
||||
LOGL_FTL = (1u << 7u),
|
||||
LOGL_ANY = 0xFFu
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -43,33 +43,13 @@ private:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Logger();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
Logger(const Logger & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
Logger(Logger && o) = delete;
|
||||
Logger() noexcept;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~Logger();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Logger & operator = (const Logger & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Logger & operator = (Logger && o) = delete;
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
@ -92,7 +72,7 @@ private:
|
||||
std::string m_Filename; // The name of the file where the logs are saved.
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Function m_LogCb[7]; //Callback to receive debug information instead of console.
|
||||
Function m_LogCb[7]; //Callback to receive debug information instead of console.
|
||||
|
||||
protected:
|
||||
|
||||
@ -111,6 +91,26 @@ public:
|
||||
return s_Inst;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
Logger(const Logger & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
Logger(Logger && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Logger & operator = (const Logger & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Logger & operator = (Logger && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Flush buffered data and close the logging file.
|
||||
*/
|
||||
|
@ -59,7 +59,7 @@ void DoReload()
|
||||
return; // Don't even bother!
|
||||
}
|
||||
// Make sure reloading is disabled at the end of this function
|
||||
const ReloadGuard rg;
|
||||
const ReloadGuard rg();
|
||||
// Tell the central core to attempt to reload
|
||||
if (!Core::Get().Reload())
|
||||
{
|
||||
@ -80,7 +80,7 @@ void DoReload()
|
||||
#define SQMOD_RELOAD_CHECK(exp) if (exp) DoReload();
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static uint8_t OnServerInitialise(void)
|
||||
static uint8_t OnServerInitialise()
|
||||
{
|
||||
// Mark the initialization as successful by default
|
||||
const CoreState cs(SQMOD_SUCCESS);
|
||||
@ -125,10 +125,10 @@ struct CallbackUnbinder
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void OnServerShutdown(void)
|
||||
static void OnServerShutdown()
|
||||
{
|
||||
// The server still triggers callbacks and we deallocated everything!
|
||||
const CallbackUnbinder cu;
|
||||
const CallbackUnbinder cu();
|
||||
// Attempt to forward the event
|
||||
try
|
||||
{
|
||||
@ -507,6 +507,7 @@ static void OnPlayerActionChange(int32_t player_id, int32_t old_action, int32_t
|
||||
case SQMOD_PLAYER_ACTION_EXITING_VEHICLE:
|
||||
Core::Get().EmitActionDisembarking(player_id, old_action);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
SQMOD_SV_EV_TRACEBACK("[TRACE>] OnPlayerActionChange")
|
||||
}
|
||||
|
@ -123,9 +123,9 @@
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* VCMP SDK VERSION CHECK.
|
||||
*/
|
||||
#define SQMOD_SDK_MATCH(MJR, MNR) ((PLUGIN_API_MAJOR == MJR) && (PLUGIN_API_MINOR == MNR))
|
||||
#define SQMOD_SDK_LEAST(MJR, MNR) ((PLUGIN_API_MAJOR >= MJR) && (PLUGIN_API_MINOR >= MNR))
|
||||
#define SQMOD_SDK_PRIOR(MJR, MNR) ((PLUGIN_API_MAJOR < MJR) && (PLUGIN_API_MINOR < MNR))
|
||||
#define SQMOD_SDK_MATCH(MJR, MNR) ((PLUGIN_API_MAJOR == (MJR)) && (PLUGIN_API_MINOR == (MNR)))
|
||||
#define SQMOD_SDK_LEAST(MJR, MNR) ((PLUGIN_API_MAJOR >= (MJR)) && (PLUGIN_API_MINOR >= (MNR)))
|
||||
#define SQMOD_SDK_PRIOR(MJR, MNR) ((PLUGIN_API_MAJOR < (MJR)) && (PLUGIN_API_MINOR < (MNR)))
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* SQUIRREL FORWARD DECLARATIONS
|
||||
@ -436,9 +436,9 @@ enum EventType
|
||||
enum EntityFlags
|
||||
{
|
||||
ENF_DEFAULT = (0),
|
||||
ENF_OWNED = (1 << 1),
|
||||
ENF_LOCKED = (1 << 2),
|
||||
ENF_AREA_TRACK = (1 << 3)
|
||||
ENF_OWNED = (1u << 1u),
|
||||
ENF_LOCKED = (1u << 2u),
|
||||
ENF_AREA_TRACK = (1u << 3u)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -608,28 +608,28 @@ enum EntityType
|
||||
#define SQMOD_DECL_UNUSED_VAR(t, n, v) t n = v; (void)(n)
|
||||
#define SQMOD_UNUSED_VAR(n) (void)(n)
|
||||
|
||||
#define VALID_ENTITY(e) (e >= 0)
|
||||
#define INVALID_ENTITY(e) (e < 0)
|
||||
#define VALID_ENTITY(e) ((e) >= 0)
|
||||
#define INVALID_ENTITY(e) ((e) < 0)
|
||||
|
||||
#define VALID_ENTITYEX(e, m) ((e >= 0) && (e < m))
|
||||
#define INVALID_ENTITYEX(e, m) ((e < 0) || (e >= m))
|
||||
#define VALID_ENTITYEX(e, m) (((e) >= 0) && ((e) < (m)))
|
||||
#define INVALID_ENTITYEX(e, m) (((e) < 0) || ((e) >= (m)))
|
||||
|
||||
#define VALID_ENTITYGET(e) ((e >= 0) ? e : -1)
|
||||
#define VALID_ENTITYGETEX(e, m) ((e >= 0) && (e < m) ? e : -1)
|
||||
#define VALID_ENTITYGET(e) (((e) >= 0) ? (e) : -1)
|
||||
#define VALID_ENTITYGETEX(e, m) (((e) >= 0) && ((e) < (m)) ? (e) : -1)
|
||||
|
||||
#define VALID_VEHCOL(e) ((e >= 0) && (e <= 94))
|
||||
#define INVALID_VEHCOL(e) ((e < 0) && (e > 94))
|
||||
#define VALID_VEHCOL(e) (((e) >= 0) && ((e) <= 94))
|
||||
#define INVALID_VEHCOL(e) (((e) < 0) && ((e) > 94))
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* COLOR PACKING
|
||||
*/
|
||||
|
||||
#define SQMOD_PACK_RGB(r, g, b) static_cast< Uint32 >(r << 16u | g << 8u | b)
|
||||
#define SQMOD_PACK_RGBA(r, g, b, a) static_cast< Uint32 >(r << 24u | g << 16u | b << 8u | a)
|
||||
#define SQMOD_PACK_ARGB(a, r, g, b) static_cast< Uint32 >(a << 24u | r << 16u | g << 8u | b)
|
||||
#define SQMOD_PACK_RGB(r, g, b) static_cast< Uint32 >((r) << 16u | (g) << 8u | (b))
|
||||
#define SQMOD_PACK_RGBA(r, g, b, a) static_cast< Uint32 >((r) << 24u | (g) << 16u | (b) << 8u | (a))
|
||||
#define SQMOD_PACK_ARGB(a, r, g, b) static_cast< Uint32 >((a) << 24u | (r) << 16u | (g) << 8u | (b))
|
||||
|
||||
#define SQMOD_PACK_RGB_TO_RGBA(r, g, b) static_cast< Uint32 >(r << 24u | g << 16u | b << 8u | 0u)
|
||||
#define SQMOD_PACK_RGB_TO_ARGB(r, g, b) static_cast< Uint32 >(0u << 24u | r << 16u | g << 8u | b)
|
||||
#define SQMOD_PACK_RGB_TO_RGBA(r, g, b) static_cast< Uint32 >((r) << 24u | (g) << 16u | (b) << 8u | 0u)
|
||||
#define SQMOD_PACK_RGB_TO_ARGB(r, g, b) static_cast< Uint32 >(0u << 24u | (r) << 16u | (g) << 8u | (b))
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* GENERAL RESPONSES
|
||||
@ -637,7 +637,7 @@ enum EntityType
|
||||
|
||||
#define SQMOD_SUCCESS 1
|
||||
#define SQMOD_FAILURE 0
|
||||
#define SQMOD_UNKNOWN -1
|
||||
#define SQMOD_UNKNOWN (-1)
|
||||
#define SQMOD_TRUE 1
|
||||
#define SQMOD_FALSE 0
|
||||
#define SQMOD_NULL NULL
|
||||
@ -676,18 +676,18 @@ enum EntityType
|
||||
*/
|
||||
|
||||
#define SQMOD_CREATE_DEFAULT 0
|
||||
#define SQMOD_CREATE_MANUAL -3
|
||||
#define SQMOD_CREATE_POOL -4
|
||||
#define SQMOD_CREATE_AUTOMATIC -5
|
||||
#define SQMOD_CREATE_OVERWRITE -6
|
||||
#define SQMOD_CREATE_IMPORT -7
|
||||
#define SQMOD_CREATE_MANUAL (-3)
|
||||
#define SQMOD_CREATE_POOL (-4)
|
||||
#define SQMOD_CREATE_AUTOMATIC (-5)
|
||||
#define SQMOD_CREATE_OVERWRITE (-6)
|
||||
#define SQMOD_CREATE_IMPORT (-7)
|
||||
|
||||
#define SQMOD_DESTROY_DEFAULT 0
|
||||
#define SQMOD_DESTROY_MANUAL -3
|
||||
#define SQMOD_DESTROY_POOL -4
|
||||
#define SQMOD_DESTROY_AUTOMATIC -5
|
||||
#define SQMOD_DESTROY_OVERWRITE -6
|
||||
#define SQMOD_DESTROY_CLEANUP -7
|
||||
#define SQMOD_DESTROY_MANUAL (-3)
|
||||
#define SQMOD_DESTROY_POOL (-4)
|
||||
#define SQMOD_DESTROY_AUTOMATIC (-5)
|
||||
#define SQMOD_DESTROY_OVERWRITE (-6)
|
||||
#define SQMOD_DESTROY_CLEANUP (-7)
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* MODEL ID LIMITS
|
||||
|
Loading…
Reference in New Issue
Block a user