mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-11-03 07:47:18 +01:00
Code cleanup. Most of it via linting.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include "Entity/Vehicle.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define SQMOD_VALID_NAME_STR(t) if (!t) { STHROWF("The specified name is invalid"); }
|
||||
#define SQMOD_VALID_NAME_STR(t) if (!(t)) { STHROWF("The specified name is invalid"); }
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
@@ -119,8 +119,8 @@ static const LightObj & Blip_FindBySprID(Int32 sprid)
|
||||
STHROWF("The specified sprite identifier is invalid: %d", sprid);
|
||||
}
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
|
||||
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
|
||||
auto itr = Core::Get().GetBlips().cbegin();
|
||||
auto end = Core::Get().GetBlips().cend();
|
||||
// Process each entity in the pool
|
||||
for (; itr != end; ++itr)
|
||||
{
|
||||
@@ -467,7 +467,7 @@ static inline Uint32 Player_EachWhereNameMatchesData(bool neg, bool cs, CSStr na
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Count all entities of this type where the name matches or not the specified one.
|
||||
*/
|
||||
static inline Uint32 Player_CountWhereNameEquals(bool neg, bool cs, CSStr name)
|
||||
static inline CountElemFunc <CPlayer> Player_CountWhereNameEquals(bool neg, bool cs, CSStr name)
|
||||
{
|
||||
SQMOD_VALID_NAME_STR(name)
|
||||
// Create a new element counter
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <functional>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define SQMOD_VALID_TAG_STR(t) if (!t) { STHROWF("The specified tag is invalid"); }
|
||||
#define SQMOD_VALID_TAG_STR(t) if (!(t)) { STHROWF("The specified tag is invalid"); }
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
@@ -20,7 +20,7 @@ namespace Algo {
|
||||
*/
|
||||
inline CSStr sqmod_stristr(CSStr haystack, CSStr needle)
|
||||
{
|
||||
for (const SQChar chr = std::tolower(*needle); *haystack != '\0'; ++haystack)
|
||||
for (const auto chr = static_cast< const SQChar >(std::tolower(*needle)); *haystack != '\0'; ++haystack)
|
||||
{
|
||||
if (static_cast< SQChar >(std::tolower(*haystack)) != chr)
|
||||
{
|
||||
@@ -241,7 +241,7 @@ void EachBegins(Iterator first, Iterator last,
|
||||
// Compare the string
|
||||
if (s.size() >= len)
|
||||
{
|
||||
if ((CompareStr(s.c_str(), str, len, cs) == 0) == neg)
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(len), cs) == 0) == neg)
|
||||
{
|
||||
collect(*first);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ void EachBeginsWhile(Iterator first, Iterator last,
|
||||
// Compare the string
|
||||
if (s.size() >= len)
|
||||
{
|
||||
if ((CompareStr(s.c_str(), str, len, cs) == 0) == neg)
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(len), cs) == 0) == neg)
|
||||
{
|
||||
if (!collect(*first))
|
||||
{
|
||||
@@ -311,7 +311,7 @@ void EachEnds(Iterator first, Iterator last,
|
||||
// Compare the tag
|
||||
if (s.size() >= len)
|
||||
{
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(s.size() - len), len, cs) == 0) == neg)
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(s.size() - len), static_cast< Uint32 >(len), cs) == 0) == neg)
|
||||
{
|
||||
collect(*first);
|
||||
}
|
||||
@@ -343,7 +343,7 @@ void EachEndsWhile(Iterator first, Iterator last,
|
||||
// Compare the tag
|
||||
if (s.size() >= len)
|
||||
{
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(s.size() - len), len, cs) == 0) == neg)
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(s.size() - len), static_cast< Uint32 >(len), cs) == 0) == neg)
|
||||
{
|
||||
if (!collect(*first))
|
||||
{
|
||||
@@ -477,7 +477,7 @@ void FirstBegins(Iterator first, Iterator last,
|
||||
// Compare the string
|
||||
if (s.size() >= len)
|
||||
{
|
||||
if ((CompareStr(s.c_str(), str, len, cs) == 0) == neg)
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(len), cs) == 0) == neg)
|
||||
{
|
||||
receive(*first);
|
||||
break;
|
||||
@@ -511,7 +511,7 @@ void FirstEnds(Iterator first, Iterator last,
|
||||
// Compare the string
|
||||
if (s.size() >= len)
|
||||
{
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(s.size() - len), len, cs) == 0) == neg)
|
||||
if ((CompareStr(s.c_str(), str, static_cast< Uint32 >(s.size() - len), static_cast< Uint32 >(len), cs) == 0) == neg)
|
||||
{
|
||||
receive(*first);
|
||||
break;
|
||||
@@ -895,7 +895,7 @@ template < typename T > struct AppendElemFunc
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
AppendElemFunc(SQInteger idx = -2, HSQUIRRELVM vm = DefaultVM::Get())
|
||||
explicit AppendElemFunc(SQInteger idx = -2, HSQUIRRELVM vm = DefaultVM::Get())
|
||||
: mIdx(idx), mVM(vm)
|
||||
{
|
||||
/* ... */
|
||||
@@ -979,7 +979,7 @@ public:
|
||||
// Push the element instance on the stack
|
||||
sq_pushobject(vm, inst.mObj.mObj);
|
||||
// Make the function call and store the result
|
||||
SQRESULT res = sq_call(vm, 2, true, ErrorHandling::IsEnabled());
|
||||
SQRESULT res = sq_call(vm, 2, static_cast< SQBool >(true), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Make sure the callback object and return value are popped from the stack
|
||||
const SqPopGuard pg(vm, 2);
|
||||
// Validate the result
|
||||
@@ -1009,7 +1009,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit cast to the count value.
|
||||
*/
|
||||
operator Uint32 () const
|
||||
operator Uint32 () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||
{
|
||||
return mCount;
|
||||
}
|
||||
@@ -1055,7 +1055,7 @@ public:
|
||||
// Push the iteration context on the stack
|
||||
sq_pushobject(vm, mData.mObj);
|
||||
// Make the function call and store the result
|
||||
SQRESULT res = sq_call(vm, 3, true, ErrorHandling::IsEnabled());
|
||||
SQRESULT res = sq_call(vm, 3, static_cast< SQBool >(true), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Make sure the callback object and return value are popped from the stack
|
||||
const SqPopGuard pg(vm, 2);
|
||||
// Validate the result
|
||||
@@ -1085,7 +1085,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit cast to the count value.
|
||||
*/
|
||||
operator Uint32 () const
|
||||
operator Uint32 () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||
{
|
||||
return mCount;
|
||||
}
|
||||
@@ -1121,7 +1121,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Implicit cast to the count value.
|
||||
*/
|
||||
operator Uint32 () const
|
||||
operator Uint32 () const // NOLINT(google-explicit-constructor,hicpp-explicit-conversions)
|
||||
{
|
||||
return mCount;
|
||||
}
|
||||
@@ -1629,14 +1629,14 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Count all entities of this type where the tag matches the specified filter.
|
||||
*/
|
||||
static inline Uint32 CountWhereTagMatches(bool neg, bool cs, CSStr tag)
|
||||
static inline CountElem CountWhereTagMatches(bool neg, bool cs, CSStr tag)
|
||||
{
|
||||
SQMOD_VALID_TAG_STR(tag)
|
||||
// Create a new element counter
|
||||
CountElem cnt;
|
||||
// Process each entity in the pool
|
||||
EachMatches(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(),
|
||||
std::reference_wrapper< CountElem >(cnt), tag, !neg, cs);
|
||||
std::reference_wrapper< CountElem >(cnt), tag, !neg, static_cast< bool >(cs));
|
||||
// Return the count
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ SQMODE_DECL_TYPENAME(AreaTypename, _SC("SqArea"))
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
AreaManager AreaManager::s_Inst;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "UnusedValue"
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Area::AddArray(const Sqrat::Array & a)
|
||||
{
|
||||
@@ -45,6 +47,7 @@ void Area::AddArray(const Sqrat::Array & a)
|
||||
return true;
|
||||
});
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool Area::Manage()
|
||||
@@ -115,9 +118,9 @@ bool Area::IsInside(float x, float y) const
|
||||
const float dy = (b.y - a.y);
|
||||
float k;
|
||||
|
||||
if (fabs(dx) < 0.000001f)
|
||||
if (fabsf(dx) < 0.000001f)
|
||||
{
|
||||
k = 0xffffffff;
|
||||
k = 0xffffffffu; // NOLINT(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions)
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -138,7 +141,7 @@ bool Area::IsInside(float x, float y) const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
AreaManager::AreaManager(size_t sz)
|
||||
AreaManager::AreaManager(size_t sz) noexcept
|
||||
: m_Queue(), m_ProcList(), m_Grid{}
|
||||
{
|
||||
// Negative half grid size (left)
|
||||
@@ -150,12 +153,11 @@ AreaManager::AreaManager(size_t sz)
|
||||
// Positive half grid size (top)
|
||||
int t = abs(l);
|
||||
// Initialize the grid cells
|
||||
for (int y = 0; y < GRIDN; ++y)
|
||||
for (auto & a : m_Grid)
|
||||
{
|
||||
for (int x = 0; x < GRIDN; ++x)
|
||||
for (auto & c : a)
|
||||
{
|
||||
// Grab a reference to the cell
|
||||
AreaCell & c = m_Grid[y][x];
|
||||
// Configure the range of the cell
|
||||
c.mL = static_cast< float >(l);
|
||||
c.mB = static_cast< float >(b);
|
||||
@@ -215,7 +217,7 @@ void AreaManager::Remove(AreaCell & c, Area & a)
|
||||
else
|
||||
{
|
||||
// Attempt to locate this area in the cell
|
||||
AreaCell::Areas::iterator itr = std::find_if(c.mAreas.begin(), c.mAreas.end(),
|
||||
auto itr = std::find_if(c.mAreas.begin(), c.mAreas.end(),
|
||||
[&a](AreaCell::Areas::reference p) -> bool {
|
||||
return (p.first == &a);
|
||||
});
|
||||
@@ -226,7 +228,7 @@ void AreaManager::Remove(AreaCell & c, Area & a)
|
||||
}
|
||||
}
|
||||
// Dissociate the area with this cell so it can be managed again (even while in the queue)
|
||||
Area::Cells::iterator itr = std::find(a.mCells.begin(), a.mCells.end(), &c);
|
||||
auto itr = std::find(a.mCells.begin(), a.mCells.end(), &c);
|
||||
// Was is associated?
|
||||
if (itr != a.mCells.end())
|
||||
{
|
||||
@@ -238,7 +240,7 @@ void AreaManager::Remove(AreaCell & c, Area & a)
|
||||
void AreaManager::ProcQueue()
|
||||
{
|
||||
// Look for actions that can be completed
|
||||
for (Queue::iterator itr = m_Queue.begin(); itr != m_Queue.end(); ++itr)
|
||||
for (auto itr = m_Queue.begin(); itr != m_Queue.end(); ++itr)
|
||||
{
|
||||
// Was this cell unlocked in the meantime?
|
||||
if (itr->mCell->mLocks <= 0)
|
||||
@@ -293,11 +295,10 @@ void AreaManager::InsertArea(Area & a, LightObj & obj)
|
||||
return; // Already managed or nothing to manage
|
||||
}
|
||||
// Go through each cell and check if the area touches it
|
||||
for (int y = 0; y < GRIDN; ++y)
|
||||
for (auto & y : m_Grid)
|
||||
{
|
||||
for (int x = 0; x < GRIDN; ++x)
|
||||
for (auto & c : y)
|
||||
{
|
||||
AreaCell & c = m_Grid[y][x];
|
||||
// Does the bounding box of this cell intersect with the one of the area?
|
||||
if (a.mL <= c.mR && c.mL <= a.mR && a.mB <= c.mT && c.mB <= a.mT)
|
||||
{
|
||||
@@ -330,7 +331,7 @@ Vector2i AreaManager::LocateCell(float x, float y)
|
||||
// Make sure the cell coordinates are within range
|
||||
if (xca > (GRIDH+1) || yca > (GRIDH+1))
|
||||
{
|
||||
return Vector2i(NOCELL, NOCELL); // Out of our scanning area
|
||||
return {NOCELL, NOCELL}; // Out of our scanning area
|
||||
}
|
||||
// Clamp the x coordinate if necessary
|
||||
if (xca >= (GRIDH))
|
||||
@@ -343,7 +344,7 @@ Vector2i AreaManager::LocateCell(float x, float y)
|
||||
yc = xc < 0 ? -(GRIDH-1) : (GRIDH-1);
|
||||
}
|
||||
// Return the identified cell row and column
|
||||
return Vector2i(GRIDH+xc, GRIDH-yc);
|
||||
return {GRIDH+xc, GRIDH-yc};
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -73,7 +73,7 @@ struct Area
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Named constructor.
|
||||
*/
|
||||
Area(StackStrF & name)
|
||||
explicit Area(StackStrF & name)
|
||||
: Area(16, name)
|
||||
{
|
||||
//...
|
||||
@@ -83,7 +83,7 @@ struct Area
|
||||
*/
|
||||
Area(SQInteger sz, StackStrF & name)
|
||||
: mL(DEF_L), mB(DEF_B), mR(DEF_R), mT(DEF_T), mPoints(), mID(0), mCells()
|
||||
, mName(name.mPtr, name.mLen <= 0 ? 0 : name.mLen)
|
||||
, mName(name.mPtr, static_cast< size_t >(name.mLen <= 0 ? 0 : name.mLen))
|
||||
|
||||
{
|
||||
// Should we reserve some space for points in advance?
|
||||
@@ -142,7 +142,7 @@ struct Area
|
||||
*/
|
||||
Area(float ax, float ay, float bx, float by, float cx, float cy, SQInteger sz, StackStrF & name)
|
||||
: mL(DEF_L), mB(DEF_B), mR(DEF_R), mT(DEF_T), mPoints(), mID(0), mCells()
|
||||
, mName(name.mPtr, name.mLen <= 0 ? 0 : name.mLen)
|
||||
, mName(name.mPtr, static_cast<size_t>(name.mLen <= 0 ? 0 : name.mLen))
|
||||
{
|
||||
// Should we reserve some space for points in advance?
|
||||
if (sz > 0)
|
||||
@@ -169,14 +169,6 @@ struct Area
|
||||
*/
|
||||
Area(Area && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~Area()
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
@@ -278,7 +270,7 @@ struct Area
|
||||
*/
|
||||
Vector2 GetCenter() const
|
||||
{
|
||||
return Vector2((mL * 0.5f) + (mR * 0.5f), (mB * 0.5f) + (mT * 0.5f));
|
||||
return {(mL * 0.5f) + (mR * 0.5f), (mB * 0.5f) + (mT * 0.5f)};
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@@ -286,7 +278,7 @@ struct Area
|
||||
*/
|
||||
Vector4 GetBoundingBox() const
|
||||
{
|
||||
return Vector4(mL, mB, mR, mT);
|
||||
return {mL, mB, mR, mT};
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@@ -472,43 +464,13 @@ protected:
|
||||
*/
|
||||
class AreaManager
|
||||
{
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static AreaManager s_Inst; // Manager instance.
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
AreaManager(size_t sz = 16);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
AreaManager(const AreaManager & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
AreaManager(AreaManager && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~AreaManager()
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
AreaManager & operator = (const AreaManager & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
AreaManager & operator = (AreaManager && o) = delete;
|
||||
explicit AreaManager(size_t sz = 16) noexcept;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -521,7 +483,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
CellGuard(AreaCell & cell)
|
||||
explicit CellGuard(AreaCell & cell)
|
||||
: mCell(cell)
|
||||
{
|
||||
++(cell.mLocks); // Place a lock on the cell to prevent iterator invalidation
|
||||
@@ -580,7 +542,7 @@ protected:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
QueueElement(QueueElement && o)
|
||||
QueueElement(QueueElement && o) noexcept
|
||||
: mCell(o.mCell), mArea(o.mArea), mObj(std::move(o.mObj))
|
||||
{
|
||||
// Take ownership
|
||||
@@ -588,14 +550,6 @@ protected:
|
||||
o.mArea = nullptr;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~QueueElement()
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
@@ -604,7 +558,7 @@ protected:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
QueueElement & operator = (QueueElement && o)
|
||||
QueueElement & operator = (QueueElement && o) noexcept
|
||||
{
|
||||
// Avoid self assignment
|
||||
if (this != &o)
|
||||
@@ -645,6 +599,26 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
AreaManager(const AreaManager & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
AreaManager(AreaManager && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
AreaManager & operator = (const AreaManager & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
AreaManager & operator = (AreaManager && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the core instance.
|
||||
*/
|
||||
@@ -676,7 +650,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Clear all cell lists and release any script references.
|
||||
*/
|
||||
Vector2i LocateCell(float x, float y);
|
||||
static Vector2i LocateCell(float x, float y);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Test a point to see whether it intersects with any areas
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Core.hpp"
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Base/Color3.hpp"
|
||||
#include "Base/Color4.hpp"
|
||||
#include "Entity/Player.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -26,7 +24,7 @@ static inline bool SqCanBeInteger(HSQUIRRELVM vm, Int32 idx)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int32 & msgidx)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = static_cast< Int32 >(sq_gettop(vm));
|
||||
// Is the color argument a Color3/Color4 instance?
|
||||
if (sq_gettype(vm, idx) == OT_INSTANCE)
|
||||
{
|
||||
@@ -35,7 +33,7 @@ SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int
|
||||
// Attempt to extract a Color3 value
|
||||
try
|
||||
{
|
||||
color = (Var< Color3 >(vm, idx).value.GetRGBA() | 0xFF);
|
||||
color = (Var< Color3 >(vm, idx).value.GetRGBA() | 0xFFu);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -78,7 +76,7 @@ SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int
|
||||
color = SQMOD_PACK_RGBA(ConvTo< Uint8 >::From(PopStackInteger(vm, idx)),
|
||||
ConvTo< Uint8 >::From(PopStackInteger(vm, idx+1)),
|
||||
ConvTo< Uint8 >::From(PopStackInteger(vm, idx+2)),
|
||||
0xFF);
|
||||
0xFFu);
|
||||
// The message starts right after the color
|
||||
msgidx += 3;
|
||||
}
|
||||
@@ -119,43 +117,44 @@ SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
color = 0x000000FF;
|
||||
color = 0x000000FFu;
|
||||
} break;
|
||||
case 1:
|
||||
{
|
||||
color <<= 28;
|
||||
color |= 0x00000FF;
|
||||
color <<= 28u;
|
||||
color |= 0x00000FFu;
|
||||
} break;
|
||||
case 2:
|
||||
{
|
||||
color <<= 24;
|
||||
color |= 0x0000FF;
|
||||
color <<= 24u;
|
||||
color |= 0x0000FFu;
|
||||
} break;
|
||||
case 3:
|
||||
{
|
||||
color <<= 20;
|
||||
color |= 0x000FF;
|
||||
color <<= 20u;
|
||||
color |= 0x000FFu;
|
||||
} break;
|
||||
case 4:
|
||||
{
|
||||
color <<= 16;
|
||||
color |= 0x00FF;
|
||||
color <<= 16u;
|
||||
color |= 0x00FFu;
|
||||
} break;
|
||||
case 5:
|
||||
{
|
||||
color <<= 12;
|
||||
color |= 0x0FF;
|
||||
color <<= 12u;
|
||||
color |= 0x0FFu;
|
||||
} break;
|
||||
case 6:
|
||||
{
|
||||
color <<= 8;
|
||||
color |= 0xFF;
|
||||
color <<= 8u;
|
||||
color |= 0xFFu;
|
||||
} break;
|
||||
case 7:
|
||||
{
|
||||
color <<= 4;
|
||||
color |= 0x0;
|
||||
color <<= 4u;
|
||||
color |= 0x0u;
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// Are the first characters 0x so we can treat this as hex?
|
||||
@@ -168,43 +167,44 @@ SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
color = 0x000000FF;
|
||||
color = 0x000000FFu;
|
||||
} break;
|
||||
case 1:
|
||||
{
|
||||
color <<= 28;
|
||||
color |= 0x00000FF;
|
||||
color <<= 28u;
|
||||
color |= 0x00000FFu;
|
||||
} break;
|
||||
case 2:
|
||||
{
|
||||
color <<= 24;
|
||||
color |= 0x0000FF;
|
||||
color <<= 24u;
|
||||
color |= 0x0000FFu;
|
||||
} break;
|
||||
case 3:
|
||||
{
|
||||
color <<= 20;
|
||||
color |= 0x000FF;
|
||||
color <<= 20u;
|
||||
color |= 0x000FFu;
|
||||
} break;
|
||||
case 4:
|
||||
{
|
||||
color <<= 16;
|
||||
color |= 0x00FF;
|
||||
color <<= 16u;
|
||||
color |= 0x00FFu;
|
||||
} break;
|
||||
case 5:
|
||||
{
|
||||
color <<= 12;
|
||||
color |= 0x0FF;
|
||||
color <<= 12u;
|
||||
color |= 0x0FFu;
|
||||
} break;
|
||||
case 6:
|
||||
{
|
||||
color <<= 8;
|
||||
color |= 0xFF;
|
||||
color <<= 8u;
|
||||
color |= 0xFFu;
|
||||
} break;
|
||||
case 7:
|
||||
{
|
||||
color <<= 4;
|
||||
color |= 0x0;
|
||||
color <<= 4u;
|
||||
color |= 0x0u;
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -212,7 +212,7 @@ SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int
|
||||
// Attempt to treat the value as a color name
|
||||
try
|
||||
{
|
||||
color = (::SqMod::GetColorStr(str).GetRGBA() | 0xFF);
|
||||
color = (::SqMod::GetColorStr(str).GetRGBA() | 0xFFu);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -234,7 +234,7 @@ SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int
|
||||
static SQInteger SqBroadcastMsg(HSQUIRRELVM vm)
|
||||
{
|
||||
// The function needs at least 2 arguments
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = static_cast< Int32 >(sq_gettop(vm));
|
||||
// Was the message color specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
@@ -267,8 +267,8 @@ static SQInteger SqBroadcastMsg(HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
||||
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
||||
auto itr = Core::Get().GetPlayers().cbegin();
|
||||
auto end = Core::Get().GetPlayers().cend();
|
||||
// The number of players that the message was sent to
|
||||
Uint32 count = 0;
|
||||
// Currently processed player
|
||||
@@ -307,7 +307,7 @@ static SQInteger SqBroadcastMsg(HSQUIRRELVM vm)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqBroadcastMsgP(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = static_cast< Int32 >(sq_gettop(vm));
|
||||
// Was the index of the message prefix specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
@@ -346,10 +346,10 @@ static SQInteger SqBroadcastMsgP(HSQUIRRELVM vm)
|
||||
return val.mRes; // Propagate the error!
|
||||
}
|
||||
|
||||
vcmpError result = vcmpErrorNone;
|
||||
vcmpError result;
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
||||
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
||||
auto itr = Core::Get().GetPlayers().cbegin();
|
||||
auto end = Core::Get().GetPlayers().cend();
|
||||
// The number of players that the message was sent to
|
||||
Uint32 count = 0;
|
||||
// Currently processed player
|
||||
@@ -395,7 +395,7 @@ static SQInteger SqBroadcastMsgP(HSQUIRRELVM vm)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqBroadcastMsgEx(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = static_cast< Int32 >(sq_gettop(vm));
|
||||
// Was the index of the message prefix specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
@@ -451,10 +451,10 @@ static SQInteger SqBroadcastMsgEx(HSQUIRRELVM vm)
|
||||
return val.mRes; // Propagate the error!
|
||||
}
|
||||
|
||||
vcmpError result = vcmpErrorNone;
|
||||
vcmpError result;
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
||||
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
||||
auto itr = Core::Get().GetPlayers().cbegin();
|
||||
auto end = Core::Get().GetPlayers().cend();
|
||||
// The number of players that the message was sent to
|
||||
Uint32 count = 0;
|
||||
// Currently processed player
|
||||
@@ -500,7 +500,7 @@ static SQInteger SqBroadcastMsgEx(HSQUIRRELVM vm)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqBroadcastMessage(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = static_cast< Int32 >(sq_gettop(vm));
|
||||
// Was the message value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
@@ -516,8 +516,8 @@ static SQInteger SqBroadcastMessage(HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
||||
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
||||
auto itr = Core::Get().GetPlayers().cbegin();
|
||||
auto end = Core::Get().GetPlayers().cend();
|
||||
// The number of players that the message was sent to
|
||||
Uint32 count = 0;
|
||||
// Currently processed player
|
||||
@@ -556,7 +556,7 @@ static SQInteger SqBroadcastMessage(HSQUIRRELVM vm)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqBroadcastAnnounce(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = static_cast< Int32 >(sq_gettop(vm));
|
||||
// Was the announcement value specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
@@ -572,8 +572,8 @@ static SQInteger SqBroadcastAnnounce(HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
||||
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
||||
auto itr = Core::Get().GetPlayers().cbegin();
|
||||
auto end = Core::Get().GetPlayers().cend();
|
||||
// The number of players that the message was sent to
|
||||
Uint32 count = 0;
|
||||
// Currently processed player
|
||||
@@ -617,7 +617,7 @@ static SQInteger SqBroadcastAnnounce(HSQUIRRELVM vm)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqBroadcastAnnounceEx(HSQUIRRELVM vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
const auto top = static_cast< Int32 >(sq_gettop(vm));
|
||||
// Was the announcement style specified?
|
||||
if (top <= 1)
|
||||
{
|
||||
@@ -649,8 +649,8 @@ static SQInteger SqBroadcastAnnounceEx(HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
// Obtain the ends of the entity pool
|
||||
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
||||
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
||||
auto itr = Core::Get().GetPlayers().cbegin();
|
||||
auto end = Core::Get().GetPlayers().cend();
|
||||
// The number of players that the message was sent to
|
||||
Uint32 count = 0;
|
||||
// Currently processed player
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <utility>
|
||||
|
||||
|
||||
#include "Misc/Command.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -16,8 +19,8 @@ SQMODE_DECL_TYPENAME(ManagerTypename, _SC("SqCmdManager"))
|
||||
SQMODE_DECL_TYPENAME(ListenerTypename, _SC("SqCmdListener"))
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Guard::Guard(const CtrRef & ctr, Object & invoker)
|
||||
: mController(ctr)
|
||||
Guard::Guard(CtrRef ctr, Object & invoker)
|
||||
: mController(std::move(ctr))
|
||||
, mPrevious(mController->m_Context)
|
||||
, mCurrent(new Context(invoker))
|
||||
{
|
||||
@@ -31,8 +34,8 @@ Guard::~Guard()
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Listener * ptr, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(ptr), mObj(ptr), mCtr(ctr)
|
||||
Command::Command(std::size_t hash, String name, Listener * ptr, CtrPtr ctr)
|
||||
: mHash(hash), mName(std::move(name)), mPtr(ptr), mObj(ptr), mCtr(std::move(ctr))
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
@@ -40,8 +43,8 @@ Command::Command(std::size_t hash, const String & name, Listener * ptr, const Ct
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, const Object & obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(obj.Cast< Listener * >()), mObj(obj), mCtr(ctr)
|
||||
Command::Command(std::size_t hash, String name, const Object & obj, CtrPtr ctr)
|
||||
: mHash(hash), mName(std::move(name)), mPtr(obj.Cast< Listener * >()), mObj(obj), mCtr(std::move(ctr))
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
@@ -50,8 +53,8 @@ Command::Command(std::size_t hash, const String & name, const Object & obj, cons
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Object && obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(obj.Cast< Listener * >()), mObj(obj), mCtr(ctr)
|
||||
Command::Command(std::size_t hash, String name, Object && obj, CtrPtr ctr)
|
||||
: mHash(hash), mName(std::move(name)), mPtr(obj.Cast< Listener * >()), mObj(obj), mCtr(std::move(ctr))
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
@@ -60,8 +63,8 @@ Command::Command(std::size_t hash, const String & name, Object && obj, const Ctr
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Listener * ptr, const Object & obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(ptr), mObj(obj), mCtr(ctr)
|
||||
Command::Command(std::size_t hash, String name, Listener * ptr, const Object & obj, CtrPtr ctr) // NOLINT(modernize-pass-by-value)
|
||||
: mHash(hash), mName(std::move(name)), mPtr(ptr), mObj(obj), mCtr(std::move(ctr))
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
@@ -70,8 +73,8 @@ Command::Command(std::size_t hash, const String & name, Listener * ptr, const Ob
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Listener * ptr, Object && obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(ptr), mObj(obj), mCtr(ctr)
|
||||
Command::Command(std::size_t hash, String name, Listener * ptr, Object && obj, CtrPtr ctr)
|
||||
: mHash(hash), mName(std::move(name)), mPtr(ptr), mObj(obj), mCtr(std::move(ctr))
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
@@ -382,7 +385,7 @@ Int32 Controller::Exec(Context & ctx)
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Let's store the exception message
|
||||
ctx.mBuffer.Write(0, e.what(), e.Message().size());
|
||||
ctx.mBuffer.Write(0, e.what(), static_cast< Buffer::SzType >(e.Message().size()));
|
||||
// Specify that the command execution failed
|
||||
failed = true;
|
||||
}
|
||||
@@ -404,7 +407,7 @@ Int32 Controller::Exec(Context & ctx)
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
// Let's store the exception message
|
||||
ctx.mBuffer.Write(0, e.what(), e.Message().size());
|
||||
ctx.mBuffer.Write(0, e.what(), static_cast< Buffer::SzType >(e.Message().size()));
|
||||
// Specify that the command execution failed
|
||||
failed = true;
|
||||
}
|
||||
@@ -480,7 +483,7 @@ bool Controller::Parse(Context & ctx)
|
||||
// Obtain the flags of the currently processed argument
|
||||
Uint8 arg_flags = ctx.mInstance->m_ArgSpec[ctx.mArgc];
|
||||
// Adjust the internal buffer if necessary (mostly never)
|
||||
ctx.mBuffer.Adjust(ctx.mArgument.size());
|
||||
ctx.mBuffer.Adjust(static_cast< Buffer::SzType >(ctx.mArgument.size()));
|
||||
// The iterator to the currently processed character
|
||||
String::const_iterator itr = ctx.mArgument.cbegin();
|
||||
// Previous and currently processed character
|
||||
@@ -633,7 +636,7 @@ bool Controller::Parse(Context & ctx)
|
||||
// Obtain both ends of the argument string
|
||||
CCStr str = &(*itr), end = &(*pos);
|
||||
// Compute the argument string size
|
||||
const Uint32 sz = std::distance(itr, pos);
|
||||
const auto sz = static_cast< const Uint32 >(std::distance(itr, pos));
|
||||
// Update the main iterator position
|
||||
itr = pos;
|
||||
// Update the currently processed character
|
||||
@@ -696,7 +699,7 @@ bool Controller::Parse(Context & ctx)
|
||||
// Fill the temporary buffer with data from the internal buffer
|
||||
for (; sptr < end; ++sptr, ++bptr)
|
||||
{
|
||||
*bptr = std::tolower(*sptr);
|
||||
*bptr = static_cast< char >(std::tolower(*sptr));
|
||||
}
|
||||
// Terminate the copied string portion
|
||||
*bptr = '\0';
|
||||
@@ -706,7 +709,7 @@ bool Controller::Parse(Context & ctx)
|
||||
if (std::strcmp(lc, "true") == 0 || std::strcmp(lc, "on") == 0)
|
||||
{
|
||||
// Transform it into a script object
|
||||
sq_pushbool(DefaultVM::Get(), true);
|
||||
sq_pushbool(DefaultVM::Get(), static_cast< SQBool >(true));
|
||||
// We've identified the correct value type
|
||||
identified = true;
|
||||
}
|
||||
@@ -714,7 +717,7 @@ bool Controller::Parse(Context & ctx)
|
||||
else if (std::strcmp(lc, "false") == 0 || std::strcmp(lc, "off") == 0)
|
||||
{
|
||||
// Transform it into a script object
|
||||
sq_pushbool(DefaultVM::Get(), false);
|
||||
sq_pushbool(DefaultVM::Get(), static_cast< SQBool >(false));
|
||||
// We've identified the correct value type
|
||||
identified = true;
|
||||
}
|
||||
@@ -1012,7 +1015,7 @@ void Listener::ProcSpec(CSStr str)
|
||||
// Reset all argument specifiers if failed
|
||||
std::memset(m_ArgSpec, CMDARG_ANY, sizeof(m_ArgSpec));
|
||||
// Propagate the exception back to the caller
|
||||
throw e;
|
||||
throw e; // NOLINT(hicpp-exception-baseclass,cert-err60-cpp)
|
||||
}
|
||||
// Attempt to generate an informational message
|
||||
GenerateInfo(false);
|
||||
@@ -1051,22 +1054,14 @@ void Register(HSQUIRRELVM vm)
|
||||
.Func(_SC("GetTable"), &Manager::GetCommandsTable)
|
||||
.Func(_SC("Foreach"), &Manager::ForeachCommand)
|
||||
// Member Overloads
|
||||
.Overload< Object (Manager::*)(StackStrF &) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload< Object (Manager::*)(StackStrF &, StackStrF &) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload< Object (Manager::*)(StackStrF &, StackStrF &, Array &) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload< Object (Manager::*)(StackStrF &, StackStrF &, Uint8, Uint8) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload< Object (Manager::*)(StackStrF &, StackStrF &, Array &, Uint8, Uint8) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload< Object (Manager::*)(StackStrF &, StackStrF &, Array &, Uint8, Uint8, SQInteger) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload< Object (Manager::*)(StackStrF &, StackStrF &, Array &, Uint8, Uint8, SQInteger, bool) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload< Object (Manager::*)(StackStrF &, StackStrF &, Array &, Uint8, Uint8, SQInteger, bool, bool) >
|
||||
(_SC("Create"), &Manager::Create)
|
||||
.Overload(_SC("Create"), &Manager::Create1)
|
||||
.Overload(_SC("Create"), &Manager::Create2)
|
||||
.Overload(_SC("Create"), &Manager::Create3)
|
||||
.Overload(_SC("Create"), &Manager::Create4)
|
||||
.Overload(_SC("Create"), &Manager::Create5)
|
||||
.Overload(_SC("Create"), &Manager::Create6)
|
||||
.Overload(_SC("Create"), &Manager::Create7)
|
||||
.Overload(_SC("Create"), &Manager::Create)
|
||||
);
|
||||
|
||||
cmdns.Bind(_SC("Listener"),
|
||||
|
||||
@@ -53,14 +53,14 @@ typedef std::vector< Controller * > Controllers; // List of active controllers.
|
||||
*/
|
||||
enum CmdArgType
|
||||
{
|
||||
CMDARG_ANY = 0,
|
||||
CMDARG_INTEGER = (1 << 1),
|
||||
CMDARG_FLOAT = (1 << 2),
|
||||
CMDARG_BOOLEAN = (1 << 3),
|
||||
CMDARG_STRING = (1 << 4),
|
||||
CMDARG_LOWER = (1 << 5),
|
||||
CMDARG_UPPER = (1 << 6),
|
||||
CMDARG_GREEDY = (1 << 7)
|
||||
CMDARG_ANY = 0u,
|
||||
CMDARG_INTEGER = (1u << 1u),
|
||||
CMDARG_FLOAT = (1u << 2u),
|
||||
CMDARG_BOOLEAN = (1u << 3u),
|
||||
CMDARG_STRING = (1u << 4u),
|
||||
CMDARG_LOWER = (1u << 5u),
|
||||
CMDARG_UPPER = (1u << 6u),
|
||||
CMDARG_GREEDY = (1u << 7u)
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -69,7 +69,7 @@ enum CmdArgType
|
||||
enum CmdError
|
||||
{
|
||||
// The command failed for unknown reasons
|
||||
CMDERR_UNKNOWN = 0,
|
||||
CMDERR_UNKNOWN = 0u,
|
||||
// The command failed to execute because there was nothing to execute
|
||||
CMDERR_EMPTY_COMMAND,
|
||||
// The command failed to execute because the command name was invalid after processing
|
||||
@@ -115,7 +115,9 @@ inline CSStr ValidateName(CSStr name)
|
||||
// Create iterator to name start
|
||||
CSStr str = name;
|
||||
// Inspect name characters
|
||||
while (*str != '\0')
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCDFAInspection"
|
||||
while ('\0' != *str)
|
||||
{
|
||||
// Does it contain spaces?
|
||||
if (std::isspace(*str) != 0)
|
||||
@@ -125,6 +127,7 @@ inline CSStr ValidateName(CSStr name)
|
||||
// Move to the next character
|
||||
++str;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
// Return the name
|
||||
return name;
|
||||
}
|
||||
@@ -170,7 +173,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Context(Object & invoker)
|
||||
explicit Context(Object & invoker)
|
||||
: mBuffer(512)
|
||||
, mInvoker(invoker)
|
||||
, mCommand()
|
||||
@@ -221,7 +224,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Guard(const CtrRef & ctr, Object & invoker);
|
||||
Guard(CtrRef ctr, Object & invoker);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
@@ -264,27 +267,27 @@ struct Command
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a command and the also create a script object from the specified listener.
|
||||
*/
|
||||
Command(std::size_t hash, const String & name, Listener * ptr, const CtrPtr & ctr);
|
||||
Command(std::size_t hash, String name, Listener * ptr, CtrPtr ctr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a command and extract the listener from the specified script object.
|
||||
*/
|
||||
Command(std::size_t hash, const String & name, const Object & obj, const CtrPtr & ctr);
|
||||
Command(std::size_t hash, String name, const Object & obj, CtrPtr ctr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a command and extract the listener from the specified script object.
|
||||
*/
|
||||
Command(std::size_t hash, const String & name, Object && obj, const CtrPtr & ctr);
|
||||
Command(std::size_t hash, String name, Object && obj, CtrPtr ctr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a command with the given parameters.
|
||||
*/
|
||||
Command(std::size_t hash, const String & name, Listener * ptr, const Object & obj, const CtrPtr & ctr);
|
||||
Command(std::size_t hash, String name, Listener * ptr, const Object & obj, CtrPtr ctr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Construct a command with the given parameters.
|
||||
*/
|
||||
Command(std::size_t hash, const String & name, Listener * ptr, Object && obj, const CtrPtr & ctr);
|
||||
Command(std::size_t hash, String name, Listener * ptr, Object && obj, CtrPtr ctr);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor.
|
||||
@@ -294,12 +297,12 @@ struct Command
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Command(Command && o)
|
||||
Command(Command && o) noexcept
|
||||
: mHash(o.mHash)
|
||||
, mName(std::move(o.mName))
|
||||
, mName(std::forward< String >(o.mName))
|
||||
, mPtr(o.mPtr)
|
||||
, mObj(o.mObj)
|
||||
, mCtr(o.mCtr)
|
||||
, mObj(std::forward< Object >(o.mObj))
|
||||
, mCtr(std::forward< CtrPtr >(o.mCtr))
|
||||
{
|
||||
o.mPtr = nullptr;
|
||||
}
|
||||
@@ -317,14 +320,14 @@ struct Command
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Command & operator = (Command && o)
|
||||
Command & operator = (Command && o) noexcept
|
||||
{
|
||||
if (this != &o)
|
||||
{
|
||||
mHash = o.mHash;
|
||||
mName = std::move(o.mName);
|
||||
mName = std::forward< String >(o.mName);
|
||||
mPtr = o.mPtr;
|
||||
mObj = o.mObj;
|
||||
mObj = std::forward< Object >(o.mObj);
|
||||
mCtr = o.mCtr;
|
||||
o.mPtr = nullptr;
|
||||
}
|
||||
@@ -363,7 +366,7 @@ protected:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Controller(Manager * mgr)
|
||||
explicit Controller(Manager * mgr)
|
||||
: m_Commands()
|
||||
, m_Context()
|
||||
, m_OnFail()
|
||||
@@ -373,26 +376,6 @@ protected:
|
||||
s_Controllers.push_back(this);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
Controller(const Controller & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
Controller(Controller && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Controller & operator = (const Controller & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Controller & operator = (Controller && o) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@@ -461,7 +444,7 @@ protected:
|
||||
// Obtain the unique identifier of the specified name
|
||||
const std::size_t hash = std::hash< String >()(name);
|
||||
// Iterator to the found command, if any
|
||||
Commands::const_iterator itr = m_Commands.cbegin();
|
||||
auto itr = m_Commands.cbegin();
|
||||
// Attempt to find the specified command
|
||||
for (; itr != m_Commands.cend(); ++itr)
|
||||
{
|
||||
@@ -484,7 +467,7 @@ protected:
|
||||
void Detach(Listener * ptr)
|
||||
{
|
||||
// Iterator to the found command, if any
|
||||
Commands::const_iterator itr = m_Commands.cbegin();
|
||||
auto itr = m_Commands.cbegin();
|
||||
// Attempt to find the specified command
|
||||
for (; itr != m_Commands.cend(); ++itr)
|
||||
{
|
||||
@@ -503,6 +486,26 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
Controller(const Controller & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
Controller(Controller && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Controller & operator = (const Controller & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Controller & operator = (Controller && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Terminate the all controllers by releasing their command listeners and callbacks.
|
||||
*/
|
||||
@@ -891,7 +894,7 @@ public:
|
||||
{
|
||||
if ((SQ_FAILED(command.Proc())))
|
||||
{
|
||||
return command.mRes;
|
||||
return static_cast< Int32 >(command.mRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -938,7 +941,7 @@ public:
|
||||
STHROWF("Invalid or empty command name");
|
||||
}
|
||||
// Attempt to return the requested command
|
||||
return GetValid()->FindByName(String(name.mPtr, name.mLen));
|
||||
return GetValid()->FindByName(String(name.mPtr, static_cast< size_t >(name.mLen)));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@@ -1056,7 +1059,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create command instances and obtain the associated object.
|
||||
*/
|
||||
Object Create(StackStrF & name)
|
||||
Object Create1(StackStrF & name)
|
||||
{
|
||||
return Create(name, DummyStackStrF(), NullArray(), 0, SQMOD_MAX_CMD_ARGS-1, -1, false, false);
|
||||
}
|
||||
@@ -1064,7 +1067,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create command instances and obtain the associated object.
|
||||
*/
|
||||
Object Create(StackStrF & name, StackStrF & spec)
|
||||
Object Create2(StackStrF & name, StackStrF & spec)
|
||||
{
|
||||
return Create(name, spec, NullArray(), 0, SQMOD_MAX_CMD_ARGS-1, -1, false, false);
|
||||
}
|
||||
@@ -1072,7 +1075,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create command instances and obtain the associated object.
|
||||
*/
|
||||
Object Create(StackStrF & name, StackStrF & spec, Array & tags)
|
||||
Object Create3(StackStrF & name, StackStrF & spec, Array & tags)
|
||||
{
|
||||
return Create(name, spec, tags, 0, SQMOD_MAX_CMD_ARGS-1, -1, false, false);
|
||||
}
|
||||
@@ -1080,7 +1083,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create command instances and obtain the associated object.
|
||||
*/
|
||||
Object Create(StackStrF & name, StackStrF & spec, Uint8 min, Uint8 max)
|
||||
Object Create4(StackStrF & name, StackStrF & spec, Uint8 min, Uint8 max)
|
||||
{
|
||||
return Create(name, spec, NullArray(), min, max, -1, false, false);
|
||||
}
|
||||
@@ -1088,7 +1091,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create command instances and obtain the associated object.
|
||||
*/
|
||||
Object Create(StackStrF & name, StackStrF & spec, Array & tags, Uint8 min, Uint8 max)
|
||||
Object Create5(StackStrF & name, StackStrF & spec, Array & tags, Uint8 min, Uint8 max)
|
||||
{
|
||||
return Create(name, spec, tags, min, max, -1, false, false);
|
||||
}
|
||||
@@ -1096,7 +1099,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create command instances and obtain the associated object.
|
||||
*/
|
||||
Object Create(StackStrF & name, StackStrF & spec, Array & tags, Uint8 min, Uint8 max, SQInteger auth)
|
||||
Object Create6(StackStrF & name, StackStrF & spec, Array & tags, Uint8 min, Uint8 max, SQInteger auth)
|
||||
{
|
||||
return Create(name, spec, tags, min, max, auth, auth >= 0, false);
|
||||
}
|
||||
@@ -1104,7 +1107,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Create command instances and obtain the associated object.
|
||||
*/
|
||||
Object Create(StackStrF & name, StackStrF & spec, Array & tags, Uint8 min, Uint8 max, SQInteger auth, bool prot)
|
||||
Object Create7(StackStrF & name, StackStrF & spec, Array & tags, Uint8 min, Uint8 max, SQInteger auth, bool prot)
|
||||
{
|
||||
return Create(name, spec, tags, min, max, auth, prot, false);
|
||||
}
|
||||
@@ -1149,7 +1152,7 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Convenience constructor.
|
||||
*/
|
||||
Listener(StackStrF & name)
|
||||
explicit Listener(StackStrF & name)
|
||||
: Listener(name, DummyStackStrF(), NullArray(), 0, SQMOD_MAX_CMD_ARGS-1, -1, false, false)
|
||||
{
|
||||
/* ... */
|
||||
@@ -1239,11 +1242,11 @@ public:
|
||||
STHROWF("Unable to extract a valid listener name");
|
||||
}
|
||||
// Validate the specified name and assign it
|
||||
m_Name.assign(ValidateName(name.mPtr), name.mLen);
|
||||
m_Name.assign(ValidateName(name.mPtr), static_cast< size_t >(name.mLen));
|
||||
// Initialize the specifiers to default values
|
||||
for (Uint8 n = 0; n < SQMOD_MAX_CMD_ARGS; ++n)
|
||||
for (unsigned char & n : m_ArgSpec)
|
||||
{
|
||||
m_ArgSpec[n] = CMDARG_ANY;
|
||||
n = CMDARG_ANY;
|
||||
}
|
||||
// Apply the specified argument rules/specifications
|
||||
SetSpec(spec); // guaranteed the value will not be modified!
|
||||
@@ -1449,13 +1452,13 @@ public:
|
||||
// Detach from the current name if necessary
|
||||
ctr->Detach(this);
|
||||
// Now it's safe to assign the new name
|
||||
m_Name.assign(name.mPtr, name.mLen);
|
||||
m_Name.assign(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
// We know the new name is valid
|
||||
ctr->Attach(NullObject(), this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Name.assign(name.mPtr, name.mLen); // Just assign the name
|
||||
m_Name.assign(name.mPtr, static_cast< size_t >(name.mLen)); // Just assign the name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1498,7 +1501,7 @@ public:
|
||||
// Assign the specifier, if any
|
||||
if (spec.mLen > 0)
|
||||
{
|
||||
m_Spec.assign(spec.mPtr, spec.mLen);
|
||||
m_Spec.assign(spec.mPtr, static_cast< size_t >(spec.mLen));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1530,9 +1533,9 @@ public:
|
||||
// Preliminary checks before even attempting anything
|
||||
if (tags.GetType() != OT_ARRAY || tags.IsNull())
|
||||
{
|
||||
for (Uint8 n = 0; n < SQMOD_MAX_CMD_ARGS; ++n)
|
||||
for (auto & m_ArgTag : m_ArgTags)
|
||||
{
|
||||
m_ArgTags[n].clear();
|
||||
m_ArgTag.clear();
|
||||
}
|
||||
// We're done here!
|
||||
return;
|
||||
@@ -1542,9 +1545,9 @@ public:
|
||||
// If no tags were specified then clear current tags
|
||||
if (!max)
|
||||
{
|
||||
for (Uint8 n = 0; n < SQMOD_MAX_CMD_ARGS; ++n)
|
||||
for (auto & m_ArgTag : m_ArgTags)
|
||||
{
|
||||
m_ArgTags[n].clear();
|
||||
m_ArgTag.clear();
|
||||
}
|
||||
}
|
||||
// See if we're in range
|
||||
@@ -1578,7 +1581,7 @@ public:
|
||||
}
|
||||
else if (help.mLen > 0)
|
||||
{
|
||||
m_Help.assign(help.mPtr, help.mLen);
|
||||
m_Help.assign(help.mPtr, static_cast< size_t >(help.mLen));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1605,7 +1608,7 @@ public:
|
||||
}
|
||||
else if (info.mLen > 0)
|
||||
{
|
||||
m_Info.assign(info.mPtr, info.mLen);
|
||||
m_Info.assign(info.mPtr, static_cast< size_t >(info.mLen));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1880,7 +1883,7 @@ public:
|
||||
// The string type doesn't appreciate null values
|
||||
else if (name.mLen > 0)
|
||||
{
|
||||
m_ArgTags[arg].assign(name.mPtr, name.mLen);
|
||||
m_ArgTags[arg].assign(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
}
|
||||
// Clear previous name in this case
|
||||
else
|
||||
@@ -1925,10 +1928,7 @@ public:
|
||||
bool AuthCheck(const Object & invoker)
|
||||
{
|
||||
// Do we need explicit authority verification?
|
||||
if (!m_Protected)
|
||||
{
|
||||
return true; // Anyone can invoke this command
|
||||
}
|
||||
if (!m_Protected) { /* Anyone can invoke this command */ }
|
||||
// Was there a custom authority inspector specified?
|
||||
else if (!m_OnAuth.IsNull())
|
||||
{
|
||||
|
||||
@@ -37,9 +37,9 @@ static const EnumElement g_SqMod[] = {
|
||||
{_SC("MinFloat32"), std::numeric_limits< Float32 >::min()},
|
||||
{_SC("MaxFloat32"), std::numeric_limits< Float32 >::max()},
|
||||
{_SC("FpNormal"), FP_NORMAL},
|
||||
{_SC("FpSubnormal"), FP_SUBNORMAL},
|
||||
{_SC("FpSubnormal"), FP_SUBNORMAL}, // NOLINT(hicpp-signed-bitwise)
|
||||
{_SC("FpZero"), FP_ZERO},
|
||||
{_SC("FpInfinite"), FP_INFINITE},
|
||||
{_SC("FpInfinite"), FP_INFINITE}, // NOLINT(hicpp-signed-bitwise)
|
||||
{_SC("FpNan"), FP_NAN},
|
||||
#ifdef SQUSEDOUBLE
|
||||
{_SC("HugeVal"), HUGE_VAL},
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -25,7 +23,7 @@ static HSQUIRRELVM GetSquirrelVM()
|
||||
static SQRESULT SqModImpl_LoadScript(const SQChar * filepath, SQBool delay)
|
||||
{
|
||||
// Attempt to add the specified script to the load queue
|
||||
if (Core::Get().LoadScript(filepath, delay))
|
||||
if (Core::Get().LoadScript(filepath, static_cast< bool >(delay)))
|
||||
{
|
||||
return SQ_OK; // The script as added or already existed
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ Int32 GetMaxPlayers(void)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SetMaxPlayers(Int32 max)
|
||||
{
|
||||
_Func->SetMaxPlayers(max);
|
||||
_Func->SetMaxPlayers(static_cast< uint32_t >(max));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -338,7 +338,7 @@ void SetGameModeText(StackStrF & text)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CreateRadioStream(bool listed, StackStrF & name, StackStrF & url)
|
||||
{
|
||||
if (_Func->AddRadioStream(-1, name.mPtr, url.mPtr, listed) == vcmpErrorArgumentOutOfBounds)
|
||||
if (_Func->AddRadioStream(-1, name.mPtr, url.mPtr, static_cast< uint8_t >(listed)) == vcmpErrorArgumentOutOfBounds)
|
||||
{
|
||||
STHROWF("Invalid radio stream identifier");
|
||||
}
|
||||
@@ -347,7 +347,7 @@ void CreateRadioStream(bool listed, StackStrF & name, StackStrF & url)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CreateRadioStreamEx(Int32 id, bool listed, StackStrF & name, StackStrF & url)
|
||||
{
|
||||
if (_Func->AddRadioStream(id, name.mPtr, url.mPtr, listed) == vcmpErrorArgumentOutOfBounds)
|
||||
if (_Func->AddRadioStream(id, name.mPtr, url.mPtr, static_cast< uint8_t >(listed)) == vcmpErrorArgumentOutOfBounds)
|
||||
{
|
||||
STHROWF("Invalid radio stream identifier");
|
||||
}
|
||||
@@ -386,7 +386,7 @@ bool GetServerOption(Int32 option_id)
|
||||
void SetServerOption(Int32 option_id, bool toggle)
|
||||
{
|
||||
if (_Func->SetServerOption(static_cast< vcmpServerOption >(option_id),
|
||||
toggle) == vcmpErrorArgumentOutOfBounds)
|
||||
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
||||
{
|
||||
STHROWF("Unknown option identifier: %d", option_id);
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void SetServerOption(Int32 option_id, bool toggle)
|
||||
void SetServerOptionEx(Int32 option_id, bool toggle, Int32 header, LightObj & payload)
|
||||
{
|
||||
if (_Func->SetServerOption(static_cast< vcmpServerOption >(option_id),
|
||||
toggle) == vcmpErrorArgumentOutOfBounds)
|
||||
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
||||
{
|
||||
STHROWF("Unknown option identifier: %d", option_id);
|
||||
}
|
||||
@@ -469,7 +469,7 @@ void SetWastedSettings(Uint32 dt, Uint32 ft, Float32 fis, Float32 fos,
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Uint32 GetTimeRate(void)
|
||||
Int32 GetTimeRate(void)
|
||||
{
|
||||
return _Func->GetTimeRate();
|
||||
}
|
||||
@@ -592,7 +592,7 @@ void SetVehiclesForcedRespawnHeight(Float32 height)
|
||||
void CreateExplosion(Int32 world, Int32 type, const Vector3 & pos, CPlayer & source, bool grounded)
|
||||
{
|
||||
if (_Func->CreateExplosion(world, type, pos.x, pos.y, pos.z,
|
||||
source.GetID(), grounded) == vcmpErrorArgumentOutOfBounds)
|
||||
source.GetID(), static_cast< uint8_t >(grounded)) == vcmpErrorArgumentOutOfBounds)
|
||||
{
|
||||
STHROWF("Argument value out of bounds");
|
||||
}
|
||||
@@ -602,7 +602,7 @@ void CreateExplosion(Int32 world, Int32 type, const Vector3 & pos, CPlayer & sou
|
||||
void CreateExplosionEx(Int32 world, Int32 type, Float32 x, Float32 y, Float32 z, CPlayer & source, bool grounded)
|
||||
{
|
||||
if (_Func->CreateExplosion(world, type, x, y, z,
|
||||
source.GetID(), grounded) == vcmpErrorArgumentOutOfBounds)
|
||||
source.GetID(), static_cast< uint8_t >(grounded)) == vcmpErrorArgumentOutOfBounds)
|
||||
{
|
||||
STHROWF("Argument value out of bounds");
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ Uint32 GetServerFlags();
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the maximum number of clients allowed on the server.
|
||||
*/
|
||||
Int32 GetMaxPlayers(void);
|
||||
Int32 GetMaxPlayers();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the maximum number of clients allowed on the server.
|
||||
@@ -200,7 +200,7 @@ void SetWastedSettings(Uint32 dt, Uint32 ft, Float32 fis, Float32 fos,
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the current time-rate.
|
||||
*/
|
||||
Uint32 GetTimeRate(void);
|
||||
Int32 GetTimeRate();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the current time-rate.
|
||||
@@ -210,7 +210,7 @@ void SetTimeRate(Uint32 rate);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the game hour.
|
||||
*/
|
||||
Int32 GetHour(void);
|
||||
Int32 GetHour();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the game hour.
|
||||
@@ -220,7 +220,7 @@ void SetHour(Int32 hour);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the game minute.
|
||||
*/
|
||||
Int32 GetMinute(void);
|
||||
Int32 GetMinute();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the game minute.
|
||||
@@ -230,7 +230,7 @@ void SetMinute(Int32 minute);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the weather effects.
|
||||
*/
|
||||
Int32 GetWeather(void);
|
||||
Int32 GetWeather();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the weather effects.
|
||||
@@ -240,7 +240,7 @@ void SetWeather(Int32 weather);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the game gravity.
|
||||
*/
|
||||
Float32 GetGravity(void);
|
||||
Float32 GetGravity();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the game gravity.
|
||||
@@ -250,7 +250,7 @@ void SetGravity(Float32 gravity);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the game speed.
|
||||
*/
|
||||
Float32 GetGameSpeed(void);
|
||||
Float32 GetGameSpeed();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the game speed.
|
||||
@@ -260,7 +260,7 @@ void SetGameSpeed(Float32 speed);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the water level.
|
||||
*/
|
||||
Float32 GetWaterLevel(void);
|
||||
Float32 GetWaterLevel();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the water level.
|
||||
@@ -270,7 +270,7 @@ void SetWaterLevel(Float32 level);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the maximum flight altitude.
|
||||
*/
|
||||
Float32 GetMaximumFlightAltitude(void);
|
||||
Float32 GetMaximumFlightAltitude();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the maximum flight altitude.
|
||||
@@ -280,7 +280,7 @@ void SetMaximumFlightAltitude(Float32 height);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the kill command delay.
|
||||
*/
|
||||
Int32 GetKillCommandDelay(void);
|
||||
Int32 GetKillCommandDelay();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the kill command delay.
|
||||
@@ -290,7 +290,7 @@ void SetKillCommandDelay(Int32 delay);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve the vehicles forced respawn height.
|
||||
*/
|
||||
Float32 GetVehiclesForcedRespawnHeight(void);
|
||||
Float32 GetVehiclesForcedRespawnHeight();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the vehicles forced respawn height.
|
||||
@@ -355,7 +355,7 @@ void ShowMapObjectRaw(Int32 model, Int16 x, Int16 y, Int16 z);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Make all map objects visible again.
|
||||
*/
|
||||
void ShowAllMapObjects(void);
|
||||
void ShowAllMapObjects();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Retrieve field data of a certain weapon.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static String CS_Skin_Names[] = {
|
||||
static String CS_Skin_Names[] = { // NOLINT(cert-err58-cpp)
|
||||
/* 0 */ "Tommy Vercetti", /* 1 */ "Cop",
|
||||
/* 2 */ "SWAT", /* 3 */ "FBI",
|
||||
/* 4 */ "Army", /* 5 */ "Paramedic",
|
||||
@@ -114,7 +114,7 @@ void SetSkinName(Uint32 id, StackStrF & name)
|
||||
Int32 GetSkinID(StackStrF & name)
|
||||
{
|
||||
// Clone the string into an editable version
|
||||
String str(name.mPtr, name.mLen);
|
||||
String str(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
// Strip non alphanumeric characters from the name
|
||||
str.erase(std::remove_if(str.begin(), str.end(), std::not1(std::ptr_fun(::isalnum))), str.end());
|
||||
// Convert the string to lowercase
|
||||
@@ -154,6 +154,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'r':
|
||||
if (c == 'a') return SQMOD_SKIN_ARABIC_GUY;
|
||||
else if (c == 'm') return SQMOD_SKIN_ARMY;
|
||||
default: break;
|
||||
}
|
||||
// [B]each guy (#1|A)/(#2|B)/(#3|C)/(#4|D)/(#5|E)/(#6|F)/(#7|G)/(#8|H)
|
||||
// [B]each lady (#1|A)/(#2|B)/(#3|C)/(#4|D)/(#5|E)/(#6|F)/(#7|G)
|
||||
@@ -184,6 +185,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'g': return SQMOD_SKIN_BEACH_GUY_G;
|
||||
case '8':
|
||||
case 'h': return SQMOD_SKIN_BEACH_GUY_H;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Be]ach [l]ady (#1|A)/(#2|B)/(#3|C)/(#4|D)/(#5|E)/(#6|F)/(#7|G)
|
||||
@@ -205,6 +207,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'f': return SQMOD_SKIN_BEACH_LADY_F;
|
||||
case '7':
|
||||
case 'g': return SQMOD_SKIN_BEACH_LADY_G;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Bi]ker (#1|A)/(#2|B)
|
||||
@@ -248,6 +251,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'e': return SQMOD_SKIN_BUSINESS_MAN_E;
|
||||
case '6':
|
||||
case 'f': return SQMOD_SKIN_BUSINESS_MAN_F;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [C]am, [C]am (Robber), [C]andy Suxx, [C]hef
|
||||
@@ -315,6 +319,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'c': return SQMOD_SKIN_COOL_GUY_C;
|
||||
case '4':
|
||||
case 'd': return SQMOD_SKIN_COOL_GUY_D;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Cop]
|
||||
@@ -346,6 +351,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'g':
|
||||
if (d == '1' || d == 'a') return SQMOD_SKIN_DIAZ_GUY_A;
|
||||
else if (d == '2' || d == 'b') return SQMOD_SKIN_DIAZ_GUY_B;
|
||||
default: break;
|
||||
}
|
||||
// [F]BI, [F]ireman, [F]ood lady, [F]rench guy
|
||||
// fall through
|
||||
@@ -363,6 +369,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
// [Fr]ench [g]uy
|
||||
case 'r':
|
||||
case 'g': return SQMOD_SKIN_FRENCH_GUY;
|
||||
default: break;
|
||||
}
|
||||
// [G]arbageman (#1|A)/(#2|B)/(#3|C)/(#4|D)/(#5|E)
|
||||
// [G]olf guy (#1|A)/(#2|B)/(#3|C)
|
||||
@@ -385,6 +392,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'd': return SQMOD_SKIN_GARBAGEMAN_D;
|
||||
case '5':
|
||||
case 'e': return SQMOD_SKIN_GARBAGEMAN_E;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Go]lf [g]uy (#1|A)/(#2|B)/(#3|C)
|
||||
@@ -398,6 +406,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'b': return SQMOD_SKIN_GOLF_GUY_B;
|
||||
case '3':
|
||||
case 'c': return SQMOD_SKIN_GOLF_GUY_C;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Go]lf [l]ady
|
||||
@@ -434,6 +443,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'd': return SQMOD_SKIN_HATIAN_D;
|
||||
case '5':
|
||||
case 'e': return SQMOD_SKIN_HATIAN_E;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Hi]lary ([R]obbe[r])
|
||||
@@ -453,7 +463,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'l':
|
||||
//[Lan]ce ([C]o[p])
|
||||
if ((b == 'a') && (c == 'n') && ((len > 5 && str[5] == 'c') || d == 'p'))
|
||||
return SQMOD_SKIN_LANCE_COP;
|
||||
return SQMOD_SKIN_LANCE_COP; // NOLINT(bugprone-branch-clone)
|
||||
else if (b && (b == 'c' || (b == 'a' && (c == 'n'))))
|
||||
return SQMOD_SKIN_LANCE_COP;
|
||||
// [La]nce (#1|A)/(#1|B)
|
||||
@@ -476,6 +486,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case '3':
|
||||
case 'c': return SQMOD_SKIN_LOVE_FIST_C;
|
||||
case 'd': return SQMOD_SKIN_LOVE_FIST_D;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [M]ercades
|
||||
@@ -526,6 +537,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'e': return SQMOD_SKIN_PROSTITUTE_E;
|
||||
case '4':
|
||||
case 'f': return SQMOD_SKIN_PROSTITUTE_F;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Pu]nk (#1|A)/(#2|B)/(#3|C)
|
||||
@@ -539,6 +551,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'b': return SQMOD_SKIN_PUNK_B;
|
||||
case '3':
|
||||
case 'c': return SQMOD_SKIN_PUNK_C;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [R]ich guy, [R]ockstar guy
|
||||
@@ -572,6 +585,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'b': return SQMOD_SKIN_SAILOR_B;
|
||||
case '3':
|
||||
case 'c': return SQMOD_SKIN_SAILOR_C;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [S]hark (#1|A)/(#2|B)
|
||||
@@ -583,6 +597,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'a': return SQMOD_SKIN_SHARK_A;
|
||||
case '2':
|
||||
case 'b': return SQMOD_SKIN_SHARK_B;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [S]hopper (#1|A)/(#2|B)
|
||||
@@ -594,6 +609,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'a': return SQMOD_SKIN_SHOPPER_A;
|
||||
case '2':
|
||||
case 'b': return SQMOD_SKIN_SHOPPER_B;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Sk]ate [g]uy
|
||||
@@ -605,7 +621,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
// [So]nny
|
||||
// [So]nny guy (#1|A)/(#2|B)/(#3|C)
|
||||
else if (b == 'o')
|
||||
{
|
||||
{ // NOLINT(bugprone-branch-clone)
|
||||
switch (d)
|
||||
{
|
||||
case '1':
|
||||
@@ -614,6 +630,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'b': return SQMOD_SKIN_SONNY_GUY_B;
|
||||
case '3':
|
||||
case 'c': return SQMOD_SKIN_SONNY_GUY_C;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else if (b == 'g')
|
||||
@@ -626,6 +643,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'b': return SQMOD_SKIN_SONNY_GUY_B;
|
||||
case '3':
|
||||
case 'c': return SQMOD_SKIN_SONNY_GUY_C;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Sp]andE[x] (#1|A)/(#2|B)
|
||||
@@ -637,6 +655,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'a': return SQMOD_SKIN_SPANDEX_GUY_A;
|
||||
case '2':
|
||||
case 'b': return SQMOD_SKIN_SPANDEX_GUY_B;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Sp]anish [g]uy
|
||||
@@ -655,6 +674,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'c': return SQMOD_SKIN_SPANISH_LADY_C;
|
||||
case '4':
|
||||
case 'd': return SQMOD_SKIN_SPANISH_LADY_D;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Sto]re clerk
|
||||
@@ -670,6 +690,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'b': return SQMOD_SKIN_STRIPPER_B;
|
||||
case '3':
|
||||
case 'c': return SQMOD_SKIN_STRIPPER_C;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
// [Sw]at
|
||||
@@ -693,6 +714,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'b': return SQMOD_SKIN_TAXI_DRIVER_B;
|
||||
case 'c': return SQMOD_SKIN_TAXI_DRIVER_C;
|
||||
case 'd': return SQMOD_SKIN_TAXI_DRIVER_D;
|
||||
default: break;
|
||||
}
|
||||
// [Th]ug (#1|A)/(#2|B)
|
||||
case 'h':
|
||||
@@ -702,6 +724,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'a': return SQMOD_SKIN_THUG_A;
|
||||
case '5':
|
||||
case 'b': return SQMOD_SKIN_THUG_B;
|
||||
default: break;
|
||||
}
|
||||
// [To]mmy [V]ercetti
|
||||
// [To]urist (#1|A)/(#2|B)
|
||||
@@ -712,6 +735,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
else if (c == 'u' && (d == '2' || d == 'b')) return SQMOD_SKIN_TOURIST_B;
|
||||
// fall through
|
||||
case 'r': return SQMOD_SKIN_TRANNY;
|
||||
default: break;
|
||||
}
|
||||
// [U]ndercover cop (#1|A)/(#2|B)/(#3|C)/(#4|D)/(#5|E)/(#6|F)
|
||||
case 'u':
|
||||
@@ -729,6 +753,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'e': return SQMOD_SKIN_UNDERCOVER_COP_E;
|
||||
case '6':
|
||||
case 'f': return SQMOD_SKIN_UNDERCOVER_COP_F;
|
||||
default: break;
|
||||
}
|
||||
// [V]ercetti guy (#1|A)/(#2|B)
|
||||
case 'v':
|
||||
@@ -738,6 +763,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'a': return SQMOD_SKIN_VERCETTI_GUY_A;
|
||||
case '2':
|
||||
case 'b': return SQMOD_SKIN_VERCETTI_GUY_B;
|
||||
default: break;
|
||||
}
|
||||
// [W]aitress (#1|A)/(#2|B)
|
||||
case 'w':
|
||||
@@ -747,6 +773,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
case 'a': return SQMOD_SKIN_WAITRESS_A;
|
||||
case '2':
|
||||
case 'b': return SQMOD_SKIN_WAITRESS_B;
|
||||
default: break;
|
||||
}
|
||||
// Default to unknown
|
||||
default: return SQMOD_UNKNOWN;
|
||||
@@ -756,7 +783,7 @@ Int32 GetSkinID(StackStrF & name)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool IsSkinValid(Int32 id)
|
||||
{
|
||||
CSStr name = GetSkinName(id);
|
||||
CSStr name = GetSkinName(static_cast<Uint32>(id));
|
||||
return (name && *name != '\0');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Core.hpp"
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Base/Color3.hpp"
|
||||
#include "Base/Vector2.hpp"
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Library/Numeric/LongInt.hpp"
|
||||
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
#include "Library/Chrono.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <utility>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
@@ -37,7 +34,7 @@ void Routine::Process()
|
||||
// Get the current time-stamp
|
||||
s_Last = Chrono::GetCurrentSysTime();
|
||||
// Calculate the elapsed time
|
||||
const Int32 delta = Int32((s_Last - s_Prev) / 1000L);
|
||||
const auto delta = Int32((s_Last - s_Prev) / 1000L);
|
||||
// Process all active routines
|
||||
for (Interval * itr = s_Intervals; itr != (s_Intervals + SQMOD_MAX_ROUTINES); ++itr)
|
||||
{
|
||||
@@ -251,7 +248,7 @@ SQInteger Routine::Create(HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
// Alright, at this point we can initialize the slot
|
||||
inst.Init(env, func, obj, intrv, itr);
|
||||
inst.Init(env, func, obj, intrv, static_cast< Iterator >(itr));
|
||||
// Now initialize the timer
|
||||
s_Intervals[slot] = intrv;
|
||||
// We have the created routine on the stack, so let's return it
|
||||
@@ -267,7 +264,7 @@ bool Routine::IsWithTag(StackStrF & tag)
|
||||
// Iterate routine list
|
||||
for (const auto & r : s_Instances)
|
||||
{
|
||||
if (!r.mInst.IsNull() && r.mTag.compare(tag.mPtr) == 0)
|
||||
if (!r.mInst.IsNull() && r.mTag == tag.mPtr)
|
||||
{
|
||||
return true; // Yup, we're doing this
|
||||
}
|
||||
@@ -286,7 +283,7 @@ bool Routine::TerminateWithTag(StackStrF & tag)
|
||||
// Iterate routine list
|
||||
for (auto & r : s_Instances)
|
||||
{
|
||||
if (!r.mInst.IsNull() && r.mTag.compare(tag.mPtr) == 0)
|
||||
if (!r.mInst.IsNull() && r.mTag == tag.mPtr)
|
||||
{
|
||||
r.Terminate(); // Yup, we're doing this
|
||||
return true; // A routine was terminated
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Instance()
|
||||
Instance() noexcept
|
||||
: mEnv()
|
||||
, mFunc()
|
||||
, mInst()
|
||||
@@ -160,7 +160,7 @@ private:
|
||||
sq_pushobject(vm, mArgv[n].mObj);
|
||||
}
|
||||
// Make the function call and store the result
|
||||
const SQRESULT res = sq_call(vm, mArgc + 1, false, !mQuiet);
|
||||
const SQRESULT res = sq_call(vm, mArgc + 1, static_cast< SQBool >(false), static_cast< SQBool >(!mQuiet));
|
||||
// Pop the callback object from the stack
|
||||
sq_pop(vm, 1);
|
||||
// Validate the result
|
||||
@@ -235,12 +235,30 @@ protected:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Routine(Uint32 slot)
|
||||
explicit Routine(Uint32 slot)
|
||||
: m_Slot(slot)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Find an unoccupied routine slot.
|
||||
*/
|
||||
static SQInteger FindUnused()
|
||||
{
|
||||
for (const auto & r : s_Instances)
|
||||
{
|
||||
if (r.mInst.IsNull())
|
||||
{
|
||||
return (&r - s_Instances); // Return the index of this element
|
||||
}
|
||||
}
|
||||
// No available slot
|
||||
return -1;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
@@ -261,24 +279,6 @@ protected:
|
||||
*/
|
||||
Routine & operator = (Routine && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Find an unoccupied routine slot.
|
||||
*/
|
||||
static SQInteger FindUnused()
|
||||
{
|
||||
for (const auto & r : s_Instances)
|
||||
{
|
||||
if (r.mInst.IsNull())
|
||||
{
|
||||
return (&r - s_Instances); // Return the index of this element
|
||||
}
|
||||
}
|
||||
// No available slot
|
||||
return -1;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the number of used routine slots.
|
||||
*/
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
// Iterate routine list
|
||||
for (const auto & r : s_Instances)
|
||||
{
|
||||
if (!r.mInst.IsNull() && r.mTag.compare(tag.mPtr) == 0)
|
||||
if (!r.mInst.IsNull() && r.mTag == tag.mPtr)
|
||||
{
|
||||
return r.mInst; // Return this routine instance
|
||||
}
|
||||
@@ -318,7 +318,10 @@ public:
|
||||
// Unable to find such routine
|
||||
STHROWF("Unable to find a routine with tag (%s)", tag.mPtr);
|
||||
// Should not reach this point but if it did, we have to return something
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warray-bounds"
|
||||
return s_Instances[SQMOD_MAX_ROUTINES].mInst; // Intentional Buffer overflow!
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Check if a routine with a certain tag exists.
|
||||
@@ -405,7 +408,7 @@ public:
|
||||
*/
|
||||
void SetTag(StackStrF & tag)
|
||||
{
|
||||
GetValid().mTag.assign(tag.mPtr, ClampMin(tag.mLen, 0));
|
||||
GetValid().mTag.assign(tag.mPtr, static_cast< size_t >(ClampMin(tag.mLen, 0)));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -30,11 +30,12 @@ struct SignalWrapper
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Explicit constructor.
|
||||
*/
|
||||
SignalWrapper(HSQUIRRELVM vm, bool extra = false)
|
||||
explicit SignalWrapper(HSQUIRRELVM vm, bool extra = false)
|
||||
: mSignal(nullptr)
|
||||
, mSlot()
|
||||
, mVM(vm)
|
||||
, mRes(Initialize(vm, extra))
|
||||
, mOne(false), mAppend(false)
|
||||
{
|
||||
//...
|
||||
}
|
||||
@@ -236,7 +237,7 @@ template < class Slot > struct MatchThis
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
MatchThis(SQHash t)
|
||||
explicit MatchThis(SQHash t)
|
||||
: mThisHash(t)
|
||||
{
|
||||
//...
|
||||
@@ -262,7 +263,7 @@ template < class Slot > struct MatchFunc
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
MatchFunc(SQHash f)
|
||||
explicit MatchFunc(SQHash f)
|
||||
: mFuncHash(f)
|
||||
{
|
||||
//...
|
||||
@@ -612,10 +613,10 @@ bool Signal::AdjustSlots(SizeType capacity)
|
||||
// Calculate the next optimal size of the buffer
|
||||
while (size < capacity)
|
||||
{
|
||||
size += (size + 1) >> 1;
|
||||
size += (size + 1u) >> 1u;
|
||||
}
|
||||
// Attempt to allocate a memory buffer of the resulted size
|
||||
Pointer slots = reinterpret_cast< Pointer >(new uint8_t[size * sizeof(Slot)]);
|
||||
auto slots = reinterpret_cast< Pointer >(new uint8_t[size * sizeof(Slot)]);
|
||||
// See if the memory could be allocated
|
||||
if (slots == nullptr)
|
||||
{
|
||||
@@ -626,7 +627,7 @@ bool Signal::AdjustSlots(SizeType capacity)
|
||||
// Are there any existing slots?
|
||||
if (m_Used)
|
||||
{
|
||||
// Grab the range of slots to be transfered
|
||||
// Grab the range of slots to be transferred
|
||||
Pointer src = m_Slots, end = (m_Slots + m_Used);
|
||||
// Transfer the existing slots
|
||||
while (src != end)
|
||||
@@ -728,7 +729,7 @@ SQInteger Signal::Exists(SignalWrapper & w)
|
||||
const bool r = ExistsIf(MatchSlot< Slot >(w.mSlot.mThisHash, w.mSlot.mFuncHash),
|
||||
m_Slots, m_Slots + m_Used);
|
||||
// Push the resulted value on the stack
|
||||
sq_pushbool(w.mVM, r);
|
||||
sq_pushbool(w.mVM, static_cast< SQBool >(r));
|
||||
// Specify that we returned a value
|
||||
return 1;
|
||||
}
|
||||
@@ -739,7 +740,7 @@ SQInteger Signal::ExistsThis(SignalWrapper & w)
|
||||
// Forward the call to the actual function
|
||||
const bool r = ExistsIf(MatchThis< Slot >(w.mSlot.mThisHash), m_Slots, m_Slots + m_Used);
|
||||
// Push the resulted value on the stack
|
||||
sq_pushbool(w.mVM, r);
|
||||
sq_pushbool(w.mVM, static_cast< SQBool >(r));
|
||||
// Specify that we returned a value
|
||||
return 1;
|
||||
}
|
||||
@@ -750,7 +751,7 @@ SQInteger Signal::ExistsFunc(SignalWrapper & w)
|
||||
// Forward the call to the actual function
|
||||
const bool r = ExistsIf(MatchFunc< Slot >(w.mSlot.mFuncHash), m_Slots, m_Slots + m_Used);
|
||||
// Push the resulted value on the stack
|
||||
sq_pushbool(w.mVM, r);
|
||||
sq_pushbool(w.mVM, static_cast< SQBool >(r));
|
||||
// Specify that we returned a value
|
||||
return 1;
|
||||
}
|
||||
@@ -1000,7 +1001,7 @@ SQInteger Signal::Emit(HSQUIRRELVM vm, SQInteger top)
|
||||
}
|
||||
}
|
||||
// Make the function call and store the result
|
||||
res = sq_call(vm, top, false, ErrorHandling::IsEnabled());
|
||||
res = sq_call(vm, top, static_cast< SQBool >(false), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Pop the callback object from the stack
|
||||
sq_pop(vm, 1);
|
||||
// Validate the result
|
||||
@@ -1083,7 +1084,7 @@ SQInteger Signal::Query(HSQUIRRELVM vm, SQInteger top)
|
||||
}
|
||||
}
|
||||
// Make the function call and store the result
|
||||
res = sq_call(vm, top-2, true, ErrorHandling::IsEnabled());
|
||||
res = sq_call(vm, top-2, static_cast< SQBool >(true), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Validate the result
|
||||
if (SQ_FAILED(res))
|
||||
{
|
||||
@@ -1098,7 +1099,7 @@ SQInteger Signal::Query(HSQUIRRELVM vm, SQInteger top)
|
||||
// Push the returned value
|
||||
sq_push(vm, -3);
|
||||
// Make the function call and store the result
|
||||
res = sq_call(vm, 2, false, ErrorHandling::IsEnabled());
|
||||
res = sq_call(vm, 2, static_cast< SQBool >(false), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Pop the callback object, return value and collector from the stack
|
||||
sq_pop(vm, 3);
|
||||
// Validate the result
|
||||
@@ -1149,7 +1150,7 @@ SQInteger Signal::Consume(HSQUIRRELVM vm, SQInteger top)
|
||||
}
|
||||
}
|
||||
// Make the function call and store the result
|
||||
res = sq_call(vm, top, true, ErrorHandling::IsEnabled());
|
||||
res = sq_call(vm, top, static_cast< SQBool >(true), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Validate the result
|
||||
if (SQ_FAILED(res))
|
||||
{
|
||||
@@ -1224,7 +1225,7 @@ SQInteger Signal::Approve(HSQUIRRELVM vm, SQInteger top)
|
||||
}
|
||||
}
|
||||
// Make the function call and store the result
|
||||
res = sq_call(vm, top, true, ErrorHandling::IsEnabled());
|
||||
res = sq_call(vm, top, static_cast< SQBool >(true), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Validate the result
|
||||
if (SQ_FAILED(res))
|
||||
{
|
||||
@@ -1297,7 +1298,7 @@ SQInteger Signal::Request(HSQUIRRELVM vm, SQInteger top)
|
||||
}
|
||||
}
|
||||
// Make the function call and store the result
|
||||
res = sq_call(vm, top, true, ErrorHandling::IsEnabled());
|
||||
res = sq_call(vm, top, static_cast< SQBool >(true), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Validate the result
|
||||
if (SQ_FAILED(res))
|
||||
{
|
||||
@@ -1328,7 +1329,7 @@ SQInteger Signal::SqEmit(HSQUIRRELVM vm)
|
||||
{
|
||||
const SQInteger top = sq_gettop(vm);
|
||||
// Contains the last received result
|
||||
SQRESULT res = SQ_OK;
|
||||
SQRESULT res;
|
||||
// Attempt to forward the call to the signal instance
|
||||
try
|
||||
{
|
||||
@@ -1368,7 +1369,7 @@ SQInteger Signal::SqQuery(HSQUIRRELVM vm)
|
||||
return sq_throwerror(vm, "Missing collector callback");
|
||||
}
|
||||
// Contains the last received result
|
||||
SQRESULT res = SQ_OK;
|
||||
SQRESULT res;
|
||||
// Attempt to forward the call to the signal instance
|
||||
try
|
||||
{
|
||||
@@ -1398,7 +1399,7 @@ SQInteger Signal::SqConsume(HSQUIRRELVM vm)
|
||||
{
|
||||
const SQInteger top = sq_gettop(vm);
|
||||
// Contains the last received result
|
||||
SQRESULT res = SQ_OK;
|
||||
SQRESULT res;
|
||||
// Attempt to forward the call to the signal instance
|
||||
try
|
||||
{
|
||||
@@ -1428,7 +1429,7 @@ SQInteger Signal::SqApprove(HSQUIRRELVM vm)
|
||||
{
|
||||
const SQInteger top = sq_gettop(vm);
|
||||
// Contains the last received result
|
||||
SQRESULT res = SQ_OK;
|
||||
SQRESULT res;
|
||||
// Attempt to forward the call to the signal instance
|
||||
try
|
||||
{
|
||||
@@ -1458,7 +1459,7 @@ SQInteger Signal::SqRequest(HSQUIRRELVM vm)
|
||||
{
|
||||
const SQInteger top = sq_gettop(vm);
|
||||
// Contains the last received result
|
||||
SQRESULT res = SQ_OK;
|
||||
SQRESULT res;
|
||||
// Attempt to forward the call to the signal instance
|
||||
try
|
||||
{
|
||||
@@ -1536,7 +1537,7 @@ LightObj Signal::Create(StackStrF & name)
|
||||
return CreateFree();
|
||||
}
|
||||
// Create a copy of the name
|
||||
String sname(name.mPtr, name.mLen);
|
||||
String sname(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
// Compute the hash of the specified name
|
||||
const std::size_t hash = std::hash< String >{}(sname);
|
||||
// See if the signal already exists
|
||||
@@ -1572,11 +1573,11 @@ void Signal::Remove(StackStrF & name)
|
||||
STHROWF("Signals without names cannot be removed manually");
|
||||
}
|
||||
// Create a copy of the name
|
||||
const String sname(name.mPtr, name.mLen);
|
||||
const String sname(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
// Compute the hash of the specified name
|
||||
const std::size_t hash = std::hash< String >{}(sname);
|
||||
// Iterator to the existing signal, if any
|
||||
SignalPool::const_iterator itr = s_Signals.cbegin();
|
||||
auto itr = s_Signals.cbegin();
|
||||
// Search for a signal with this name
|
||||
for (; itr != s_Signals.cend(); ++itr)
|
||||
{
|
||||
@@ -1606,7 +1607,7 @@ const LightObj & Signal::Fetch(StackStrF & name)
|
||||
STHROWF("Signals without names cannot be retrieved manually");
|
||||
}
|
||||
// Create a copy of the name
|
||||
const String sname(name.mPtr, name.mLen);
|
||||
const String sname(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
// Compute the hash of the specified name
|
||||
const std::size_t hash = std::hash< String >{}(sname);
|
||||
// Search for a signal with this name
|
||||
|
||||
@@ -53,7 +53,7 @@ struct Signal
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Signal(String && name);
|
||||
explicit Signal(String && name);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor (disabled).
|
||||
@@ -183,7 +183,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Slot(Slot && o)
|
||||
Slot(Slot && o) noexcept
|
||||
: mThisHash(o.mThisHash)
|
||||
, mFuncHash(o.mFuncHash)
|
||||
, mThisRef(o.mThisRef)
|
||||
@@ -227,7 +227,7 @@ protected:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Slot & operator = (Slot && o)
|
||||
Slot & operator = (Slot && o) noexcept
|
||||
{
|
||||
if (this != &o)
|
||||
{
|
||||
@@ -665,6 +665,8 @@ protected:
|
||||
static SignalPool s_Signals; // List of all created signals.
|
||||
static FreeSignals s_FreeSignals; // List of signals without a name.
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "MemberFunctionCanBeStatic"
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Specialization for when there are no arguments given.
|
||||
*/
|
||||
@@ -672,6 +674,7 @@ protected:
|
||||
{
|
||||
//...
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Specialization for when there's only one argument given/remaining.
|
||||
@@ -749,13 +752,13 @@ public:
|
||||
// Push the given parameters on the stack
|
||||
PushParameters(args...);
|
||||
// Make the function call and store the result
|
||||
const SQRESULT res = sq_call(vm, 1 + sizeof...(Args), false, ErrorHandling::IsEnabled());
|
||||
const SQRESULT res = sq_call(vm, 1 + sizeof...(Args), static_cast< SQBool >(false), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Pop the callback object from the stack
|
||||
sq_pop(vm, 1);
|
||||
// Validate the result
|
||||
if (SQ_FAILED(res))
|
||||
{
|
||||
SQTHROW(vm, LastErrorString(vm)); // Stop emitting signals
|
||||
SQTHROW(vm, LastErrorString(vm)); // Stop emitting signals NOLINT(hicpp-exception-baseclass,cert-err60-cpp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,9 @@
|
||||
#include "Library/Chrono.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <utility>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
@@ -62,7 +59,7 @@ void Tasks::Task::Release()
|
||||
mIterations = 0;
|
||||
mInterval = 0;
|
||||
mEntity = -1;
|
||||
mType = -1;
|
||||
mType = 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -85,7 +82,7 @@ Tasks::Interval Tasks::Task::Execute()
|
||||
sq_pushobject(vm, mArgv[n].mObj);
|
||||
}
|
||||
// Make the function call and store the result
|
||||
const SQRESULT res = sq_call(vm, mArgc + 1, false, ErrorHandling::IsEnabled());
|
||||
const SQRESULT res = sq_call(vm, mArgc + 1, static_cast< SQBool >(false), static_cast< SQBool >(ErrorHandling::IsEnabled()));
|
||||
// Pop the callback object from the stack
|
||||
sq_pop(vm, 1);
|
||||
// Validate the result
|
||||
@@ -117,7 +114,7 @@ void Tasks::Process()
|
||||
// Get the current time-stamp
|
||||
s_Last = Chrono::GetCurrentSysTime();
|
||||
// Calculate the elapsed time
|
||||
const Int32 delta = Int32((s_Last - s_Prev) / 1000L);
|
||||
const auto delta = Int32((s_Last - s_Prev) / 1000L);
|
||||
// Process all active tasks
|
||||
for (Interval * itr = s_Intervals; itr != (s_Intervals + SQMOD_MAX_TASKS); ++itr)
|
||||
{
|
||||
@@ -317,7 +314,7 @@ SQInteger Tasks::Create(Int32 id, Int32 type, HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
// Alright, at this point we can initialize the slot
|
||||
task.Init(func, inst, intrv, itr, id, type);
|
||||
task.Init(func, inst, intrv, static_cast< Iterator >(itr), id, type);
|
||||
// Now initialize the timer
|
||||
s_Intervals[slot] = intrv;
|
||||
// Push the tag instance on the stack
|
||||
@@ -445,7 +442,7 @@ SQInteger Tasks::Exists(Int32 id, Int32 type, HSQUIRRELVM vm)
|
||||
return res; // Propagate the error
|
||||
}
|
||||
// Push a boolean on whether this task was found
|
||||
sq_pushbool(vm, pos >= 0);
|
||||
sq_pushbool(vm, static_cast< SQBool >(pos >= 0));
|
||||
// Specify that we're returning a value
|
||||
return 1;
|
||||
}
|
||||
@@ -456,7 +453,7 @@ const Tasks::Task & Tasks::FindByTag(Int32 id, Int32 type, StackStrF & tag)
|
||||
// Attempt to find the requested task
|
||||
for (const auto & t : s_Tasks)
|
||||
{
|
||||
if (t.mEntity == id && t.mType == type && t.mTag.compare(tag.mPtr) == 0)
|
||||
if (t.mEntity == id && t.mType == type && t.mTag == tag.mPtr)
|
||||
{
|
||||
return t; // Return this task instance
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
Task()
|
||||
Task() noexcept
|
||||
: mHash(0)
|
||||
, mTag()
|
||||
, mSelf()
|
||||
@@ -55,7 +55,7 @@ private:
|
||||
, mIterations(0)
|
||||
, mInterval(0)
|
||||
, mEntity(-1)
|
||||
, mType(-1)
|
||||
, mType(0)
|
||||
, mArgc(0)
|
||||
, mArgv()
|
||||
{
|
||||
@@ -149,7 +149,7 @@ private:
|
||||
*/
|
||||
void SetTag(StackStrF & tag)
|
||||
{
|
||||
mTag.assign(tag.mPtr, ClampMin(tag.mLen, 0));
|
||||
mTag.assign(tag.mPtr, static_cast< size_t >(ClampMin(tag.mLen, 0)));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
@@ -270,7 +270,19 @@ private:
|
||||
static Interval s_Intervals[SQMOD_MAX_TASKS]; // List of intervals to be processed.
|
||||
static Task s_Tasks[SQMOD_MAX_TASKS]; // List of tasks to be executed.
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Tasks & operator = (const Tasks & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Tasks & operator = (Tasks && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor. (disabled)
|
||||
*/
|
||||
Tasks() = delete;
|
||||
@@ -290,18 +302,6 @@ private:
|
||||
*/
|
||||
~Tasks() = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Tasks & operator = (const Tasks & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
Tasks & operator = (Tasks && o) = delete;
|
||||
|
||||
public:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Process all active tasks and update elapsed time.
|
||||
*/
|
||||
@@ -402,7 +402,10 @@ public:
|
||||
STHROWF("Invalid entity instance");
|
||||
}
|
||||
// Validate the actual entity instance
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCDFAInspection"
|
||||
inst->Validate();
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
@@ -430,7 +433,10 @@ public:
|
||||
STHROWF("Invalid entity instance");
|
||||
}
|
||||
// Validate the actual entity instance
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCDFAInspection"
|
||||
inst->Validate();
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
@@ -458,7 +464,10 @@ public:
|
||||
STHROWF("Invalid entity instance");
|
||||
}
|
||||
// Validate the actual entity instance
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCDFAInspection"
|
||||
inst->Validate();
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
@@ -491,7 +500,10 @@ public:
|
||||
STHROWF("Invalid entity instance");
|
||||
}
|
||||
// Validate the actual entity instance
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "OCDFAInspection"
|
||||
inst->Validate();
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
catch (const Sqrat::Exception & e)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static String CS_Vehicle_Names[] = {
|
||||
static String CS_Vehicle_Names[] = { // NOLINT(cert-err58-cpp)
|
||||
/* 130 */ "Landstalker", /* 131 */ "Idaho",
|
||||
/* 132 */ "Stinger", /* 133 */ "Linerunner",
|
||||
/* 134 */ "Perennial", /* 135 */ "Sentinel",
|
||||
@@ -73,7 +73,7 @@ static String CS_Custom_Vehicle_Names[100]{};
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
struct InitCustomVehicleNames
|
||||
{
|
||||
InitCustomVehicleNames()
|
||||
InitCustomVehicleNames() noexcept
|
||||
{
|
||||
for (String & s : CS_Custom_Vehicle_Names)
|
||||
{
|
||||
@@ -122,7 +122,7 @@ void SetAutomobileName(Uint32 id, StackStrF & name)
|
||||
Int32 GetAutomobileID(StackStrF & name)
|
||||
{
|
||||
// Clone the string into an editable version
|
||||
String str(name.mPtr, name.mLen);
|
||||
String str(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
// Strip non alphanumeric characters from the name
|
||||
str.erase(std::remove_if(str.begin(), str.end(), std::not1(std::ptr_fun(::isalnum))), str.end());
|
||||
// Convert the string to lowercase
|
||||
@@ -205,11 +205,11 @@ Int32 GetAutomobileID(StackStrF & name)
|
||||
// [Bl]oodring Banger #2
|
||||
case 'l':
|
||||
// [Bli]sta [C]ompact
|
||||
if (b == 'c' || c == 'i') return SQMOD_VEHICLE_BLISTACOMPACT;
|
||||
if (c == 'i') return SQMOD_VEHICLE_BLISTACOMPACT;
|
||||
// [Blo]odring [B]anger (#1|A)
|
||||
else if ((b == 'b' || c == 'o') && (d == '1' || d == 'a')) return SQMOD_VEHICLE_BLOODRINGBANGER1;
|
||||
else if ((c == 'o') && (d == '1' || d == 'a')) return SQMOD_VEHICLE_BLOODRINGBANGER1;
|
||||
// [Blo]odring [B]anger (#2|B)
|
||||
else if ((b == 'b' || c == 'o') && (d == '2' || d == 'b')) return SQMOD_VEHICLE_BLOODRINGBANGER2;
|
||||
else if ((c == 'o') && (d == '2' || d == 'b')) return SQMOD_VEHICLE_BLOODRINGBANGER2;
|
||||
// Default to unknwon
|
||||
else return SQMOD_UNKNOWN;
|
||||
// [Bo]bcat
|
||||
@@ -303,9 +303,9 @@ Int32 GetAutomobileID(StackStrF & name)
|
||||
// [E]nforcer
|
||||
case 'e':
|
||||
// [Es]peranto
|
||||
if (b && b == 's') return SQMOD_VEHICLE_ESPERANTO;
|
||||
if (b == 's') return SQMOD_VEHICLE_ESPERANTO;
|
||||
// [En]forcer
|
||||
else if (b && b == 'n') return SQMOD_VEHICLE_ENFORCER;
|
||||
else if (b == 'n') return SQMOD_VEHICLE_ENFORCER;
|
||||
// Default to unknwon
|
||||
else return SQMOD_UNKNOWN;
|
||||
// [F]aggio
|
||||
@@ -390,9 +390,9 @@ Int32 GetAutomobileID(StackStrF & name)
|
||||
// [I]nfernus
|
||||
case 'i':
|
||||
// [Id]aho
|
||||
if (b && b == 'd') return SQMOD_VEHICLE_IDAHO;
|
||||
if (b == 'd') return SQMOD_VEHICLE_IDAHO;
|
||||
// [In]fernus
|
||||
else if (b && b == 'n') return SQMOD_VEHICLE_INFERNUS;
|
||||
else if (b == 'n') return SQMOD_VEHICLE_INFERNUS;
|
||||
// Default to unknwon
|
||||
else return SQMOD_UNKNOWN;
|
||||
// [K]aufman Cab
|
||||
@@ -604,7 +604,7 @@ Int32 GetAutomobileID(StackStrF & name)
|
||||
// [Spa]nd [E]xpres[s]
|
||||
if (c == 'a' || ((len > 5 && str[5] == 'e') || d == 's')) return SQMOD_VEHICLE_SPANDEXPRESS;
|
||||
// [Spa]rro[w]
|
||||
else if (d == 'w' && (c == 'a' && d == 'w')) return SQMOD_VEHICLE_SPARROW;
|
||||
else if (d == 'w') return SQMOD_VEHICLE_SPARROW;
|
||||
// [Spe]ede[r]
|
||||
else if (c == 'e' || d == 'r') return SQMOD_VEHICLE_SPEEDER;
|
||||
// Default to unknwon
|
||||
@@ -695,7 +695,7 @@ bool IsAutomobileValid(Int32 id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return !GetAutomobileName(id).empty();
|
||||
return !GetAutomobileName(static_cast< Uint32 >(id)).empty();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static String CS_Weapon_Names[] = {
|
||||
static String CS_Weapon_Names[] = { // NOLINT(cert-err58-cpp)
|
||||
/* 0 */ "Unarmed", /* 1 */ "Brass Knuckles",
|
||||
/* 2 */ "Screwdriver", /* 3 */ "Golf Club",
|
||||
/* 4 */ "Nightstick", /* 5 */ "Knife",
|
||||
@@ -138,7 +138,7 @@ void SetWeaponName(Uint32 id, StackStrF & name)
|
||||
if (IsCustomWeapon(id))
|
||||
{
|
||||
// Attempt to insert or update the name into the custom weapon table
|
||||
CS_Custom_Weapon_Names[id] = String(name.mPtr, name.mLen);
|
||||
CS_Custom_Weapon_Names[id] = String(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -163,7 +163,7 @@ void ClearCustomWeaponNamePool()
|
||||
Int32 GetWeaponID(StackStrF & name)
|
||||
{
|
||||
// Clone the string into an editable version
|
||||
String str(name.mPtr, name.mLen);
|
||||
String str(name.mPtr, static_cast< size_t >(name.mLen));
|
||||
// Strip non alphanumeric characters from the name
|
||||
str.erase(std::remove_if(str.begin(), str.end(), std::not1(std::ptr_fun(::isalnum))), str.end());
|
||||
// Convert the string to lowercase
|
||||
@@ -340,7 +340,7 @@ Int32 GetWeaponID(StackStrF & name)
|
||||
// [Su]icide
|
||||
else if (b == 'u') return SQMOD_WEAPON_SUICIDE;
|
||||
// Pump action [Sh]otgun
|
||||
else if (b == 'h') return SQMOD_WEAPON_SHOTGUN;
|
||||
else if (b == 'h') return SQMOD_WEAPON_SHOTGUN;
|
||||
// Default to unknwon
|
||||
else return SQMOD_UNKNOWN;
|
||||
// [T]ear Gas
|
||||
@@ -371,7 +371,7 @@ Int32 GetWeaponID(StackStrF & name)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool IsWeaponValid(Int32 id)
|
||||
{
|
||||
CSStr name = GetWeaponName(id);
|
||||
CSStr name = GetWeaponName(static_cast< Uint32 >(id));
|
||||
return (name && *name != '\0');
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,6 @@ Uint32 GetCustomWeaponNamePoolSize();
|
||||
*/
|
||||
void ClearCustomWeaponNamePool();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Modify the name associated with a weapon identifier.
|
||||
*/
|
||||
void SetWeaponName(Uint32 id, StackStrF & name);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Convert a weapon name to a weapon identifier.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user