mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-18 19:47:15 +01:00
Compare commits
8 Commits
131a3f6a62
...
8eb431ea8f
Author | SHA1 | Date | |
---|---|---|---|
|
8eb431ea8f | ||
|
7b7f974e42 | ||
|
0641de7920 | ||
|
e2e9d2c83f | ||
|
47519cb3f4 | ||
|
79b5641b9f | ||
|
2088a825e3 | ||
|
747586ecf3 |
@ -181,6 +181,7 @@ Core::Core() noexcept
|
|||||||
, m_LockUnloadSignal(false)
|
, m_LockUnloadSignal(false)
|
||||||
, m_EmptyInit(false)
|
, m_EmptyInit(false)
|
||||||
, m_Verbosity(1)
|
, m_Verbosity(1)
|
||||||
|
, m_ClientData()
|
||||||
, m_NullBlip()
|
, m_NullBlip()
|
||||||
, m_NullCheckpoint()
|
, m_NullCheckpoint()
|
||||||
, m_NullKeyBind()
|
, m_NullKeyBind()
|
||||||
@ -560,6 +561,8 @@ void Core::Terminate(bool shutdown)
|
|||||||
NullObject().Release();
|
NullObject().Release();
|
||||||
NullLightObj().Release();
|
NullLightObj().Release();
|
||||||
NullFunction().Release();
|
NullFunction().Release();
|
||||||
|
// Release client data buffer, if any
|
||||||
|
m_ClientData.Release();
|
||||||
// Release null entity instances
|
// Release null entity instances
|
||||||
m_NullBlip.Release();
|
m_NullBlip.Release();
|
||||||
m_NullCheckpoint.Release();
|
m_NullCheckpoint.Release();
|
||||||
@ -2846,6 +2849,12 @@ static bool SqDelVehicle(int32_t id, int32_t header, LightObj & payload)
|
|||||||
return Core::Get().DelVehicle(id, header, payload);
|
return Core::Get().DelVehicle(id, header, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static LightObj & SqGetClientDataBuffer()
|
||||||
|
{
|
||||||
|
return Core::Get().GetClientDataBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_Core(HSQUIRRELVM vm)
|
void Register_Core(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
@ -2894,6 +2903,7 @@ void Register_Core(HSQUIRRELVM vm)
|
|||||||
.Func(_SC("DestroyObject"), &SqDelObject)
|
.Func(_SC("DestroyObject"), &SqDelObject)
|
||||||
.Func(_SC("DestroyPickup"), &SqDelPickup)
|
.Func(_SC("DestroyPickup"), &SqDelPickup)
|
||||||
.Func(_SC("DestroyVehicle"), &SqDelVehicle)
|
.Func(_SC("DestroyVehicle"), &SqDelVehicle)
|
||||||
|
.Func(_SC("ClientDataBuffer"), &SqGetClientDataBuffer)
|
||||||
.Func(_SC("OnPreLoad"), &SqGetPreLoadEvent)
|
.Func(_SC("OnPreLoad"), &SqGetPreLoadEvent)
|
||||||
.Func(_SC("OnPostLoad"), &SqGetPostLoadEvent)
|
.Func(_SC("OnPostLoad"), &SqGetPostLoadEvent)
|
||||||
.Func(_SC("OnUnload"), &SqGetUnloadEvent)
|
.Func(_SC("OnUnload"), &SqGetUnloadEvent)
|
||||||
|
@ -104,6 +104,9 @@ private:
|
|||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
int32_t m_Verbosity; // Restrict the amount of outputted information.
|
int32_t m_Verbosity; // Restrict the amount of outputted information.
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
LightObj m_ClientData; // Currently processed client data buffer.
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
LightObj m_NullBlip; // Null Blips instance.
|
LightObj m_NullBlip; // Null Blips instance.
|
||||||
LightObj m_NullCheckpoint; // Null Checkpoints instance.
|
LightObj m_NullCheckpoint; // Null Checkpoints instance.
|
||||||
@ -383,6 +386,14 @@ public:
|
|||||||
return (!m_IncomingNameBuffer) ? _SC("") : m_IncomingNameBuffer;
|
return (!m_IncomingNameBuffer) ? _SC("") : m_IncomingNameBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the current client data buffer, if any.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetClientDataBuffer()
|
||||||
|
{
|
||||||
|
return m_ClientData;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieves a line of code from a certain source.
|
* Retrieves a line of code from a certain source.
|
||||||
*/
|
*/
|
||||||
|
@ -2213,18 +2213,25 @@ void Core::EmitClientScriptData(int32_t player_id, const uint8_t * data, size_t
|
|||||||
{
|
{
|
||||||
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ClientScriptData(%d, [byte stream], %" PRINT_SZ_FMT ")", player_id, size)
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ClientScriptData(%d, [byte stream], %" PRINT_SZ_FMT ")", player_id, size)
|
||||||
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
||||||
|
#ifndef VCMP_ENABLE_OFFICIAL
|
||||||
// Don't even bother if there's no one listening
|
// Don't even bother if there's no one listening
|
||||||
if (!(_player.mOnClientScriptData.first->IsEmpty()) || !(mOnClientScriptData.first->IsEmpty()))
|
if (!(_player.mOnClientScriptData.first->IsEmpty()) || !(mOnClientScriptData.first->IsEmpty()))
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
// Allocate a buffer with the received size
|
// Allocate a buffer with the received size
|
||||||
Buffer b(static_cast< Buffer::SzType >(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), static_cast< Buffer::SzType >(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(SqTypeIdentity< SqBuffer >{}, m_VM, std::move(b));
|
m_ClientData = LightObj(SqTypeIdentity< SqBuffer >{}, m_VM, std::move(b));
|
||||||
|
#ifdef VCMP_ENABLE_OFFICIAL
|
||||||
|
// Don't even bother if there's no one listening
|
||||||
|
if (!(_player.mOnClientScriptData.first->IsEmpty()) || !(mOnClientScriptData.first->IsEmpty()))
|
||||||
|
{
|
||||||
|
#endif
|
||||||
// Forward the event call
|
// Forward the event call
|
||||||
(*_player.mOnClientScriptData.first)(o, size);
|
(*_player.mOnClientScriptData.first)(m_ClientData, size);
|
||||||
(*mOnClientScriptData.first)(_player.mObj, o, size);
|
(*mOnClientScriptData.first)(_player.mObj, m_ClientData, size);
|
||||||
}
|
}
|
||||||
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ClientScriptData")
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ClientScriptData")
|
||||||
#ifdef VCMP_ENABLE_OFFICIAL
|
#ifdef VCMP_ENABLE_OFFICIAL
|
||||||
@ -2234,6 +2241,8 @@ void Core::EmitClientScriptData(int32_t player_id, const uint8_t * data, size_t
|
|||||||
ExecuteLegacyEvent(m_VM, _SC("onClientScriptData"), _player.mLgObj);
|
ExecuteLegacyEvent(m_VM, _SC("onClientScriptData"), _player.mLgObj);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// Discard the buffer instance, if any
|
||||||
|
m_ClientData.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef NULL_SQOBJ_ // don't need this anymore
|
#undef NULL_SQOBJ_ // don't need this anymore
|
||||||
|
@ -18,6 +18,7 @@ Routine::Time Routine::s_Last = 0;
|
|||||||
Routine::Time Routine::s_Prev = 0;
|
Routine::Time Routine::s_Prev = 0;
|
||||||
Routine::Interval Routine::s_Intervals[SQMOD_MAX_ROUTINES];
|
Routine::Interval Routine::s_Intervals[SQMOD_MAX_ROUTINES];
|
||||||
Routine::Instance Routine::s_Instances[SQMOD_MAX_ROUTINES];
|
Routine::Instance Routine::s_Instances[SQMOD_MAX_ROUTINES];
|
||||||
|
SQInteger Routine::s_Current = SQMOD_MAX_ROUTINES;
|
||||||
bool Routine::s_Silenced = false;
|
bool Routine::s_Silenced = false;
|
||||||
bool Routine::s_Persistent = false;
|
bool Routine::s_Persistent = false;
|
||||||
|
|
||||||
@ -48,11 +49,14 @@ void Routine::Process()
|
|||||||
// Have we completed the routine interval?
|
// Have we completed the routine interval?
|
||||||
if ((*itr) <= 0)
|
if ((*itr) <= 0)
|
||||||
{
|
{
|
||||||
|
s_Current = static_cast< SQInteger >(itr - s_Intervals);
|
||||||
// Execute and reset the elapsed time
|
// Execute and reset the elapsed time
|
||||||
(*itr) = s_Instances[itr - s_Intervals].Execute();
|
(*itr) = s_Instances[s_Current].Execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Clear currently executed routine
|
||||||
|
s_Current = SQMOD_MAX_ROUTINES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -535,6 +539,7 @@ void Register_Routine(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("Env"), &Routine::GetEnv, &Routine::SetEnv)
|
.Prop(_SC("Env"), &Routine::GetEnv, &Routine::SetEnv)
|
||||||
.Prop(_SC("Func"), &Routine::GetFunc, &Routine::SetFunc)
|
.Prop(_SC("Func"), &Routine::GetFunc, &Routine::SetFunc)
|
||||||
.Prop(_SC("Data"), &Routine::GetData, &Routine::SetData)
|
.Prop(_SC("Data"), &Routine::GetData, &Routine::SetData)
|
||||||
|
.Prop(_SC("Result"), &Routine::GetResult, &Routine::SetResult)
|
||||||
.Prop(_SC("Interval"), &Routine::GetInterval, &Routine::SetInterval)
|
.Prop(_SC("Interval"), &Routine::GetInterval, &Routine::SetInterval)
|
||||||
.Prop(_SC("Iterations"), &Routine::GetIterations, &Routine::SetIterations)
|
.Prop(_SC("Iterations"), &Routine::GetIterations, &Routine::SetIterations)
|
||||||
.Prop(_SC("Suspended"), &Routine::GetSuspended, &Routine::SetSuspended)
|
.Prop(_SC("Suspended"), &Routine::GetSuspended, &Routine::SetSuspended)
|
||||||
@ -543,6 +548,7 @@ void Register_Routine(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("Endure"), &Routine::GetEndure, &Routine::SetEndure)
|
.Prop(_SC("Endure"), &Routine::GetEndure, &Routine::SetEndure)
|
||||||
.Prop(_SC("Inactive"), &Routine::GetInactive)
|
.Prop(_SC("Inactive"), &Routine::GetInactive)
|
||||||
.Prop(_SC("Persistent"), &Routine::GetPersistent, &Routine::SetPersistent)
|
.Prop(_SC("Persistent"), &Routine::GetPersistent, &Routine::SetPersistent)
|
||||||
|
.Prop(_SC("Yields"), &Routine::GetYields, &Routine::SetYields)
|
||||||
.Prop(_SC("Terminated"), &Routine::GetTerminated)
|
.Prop(_SC("Terminated"), &Routine::GetTerminated)
|
||||||
.Prop(_SC("Arguments"), &Routine::GetArguments)
|
.Prop(_SC("Arguments"), &Routine::GetArguments)
|
||||||
// Member Methods
|
// Member Methods
|
||||||
@ -554,10 +560,12 @@ void Register_Routine(HSQUIRRELVM vm)
|
|||||||
.Func(_SC("SetQuiet"), &Routine::ApplyQuiet)
|
.Func(_SC("SetQuiet"), &Routine::ApplyQuiet)
|
||||||
.Func(_SC("SetEndure"), &Routine::ApplyEndure)
|
.Func(_SC("SetEndure"), &Routine::ApplyEndure)
|
||||||
.Func(_SC("SetPersistent"), &Routine::ApplyPersistent)
|
.Func(_SC("SetPersistent"), &Routine::ApplyPersistent)
|
||||||
|
.Func(_SC("SetYields"), &Routine::ApplyYields)
|
||||||
.Func(_SC("Terminate"), &Routine::Terminate)
|
.Func(_SC("Terminate"), &Routine::Terminate)
|
||||||
.Func(_SC("GetArgument"), &Routine::GetArgument)
|
.Func(_SC("GetArgument"), &Routine::GetArgument)
|
||||||
.Func(_SC("DropEnv"), &Routine::DropEnv)
|
.Func(_SC("DropEnv"), &Routine::DropEnv)
|
||||||
.Func(_SC("Restart"), &Routine::Restart)
|
.Func(_SC("Restart"), &Routine::Restart)
|
||||||
|
.StaticFunc(_SC("Current"), &Routine::GetCurrent)
|
||||||
.StaticFunc(_SC("UsedCount"), &Routine::GetUsed)
|
.StaticFunc(_SC("UsedCount"), &Routine::GetUsed)
|
||||||
.StaticFunc(_SC("AreSilenced"), &Routine::GetSilenced)
|
.StaticFunc(_SC("AreSilenced"), &Routine::GetSilenced)
|
||||||
.StaticFunc(_SC("SetSilenced"), &Routine::SetSilenced)
|
.StaticFunc(_SC("SetSilenced"), &Routine::SetSilenced)
|
||||||
|
@ -37,6 +37,7 @@ private:
|
|||||||
LightObj mFunc{}; // A reference to the managed function object.
|
LightObj mFunc{}; // A reference to the managed function object.
|
||||||
LightObj mInst{}; // Reference to the routine associated with this instance.
|
LightObj mInst{}; // Reference to the routine associated with this instance.
|
||||||
LightObj mData{}; // A reference to the arbitrary data associated with this instance.
|
LightObj mData{}; // A reference to the arbitrary data associated with this instance.
|
||||||
|
LightObj mResult{}; // A reference to the value returned by the callback on last invocation.
|
||||||
String mTag{}; // An arbitrary string which represents the tag.
|
String mTag{}; // An arbitrary string which represents the tag.
|
||||||
Iterator mIterations{0}; // Number of iterations before self destruct.
|
Iterator mIterations{0}; // Number of iterations before self destruct.
|
||||||
Interval mInterval{0}; // Interval between routine invocations.
|
Interval mInterval{0}; // Interval between routine invocations.
|
||||||
@ -46,6 +47,7 @@ private:
|
|||||||
bool mEndure{false}; // Whether this instance is allowed to terminate itself on errors.
|
bool mEndure{false}; // Whether this instance is allowed to terminate itself on errors.
|
||||||
bool mInactive{true}; // Whether this instance has finished all iterations.
|
bool mInactive{true}; // Whether this instance has finished all iterations.
|
||||||
bool mPersistent{false}; // Whether this instance should not reset when finished.
|
bool mPersistent{false}; // Whether this instance should not reset when finished.
|
||||||
|
bool mYields{false}; // Whether this instance may yield a value when callback is invoked.
|
||||||
uint8_t mArgc{0}; // The number of arguments that the routine must forward.
|
uint8_t mArgc{0}; // The number of arguments that the routine must forward.
|
||||||
Argument mArgv[14]{}; // The arguments that the routine must forward.
|
Argument mArgv[14]{}; // The arguments that the routine must forward.
|
||||||
|
|
||||||
@ -57,6 +59,7 @@ private:
|
|||||||
, mFunc()
|
, mFunc()
|
||||||
, mInst()
|
, mInst()
|
||||||
, mData()
|
, mData()
|
||||||
|
, mResult()
|
||||||
, mTag()
|
, mTag()
|
||||||
, mIterations(0)
|
, mIterations(0)
|
||||||
, mInterval(0)
|
, mInterval(0)
|
||||||
@ -66,6 +69,7 @@ private:
|
|||||||
, mEndure(false)
|
, mEndure(false)
|
||||||
, mInactive(true)
|
, mInactive(true)
|
||||||
, mPersistent(GetPersistency())
|
, mPersistent(GetPersistency())
|
||||||
|
, mYields(false)
|
||||||
, mArgc(0)
|
, mArgc(0)
|
||||||
, mArgv()
|
, mArgv()
|
||||||
{
|
{
|
||||||
@ -128,6 +132,7 @@ private:
|
|||||||
mFunc.Release();
|
mFunc.Release();
|
||||||
mInst.Release();
|
mInst.Release();
|
||||||
mData.Release();
|
mData.Release();
|
||||||
|
mResult.Release();
|
||||||
mIterations = 0;
|
mIterations = 0;
|
||||||
mInterval = 0;
|
mInterval = 0;
|
||||||
mInactive = true;
|
mInactive = true;
|
||||||
@ -168,9 +173,30 @@ private:
|
|||||||
// This routine is currently executing
|
// This routine is currently executing
|
||||||
mExecuting = true;
|
mExecuting = true;
|
||||||
// Make the function call and store the result
|
// Make the function call and store the result
|
||||||
const SQRESULT res = sq_call(vm, mArgc + 1, static_cast< SQBool >(false), static_cast< SQBool >(!mQuiet));
|
const SQRESULT res = sq_call(vm, mArgc + 1, static_cast< SQBool >(mYields), static_cast< SQBool >(!mQuiet));
|
||||||
// This routine has finished executing
|
// This routine has finished executing
|
||||||
mExecuting = false;
|
mExecuting = false;
|
||||||
|
// Should we look for a yielded value?
|
||||||
|
if (mYields)
|
||||||
|
{
|
||||||
|
// Release previous value, if any
|
||||||
|
if (!sq_isnull(mResult.mObj))
|
||||||
|
{
|
||||||
|
sq_release(vm, &(mResult.mObj));
|
||||||
|
}
|
||||||
|
// Attempt to retrieve the new value if possible
|
||||||
|
if (SQ_SUCCEEDED(res) && SQ_SUCCEEDED(sq_getstackobj(vm, -1, &(mResult.mObj))))
|
||||||
|
{
|
||||||
|
sq_addref(vm, &(mResult.mObj)); // Don't destroy once popped
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sq_resetobject(&(mResult.mObj)); // Discard anything so far
|
||||||
|
}
|
||||||
|
// Pop the returned value from the stack
|
||||||
|
sq_pop(vm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Pop the callback object from the stack
|
// Pop the callback object from the stack
|
||||||
sq_pop(vm, 1);
|
sq_pop(vm, 1);
|
||||||
// Validate the result
|
// Validate the result
|
||||||
@ -242,6 +268,7 @@ private:
|
|||||||
static Time s_Prev; // Previous time point.
|
static Time s_Prev; // Previous time point.
|
||||||
static Interval s_Intervals[SQMOD_MAX_ROUTINES]; // List of intervals to be processed.
|
static Interval s_Intervals[SQMOD_MAX_ROUTINES]; // List of intervals to be processed.
|
||||||
static Instance s_Instances[SQMOD_MAX_ROUTINES]; // List of routines to be executed.
|
static Instance s_Instances[SQMOD_MAX_ROUTINES]; // List of routines to be executed.
|
||||||
|
static SQInteger s_Current; // Currently executed routine index (SQMOD_MAX_ROUTINES if none).
|
||||||
static bool s_Silenced; // Error reporting independent from global setting.
|
static bool s_Silenced; // Error reporting independent from global setting.
|
||||||
static bool s_Persistent; // Whether all routines should be persistent by default.
|
static bool s_Persistent; // Whether all routines should be persistent by default.
|
||||||
|
|
||||||
@ -562,6 +589,22 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the value that the callback has yielded last invocation.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const LightObj & GetResult() const
|
||||||
|
{
|
||||||
|
return GetValid().mResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the value that the callback has yielded last invocation.
|
||||||
|
*/
|
||||||
|
void SetResult(const LightObj & value)
|
||||||
|
{
|
||||||
|
GetValid().mResult = value;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the execution interval.
|
* Retrieve the execution interval.
|
||||||
*/
|
*/
|
||||||
@ -728,6 +771,31 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* See whether the routine is yielding a value.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetYields() const
|
||||||
|
{
|
||||||
|
return GetValid().mYields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set whether the routine should be yielding values.
|
||||||
|
*/
|
||||||
|
void SetYields(bool toggle)
|
||||||
|
{
|
||||||
|
GetValid().mYields = toggle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set whether the routine should be yielding values.
|
||||||
|
*/
|
||||||
|
Routine & ApplyYields(bool toggle)
|
||||||
|
{
|
||||||
|
SetYields(toggle);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether the routine was terminated.
|
* See whether the routine was terminated.
|
||||||
*/
|
*/
|
||||||
@ -791,6 +859,14 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the currently executed routine, if any.
|
||||||
|
*/
|
||||||
|
static LightObj & GetCurrent()
|
||||||
|
{
|
||||||
|
return (s_Current != SQMOD_MAX_ROUTINES) ? s_Instances[s_Current].mInst : NullLightObj();
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See if error reporting is enabled for all newly created routines.
|
* See if error reporting is enabled for all newly created routines.
|
||||||
*/
|
*/
|
||||||
|
@ -817,7 +817,7 @@ void CPlayer::SetArmor(float amount) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t CPlayer::GetImmunity() const
|
uint32_t CPlayer::GetImmunity() const
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
@ -826,12 +826,12 @@ int32_t CPlayer::GetImmunity() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CPlayer::SetImmunity(int32_t flags)
|
void CPlayer::SetImmunity(uint32_t flags)
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const int32_t current = _Func->GetPlayerImmunityFlags(m_ID);
|
const uint32_t current = _Func->GetPlayerImmunityFlags(m_ID);
|
||||||
// Avoid property unwind from a recursive call
|
// Avoid property unwind from a recursive call
|
||||||
_Func->SetPlayerImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
_Func->SetPlayerImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
@ -840,7 +840,7 @@ void CPlayer::SetImmunity(int32_t flags)
|
|||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_IMMUNITY);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_IMMUNITY);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerImmunity(m_ID, current, flags);
|
Core::Get().EmitPlayerImmunity(m_ID, static_cast< int32_t >(current), static_cast< int32_t >(flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,7 +1035,7 @@ int32_t CPlayer::GetAction() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t CPlayer::GetGameKeys() const
|
uint32_t CPlayer::GetGameKeys() const
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
@ -1845,7 +1845,7 @@ void CPlayer::StartStreamEx(uint32_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t CPlayer::GetBufferCursor() const
|
uint32_t CPlayer::GetBufferCursor() const
|
||||||
{
|
{
|
||||||
return m_Buffer.Position();
|
return m_Buffer.Position();
|
||||||
}
|
}
|
||||||
|
@ -488,12 +488,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the immunity flags of the managed player entity.
|
* Retrieve the immunity flags of the managed player entity.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetImmunity() const;
|
SQMOD_NODISCARD uint32_t GetImmunity() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the immunity flags of the managed player entity.
|
* Modify the immunity flags of the managed player entity.
|
||||||
*/
|
*/
|
||||||
void SetImmunity(int32_t flags);
|
void SetImmunity(uint32_t flags);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the position of the managed player entity.
|
* Retrieve the position of the managed player entity.
|
||||||
@ -588,7 +588,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the game keys of the managed player entity.
|
* Retrieve the game keys of the managed player entity.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetGameKeys() const;
|
SQMOD_NODISCARD uint32_t GetGameKeys() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Embark the managed player entity into the specified vehicle entity.
|
* Embark the managed player entity into the specified vehicle entity.
|
||||||
@ -959,7 +959,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the current cursor position of the stream buffer.
|
* Retrieve the current cursor position of the stream buffer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetBufferCursor() const;
|
SQMOD_NODISCARD uint32_t GetBufferCursor() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the current cursor position of the stream buffer.
|
* Retrieve the current cursor position of the stream buffer.
|
||||||
|
@ -306,7 +306,7 @@ void CVehicle::Respawn() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t CVehicle::GetImmunity() const
|
uint32_t CVehicle::GetImmunity() const
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
@ -315,12 +315,12 @@ int32_t CVehicle::GetImmunity() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void CVehicle::SetImmunity(int32_t flags)
|
void CVehicle::SetImmunity(uint32_t flags)
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const int32_t current = _Func->GetVehicleImmunityFlags(m_ID);
|
const uint32_t current = _Func->GetVehicleImmunityFlags(m_ID);
|
||||||
// Avoid property unwind from a recursive call
|
// Avoid property unwind from a recursive call
|
||||||
_Func->SetVehicleImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
_Func->SetVehicleImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
@ -329,7 +329,7 @@ void CVehicle::SetImmunity(int32_t flags)
|
|||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_IMMUNITY);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_IMMUNITY);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleImmunity(m_ID, current, flags);
|
Core::Get().EmitVehicleImmunity(m_ID, static_cast< int32_t >(current), static_cast< int32_t >(flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,7 +1130,7 @@ void CVehicle::ResetHandlings() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t CVehicle::GetLightsData() const
|
uint32_t CVehicle::GetLightsData() const
|
||||||
{
|
{
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
|
@ -250,12 +250,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the immunity flags of the managed vehicle entity.
|
* Retrieve the immunity flags of the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetImmunity() const;
|
SQMOD_NODISCARD uint32_t GetImmunity() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the immunity flags of the managed vehicle entity.
|
* Modify the immunity flags of the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
void SetImmunity(int32_t flags);
|
void SetImmunity(uint32_t flags);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Explode the managed vehicle entity.
|
* Explode the managed vehicle entity.
|
||||||
@ -605,7 +605,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the lights data for the managed vehicle entity.
|
* Retrieve the lights data for the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetLightsData() const;
|
SQMOD_NODISCARD uint32_t GetLightsData() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the lights data for the managed vehicle entity.
|
* Modify the lights data for the managed vehicle entity.
|
||||||
|
@ -622,9 +622,9 @@ void Logger::DebugFv(HSQUIRRELVM vm, const char * fmt, va_list args)
|
|||||||
using namespace Sqrat;
|
using namespace Sqrat;
|
||||||
// We want to make sure these messages appear in succession
|
// We want to make sure these messages appear in succession
|
||||||
// So we will push them in bulk after generating them
|
// So we will push them in bulk after generating them
|
||||||
std::array< MsgPtr, 3 > messages{};
|
std::array< MsgPtr, 3 > messages{nullptr, nullptr, nullptr};
|
||||||
// Create a new message builder
|
// Create a new message builder
|
||||||
MsgPtr message(new Message(LOGL_ERR, true));
|
MsgPtr message = std::make_unique< Message >(LOGL_ERR, true);
|
||||||
// Used to acquire stack information
|
// Used to acquire stack information
|
||||||
SQStackInfos si;
|
SQStackInfos si;
|
||||||
// Write the given error message
|
// Write the given error message
|
||||||
@ -663,7 +663,7 @@ void Logger::DebugFv(HSQUIRRELVM vm, const char * fmt, va_list args)
|
|||||||
// Assign the error message
|
// Assign the error message
|
||||||
messages[0] = std::move(message);
|
messages[0] = std::move(message);
|
||||||
// Create a new message builder
|
// Create a new message builder
|
||||||
message = std::make_unique<Message>(LOGL_INF, true);
|
message = std::make_unique< Message >(LOGL_INF, true);
|
||||||
// Trace list (so it can be reused later in locals)
|
// Trace list (so it can be reused later in locals)
|
||||||
std::vector< std::string > locations;
|
std::vector< std::string > locations;
|
||||||
std::vector< std::string > closures;
|
std::vector< std::string > closures;
|
||||||
@ -687,7 +687,7 @@ void Logger::DebugFv(HSQUIRRELVM vm, const char * fmt, va_list args)
|
|||||||
// Assign the error message
|
// Assign the error message
|
||||||
messages[1] = std::move(message);
|
messages[1] = std::move(message);
|
||||||
// Create a new message builder
|
// Create a new message builder
|
||||||
message = std::make_unique<Message>(LOGL_INF, true);
|
message = std::make_unique< Message >(LOGL_INF, true);
|
||||||
// Temporary variables to retrieve stack information
|
// Temporary variables to retrieve stack information
|
||||||
const SQChar * s_ = nullptr, * name;
|
const SQChar * s_ = nullptr, * name;
|
||||||
SQInteger i_;
|
SQInteger i_;
|
||||||
@ -697,7 +697,7 @@ void Logger::DebugFv(HSQUIRRELVM vm, const char * fmt, va_list args)
|
|||||||
// Begin the local variables information
|
// Begin the local variables information
|
||||||
message->Append("Locals:\n[\n");
|
message->Append("Locals:\n[\n");
|
||||||
// Indentation string
|
// Indentation string
|
||||||
std::string indent;
|
std::string indent{};
|
||||||
// Whether current level includes trace
|
// Whether current level includes trace
|
||||||
bool traced = false;
|
bool traced = false;
|
||||||
// Process each stack level
|
// Process each stack level
|
||||||
@ -726,74 +726,74 @@ void Logger::DebugFv(HSQUIRRELVM vm, const char * fmt, va_list args)
|
|||||||
// Identify type
|
// Identify type
|
||||||
switch(sq_gettype(vm, -1))
|
switch(sq_gettype(vm, -1))
|
||||||
{
|
{
|
||||||
case OT_NULL:
|
case OT_NULL: {
|
||||||
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "NULL", name);
|
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "NULL", name);
|
||||||
break;
|
} break;
|
||||||
case OT_INTEGER:
|
case OT_INTEGER: {
|
||||||
sq_getinteger(vm, -1, &i_);
|
sq_getinteger(vm, -1, &i_);
|
||||||
message->AppendF("%s|- %-10s[%s] with value: %" PRINT_INT_FMT "\n", indent.c_str(), "INTEGER", name, i_);
|
message->AppendF("%s|- %-10s[%s] with value: %" PRINT_INT_FMT "\n", indent.c_str(), "INTEGER", name, i_);
|
||||||
break;
|
} break;
|
||||||
case OT_FLOAT:
|
case OT_FLOAT: {
|
||||||
sq_getfloat(vm, -1, &f_);
|
sq_getfloat(vm, -1, &f_);
|
||||||
message->AppendF("%s|- %-10s[%s] with value: %f\n", indent.c_str(), "FLOAT", name, f_);
|
message->AppendF("%s|- %-10s[%s] with value: %f\n", indent.c_str(), "FLOAT", name, f_);
|
||||||
break;
|
} break;
|
||||||
case OT_USERPOINTER:
|
case OT_USERPOINTER: {
|
||||||
sq_getuserpointer(vm, -1, &p_);
|
sq_getuserpointer(vm, -1, &p_);
|
||||||
message->AppendF("%s|- %-10s[%s] pointing at: %p\n", indent.c_str(), "POINTER", name, p_);
|
message->AppendF("%s|- %-10s[%s] pointing at: %p\n", indent.c_str(), "POINTER", 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) {
|
||||||
message->AppendF("%s|- %-10s[%s] of %" PRINT_INT_FMT " characters: %.*s\n", indent.c_str(), "STRING", name, i_, m_StringTruncate, s_);
|
message->AppendF("%s|- %-10s[%s] of %" PRINT_INT_FMT " characters: %.*s\n", indent.c_str(), "STRING", name, i_, m_StringTruncate, s_);
|
||||||
} else {
|
} else {
|
||||||
message->AppendF("%s|- %-10s[%s] empty\n", indent.c_str(), "STRING", level, name);
|
message->AppendF("%s|- %-10s[%s] empty\n", indent.c_str(), "STRING", level, name);
|
||||||
}
|
}
|
||||||
break;
|
} break;
|
||||||
case OT_TABLE:
|
case OT_TABLE: {
|
||||||
i_ = sq_getsize(vm, -1);
|
i_ = sq_getsize(vm, -1);
|
||||||
message->AppendF("%s|- %-10s[%s] with %" PRINT_INT_FMT " elements\n", indent.c_str(), "TABLE", name, i_);
|
message->AppendF("%s|- %-10s[%s] with %" PRINT_INT_FMT " elements\n", indent.c_str(), "TABLE", name, i_);
|
||||||
break;
|
} break;
|
||||||
case OT_ARRAY:
|
case OT_ARRAY: {
|
||||||
i_ = sq_getsize(vm, -1);
|
i_ = sq_getsize(vm, -1);
|
||||||
message->AppendF("%s|- %-10s[%s] with %" PRINT_INT_FMT " elements\n", indent.c_str(), "ARRAY", name, i_);
|
message->AppendF("%s|- %-10s[%s] with %" PRINT_INT_FMT " elements\n", indent.c_str(), "ARRAY", name, i_);
|
||||||
break;
|
} break;
|
||||||
case OT_CLOSURE:
|
case OT_CLOSURE: {
|
||||||
s_ = _SC("@anonymous");
|
s_ = _SC("@anonymous");
|
||||||
if (SQ_SUCCEEDED(sq_getclosurename(vm, -1))) {
|
if (SQ_SUCCEEDED(sq_getclosurename(vm, -1))) {
|
||||||
if (sq_gettype(vm, -1) != OT_NULL && SQ_SUCCEEDED(ssf_.Release(vm).Proc())) {
|
if (sq_gettype(vm, -1) != OT_NULL && SQ_SUCCEEDED(ssf_.Release(vm).Proc(false))) {
|
||||||
s_ = ssf_.mPtr;
|
s_ = ssf_.mPtr;
|
||||||
}
|
}
|
||||||
sq_poptop(vm);
|
sq_poptop(vm);
|
||||||
}
|
}
|
||||||
message->AppendF("%s|- %-10s[%s] with name: %s\n", indent.c_str(), "CLOSURE", name, s_);
|
message->AppendF("%s|- %-10s[%s] with name: %s\n", indent.c_str(), "CLOSURE", name, s_);
|
||||||
break;
|
} break;
|
||||||
case OT_NATIVECLOSURE:
|
case OT_NATIVECLOSURE: {
|
||||||
s_ = _SC("@unknown");
|
s_ = _SC("@unknown");
|
||||||
if (SQ_SUCCEEDED(sq_getclosurename(vm, -1))) {
|
if (SQ_SUCCEEDED(sq_getclosurename(vm, -1))) {
|
||||||
if (sq_gettype(vm, -1) != OT_NULL && SQ_SUCCEEDED(ssf_.Release(vm).Proc())) {
|
if (sq_gettype(vm, -1) != OT_NULL && SQ_SUCCEEDED(ssf_.Release(vm).Proc(false))) {
|
||||||
s_ = ssf_.mPtr;
|
s_ = ssf_.mPtr;
|
||||||
}
|
}
|
||||||
sq_poptop(vm);
|
sq_poptop(vm);
|
||||||
}
|
}
|
||||||
message->AppendF("%s|- %-10s[%s] with name: %s\n", indent.c_str(), "NCLOSURE", name, s_);
|
message->AppendF("%s|- %-10s[%s] with name: %s\n", indent.c_str(), "NCLOSURE", name, s_);
|
||||||
break;
|
} break;
|
||||||
case OT_GENERATOR:
|
case OT_GENERATOR: {
|
||||||
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "GENERATOR", name);
|
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "GENERATOR", name);
|
||||||
break;
|
} break;
|
||||||
case OT_USERDATA:
|
case OT_USERDATA: {
|
||||||
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "USERDATA", name);
|
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "USERDATA", name);
|
||||||
break;
|
} break;
|
||||||
case OT_THREAD:
|
case OT_THREAD: {
|
||||||
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "THREAD", name);
|
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "THREAD", 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
|
||||||
s_ = _SC("@unknown");
|
s_ = _SC("@unknown");
|
||||||
// Create a dummy, non-constructed instance and hope `_typeof` doesn't rely on member variables
|
// Create a dummy, non-constructed instance and hope `_typeof` doesn't rely on member variables
|
||||||
if (SQ_SUCCEEDED(sq_createinstance(vm, -1))) {
|
if (SQ_SUCCEEDED(sq_createinstance(vm, -1))) {
|
||||||
// Attempt a `_typeof` on that instance
|
// Attempt a `_typeof` on that instance
|
||||||
if (SQ_SUCCEEDED(sq_typeof(vm, -1))) {
|
if (SQ_SUCCEEDED(sq_typeof(vm, -1))) {
|
||||||
if (SQ_SUCCEEDED(ssf_.Release(vm).Proc())) {
|
if (SQ_SUCCEEDED(ssf_.Release(vm).Proc(false))) {
|
||||||
s_ = ssf_.mPtr;
|
s_ = ssf_.mPtr;
|
||||||
}
|
}
|
||||||
// Pop the name object
|
// Pop the name object
|
||||||
@ -803,24 +803,24 @@ void Logger::DebugFv(HSQUIRRELVM vm, const char * fmt, va_list args)
|
|||||||
sq_poptop(vm);
|
sq_poptop(vm);
|
||||||
}
|
}
|
||||||
message->AppendF("%s|- %-10s[%s] of type: %s\n", indent.c_str(), "CLASS", name, s_);
|
message->AppendF("%s|- %-10s[%s] of type: %s\n", indent.c_str(), "CLASS", name, s_);
|
||||||
break;
|
} break;
|
||||||
case OT_INSTANCE:
|
case OT_INSTANCE: {
|
||||||
s_ = _SC("@unknown");
|
s_ = _SC("@unknown");
|
||||||
if (SQ_SUCCEEDED(sq_typeof(vm, -1))) {
|
if (SQ_SUCCEEDED(sq_typeof(vm, -1))) {
|
||||||
if (SQ_SUCCEEDED(ssf_.Release(vm).Proc())) {
|
if (SQ_SUCCEEDED(ssf_.Release(vm).Proc(false))) {
|
||||||
s_ = ssf_.mPtr;
|
s_ = ssf_.mPtr;
|
||||||
}
|
}
|
||||||
sq_poptop(vm);
|
sq_poptop(vm);
|
||||||
}
|
}
|
||||||
message->AppendF("%s|- %-10s[%s] of type: %s\n", indent.c_str(), "INSTANCE", name, s_);
|
message->AppendF("%s|- %-10s[%s] of type: %s\n", indent.c_str(), "INSTANCE", name, s_);
|
||||||
break;
|
} break;
|
||||||
case OT_WEAKREF:
|
case OT_WEAKREF: {
|
||||||
s_ = _SC("@unknown");
|
s_ = _SC("@unknown");
|
||||||
// Attempt to grab the value pointed by the weak reference
|
// Attempt to grab the value pointed by the weak reference
|
||||||
if (SQ_SUCCEEDED(sq_getweakrefval(vm, -1))) {
|
if (SQ_SUCCEEDED(sq_getweakrefval(vm, -1))) {
|
||||||
// Attempt a `_typeof` on that instance
|
// Attempt a `_typeof` on that instance
|
||||||
if (SQ_SUCCEEDED(sq_typeof(vm, -1))) {
|
if (SQ_SUCCEEDED(sq_typeof(vm, -1))) {
|
||||||
if (SQ_SUCCEEDED(ssf_.Release(vm).Proc())) {
|
if (SQ_SUCCEEDED(ssf_.Release(vm).Proc(false))) {
|
||||||
s_ = ssf_.mPtr;
|
s_ = ssf_.mPtr;
|
||||||
}
|
}
|
||||||
// Pop the name object
|
// Pop the name object
|
||||||
@ -830,14 +830,14 @@ void Logger::DebugFv(HSQUIRRELVM vm, const char * fmt, va_list args)
|
|||||||
sq_poptop(vm);
|
sq_poptop(vm);
|
||||||
}
|
}
|
||||||
message->AppendF("%s|- %-10s[%s] of type: %s\n", indent.c_str(), "WEAKREF", name, s_);
|
message->AppendF("%s|- %-10s[%s] of type: %s\n", indent.c_str(), "WEAKREF", name, s_);
|
||||||
break;
|
} break;
|
||||||
case OT_BOOL:
|
case OT_BOOL: {
|
||||||
sq_getinteger(vm, -1, &i_);
|
sq_getinteger(vm, -1, &i_);
|
||||||
message->AppendF("%s|- %-10s[%s] with value: %s\n", indent.c_str(), "BOOL", name, i_ ? _SC("true") : _SC("false"));
|
message->AppendF("%s|- %-10s[%s] with value: %s\n", indent.c_str(), "BOOL", name, i_ ? _SC("true") : _SC("false"));
|
||||||
break;
|
} break;
|
||||||
default:
|
default: {
|
||||||
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "UNKNOWN", name);
|
message->AppendF("%s|- %-10s[%s]\n", indent.c_str(), "UNKNOWN", name);
|
||||||
break;
|
} break;
|
||||||
}
|
}
|
||||||
sq_pop(vm, 1);
|
sq_pop(vm, 1);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "Misc/Official.hpp"
|
#include "Misc/Official.hpp"
|
||||||
#include "Base/Vector2.hpp"
|
#include "Base/Vector2.hpp"
|
||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
#include "Library/IO/Buffer.hpp"
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Entity.hpp"
|
#include "Core/Entity.hpp"
|
||||||
#include "Core.hpp"
|
#include "Core.hpp"
|
||||||
@ -697,7 +698,7 @@ struct LgPlayer
|
|||||||
SQMOD_NODISCARD int GetPing() const { return Get().GetPing(); }
|
SQMOD_NODISCARD int GetPing() const { return Get().GetPing(); }
|
||||||
SQMOD_NODISCARD float GetHealth() const { return Get().GetHealth(); }
|
SQMOD_NODISCARD float GetHealth() const { return Get().GetHealth(); }
|
||||||
SQMOD_NODISCARD float GetArmour() const { return Get().GetArmor(); }
|
SQMOD_NODISCARD float GetArmour() const { return Get().GetArmor(); }
|
||||||
SQMOD_NODISCARD int32_t GetImmunity() const { return Get().GetImmunity(); }
|
SQMOD_NODISCARD uint32_t GetImmunity() const { return Get().GetImmunity(); }
|
||||||
SQMOD_NODISCARD float GetHeading() const { return Get().GetHeading(); }
|
SQMOD_NODISCARD float GetHeading() const { return Get().GetHeading(); }
|
||||||
SQMOD_NODISCARD LgVehicle * GetVehicle() const
|
SQMOD_NODISCARD LgVehicle * GetVehicle() const
|
||||||
{ const int id = _Func->GetPlayerVehicleId(GetIdentifier()); return VALID_ENTITYEX(id, SQMOD_VEHICLE_POOL) ? Core::Get().GetVehicle(id).mLgInst : nullptr; }
|
{ const int id = _Func->GetPlayerVehicleId(GetIdentifier()); return VALID_ENTITYEX(id, SQMOD_VEHICLE_POOL) ? Core::Get().GetVehicle(id).mLgInst : nullptr; }
|
||||||
@ -718,7 +719,7 @@ struct LgPlayer
|
|||||||
SQMOD_NODISCARD bool Typing() const { return Get().IsTyping(); }
|
SQMOD_NODISCARD bool Typing() const { return Get().IsTyping(); }
|
||||||
SQMOD_NODISCARD bool ShowingMarkers() const { return _Func->GetPlayerOption(GetIdentifier(), vcmpPlayerOptionShowMarkers) >= 1; }
|
SQMOD_NODISCARD bool ShowingMarkers() const { return _Func->GetPlayerOption(GetIdentifier(), vcmpPlayerOptionShowMarkers) >= 1; }
|
||||||
SQMOD_NODISCARD bool GetCameraLocked() const { return Get().IsCameraLocked(); }
|
SQMOD_NODISCARD bool GetCameraLocked() const { return Get().IsCameraLocked(); }
|
||||||
SQMOD_NODISCARD int GetKey() const { return Get().GetKey(); }
|
SQMOD_NODISCARD uint32_t GetKey() const { return Get().GetKey(); }
|
||||||
SQMOD_NODISCARD bool GetAwayStatus() const { return Get().IsAway(); }
|
SQMOD_NODISCARD bool GetAwayStatus() const { return Get().IsAway(); }
|
||||||
SQMOD_NODISCARD LgPlayer * GetSpectateTarget() const
|
SQMOD_NODISCARD LgPlayer * GetSpectateTarget() const
|
||||||
{ const int id = _Func->GetPlayerSpectateTarget(GetIdentifier()); return VALID_ENTITYEX(id, SQMOD_PLAYER_POOL) ? Core::Get().GetPlayer(id).mLgInst : nullptr; }
|
{ const int id = _Func->GetPlayerSpectateTarget(GetIdentifier()); return VALID_ENTITYEX(id, SQMOD_PLAYER_POOL) ? Core::Get().GetPlayer(id).mLgInst : nullptr; }
|
||||||
@ -733,7 +734,7 @@ struct LgPlayer
|
|||||||
SQMOD_NODISCARD bool GetPlayerOnFireStatus() const { return Get().IsBurning(); }
|
SQMOD_NODISCARD bool GetPlayerOnFireStatus() const { return Get().IsBurning(); }
|
||||||
SQMOD_NODISCARD bool GetPlayerCrouchStatus() const { return Get().IsCrouched(); }
|
SQMOD_NODISCARD bool GetPlayerCrouchStatus() const { return Get().IsCrouched(); }
|
||||||
SQMOD_NODISCARD int GetPlayerAction() const { return Get().GetAction(); }
|
SQMOD_NODISCARD int GetPlayerAction() const { return Get().GetAction(); }
|
||||||
SQMOD_NODISCARD int GetPlayerGameKeys() const { return Get().GetGameKeys(); }
|
SQMOD_NODISCARD uint32_t GetPlayerGameKeys() const { return Get().GetGameKeys(); }
|
||||||
SQMOD_NODISCARD LgVector GetPlayerAimPos() const { return LgVector(Get().GetAimPosition()); }
|
SQMOD_NODISCARD LgVector GetPlayerAimPos() const { return LgVector(Get().GetAimPosition()); }
|
||||||
SQMOD_NODISCARD LgVector GetPlayerAimDir() const { return LgVector(Get().GetAimDirection()); }
|
SQMOD_NODISCARD LgVector GetPlayerAimDir() const { return LgVector(Get().GetAimDirection()); }
|
||||||
SQMOD_NODISCARD int GetWantedLevel() const { return Get().GetWantedLevel(); }
|
SQMOD_NODISCARD int GetWantedLevel() const { return Get().GetWantedLevel(); }
|
||||||
@ -825,9 +826,12 @@ struct LgVehicle
|
|||||||
}
|
}
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
SQMOD_NODISCARD static int32_t GetDriverID(int32_t id) {
|
SQMOD_NODISCARD static int32_t GetDriverID(int32_t id) {
|
||||||
for(int i = 0, n = _Func->GetMaxPlayers(); i < n; ++i) {
|
for(uint32_t i = 0, n = _Func->GetMaxPlayers(); i < n; ++i) {
|
||||||
if(_Func->IsPlayerConnected(i)) {
|
if(_Func->IsPlayerConnected(static_cast< int32_t >(i))) {
|
||||||
if(_Func->GetPlayerVehicleId(i) == id && _Func->GetPlayerInVehicleSlot(i) == 0) return i;
|
if(_Func->GetPlayerVehicleId(static_cast< int32_t >(i)) == id &&
|
||||||
|
_Func->GetPlayerInVehicleSlot(static_cast< int32_t >(i)) == 0) {
|
||||||
|
return static_cast< int32_t >(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -845,7 +849,7 @@ struct LgVehicle
|
|||||||
void SetColour2(int colour2) const { Get().SetSecondaryColor(colour2); }
|
void SetColour2(int colour2) const { Get().SetSecondaryColor(colour2); }
|
||||||
void SetLocked(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionDoorsLocked, static_cast< uint8_t >(toggle)); }
|
void SetLocked(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionDoorsLocked, static_cast< uint8_t >(toggle)); }
|
||||||
void SetDamage(uint32_t damage) const { Get().SetDamageData(damage); }
|
void SetDamage(uint32_t damage) const { Get().SetDamageData(damage); }
|
||||||
void SetLightFlags(uint32_t flags) const { Get().SetLightsData(flags); }
|
void SetLightFlags(int32_t flags) const { Get().SetLightsData(flags); }
|
||||||
void SetAlarm(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionAlarm, static_cast< uint8_t >(toggle)); }
|
void SetAlarm(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionAlarm, static_cast< uint8_t >(toggle)); }
|
||||||
void SetSiren(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionSiren, static_cast< uint8_t >(toggle)); }
|
void SetSiren(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionSiren, static_cast< uint8_t >(toggle)); }
|
||||||
void SetLights(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionLights, static_cast< uint8_t >(toggle)); }
|
void SetLights(bool toggle) const { _Func->SetVehicleOption(GetIdentifier(), vcmpVehicleOptionLights, static_cast< uint8_t >(toggle)); }
|
||||||
@ -869,7 +873,7 @@ struct LgVehicle
|
|||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
SQMOD_NODISCARD int GetWorld() const { return Get().GetWorld(); }
|
SQMOD_NODISCARD int GetWorld() const { return Get().GetWorld(); }
|
||||||
SQMOD_NODISCARD int GetModel() const { return Get().GetModel(); }
|
SQMOD_NODISCARD int GetModel() const { return Get().GetModel(); }
|
||||||
SQMOD_NODISCARD int GetImmunity() const { return Get().GetImmunity(); }
|
SQMOD_NODISCARD uint32_t GetImmunity() const { return Get().GetImmunity(); }
|
||||||
SQMOD_NODISCARD LgEntityVector GetPosition() const
|
SQMOD_NODISCARD LgEntityVector GetPosition() const
|
||||||
{ return LgEntityVector(mID, LgEntityType::Vehicle, LgVehicleVectorFlag::Pos, Get().GetPosition()); }
|
{ return LgEntityVector(mID, LgEntityType::Vehicle, LgVehicleVectorFlag::Pos, Get().GetPosition()); }
|
||||||
SQMOD_NODISCARD LgEntityVector GetSpawnPos() const
|
SQMOD_NODISCARD LgEntityVector GetSpawnPos() const
|
||||||
@ -1259,7 +1263,7 @@ static void LgSetServerName(StackStrF & str) { _Func->SetServerName(str.mPtr); }
|
|||||||
static void LgSetMaxPlayers(int newMaxPlayers) { _Func->SetMaxPlayers(static_cast< uint32_t >(newMaxPlayers)); }
|
static void LgSetMaxPlayers(int newMaxPlayers) { _Func->SetMaxPlayers(static_cast< uint32_t >(newMaxPlayers)); }
|
||||||
static void LgSetServerPassword(StackStrF & str) { _Func->SetServerPassword(str.mPtr); }
|
static void LgSetServerPassword(StackStrF & str) { _Func->SetServerPassword(str.mPtr); }
|
||||||
static void LgSetGameModeText(StackStrF & str) { _Func->SetGameModeText(str.mPtr); }
|
static void LgSetGameModeText(StackStrF & str) { _Func->SetGameModeText(str.mPtr); }
|
||||||
static void LgSetTimeRate(uint32_t rate) { _Func->SetTimeRate(rate); }
|
static void LgSetTimeRate(int32_t rate) { _Func->SetTimeRate(rate); }
|
||||||
static void LgSetHour(int hour) { _Func->SetHour( hour ); }
|
static void LgSetHour(int hour) { _Func->SetHour( hour ); }
|
||||||
static void LgSetMinute(int minute) { _Func->SetMinute(minute); }
|
static void LgSetMinute(int minute) { _Func->SetMinute(minute); }
|
||||||
static void LgSetTime(int hour, int minute) { LgSetHour(hour); LgSetMinute(minute); }
|
static void LgSetTime(int hour, int minute) { LgSetHour(hour); LgSetMinute(minute); }
|
||||||
@ -1290,7 +1294,7 @@ SQMOD_NODISCARD static SQInteger LgGetGameModeText(HSQUIRRELVM vm) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQMOD_NODISCARD static int LgGetMaxPlayers() { return _Func->GetMaxPlayers(); }
|
SQMOD_NODISCARD static uint32_t LgGetMaxPlayers() { return _Func->GetMaxPlayers(); }
|
||||||
SQMOD_NODISCARD static uint32_t LgGetTimeRate() { return static_cast< uint32_t >(_Func->GetTimeRate()); }
|
SQMOD_NODISCARD static uint32_t LgGetTimeRate() { return static_cast< uint32_t >(_Func->GetTimeRate()); }
|
||||||
SQMOD_NODISCARD static int LgGetHour() { return _Func->GetHour(); }
|
SQMOD_NODISCARD static int LgGetHour() { return _Func->GetHour(); }
|
||||||
SQMOD_NODISCARD static int LgGetMinute() { return _Func->GetMinute(); }
|
SQMOD_NODISCARD static int LgGetMinute() { return _Func->GetMinute(); }
|
||||||
@ -2245,7 +2249,7 @@ struct LgStream {
|
|||||||
length = static_cast< uint16_t >(MAX_SIZE - m_OutputStreamPosition);
|
length = static_cast< uint16_t >(MAX_SIZE - m_OutputStreamPosition);
|
||||||
m_OutputStreamError = true;
|
m_OutputStreamError = true;
|
||||||
}
|
}
|
||||||
uint16_t lengthBE = static_cast< uint16_t >(((length >> 8u) & 0xFFu) | ((length & 0xFFu) << 8u));
|
auto lengthBE = static_cast< uint16_t >(((length >> 8u) & 0xFFu) | ((length & 0xFFu) << 8u));
|
||||||
Write(&lengthBE, sizeof(lengthBE));
|
Write(&lengthBE, sizeof(lengthBE));
|
||||||
Write(value.mPtr, length);
|
Write(value.mPtr, length);
|
||||||
}
|
}
|
||||||
@ -2310,6 +2314,17 @@ struct LgStream {
|
|||||||
m_InputStreamPosition += length;
|
m_InputStreamPosition += length;
|
||||||
return LightObj(m_Buffer, static_cast< SQInteger >(length));
|
return LightObj(m_Buffer, static_cast< SQInteger >(length));
|
||||||
}
|
}
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
static LightObj CloneInputToBuffer() {
|
||||||
|
return LightObj(SqTypeIdentity< SqBuffer >{}, SqVM(), Buffer(m_Buffer,
|
||||||
|
static_cast< Buffer::SzType >(m_InputStreamSize),
|
||||||
|
static_cast< Buffer::SzType >(m_InputStreamPosition)));
|
||||||
|
}
|
||||||
|
static LightObj CloneOutputToBuffer() {
|
||||||
|
return LightObj(SqTypeIdentity< SqBuffer >{}, SqVM(), Buffer(m_Buffer,
|
||||||
|
static_cast< Buffer::SzType >(m_OutputStreamEnd),
|
||||||
|
static_cast< Buffer::SzType >(m_OutputStreamPosition)));
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
static bool CanWrite(size_t size) { return (size <= (MAX_SIZE - m_OutputStreamPosition)); }
|
static bool CanWrite(size_t size) { return (size <= (MAX_SIZE - m_OutputStreamPosition)); }
|
||||||
@ -2331,28 +2346,28 @@ private:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
static uint8_t m_InputStreamData[MAX_SIZE];
|
static uint8_t m_InputStreamData[MAX_SIZE];
|
||||||
static size_t m_InputStreamSize;
|
static size_t m_InputStreamSize;
|
||||||
static size_t m_InputStreamPosition;
|
static size_t m_InputStreamPosition;
|
||||||
static bool m_InputStreamError;
|
static bool m_InputStreamError;
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
static uint8_t m_OutputStreamData[MAX_SIZE];
|
static uint8_t m_OutputStreamData[MAX_SIZE];
|
||||||
static size_t m_OutputStreamPosition;
|
static size_t m_OutputStreamPosition;
|
||||||
static size_t m_OutputStreamEnd;
|
static size_t m_OutputStreamEnd;
|
||||||
static bool m_OutputStreamError;
|
static bool m_OutputStreamError;
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
static SQChar m_Buffer[MAX_SIZE];
|
static SQChar m_Buffer[MAX_SIZE];
|
||||||
};
|
};
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
uint8_t LgStream::m_InputStreamData[LgStream::MAX_SIZE];
|
uint8_t LgStream::m_InputStreamData[LgStream::MAX_SIZE]{};
|
||||||
size_t LgStream::m_InputStreamSize;
|
size_t LgStream::m_InputStreamSize{0};
|
||||||
size_t LgStream::m_InputStreamPosition;
|
size_t LgStream::m_InputStreamPosition{0};
|
||||||
bool LgStream::m_InputStreamError;
|
bool LgStream::m_InputStreamError{false};
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
uint8_t LgStream::m_OutputStreamData[LgStream::MAX_SIZE];
|
uint8_t LgStream::m_OutputStreamData[LgStream::MAX_SIZE]{};
|
||||||
size_t LgStream::m_OutputStreamEnd;
|
size_t LgStream::m_OutputStreamEnd{0};
|
||||||
size_t LgStream::m_OutputStreamPosition;
|
size_t LgStream::m_OutputStreamPosition{0};
|
||||||
bool LgStream::m_OutputStreamError;
|
bool LgStream::m_OutputStreamError{false};
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQChar LgStream::m_Buffer[LgStream::MAX_SIZE];
|
SQChar LgStream::m_Buffer[LgStream::MAX_SIZE];
|
||||||
|
|
||||||
@ -2383,6 +2398,8 @@ void Register_Official_Stream(HSQUIRRELVM vm)
|
|||||||
.StaticFunc(_SC("ReadInt"), &LgStream::ReadInt)
|
.StaticFunc(_SC("ReadInt"), &LgStream::ReadInt)
|
||||||
.StaticFunc(_SC("ReadFloat"), &LgStream::ReadFloat)
|
.StaticFunc(_SC("ReadFloat"), &LgStream::ReadFloat)
|
||||||
.StaticFunc(_SC("ReadString"), &LgStream::ReadString)
|
.StaticFunc(_SC("ReadString"), &LgStream::ReadString)
|
||||||
|
.StaticFunc(_SC("CloneInputToBuffer"), &LgStream::CloneInputToBuffer)
|
||||||
|
.StaticFunc(_SC("CloneOutputToBuffer"), &LgStream::CloneOutputToBuffer)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
vendor/SAJSON/sajson.cpp
vendored
6
vendor/SAJSON/sajson.cpp
vendored
@ -1,7 +1 @@
|
|||||||
#include <sajson.h>
|
#include <sajson.h>
|
||||||
|
|
||||||
namespace sajson {
|
|
||||||
namespace internal {
|
|
||||||
//template <> const uint8_t globals_struct<void>::parse_flags[256];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user