2499
|
1 #pragma once
|
|
2
|
|
3 #include <cassert>
|
|
4 #include <limits>
|
2534
|
5 #define pi_double 3.14159265358979323846
|
2499
|
6 /* 186 */
|
|
7 #pragma pack(push, 1)
|
|
8 struct stru193_math
|
|
9 {
|
|
10 stru193_math();
|
|
11 int Cos(int angle);
|
|
12 unsigned int Atan2(int x, int y);
|
|
13 int Sin(int angle);
|
|
14
|
|
15 int pTanTable[520];
|
|
16 int pCosTable[520];
|
|
17 int pInvCosTable[520];
|
|
18 static const unsigned int uIntegerPi = 1024;
|
|
19 static const unsigned int uIntegerHalfPi = 512;
|
|
20 static const unsigned int uIntegerDoublePi = 2048;
|
|
21 static const unsigned int uDoublePiMask = 2047;
|
|
22 static const unsigned int uPiMask = 1023;
|
|
23 static const unsigned int uHalfPiMask = 511;
|
|
24 };
|
|
25 #pragma pack(pop)
|
|
26
|
|
27 __int64 fixpoint_mul(int, int);
|
|
28 __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2);
|
|
29 __int64 fixpoint_div(int, int);
|
|
30 __int64 fixpoint_sub_unknown(int, int);
|
|
31 int fixpoint_from_float(float value);
|
|
32 int fixpoint_from_int(int lhv, int rhv);
|
|
33 int integer_sqrt(int val);
|
|
34 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb
|
|
35 inline int round_to_int(float x) { return (int)floor(x + 0.5f); }
|
|
36
|
|
37 template <typename FloatType>
|
|
38 inline int bankersRounding(const FloatType& value)
|
|
39 {
|
|
40 assert("Method unsupported for this type" && false);
|
|
41 return value;
|
|
42 }
|
|
43
|
|
44 template<> inline int bankersRounding<float>(const float& inValue)
|
|
45 {
|
|
46 union Cast
|
|
47 {
|
|
48 double d;
|
|
49 long l;
|
|
50 };
|
|
51 volatile Cast c;
|
|
52 c.d = inValue + 6755399441055744.0;
|
|
53 return c.l;
|
|
54 }
|
|
55
|
|
56 #pragma push_macro("max")
|
|
57 #undef max
|
|
58 template<> inline int bankersRounding<double>(const double& inValue)
|
|
59 {
|
|
60 double maxValue = std::numeric_limits<int>::max();
|
|
61 assert(maxValue - 6755399441055744.0 >= inValue);
|
|
62 union Cast
|
|
63 {
|
|
64 double d;
|
|
65 long l;
|
|
66 };
|
|
67 volatile Cast c;
|
|
68 c.d = inValue + 6755399441055744.0;
|
|
69 return c.l;
|
|
70 }
|
|
71 #pragma pop_macro("max")
|
|
72
|
|
73 extern struct stru193_math *stru_5C6E00;
|