1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-12 07:47:12 +01:00

Code cleanup.

This commit is contained in:
Sandu Liviu Catalin 2020-03-22 10:31:43 +02:00
parent 33f057ac15
commit 453eff0037
7 changed files with 356 additions and 372 deletions

View File

@ -3,7 +3,6 @@
#include "Logger.hpp" #include "Logger.hpp"
#include "Misc/Signal.hpp" #include "Misc/Signal.hpp"
#include "Misc/Areas.hpp" #include "Misc/Areas.hpp"
#include "Misc/Signal.hpp"
#include "Base/Buffer.hpp" #include "Base/Buffer.hpp"
#include "Library/Utils/Buffer.hpp" #include "Library/Utils/Buffer.hpp"
@ -68,7 +67,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
ScriptLoader(CSimpleIniA & conf) explicit ScriptLoader(CSimpleIniA & conf)
: m_Config(conf) : m_Config(conf)
{ {
/* ... */ /* ... */
@ -137,7 +136,7 @@ public:
Core Core::s_Inst; Core Core::s_Inst;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Core::Core() Core::Core() noexcept
: m_State(0) : m_State(0)
, m_VM(nullptr) , m_VM(nullptr)
, m_Scripts() , m_Scripts()

View File

@ -20,8 +20,8 @@ namespace SqMod {
*/ */
enum CoreCircularLocks enum CoreCircularLocks
{ {
CCL_RELOAD_SCRIPTS = (1 << 0), CCL_RELOAD_SCRIPTS = (1u << 0u),
CCL_EMIT_SERVER_OPTION = (1 << 1) CCL_EMIT_SERVER_OPTION = (1u << 1u)
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@ -37,33 +37,13 @@ private:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Core(); Core() noexcept;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
Core(const Core & o) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
Core(Core && o) = delete;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
*/ */
~Core(); ~Core();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
Core & operator = (const Core & o) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
Core & operator = (Core && o) = delete;
protected: protected:
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
@ -77,11 +57,7 @@ protected:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
BlipInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj() BlipInst() = default;
{
ResetInstance();
}
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Destructor. * Destructor.
*/ */
@ -114,28 +90,28 @@ protected:
void DropEvents(); void DropEvents();
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mID; // The unique number that identifies this entity on the server. Int32 mID{-1}; // The unique number that identifies this entity on the server.
Uint32 mFlags; // Various options and states that can be toggled on the instance. Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
CBlip * mInst; // Pointer to the actual instance used to interact this entity. 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. 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 mWorld{-1}; // The identifier of the world in which this blip was created.
Int32 mScale; // The scale of the blip. 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; Vector3 mPosition{};
Color4 mColor; Color4 mColor{};
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
SignalPair mOnDestroyed; SignalPair mOnDestroyed{};
SignalPair mOnCustom; SignalPair mOnCustom{};
}; };
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -146,10 +122,7 @@ protected:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
CheckpointInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj() CheckpointInst() = default;
{
ResetInstance();
}
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -183,25 +156,25 @@ protected:
void DropEvents(); void DropEvents();
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mID; // The unique number that identifies this entity on the server. Int32 mID{-1}; // The unique number that identifies this entity on the server.
Uint32 mFlags; // Various options and states that can be toggled on the instance. Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
CCheckpoint * mInst; // Pointer to the actual instance used to interact this entity. 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 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 mOnDestroyed{};
SignalPair mOnCustom; SignalPair mOnCustom{};
#if SQMOD_SDK_LEAST(2, 1) #if SQMOD_SDK_LEAST(2, 1)
SignalPair mOnStream; SignalPair mOnStream{};
#endif #endif
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
SignalPair mOnEntered; SignalPair mOnEntered{};
SignalPair mOnExited; SignalPair mOnExited{};
SignalPair mOnWorld; SignalPair mOnWorld{};
SignalPair mOnRadius; SignalPair mOnRadius{};
}; };
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -212,10 +185,7 @@ protected:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
KeybindInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj() KeybindInst() = default;
{
ResetInstance();
}
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -249,27 +219,27 @@ protected:
void DropEvents(); void DropEvents();
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mID; // The unique number that identifies this entity on the server. Int32 mID{-1}; // The unique number that identifies this entity on the server.
Uint32 mFlags; // Various options and states that can be toggled on the instance. Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
CKeybind * mInst; // Pointer to the actual instance used to interact this entity. 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. 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 mFirst{-1}; // Key-code of the first button from the triggering combination.
Int32 mSecond; // Key-code of the second button from the triggering combination. Int32 mSecond{-1}; // Key-code of the second button from the triggering combination.
Int32 mThird; // Key-code of the third button from the triggering combination. Int32 mThird{-1}; // Key-code of the third button from the triggering combination.
Int32 mRelease; // Whether the key-bind reacts to button press or release. 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 mOnDestroyed{};
SignalPair mOnCustom; SignalPair mOnCustom{};
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
SignalPair mOnKeyPress; SignalPair mOnKeyPress{};
SignalPair mOnKeyRelease; SignalPair mOnKeyRelease{};
}; };
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -280,10 +250,7 @@ protected:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
ObjectInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj() ObjectInst() = default;
{
ResetInstance();
}
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -317,26 +284,26 @@ protected:
void DropEvents(); void DropEvents();
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mID; // The unique number that identifies this entity on the server. Int32 mID{-1}; // The unique number that identifies this entity on the server.
Uint32 mFlags; // Various options and states that can be toggled on the instance. Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
CObject * mInst; // Pointer to the actual instance used to interact this entity. 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 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 mOnDestroyed{};
SignalPair mOnCustom; SignalPair mOnCustom{};
#if SQMOD_SDK_LEAST(2, 1) #if SQMOD_SDK_LEAST(2, 1)
SignalPair mOnStream; SignalPair mOnStream{};
#endif #endif
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
SignalPair mOnShot; SignalPair mOnShot{};
SignalPair mOnTouched; SignalPair mOnTouched{};
SignalPair mOnWorld; SignalPair mOnWorld{};
SignalPair mOnAlpha; SignalPair mOnAlpha{};
SignalPair mOnReport; SignalPair mOnReport{};
}; };
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -347,10 +314,7 @@ protected:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
PickupInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj() PickupInst() = default;
{
ResetInstance();
}
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -384,29 +348,29 @@ protected:
void DropEvents(); void DropEvents();
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mID; // The unique number that identifies this entity on the server. Int32 mID{-1}; // The unique number that identifies this entity on the server.
Uint32 mFlags; // Various options and states that can be toggled on the instance. Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
CPickup * mInst; // Pointer to the actual instance used to interact this entity. 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 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 mOnDestroyed{};
SignalPair mOnCustom; SignalPair mOnCustom{};
#if SQMOD_SDK_LEAST(2, 1) #if SQMOD_SDK_LEAST(2, 1)
SignalPair mOnStream; SignalPair mOnStream{};
#endif #endif
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
SignalPair mOnRespawn; SignalPair mOnRespawn{};
SignalPair mOnClaimed; SignalPair mOnClaimed{};
SignalPair mOnCollected; SignalPair mOnCollected{};
SignalPair mOnWorld; SignalPair mOnWorld{};
SignalPair mOnAlpha; SignalPair mOnAlpha{};
SignalPair mOnAutomatic; SignalPair mOnAutomatic{};
SignalPair mOnAutoTimer; SignalPair mOnAutoTimer{};
SignalPair mOnOption; SignalPair mOnOption{};
}; };
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -417,10 +381,7 @@ protected:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
PlayerInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj() PlayerInst() = default;
{
ResetInstance();
}
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -454,122 +415,122 @@ protected:
void DropEvents(); void DropEvents();
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mID; // The unique number that identifies this entity on the server. Int32 mID{-1}; // The unique number that identifies this entity on the server.
Uint32 mFlags; // Various options and states that can be toggled on the instance. Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
CPlayer * mInst; // Pointer to the actual instance used to interact this entity. 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. 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 mTrackPosition{0}; // The number of times to track position changes.
SQInteger mTrackHeading; // The number of times to track heading changes. SQInteger mTrackHeading{0}; // The number of times to track heading changes.
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mTrackPositionHeader; // Header 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. LightObj mTrackPositionPayload{}; // Payload to send when triggering position callback.
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mKickBanHeader; // Header 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. LightObj mKickBanPayload{}; // Payload to send when triggering kick/ban callback.
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mLastWeapon; // Last known weapon of the player entity. Int32 mLastWeapon{-1}; // Last known weapon of the player entity.
Float32 mLastHealth; // Last known health of the player entity. Float32 mLastHealth{0}; // Last known health of the player entity.
Float32 mLastArmour; // Last known armor of the player entity. Float32 mLastArmour{0}; // Last known armor of the player entity.
Float32 mLastHeading; // Last known heading of the player entity. Float32 mLastHeading{0}; // Last known heading of the player entity.
Vector3 mLastPosition; // Last known position 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 mOnDestroyed{};
SignalPair mOnCustom; SignalPair mOnCustom{};
#if SQMOD_SDK_LEAST(2, 1) #if SQMOD_SDK_LEAST(2, 1)
SignalPair mOnStream; SignalPair mOnStream{};
#endif #endif
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
SignalPair mOnRequestClass; SignalPair mOnRequestClass{};
SignalPair mOnRequestSpawn; SignalPair mOnRequestSpawn{};
SignalPair mOnSpawn; SignalPair mOnSpawn{};
SignalPair mOnWasted; SignalPair mOnWasted{};
SignalPair mOnKilled; SignalPair mOnKilled{};
SignalPair mOnEmbarking; SignalPair mOnEmbarking{};
SignalPair mOnEmbarked; SignalPair mOnEmbarked{};
SignalPair mOnDisembark; SignalPair mOnDisembark{};
SignalPair mOnRename; SignalPair mOnRename{};
SignalPair mOnState; SignalPair mOnState{};
SignalPair mOnStateNone; SignalPair mOnStateNone{};
SignalPair mOnStateNormal; SignalPair mOnStateNormal{};
SignalPair mOnStateAim; SignalPair mOnStateAim{};
SignalPair mOnStateDriver; SignalPair mOnStateDriver{};
SignalPair mOnStatePassenger; SignalPair mOnStatePassenger{};
SignalPair mOnStateEnterDriver; SignalPair mOnStateEnterDriver{};
SignalPair mOnStateEnterPassenger; SignalPair mOnStateEnterPassenger{};
SignalPair mOnStateExit; SignalPair mOnStateExit{};
SignalPair mOnStateUnspawned; SignalPair mOnStateUnspawned{};
SignalPair mOnAction; SignalPair mOnAction{};
SignalPair mOnActionNone; SignalPair mOnActionNone{};
SignalPair mOnActionNormal; SignalPair mOnActionNormal{};
SignalPair mOnActionAiming; SignalPair mOnActionAiming{};
SignalPair mOnActionShooting; SignalPair mOnActionShooting{};
SignalPair mOnActionJumping; SignalPair mOnActionJumping{};
SignalPair mOnActionLieDown; SignalPair mOnActionLieDown{};
SignalPair mOnActionGettingUp; SignalPair mOnActionGettingUp{};
SignalPair mOnActionJumpVehicle; SignalPair mOnActionJumpVehicle{};
SignalPair mOnActionDriving; SignalPair mOnActionDriving{};
SignalPair mOnActionDying; SignalPair mOnActionDying{};
SignalPair mOnActionWasted; SignalPair mOnActionWasted{};
SignalPair mOnActionEmbarking; SignalPair mOnActionEmbarking{};
SignalPair mOnActionDisembarking; SignalPair mOnActionDisembarking{};
SignalPair mOnBurning; SignalPair mOnBurning{};
SignalPair mOnCrouching; SignalPair mOnCrouching{};
SignalPair mOnGameKeys; SignalPair mOnGameKeys{};
SignalPair mOnStartTyping; SignalPair mOnStartTyping{};
SignalPair mOnStopTyping; SignalPair mOnStopTyping{};
SignalPair mOnAway; SignalPair mOnAway{};
SignalPair mOnMessage; SignalPair mOnMessage{};
SignalPair mOnCommand; SignalPair mOnCommand{};
SignalPair mOnPrivateMessage; SignalPair mOnPrivateMessage{};
SignalPair mOnKeyPress; SignalPair mOnKeyPress{};
SignalPair mOnKeyRelease; SignalPair mOnKeyRelease{};
SignalPair mOnSpectate; SignalPair mOnSpectate{};
SignalPair mOnUnspectate; SignalPair mOnUnspectate{};
SignalPair mOnCrashreport; SignalPair mOnCrashreport{};
SignalPair mOnModuleList; SignalPair mOnModuleList{};
SignalPair mOnObjectShot; SignalPair mOnObjectShot{};
SignalPair mOnObjectTouched; SignalPair mOnObjectTouched{};
SignalPair mOnPickupClaimed; SignalPair mOnPickupClaimed{};
SignalPair mOnPickupCollected; SignalPair mOnPickupCollected{};
SignalPair mOnCheckpointEntered; SignalPair mOnCheckpointEntered{};
SignalPair mOnCheckpointExited; SignalPair mOnCheckpointExited{};
SignalPair mOnClientScriptData; SignalPair mOnClientScriptData{};
#if SQMOD_SDK_LEAST(2, 1) #if SQMOD_SDK_LEAST(2, 1)
SignalPair mOnEntityStream; SignalPair mOnEntityStream{};
#endif #endif
SignalPair mOnUpdate; SignalPair mOnUpdate{};
SignalPair mOnHealth; SignalPair mOnHealth{};
SignalPair mOnArmour; SignalPair mOnArmour{};
SignalPair mOnWeapon; SignalPair mOnWeapon{};
SignalPair mOnHeading; SignalPair mOnHeading{};
SignalPair mOnPosition; SignalPair mOnPosition{};
SignalPair mOnOption; SignalPair mOnOption{};
SignalPair mOnAdmin; SignalPair mOnAdmin{};
SignalPair mOnWorld; SignalPair mOnWorld{};
SignalPair mOnTeam; SignalPair mOnTeam{};
SignalPair mOnSkin; SignalPair mOnSkin{};
SignalPair mOnMoney; SignalPair mOnMoney{};
SignalPair mOnScore; SignalPair mOnScore{};
SignalPair mOnWantedLevel; SignalPair mOnWantedLevel{};
SignalPair mOnImmunity; SignalPair mOnImmunity{};
SignalPair mOnAlpha; SignalPair mOnAlpha{};
SignalPair mOnEnterArea; SignalPair mOnEnterArea{};
SignalPair mOnLeaveArea; SignalPair mOnLeaveArea{};
}; };
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -580,10 +541,7 @@ protected:
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
VehicleInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj() VehicleInst() = default;
{
ResetInstance();
}
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Destructor. * Destructor.
@ -617,55 +575,55 @@ protected:
void DropEvents(); void DropEvents();
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mID; // The unique number that identifies this entity on the server. Int32 mID{-1}; // The unique number that identifies this entity on the server.
Uint32 mFlags; // Various options and states that can be toggled on the instance. Uint32 mFlags{ENF_DEFAULT}; // Various options and states that can be toggled on the instance.
CVehicle * mInst; // Pointer to the actual instance used to interact this entity. 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. 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 mTrackPosition{0}; // The number of times to track position changes.
SQInteger mTrackRotation; // The number of times to track rotation changes. SQInteger mTrackRotation{0}; // The number of times to track rotation changes.
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
Int32 mLastPrimaryColor; // Last known secondary-color of the player entity. Int32 mLastPrimaryColor{-1}; // Last known secondary-color of the player entity.
Int32 mLastSecondaryColor; // Last known primary-color of the player entity. Int32 mLastSecondaryColor{-1}; // Last known primary-color of the player entity.
Float32 mLastHealth; // Last known health of the player entity. Float32 mLastHealth{0}; // Last known health of the player entity.
Vector3 mLastPosition; // Last known position of the player entity. Vector3 mLastPosition{}; // Last known position of the player entity.
Quaternion mLastRotation; // Last known rotation 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 mOnDestroyed{};
SignalPair mOnCustom; SignalPair mOnCustom{};
#if SQMOD_SDK_LEAST(2, 1) #if SQMOD_SDK_LEAST(2, 1)
SignalPair mOnStream; SignalPair mOnStream{};
#endif #endif
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
SignalPair mOnEmbarking; SignalPair mOnEmbarking{};
SignalPair mOnEmbarked; SignalPair mOnEmbarked{};
SignalPair mOnDisembark; SignalPair mOnDisembark{};
SignalPair mOnExplode; SignalPair mOnExplode{};
SignalPair mOnRespawn; SignalPair mOnRespawn{};
SignalPair mOnUpdate; SignalPair mOnUpdate{};
SignalPair mOnColor; SignalPair mOnColor{};
SignalPair mOnHealth; SignalPair mOnHealth{};
SignalPair mOnPosition; SignalPair mOnPosition{};
SignalPair mOnRotation; SignalPair mOnRotation{};
SignalPair mOnOption; SignalPair mOnOption{};
SignalPair mOnWorld; SignalPair mOnWorld{};
SignalPair mOnImmunity; SignalPair mOnImmunity{};
SignalPair mOnPartStatus; SignalPair mOnPartStatus{};
SignalPair mOnTyreStatus; SignalPair mOnTyreStatus{};
SignalPair mOnDamageData; SignalPair mOnDamageData{};
SignalPair mOnRadio; SignalPair mOnRadio{};
SignalPair mOnHandlingRule; SignalPair mOnHandlingRule{};
SignalPair mOnEnterArea; SignalPair mOnEnterArea{};
SignalPair mOnLeaveArea; SignalPair mOnLeaveArea{};
}; };
public: public:
@ -739,6 +697,26 @@ private:
public: 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. * Retrieve the core instance.
*/ */
@ -846,12 +824,12 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the script source associated with a certain path in the scripts list. * 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. * 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. * Retrieve the scripts list. Should not be modified directly! Information purposes only.
@ -922,7 +900,7 @@ public:
*/ */
bool IsCircularLock(Uint32 lock) const 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, Float32 x, Float32 y, Float32 z, Int32 alpha, bool automatic,
Int32 header, LightObj & payload); 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, LightObj & NewVehicle(Int32 model, Int32 world, Float32 x, Float32 y, Float32 z,
Float32 angle, Int32 primary, Int32 secondary, Float32 angle, Int32 primary, Int32 secondary,
Int32 header, LightObj & payload); Int32 header, LightObj & payload);
@ -1082,13 +1053,13 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Entity retrievers. * Entity retrievers.
*/ */
BlipInst & GetBlip(Int32 id) { return m_Blips.at(id); } BlipInst & GetBlip(Int32 id) { return m_Blips.at(static_cast< size_t >(id)); }
CheckpointInst & GetCheckpoint(Int32 id) { return m_Checkpoints.at(id); } CheckpointInst & GetCheckpoint(Int32 id) { return m_Checkpoints.at(static_cast< size_t >(id)); }
KeybindInst & GetKeybind(Int32 id) { return m_Keybinds.at(id); } KeybindInst & GetKeybind(Int32 id) { return m_Keybinds.at(static_cast< size_t >(id)); }
ObjectInst & GetObject(Int32 id) { return m_Objects.at(id); } ObjectInst & GetObject(Int32 id) { return m_Objects.at(static_cast< size_t >(id)); }
PickupInst & GetPickup(Int32 id) { return m_Pickups.at(id); } PickupInst & GetPickup(Int32 id) { return m_Pickups.at(static_cast< size_t >(id)); }
PlayerInst & GetPlayer(Int32 id) { return m_Players.at(id); } PlayerInst & GetPlayer(Int32 id) { return m_Players.at(static_cast< size_t >(id)); }
VehicleInst & GetVehicle(Int32 id) { return m_Vehicles.at(id); } VehicleInst & GetVehicle(Int32 id) { return m_Vehicles.at(static_cast< size_t >(id)); }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Pool retrievers. * Pool retrievers.
@ -1471,7 +1442,7 @@ struct CoreState
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Backup the current core state and set the given state. * Backup the current core state and set the given state.
*/ */
CoreState(int s) explicit CoreState(int s)
: m_State(Core::Get().GetState()) : m_State(Core::Get().GetState())
{ {
Core::Get().SetState(s); Core::Get().SetState(s);

View File

@ -232,6 +232,8 @@ void Core::EmitServerFrame(Float32 elapsed_time)
//SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ServerFrame") //SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ServerFrame")
} }
#pragma clang diagnostic push
#pragma ide diagnostic ignored "MemberFunctionCanBeStatic"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Core::EmitPluginCommand(Uint32 command_identifier, CCStr message) void Core::EmitPluginCommand(Uint32 command_identifier, CCStr message)
{ {
@ -245,6 +247,7 @@ void Core::EmitPluginCommand(Uint32 command_identifier, CCStr message)
(void)message; (void)message;
#endif #endif
} }
#pragma clang diagnostic pop
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Core::EmitIncomingConnection(CStr player_name, size_t name_buffer_size, CCStr user_password, CCStr ip_address) 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; return;
} }
// Allocate a buffer with the received size // Allocate a buffer with the received size
Buffer b(size); Buffer b(static_cast< Buffer::SzType >(size));
// Replicate the data to the allocated buffer // 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 // Prepare an object for the obtained buffer
LightObj o; LightObj o;
// Attempt to create the requested buffer // Attempt to create the requested buffer

View File

@ -1,7 +1,6 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include "Logger.hpp" #include "Logger.hpp"
#include "Core.hpp" #include "Core.hpp"
#include "Base/Utility.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <ctime> #include <ctime>
@ -20,7 +19,8 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace { namespace {
#pragma clang diagnostic push
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Common windows colors. * Common windows colors.
*/ */
@ -42,7 +42,7 @@ enum
LC_LIGHT_MAGENTA = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE, LC_LIGHT_MAGENTA = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE,
LC_DARK_MAGENTA = FOREGROUND_RED | FOREGROUND_BLUE LC_DARK_MAGENTA = FOREGROUND_RED | FOREGROUND_BLUE
}; };
#pragma clang diagnostic pop
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Logging colors. * Logging colors.
*/ */
@ -209,7 +209,7 @@ static inline CCStr GetTimeStampStr()
Logger Logger::s_Inst; Logger Logger::s_Inst;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Logger::Logger() Logger::Logger() noexcept
: m_Buffer() : m_Buffer()
, m_ConsoleLevels(LOGL_ANY) , m_ConsoleLevels(LOGL_ANY)
, m_LogFileLevels(~LOGL_DBG) , m_LogFileLevels(~LOGL_DBG)
@ -332,9 +332,9 @@ void Logger::Terminate()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Logger::Release() 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 // Specify whether this is a sub message
sq_pushbool(vm, static_cast< SQBool >(sub)); sq_pushbool(vm, static_cast< SQBool >(sub));
// Make the function call and store the result // 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 // Default to non greedy callback
SQBool ret = SQFalse; SQBool ret = SQFalse;
// Did the function succeeded and is the returned value not null? // 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 // Lock the logger to prevent a cyclic dependency
m_CyclicLock = true; m_CyclicLock = true;
// Attempt to process the script callback first // 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 // Unlock the logger after the callback was invoked
m_CyclicLock = false; m_CyclicLock = false;
// Is the callback for this level greedy? // Is the callback for this level greedy?
@ -483,7 +484,7 @@ void Logger::Debug(CCStr fmt, va_list args)
// Valid line of code? // Valid line of code?
if (!code.empty()) 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()); , si.source, si.line, si.funcname ? si.funcname : _SC("unknown"), code.c_str());
fall_back = false; // No need to fall back to normal message! 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? // Should the regular message be shown instead?
if (fall_back) 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.source ? si.source : _SC("unknown")
, si.line , si.line
, si.funcname ? si.funcname : _SC("unknown")); , si.funcname ? si.funcname : _SC("unknown"));
@ -499,7 +500,8 @@ void Logger::Debug(CCStr fmt, va_list args)
} }
else 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 // Process the message in the buffer
Proccess(LOGL_ERR, true); Proccess(LOGL_ERR, true);
@ -508,17 +510,17 @@ void Logger::Debug(CCStr fmt, va_list args)
// Traceback the function call // Traceback the function call
for (Int32 level = 1; SQ_SUCCEEDED(sq_stackinfos(vm, level, &si)); ++level) 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.source ? si.source : _SC("unknown")
, si.line , si.line
, si.funcname ? si.funcname : _SC("unknown")); , si.funcname ? si.funcname : _SC("unknown"));
} }
// End the function call traceback // End the function call traceback
m_Buffer.WriteF(ret, "]"); m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "]");
// Process the message in the buffer // Process the message in the buffer
Proccess(LOGL_INF, true); Proccess(LOGL_INF, true);
// Temporary variables to retrieve stack information // Temporary variables to retrieve stack information
CSStr s_ = 0, name = 0; CSStr s_ = nullptr, name = nullptr;
SQInteger i_, seq = 0; SQInteger i_, seq = 0;
SQFloat f_; SQFloat f_;
SQUserPointer p_; SQUserPointer p_;
@ -530,41 +532,47 @@ void Logger::Debug(CCStr fmt, va_list args)
{ {
seq = 0; seq = 0;
// Display all locals in the current stack level // 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; ++seq;
switch(sq_gettype(vm, -1)) switch(sq_gettype(vm, -1))
{ {
case OT_NULL: 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; break;
case OT_INTEGER: case OT_INTEGER:
sq_getinteger(vm, -1, &i_); 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; break;
case OT_FLOAT: case OT_FLOAT:
sq_getfloat(vm, -1, &f_); 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; break;
case OT_USERPOINTER: case OT_USERPOINTER:
sq_getuserpointer(vm, -1, &p_); 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; break;
case OT_STRING: case OT_STRING:
sq_getstringandsize(vm, -1, &s_, &i_); sq_getstringandsize(vm, -1, &s_, &i_);
if (i_ > 0) { 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 { } 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; break;
case OT_TABLE: case OT_TABLE:
i_ = sq_getsize(vm, -1); 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; break;
case OT_ARRAY: case OT_ARRAY:
i_ = sq_getsize(vm, -1); 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; break;
case OT_CLOSURE: case OT_CLOSURE:
s_ = _SC("@anonymous"); s_ = _SC("@anonymous");
@ -574,7 +582,7 @@ void Logger::Debug(CCStr fmt, va_list args)
} }
sq_poptop(vm); 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; break;
case OT_NATIVECLOSURE: case OT_NATIVECLOSURE:
s_ = _SC("@unknown"); s_ = _SC("@unknown");
@ -584,16 +592,17 @@ void Logger::Debug(CCStr fmt, va_list args)
} }
sq_poptop(vm); 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; break;
case OT_GENERATOR: 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; break;
case OT_USERDATA: 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; break;
case OT_THREAD: 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; break;
case OT_CLASS: case OT_CLASS:
// Brute force our way into getting the name of this class without blowing up // 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 // Pop the dummy instance
sq_poptop(vm); 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; break;
case OT_INSTANCE: case OT_INSTANCE:
s_ = _SC("@unknown"); s_ = _SC("@unknown");
@ -621,7 +630,8 @@ void Logger::Debug(CCStr fmt, va_list args)
} }
sq_poptop(vm); 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; break;
case OT_WEAKREF: case OT_WEAKREF:
s_ = _SC("@unknown"); s_ = _SC("@unknown");
@ -638,21 +648,21 @@ void Logger::Debug(CCStr fmt, va_list args)
// Pop the referenced value // Pop the referenced value
sq_poptop(vm); 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; break;
case OT_BOOL: case OT_BOOL:
sq_getinteger(vm, -1, &i_); 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; break;
default: 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; break;
} }
sq_pop(vm, 1); sq_pop(vm, 1);
} }
} }
// End the variables information // End the variables information
m_Buffer.WriteF(ret, "]"); m_Buffer.WriteF(static_cast< Buffer::SzType >(ret), "]");
// Process the message in the buffer // Process the message in the buffer
Proccess(LOGL_INF, true); Proccess(LOGL_INF, true);
} }
@ -723,7 +733,7 @@ SQMOD_CLOG(cLogSFtl, LOGL_FTL, true)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm) 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? // Was the message value specified?
if (top <= 1) if (top <= 1)
{ {

View File

@ -19,15 +19,15 @@ namespace SqMod {
*/ */
enum LogLvl enum LogLvl
{ {
LOGL_NIL = (1 << 0), LOGL_NIL = (1u << 0u),
LOGL_DBG = (1 << 1), LOGL_DBG = (1u << 1u),
LOGL_USR = (1 << 2), LOGL_USR = (1u << 2u),
LOGL_SCS = (1 << 3), LOGL_SCS = (1u << 3u),
LOGL_INF = (1 << 4), LOGL_INF = (1u << 4u),
LOGL_WRN = (1 << 5), LOGL_WRN = (1u << 5u),
LOGL_ERR = (1 << 6), LOGL_ERR = (1u << 6u),
LOGL_FTL = (1 << 7), LOGL_FTL = (1u << 7u),
LOGL_ANY = 0xFF LOGL_ANY = 0xFFu
}; };
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@ -43,33 +43,13 @@ private:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Default constructor. * Default constructor.
*/ */
Logger(); Logger() noexcept;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
Logger(const Logger & o) = delete;
/* --------------------------------------------------------------------------------------------
* Move constructor. (disabled)
*/
Logger(Logger && o) = delete;
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Destructor. * Destructor.
*/ */
~Logger(); ~Logger();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
Logger & operator = (const Logger & o) = delete;
/* --------------------------------------------------------------------------------------------
* Move assignment operator. (disabled)
*/
Logger & operator = (Logger && o) = delete;
private: private:
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
@ -111,6 +91,26 @@ public:
return s_Inst; 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. * Flush buffered data and close the logging file.
*/ */

View File

@ -59,7 +59,7 @@ void DoReload()
return; // Don't even bother! return; // Don't even bother!
} }
// Make sure reloading is disabled at the end of this function // 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 // Tell the central core to attempt to reload
if (!Core::Get().Reload()) if (!Core::Get().Reload())
{ {
@ -80,7 +80,7 @@ void DoReload()
#define SQMOD_RELOAD_CHECK(exp) if (exp) 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 // Mark the initialization as successful by default
const CoreState cs(SQMOD_SUCCESS); 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! // The server still triggers callbacks and we deallocated everything!
const CallbackUnbinder cu; const CallbackUnbinder cu();
// Attempt to forward the event // Attempt to forward the event
try try
{ {
@ -507,6 +507,7 @@ static void OnPlayerActionChange(int32_t player_id, int32_t old_action, int32_t
case SQMOD_PLAYER_ACTION_EXITING_VEHICLE: case SQMOD_PLAYER_ACTION_EXITING_VEHICLE:
Core::Get().EmitActionDisembarking(player_id, old_action); Core::Get().EmitActionDisembarking(player_id, old_action);
break; break;
default: break;
} }
SQMOD_SV_EV_TRACEBACK("[TRACE>] OnPlayerActionChange") SQMOD_SV_EV_TRACEBACK("[TRACE>] OnPlayerActionChange")
} }

View File

@ -123,9 +123,9 @@
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* VCMP SDK VERSION CHECK. * VCMP SDK VERSION CHECK.
*/ */
#define SQMOD_SDK_MATCH(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_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_PRIOR(MJR, MNR) ((PLUGIN_API_MAJOR < (MJR)) && (PLUGIN_API_MINOR < (MNR)))
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* SQUIRREL FORWARD DECLARATIONS * SQUIRREL FORWARD DECLARATIONS
@ -436,9 +436,9 @@ enum EventType
enum EntityFlags enum EntityFlags
{ {
ENF_DEFAULT = (0), ENF_DEFAULT = (0),
ENF_OWNED = (1 << 1), ENF_OWNED = (1u << 1u),
ENF_LOCKED = (1 << 2), ENF_LOCKED = (1u << 2u),
ENF_AREA_TRACK = (1 << 3) 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_DECL_UNUSED_VAR(t, n, v) t n = v; (void)(n)
#define SQMOD_UNUSED_VAR(n) (void)(n) #define SQMOD_UNUSED_VAR(n) (void)(n)
#define VALID_ENTITY(e) (e >= 0) #define VALID_ENTITY(e) ((e) >= 0)
#define INVALID_ENTITY(e) (e < 0) #define INVALID_ENTITY(e) ((e) < 0)
#define VALID_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 INVALID_ENTITYEX(e, m) (((e) < 0) || ((e) >= (m)))
#define VALID_ENTITYGET(e) ((e >= 0) ? e : -1) #define VALID_ENTITYGET(e) (((e) >= 0) ? (e) : -1)
#define VALID_ENTITYGETEX(e, m) ((e >= 0) && (e < m) ? e : -1) #define VALID_ENTITYGETEX(e, m) (((e) >= 0) && ((e) < (m)) ? (e) : -1)
#define VALID_VEHCOL(e) ((e >= 0) && (e <= 94)) #define VALID_VEHCOL(e) (((e) >= 0) && ((e) <= 94))
#define INVALID_VEHCOL(e) ((e < 0) && (e > 94)) #define INVALID_VEHCOL(e) (((e) < 0) && ((e) > 94))
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* COLOR PACKING * COLOR PACKING
*/ */
#define SQMOD_PACK_RGB(r, g, b) static_cast< Uint32 >(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_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_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_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_ARGB(r, g, b) static_cast< Uint32 >(0u << 24u | (r) << 16u | (g) << 8u | (b))
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* GENERAL RESPONSES * GENERAL RESPONSES
@ -637,7 +637,7 @@ enum EntityType
#define SQMOD_SUCCESS 1 #define SQMOD_SUCCESS 1
#define SQMOD_FAILURE 0 #define SQMOD_FAILURE 0
#define SQMOD_UNKNOWN -1 #define SQMOD_UNKNOWN (-1)
#define SQMOD_TRUE 1 #define SQMOD_TRUE 1
#define SQMOD_FALSE 0 #define SQMOD_FALSE 0
#define SQMOD_NULL NULL #define SQMOD_NULL NULL
@ -676,18 +676,18 @@ enum EntityType
*/ */
#define SQMOD_CREATE_DEFAULT 0 #define SQMOD_CREATE_DEFAULT 0
#define SQMOD_CREATE_MANUAL -3 #define SQMOD_CREATE_MANUAL (-3)
#define SQMOD_CREATE_POOL -4 #define SQMOD_CREATE_POOL (-4)
#define SQMOD_CREATE_AUTOMATIC -5 #define SQMOD_CREATE_AUTOMATIC (-5)
#define SQMOD_CREATE_OVERWRITE -6 #define SQMOD_CREATE_OVERWRITE (-6)
#define SQMOD_CREATE_IMPORT -7 #define SQMOD_CREATE_IMPORT (-7)
#define SQMOD_DESTROY_DEFAULT 0 #define SQMOD_DESTROY_DEFAULT 0
#define SQMOD_DESTROY_MANUAL -3 #define SQMOD_DESTROY_MANUAL (-3)
#define SQMOD_DESTROY_POOL -4 #define SQMOD_DESTROY_POOL (-4)
#define SQMOD_DESTROY_AUTOMATIC -5 #define SQMOD_DESTROY_AUTOMATIC (-5)
#define SQMOD_DESTROY_OVERWRITE -6 #define SQMOD_DESTROY_OVERWRITE (-6)
#define SQMOD_DESTROY_CLEANUP -7 #define SQMOD_DESTROY_CLEANUP (-7)
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* MODEL ID LIMITS * MODEL ID LIMITS