mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Fix bug in entity initialization which was pushing a null pointer on the stack instead of the actual instance.
Player instance initialization was missing.
This commit is contained in:
parent
e7bb68d76c
commit
135484e467
@ -74,7 +74,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
BlipInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr)
|
||||
BlipInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
@ -143,7 +143,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
CheckpointInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr)
|
||||
CheckpointInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
@ -207,7 +207,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
KeybindInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr)
|
||||
KeybindInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
@ -275,7 +275,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
ObjectInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr)
|
||||
ObjectInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
@ -340,7 +340,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
PickupInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr)
|
||||
PickupInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
@ -407,7 +407,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
PlayerInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr)
|
||||
PlayerInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
@ -558,7 +558,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
VehicleInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr)
|
||||
VehicleInst() : mID(-1), mFlags(ENF_DEFAULT), mInst(nullptr), mObj()
|
||||
{
|
||||
ResetInstance();
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ Core::BlipInst & Core::AllocBlip(Int32 id, bool owned, Int32 header, LightObj &
|
||||
// Instantiate the entity manager
|
||||
DeleteGuard< CBlip > dg(new CBlip(id));
|
||||
// Create the script object
|
||||
inst.mObj = LightObj(inst.mInst, m_VM);
|
||||
inst.mObj = LightObj(dg.Get(), m_VM);
|
||||
// Store the manager instance itself
|
||||
inst.mInst = dg.Get();
|
||||
// The instance is now managed by the script
|
||||
@ -201,7 +201,7 @@ Core::CheckpointInst & Core::AllocCheckpoint(Int32 id, bool owned, Int32 header,
|
||||
// Instantiate the entity manager
|
||||
DeleteGuard< CCheckpoint > dg(new CCheckpoint(id));
|
||||
// Create the script object
|
||||
inst.mObj = LightObj(inst.mInst, m_VM);
|
||||
inst.mObj = LightObj(dg.Get(), m_VM);
|
||||
// Store the manager instance itself
|
||||
inst.mInst = dg.Get();
|
||||
// The instance is now managed by the script
|
||||
@ -250,7 +250,7 @@ Core::KeybindInst & Core::AllocKeybind(Int32 id, bool owned, Int32 header, Light
|
||||
// Instantiate the entity manager
|
||||
DeleteGuard< CKeybind > dg(new CKeybind(id));
|
||||
// Create the script object
|
||||
inst.mObj = LightObj(inst.mInst, m_VM);
|
||||
inst.mObj = LightObj(dg.Get(), m_VM);
|
||||
// Store the manager instance itself
|
||||
inst.mInst = dg.Get();
|
||||
// The instance is now managed by the script
|
||||
@ -299,7 +299,7 @@ Core::ObjectInst & Core::AllocObject(Int32 id, bool owned, Int32 header, LightOb
|
||||
// Instantiate the entity manager
|
||||
DeleteGuard< CObject > dg(new CObject(id));
|
||||
// Create the script object
|
||||
inst.mObj = LightObj(inst.mInst, m_VM);
|
||||
inst.mObj = LightObj(dg.Get(), m_VM);
|
||||
// Store the manager instance itself
|
||||
inst.mInst = dg.Get();
|
||||
// The instance is now managed by the script
|
||||
@ -348,7 +348,7 @@ Core::PickupInst & Core::AllocPickup(Int32 id, bool owned, Int32 header, LightOb
|
||||
// Instantiate the entity manager
|
||||
DeleteGuard< CPickup > dg(new CPickup(id));
|
||||
// Create the script object
|
||||
inst.mObj = LightObj(inst.mInst, m_VM);
|
||||
inst.mObj = LightObj(dg.Get(), m_VM);
|
||||
// Store the manager instance itself
|
||||
inst.mInst = dg.Get();
|
||||
// The instance is now managed by the script
|
||||
@ -397,7 +397,7 @@ Core::VehicleInst & Core::AllocVehicle(Int32 id, bool owned, Int32 header, Light
|
||||
// Instantiate the entity manager
|
||||
DeleteGuard< CVehicle > dg(new CVehicle(id));
|
||||
// Create the script object
|
||||
inst.mObj = LightObj(inst.mInst, m_VM);
|
||||
inst.mObj = LightObj(dg.Get(), m_VM);
|
||||
// Store the manager instance itself
|
||||
inst.mInst = dg.Get();
|
||||
// The instance is now managed by the script
|
||||
@ -780,9 +780,13 @@ void Core::ConnectPlayer(Int32 id, Int32 header, LightObj & payload)
|
||||
return; // Nothing to allocate!
|
||||
}
|
||||
// Instantiate the entity manager
|
||||
inst.mInst = new CPlayer(id);
|
||||
DeleteGuard< CPlayer > dg(new CPlayer(id));
|
||||
// Create the script object
|
||||
inst.mObj = LightObj(inst.mInst, m_VM);
|
||||
inst.mObj = LightObj(dg.Get(), m_VM);
|
||||
// Store the manager instance itself
|
||||
inst.mInst = dg.Get();
|
||||
// The instance is now managed by the script
|
||||
dg.Release();
|
||||
// Make sure that both the instance and script object could be created
|
||||
if (!inst.mInst || inst.mObj.IsNull())
|
||||
{
|
||||
@ -798,6 +802,8 @@ void Core::ConnectPlayer(Int32 id, Int32 header, LightObj & payload)
|
||||
inst.mLastHealth = _Func->GetPlayerHealth(id);
|
||||
inst.mLastArmour = _Func->GetPlayerArmour(id);
|
||||
inst.mLastHeading = _Func->GetPlayerHeading(id);
|
||||
// Initialize the instance events
|
||||
inst.InitEvents();
|
||||
// Let the script callbacks know about this entity
|
||||
EmitPlayerCreated(id, header, payload);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user