1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

More code cleanup.

This commit is contained in:
Sandu Liviu Catalin 2020-03-22 10:00:31 +02:00
parent 3225e119a2
commit 33f057ac15
16 changed files with 207 additions and 258 deletions

View File

@ -1266,7 +1266,7 @@ public:
void EmitVehicleTyreStatus(Int32 vehicle_id, Int32 tyre, Int32 old_status, Int32 new_status);
void EmitVehicleDamageData(Int32 vehicle_id, Uint32 old_data, Uint32 new_data);
void EmitVehicleRadio(Int32 vehicle_id, Int32 old_radio, Int32 new_radio);
void EmitVehicleHandlingRule(Int32 vehicle_id, Int32 rule, Float32 old_data, Float32 new_data);
void EmitVehicleHandlingRule(Int32 vehicle_id, Int32 rule, SQFloat old_data, SQFloat new_data);
void EmitVehicleEnterArea(Int32 player_id, LightObj & area_obj);
void EmitVehicleLeaveArea(Int32 player_id, LightObj & area_obj);
void EmitServerOption(Int32 option, bool value, Int32 header, LightObj & payload);

View File

@ -1258,7 +1258,7 @@ void Core::EmitVehicleRadio(Int32 vehicle_id, Int32 old_radio, Int32 new_radio)
}
// ------------------------------------------------------------------------------------------------
void Core::EmitVehicleHandlingRule(Int32 vehicle_id, Int32 rule, Float32 old_data, Float32 new_data)
void Core::EmitVehicleHandlingRule(Int32 vehicle_id, Int32 rule, SQFloat old_data, SQFloat new_data)
{
SQMOD_CO_EV_TRACEBACK("[TRACE<] Core::VehicleHandlingRule(%d, %d, %f, %f)", vehicle_id, rule, old_data, new_data)
VehicleInst & _vehicle = m_Vehicles.at(static_cast< size_t >(vehicle_id));

View File

@ -33,12 +33,6 @@ CBlip::CBlip(Int32 id)
/* ... */
}
// ------------------------------------------------------------------------------------------------
CBlip::~CBlip()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CBlip::ToString() const
{
@ -56,7 +50,7 @@ void CBlip::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
}
else
{
@ -228,7 +222,7 @@ Int32 CBlip::GetColorA() const
static LightObj & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, Int32 scale,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
{
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid, // NOLINT(hicpp-signed-bitwise)
SQMOD_CREATE_DEFAULT, NullLightObj());
}
@ -236,7 +230,7 @@ static LightObj & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, In
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
Int32 header, LightObj & payload)
{
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(-1, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid, // NOLINT(hicpp-signed-bitwise)
header, payload);
}
@ -244,7 +238,7 @@ static LightObj & Blip_CreateEx(Int32 world, Float32 x, Float32 y, Float32 z, In
static LightObj & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y, Float32 z,
Int32 scale, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid)
{
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid, // NOLINT(hicpp-signed-bitwise)
SQMOD_CREATE_DEFAULT, NullLightObj());
}
@ -252,7 +246,7 @@ static LightObj & Blip_CreateEx(Int32 index, Int32 world, Float32 x, Float32 y,
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Int32 sprid,
Int32 header, LightObj & payload)
{
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid,
return Core::Get().NewBlip(index, world, x, y, z, scale, SQMOD_PACK_RGBA(r, g, b, a), sprid, // NOLINT(hicpp-signed-bitwise)
header, payload);
}
@ -287,7 +281,10 @@ static LightObj & Blip_Create(Int32 index, Int32 world, const Vector3 & pos, Int
}
// ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_CBlip(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{
RootTable(vm).Bind(Typename::Str,
Class< CBlip, NoConstructor< CBlip > >(vm, Typename::Str)

View File

@ -34,7 +34,7 @@ private:
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CBlip(Int32 id);
explicit CBlip(Int32 id);
public:
@ -53,11 +53,6 @@ public:
*/
CBlip(CBlip &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CBlip();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/

View File

@ -36,12 +36,6 @@ CCheckpoint::CCheckpoint(Int32 id)
/* ... */
}
// ------------------------------------------------------------------------------------------------
CCheckpoint::~CCheckpoint()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CCheckpoint::ToString() const
{
@ -59,7 +53,7 @@ void CCheckpoint::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
}
else
{
@ -185,8 +179,8 @@ Color4 CCheckpoint::GetColor() const
// Query the server for the color values
_Func->GetCheckPointColour(m_ID, &r, &g, &b, &a);
// Return the requested information
return Color4(ConvTo< Color4::Value >::From(r), ConvTo< Color4::Value >::From(g),
ConvTo< Color4::Value >::From(b), ConvTo< Color4::Value >::From(a));
return {ConvTo< Color4::Value >::From(r), ConvTo< Color4::Value >::From(g),
ConvTo< Color4::Value >::From(b), ConvTo< Color4::Value >::From(a)};
}
// ------------------------------------------------------------------------------------------------
@ -508,7 +502,10 @@ static LightObj & Checkpoint_Create(Int32 world, bool sphere, const Vector3 & po
}
// ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_CCheckpoint(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{
RootTable(vm).Bind(Typename::Str,
Class< CCheckpoint, NoConstructor< CCheckpoint > >(vm, Typename::Str)

View File

@ -11,8 +11,8 @@ namespace SqMod {
*/
enum CheckpointCircularLocks
{
CHECKPOINTCL_EMIT_CHECKPOINT_WORLD = (1 << 0),
CHECKPOINTCL_EMIT_CHECKPOINT_RADIUS = (1 << 1)
CHECKPOINTCL_EMIT_CHECKPOINT_WORLD = (1u << 0u),
CHECKPOINTCL_EMIT_CHECKPOINT_RADIUS = (1u << 1u)
};
/* ------------------------------------------------------------------------------------------------
@ -48,7 +48,7 @@ private:
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CCheckpoint(Int32 id);
explicit CCheckpoint(Int32 id);
public:
@ -67,11 +67,6 @@ public:
*/
CCheckpoint(CCheckpoint &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CCheckpoint();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/

View File

@ -33,12 +33,6 @@ CKeybind::CKeybind(Int32 id)
/* ... */
}
// ------------------------------------------------------------------------------------------------
CKeybind::~CKeybind()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CKeybind::ToString() const
{
@ -56,7 +50,7 @@ void CKeybind::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
}
else
{
@ -149,7 +143,7 @@ bool CKeybind::IsRelease() const
// Validate the managed identifier
Validate();
// Return the requested information
return Core::Get().GetKeybind(m_ID).mRelease;
return static_cast< bool >(Core::Get().GetKeybind(m_ID).mRelease);
}
// ------------------------------------------------------------------------------------------------
@ -186,7 +180,10 @@ static SQInteger Keybind_UnusedSlot()
}
// ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_CKeybind(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{
RootTable(vm).Bind(Typename::Str,
Class< CKeybind, NoConstructor< CKeybind > >(vm, Typename::Str)

View File

@ -34,7 +34,7 @@ private:
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CKeybind(Int32 id);
explicit CKeybind(Int32 id);
public:
@ -53,11 +53,6 @@ public:
*/
CKeybind(CKeybind &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CKeybind();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/

View File

@ -42,12 +42,6 @@ CObject::CObject(Int32 id)
/* ... */
}
// ------------------------------------------------------------------------------------------------
CObject::~CObject()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CObject::ToString() const
{
@ -65,7 +59,7 @@ void CObject::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
}
else
{
@ -407,7 +401,7 @@ void CObject::SetShotReport(bool toggle)
return;
}
// Avoid property unwind from a recursive call
_Func->SetObjectShotReportEnabled(m_ID, toggle);
_Func->SetObjectShotReportEnabled(m_ID, static_cast< uint8_t >(toggle));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
{
@ -440,7 +434,7 @@ void CObject::SetTouchedReport(bool toggle)
return;
}
// Avoid property unwind from a recursive call
_Func->SetObjectTouchedReportEnabled(m_ID, toggle);
_Func->SetObjectTouchedReportEnabled(m_ID, static_cast< uint8_t >(toggle));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
{
@ -867,7 +861,10 @@ static LightObj & Object_Create(Int32 model, Int32 world, const Vector3 & pos, I
}
// ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_CObject(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{
RootTable(vm).Bind(Typename::Str,
Class< CObject, NoConstructor< CObject > >(vm, Typename::Str)

View File

@ -11,9 +11,9 @@ namespace SqMod {
*/
enum ObjectCircularLocks
{
OBJECTCL_EMIT_OBJECT_WORLD = (1 << 0),
OBJECTCL_EMIT_OBJECT_ALPHA = (2 << 0),
OBJECTCL_EMIT_OBJECT_REPORT = (3 << 0)
OBJECTCL_EMIT_OBJECT_WORLD = (1u << 0u),
OBJECTCL_EMIT_OBJECT_ALPHA = (2u << 0u),
OBJECTCL_EMIT_OBJECT_REPORT = (3u << 0u)
};
/* ------------------------------------------------------------------------------------------------
@ -49,7 +49,7 @@ private:
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CObject(Int32 id);
explicit CObject(Int32 id);
public:
@ -86,11 +86,6 @@ public:
*/
CObject(CObject &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CObject();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/

View File

@ -35,12 +35,6 @@ CPickup::CPickup(Int32 id)
/* ... */
}
// ------------------------------------------------------------------------------------------------
CPickup::~CPickup()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CPickup::ToString() const
{
@ -58,7 +52,7 @@ void CPickup::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
}
else
{
@ -153,7 +147,7 @@ void CPickup::SetOption(Int32 option_id, bool toggle)
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
// Attempt to modify the current value of the specified option
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
@ -173,7 +167,7 @@ void CPickup::SetOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj &
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
// Attempt to modify the current value of the specified option
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
@ -274,7 +268,7 @@ void CPickup::SetAutomatic(bool toggle)
return;
}
// Avoid property unwind from a recursive call
_Func->SetPickupIsAutomatic(m_ID, toggle);
_Func->SetPickupIsAutomatic(m_ID, static_cast< uint8_t >(toggle));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOMATIC))
{
@ -307,7 +301,7 @@ void CPickup::SetAutoTimer(Int32 timer)
return;
}
// Avoid property unwind from a recursive call
_Func->SetPickupAutoTimer(m_ID, timer);
_Func->SetPickupAutoTimer(m_ID, static_cast< uint32_t >(timer));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOTIMER))
{
@ -485,7 +479,10 @@ static LightObj & Pickup_Create(Int32 model, Int32 world, Int32 quantity, const
}
// ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_CPickup(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{
RootTable(vm).Bind(Typename::Str,
Class< CPickup, NoConstructor< CPickup > >(vm, Typename::Str)

View File

@ -11,11 +11,11 @@ namespace SqMod {
*/
enum PickupCircularLocks
{
PICKUPCL_EMIT_PICKUP_OPTION = (1 << 0),
PICKUPCL_EMIT_PICKUP_WORLD = (1 << 1),
PICKUPCL_EMIT_PICKUP_ALPHA = (1 << 2),
PICKUPCL_EMIT_PICKUP_AUTOMATIC = (1 << 3),
PICKUPCL_EMIT_PICKUP_AUTOTIMER = (1 << 4)
PICKUPCL_EMIT_PICKUP_OPTION = (1u << 0u),
PICKUPCL_EMIT_PICKUP_WORLD = (1u << 1u),
PICKUPCL_EMIT_PICKUP_ALPHA = (1u << 2u),
PICKUPCL_EMIT_PICKUP_AUTOMATIC = (1u << 3u),
PICKUPCL_EMIT_PICKUP_AUTOTIMER = (1u << 4u)
};
/* ------------------------------------------------------------------------------------------------
@ -51,7 +51,7 @@ private:
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CPickup(Int32 id);
explicit CPickup(Int32 id);
public:
@ -70,11 +70,6 @@ public:
*/
CPickup(CPickup &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CPickup();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/

View File

@ -9,12 +9,6 @@
#include "Misc/Areas.hpp"
#include "Misc/Tasks.hpp"
// ------------------------------------------------------------------------------------------------
#include <cstring>
// ------------------------------------------------------------------------------------------------
#include <sqstdstring.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
@ -59,18 +53,12 @@ CPlayer::CPlayer(Int32 id)
, mLimitPrefixPostfixMessage(true)
{
// Reset message prefixes
for (unsigned n = 0; n < SQMOD_PLAYER_MSG_PREFIXES; ++n)
for (auto & mMessagePrefixe : mMessagePrefixes)
{
mMessagePrefixes[n].assign(_SC(""));
mMessagePrefixe.assign(_SC(""));
}
}
// ------------------------------------------------------------------------------------------------
CPlayer::~CPlayer()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CPlayer::ToString() const
{
@ -88,7 +76,7 @@ void CPlayer::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
}
else
{
@ -181,7 +169,7 @@ void CPlayer::SetAdmin(bool toggle)
return;
}
// Avoid property unwind from a recursive call
_Func->SetPlayerAdmin(m_ID, toggle);
_Func->SetPlayerAdmin(m_ID, static_cast< uint8_t >(toggle));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ADMIN))
{
@ -387,7 +375,8 @@ void CPlayer::SetOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj &
}
// Avoid property unwind from a recursive call
else if (_Func->SetPlayerOption(m_ID,
static_cast< vcmpPlayerOption >(option_id), toggle) == vcmpErrorArgumentOutOfBounds)
static_cast< vcmpPlayerOption >(option_id),
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
@ -616,7 +605,7 @@ void CPlayer::SetColorEx(Uint8 r, Uint8 g, Uint8 b) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetPlayerColour(m_ID, SQMOD_PACK_RGB(r, g, b));
_Func->SetPlayerColour(m_ID, SQMOD_PACK_RGB(r, g, b)); // NOLINT(hicpp-signed-bitwise)
}
// ------------------------------------------------------------------------------------------------
@ -783,12 +772,12 @@ Int32 CPlayer::GetPing() const
}
// ------------------------------------------------------------------------------------------------
Float32 CPlayer::GetFPS() const
SQFloat CPlayer::GetFPS() const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetPlayerFPS(m_ID);
return static_cast< SQFloat >(_Func->GetPlayerFPS(m_ID));
}
// ------------------------------------------------------------------------------------------------
@ -844,7 +833,7 @@ void CPlayer::SetImmunity(Int32 flags)
// Grab the current value for this property
const Int32 current = _Func->GetPlayerImmunityFlags(m_ID);
// Avoid property unwind from a recursive call
_Func->SetPlayerImmunityFlags(m_ID, flags);
_Func->SetPlayerImmunityFlags(m_ID, static_cast< uint32_t >(flags));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_IMMUNITY))
{
@ -981,7 +970,7 @@ void CPlayer::SetAlphaEx(Int32 alpha, Int32 fade)
return;
}
// Avoid property unwind from a recursive call
_Func->SetPlayerAlpha(m_ID, alpha, fade);
_Func->SetPlayerAlpha(m_ID, alpha, static_cast< uint32_t >(fade));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ALPHA))
{
@ -1065,8 +1054,8 @@ bool CPlayer::Embark(CVehicle & vehicle) const
// Validate the managed identifier
Validate();
// Perform the requested operation
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), 0, true, true)
!= vcmpErrorRequestDenied);
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), 0,
static_cast< uint8_t >(true), static_cast< uint8_t >(true)) != vcmpErrorRequestDenied);
}
// ------------------------------------------------------------------------------------------------
@ -1080,8 +1069,8 @@ bool CPlayer::Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) c
// Validate the managed identifier
Validate();
// Perform the requested operation
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), slot, allocate, warp)
!= vcmpErrorRequestDenied);
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), slot,
static_cast< uint8_t >(allocate), static_cast< uint8_t >(warp)) != vcmpErrorRequestDenied);
}
// ------------------------------------------------------------------------------------------------
@ -1396,7 +1385,7 @@ void CPlayer::SetSpectatorID(SQInteger id) const
// Validate the managed identifier
Validate();
// Spectate the given target
_Func->SetPlayerSpectateTarget(m_ID, id);
_Func->SetPlayerSpectateTarget(m_ID, static_cast< int32_t >(id));
}
// ------------------------------------------------------------------------------------------------
@ -1581,7 +1570,7 @@ bool CPlayer::GetCollideAreas() const
// Validate the managed identifier
Validate();
// Return the requested information
return (Core::Get().GetPlayer(m_ID).mFlags & ENF_AREA_TRACK);
return static_cast< bool >(Core::Get().GetPlayer(m_ID).mFlags & ENF_AREA_TRACK);
}
void CPlayer::SetCollideAreas(bool toggle) const
@ -1695,7 +1684,8 @@ void CPlayer::SetMessagePrefix(Uint32 index, StackStrF & prefix)
// Validate the managed identifier
Validate();
// Perform the requested operation
mMessagePrefixes[index].assign(prefix.mPtr, ClampMin(prefix.mLen, 0));
mMessagePrefixes[index].assign(prefix.mPtr,
static_cast< size_t >(ClampMin(prefix.mLen, 0)));
}
// ------------------------------------------------------------------------------------------------
@ -1822,7 +1812,7 @@ void CPlayer::SetBufferCursor(Int32 pos)
// Validate the managed identifier
Validate();
// Perform the requested operation
m_Buffer.Move(pos);
m_Buffer.Move(static_cast< Buffer::SzType >(pos));
}
// ------------------------------------------------------------------------------------------------
@ -1869,7 +1859,7 @@ void CPlayer::StreamString(StackStrF & val)
// Calculate the string length
Uint16 length = ConvTo< Uint16 >::From(val.mLen);
// Change the size endianness to big endian
Uint16 size = ((length >> 8) & 0xFF) | ((length & 0xFF) << 8);
auto size = static_cast< Uint16 >(((length >> 8u) & 0xFFu) | ((length & 0xFFu) << 8u)); // NOLINT(hicpp-signed-bitwise)
// Write the size and then the string contents
m_Buffer.Push< Uint16 >(size);
m_Buffer.AppendS(val.mPtr, length);
@ -1881,7 +1871,7 @@ void CPlayer::StreamRawString(StackStrF & val)
// Validate the managed identifier
Validate();
// Write the the string contents
m_Buffer.AppendS(val.mPtr, ClampMin(val.mLen, 0));
m_Buffer.AppendS(val.mPtr, static_cast< Buffer::SzType >(ClampMin(val.mLen, 0)));
}
// ------------------------------------------------------------------------------------------------
@ -2024,7 +2014,7 @@ Int32 CPlayer::GetColorR() const
// Validate the managed identifier
Validate();
// Return the requested information
return static_cast< Int32 >((_Func->GetPlayerColour(m_ID) >> 16) & 0xFF);
return static_cast< Int32 >((_Func->GetPlayerColour(m_ID) >> 16u) & 0xFFu);
}
// ------------------------------------------------------------------------------------------------
@ -2033,7 +2023,7 @@ Int32 CPlayer::GetColorG() const
// Validate the managed identifier
Validate();
// Return the requested information
return static_cast< Int32 >((_Func->GetPlayerColour(m_ID) >> 8) & 0xFF);
return static_cast< Int32 >((_Func->GetPlayerColour(m_ID) >> 8u) & 0xFFu);
}
// ------------------------------------------------------------------------------------------------
@ -2042,7 +2032,7 @@ Int32 CPlayer::GetColorB() const
// Validate the managed identifier
Validate();
// Return the requested information
return static_cast< Int32 >(_Func->GetPlayerColour(m_ID) & 0xFF);
return static_cast< Int32 >(_Func->GetPlayerColour(m_ID) & 0xFFu);
}
// ------------------------------------------------------------------------------------------------
@ -2051,8 +2041,8 @@ void CPlayer::SetColorR(Int32 r) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(r) << 16) |
(~(0xFF << 16) & _Func->GetPlayerColour(m_ID)));
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(r) << 16u) | // NOLINT(hicpp-signed-bitwise)
(~(0xFFu << 16u) & _Func->GetPlayerColour(m_ID)));
}
// ------------------------------------------------------------------------------------------------
@ -2061,8 +2051,8 @@ void CPlayer::SetColorG(Int32 g) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(g) << 8) |
(~(0xFF << 8) & _Func->GetPlayerColour(m_ID)));
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(g) << 8u) | // NOLINT(hicpp-signed-bitwise)
(~(0xFFu << 8u) & _Func->GetPlayerColour(m_ID)));
}
// ------------------------------------------------------------------------------------------------
@ -2072,14 +2062,14 @@ void CPlayer::SetColorB(Int32 g) const
Validate();
// Perform the requested operation
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(g)) |
(~(0xFF) & _Func->GetPlayerColour(m_ID)));
(~(0xFFu) & _Func->GetPlayerColour(m_ID)));
}
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::Msg(HSQUIRRELVM vm)
{
// The function needs at least 2 arguments
const Int32 top = sq_gettop(vm);
const auto top = sq_gettop(vm);
// Was the message color specified?
if (top <= 1)
{
@ -2154,7 +2144,7 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm)
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
const auto top = sq_gettop(vm);
// Was the index of the message prefix specified?
if (top <= 1)
{
@ -2216,7 +2206,7 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
return val.mRes; // Propagate the error!
}
vcmpError result = vcmpErrorNone;
vcmpError result;
// Send the resulted message string
if (player->mLimitPrefixPostfixMessage)
{
@ -2243,7 +2233,7 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
const auto top = sq_gettop(vm);
// Was the index of the message prefix specified?
if (top <= 1)
{
@ -2322,7 +2312,7 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
return val.mRes; // Propagate the error!
}
vcmpError result = vcmpErrorNone;
vcmpError result;
// Send the resulted message string
if (player->mLimitPrefixPostfixMessage)
{
@ -2349,7 +2339,7 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::Message(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
const auto top = sq_gettop(vm);
// Was the message value specified?
if (top <= 1)
{
@ -2406,7 +2396,7 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm)
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::Announce(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
const auto top = sq_gettop(vm);
// Was the announcement value specified?
if (top <= 1)
{
@ -2468,7 +2458,7 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm)
// ------------------------------------------------------------------------------------------------
SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
{
const Int32 top = sq_gettop(vm);
const auto top = sq_gettop(vm);
// Was the announcement style specified?
if (top <= 1)
{
@ -2522,7 +2512,6 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
// Validate the result
if (result == vcmpErrorArgumentOutOfBounds)
{
return sq_throwerror(vm, "");
return sq_throwerror(vm, ToStrF("Invalid announcement style %d [%s]",
style, player->GetTag().c_str()));
}
@ -2563,7 +2552,7 @@ SQInteger Player_FindAuto(HSQUIRRELVM vm)
// Finally, attempt to push the return value
else
{
sq_pushobject(vm, Core::Get().GetPlayer(id).mObj.mObj);
sq_pushobject(vm, Core::Get().GetPlayer(static_cast< Int32 >(id)).mObj.mObj);
}
} break;
case OT_FLOAT: {
@ -2577,7 +2566,7 @@ SQInteger Player_FindAuto(HSQUIRRELVM vm)
return res; // Propagate the error
}
// Convert the float value to an integer
const Int32 id = std::round(static_cast< Float32 >(fid));
const auto id = static_cast< Int32 >(std::lround(static_cast< Float32 >(fid)));
// Check identifier range
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
{
@ -2644,7 +2633,7 @@ SQInteger Player_ExistsAuto(HSQUIRRELVM vm)
return res; // Propagate the error
}
// Check identifier range and the entity instance
else if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL) || INVALID_ENTITY(Core::Get().GetPlayer(id).mID))
else if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL) || INVALID_ENTITY(Core::Get().GetPlayer(static_cast< Int32 >(id)).mID))
{
sq_pushbool(vm, SQFalse);
}
@ -2664,7 +2653,7 @@ SQInteger Player_ExistsAuto(HSQUIRRELVM vm)
return res; // Propagate the error
}
// Convert the float value to an integer
const Int32 id = std::round(static_cast< Float32 >(fid));
const auto id = static_cast< Int32 >(std::lround(static_cast< Float32 >(fid)));
// Check identifier range and the entity instance
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL) || INVALID_ENTITY(Core::Get().GetPlayer(id).mID))
{

View File

@ -12,16 +12,16 @@ namespace SqMod {
*/
enum PlayerCircularLocks
{
PLAYERCL_EMIT_PLAYER_OPTION = (1 << 0),
PLAYERCL_EMIT_PLAYER_ADMIN = (1 << 1),
PLAYERCL_EMIT_PLAYER_WORLD = (1 << 2),
PLAYERCL_EMIT_PLAYER_TEAM = (1 << 3),
PLAYERCL_EMIT_PLAYER_SKIN = (1 << 4),
PLAYERCL_EMIT_PLAYER_MONEY = (1 << 5),
PLAYERCL_EMIT_PLAYER_SCORE = (1 << 6),
PLAYERCL_EMIT_PLAYER_WANTED_LEVEL = (1 << 7),
PLAYERCL_EMIT_PLAYER_IMMUNITY = (1 << 8),
PLAYERCL_EMIT_PLAYER_ALPHA = (1 << 9)
PLAYERCL_EMIT_PLAYER_OPTION = (1u << 0u),
PLAYERCL_EMIT_PLAYER_ADMIN = (1u << 1u),
PLAYERCL_EMIT_PLAYER_WORLD = (1u << 2u),
PLAYERCL_EMIT_PLAYER_TEAM = (1u << 3u),
PLAYERCL_EMIT_PLAYER_SKIN = (1u << 4u),
PLAYERCL_EMIT_PLAYER_MONEY = (1u << 5u),
PLAYERCL_EMIT_PLAYER_SCORE = (1u << 6u),
PLAYERCL_EMIT_PLAYER_WANTED_LEVEL = (1u << 7u),
PLAYERCL_EMIT_PLAYER_IMMUNITY = (1u << 8u),
PLAYERCL_EMIT_PLAYER_ALPHA = (1u << 9u)
};
/* ------------------------------------------------------------------------------------------------
@ -65,7 +65,7 @@ private:
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CPlayer(Int32 id);
explicit CPlayer(Int32 id);
public:
@ -137,11 +137,6 @@ public:
*/
CPlayer(CPlayer &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CPlayer();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
@ -467,7 +462,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the frames per second of the managed player entity.
*/
Float32 GetFPS() const;
SQFloat GetFPS() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the current health of the managed player entity.

View File

@ -38,12 +38,6 @@ CVehicle::CVehicle(Int32 id)
/* ... */
}
// ------------------------------------------------------------------------------------------------
CVehicle::~CVehicle()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
const String & CVehicle::ToString() const
{
@ -61,7 +55,7 @@ void CVehicle::SetTag(StackStrF & tag)
{
if (tag.mLen > 0)
{
m_Tag.assign(tag.mPtr, tag.mLen);
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
}
else
{
@ -156,7 +150,7 @@ void CVehicle::SetOption(Int32 option_id, bool toggle)
const bool value = _Func->GetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id));
// Attempt to modify the current value of the specified option
if (_Func->SetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
@ -176,7 +170,7 @@ void CVehicle::SetOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj
const bool value = _Func->GetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id));
// Attempt to modify the current value of the specified option
if (_Func->SetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id),
toggle) == vcmpErrorArgumentOutOfBounds)
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
{
STHROWF("Invalid option identifier: %d", option_id);
}
@ -328,7 +322,7 @@ void CVehicle::SetImmunity(Int32 flags)
// Grab the current value for this property
const Int32 current = _Func->GetVehicleImmunityFlags(m_ID);
// Avoid property unwind from a recursive call
_Func->SetVehicleImmunityFlags(m_ID, flags);
_Func->SetVehicleImmunityFlags(m_ID, static_cast< uint32_t >(flags));
// Avoid infinite recursive event loops
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_IMMUNITY))
{
@ -376,7 +370,7 @@ void CVehicle::SetPosition(const Vector3 & pos) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehiclePosition(m_ID, pos.x, pos.y, pos.z, false);
_Func->SetVehiclePosition(m_ID, pos.x, pos.y, pos.z, static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -385,7 +379,7 @@ void CVehicle::SetPositionEx(const Vector3 & pos, bool empty) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehiclePosition(m_ID, pos.x, pos.y, pos.z, empty);
_Func->SetVehiclePosition(m_ID, pos.x, pos.y, pos.z, static_cast< uint8_t >(empty));
}
// ------------------------------------------------------------------------------------------------
@ -394,7 +388,7 @@ void CVehicle::SetPositionEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehiclePosition(m_ID, x, y, z, false);
_Func->SetVehiclePosition(m_ID, x, y, z, static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -403,7 +397,7 @@ void CVehicle::SetPositionEx(Float32 x, Float32 y, Float32 z, bool empty) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehiclePosition(m_ID, x, y, z, empty);
_Func->SetVehiclePosition(m_ID, x, y, z, static_cast< uint8_t >(empty));
}
// ------------------------------------------------------------------------------------------------
@ -476,7 +470,7 @@ Vector3 CVehicle::GetSpeed() const
// Create a default vector instance
Vector3 vec;
// Query the server for the values
_Func->GetVehicleSpeed(m_ID, &vec.x, &vec.y, &vec.z, false);
_Func->GetVehicleSpeed(m_ID, &vec.x, &vec.y, &vec.z, static_cast< uint8_t >(false));
// Return the requested information
return vec;
}
@ -487,7 +481,8 @@ void CVehicle::SetSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z, false, false);
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -496,7 +491,7 @@ void CVehicle::SetSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, false, false);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -505,7 +500,8 @@ void CVehicle::AddSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z, true, false);
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(true), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -514,7 +510,7 @@ void CVehicle::AddSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, true, false);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(true), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -525,7 +521,7 @@ Vector3 CVehicle::GetRelativeSpeed() const
// Create a default vector instance
Vector3 vec;
// Query the server for the values
_Func->GetVehicleSpeed(m_ID, &vec.x, &vec.y, &vec.z, true);
_Func->GetVehicleSpeed(m_ID, &vec.x, &vec.y, &vec.z, static_cast< uint8_t >(true));
// Return the requested information
return vec;
}
@ -536,7 +532,8 @@ void CVehicle::SetRelativeSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z, false, true);
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -545,7 +542,7 @@ void CVehicle::SetRelativeSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, false, true);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -554,7 +551,8 @@ void CVehicle::AddRelativeSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z, true, true);
_Func->SetVehicleSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(true), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -563,7 +561,7 @@ void CVehicle::AddRelativeSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, true, true);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(true), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -574,7 +572,7 @@ Vector3 CVehicle::GetTurnSpeed() const
// Create a default vector instance
Vector3 vec;
// Query the server for the values
_Func->GetVehicleTurnSpeed(m_ID, &vec.x, &vec.y, &vec.z, false);
_Func->GetVehicleTurnSpeed(m_ID, &vec.x, &vec.y, &vec.z, static_cast< uint8_t >(false));
// Return the requested information
return vec;
}
@ -585,7 +583,8 @@ void CVehicle::SetTurnSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z, false, false);
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -594,7 +593,8 @@ void CVehicle::SetTurnSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, false, false);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(false),
static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -603,7 +603,8 @@ void CVehicle::AddTurnSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z, true, false);
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(true), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -612,7 +613,8 @@ void CVehicle::AddTurnSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, true, false);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(true),
static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -623,7 +625,7 @@ Vector3 CVehicle::GetRelativeTurnSpeed() const
// Create a default vector instance
Vector3 vec;
// Query the server for the values
_Func->GetVehicleTurnSpeed(m_ID, &vec.x, &vec.y, &vec.z, true);
_Func->GetVehicleTurnSpeed(m_ID, &vec.x, &vec.y, &vec.z, static_cast< uint8_t >(true));
// Return the requested information
return vec;
}
@ -634,7 +636,8 @@ void CVehicle::SetRelativeTurnSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z, false, true);
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -643,7 +646,8 @@ void CVehicle::SetRelativeTurnSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, false, true);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(false),
static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -652,7 +656,8 @@ void CVehicle::AddRelativeTurnSpeed(const Vector3 & vel) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z, true, true);
_Func->SetVehicleTurnSpeed(m_ID, vel.x, vel.y, vel.z,
static_cast< uint8_t >(true), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -661,7 +666,8 @@ void CVehicle::AddRelativeTurnSpeedEx(Float32 x, Float32 y, Float32 z) const
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, true, true);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(true),
static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -1045,12 +1051,12 @@ bool CVehicle::ExistsHandlingRule(Int32 rule) const
}
// ------------------------------------------------------------------------------------------------
Float32 CVehicle::GetHandlingRule(Int32 rule) const
SQFloat CVehicle::GetHandlingRule(Int32 rule) const
{
// Validate the managed identifier
Validate();
// Return the requested information
return _Func->GetInstHandlingRule(m_ID, rule);
return static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule));
}
// ------------------------------------------------------------------------------------------------
@ -1059,7 +1065,7 @@ void CVehicle::SetHandlingRule(Int32 rule, Float32 data)
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Float32 current = _Func->GetInstHandlingRule(m_ID, rule);
const auto current = static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule));
// Avoid property unwind from a recursive call
_Func->SetInstHandlingRule(m_ID, rule, data);
// Avoid infinite recursive event loops
@ -1078,7 +1084,7 @@ void CVehicle::ResetHandlingRule(Int32 rule)
// Validate the managed identifier
Validate();
// Grab the current value for this property
const Float32 current = _Func->GetInstHandlingRule(m_ID, rule);
const auto current = static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule));
// Avoid property unwind from a recursive call
_Func->ResetInstHandlingRule(m_ID, rule);
// Avoid infinite recursive event loops
@ -1087,7 +1093,7 @@ void CVehicle::ResetHandlingRule(Int32 rule)
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_HANDLINGRULE);
// Now forward the event call
Core::Get().EmitVehicleHandlingRule(m_ID, rule, current, _Func->GetInstHandlingRule(m_ID, rule));
Core::Get().EmitVehicleHandlingRule(m_ID, rule, current, static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule)));
}
}
@ -1115,7 +1121,7 @@ void CVehicle::SetLightsData(Int32 data) const
// Validate the managed identifier
Validate();
// Apply the requested data
_Func->SetVehicleLightsData(m_ID, data);
_Func->SetVehicleLightsData(m_ID, static_cast< uint32_t >(data));
}
// ------------------------------------------------------------------------------------------------
@ -1129,7 +1135,8 @@ bool CVehicle::Embark(CPlayer & player) const
// Validate the managed identifier
Validate();
// Perform the requested operation
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, 0, true, true)
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, 0,
static_cast< uint8_t >(true), static_cast< uint8_t >(true))
!= vcmpErrorRequestDenied);
}
@ -1144,8 +1151,8 @@ bool CVehicle::Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) co
// Validate the managed identifier
Validate();
// Perform the requested operation
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, slot, allocate, warp)
!= vcmpErrorRequestDenied);
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, slot,
static_cast< uint8_t >(allocate), static_cast< uint8_t >(warp)) != vcmpErrorRequestDenied);
}
#if SQMOD_SDK_LEAST(2, 1)
// ------------------------------------------------------------------------------------------------
@ -1190,7 +1197,7 @@ bool CVehicle::GetCollideAreas() const
// Validate the managed identifier
Validate();
// Return the requested information
return (Core::Get().GetVehicle(m_ID).mFlags & ENF_AREA_TRACK);
return static_cast< bool >(Core::Get().GetVehicle(m_ID).mFlags & ENF_AREA_TRACK);
}
void CVehicle::SetCollideAreas(bool toggle) const
@ -1391,7 +1398,7 @@ void CVehicle::SetPositionX(Float32 x) const
// Retrieve the current values for unchanged components
_Func->GetVehiclePosition(m_ID, &dummy, &y, &z);
// Perform the requested operation
_Func->SetVehiclePosition(m_ID, x, y, z, false);
_Func->SetVehiclePosition(m_ID, x, y, z, static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1404,7 +1411,7 @@ void CVehicle::SetPositionY(Float32 y) const
// Retrieve the current values for unchanged components
_Func->GetVehiclePosition(m_ID, &x, &dummy, &z);
// Perform the requested operation
_Func->SetVehiclePosition(m_ID, x, y, z, false);
_Func->SetVehiclePosition(m_ID, x, y, z, static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1417,7 +1424,7 @@ void CVehicle::SetPositionZ(Float32 z) const
// Retrieve the current values for unchanged components
_Func->GetVehiclePosition(m_ID, &x, &y, &dummy);
// Perform the requested operation
_Func->SetVehiclePosition(m_ID, z, y, z, false);
_Func->SetVehiclePosition(m_ID, z, y, z, static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1611,7 +1618,7 @@ Float32 CVehicle::GetSpeedX() const
// Clear previous information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &dummy, false);
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &dummy, static_cast< uint8_t >(false));
// Return the requested information
return x;
}
@ -1624,7 +1631,7 @@ Float32 CVehicle::GetSpeedY() const
// Clear previous information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &dummy, false);
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &dummy, static_cast< uint8_t >(false));
// Return the requested information
return y;
}
@ -1637,7 +1644,7 @@ Float32 CVehicle::GetSpeedZ() const
// Clear previous information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleSpeed(m_ID, &dummy, &dummy, &z, false);
_Func->GetVehicleSpeed(m_ID, &dummy, &dummy, &z, static_cast< uint8_t >(false));
// Return the requested information
return z;
}
@ -1650,9 +1657,9 @@ void CVehicle::SetSpeedX(Float32 x) const
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &z, false);
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &z, static_cast< uint8_t >(false));
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, false, false);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1663,9 +1670,9 @@ void CVehicle::SetSpeedY(Float32 y) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &z, false);
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &z, static_cast< uint8_t >(false));
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, false, false);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1676,9 +1683,9 @@ void CVehicle::SetSpeedZ(Float32 z) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleSpeed(m_ID, &x, &y, &dummy, false);
_Func->GetVehicleSpeed(m_ID, &x, &y, &dummy, static_cast< uint8_t >(false));
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, z, y, z, false, false);
_Func->SetVehicleSpeed(m_ID, z, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1689,7 +1696,7 @@ Float32 CVehicle::GetRelativeSpeedX() const
// Clear previous information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &dummy, true);
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &dummy, static_cast< uint8_t >(true));
// Return the requested information
return x;
}
@ -1702,7 +1709,7 @@ Float32 CVehicle::GetRelativeSpeedY() const
// Clear previous information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &dummy, true);
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &dummy, static_cast< uint8_t >(true));
// Return the requested information
return y;
}
@ -1715,7 +1722,7 @@ Float32 CVehicle::GetRelativeSpeedZ() const
// Clear previous information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleSpeed(m_ID, &dummy, &dummy, &z, true);
_Func->GetVehicleSpeed(m_ID, &dummy, &dummy, &z, static_cast< uint8_t >(true));
// Return the requested information
return z;
}
@ -1728,9 +1735,9 @@ void CVehicle::SetRelativeSpeedX(Float32 x) const
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &z, true);
_Func->GetVehicleSpeed(m_ID, &dummy, &y, &z, static_cast< uint8_t >(true));
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, false, true);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -1741,9 +1748,9 @@ void CVehicle::SetRelativeSpeedY(Float32 y) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &z, true);
_Func->GetVehicleSpeed(m_ID, &x, &dummy, &z, static_cast< uint8_t >(true));
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, x, y, z, false, true);
_Func->SetVehicleSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -1754,9 +1761,9 @@ void CVehicle::SetRelativeSpeedZ(Float32 z) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleSpeed(m_ID, &x, &y, &dummy, true);
_Func->GetVehicleSpeed(m_ID, &x, &y, &dummy, static_cast< uint8_t >(true));
// Perform the requested operation
_Func->SetVehicleSpeed(m_ID, z, y, z, false, true);
_Func->SetVehicleSpeed(m_ID, z, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -1767,7 +1774,7 @@ Float32 CVehicle::GetTurnSpeedX() const
// Clear previous information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &dummy, false);
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &dummy, static_cast< uint8_t >(false));
// Return the requested information
return x;
}
@ -1780,7 +1787,7 @@ Float32 CVehicle::GetTurnSpeedY() const
// Clear previous information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &dummy, false);
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &dummy, static_cast< uint8_t >(false));
// Return the requested information
return y;
}
@ -1793,7 +1800,7 @@ Float32 CVehicle::GetTurnSpeedZ() const
// Clear previous information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &dummy, &z, false);
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &dummy, &z, static_cast< uint8_t >(false));
// Return the requested information
return z;
}
@ -1806,9 +1813,9 @@ void CVehicle::SetTurnSpeedX(Float32 x) const
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &z, false);
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &z, static_cast< uint8_t >(false));
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, false, false);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1819,9 +1826,9 @@ void CVehicle::SetTurnSpeedY(Float32 y) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &z, false);
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &z, static_cast< uint8_t >(false));
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, false, false);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1832,9 +1839,9 @@ void CVehicle::SetTurnSpeedZ(Float32 z) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleTurnSpeed(m_ID, &x, &y, &dummy, false);
_Func->GetVehicleTurnSpeed(m_ID, &x, &y, &dummy, static_cast< uint8_t >(false));
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, z, y, z, false, false);
_Func->SetVehicleTurnSpeed(m_ID, z, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(false));
}
// ------------------------------------------------------------------------------------------------
@ -1845,7 +1852,7 @@ Float32 CVehicle::GetRelativeTurnSpeedX() const
// Clear previous information, if any
Float32 x = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &dummy, true);
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &dummy, static_cast< uint8_t >(true));
// Return the requested information
return x;
}
@ -1858,7 +1865,7 @@ Float32 CVehicle::GetRelativeTurnSpeedY() const
// Clear previous information, if any
Float32 y = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &dummy, true);
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &dummy, static_cast< uint8_t >(true));
// Return the requested information
return y;
}
@ -1871,7 +1878,7 @@ Float32 CVehicle::GetRelativeTurnSpeedZ() const
// Clear previous information, if any
Float32 z = 0.0f, dummy;
// Query the server for the requested component value
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &dummy, &z, true);
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &dummy, &z, static_cast< uint8_t >(true));
// Return the requested information
return z;
}
@ -1884,9 +1891,9 @@ void CVehicle::SetRelativeTurnSpeedX(Float32 x) const
// Reserve some temporary floats to retrieve the missing components
Float32 y, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &z, true);
_Func->GetVehicleTurnSpeed(m_ID, &dummy, &y, &z, static_cast< uint8_t >(true));
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, false, true);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -1897,9 +1904,9 @@ void CVehicle::SetRelativeTurnSpeedY(Float32 y) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, z, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &z, true);
_Func->GetVehicleTurnSpeed(m_ID, &x, &dummy, &z, static_cast< uint8_t >(true));
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, false, true);
_Func->SetVehicleTurnSpeed(m_ID, x, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -1910,9 +1917,9 @@ void CVehicle::SetRelativeTurnSpeedZ(Float32 z) const
// Reserve some temporary floats to retrieve the missing components
Float32 x, y, dummy;
// Retrieve the current values for unchanged components
_Func->GetVehicleTurnSpeed(m_ID, &x, &y, &dummy, true);
_Func->GetVehicleTurnSpeed(m_ID, &x, &y, &dummy, static_cast< uint8_t >(true));
// Perform the requested operation
_Func->SetVehicleTurnSpeed(m_ID, z, y, z, false, true);
_Func->SetVehicleTurnSpeed(m_ID, z, y, z, static_cast< uint8_t >(false), static_cast< uint8_t >(true));
}
// ------------------------------------------------------------------------------------------------
@ -1946,7 +1953,10 @@ static LightObj & Vehicle_Create(Int32 model, Int32 world, const Vector3 & pos,
}
// ================================================================================================
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void Register_CVehicle(HSQUIRRELVM vm)
#pragma clang diagnostic pop
{
RootTable(vm).Bind(Typename::Str,
Class< CVehicle, NoConstructor< CVehicle > >(vm, Typename::Str)

View File

@ -11,14 +11,14 @@ namespace SqMod {
*/
enum VehicleCircularLocks
{
VEHICLECL_EMIT_VEHICLE_OPTION = (1 << 0),
VEHICLECL_EMIT_VEHICLE_WORLD = (1 << 1),
VEHICLECL_EMIT_VEHICLE_IMMUNITY = (1 << 2),
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (1 << 3),
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (1 << 4),
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (1 << 5),
VEHICLECL_EMIT_VEHICLE_RADIO = (1 << 6),
VEHICLECL_EMIT_VEHICLE_HANDLINGRULE = (1 << 7)
VEHICLECL_EMIT_VEHICLE_OPTION = (1u << 0u),
VEHICLECL_EMIT_VEHICLE_WORLD = (1u << 1u),
VEHICLECL_EMIT_VEHICLE_IMMUNITY = (1u << 2u),
VEHICLECL_EMIT_VEHICLE_PARTSTATUS = (1u << 3u),
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (1u << 4u),
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (1u << 5u),
VEHICLECL_EMIT_VEHICLE_RADIO = (1u << 6u),
VEHICLECL_EMIT_VEHICLE_HANDLINGRULE = (1u << 7u)
};
/* ------------------------------------------------------------------------------------------------
@ -54,7 +54,7 @@ private:
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
CVehicle(Int32 id);
explicit CVehicle(Int32 id);
public:
@ -73,11 +73,6 @@ public:
*/
CVehicle(CVehicle &&) = delete;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~CVehicle();
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
@ -584,7 +579,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the handling data of the managed vehicle entity.
*/
Float32 GetHandlingRule(Int32 rule) const;
SQFloat GetHandlingRule(Int32 rule) const;
/* --------------------------------------------------------------------------------------------
* Modify the handling data of the managed vehicle entity.