annotate Engine/OurMath.cpp @ 2531:f6de3e15d4a5

for light in indoor
author Ritor1
date Sun, 23 Nov 2014 15:30:17 +0600
parents 68cdef6879a0
children 1bcadc6dd203
rev   line source
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1 #define _CRTDBG_MAP_ALLOC
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2 #include <stdlib.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
3 #include <crtdbg.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
5 #include "OurMath.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
6 #include "MM7_data.h"
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
7
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
8 //----- (00452969) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
9 stru193_math::stru193_math()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
10 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
11 double v3; // ST18_8@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
12
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
13 this->pTanTable[0] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
14 this->pCosTable[0] = 65536;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
15 this->pInvCosTable[0] = 65536;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
16 for(int i = 1; i < (signed int)this->uIntegerHalfPi; i++)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
17 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
18 v3 = (double)i * 3.141592653589793 / (double)uIntegerPi;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
19 pTanTable[i] = (signed __int64)(tan(v3) * (double)this->pCosTable[0] + 0.5);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
20 pCosTable[i] = (signed __int64)(cos(v3) * (double)this->pCosTable[0] + 0.5);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
21 pInvCosTable[i] = (signed __int64)(1.0 / cos(v3) * (double)this->pCosTable[0] + 0.5);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
22 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
23 for(int i = this->uIntegerHalfPi; i < 520; i++)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
24 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
25 this->pTanTable[i] = 0xEFFFFFFFu;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
26 this->pCosTable[i] = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
27 this->pInvCosTable[i] = 0xEFFFFFFFu;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
28 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
29 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
30
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
31
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
32 //----- (00402CAE) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
33 int stru193_math::Cos(int angle)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
34 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
35 int v2; // eax@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
36
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
37 //a2: (angle - uIntegerHalfPi) for sin(angle)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
38 // (angle) for cos(angle)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
39
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
40 v2 = uDoublePiMask & angle;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
41
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
42 if ( v2 > uIntegerPi )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
43 v2 = uIntegerDoublePi - v2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
44 if ( v2 >= uIntegerHalfPi )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
45 return -pCosTable[uIntegerPi - v2];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
46 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
47 return pCosTable[v2];
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
48 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
49
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
50
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
51 //----- (0045281E) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
52 // Calculates atan2(y/x)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
53 // return value: angle in integer format (multiplier of Pi/1024)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
54 unsigned int stru193_math::Atan2(int x, int y)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
55 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
56 signed int quadrant;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
57 __int64 dividend;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
58 int quotient;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
59 int lowIdx;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
60 int highIdx;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
61 int angle;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
62
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
63 int X = x;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
64 int Y = y;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
65
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
66 if ( abs(X) < 65536 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
67 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
68 if ( (abs(Y) >> 15) >= abs(X) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
69 X = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
70 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
71
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
72 if ( !X )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
73 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
74 if ( Y > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
75 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
76 return uIntegerHalfPi; //Pi/2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
77 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
78 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
79 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
80 return uIntegerHalfPi + uIntegerPi; //3*(Pi/2)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
81 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
82 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
83
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
84 if ( Y )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
85 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
86 if ( X < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
87 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
88 X = -X;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
89 if ( Y > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
90 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
91 quadrant = 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
92 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
93 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
94 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
95 quadrant = 3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
96 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
97 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
98 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
99 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
100 if ( Y > 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
101 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
102 quadrant = 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
103 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
104 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
105 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
106 quadrant = 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
107 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
108 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
109
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
110 if ( Y < 0 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
111 Y = -Y;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
112
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
113 LODWORD(dividend) = Y << 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
114 HIDWORD(dividend) = Y >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
115 quotient = dividend / X;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
116
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
117 //looks like binary search
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
118 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
119 int i;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
120 highIdx = uIntegerHalfPi;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
121 lowIdx = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
122
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
123 for (i = 0; i < 6; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
124 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
125 if (quotient <= pTanTable[(lowIdx + highIdx) / 2])
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
126 highIdx = (lowIdx + highIdx) / 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
127 else
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
128 lowIdx = (lowIdx + highIdx) / 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
129 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
130 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
131
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
132 angle = lowIdx + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
133 while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
134 ++angle;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
135
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
136 switch (quadrant)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
137 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
138 case 1: //X > 0, Y > 0
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
139 return angle;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
140
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
141 case 2: //X > 0, Y < 0
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
142 return uIntegerDoublePi - angle; //2*Pi - angle
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
143
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
144 case 3: //X > 0, Y < 0
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
145 return uIntegerPi + angle; //Pi + angle
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
146
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
147 case 4: //X < 0, Y > 0
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
148 return uIntegerPi - angle; //Pi - angle
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
149 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
150
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
151 //should newer get here
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
152 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
153 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
154
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
155 if ( X < 0 ) //Y == 0, X < 0
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
156 return uIntegerPi;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
157
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
158 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
159 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
160
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
161 //----- (0042EBDB) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
162 int stru193_math::Sin(int angle)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
163 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
164 return Cos(angle - this->uIntegerHalfPi);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
165 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
166
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
167 //----- (0042EBBE) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
168 //----- (004453C0) mm6-----------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
169 //----- (004A1760) mm6_chinese---------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
170 __int64 fixpoint_mul(int a1, int a2)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
171 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
172 return ((__int64)a1 * (__int64)a2) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
173 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
174
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
175 __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
176 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
177 return fixpoint_mul(x1, x2) +
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
178 fixpoint_mul(y1, y2) +
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
179 fixpoint_mul(z1, z2);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
180 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
181
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
182 //----- (004A1780) mm6_chinese---------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
183 __int64 fixpoint_div(int a1, int a2)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
184 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
185 return ((__int64)a1 << 16) / a2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
186 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
187
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
188 __int64 fixpoint_sub_unknown(int a1, int a2)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
189 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
190 return (((__int64)a1 << 16) * a2) >> 16;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
191 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
192
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
193 //----- (0048B561) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
194 int fixpoint_from_float(float val)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
195 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
196 // float X.Yf -> int XXXX YYYY
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
197 int left = floorf((val - 0.5f) + 0.5f);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
198 int right = floorf((val - left) * 65536.0f);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
199 return (left << 16) | right;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
200 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
201
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
202 int fixpoint_from_int(int lhv, int rhv)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
203 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
204 return (lhv << 16) | rhv;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
205 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
206
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
207
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
208 //----- (00452A9E) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
209 int integer_sqrt(int val)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
210 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
211 ///////////////////////////////
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
212 //Получение квадратного корня//
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
213 ///////////////////////////////
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
214
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
215 signed int result; // eax@2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
216 unsigned int v2; // edx@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
217 unsigned int v3; // edi@3
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
218 int v5; // esi@4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
219
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
220 if (val < 1)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
221 return val;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
222
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
223 v2 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
224 v3 = val;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
225 result = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
226 for (uint i = 0; i < 16; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
227 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
228 result *= 2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
229 v2 = (v3 >> 30) | 4 * v2;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
230 v5 = 2 * result + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
231 v3 *= 4;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
232 if ( v2 >= v5 )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
233 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
234 ++result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
235 v2 -= v5;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
236 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
237 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
238 if ( val - result * result >= (unsigned int)(result - 1) )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
239 ++result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
240 return result;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
241 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
242
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
243 //----- (00452B2E) --------------------------------------------------------
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
244 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
245 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
246 int v3; // esi@1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
247
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
248 v3 = 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
249 if ( uDiceSides )
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
250 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
251 for ( uint i = 0; i < uNumDice; ++i)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
252 v3 += rand() % uDiceSides + 1;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
253 return v3;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
254 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
255 return 0;
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
256 }