2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2019-06-02 16:43:04 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#define NULL_SQOBJ_(o) (o.IsNull() ? "NULL" : "OBJ")
|
|
|
|
|
2016-05-23 02:51:44 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCustomEvent(int32_t group, int32_t header, LightObj & payload) const
|
2016-05-23 02:51:44 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CustomEvent(%d, %d, %s)", group, header, NULL_SQOBJ_(payload))
|
2017-02-21 20:24:59 +01:00
|
|
|
(*mOnCustomEvent.first)(group, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CustomEvent")
|
2016-05-23 02:51:44 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitBlipCreated(int32_t blip, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::BlipCreated(%d, %d, %s)", blip, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
(*mOnBlipCreated.first)(m_Blips.at(static_cast< size_t >(blip)).mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::BlipCreated")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCheckpointCreated(int32_t checkpoint, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointCreated(%d, %d, %s)", checkpoint, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
(*mOnCheckpointCreated.first)(m_Checkpoints.at(static_cast< size_t >(checkpoint)).mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointCreated")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitKeyBindCreated(int32_t keybind, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::KeyBindCreated(%d, %d, %s)", keybind, header, NULL_SQOBJ_(payload))
|
|
|
|
(*mOnKeyBindCreated.first)(m_KeyBinds.at(static_cast< size_t >(keybind)).mObj, header, payload);
|
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::KeyBindCreated")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectCreated(int32_t object, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectCreated(%d, %d, %s)", object, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
(*mOnObjectCreated.first)(m_Objects.at(static_cast< size_t >(object)).mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectCreated")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupCreated(int32_t pickup, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupCreated(%d, %d, %s)", pickup, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
(*mOnPickupCreated.first)(m_Pickups.at(static_cast< size_t >(pickup)).mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupCreated")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerCreated(int32_t player, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerCreated(%d, %d, %s)", player, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
(*mOnPlayerCreated.first)(m_Players.at(static_cast< size_t >(player)).mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerCreated")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleCreated(int32_t vehicle, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleCreated(%d, %d, %s)", vehicle, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
(*mOnVehicleCreated.first)(m_Vehicles.at(static_cast< size_t >(vehicle)).mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleCreated")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitBlipDestroyed(int32_t blip, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::BlipDestroyed(%d, %d, %s)", blip, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
BlipInst & _blip = m_Blips.at(static_cast< size_t >(blip));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_blip.mOnDestroyed.first)(header, payload);
|
|
|
|
(*mOnBlipDestroyed.first)(_blip.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::BlipDestroyed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCheckpointDestroyed(int32_t checkpoint, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointDestroyed(%d, %d, %s)", checkpoint, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
CheckpointInst & _checkpoint = m_Checkpoints.at(static_cast< size_t >(checkpoint));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_checkpoint.mOnDestroyed.first)(header, payload);
|
|
|
|
(*mOnCheckpointDestroyed.first)(_checkpoint.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointDestroyed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitKeyBindDestroyed(int32_t keybind, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::KeyBindDestroyed(%d, %d, %s)", keybind, header, NULL_SQOBJ_(payload))
|
|
|
|
KeyBindInst & _keybind = m_KeyBinds.at(static_cast< size_t >(keybind));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_keybind.mOnDestroyed.first)(header, payload);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnKeyBindDestroyed.first)(_keybind.mObj, header, payload);
|
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::KeyBindDestroyed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectDestroyed(int32_t object, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectDestroyed(%d, %d, %s)", object, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
ObjectInst & _object = m_Objects.at(static_cast< size_t >(object));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_object.mOnDestroyed.first)(header, payload);
|
|
|
|
(*mOnObjectDestroyed.first)(_object.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectDestroyed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupDestroyed(int32_t pickup, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupDestroyed(%d, %d, %s)", pickup, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnDestroyed.first)(header, payload);
|
|
|
|
(*mOnPickupDestroyed.first)(_pickup.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupDestroyed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerDestroyed(int32_t player, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerDestroyed(%d, %d, %s)", player, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnDestroyed.first)(header, payload);
|
|
|
|
(*mOnPlayerDestroyed.first)(_player.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerDestroyed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleDestroyed(int32_t vehicle, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleDestroyed(%d, %d, %s)", vehicle, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnDestroyed.first)(header, payload);
|
|
|
|
(*mOnVehicleDestroyed.first)(_vehicle.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleDestroyed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitBlipCustom(int32_t blip, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::BlipCustom(%d, %d, %s)", blip, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
BlipInst & _blip = m_Blips.at(static_cast< size_t >(blip));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_blip.mOnCustom.first)(header, payload);
|
|
|
|
(*mOnBlipCustom.first)(_blip.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::BlipCustom")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCheckpointCustom(int32_t checkpoint, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointCustom(%d, %d, %s)", checkpoint, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
CheckpointInst & _checkpoint = m_Checkpoints.at(static_cast< size_t >(checkpoint));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_checkpoint.mOnCustom.first)(header, payload);
|
|
|
|
(*mOnCheckpointCustom.first)(_checkpoint.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointCustom")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitKeyBindCustom(int32_t keybind, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::KeyBindCustom(%d, %d, %s)", keybind, header, NULL_SQOBJ_(payload))
|
|
|
|
KeyBindInst & _keybind = m_KeyBinds.at(static_cast< size_t >(keybind));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_keybind.mOnCustom.first)(header, payload);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnKeyBindCustom.first)(_keybind.mObj, header, payload);
|
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::KeyBindCustom")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectCustom(int32_t object, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectCustom(%d, %d, %s)", object, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
ObjectInst & _object = m_Objects.at(static_cast< size_t >(object));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_object.mOnCustom.first)(header, payload);
|
|
|
|
(*mOnObjectCustom.first)(_object.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectCustom")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupCustom(int32_t pickup, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupCustom(%d, %d, %s)", pickup, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnCustom.first)(header, payload);
|
|
|
|
(*mOnPickupCustom.first)(_pickup.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupCustom")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerCustom(int32_t player, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerCustom(%d, %d, %s)", player, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnCustom.first)(header, payload);
|
|
|
|
(*mOnPlayerCustom.first)(_player.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerCustom")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleCustom(int32_t vehicle, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleCustom(%d, %d, %s)", vehicle, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnCustom.first)(header, payload);
|
|
|
|
(*mOnVehicleCustom.first)(_vehicle.mObj, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleCustom")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitServerStartup() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ServerStartup()")
|
2017-02-21 20:24:59 +01:00
|
|
|
(*mOnServerStartup.first)();
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ServerStartup")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitServerShutdown() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ServerShutdown()")
|
2017-02-21 20:24:59 +01:00
|
|
|
(*mOnServerShutdown.first)();
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ServerShutdown")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitServerFrame(float elapsed_time) const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:59:30 +02:00
|
|
|
//SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ServerFrame(%f)", elapsed_time)
|
2017-02-21 20:24:59 +01:00
|
|
|
(*mOnServerFrame.first)(elapsed_time);
|
2019-06-02 16:59:30 +02:00
|
|
|
//SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ServerFrame")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPluginCommand(uint32_t command_identifier, const char * message) // NOLINT(readability-convert-member-functions-to-static)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 17:15:04 +02:00
|
|
|
#if defined(_DEBUG) || defined(SQMOD_ENABLE_SV_EV_TRACEBACK)
|
2019-06-02 17:16:56 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PluginCommand(0x%08X, '%s')", command_identifier, message)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Ignored for now...
|
2019-06-02 17:15:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PluginCommand")
|
|
|
|
#else
|
|
|
|
// avoid unused parameter warnings!
|
|
|
|
(void)command_identifier;
|
|
|
|
(void)message;
|
|
|
|
#endif
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitIncomingConnection(char * player_name, size_t name_buffer_size, const char * user_password, const char * ip_address)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::IncomingConnection(%s, %" PRINT_SZ_FMT ", %s, %s)", player_name, name_buffer_size, user_password, ip_address)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Save the buffer information so that we can write to it from the string
|
|
|
|
m_IncomingNameBuffer = player_name;
|
|
|
|
m_IncomingNameCapacity = name_buffer_size;
|
|
|
|
// Attempt to forward the event to the script callback
|
|
|
|
try
|
|
|
|
{
|
2017-02-21 21:17:25 +01:00
|
|
|
(*mOnIncomingConnection.first)(LightObj(player_name, -1), name_buffer_size,
|
|
|
|
LightObj(user_password, -1), LightObj(ip_address, -1));
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
// Release any stored buffer information
|
|
|
|
m_IncomingNameBuffer = nullptr;
|
|
|
|
m_IncomingNameCapacity = 0;
|
|
|
|
// We catched the exception so we can release the assigned buffer
|
|
|
|
throw; // re-throw it
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Release any stored buffer information
|
|
|
|
m_IncomingNameBuffer = nullptr;
|
|
|
|
m_IncomingNameCapacity = 0;
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::IncomingConnection")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerRequestClass(int32_t player_id, int32_t offset)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerRequestClass(%d, %d)", player_id, offset)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnRequestClass.first)(offset);
|
|
|
|
(*mOnPlayerRequestClass.first)(_player.mObj, offset);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerRequestClass")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerRequestSpawn(int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerRequestSpawn(%d)", player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnRequestSpawn.first)();
|
|
|
|
(*mOnPlayerRequestSpawn.first)(_player.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerRequestSpawn")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerSpawn(int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerSpawn(%d)", player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnSpawn.first)();
|
|
|
|
(*mOnPlayerSpawn.first)(_player.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerSpawn")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerWasted(int32_t player_id, int32_t reason)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerWasted(%d, %d)", player_id, reason)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnWasted.first)(reason);
|
|
|
|
(*mOnPlayerWasted.first)(_player.mObj, reason);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerWasted")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerKilled(int32_t player_id, int32_t killer_id, int32_t reason, vcmpBodyPart body_part, bool team_kill)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerKilled(%d, %d, %d, %d, %d)", player_id, killer_id, reason, body_part, team_kill)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
|
|
|
PlayerInst & _killer = m_Players.at(static_cast< size_t >(killer_id));
|
2021-01-30 07:51:39 +01:00
|
|
|
(*_player.mOnKilled.first)(_killer.mObj, reason, static_cast< int32_t >(body_part), team_kill);
|
|
|
|
(*mOnPlayerKilled.first)(_player.mObj, _killer.mObj, reason, static_cast< int32_t >(body_part), team_kill);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerKilled")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerEmbarking(int32_t player_id, int32_t vehicle_id, int32_t slot_index)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerEmbarking(%d, %d, %d)", player_id, vehicle_id, slot_index)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnEmbarking.first)(_vehicle.mObj, slot_index);
|
|
|
|
(*_vehicle.mOnEmbarking.first)(_player.mObj, slot_index);
|
|
|
|
(*mOnPlayerEmbarking.first)(_player.mObj, _vehicle.mObj, slot_index);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerEmbarking")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerEmbarked(int32_t player_id, int32_t vehicle_id, int32_t slot_index)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerEmbarked(%d, %d, %d)", player_id, vehicle_id, slot_index)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnEmbarked.first)(_vehicle.mObj, slot_index);
|
|
|
|
(*_vehicle.mOnEmbarked.first)(_player.mObj, slot_index);
|
|
|
|
(*mOnPlayerEmbarked.first)(_player.mObj, _vehicle.mObj, slot_index);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerEmbarked")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerDisembark(int32_t player_id, int32_t vehicle_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerDisembark(%d, %d)", player_id, vehicle_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnDisembark.first)(_vehicle.mObj);
|
|
|
|
(*_vehicle.mOnDisembark.first)(_player.mObj);
|
|
|
|
(*mOnPlayerDisembark.first)(_player.mObj, _vehicle.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerDisembark")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerRename(int32_t player_id, const char * old_name, const char * new_name)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerRename(%d, %s, %s)", player_id, old_name, new_name)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 21:17:25 +01:00
|
|
|
LightObj oname(old_name, -1), nname(new_name, -1);
|
|
|
|
(*_player.mOnRename.first)(oname, nname);
|
|
|
|
(*mOnPlayerRename.first)(_player.mObj, oname, nname);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerRename")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerState(int32_t player_id, int32_t old_state, int32_t new_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerState(%d, %d, %d)", player_id, old_state, new_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnState.first)(old_state, new_state);
|
|
|
|
(*mOnPlayerState.first)(_player.mObj, old_state, new_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerState")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateNone(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateNone(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateNone.first)(old_state);
|
|
|
|
(*mOnStateNone.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateNone")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateNormal(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateNormal(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateNormal.first)(old_state);
|
|
|
|
(*mOnStateNormal.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateNormal")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateAim(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateAim(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateAim.first)(old_state);
|
|
|
|
(*mOnStateAim.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateAim")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateDriver(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateDriver(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateDriver.first)(old_state);
|
|
|
|
(*mOnStateDriver.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateDriver")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStatePassenger(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StatePassenger(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStatePassenger.first)(old_state);
|
|
|
|
(*mOnStatePassenger.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StatePassenger")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateEnterDriver(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateEnterDriver(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateEnterDriver.first)(old_state);
|
|
|
|
(*mOnStateEnterDriver.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateEnterDriver")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateEnterPassenger(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateEnterPassenger(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateEnterPassenger.first)(old_state);
|
|
|
|
(*mOnStateEnterPassenger.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateEnterPassenger")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateExit(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateExit(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateExit.first)(old_state);
|
|
|
|
(*mOnStateExit.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateExit")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitStateUnspawned(int32_t player_id, int32_t old_state)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::StateUnspawned(%d, %d)", player_id, old_state)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStateUnspawned.first)(old_state);
|
|
|
|
(*mOnStateUnspawned.first)(_player.mObj, old_state);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::StateUnspawned")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerAction(int32_t player_id, int32_t old_action, int32_t new_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerAction(%d, %d, %d)", player_id, old_action, new_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnAction.first)(old_action, new_action);
|
|
|
|
(*mOnPlayerAction.first)(_player.mObj, old_action, new_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerAction")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionNone(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionNone(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionNone.first)(old_action);
|
|
|
|
(*mOnActionNone.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionNone")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionNormal(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionNormal(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionNormal.first)(old_action);
|
|
|
|
(*mOnActionNormal.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionNormal")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionAiming(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionAiming(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionAiming.first)(old_action);
|
|
|
|
(*mOnActionAiming.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionAiming")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionShooting(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionShooting(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionShooting.first)(old_action);
|
|
|
|
(*mOnActionShooting.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionShooting")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionJumping(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionJumping(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionJumping.first)(old_action);
|
|
|
|
(*mOnActionJumping.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionJumping")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionLieDown(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionLieDown(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionLieDown.first)(old_action);
|
|
|
|
(*mOnActionLieDown.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionLieDown")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionGettingUp(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionGettingUp(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionGettingUp.first)(old_action);
|
|
|
|
(*mOnActionGettingUp.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionGettingUp")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionJumpVehicle(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionJumpVehicle(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionJumpVehicle.first)(old_action);
|
|
|
|
(*mOnActionJumpVehicle.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionJumpVehicle")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionDriving(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionDriving(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionDriving.first)(old_action);
|
|
|
|
(*mOnActionDriving.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionDriving")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionDying(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionDying(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionDying.first)(old_action);
|
|
|
|
(*mOnActionDying.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionDying")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionWasted(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionWasted(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionWasted.first)(old_action);
|
|
|
|
(*mOnActionWasted.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionWasted")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionEmbarking(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionEmbarking(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionEmbarking.first)(old_action);
|
|
|
|
(*mOnActionEmbarking.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionEmbarking")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitActionDisembarking(int32_t player_id, int32_t old_action)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ActionDisembarking(%d, %d)", player_id, old_action)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnActionDisembarking.first)(old_action);
|
|
|
|
(*mOnActionDisembarking.first)(_player.mObj, old_action);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ActionDisembarking")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerBurning(int32_t player_id, bool is_on_fire)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerBurning(%d, %d)", player_id, is_on_fire)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnBurning.first)(is_on_fire);
|
|
|
|
(*mOnPlayerBurning.first)(_player.mObj, is_on_fire);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerBurning")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerCrouching(int32_t player_id, bool is_crouching)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerCrouching(%d, %d)", player_id, is_crouching)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnCrouching.first)(is_crouching);
|
|
|
|
(*mOnPlayerCrouching.first)(_player.mObj, is_crouching);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerCrouching")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerGameKeys(int32_t player_id, uint32_t old_keys, uint32_t new_keys)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerGameKeys(%d, %u, %u)", player_id, old_keys, new_keys)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnGameKeys.first)(old_keys, new_keys);
|
|
|
|
(*mOnPlayerGameKeys.first)(_player.mObj, old_keys, new_keys);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerGameKeys")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerStartTyping(int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerStartTyping(%d)", player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStartTyping.first)();
|
|
|
|
(*mOnPlayerStartTyping.first)(_player.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerStartTyping")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerStopTyping(int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerStopTyping(%d)", player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnStopTyping.first)();
|
|
|
|
(*mOnPlayerStopTyping.first)(_player.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerStopTyping")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerAway(int32_t player_id, bool is_away)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerAway(%d, %d)", player_id, is_away)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnAway.first)(is_away);
|
|
|
|
(*mOnPlayerAway.first)(_player.mObj, is_away);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerAway")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerMessage(int32_t player_id, const char * message)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerMessage(%d, %s)", player_id, message)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 21:17:25 +01:00
|
|
|
LightObj msg(message, -1);
|
|
|
|
(*_player.mOnMessage.first)(msg);
|
|
|
|
(*mOnPlayerMessage.first)(_player.mObj, msg);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerMessage")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerCommand(int32_t player_id, const char * message)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerCommand(%d, %s)", player_id, message)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 21:17:25 +01:00
|
|
|
LightObj msg(message, -1);
|
|
|
|
(*_player.mOnCommand.first)(msg);
|
|
|
|
(*mOnPlayerCommand.first)(_player.mObj, msg);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerCommand")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerPrivateMessage(int32_t player_id, int32_t target_player_id, const char * message)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerPrivateMessage(%d, %d, %s)", player_id, target_player_id, message)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
|
|
|
PlayerInst & _receiver = m_Players.at(static_cast< size_t >(target_player_id));
|
2017-02-21 21:17:25 +01:00
|
|
|
LightObj msg(message, -1);
|
|
|
|
(*_player.mOnMessage.first)(_receiver.mObj, msg);
|
|
|
|
(*mOnPlayerPrivateMessage.first)(_player.mObj, _receiver.mObj, msg);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerPrivateMessage")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerKeyPress(int32_t player_id, int32_t bind_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerKeyPress(%d, %d)", player_id, bind_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2021-01-30 07:51:39 +01:00
|
|
|
KeyBindInst & _keybind = m_KeyBinds.at(static_cast< size_t >(bind_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnKeyPress.first)(_keybind.mObj);
|
|
|
|
(*_keybind.mOnKeyPress.first)(_player.mObj);
|
|
|
|
(*mOnPlayerKeyPress.first)(_player.mObj, _keybind.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerKeyPress")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerKeyRelease(int32_t player_id, int32_t bind_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerKeyRelease(%d, %d)", player_id, bind_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2021-01-30 07:51:39 +01:00
|
|
|
KeyBindInst & _keybind = m_KeyBinds.at(static_cast< size_t >(bind_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_keybind.mOnKeyRelease.first)(_player.mObj);
|
|
|
|
(*_player.mOnKeyRelease.first)(_keybind.mObj);
|
|
|
|
(*mOnPlayerKeyRelease.first)(_player.mObj, _keybind.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerKeyRelease")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerSpectate(int32_t player_id, int32_t target_player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerSpectate(%d, %d)", player_id, target_player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
|
|
|
PlayerInst & _target = m_Players.at(static_cast< size_t >(target_player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnSpectate.first)(_target.mObj);
|
|
|
|
(*mOnPlayerSpectate.first)(_player.mObj, _target.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerSpectate")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
2017-08-06 17:14:58 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerUnspectate(int32_t player_id)
|
2017-08-06 17:14:58 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerUnspectate(%d)", player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-08-06 17:14:58 +02:00
|
|
|
(*_player.mOnUnspectate.first)();
|
|
|
|
(*mOnPlayerUnspectate.first)(_player.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerUnspectate")
|
2017-08-06 17:14:58 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerCrashReport(int32_t player_id, const char * report)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerCrashreport(%d, %s)", player_id, report)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 21:17:25 +01:00
|
|
|
LightObj rep(report, -1);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*_player.mOnCrashReport.first)(rep);
|
|
|
|
(*mOnPlayerCrashReport.first)(_player.mObj, rep);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerCrashreport")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
2018-06-28 20:41:31 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerModuleList(int32_t player_id, const char * list)
|
2018-06-28 20:41:31 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerModuleList(%d, %s)", player_id, list)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2018-06-28 20:41:31 +02:00
|
|
|
LightObj rep(list, -1);
|
|
|
|
(*_player.mOnModuleList.first)(rep);
|
|
|
|
(*mOnPlayerModuleList.first)(_player.mObj, rep);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerModuleList")
|
2018-06-28 20:41:31 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleExplode(int32_t vehicle_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleExplode(%d)", vehicle_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnExplode.first)();
|
|
|
|
(*mOnVehicleExplode.first)(_vehicle.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleExplode")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleRespawn(int32_t vehicle_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleRespawn(%d)", vehicle_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnRespawn.first)();
|
|
|
|
(*mOnVehicleRespawn.first)(_vehicle.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleRespawn")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectShot(int32_t object_id, int32_t player_id, int32_t weapon_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectShot(%d, %d, %d)", object_id, player_id, weapon_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
ObjectInst & _object = m_Objects.at(static_cast< size_t >(object_id));
|
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_object.mOnShot.first)(_player.mObj, weapon_id);
|
|
|
|
(*_player.mOnObjectShot.first)(_object.mObj, weapon_id);
|
|
|
|
(*mOnObjectShot.first)(_player.mObj, _object.mObj, weapon_id);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectShot")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectTouched(int32_t object_id, int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectTouched(%d, %d)", object_id, player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
ObjectInst & _object = m_Objects.at(static_cast< size_t >(object_id));
|
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_object.mOnTouched.first)(_player.mObj);
|
|
|
|
(*_player.mOnObjectTouched.first)(_object.mObj);
|
|
|
|
(*mOnObjectTouched.first)(_player.mObj, _object.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectTouched")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupClaimed(int32_t pickup_id, int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupClaimed(%d, %d)", pickup_id, player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnClaimed.first)(_player.mObj);
|
|
|
|
(*_player.mOnPickupClaimed.first)(_pickup.mObj);
|
|
|
|
(*mOnPickupClaimed.first)(_player.mObj, _pickup.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupClaimed")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupCollected(int32_t pickup_id, int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupCollected(%d, %d)", pickup_id, player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnCollected.first)(_player.mObj);
|
|
|
|
(*_player.mOnPickupCollected.first)(_pickup.mObj);
|
|
|
|
(*mOnPickupCollected.first)(_player.mObj, _pickup.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupCollected")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupRespawn(int32_t pickup_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupRespawn(%d)", pickup_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnRespawn.first)();
|
|
|
|
(*mOnPickupRespawn.first)(_pickup.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupRespawn")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCheckpointEntered(int32_t checkpoint_id, int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointEntered(%d, %d)", checkpoint_id, player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
CheckpointInst & _checkpoint = m_Checkpoints.at(static_cast< size_t >(checkpoint_id));
|
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_checkpoint.mOnEntered.first)(_player.mObj);
|
|
|
|
(*_player.mOnCheckpointEntered.first)(_checkpoint.mObj);
|
|
|
|
(*mOnCheckpointEntered.first)(_player.mObj, _checkpoint.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointEntered")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCheckpointExited(int32_t checkpoint_id, int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointExited(%d, %d)", checkpoint_id, player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
CheckpointInst & _checkpoint = m_Checkpoints.at(static_cast< size_t >(checkpoint_id));
|
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_checkpoint.mOnExited.first)(_player.mObj);
|
|
|
|
(*_player.mOnCheckpointExited.first)(_checkpoint.mObj);
|
|
|
|
(*mOnCheckpointExited.first)(_player.mObj, _checkpoint.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointExited")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 14:54:26 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCheckpointWorld(int32_t checkpoint_id, int32_t old_world, int32_t new_world)
|
2016-08-18 14:54:26 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointWorld(%d, %d, %d)", checkpoint_id, old_world, new_world)
|
2020-03-22 05:53:04 +01:00
|
|
|
CheckpointInst & _checkpoint = m_Checkpoints.at(static_cast< size_t >(checkpoint_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_checkpoint.mOnWorld.first)(old_world, new_world);
|
|
|
|
(*mOnCheckpointWorld.first)(_checkpoint.mObj, old_world, new_world);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointWorld")
|
2016-08-18 14:54:26 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 15:10:18 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitCheckpointRadius(int32_t checkpoint_id, float old_radius, float new_radius)
|
2016-08-18 15:10:18 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointRadius(%d, %f, %f)", checkpoint_id, old_radius, new_radius)
|
2020-03-22 05:53:04 +01:00
|
|
|
CheckpointInst & _checkpoint = m_Checkpoints.at(static_cast< size_t >(checkpoint_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_checkpoint.mOnRadius.first)(old_radius, new_radius);
|
|
|
|
(*mOnCheckpointRadius.first)(_checkpoint.mObj, old_radius, new_radius);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointRadius")
|
2016-08-18 15:10:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 15:37:55 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectWorld(int32_t object_id, int32_t old_world, int32_t new_world)
|
2016-08-18 15:37:55 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectWorld(%d, %d, %d)", object_id, old_world, new_world)
|
2020-03-22 05:53:04 +01:00
|
|
|
ObjectInst & _object = m_Objects.at(static_cast< size_t >(object_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_object.mOnWorld.first)(old_world, new_world);
|
|
|
|
(*mOnObjectWorld.first)(_object.mObj, old_world, new_world);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectWorld")
|
2016-08-18 15:37:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 15:50:30 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectAlpha(int32_t object_id, int32_t old_alpha, int32_t new_alpha, int32_t time)
|
2016-08-18 15:50:30 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectAlpha(%d, %d, %d, %d)", object_id, old_alpha, new_alpha, time)
|
2020-03-22 05:53:04 +01:00
|
|
|
ObjectInst & _object = m_Objects.at(static_cast< size_t >(object_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_object.mOnAlpha.first)(old_alpha, new_alpha, time);
|
|
|
|
(*mOnObjectAlpha.first)(_object.mObj, old_alpha, new_alpha, time);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectAlpha")
|
2016-08-18 15:50:30 +02:00
|
|
|
}
|
|
|
|
|
2016-08-19 16:58:08 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupWorld(int32_t pickup_id, int32_t old_world, int32_t new_world)
|
2016-08-19 16:58:08 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupWorld(%d, %d, %d)", pickup_id, old_world, new_world)
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnWorld.first)(old_world, new_world);
|
|
|
|
(*mOnPickupWorld.first)(_pickup.mObj, old_world, new_world);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupWorld")
|
2016-08-19 16:58:08 +02:00
|
|
|
}
|
|
|
|
|
2016-08-19 17:05:29 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupAlpha(int32_t pickup_id, int32_t old_alpha, int32_t new_alpha)
|
2016-08-19 17:05:29 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupAlpha(%d, %d, %d)", pickup_id, old_alpha, new_alpha)
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnAlpha.first)(old_alpha, new_alpha);
|
|
|
|
(*mOnPickupAlpha.first)(_pickup.mObj, old_alpha, new_alpha);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupAlpha")
|
2016-08-19 17:05:29 +02:00
|
|
|
}
|
|
|
|
|
2016-08-19 17:21:41 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupAutomatic(int32_t pickup_id, bool old_status, bool new_status)
|
2016-08-19 17:21:41 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupAutomatic(%d, %d, %d)", pickup_id, old_status, new_status)
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnAutomatic.first)(old_status, new_status);
|
|
|
|
(*mOnPickupAutomatic.first)(_pickup.mObj, old_status, new_status);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupAutomatic")
|
2016-08-19 17:21:41 +02:00
|
|
|
}
|
|
|
|
|
2016-08-19 17:26:52 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupAutoTimer(int32_t pickup_id, int32_t old_timer, int32_t new_timer)
|
2016-08-19 17:26:52 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupAutoTimer(%d, %d, %d)", pickup_id, old_timer, new_timer)
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_pickup.mOnAutoTimer.first)(old_timer, new_timer);
|
|
|
|
(*mOnPickupAutoTimer.first)(_pickup.mObj, old_timer, new_timer);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupAutoTimer")
|
2016-08-19 17:26:52 +02:00
|
|
|
}
|
|
|
|
|
2018-06-28 21:06:23 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPickupOption(int32_t pickup_id, int32_t option_id, bool value,
|
|
|
|
int32_t header, LightObj & payload)
|
2018-06-28 21:06:23 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupOption(%d, %d, %d, %d, %s)", pickup_id, option_id, value, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
PickupInst & _pickup = m_Pickups.at(static_cast< size_t >(pickup_id));
|
2018-06-28 21:06:23 +02:00
|
|
|
(*_pickup.mOnOption.first)(option_id, value, header, payload);
|
|
|
|
(*mOnPickupOption.first)(_pickup.mObj, option_id, value, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupOption")
|
2018-06-28 21:06:23 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 16:12:00 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitObjectReport(int32_t object_id, bool old_status, bool new_status, bool touched)
|
2016-08-18 16:12:00 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectReport(%d, %d, %d)", object_id, new_status, touched)
|
2020-03-22 05:53:04 +01:00
|
|
|
ObjectInst & _object = m_Objects.at(static_cast< size_t >(object_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_object.mOnReport.first)(old_status, new_status, touched);
|
|
|
|
(*mOnObjectReport.first)(_object.mObj, old_status, new_status, touched);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectReport")
|
2016-08-18 16:12:00 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerHealth(int32_t player_id, float old_health, float new_health)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerHealth(%d, %f, %f)", player_id, old_health, new_health)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnHealth.first)(old_health, new_health);
|
|
|
|
(*mOnPlayerHealth.first)(_player.mObj, old_health, new_health);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerHealth")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerArmour(int32_t player_id, float old_armour, float new_armour)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerArmour(%d, %f, %f)", player_id, old_armour, new_armour)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnArmour.first)(old_armour, new_armour);
|
|
|
|
(*mOnPlayerArmour.first)(_player.mObj, old_armour, new_armour);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerArmour")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerWeapon(int32_t player_id, int32_t old_weapon, int32_t new_weapon)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerWeapon(%d, %d, %d)", player_id, old_weapon, new_weapon)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnWeapon.first)(old_weapon, new_weapon);
|
|
|
|
(*mOnPlayerWeapon.first)(_player.mObj, old_weapon, new_weapon);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerWeapon")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerHeading(int32_t player_id, float old_heading, float new_heading)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerHeading(%d, %f, %f)", player_id, old_heading, new_heading)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnHeading.first)(old_heading, new_heading);
|
|
|
|
(*mOnPlayerHeading.first)(_player.mObj, old_heading, new_heading);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerHeading")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerPosition(int32_t player_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerPosition(%d)", player_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnPosition.first)(_player.mTrackPositionHeader, _player.mTrackPositionPayload);
|
|
|
|
(*mOnPlayerPosition.first)(_player.mObj, _player.mTrackPositionHeader, _player.mTrackPositionPayload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerPosition")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerOption(int32_t player_id, int32_t option_id, bool value,
|
|
|
|
int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerOption(%d, %d, %d, %d, %s)", player_id, option_id, value, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnOption.first)(option_id, value, header, payload);
|
|
|
|
(*mOnPlayerOption.first)(_player.mObj, option_id, value, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerOption")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 14:40:48 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerAdmin(int32_t player_id, bool old_status, bool new_status)
|
2016-08-17 14:40:48 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerAdmin(%d, %d, %d)", player_id, old_status, new_status)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnAdmin.first)(old_status, new_status);
|
|
|
|
(*mOnPlayerAdmin.first)(_player.mObj, old_status, new_status);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerAdmin")
|
2016-08-17 14:40:48 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 14:45:44 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerWorld(int32_t player_id, int32_t old_world, int32_t new_world, bool secondary)
|
2016-08-17 14:45:44 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerWorld(%d, %d, %d, %d)", player_id, old_world, new_world, secondary)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnWorld.first)(old_world, new_world, secondary);
|
|
|
|
(*mOnPlayerWorld.first)(_player.mObj, old_world, new_world, secondary);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerWorld")
|
2016-08-17 14:45:44 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 14:49:08 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerTeam(int32_t player_id, int32_t old_team, int32_t new_team)
|
2016-08-17 14:49:08 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerTeam(%d, %d, %d)", player_id, old_team, new_team)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnTeam.first)(old_team, new_team);
|
|
|
|
(*mOnPlayerTeam.first)(_player.mObj, old_team, new_team);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerTeam")
|
2016-08-17 14:49:08 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 14:52:22 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerSkin(int32_t player_id, int32_t old_skin, int32_t new_skin)
|
2016-08-17 14:52:22 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerSkin(%d, %d, %d)", player_id, old_skin, new_skin)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnSkin.first)(old_skin, new_skin);
|
|
|
|
(*mOnPlayerSkin.first)(_player.mObj, old_skin, new_skin);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerSkin")
|
2016-08-17 14:52:22 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 14:55:59 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerMoney(int32_t player_id, int32_t old_money, int32_t new_money)
|
2016-08-17 14:55:59 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerMoney(%d, %d, %d)", player_id, old_money, new_money)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnMoney.first)(old_money, new_money);
|
|
|
|
(*mOnPlayerMoney.first)(_player.mObj, old_money, new_money);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerMoney")
|
2016-08-17 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 15:00:28 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerScore(int32_t player_id, int32_t old_score, int32_t new_score)
|
2016-08-17 15:00:28 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerScore(%d, %d, %d)", player_id, old_score, new_score)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnScore.first)(old_score, new_score);
|
|
|
|
(*mOnPlayerScore.first)(_player.mObj, old_score, new_score);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerScore")
|
2016-08-17 15:00:28 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 15:04:14 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerWantedLevel(int32_t player_id, int32_t old_level, int32_t new_level)
|
2016-08-17 15:04:14 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerWantedLevel(%d, %d, %d)", player_id, old_level, new_level)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnWantedLevel.first)(old_level, new_level);
|
|
|
|
(*mOnPlayerWantedLevel.first)(_player.mObj, old_level, new_level);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerWantedLevel")
|
2016-08-17 15:04:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 15:07:31 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerImmunity(int32_t player_id, int32_t old_immunity, int32_t new_immunity)
|
2016-08-17 15:07:31 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerImmunity(%d, %d, %d)", player_id, old_immunity, new_immunity)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnImmunity.first)(old_immunity, new_immunity);
|
|
|
|
(*mOnPlayerImmunity.first)(_player.mObj, old_immunity, new_immunity);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerImmunity")
|
2016-08-17 15:07:31 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 15:10:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerAlpha(int32_t player_id, int32_t old_alpha, int32_t new_alpha, int32_t fade)
|
2016-08-17 15:10:43 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerAlpha(%d, %d, %d, %d)", player_id, old_alpha, new_alpha, fade)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnAlpha.first)(old_alpha, new_alpha, fade);
|
|
|
|
(*mOnPlayerAlpha.first)(_player.mObj, old_alpha, new_alpha, fade);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerAlpha")
|
2016-08-17 15:10:43 +02:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:09:35 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerEnterArea(int32_t player_id, LightObj & area_obj)
|
2017-06-19 03:09:35 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerEnterArea(%d, %s)", player_id, NULL_SQOBJ_(area_obj))
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-06-19 03:09:35 +02:00
|
|
|
(*_player.mOnEnterArea.first)(area_obj);
|
|
|
|
(*mOnPlayerEnterArea.first)(_player.mObj, area_obj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerEnterArea")
|
2017-06-19 03:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerLeaveArea(int32_t player_id, LightObj & area_obj)
|
2017-06-19 03:09:35 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerLeaveArea(%d, %s)", player_id, NULL_SQOBJ_(area_obj))
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2017-06-19 03:09:35 +02:00
|
|
|
(*_player.mOnLeaveArea.first)(area_obj);
|
|
|
|
(*mOnPlayerLeaveArea.first)(_player.mObj, area_obj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerLeaveArea")
|
2017-06-19 03:09:35 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleColor(int32_t vehicle_id, int32_t changed)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleColor(%d, %d)", vehicle_id, changed)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnColor.first)(changed);
|
|
|
|
(*mOnVehicleColor.first)(_vehicle.mObj, changed);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleColor")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleHealth(int32_t vehicle_id, float old_health, float new_health)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleHealth(%d, %f, %f)", vehicle_id, old_health, new_health)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnHealth.first)(old_health, new_health);
|
|
|
|
(*mOnVehicleHealth.first)(_vehicle.mObj, old_health, new_health);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleHealth")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehiclePosition(int32_t vehicle_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehiclePosition(%d)", vehicle_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnPosition.first)();
|
|
|
|
(*mOnVehiclePosition.first)(_vehicle.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehiclePosition")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleRotation(int32_t vehicle_id)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleRotation(%d)", vehicle_id)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnRotation.first)();
|
|
|
|
(*mOnVehicleRotation.first)(_vehicle.mObj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleRotation")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleOption(int32_t vehicle_id, int32_t option_id, bool value,
|
|
|
|
int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleOption(%d, %d, %d, %d, %s)", vehicle_id, option_id, value, header, NULL_SQOBJ_(payload))
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnOption.first)(option_id, value, header, payload);
|
|
|
|
(*mOnVehicleOption.first)(_vehicle.mObj, option_id, value, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleOption")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:38:00 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleWorld(int32_t vehicle_id, int32_t old_world, int32_t new_world)
|
2016-08-18 13:38:00 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleWorld(%d, %d, %d)", vehicle_id, old_world, new_world)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnWorld.first)(old_world, new_world);
|
|
|
|
(*mOnVehicleWorld.first)(_vehicle.mObj, old_world, new_world);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleWorld")
|
2016-08-18 13:38:00 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:45:12 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleImmunity(int32_t vehicle_id, int32_t old_immunity, int32_t new_immunity)
|
2016-08-18 13:45:12 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleImmunity(%d, %d, %d)", vehicle_id, old_immunity, new_immunity)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnImmunity.first)(old_immunity, new_immunity);
|
|
|
|
(*mOnVehicleImmunity.first)(_vehicle.mObj, old_immunity, new_immunity);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleImmunity")
|
2016-08-18 13:45:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:51:55 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehiclePartStatus(int32_t vehicle_id, int32_t part, int32_t old_status, int32_t new_status)
|
2016-08-18 13:51:55 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehiclePartStatus(%d, %d, %d, %d)", vehicle_id, part, old_status, new_status)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnPartStatus.first)(part, old_status, new_status);
|
|
|
|
(*mOnVehiclePartStatus.first)(_vehicle.mObj, part, old_status, new_status);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehiclePartStatus")
|
2016-08-18 13:51:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 13:56:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleTyreStatus(int32_t vehicle_id, int32_t tyre, int32_t old_status, int32_t new_status)
|
2016-08-18 13:56:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleTyreStatus(%d, %d, %d, %d)", vehicle_id, tyre, old_status, new_status)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnTyreStatus.first)(tyre, old_status, new_status);
|
|
|
|
(*mOnVehicleTyreStatus.first)(_vehicle.mObj, tyre, old_status, new_status);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleTyreStatus")
|
2016-08-18 13:56:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 14:06:03 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleDamageData(int32_t vehicle_id, uint32_t old_data, uint32_t new_data)
|
2016-08-18 14:06:03 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleDamageData(%d, %u, %u)", vehicle_id, old_data, new_data)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnDamageData.first)(old_data, new_data);
|
|
|
|
(*mOnVehicleDamageData.first)(_vehicle.mObj, old_data, new_data);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleDamageData")
|
2016-08-18 14:06:03 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 14:13:33 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleRadio(int32_t vehicle_id, int32_t old_radio, int32_t new_radio)
|
2016-08-18 14:13:33 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleRadio(%d, %d, %d)", vehicle_id, old_radio, new_radio)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnRadio.first)(old_radio, new_radio);
|
|
|
|
(*mOnVehicleRadio.first)(_vehicle.mObj, old_radio, new_radio);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleRadio")
|
2016-08-18 14:13:33 +02:00
|
|
|
}
|
2016-08-18 14:21:50 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleHandlingRule(int32_t vehicle_id, int32_t rule, SQFloat old_data, SQFloat new_data)
|
2016-08-18 14:21:50 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleHandlingRule(%d, %d, %f, %f)", vehicle_id, rule, old_data, new_data)
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_vehicle.mOnHandlingRule.first)(rule, old_data, new_data);
|
2017-06-19 03:09:35 +02:00
|
|
|
(*mOnVehicleHandlingRule.first)(_vehicle.mObj, rule, old_data, new_data);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleHandlingRule")
|
2017-06-19 03:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleEnterArea(int32_t vehicle_id, LightObj & area_obj)
|
2017-06-19 03:09:35 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleEnterArea(%d, %s)", vehicle_id, NULL_SQOBJ_(area_obj))
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-06-19 03:09:35 +02:00
|
|
|
(*_vehicle.mOnEnterArea.first)(area_obj);
|
|
|
|
(*mOnVehicleEnterArea.first)(_vehicle.mObj, area_obj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleEnterArea")
|
2017-06-19 03:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleLeaveArea(int32_t vehicle_id, LightObj & area_obj)
|
2017-06-19 03:09:35 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleLeaveArea(%d, %s)", vehicle_id, NULL_SQOBJ_(area_obj))
|
2020-03-22 05:53:04 +01:00
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));
|
2017-06-19 03:09:35 +02:00
|
|
|
(*_vehicle.mOnLeaveArea.first)(area_obj);
|
|
|
|
(*mOnVehicleLeaveArea.first)(_vehicle.mObj, area_obj);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleLeaveArea")
|
2016-08-18 14:21:50 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitServerOption(int32_t option, bool value, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ServerOption(%d, %d, %d, %s)", option, value, header, NULL_SQOBJ_(payload))
|
2016-05-22 05:20:38 +02:00
|
|
|
if (m_CircularLocks & CCL_EMIT_SERVER_OPTION)
|
|
|
|
{
|
|
|
|
return; // Already inside this event!
|
|
|
|
}
|
|
|
|
// Prevent further calls to this event
|
|
|
|
BitGuardU32 bg(m_CircularLocks, CCL_EMIT_SERVER_OPTION);
|
|
|
|
// Now forward the event call
|
2017-02-21 20:24:59 +01:00
|
|
|
(*mOnServerOption.first)(option, value, header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ServerOption")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitScriptReload(int32_t header, LightObj & payload) const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ScriptReload(%d, %s)", header, NULL_SQOBJ_(payload))
|
2017-02-21 20:24:59 +01:00
|
|
|
(*mOnScriptReload.first)(header, payload);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ScriptReload")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitScriptLoaded() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 17:24:33 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ScriptLoaded()")
|
2017-02-21 20:24:59 +01:00
|
|
|
(*mOnScriptLoaded.first)();
|
2019-06-02 17:24:33 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ScriptLoaded")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitEntityPool(vcmpEntityPool entity_type, int32_t entity_id, bool is_deleted)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::EntityPool(%d, %d, %d)", static_cast<int32_t>(entity_type), entity_id, is_deleted)
|
2016-05-22 05:20:38 +02:00
|
|
|
// See what type of change happened in the entity pool
|
|
|
|
switch (entity_type)
|
|
|
|
{
|
|
|
|
case vcmpEntityPoolVehicle:
|
|
|
|
// Do we even have this vehicle that we're trying to delete?
|
|
|
|
if (is_deleted && VALID_ENTITY(m_Vehicles[entity_id].mID))
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
DeallocVehicle(entity_id, false, SQMOD_DESTROY_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Do we already have this vehicle that we're trying to create?
|
|
|
|
else if (INVALID_ENTITY(m_Vehicles[entity_id].mID))
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
AllocVehicle(entity_id, false, SQMOD_CREATE_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case vcmpEntityPoolObject:
|
|
|
|
// Do we even have this object that we're trying to delete?
|
|
|
|
if (is_deleted && VALID_ENTITY(m_Objects[entity_id].mID))
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
DeallocObject(entity_id, false, SQMOD_DESTROY_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Do we already have this object that we're trying to create?
|
|
|
|
else if (INVALID_ENTITY(m_Objects[entity_id].mID))
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
AllocObject(entity_id, false, SQMOD_CREATE_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case vcmpEntityPoolPickup:
|
|
|
|
// Do we even have this pickup that we're trying to delete?
|
|
|
|
if (is_deleted && VALID_ENTITY(m_Pickups[entity_id].mID))
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
DeallocPickup(entity_id, false, SQMOD_DESTROY_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Do we already have this pickup that we're trying to create?
|
|
|
|
else if (INVALID_ENTITY(m_Pickups[entity_id].mID))
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
AllocPickup(entity_id, false, SQMOD_CREATE_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case vcmpEntityPoolRadio:
|
|
|
|
// @TODO Implement...
|
2019-06-02 12:57:08 +02:00
|
|
|
//break;
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-02 12:57:08 +02:00
|
|
|
case vcmpEntityPoolPlayer:
|
|
|
|
// @TODO Implement...
|
|
|
|
//break;
|
|
|
|
case vcmpEntityReserved1:
|
|
|
|
// @TODO Implement...
|
2016-05-22 05:20:38 +02:00
|
|
|
break;
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-05-22 05:20:38 +02:00
|
|
|
case vcmpEntityPoolBlip:
|
|
|
|
// Do we even have this blip that we're trying to delete?
|
|
|
|
if (is_deleted && VALID_ENTITY(m_Blips[entity_id].mID))
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
DeallocBlip(entity_id, false, SQMOD_DESTROY_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Do we already have this blip that we're trying to create?
|
|
|
|
else if (INVALID_ENTITY(m_Blips[entity_id].mID))
|
|
|
|
{
|
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(entity_id, SQMOD_BLIP_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot allocate blip with invalid identifier: %d", entity_id);
|
|
|
|
}
|
|
|
|
// Retrieve the specified entity instance
|
|
|
|
BlipInst & inst = m_Blips[entity_id];
|
|
|
|
// Make sure that the instance isn't already allocated
|
|
|
|
if (VALID_ENTITY(inst.mID))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot allocate blip that already exists: %d", entity_id);
|
|
|
|
}
|
|
|
|
// Information about the blip entity
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t world, scale, sprid;
|
|
|
|
uint32_t color;
|
|
|
|
float x, y, z;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Get the blip information from the server
|
|
|
|
_Func->GetCoordBlipInfo(entity_id, &world, &x, &y, &z, &scale, &color, &sprid);
|
|
|
|
// Assign the obtain information
|
|
|
|
inst.mWorld = world;
|
|
|
|
inst.mScale = scale;
|
|
|
|
inst.mSprID = sprid;
|
|
|
|
inst.mColor.SetRGBA(color);
|
2016-07-24 23:10:46 +02:00
|
|
|
inst.mPosition.SetVector3Ex(x, y, z);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Now we can try to allocate the instance after we have all the information
|
2017-02-21 20:24:59 +01:00
|
|
|
AllocBlip(entity_id, false, SQMOD_CREATE_POOL, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
break;
|
2019-06-02 12:57:08 +02:00
|
|
|
case vcmpEntityPoolCheckPoint:
|
|
|
|
// Do we even have this checkpoint that we're trying to delete?
|
|
|
|
if (is_deleted && VALID_ENTITY(m_Checkpoints[entity_id].mID))
|
|
|
|
{
|
|
|
|
DeallocCheckpoint(entity_id, false, SQMOD_DESTROY_POOL, NullLightObj());
|
|
|
|
}
|
|
|
|
// Do we already have this checkpoint that we're trying to create?
|
|
|
|
else if (INVALID_ENTITY(m_Checkpoints[entity_id].mID))
|
|
|
|
{
|
|
|
|
AllocCheckpoint(entity_id, false, SQMOD_CREATE_POOL, NullLightObj());
|
|
|
|
}
|
|
|
|
break;
|
2016-05-22 05:20:38 +02:00
|
|
|
default:
|
2021-01-30 07:51:39 +01:00
|
|
|
LogErr("Unknown change in the entity pool: type %d > entity %d", static_cast<int32_t>(entity_type), entity_id);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Finally, forward the event to the script
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnEntityPool.first)(static_cast< int32_t >(entity_type), entity_id, is_deleted);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::EntityPool")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitPlayerUpdate(int32_t player_id, vcmpPlayerUpdate update_type)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerUpdate(%d, %d)", player_id, static_cast<int32_t>(update_type))
|
2016-05-22 05:20:38 +02:00
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(player_id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot update player with invalid identifier: %d", player_id);
|
|
|
|
}
|
|
|
|
// Retrieve the associated tracking instance
|
|
|
|
PlayerInst & inst = m_Players[player_id];
|
|
|
|
|
|
|
|
// Obtain the current heading of this instance
|
2021-01-30 07:51:39 +01:00
|
|
|
float heading = _Func->GetPlayerHeading(player_id);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Did the heading change since the last tracked value?
|
|
|
|
if (!EpsEq(heading, inst.mLastHeading))
|
|
|
|
{
|
|
|
|
// Trigger the event specific to this change
|
2016-07-14 18:52:14 +02:00
|
|
|
if (inst.mTrackHeading != 0)
|
|
|
|
{
|
|
|
|
// Should we decrease the tracked position changes?
|
|
|
|
if (inst.mTrackHeading)
|
|
|
|
{
|
|
|
|
--inst.mTrackHeading;
|
|
|
|
}
|
2016-07-14 18:56:13 +02:00
|
|
|
// Now emit the event
|
|
|
|
EmitPlayerHeading(player_id, inst.mLastHeading, heading);
|
2016-07-14 18:52:14 +02:00
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Update the tracked value
|
|
|
|
inst.mLastHeading = heading;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3 pos;
|
|
|
|
// Obtain the current position of this instance
|
|
|
|
_Func->GetPlayerPosition(player_id, &pos.x, &pos.y, &pos.z);
|
|
|
|
// Did the position change since the last tracked value?
|
|
|
|
if (pos != inst.mLastPosition)
|
|
|
|
{
|
|
|
|
// Trigger the event specific to this change
|
2016-06-08 15:53:16 +02:00
|
|
|
if (inst.mTrackPosition != 0)
|
|
|
|
{
|
|
|
|
// Should we decrease the tracked position changes?
|
|
|
|
if (inst.mTrackPosition)
|
|
|
|
{
|
|
|
|
--inst.mTrackPosition;
|
|
|
|
}
|
2016-07-14 18:56:13 +02:00
|
|
|
// Now emit the event
|
|
|
|
EmitPlayerPosition(player_id);
|
2016-06-08 15:53:16 +02:00
|
|
|
}
|
2020-05-04 10:58:30 +02:00
|
|
|
// Should we check for distance traveled?
|
|
|
|
if (inst.mFlags & ENF_DIST_TRACK)
|
|
|
|
{
|
|
|
|
inst.mDistance += inst.mLastPosition.GetDistanceTo(pos);
|
|
|
|
}
|
|
|
|
// Should we check for area collision?
|
2017-06-19 03:09:35 +02:00
|
|
|
if (inst.mFlags & ENF_AREA_TRACK)
|
|
|
|
{
|
|
|
|
// Eliminate existing areas first, if the player is not in them anymore
|
|
|
|
inst.mAreas.erase(std::remove_if(inst.mAreas.begin(), inst.mAreas.end(),
|
|
|
|
[this, pos, player_id](AreaList::reference ap) -> bool {
|
|
|
|
// Is this player still in this area?
|
|
|
|
if (!ap.first->TestEx(pos.x, pos.y))
|
|
|
|
{
|
|
|
|
// Emit the script event
|
|
|
|
this->EmitPlayerLeaveArea(player_id, ap.second);
|
|
|
|
// Remove this area
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Still in this area
|
|
|
|
return false;
|
|
|
|
}), inst.mAreas.end());
|
|
|
|
// See if the player entered any new areas
|
|
|
|
AreaManager::Get().TestPoint([this, &inst, player_id](AreaList::reference ap) -> void {
|
|
|
|
// Was the player in this area before?
|
|
|
|
if (std::find_if(inst.mAreas.begin(), inst.mAreas.end(),
|
|
|
|
[a = ap.first](AreaList::reference ap) -> bool {
|
|
|
|
return (a == ap.first);
|
|
|
|
}) == inst.mAreas.end())
|
|
|
|
{
|
|
|
|
// The player just entered this area so emit the event
|
|
|
|
this->EmitPlayerEnterArea(player_id, ap.second);
|
|
|
|
// Now store this area so we know when the player leaves
|
|
|
|
inst.mAreas.emplace_back(ap);
|
|
|
|
}
|
|
|
|
// The player was in this area before so ignore it
|
|
|
|
}, pos.x, pos.y);
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Update the tracked value
|
|
|
|
inst.mLastPosition = pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Obtain the current health of this instance
|
2021-01-30 07:51:39 +01:00
|
|
|
float health = _Func->GetPlayerHealth(player_id);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Did the health change since the last tracked value?
|
|
|
|
if (!EpsEq(health, inst.mLastHealth))
|
|
|
|
{
|
|
|
|
// Trigger the event specific to this change
|
|
|
|
EmitPlayerHealth(player_id, inst.mLastHealth, health);
|
|
|
|
// Update the tracked value
|
|
|
|
inst.mLastHealth = health;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Obtain the current armor of this instance
|
2021-01-30 07:51:39 +01:00
|
|
|
float armour = _Func->GetPlayerArmour(player_id);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Did the armor change since the last tracked value?
|
|
|
|
if (!EpsEq(armour, inst.mLastArmour))
|
|
|
|
{
|
|
|
|
// Trigger the event specific to this change
|
|
|
|
EmitPlayerArmour(player_id, inst.mLastArmour, armour);
|
|
|
|
// Update the tracked value
|
|
|
|
inst.mLastArmour = armour;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Obtain the current weapon of this instance
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t wep = _Func->GetPlayerWeapon(player_id);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Did the weapon change since the last tracked value?
|
|
|
|
if (wep != inst.mLastWeapon)
|
|
|
|
{
|
|
|
|
// Trigger the event specific to this change
|
|
|
|
EmitPlayerWeapon(player_id, inst.mLastWeapon, wep);
|
|
|
|
// Update the tracked value
|
|
|
|
inst.mLastWeapon = wep;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, forward the call to the update callback
|
2021-01-30 07:51:39 +01:00
|
|
|
(*inst.mOnUpdate.first)(static_cast< int32_t >(update_type));
|
|
|
|
(*mOnPlayerUpdate.first)(inst.mObj, static_cast< int32_t >(update_type));
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerUpdate")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-01 23:39:06 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Core::EmitCheckpointStream(int32_t player_id, int32_t entity_id, bool is_deleted)
|
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::CheckpointStream(%d, %d, %d)", player_id, entity_id, is_deleted)
|
2019-06-01 23:39:06 +02:00
|
|
|
CheckpointInst & _checkpoint = m_Checkpoints.at(entity_id);
|
2019-06-02 17:58:38 +02:00
|
|
|
if (_checkpoint.mObj.IsNull()) return; // At fisrt call, the entity does not exist!
|
2019-06-01 23:39:06 +02:00
|
|
|
PlayerInst & _client = m_Players.at(player_id);
|
|
|
|
(*_checkpoint.mOnStream.first)(_client.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*_client.mOnEntityStream.first)(_checkpoint.mObj, static_cast< int32_t >(vcmpEntityPoolCheckPoint), is_deleted);
|
2019-06-01 23:39:06 +02:00
|
|
|
(*mOnCheckpointStream.first)(_client.mObj, _checkpoint.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnEntityStream.first)(_client.mObj, _checkpoint.mObj, static_cast< int32_t >(vcmpEntityPoolCheckPoint), is_deleted);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::CheckpointStream")
|
2019-06-01 23:39:06 +02:00
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Core::EmitObjectStream(int32_t player_id, int32_t entity_id, bool is_deleted)
|
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ObjectStream(%d, %d, %d)", player_id, entity_id, is_deleted)
|
2019-06-01 23:39:06 +02:00
|
|
|
ObjectInst & _object = m_Objects.at(entity_id);
|
2019-06-02 17:58:38 +02:00
|
|
|
if (_object.mObj.IsNull()) return; // At fisrt call, the entity does not exist!
|
2019-06-01 23:39:06 +02:00
|
|
|
PlayerInst & _client = m_Players.at(player_id);
|
|
|
|
(*_object.mOnStream.first)(_client.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*_client.mOnEntityStream.first)(_object.mObj, static_cast< int32_t >(vcmpEntityPoolObject), is_deleted);
|
2019-06-01 23:39:06 +02:00
|
|
|
(*mOnObjectStream.first)(_client.mObj, _object.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnEntityStream.first)(_client.mObj, _object.mObj, static_cast< int32_t >(vcmpEntityPoolObject), is_deleted);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ObjectStream")
|
2019-06-01 23:39:06 +02:00
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Core::EmitPickupStream(int32_t player_id, int32_t entity_id, bool is_deleted)
|
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PickupStream(%d, %d, %d)", player_id, entity_id, is_deleted)
|
2019-06-01 23:39:06 +02:00
|
|
|
PickupInst & _pickup = m_Pickups.at(entity_id);
|
2019-06-02 17:58:38 +02:00
|
|
|
if (_pickup.mObj.IsNull()) return; // At fisrt call, the entity does not exist!
|
2019-06-01 23:39:06 +02:00
|
|
|
PlayerInst & _client = m_Players.at(player_id);
|
|
|
|
(*_pickup.mOnStream.first)(_client.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*_client.mOnEntityStream.first)(_pickup.mObj, static_cast< int32_t >(vcmpEntityPoolPickup), is_deleted);
|
2019-06-01 23:39:06 +02:00
|
|
|
(*mOnPickupStream.first)(_client.mObj, _pickup.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnEntityStream.first)(_client.mObj, _pickup.mObj, static_cast< int32_t >(vcmpEntityPoolPickup), is_deleted);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PickupStream")
|
2019-06-01 23:39:06 +02:00
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Core::EmitPlayerStream(int32_t player_id, int32_t entity_id, bool is_deleted)
|
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::PlayerStream(%d, %d, %d)", player_id, entity_id, is_deleted)
|
2019-06-01 23:39:06 +02:00
|
|
|
PlayerInst & _player = m_Players.at(entity_id);
|
2019-06-02 17:58:38 +02:00
|
|
|
if (_player.mObj.IsNull()) return; // At fisrt call, the entity does not exist!
|
2019-06-01 23:39:06 +02:00
|
|
|
PlayerInst & _client = m_Players.at(player_id);
|
|
|
|
(*_player.mOnStream.first)(_client.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*_client.mOnEntityStream.first)(_player.mObj, static_cast< int32_t >(vcmpEntityPoolPlayer), is_deleted);
|
2019-06-01 23:39:06 +02:00
|
|
|
(*mOnPlayerStream.first)(_client.mObj, _player.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnEntityStream.first)(_client.mObj, _player.mObj, static_cast< int32_t >(vcmpEntityPoolPlayer), is_deleted);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::PlayerStream")
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Core::EmitVehicleStream(int32_t player_id, int32_t entity_id, bool is_deleted)
|
|
|
|
{
|
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleStream(%d, %d, %d)", player_id, entity_id, is_deleted)
|
|
|
|
VehicleInst & _vehicle = m_Vehicles.at(entity_id);
|
2019-06-02 17:58:38 +02:00
|
|
|
if (_vehicle.mObj.IsNull()) return; // At fisrt call, the entity does not exist!
|
2019-06-02 16:43:04 +02:00
|
|
|
PlayerInst & _client = m_Players.at(player_id);
|
|
|
|
(*_vehicle.mOnStream.first)(_client.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*_client.mOnEntityStream.first)(_vehicle.mObj, static_cast< int32_t >(vcmpEntityPoolVehicle), is_deleted);
|
2019-06-02 16:43:04 +02:00
|
|
|
(*mOnVehicleStream.first)(_client.mObj, _vehicle.mObj, is_deleted);
|
2021-01-30 07:51:39 +01:00
|
|
|
(*mOnEntityStream.first)(_client.mObj, _vehicle.mObj, static_cast< int32_t >(vcmpEntityPoolVehicle), is_deleted);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleStream")
|
2019-06-01 23:39:06 +02:00
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Core::EmitEntityStreaming(int32_t player_id, int32_t entity_id, vcmpEntityPool entity_type, bool is_deleted)
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::EntityStreaming(%d, %d, %d, %d)", player_id, entity_id, static_cast<int32_t>(entity_type), is_deleted)
|
2019-06-01 23:39:06 +02:00
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(player_id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot notify player with invalid identifier about streaming: %d", player_id);
|
|
|
|
}
|
|
|
|
// See what type of entity changed
|
|
|
|
switch (entity_type)
|
|
|
|
{
|
|
|
|
case vcmpEntityPoolVehicle: {
|
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(entity_id, SQMOD_VEHICLE_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot stream vehicle with invalid identifier: %d", entity_id);
|
|
|
|
}
|
|
|
|
// Forward the event to the dedicated handler
|
|
|
|
EmitVehicleStream(player_id, entity_id, is_deleted);
|
|
|
|
} break;
|
|
|
|
case vcmpEntityPoolObject: {
|
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(entity_id, SQMOD_OBJECT_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot stream object with invalid identifier: %d", entity_id);
|
|
|
|
}
|
|
|
|
// Forward the event to the dedicated handler
|
|
|
|
EmitObjectStream(player_id, entity_id, is_deleted);
|
|
|
|
} break;
|
|
|
|
case vcmpEntityPoolPickup: {
|
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(entity_id, SQMOD_PICKUP_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot stream pickup with invalid identifier: %d", entity_id);
|
|
|
|
}
|
|
|
|
// Forward the event to the dedicated handler
|
|
|
|
EmitPickupStream(player_id, entity_id, is_deleted);
|
|
|
|
} break;
|
|
|
|
case vcmpEntityPoolPlayer: {
|
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(entity_id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot stream player with invalid identifier: %d", entity_id);
|
|
|
|
}
|
|
|
|
// Forward the event to the dedicated handler
|
|
|
|
EmitPlayerStream(player_id, entity_id, is_deleted);
|
|
|
|
} break;
|
|
|
|
case vcmpEntityPoolCheckPoint: {
|
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(entity_id, SQMOD_CHECKPOINT_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot stream checkpoint with invalid identifier: %d", entity_id);
|
|
|
|
}
|
|
|
|
// Forward the event to the dedicated handler
|
|
|
|
EmitCheckpointStream(player_id, entity_id, is_deleted);
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
LogErr("Unknown change in entity streaming: client %d > type %d > entity %d", player_id, entity_type, entity_id);
|
|
|
|
}
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::EntityStreaming")
|
2019-06-01 23:39:06 +02:00
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitVehicleUpdate(int32_t vehicle_id, vcmpVehicleUpdate update_type)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleUpdate(%d, %d)", vehicle_id, static_cast<int32_t>(update_type))
|
2016-05-22 05:20:38 +02:00
|
|
|
// Make sure that the specified entity identifier is valid
|
|
|
|
if (INVALID_ENTITYEX(vehicle_id, SQMOD_VEHICLE_POOL))
|
|
|
|
{
|
|
|
|
STHROWF("Cannot update vehicle with invalid identifier: %d", vehicle_id);
|
|
|
|
}
|
|
|
|
// Retrieve the associated instance
|
|
|
|
VehicleInst & inst = m_Vehicles[vehicle_id];
|
|
|
|
// Identify the update type
|
|
|
|
switch (update_type)
|
|
|
|
{
|
|
|
|
case vcmpVehicleUpdatePosition:
|
|
|
|
{
|
|
|
|
// Trigger the event specific to this change
|
2016-06-08 15:53:16 +02:00
|
|
|
if (inst.mTrackPosition != 0)
|
|
|
|
{
|
|
|
|
// Should we decrease the tracked position changes?
|
|
|
|
if (inst.mTrackPosition)
|
|
|
|
{
|
|
|
|
--inst.mTrackPosition;
|
|
|
|
}
|
2016-07-14 18:56:13 +02:00
|
|
|
// Now emit the event
|
|
|
|
EmitVehiclePosition(vehicle_id);
|
2016-06-08 15:53:16 +02:00
|
|
|
}
|
2017-06-19 03:09:35 +02:00
|
|
|
// New vehicle position
|
|
|
|
Vector3 pos;
|
|
|
|
// Retrieve the current vehicle position
|
|
|
|
_Func->GetVehiclePosition(vehicle_id, &pos.x, &pos.y, &pos.z);
|
2020-05-04 10:58:30 +02:00
|
|
|
// Should we check for distance traveled?
|
|
|
|
if (inst.mFlags & ENF_DIST_TRACK)
|
|
|
|
{
|
|
|
|
inst.mDistance += inst.mLastPosition.GetDistanceTo(pos);
|
|
|
|
}
|
|
|
|
// Should we check for area collision?
|
2017-06-19 03:09:35 +02:00
|
|
|
if (inst.mFlags & ENF_AREA_TRACK)
|
|
|
|
{
|
|
|
|
// Eliminate existing areas first, if the vehicle is not in them anymore
|
|
|
|
inst.mAreas.erase(std::remove_if(inst.mAreas.begin(), inst.mAreas.end(),
|
|
|
|
[this, pos, vehicle_id](AreaList::reference ap) -> bool {
|
|
|
|
// Is this vehicle still in this area?
|
|
|
|
if (!ap.first->TestEx(pos.x, pos.y))
|
|
|
|
{
|
|
|
|
// Emit the script event
|
|
|
|
this->EmitVehicleLeaveArea(vehicle_id, ap.second);
|
|
|
|
// Remove this area
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Still in this area
|
|
|
|
return false;
|
|
|
|
}), inst.mAreas.end());
|
|
|
|
// See if the vehicle entered any new areas
|
|
|
|
AreaManager::Get().TestPoint([this, &inst, vehicle_id](AreaList::reference ap) -> void {
|
|
|
|
// Was the vehicle in this area before?
|
|
|
|
if (std::find_if(inst.mAreas.begin(), inst.mAreas.end(),
|
|
|
|
[a = ap.first](AreaList::reference ap) -> bool {
|
|
|
|
return (a == ap.first);
|
|
|
|
}) == inst.mAreas.end())
|
|
|
|
{
|
|
|
|
// The vehicle just entered this area so emit the event
|
|
|
|
this->EmitVehicleEnterArea(vehicle_id, ap.second);
|
|
|
|
// Now store this area so we know when the vehicle leaves
|
|
|
|
inst.mAreas.emplace_back(ap);
|
|
|
|
}
|
|
|
|
// The vehicle was in this area before so ignore it
|
|
|
|
}, pos.x, pos.y);
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Update the tracked value
|
2017-06-19 03:09:35 +02:00
|
|
|
inst.mLastPosition = pos;
|
2016-05-22 05:20:38 +02:00
|
|
|
} break;
|
|
|
|
case vcmpVehicleUpdateHealth:
|
|
|
|
{
|
|
|
|
// Obtain the current health of this instance
|
2021-01-30 07:51:39 +01:00
|
|
|
float health = _Func->GetVehicleHealth(vehicle_id);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Trigger the event specific to this change
|
|
|
|
EmitVehicleHealth(vehicle_id, inst.mLastHealth, health);
|
|
|
|
// Update the tracked value
|
|
|
|
inst.mLastHealth = health;
|
|
|
|
} break;
|
|
|
|
case vcmpVehicleUpdateColour:
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t primary, secondary;
|
2016-08-21 17:07:35 +02:00
|
|
|
// Obtain the current colors of this instance
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->GetVehicleColour(vehicle_id, &primary, &secondary);
|
2016-08-21 17:07:35 +02:00
|
|
|
// Which colors changed
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t changed = 0;
|
2016-08-21 17:07:35 +02:00
|
|
|
// Did the primary color changed?
|
|
|
|
if (primary != inst.mLastPrimaryColor)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
changed |= (1<<0);
|
|
|
|
}
|
2016-08-21 17:07:35 +02:00
|
|
|
// Did the secondary color changed?
|
|
|
|
if (primary != inst.mLastSecondaryColor)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
changed |= (1<<1);
|
|
|
|
}
|
|
|
|
// Trigger the event specific to this change
|
2016-08-21 17:07:35 +02:00
|
|
|
EmitVehicleColor(vehicle_id, changed);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Update the tracked value
|
2016-08-21 17:07:35 +02:00
|
|
|
inst.mLastPrimaryColor = primary;
|
|
|
|
inst.mLastSecondaryColor = secondary;
|
2016-05-22 05:20:38 +02:00
|
|
|
} break;
|
|
|
|
case vcmpVehicleUpdateRotation:
|
|
|
|
{
|
|
|
|
// Trigger the event specific to this change
|
2016-06-08 15:53:16 +02:00
|
|
|
if (inst.mTrackRotation != 0)
|
|
|
|
{
|
|
|
|
// Should we decrease the tracked rotation changes?
|
|
|
|
if (inst.mTrackRotation)
|
|
|
|
{
|
|
|
|
--inst.mTrackRotation;
|
|
|
|
}
|
2016-07-14 18:56:13 +02:00
|
|
|
// Now emit the event
|
|
|
|
EmitVehicleRotation(vehicle_id);
|
2016-06-08 15:53:16 +02:00
|
|
|
}
|
|
|
|
// Obtain the current rotation of this instance
|
|
|
|
_Func->GetVehicleRotation(vehicle_id, &inst.mLastRotation.x, &inst.mLastRotation.y,
|
|
|
|
&inst.mLastRotation.z, &inst.mLastRotation.w);
|
2016-05-22 05:20:38 +02:00
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
// Finally, forward the call to the update callback
|
2021-01-30 07:51:39 +01:00
|
|
|
(*inst.mOnUpdate.first)(static_cast< int32_t >(update_type));
|
|
|
|
(*mOnVehicleUpdate.first)(inst.mObj, static_cast< int32_t >(update_type));
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
}
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::VehicleUpdate")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void Core::EmitClientScriptData(int32_t player_id, const uint8_t * data, size_t size)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::ClientScriptData(%d, [byte stream], %" PRINT_SZ_FMT ")", player_id, size)
|
2020-03-22 05:53:04 +01:00
|
|
|
PlayerInst & _player = m_Players.at(static_cast< size_t >(player_id));
|
2016-06-20 17:02:44 +02:00
|
|
|
// Don't even bother if there's no one listening
|
2017-02-21 20:24:59 +01:00
|
|
|
if (_player.mOnClientScriptData.first->IsEmpty() && mOnClientScriptData.first->IsEmpty())
|
2016-06-20 17:02:44 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Allocate a buffer with the received size
|
2020-03-22 09:31:43 +01:00
|
|
|
Buffer b(static_cast< Buffer::SzType >(size));
|
2016-05-22 05:20:38 +02:00
|
|
|
// Replicate the data to the allocated buffer
|
2020-03-22 09:31:43 +01:00
|
|
|
b.Write(0, reinterpret_cast< Buffer::ConstPtr >(data), static_cast< Buffer::SzType >(size));
|
2016-06-20 17:02:44 +02:00
|
|
|
// Prepare an object for the obtained buffer
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj o;
|
2016-06-20 17:02:44 +02:00
|
|
|
// Attempt to create the requested buffer
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Remember the current stack size
|
|
|
|
const StackGuard sg;
|
|
|
|
// Create a protected instance of a buffer wrapper
|
2019-01-29 17:44:55 +01:00
|
|
|
DeleteGuard< SqBuffer > ad(new SqBuffer(std::move(b)));
|
2016-06-20 17:02:44 +02:00
|
|
|
// Transform the pointer into a script object
|
2020-04-27 12:10:54 +02:00
|
|
|
PushVar< SqBuffer * >(SqVM(), ad.Get());
|
2016-06-20 17:02:44 +02:00
|
|
|
// The script took over the instance now
|
|
|
|
ad.Release();
|
|
|
|
// Get the object from the stack and store it
|
2020-04-27 12:10:54 +02:00
|
|
|
o = Var< LightObj >(SqVM(), -1).value;
|
2016-06-20 17:02:44 +02:00
|
|
|
}
|
|
|
|
catch (const std::exception & e)
|
|
|
|
{
|
|
|
|
STHROWF("%s", e.what()); // Re-package
|
|
|
|
}
|
|
|
|
// Make sure the buffer cannot be null at this point
|
2016-06-20 13:30:48 +02:00
|
|
|
if (o.IsNull())
|
|
|
|
{
|
|
|
|
STHROWF("Unable to transform script data into buffer");
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Forward the event call
|
2017-02-21 20:24:59 +01:00
|
|
|
(*_player.mOnClientScriptData.first)(o, size);
|
|
|
|
(*mOnClientScriptData.first)(_player.mObj, o, size);
|
2019-06-02 16:43:04 +02:00
|
|
|
SQMOD_CO_EV_TRACEBACK("[TRACE>] Core::ClientScriptData")
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
2019-06-02 16:43:04 +02:00
|
|
|
#undef NULL_SQOBJ_ // don't need this anymore
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
} // Namespace:: SqMod
|