mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-31 18:07:14 +01:00
Allow the user to store names of custom vehicles up to a certain point.
This commit is contained in:
parent
957ba97a33
commit
135e0e690f
@ -68,17 +68,41 @@ static String CS_Vehicle_Names[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
CSStr GetAutomobileName(Uint32 id)
|
static String CS_Custom_Vehicle_Names[100]{};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
String GetAutomobileName(Uint32 id)
|
||||||
{
|
{
|
||||||
return (id < 130 || id > 236) ? _SC("") : CS_Vehicle_Names[id-130].c_str();
|
if (id > 129 && id < 237)
|
||||||
|
{
|
||||||
|
return CS_Vehicle_Names[id-130];
|
||||||
|
}
|
||||||
|
else if (id > 6399 && id < 6500)
|
||||||
|
{
|
||||||
|
return CS_Custom_Vehicle_Names[id-6400];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STHROWF("Vehicle identifier breaks these demands (%u > 129 and %u < 237) or (%u > 6399 and %u < 6500)", id, id, id, id);
|
||||||
|
}
|
||||||
|
// Should never reach this point
|
||||||
|
return NullString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SetAutomobileName(Uint32 id, const StackStrF & name)
|
void SetAutomobileName(Uint32 id, const StackStrF & name)
|
||||||
{
|
{
|
||||||
if (id >= 130 || id <= 236)
|
if (id > 129 && id < 237)
|
||||||
{
|
{
|
||||||
CS_Vehicle_Names[id-130].assign(name.mPtr);
|
CS_Vehicle_Names[id-130].assign(name.mPtr, ConvTo< size_t >::From(name.mLen));
|
||||||
|
}
|
||||||
|
else if (id > 6399 && id < 6500)
|
||||||
|
{
|
||||||
|
CS_Custom_Vehicle_Names[id-6400].assign(name.mPtr, ConvTo< size_t >::From(name.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
STHROWF("Vehicle identifier breaks these demands (%u > 129 and %u < 237) or (%u > 6399 and %u < 6500)", id, id, id, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,8 +681,16 @@ Int32 GetAutomobileID(const StackStrF & name)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool IsAutomobileValid(Int32 id)
|
bool IsAutomobileValid(Int32 id)
|
||||||
{
|
{
|
||||||
CSStr name = GetAutomobileName(id);
|
try
|
||||||
return (name && *name != '\0');
|
{
|
||||||
|
return !GetAutomobileName(id).empty();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
//... Ignore it
|
||||||
|
}
|
||||||
|
// If we reached here then no!
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -10,7 +10,7 @@ namespace SqMod {
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the name associated with a vehicle model identifier.
|
* Retrieve the name associated with a vehicle model identifier.
|
||||||
*/
|
*/
|
||||||
CSStr GetAutomobileName(Uint32 id);
|
String GetAutomobileName(Uint32 id);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Modify the name associated with a vehicle model identifier.
|
* Modify the name associated with a vehicle model identifier.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user