Initial import of Red Planet v4.10 Win32 source
Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
#include "munga.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "scalar.h"
|
||||
|
||||
int Round(Scalar value)
|
||||
{
|
||||
int whole_part = floor(value);
|
||||
Scalar fractional_part = value - whole_part;
|
||||
if (fractional_part >= 0.5)
|
||||
return whole_part + 1;
|
||||
else
|
||||
return whole_part;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Find_Roots(Scalar a, Scalar b, Scalar c, Scalar *center, Scalar *range)
|
||||
{// a*x*x + b*x + c = 0
|
||||
|
||||
// See if the quadratic is solvable
|
||||
*range = b*b - 4.0f*a*c;
|
||||
if (*range < 0.0f || Small_Enough(a))
|
||||
{
|
||||
*range = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Solve the single root case
|
||||
a *= 2.0f;
|
||||
*center = -b / a;
|
||||
if (*range < SMALL)
|
||||
*range = 0.0f;
|
||||
|
||||
// Find the two-root extents
|
||||
else
|
||||
{
|
||||
*range = Sqrt(*range);
|
||||
*range /= a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Verify_Arguments(const char *str, void *value)
|
||||
{
|
||||
if (str == NULL)
|
||||
Fail("Convert_From_Ascii - str == NULL");
|
||||
if (value == NULL)
|
||||
Fail("Convert_From_Ascii - value == NULL");
|
||||
if (isalpha(*str))
|
||||
{
|
||||
std::cout << "Convert_From_Ascii - str == " << str << "\n";
|
||||
Fail("Convert_From_Ascii - isalpha(*str)");
|
||||
}
|
||||
}
|
||||
|
||||
void Convert_From_Ascii(const char *str, char *value)
|
||||
{
|
||||
#if 0
|
||||
Check_Pointer(str);
|
||||
Check_Pointer(value);
|
||||
if (isalpha(*str))
|
||||
{
|
||||
Dump(str);
|
||||
}
|
||||
Verify(!isalpha(*str));
|
||||
#else
|
||||
Verify_Arguments(str, value);
|
||||
#endif
|
||||
*value = (char)atoi(str);
|
||||
}
|
||||
|
||||
void Convert_From_Ascii(const char *str, unsigned char *value)
|
||||
{
|
||||
#if 0
|
||||
Check_Pointer(str);
|
||||
Check_Pointer(value);
|
||||
if (isalpha(*str))
|
||||
{
|
||||
Dump(str);
|
||||
}
|
||||
Verify(!isalpha(*str));
|
||||
#else
|
||||
Verify_Arguments(str, value);
|
||||
#endif
|
||||
*value = (unsigned char)atoi(str);
|
||||
}
|
||||
|
||||
void Convert_From_Ascii(const char *str, int *value)
|
||||
{
|
||||
#if 0
|
||||
Check_Pointer(str);
|
||||
Check_Pointer(value);
|
||||
if (isalpha(*str))
|
||||
{
|
||||
Dump(str);
|
||||
}
|
||||
Verify(!isalpha(*str));
|
||||
#else
|
||||
Verify_Arguments(str, value);
|
||||
#endif
|
||||
*value = atoi(str);
|
||||
}
|
||||
|
||||
void Convert_From_Ascii(const char *str, unsigned int *value)
|
||||
{
|
||||
#if 0
|
||||
Check_Pointer(str);
|
||||
Check_Pointer(value);
|
||||
if (isalpha(*str))
|
||||
{
|
||||
Dump(str);
|
||||
}
|
||||
Verify(!isalpha(*str));
|
||||
#else
|
||||
Verify_Arguments(str, value);
|
||||
#endif
|
||||
*value = atoi(str);
|
||||
}
|
||||
|
||||
void Convert_From_Ascii(const char *str, long *value)
|
||||
{
|
||||
#if 0
|
||||
Check_Pointer(str);
|
||||
Check_Pointer(value);
|
||||
if (isalpha(*str))
|
||||
{
|
||||
Dump(str);
|
||||
}
|
||||
Verify(!isalpha(*str));
|
||||
#else
|
||||
Verify_Arguments(str, value);
|
||||
#endif
|
||||
*value = atol(str);
|
||||
}
|
||||
|
||||
void Convert_From_Ascii(const char *str, unsigned long *value)
|
||||
{
|
||||
#if 0
|
||||
Check_Pointer(str);
|
||||
Check_Pointer(value);
|
||||
if (isalpha(*str))
|
||||
{
|
||||
Dump(str);
|
||||
}
|
||||
Verify(!isalpha(*str));
|
||||
#else
|
||||
Verify_Arguments(str, value);
|
||||
#endif
|
||||
*value = atol(str);
|
||||
}
|
||||
|
||||
void Convert_From_Ascii(const char *str, Scalar *value)
|
||||
{
|
||||
#if 0
|
||||
Check_Pointer(str);
|
||||
Check_Pointer(value);
|
||||
if (isalpha(*str))
|
||||
{
|
||||
Dump(str);
|
||||
}
|
||||
Verify(!isalpha(*str));
|
||||
#else
|
||||
Verify_Arguments(str, value);
|
||||
#endif
|
||||
*value = atof(str);
|
||||
}
|
||||
Reference in New Issue
Block a user