1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-15 22:57:12 +02:00

Updated the exception system in the main plugin to also include the location in the source files in debug builds.

Moved the functions that extract base types from strings as static functions under the associated type.
Revised some of the base shared code.
Fixed some of the functions in the String library that did not take into account the null terminator.
This commit is contained in:
Sandu Liviu Catalin
2016-03-21 22:37:58 +02:00
parent e3315430ea
commit 8088ba94c2
50 changed files with 648 additions and 493 deletions

View File

@ -280,7 +280,7 @@ static const Object & Blip_FindByID(Int32 id)
{
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_BLIP_POOL))
SqThrowF("The specified blip identifier is invalid: %d", id);
STHROWF("The specified blip identifier is invalid: %d", id);
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
Core::Blips::const_iterator end = _Core->GetBlips().cend();
@ -302,7 +302,7 @@ static const Object & Blip_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified blip tag is invalid: null/empty");
STHROWF("The specified blip tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();
@ -326,7 +326,7 @@ static const Object & Blip_FindBySprID(Int32 sprid)
// Perform a range check on the specified identifier
if (sprid < 0)
{
SqThrowF("The specified sprite identifier is invalid: %d", sprid);
STHROWF("The specified sprite identifier is invalid: %d", sprid);
}
// Obtain the ends of the entity pool
Core::Blips::const_iterator itr = _Core->GetBlips().cbegin();

View File

@ -76,7 +76,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid blip reference [%s]", m_Tag.c_str());
STHROWF("Invalid blip reference [%s]", m_Tag.c_str());
}
}

View File

@ -124,7 +124,7 @@ bool CCheckpoint::IsStreamedFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -455,7 +455,7 @@ static const Object & Checkpoint_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_CHECKPOINT_POOL))
{
SqThrowF("The specified checkpoint identifier is invalid: %d", id);
STHROWF("The specified checkpoint identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();
@ -478,7 +478,7 @@ static const Object & Checkpoint_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified checkpoint tag is invalid: null/empty");
STHROWF("The specified checkpoint tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Checkpoints::const_iterator itr = _Core->GetCheckpoints().cbegin();

View File

@ -83,7 +83,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid checkpoint reference [%s]", m_Tag.c_str());
STHROWF("Invalid checkpoint reference [%s]", m_Tag.c_str());
}
}

View File

@ -123,7 +123,7 @@ bool CForcefield::IsStreamedFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -429,7 +429,7 @@ static const Object & Forcefield_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_FORCEFIELD_POOL))
{
SqThrowF("The specified forcefield identifier is invalid: %d", id);
STHROWF("The specified forcefield identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();
@ -452,7 +452,7 @@ static const Object & Forcefield_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified forcefield tag is invalid: null/empty");
STHROWF("The specified forcefield tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Forcefields::const_iterator itr = _Core->GetForcefields().cbegin();

View File

@ -83,7 +83,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid forcefield reference [%s]", m_Tag.c_str());
STHROWF("Invalid forcefield reference [%s]", m_Tag.c_str());
}
}

View File

@ -174,7 +174,7 @@ static const Object & Keybind_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_KEYBIND_POOL))
{
SqThrowF("The specified keybind identifier is invalid: %d", id);
STHROWF("The specified keybind identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();
@ -197,7 +197,7 @@ static const Object & Keybind_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified keybind tag is invalid: null/empty");
STHROWF("The specified keybind tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Keybinds::const_iterator itr = _Core->GetKeybinds().cbegin();

View File

@ -76,7 +76,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid keybind reference [%s]", m_Tag.c_str());
STHROWF("Invalid keybind reference [%s]", m_Tag.c_str());
}
}

View File

@ -118,7 +118,7 @@ bool CObject::IsStreamedFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -576,7 +576,7 @@ static const Object & Object_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
{
SqThrowF("The specified object identifier is invalid: %d", id);
STHROWF("The specified object identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
@ -598,7 +598,7 @@ static const Object & Object_FindByTag(CSStr tag)
{
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
SqThrowF("The specified object tag is invalid: null/empty");
STHROWF("The specified object tag is invalid: null/empty");
// Obtain the ends of the entity pool
Core::Objects::const_iterator itr = _Core->GetObjects().cbegin();
Core::Objects::const_iterator end = _Core->GetObjects().cend();

View File

@ -80,7 +80,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid object reference [%s]", m_Tag.c_str());
STHROWF("Invalid object reference [%s]", m_Tag.c_str());
}
}

View File

@ -116,7 +116,7 @@ bool CPickup::IsStreamedFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -362,7 +362,7 @@ static const Object & Pickup_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_PICKUP_POOL))
{
SqThrowF("The specified pickup identifier is invalid: %d", id);
STHROWF("The specified pickup identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();
@ -385,7 +385,7 @@ static const Object & Pickup_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '0')
{
SqThrowF("The specified pickup tag is invalid: null/empty");
STHROWF("The specified pickup tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Pickups::const_iterator itr = _Core->GetPickups().cbegin();

View File

@ -79,7 +79,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid pickup reference [%s]", m_Tag.c_str());
STHROWF("Invalid pickup reference [%s]", m_Tag.c_str());
}
}

View File

@ -114,7 +114,7 @@ bool CPlayer::IsStreamedFor(CPlayer & player) const
{
// Is the specified player even valid?
if (!player.IsActive())
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
// Validate the managed identifier
Validate();
// Return the requested information
@ -997,7 +997,7 @@ void CPlayer::SetSpectator(CPlayer & target) const
// Is the specified player even valid?
if (!target.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -1082,7 +1082,7 @@ void CPlayer::Embark(CVehicle & vehicle) const
// Is the specified vehicle even valid?
if (!vehicle.IsActive())
{
SqThrowF("Invalid vehicle argument: null");
STHROWF("Invalid vehicle argument: null");
}
// Validate the managed identifier
Validate();
@ -1096,7 +1096,7 @@ void CPlayer::Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) c
// Is the specified vehicle even valid?
if (!vehicle.IsActive())
{
SqThrowF("Invalid vehicle argument: null");
STHROWF("Invalid vehicle argument: null");
}
// Validate the managed identifier
Validate();
@ -1146,7 +1146,7 @@ CSStr CPlayer::GetMessagePrefix(Uint32 index) const
// Perform a range check on the specified prefix index
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
{
SqThrowF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
STHROWF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
}
// Validate the managed identifier
Validate();
@ -1160,7 +1160,7 @@ void CPlayer::SetMessagePrefix(Uint32 index, CSStr prefix) const
// Perform a range check on the specified prefix index
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
{
SqThrowF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
STHROWF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
}
// Validate the managed identifier
Validate();
@ -1704,7 +1704,7 @@ static const Object & Player_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
{
SqThrowF("The specified player identifier is invalid: %d", id);
STHROWF("The specified player identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();
@ -1727,7 +1727,7 @@ static const Object & Player_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified player tag is invalid: null/empty");
STHROWF("The specified player tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Players::const_iterator itr = _Core->GetPlayers().cbegin();

View File

@ -83,7 +83,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid player reference [%s]", m_Tag.c_str());
STHROWF("Invalid player reference [%s]", m_Tag.c_str());
}
}

View File

@ -122,7 +122,7 @@ void CSprite::ShowFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -137,7 +137,7 @@ void CSprite::ShowRange(Int32 first, Int32 last) const
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -168,7 +168,7 @@ void CSprite::HideFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -182,7 +182,7 @@ void CSprite::HideRange(Int32 first, Int32 last) const
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -222,7 +222,7 @@ void CSprite::SetPositionFor(CPlayer & player, const Vector2i & pos) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -236,7 +236,7 @@ void CSprite::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -250,7 +250,7 @@ void CSprite::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) co
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -290,7 +290,7 @@ void CSprite::SetCenterFor(CPlayer & player, const Vector2i & pos) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -304,7 +304,7 @@ void CSprite::SetCenterForEx(CPlayer & player, Int32 x, Int32 y) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -318,7 +318,7 @@ void CSprite::SetCenterRange(Int32 first, Int32 last, const Vector2i & pos) cons
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -349,7 +349,7 @@ void CSprite::SetRotationFor(CPlayer & player, Float32 rot) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -363,7 +363,7 @@ void CSprite::SetRotationRange(Int32 first, Int32 last, Float32 rot) const
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -394,7 +394,7 @@ void CSprite::SetAlphaFor(CPlayer & player, Uint8 alpha) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -408,7 +408,7 @@ void CSprite::SetAlphaRange(Int32 first, Int32 last, Uint8 alpha) const
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -499,7 +499,7 @@ static const Object & Sprite_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_SPRITE_POOL))
{
SqThrowF("The specified sprite identifier is invalid: %d", id);
STHROWF("The specified sprite identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();
@ -522,7 +522,7 @@ static const Object & Sprite_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified sprite tag is invalid: null/empty");
STHROWF("The specified sprite tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Sprites::const_iterator itr = _Core->GetSprites().cbegin();

View File

@ -76,7 +76,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid sprite reference [%s]", m_Tag.c_str());
STHROWF("Invalid sprite reference [%s]", m_Tag.c_str());
}
}

View File

@ -122,7 +122,7 @@ void CTextdraw::ShowFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -136,7 +136,7 @@ void CTextdraw::ShowRange(Int32 first, Int32 last) const
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -167,7 +167,7 @@ void CTextdraw::HideFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -181,7 +181,7 @@ void CTextdraw::HideRange(Int32 first, Int32 last) const
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -221,7 +221,7 @@ void CTextdraw::SetPositionFor(CPlayer & player, const Vector2i & pos) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -235,7 +235,7 @@ void CTextdraw::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -249,7 +249,7 @@ void CTextdraw::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos)
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -289,7 +289,7 @@ void CTextdraw::SetColorFor(CPlayer & player, const Color4 & col) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -303,7 +303,7 @@ void CTextdraw::SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -317,7 +317,7 @@ void CTextdraw::SetColorRange(Int32 first, Int32 last, const Color4 & col) const
// Validate the specified range
if (first > last)
{
SqThrowF("Invalid player range: %d > %d", first, last);
STHROWF("Invalid player range: %d > %d", first, last);
}
// Validate the managed identifier
Validate();
@ -412,7 +412,7 @@ static const Object & Textdraw_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_TEXTDRAW_POOL))
{
SqThrowF("The specified textdraw identifier is invalid: %d", id);
STHROWF("The specified textdraw identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
@ -435,7 +435,7 @@ static const Object & Textdraw_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified textdraw tag is invalid: null/empty");
STHROWF("The specified textdraw tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();

View File

@ -76,7 +76,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid textdraw reference [%s]", m_Tag.c_str());
STHROWF("Invalid textdraw reference [%s]", m_Tag.c_str());
}
}

View File

@ -119,7 +119,7 @@ bool CVehicle::IsStreamedFor(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -936,7 +936,7 @@ void CVehicle::Embark(CPlayer & player) const
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -950,7 +950,7 @@ void CVehicle::Embark(CPlayer & player, Int32 slot, bool allocate, bool warp) co
// Is the specified player even valid?
if (!player.IsActive())
{
SqThrowF("Invalid player argument: null");
STHROWF("Invalid player argument: null");
}
// Validate the managed identifier
Validate();
@ -1235,7 +1235,7 @@ static const Object & Vehicle_FindByID(Int32 id)
// Perform a range check on the specified identifier
if (INVALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
{
SqThrowF("The specified vehicle identifier is invalid: %d", id);
STHROWF("The specified vehicle identifier is invalid: %d", id);
}
// Obtain the ends of the entity pool
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();
@ -1258,7 +1258,7 @@ static const Object & Vehicle_FindByTag(CSStr tag)
// Perform a validity check on the specified tag
if (!tag || *tag == '\0')
{
SqThrowF("The specified vehicle tag is invalid: null/empty");
STHROWF("The specified vehicle tag is invalid: null/empty");
}
// Obtain the ends of the entity pool
Core::Vehicles::const_iterator itr = _Core->GetVehicles().cbegin();

View File

@ -81,7 +81,7 @@ public:
{
if (INVALID_ENTITY(m_ID))
{
SqThrowF("Invalid vehicle reference [%s]", m_Tag.c_str());
STHROWF("Invalid vehicle reference [%s]", m_Tag.c_str());
}
}