mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Adjust the Sphere type functions to use the new method of receiving formatted strings.
This commit is contained in:
parent
6522889492
commit
759318d48e
@ -409,9 +409,9 @@ void Sphere::SetPositionEx(Value nx, Value ny, Value nz)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Sphere::SetStr(CSStr values, SQChar delim)
|
||||
void Sphere::SetStr(SQChar delim, const StackStrF & values)
|
||||
{
|
||||
SetSphere(Sphere::Get(values, delim));
|
||||
SetSphere(Sphere::GetEx(delim, values));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@ -468,13 +468,13 @@ Sphere Sphere::Abs() const
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Sphere & Sphere::Get(CSStr str)
|
||||
const Sphere & Sphere::Get(const StackStrF & str)
|
||||
{
|
||||
return Sphere::Get(str, Sphere::Delim);
|
||||
return Sphere::GetEx(Sphere::Delim, str);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Sphere & Sphere::Get(CSStr str, SQChar delim)
|
||||
const Sphere & Sphere::GetEx(SQChar delim, const StackStrF & str)
|
||||
{
|
||||
// The format specifications that will be used to scan the string
|
||||
static SQChar fs[] = _SC(" %f , %f , %f , %f ");
|
||||
@ -482,7 +482,7 @@ const Sphere & Sphere::Get(CSStr str, SQChar delim)
|
||||
// Clear previous values, if any
|
||||
sphere.Clear();
|
||||
// Is the specified string empty?
|
||||
if (!str || *str == '\0')
|
||||
if (str.mLen <= 0)
|
||||
{
|
||||
return sphere; // Return the value as is!
|
||||
}
|
||||
@ -491,7 +491,7 @@ const Sphere & Sphere::Get(CSStr str, SQChar delim)
|
||||
fs[9] = delim;
|
||||
fs[14] = delim;
|
||||
// Attempt to extract the component values from the specified string
|
||||
std::sscanf(str, fs, &sphere.pos.x, &sphere.pos.y, &sphere.pos.z, &sphere.rad);
|
||||
std::sscanf(str.mPtr, fs, &sphere.pos.x, &sphere.pos.y, &sphere.pos.z, &sphere.rad);
|
||||
// Return the resulted value
|
||||
return sphere;
|
||||
}
|
||||
@ -573,19 +573,18 @@ void Register_Sphere(HSQUIRRELVM vm)
|
||||
.Func(_SC("SetValues"), &Sphere::SetValues)
|
||||
.Func(_SC("SetPosition"), &Sphere::SetPosition)
|
||||
.Func(_SC("SetPositionEx"), &Sphere::SetPositionEx)
|
||||
.Func(_SC("SetStr"), &Sphere::SetStr)
|
||||
.FmtFunc(_SC("SetStr"), &Sphere::SetStr)
|
||||
.Func(_SC("Clear"), &Sphere::Clear)
|
||||
// Member Overloads
|
||||
.Overload< void (Sphere::*)(void) >(_SC("Generate"), &Sphere::Generate)
|
||||
.Overload< void (Sphere::*)(Val, Val, bool) >(_SC("Generate"), &Sphere::Generate)
|
||||
.Overload< void (Sphere::*)(Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Sphere::Generate)
|
||||
.Overload< void (Sphere::*)(Val, Val, Val, Val, Val, Val, Val, Val) >(_SC("Generate"), &Sphere::Generate)
|
||||
// Static Overloads
|
||||
.StaticOverload< const Sphere & (*)(CSStr) >(_SC("FromStr"), &Sphere::Get)
|
||||
.StaticOverload< const Sphere & (*)(CSStr, SQChar) >(_SC("FromStr"), &Sphere::Get)
|
||||
// Static Functions
|
||||
.StaticFunc(_SC("GetDelimiter"), &SqGetDelimiter< Sphere >)
|
||||
.StaticFunc(_SC("SetDelimiter"), &SqSetDelimiter< Sphere >)
|
||||
.StaticFmtFunc(_SC("FromStr"), &Sphere::Get)
|
||||
.StaticFmtFunc(_SC("FromStrEx"), &Sphere::GetEx)
|
||||
// Operator Exposure
|
||||
.Func< Sphere & (Sphere::*)(const Sphere &) >(_SC("opAddAssign"), &Sphere::operator +=)
|
||||
.Func< Sphere & (Sphere::*)(const Sphere &) >(_SC("opSubAssign"), &Sphere::operator -=)
|
||||
|
@ -376,7 +376,7 @@ struct Sphere
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set the values extracted from the specified string using the specified delimiter.
|
||||
*/
|
||||
void SetStr(CSStr values, SQChar delim);
|
||||
void SetStr(SQChar delim, const StackStrF & values);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Generate a randomly sized and positioned sphere.
|
||||
@ -414,13 +414,12 @@ struct Sphere
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Sphere type from a string.
|
||||
*/
|
||||
static const Sphere & Get(CSStr str);
|
||||
static const Sphere & Get(const StackStrF & str);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Extract the values for components of the Sphere type from a string.
|
||||
*/
|
||||
static const Sphere & Get(CSStr str, SQChar delim);
|
||||
|
||||
static const Sphere & GetEx(SQChar delim, const StackStrF & str);
|
||||
};
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
Loading…
Reference in New Issue
Block a user