1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-20 17:17:13 +02:00

Discard instances of constant StackStrF parameters. This should always be non-const if possible.

This commit is contained in:
Sandu Liviu Catalin
2019-02-17 17:23:59 +02:00
parent baee2d5c33
commit 600c21d45f
68 changed files with 250 additions and 227 deletions

View File

@ -421,14 +421,14 @@ void Register_Areas(HSQUIRRELVM vm)
Class< Area >(vm, AreaTypename::Str)
// Constructors
.Ctor()
.Ctor< const StackStrF & >()
.Ctor< SQInteger, const StackStrF & >()
.Ctor< StackStrF & >()
.Ctor< SQInteger, StackStrF & >()
.Ctor< const Vector2 &, const Vector2 &, const Vector2 & >()
.Ctor< const Vector2 &, const Vector2 &, const Vector2 &, const StackStrF & >()
.Ctor< const Vector2 &, const Vector2 &, const Vector2 &, SQInteger, const StackStrF & >()
.Ctor< const Vector2 &, const Vector2 &, const Vector2 &, StackStrF & >()
.Ctor< const Vector2 &, const Vector2 &, const Vector2 &, SQInteger, StackStrF & >()
.Ctor< float, float, float, float, float, float >()
.Ctor< float, float, float, float, float, float, const StackStrF & >()
.Ctor< float, float, float, float, float, float, SQInteger, const StackStrF & >()
.Ctor< float, float, float, float, float, float, StackStrF & >()
.Ctor< float, float, float, float, float, float, SQInteger, StackStrF & >()
// Meta-methods
.SquirrelFunc(_SC("_typename"), &AreaTypename::Fn)
.Func(_SC("_tostring"), &Area::ToString)

View File

@ -74,7 +74,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Named constructor.
*/
Area(const StackStrF & name)
Area(StackStrF & name)
: Area(16, name)
{
//...
@ -82,7 +82,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
Area(SQInteger sz, const StackStrF & name)
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)
@ -97,7 +97,7 @@ struct Area
* Vector2 constructor.
*/
Area(const Vector2 & a, const Vector2 & b, const Vector2 & c)
: Area(a.x, a.y, b.x, b.y, c.x, c.y, 16, StackStrF())
: Area(a.x, a.y, b.x, b.y, c.x, c.y, 16, StackStrF::Dummy())
{
//...
}
@ -105,7 +105,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Vector2 constructor with name.
*/
Area(const Vector2 & a, const Vector2 & b, const Vector2 & c, const StackStrF & name)
Area(const Vector2 & a, const Vector2 & b, const Vector2 & c, StackStrF & name)
: Area(a.x, a.y, b.x, b.y, c.x, c.y, 16, name)
{
//...
@ -114,7 +114,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Vector2 constructor with name and memory to reserve.
*/
Area(const Vector2 & a, const Vector2 & b, const Vector2 & c, SQInteger sz, const StackStrF & name)
Area(const Vector2 & a, const Vector2 & b, const Vector2 & c, SQInteger sz, StackStrF & name)
: Area(a.x, a.y, b.x, b.y, c.x, c.y, sz, name)
{
//...
@ -124,7 +124,7 @@ struct Area
* Extended constructor.
*/
Area(float ax, float ay, float bx, float by, float cx, float cy)
: Area(ax, ay, bx, by, cx, cy, 16, StackStrF())
: Area(ax, ay, bx, by, cx, cy, 16, StackStrF::Dummy())
{
//...
}
@ -132,7 +132,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Extended constructor with name.
*/
Area(float ax, float ay, float bx, float by, float cx, float cy, const StackStrF & name)
Area(float ax, float ay, float bx, float by, float cx, float cy, StackStrF & name)
: Area(ax, ay, bx, by, cx, cy, 16, name)
{
//...
@ -141,7 +141,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
Area(float ax, float ay, float bx, float by, float cx, float cy, SQInteger sz, const StackStrF & name)
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)
{
@ -219,7 +219,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Modify the name of this area.
*/
void SetName(const StackStrF & name)
void SetName(StackStrF & name)
{
if (name.mLen <= 0)
{
@ -235,7 +235,7 @@ struct Area
/* --------------------------------------------------------------------------------------------
* Modify the name of this area. (allows chaining function calls)
*/
Area & ApplyName(const StackStrF & name)
Area & ApplyName(StackStrF & name)
{
SetName(name);
return *this;

View File

@ -108,7 +108,7 @@ CSStr GetKeyCodeName(Uint8 keycode)
}
// ------------------------------------------------------------------------------------------------
void SetKeyCodeName(Uint8 keycode, const StackStrF & name)
void SetKeyCodeName(Uint8 keycode, StackStrF & name)
{
CS_Keycode_Names[keycode].assign(name.mPtr);
}
@ -162,13 +162,13 @@ Table GetPluginInfo(Int32 plugin_id)
}
// ------------------------------------------------------------------------------------------------
Int32 FindPlugin(const StackStrF & name)
Int32 FindPlugin(StackStrF & name)
{
return _Func->FindPlugin(name.mPtr);
}
// ------------------------------------------------------------------------------------------------
void SendPluginCommand(Uint32 identifier, const StackStrF & payload)
void SendPluginCommand(Uint32 identifier, StackStrF & payload)
{
_Func->SendPluginCommand(identifier, payload.mPtr);
}
@ -180,7 +180,7 @@ const ULongInt & GetTime()
}
// ------------------------------------------------------------------------------------------------
void SendLogMessage(const StackStrF & msg)
void SendLogMessage(StackStrF & msg)
{
if (_Func->LogMessage("%s", msg.mPtr) == vcmpErrorTooLargeInput)
{
@ -276,7 +276,7 @@ CSStr GetServerName()
}
// ------------------------------------------------------------------------------------------------
void SetServerName(const StackStrF & name)
void SetServerName(StackStrF & name)
{
_Func->SetServerName(name.mPtr);
}
@ -303,7 +303,7 @@ CSStr GetServerPassword()
}
// ------------------------------------------------------------------------------------------------
void SetServerPassword(const StackStrF & passwd)
void SetServerPassword(StackStrF & passwd)
{
_Func->SetServerPassword(passwd.mPtr);
}
@ -330,13 +330,13 @@ CSStr GetGameModeText()
}
// ------------------------------------------------------------------------------------------------
void SetGameModeText(const StackStrF & text)
void SetGameModeText(StackStrF & text)
{
_Func->SetGameModeText(text.mPtr);
}
// ------------------------------------------------------------------------------------------------
void CreateRadioStream(bool listed, const StackStrF & name, const StackStrF & url)
void CreateRadioStream(bool listed, StackStrF & name, StackStrF & url)
{
if (_Func->AddRadioStream(-1, name.mPtr, url.mPtr, listed) == vcmpErrorArgumentOutOfBounds)
{
@ -345,7 +345,7 @@ void CreateRadioStream(bool listed, const StackStrF & name, const StackStrF & ur
}
// ------------------------------------------------------------------------------------------------
void CreateRadioStreamEx(Int32 id, bool listed, const StackStrF & name, const StackStrF & url)
void CreateRadioStreamEx(Int32 id, bool listed, StackStrF & name, StackStrF & url)
{
if (_Func->AddRadioStream(id, name.mPtr, url.mPtr, listed) == vcmpErrorArgumentOutOfBounds)
{
@ -774,25 +774,25 @@ void SetSpawnCameraLookAtEx(Float32 x, Float32 y, Float32 z)
}
// ------------------------------------------------------------------------------------------------
void BanIP(const StackStrF & addr)
void BanIP(StackStrF & addr)
{
_Func->BanIP(const_cast< SStr >(addr.mPtr));
}
// ------------------------------------------------------------------------------------------------
bool UnbanIP(const StackStrF & addr)
bool UnbanIP(StackStrF & addr)
{
return _Func->UnbanIP(const_cast< SStr >(addr.mPtr));
}
// ------------------------------------------------------------------------------------------------
bool IsIPBanned(const StackStrF & addr)
bool IsIPBanned(StackStrF & addr)
{
return _Func->IsIPBanned(const_cast< SStr >(addr.mPtr));
}
// ------------------------------------------------------------------------------------------------
Int32 GetPlayerIdFromName(const StackStrF & name)
Int32 GetPlayerIdFromName(StackStrF & name)
{
return _Func->GetPlayerIdFromName(name.mPtr);
}

View File

@ -15,7 +15,7 @@ CSStr GetKeyCodeName(Uint8 keycode);
/* ------------------------------------------------------------------------------------------------
* Modify the name of a certain key-code.
*/
void SetKeyCodeName(Uint8 keycode, const StackStrF & name);
void SetKeyCodeName(Uint8 keycode, StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* Retrieve the server version.
@ -40,12 +40,12 @@ Table GetPluginInfo(Int32 plugin_id);
/* ------------------------------------------------------------------------------------------------
* Attempt to find a plug-in identifier by it's name.
*/
Int32 FindPlugin(const StackStrF & name);
Int32 FindPlugin(StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* Send a custom command to the loaded plug-ins.
*/
void SendPluginCommand(Uint32 identifier, const StackStrF & payload);
void SendPluginCommand(Uint32 identifier, StackStrF & payload);
/* ------------------------------------------------------------------------------------------------
* Retrieve the server time.
@ -55,7 +55,7 @@ const ULongInt & GetTime();
/* ------------------------------------------------------------------------------------------------
* Send a log message to the server.
*/
void SendLogMessage(const StackStrF & msg);
void SendLogMessage(StackStrF & msg);
/* ------------------------------------------------------------------------------------------------
* Retrieve the last error that occurred on the server.
@ -115,7 +115,7 @@ CSStr GetServerName();
/* ------------------------------------------------------------------------------------------------
* Modify the server name.
*/
void SetServerName(const StackStrF & name);
void SetServerName(StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* Retrieve the server password.
@ -125,7 +125,7 @@ CSStr GetServerPassword();
/* ------------------------------------------------------------------------------------------------
* Modify the server password.
*/
void SetServerPassword(const StackStrF & passwd);
void SetServerPassword(StackStrF & passwd);
/* ------------------------------------------------------------------------------------------------
* Retrieve the game-mode text.
@ -135,17 +135,17 @@ CSStr GetGameModeText();
/* ------------------------------------------------------------------------------------------------
* Modify the game-mode text.
*/
void SetGameModeText(const StackStrF & text);
void SetGameModeText(StackStrF & text);
/* ------------------------------------------------------------------------------------------------
* Create a radio stream.
*/
void CreateRadioStream(bool listed, const StackStrF & name, const StackStrF & url);
void CreateRadioStream(bool listed, StackStrF & name, StackStrF & url);
/* ------------------------------------------------------------------------------------------------
* Create a radio stream.
*/
void CreateRadioStreamEx(Int32 id, bool listed, const StackStrF & name, const StackStrF & url);
void CreateRadioStreamEx(Int32 id, bool listed, StackStrF & name, StackStrF & url);
/* ------------------------------------------------------------------------------------------------
* Remove a radio stream.
@ -427,22 +427,22 @@ void SetSpawnCameraLookAtEx(Float32 x, Float32 y, Float32 z);
/* ------------------------------------------------------------------------------------------------
* Ban an IP address from the server.
*/
void BanIP(const StackStrF & addr);
void BanIP(StackStrF & addr);
/* ------------------------------------------------------------------------------------------------
* Unban an IP address from the server.
*/
bool UnbanIP(const StackStrF & addr);
bool UnbanIP(StackStrF & addr);
/* ------------------------------------------------------------------------------------------------
* See if an IP address is banned from the server.
*/
bool IsIPBanned(const StackStrF & addr);
bool IsIPBanned(StackStrF & addr);
/* ------------------------------------------------------------------------------------------------
* Retrieve the identifier of the player with the specified name.
*/
Int32 GetPlayerIdFromName(const StackStrF & name);
Int32 GetPlayerIdFromName(StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* See if a player with the specified identifier is connected.

View File

@ -16,7 +16,7 @@ CSStr GetModelName(Int32 /*id*/)
}
// ------------------------------------------------------------------------------------------------
void SetModelName(Int32 /*id*/, const StackStrF & /*name*/)
void SetModelName(Int32 /*id*/, StackStrF & /*name*/)
{
// @TODO Implement...
}

View File

@ -15,7 +15,7 @@ CSStr GetModelName(Int32 id);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a model identifier.
*/
void SetModelName(Int32 id, const StackStrF & name);
void SetModelName(Int32 id, StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* See whether the given model identifier is used a weapon model.

View File

@ -102,7 +102,7 @@ CCStr GetSkinName(Uint32 id)
}
// ------------------------------------------------------------------------------------------------
void SetSkinName(Uint32 id, const StackStrF & name)
void SetSkinName(Uint32 id, StackStrF & name)
{
if (id <= 159)
{
@ -111,7 +111,7 @@ void SetSkinName(Uint32 id, const StackStrF & name)
}
// ------------------------------------------------------------------------------------------------
Int32 GetSkinID(const StackStrF & name)
Int32 GetSkinID(StackStrF & name)
{
// Clone the string into an editable version
String str(name.mPtr, name.mLen);

View File

@ -15,12 +15,12 @@ CCStr GetSkinName(Uint32 id);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a skin model identifier.
*/
void SetSkinName(Uint32 id, const StackStrF & name);
void SetSkinName(Uint32 id, StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* Convert a vehicle model name to a skin model identifier.
*/
Int32 GetSkinID(const StackStrF & name);
Int32 GetSkinID(StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* See whether the specified skin model identifier is valid.

View File

@ -232,7 +232,7 @@ SQInteger Routine::Create(HSQUIRRELVM vm)
}
// ------------------------------------------------------------------------------------------------
bool Routine::IsWithTag(const StackStrF & tag)
bool Routine::IsWithTag(StackStrF & tag)
{
// Is the specified tag valid?
if (tag.mPtr != nullptr)

View File

@ -285,7 +285,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve the number of used routine slots.
*/
static const LightObj & FindByTag(const StackStrF & tag)
static const LightObj & FindByTag(StackStrF & tag)
{
// Is the specified tag valid?
if (!tag.mPtr)
@ -308,7 +308,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Check if a routine with a certain tag exists.
*/
static bool IsWithTag(const StackStrF & tag);
static bool IsWithTag(StackStrF & tag);
/* --------------------------------------------------------------------------------------------
* Process all active routines and update elapsed time.
*/
@ -384,7 +384,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(const StackStrF & tag)
void SetTag(StackStrF & tag)
{
GetValid().mTag.assign(tag.mPtr, ClampMin(tag.mLen, 0));
}

View File

@ -1528,7 +1528,7 @@ LightObj Signal::CreateFree()
}
// ------------------------------------------------------------------------------------------------
LightObj Signal::Create(const StackStrF & name)
LightObj Signal::Create(StackStrF & name)
{
// Validate the signal name
if (name.mLen <= 0)
@ -1564,7 +1564,7 @@ LightObj Signal::Create(const StackStrF & name)
}
// ------------------------------------------------------------------------------------------------
void Signal::Remove(const StackStrF & name)
void Signal::Remove(StackStrF & name)
{
// Validate the signal name
if (name.mLen <= 0)
@ -1598,7 +1598,7 @@ void Signal::Remove(const StackStrF & name)
}
// ------------------------------------------------------------------------------------------------
const LightObj & Signal::Fetch(const StackStrF & name)
const LightObj & Signal::Fetch(StackStrF & name)
{
// Validate the signal name
if (name.mLen <= 0)

View File

@ -706,17 +706,17 @@ public:
/* --------------------------------------------------------------------------------------------
* Create a new signal with the specified name.
*/
static LightObj Create(const StackStrF & name);
static LightObj Create(StackStrF & name);
/* --------------------------------------------------------------------------------------------
* Remove the signal with the specified name.
*/
static void Remove(const StackStrF & name);
static void Remove(StackStrF & name);
/* --------------------------------------------------------------------------------------------
* Retrieve the signal with the specified name.
*/
static const LightObj & Fetch(const StackStrF & name);
static const LightObj & Fetch(StackStrF & name);
/* --------------------------------------------------------------------------------------------
* Emit a signal from the module.

View File

@ -451,7 +451,7 @@ SQInteger Tasks::Exists(Int32 id, Int32 type, HSQUIRRELVM vm)
}
// ------------------------------------------------------------------------------------------------
const Tasks::Task & Tasks::FindByTag(Int32 id, Int32 type, const StackStrF & tag)
const Tasks::Task & Tasks::FindByTag(Int32 id, Int32 type, StackStrF & tag)
{
// Attempt to find the requested task
for (const auto & t : s_Tasks)

View File

@ -148,7 +148,7 @@ private:
/* ----------------------------------------------------------------------------------------
* Modify the associated user tag.
*/
void SetTag(const StackStrF & tag)
void SetTag(StackStrF & tag)
{
mTag.assign(tag.mPtr, ClampMin(tag.mLen, 0));
}
@ -358,7 +358,7 @@ protected:
/* --------------------------------------------------------------------------------------------
* Cleanup all tasks associated with the specified entity.
*/
static const Task & FindByTag(Int32 id, Int32 type, const StackStrF & tag);
static const Task & FindByTag(Int32 id, Int32 type, StackStrF & tag);
public:

View File

@ -102,7 +102,7 @@ String GetAutomobileName(Uint32 id)
}
// ------------------------------------------------------------------------------------------------
void SetAutomobileName(Uint32 id, const StackStrF & name)
void SetAutomobileName(Uint32 id, StackStrF & name)
{
if (id > 129 && id < 237)
{
@ -119,7 +119,7 @@ void SetAutomobileName(Uint32 id, const StackStrF & name)
}
// ------------------------------------------------------------------------------------------------
Int32 GetAutomobileID(const StackStrF & name)
Int32 GetAutomobileID(StackStrF & name)
{
// Clone the string into an editable version
String str(name.mPtr, name.mLen);

View File

@ -15,12 +15,12 @@ String GetAutomobileName(Uint32 id);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a vehicle model identifier.
*/
void SetAutomobileName(Uint32 id, const StackStrF & name);
void SetAutomobileName(Uint32 id, StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* Convert a vehicle model name to a vehicle model identifier.
*/
Int32 GetAutomobileID(const StackStrF & name);
Int32 GetAutomobileID(StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* See whether the specified vehicle model identifier is valid.

View File

@ -81,7 +81,7 @@ CCStr GetWeaponName(Uint32 id)
}
// ------------------------------------------------------------------------------------------------
void SetWeaponName(Uint32 id, const StackStrF & name)
void SetWeaponName(Uint32 id, StackStrF & name)
{
// Can we consider this a custom weapon ID?
if (IsCustomWeapon(id))
@ -109,7 +109,7 @@ void ClearCustomWeaponNamePool()
}
// ------------------------------------------------------------------------------------------------
Int32 GetWeaponID(const StackStrF & name)
Int32 GetWeaponID(StackStrF & name)
{
// Clone the string into an editable version
String str(name.mPtr, name.mLen);

View File

@ -15,7 +15,7 @@ CSStr GetWeaponName(Uint32 id);
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a weapon identifier.
*/
void SetWeaponName(Uint32 id, const StackStrF & name);
void SetWeaponName(Uint32 id, StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* Retrieve the total number of identifiers in the pool of custom weapon names.
@ -30,12 +30,12 @@ void ClearCustomWeaponNamePool();
/* ------------------------------------------------------------------------------------------------
* Modify the name associated with a weapon identifier.
*/
void SetWeaponName(Uint32 id, const StackStrF & name);
void SetWeaponName(Uint32 id, StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* Convert a weapon name to a weapon identifier.
*/
Int32 GetWeaponID(const StackStrF & name);
Int32 GetWeaponID(StackStrF & name);
/* ------------------------------------------------------------------------------------------------
* See whether the specified weapon identifier is valid.