comparison mm7_3.cpp @ 2139:f9b55be70c1b

Слияние
author Ritor1
date Thu, 02 Jan 2014 09:11:28 +0600
parents 7cc14d9d966d 0d0aa7c1ccdd
children cfe04d858766
comparison
equal deleted inserted replaced
2138:7cc14d9d966d 2139:f9b55be70c1b
208 int a10; // [sp+80h] [bp-8h]@1 208 int a10; // [sp+80h] [bp-8h]@1
209 int a2; // [sp+84h] [bp-4h]@23 209 int a2; // [sp+84h] [bp-4h]@23
210 210
211 a11 = ecx0; 211 a11 = ecx0;
212 212
213 BLVFace f; // [sp+Ch] [bp-7Ch]@1 213 BLVFace face; // [sp+Ch] [bp-7Ch]@1
214 214
215 result = 0; 215 result = 0;
216 for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 ) 216 for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 )
217 { 217 {
218 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[a10].sMinX 218 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[a10].sMinX
223 { 223 {
224 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1 224 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1
225 && stru_721530.sMaxY <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1 225 && stru_721530.sMaxY <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1
226 && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1 ) 226 && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1 )
227 { 227 {
228 f.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x; 228 face.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x;
229 f.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y; 229 face.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y;
230 f.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z; 230 face.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z;
231 f.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist; 231 face.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist;
232 f.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes; 232 face.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes;
233 f.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1; 233 face.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1;
234 f.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1; 234 face.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1;
235 f.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1; 235 face.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1;
236 f.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2; 236 face.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2;
237 f.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2; 237 face.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2;
238 f.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2; 238 face.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2;
239 f.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1; 239 face.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1;
240 f.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2; 240 face.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2;
241 f.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3; 241 face.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3;
242 f.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements; 242 face.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements;
243 f.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements; 243 face.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements;
244 f.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements; 244 face.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements;
245 f.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType; 245 face.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType;
246 f.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices; 246 face.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices;
247 f.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID; 247 face.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID;
248 f.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs; 248 face.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs;
249 if ( !f.Ethereal() && !f.Portal() ) 249 if ( !face.Ethereal() && !face.Portal() )
250 { 250 {
251 v8 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal.x 251 v8 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal.x
252 + f.pFacePlane_old.vNormal.y * stru_721530.normal.y 252 + face.pFacePlane_old.vNormal.y * stru_721530.normal.y
253 + f.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16; 253 + face.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16;
254 if ( v8 > 0 ) 254 if ( v8 > 0 )
255 { 255 {
256 v9 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x 256 v9 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.normal2.x
257 + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y 257 + face.pFacePlane_old.vNormal.y * stru_721530.normal2.y
258 + f.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16; 258 + face.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16;
259 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d ) 259 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d )
260 { 260 {
261 if ( v9 <= v8 ) 261 if ( v9 <= v8 )
262 { 262 {
263 a2 = stru_721530.field_6C; 263 a2 = stru_721530.field_6C;
264 if ( sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, 264 if ( sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
265 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) ) 265 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, a10, a11) )
266 { 266 {
267 v10 = a2; 267 v10 = a2;
268 } 268 }
269 else 269 else
270 { 270 {
271 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C; 271 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C;
272 if ( !sub_475F30( &a2, &f, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, 272 if ( !sub_475F30( &a2, &face, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z,
273 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) ) 273 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
274 goto LABEL_29; 274 goto LABEL_29;
275 v10 = a2 - stru_721530.prolly_normal_d; 275 v10 = a2 - stru_721530.prolly_normal_d;
276 a2 -= stru_721530.prolly_normal_d; 276 a2 -= stru_721530.prolly_normal_d;
277 } 277 }
286 } 286 }
287 } 287 }
288 LABEL_29: 288 LABEL_29:
289 if ( stru_721530.field_0 & 1 ) 289 if ( stru_721530.field_0 & 1 )
290 { 290 {
291 v15 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.position.x 291 v15 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.position.x
292 + f.pFacePlane_old.vNormal.y * stru_721530.position.y 292 + face.pFacePlane_old.vNormal.y * stru_721530.position.y
293 + f.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16; 293 + face.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16;
294 if ( v15 > 0 ) 294 if ( v15 > 0 )
295 { 295 {
296 v16 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.field_4C 296 v16 = (face.pFacePlane_old.dist + face.pFacePlane_old.vNormal.x * stru_721530.field_4C
297 + f.pFacePlane_old.vNormal.y * stru_721530.field_50 297 + face.pFacePlane_old.vNormal.y * stru_721530.field_50
298 + f.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16; 298 + face.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16;
299 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) 299 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d )
300 { 300 {
301 if ( v16 <= v15 ) 301 if ( v16 <= v15 )
302 { 302 {
303 a2 = stru_721530.field_6C; 303 a2 = stru_721530.field_6C;
304 if ( sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, 304 if ( sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
305 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) ) 305 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &face, a10, a11) )
306 { 306 {
307 if ( a2 < stru_721530.field_7C ) 307 if ( a2 < stru_721530.field_7C )
308 { 308 {
309 stru_721530.field_7C = a2; 309 stru_721530.field_7C = a2;
310 v17 = 8 * (v3 | (a10 << 6)); 310 v17 = 8 * (v3 | (a10 << 6));
313 } 313 }
314 } 314 }
315 else 315 else
316 { 316 {
317 a2 = stru_721530.field_6C + stru_721530.field_8_radius; 317 a2 = stru_721530.field_6C + stru_721530.field_8_radius;
318 if ( sub_475F30(&a2, &f, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, 318 if ( sub_475F30(&a2, &face, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z,
319 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) ) 319 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) )
320 { 320 {
321 v21 = a2 - stru_721530.prolly_normal_d; 321 v21 = a2 - stru_721530.prolly_normal_d;
322 a2 -= stru_721530.prolly_normal_d; 322 a2 -= stru_721530.prolly_normal_d;
323 if ( a2 < stru_721530.field_7C ) 323 if ( a2 < stru_721530.field_7C )
369 { 369 {
370 ObjectDesc *object; // edx@4 370 ObjectDesc *object; // edx@4
371 int v10; // ecx@12 371 int v10; // ecx@12
372 int v11; // esi@13 372 int v11; // esi@13
373 373
374 if ( (signed int)uNumSpriteObjects > 0 ) 374 for ( uint i = 0; i < uNumSpriteObjects; ++i )
375 { 375 {
376 for ( uint i = 0; i < uNumSpriteObjects; ++i ) 376 if ( pSpriteObjects[i].uObjectDescID )
377 { 377 {
378 if ( pSpriteObjects[i].uObjectDescID ) 378 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
379 { 379 if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) )
380 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID]; 380 {
381 if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) ) 381 if ( stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius
382 && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius
383 && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z )
382 { 384 {
383 if ( stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius 385 if ( abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
384 && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius 386 - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16)
385 && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius 387 <= object->uHeight + stru_721530.prolly_normal_d )
386 && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius
387 && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight
388 && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z )
389 { 388 {
390 if ( abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y 389 v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x
391 - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= object->uHeight 390 + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16;
392 + stru_721530.prolly_normal_d ) 391 if ( v10 > 0 )
393 { 392 {
394 v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x 393 v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16);
395 + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16; 394 if ( v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d )
396 if ( v10 > 0 )
397 { 395 {
398 v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16); 396 if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z )
399 if ( v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d )
400 { 397 {
401 if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z ) 398 if ( v10 < stru_721530.field_7C )
402 { 399 sub_46DEF2(_this, i);
403 if ( v10 < stru_721530.field_7C )
404 sub_46DEF2(_this, i);
405 }
406 } 400 }
407 } 401 }
408 } 402 }
409 } 403 }
410 } 404 }
414 } 408 }
415 409
416 //----- (0046EF01) -------------------------------------------------------- 410 //----- (0046EF01) --------------------------------------------------------
417 int _46EF01_collision_chech_player(int a1) 411 int _46EF01_collision_chech_player(int a1)
418 { 412 {
419 int v1; // edx@1
420 int result; // eax@1 413 int result; // eax@1
421 int v3; // ebx@7 414 int v3; // ebx@7
422 int v4; // esi@7 415 int v4; // esi@7
423 int v5; // edi@8 416 int v5; // edi@8
424 int v6; // ecx@9 417 int v6; // ecx@9
425 int v7; // edi@12 418 int v7; // edi@12
426 int v8; // [sp+Ch] [bp-10h]@1
427 unsigned int v9; // [sp+10h] [bp-Ch]@1
428 int v10; // [sp+14h] [bp-8h]@7 419 int v10; // [sp+14h] [bp-8h]@7
429 int v11; // [sp+18h] [bp-4h]@7 420 int v11; // [sp+18h] [bp-4h]@7
430 421
431 v8 = a1;
432 v1 = 2 * pParty->field_14_radius;
433 result = pParty->vPosition.x; 422 result = pParty->vPosition.x;
434 v9 = pParty->uPartyHeight; 423 //v9 = pParty->uPartyHeight;
435 if ( stru_721530.sMaxX <= pParty->vPosition.x + v1 && stru_721530.sMinX >= pParty->vPosition.x - v1 424 if ( stru_721530.sMaxX <= pParty->vPosition.x + (2 * pParty->field_14_radius) && stru_721530.sMinX >= pParty->vPosition.x - (2 * pParty->field_14_radius)
436 && stru_721530.sMaxY <= pParty->vPosition.y + v1 && stru_721530.sMinY >= pParty->vPosition.y - v1 425 && stru_721530.sMaxY <= pParty->vPosition.y + (2 * pParty->field_14_radius) && stru_721530.sMinY >= pParty->vPosition.y - (2 * pParty->field_14_radius)
437 && stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) 426 && stru_721530.sMaxZ <= pParty->vPosition.z + pParty->uPartyHeight && stru_721530.sMinZ >= pParty->vPosition.z )
438 && stru_721530.sMinZ >= pParty->vPosition.z ) 427 {
439 { 428 v3 = stru_721530.prolly_normal_d + (2 * pParty->field_14_radius);
440 v3 = stru_721530.prolly_normal_d + v1;
441 v11 = pParty->vPosition.x - stru_721530.normal.x; 429 v11 = pParty->vPosition.x - stru_721530.normal.x;
442 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y 430 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
443 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16; 431 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
444 v10 = pParty->vPosition.y - stru_721530.normal.y; 432 v10 = pParty->vPosition.y - stru_721530.normal.y;
445 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y 433 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y
446 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16); 434 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16);
447 if ( result <= stru_721530.prolly_normal_d + v1 ) 435 if ( result <= stru_721530.prolly_normal_d + (2 * pParty->field_14_radius) )
448 { 436 {
449 result = v10 * stru_721530.direction.y; 437 result = v10 * stru_721530.direction.y;
450 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16; 438 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16;
451 if ( v5 > 0 ) 439 if ( v5 > 0 )
452 { 440 {
453 v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z; 441 v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z;
454 result = pParty->vPosition.z; 442 result = pParty->vPosition.z;
455 if ( v6 >= pParty->vPosition.z ) 443 if ( v6 >= pParty->vPosition.z )
456 { 444 {
457 result = v9 + pParty->vPosition.z; 445 result = pParty->uPartyHeight + pParty->vPosition.z;
458 if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 ) 446 if ( v6 <= (signed int)(pParty->uPartyHeight + pParty->vPosition.z) || a1 )
459 { 447 {
460 result = integer_sqrt(v3 * v3 - v4 * v4); 448 result = integer_sqrt(v3 * v3 - v4 * v4);
461 v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4); 449 v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4);
462 if ( v7 < 0 ) 450 if ( v7 < 0 )
463 v7 = 0; 451 v7 = 0;
533 } 521 }
534 522
535 //----- (0047050A) -------------------------------------------------------- 523 //----- (0047050A) --------------------------------------------------------
536 int stru141_actor_collision_object::_47050A(int dt) 524 int stru141_actor_collision_object::_47050A(int dt)
537 { 525 {
538 //stru141_actor_collision_object *v2; // esi@1
539 //signed int v3; // eax@1
540 //int v4; // ecx@1
541 //int v5; // edx@1
542 //int v6; // edx@1
543 int v7; // eax@1 526 int v7; // eax@1
544 //int v8; // eax@3
545 signed int result; // eax@4 527 signed int result; // eax@4
546 //int v10; // eax@5
547 //int v11; // eax@5
548 //int v12; // ebx@5
549 //int v13; // edx@5
550 //int v14; // edi@5
551 //int v15; // ecx@5
552 //int v16; // eax@5
553 int v17; // eax@5 528 int v17; // eax@5
554 int v18; // eax@7 529 int v18; // eax@7
555 //int v19; // edx@9
556 //int v20; // edi@9
557 int v21; // eax@9 530 int v21; // eax@9
558 int v22; // eax@11 531 int v22; // eax@11
559 //int v23; // edx@13 532
560 //int v24; // eax@13
561 //int v25; // eax@14
562 //int v26; // eax@16
563 //int v27; // eax@17
564 //int v28; // [sp+14h] [bp+8h]@5
565
566 //v2 = this;
567 int speed = 1 | integer_sqrt(this->velocity.z * this->velocity.z + this->velocity.y * this->velocity.y + this->velocity.x * this->velocity.x); 533 int speed = 1 | integer_sqrt(this->velocity.z * this->velocity.z + this->velocity.y * this->velocity.y + this->velocity.x * this->velocity.x);
568 534
569 this->direction.x = 65536 / speed * this->velocity.x; 535 this->direction.x = 65536 / speed * this->velocity.x;
570 this->direction.y = 65536 / speed * this->velocity.y; 536 this->direction.y = 65536 / speed * this->velocity.y;
571 this->direction.z = 65536 / speed * this->velocity.z; 537 this->direction.z = 65536 / speed * this->velocity.z;
679 unsigned int v69; // [sp+30h] [bp-20h]@6 645 unsigned int v69; // [sp+30h] [bp-20h]@6
680 unsigned int v70; // [sp+34h] [bp-1Ch]@10 646 unsigned int v70; // [sp+34h] [bp-1Ch]@10
681 int v71; // [sp+38h] [bp-18h]@62 647 int v71; // [sp+38h] [bp-18h]@62
682 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 648 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10
683 int v72b; 649 int v72b;
684 //int v73; // [sp+40h] [bp-10h]@17
685 int uIsFlying; // [sp+44h] [bp-Ch]@8 650 int uIsFlying; // [sp+44h] [bp-Ch]@8
686 unsigned int v75; // [sp+48h] [bp-8h]@1 651 unsigned int v75; // [sp+48h] [bp-8h]@1
687 int uIsOnWater; // [sp+4Ch] [bp-4h]@10 652 int uIsOnWater; // [sp+4Ch] [bp-4h]@10
688 653
689 for (v75 = 0; v75 < uNumActors; ++v75) 654 for (v75 = 0; v75 < uNumActors; ++v75)
995 960
996 //----- (0047253E) -------------------------------------------------------- 961 //----- (0047253E) --------------------------------------------------------
997 void UpdateObjects() 962 void UpdateObjects()
998 { 963 {
999 unsigned int v0; // ebx@0 964 unsigned int v0; // ebx@0
1000 //unsigned int v1; // edi@1
1001 //char *v2; // esi@2
1002 //__int16 v3; // dx@5
1003 ObjectDesc *object; // eax@5 965 ObjectDesc *object; // eax@5
1004 int v5; // ecx@6 966 int v5; // ecx@6
1005 __int16 v6; // cx@7 967 __int16 v6; // cx@7
1006 signed int v7; // eax@9 968 signed int v7; // eax@9
1007 //unsigned int v10; // ecx@16
1008 signed int v11; // eax@17 969 signed int v11; // eax@17
1009 int v12; // edi@27 970 int v12; // edi@27
1010 int v13; // eax@27 971 int v13; // eax@27
1011 int v14; // ebx@27 972 int v14; // ebx@27
1012 unsigned int v15; // ecx@27 973 unsigned int v15; // ecx@27
1013 unsigned int v16; // edx@30 974 unsigned int v16; // edx@30
1014 unsigned int v17; // edx@32 975 unsigned int v17; // edx@32
1015 int v18; // [sp+4h] [bp-10h]@27 976 int v18; // [sp+4h] [bp-10h]@27
1016 int v19; // [sp+8h] [bp-Ch]@27 977 int v19; // [sp+8h] [bp-Ch]@27
1017 //signed int v20; // [sp+10h] [bp-4h]@1 978
1018
1019 //v1 = 0;
1020 //v20 = 0;
1021 for (uint i = 0; i < uNumSpriteObjects; ++i) 979 for (uint i = 0; i < uNumSpriteObjects; ++i)
1022 { 980 {
1023 SpriteObject* item = &pSpriteObjects[i]; 981 if (pSpriteObjects[i].uAttributes & OBJECT_40)
1024 //v2 = (char *)&item->uSpriteFrameID; 982 pSpriteObjects[i].uAttributes &= ~OBJECT_40;
1025 //do
1026 //{
1027 //LOWORD(v0) = item->uAttributes;
1028 if (item->uAttributes & OBJECT_40)
1029 item->uAttributes &= ~OBJECT_40;
1030 else 983 else
1031 { 984 {
1032 object = &pObjectList->pObjects[item->uObjectDescID]; 985 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID];
1033 if (item->AttachedToActor()) 986 if (pSpriteObjects[i].AttachedToActor())
1034 { 987 {
1035 v5 = PID_ID(item->spell_target_pid); 988 v5 = PID_ID(pSpriteObjects[i].spell_target_pid);
1036 item->vPosition.x = pActors[v5].vPosition.x; 989 pSpriteObjects[i].vPosition.x = pActors[v5].vPosition.x;
1037 item->vPosition.y = pActors[v5].vPosition.y; 990 pSpriteObjects[i].vPosition.y = pActors[v5].vPosition.y;
1038 item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight; 991 pSpriteObjects[i].vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight;
1039 if ( !item->uObjectDescID ) 992 if ( !pSpriteObjects[i].uObjectDescID )
1040 continue;
1041 item->uSpriteFrameID += pEventTimer->uTimeElapsed;
1042 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
1043 continue;
1044 if ( item->uSpriteFrameID >= 0 )
1045 {
1046 v7 = object->uLifetime;
1047 if (item->uAttributes & ITEM_BROKEN)
1048 v7 = item->field_20;
1049 if ( item->uSpriteFrameID < v7 )
1050 continue;
1051 }
1052 SpriteObject::OnInteraction(i);
1053 continue; 993 continue;
1054 } 994 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
1055 995 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY))
1056 if ( item->uObjectDescID ) 996 continue;
997 if ( pSpriteObjects[i].uSpriteFrameID >= 0 )
1057 { 998 {
1058 item->uSpriteFrameID += pEventTimer->uTimeElapsed; 999 v7 = object->uLifetime;
1059 if ( object->uFlags & OBJECT_DESC_TEMPORARY ) 1000 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
1060 { 1001 v7 = pSpriteObjects[i].field_20;
1061 if ( item->uSpriteFrameID < 0 ) 1002 if ( pSpriteObjects[i].uSpriteFrameID < v7 )
1062 { 1003 continue;
1063 SpriteObject::OnInteraction(i); 1004 }
1064 continue; 1005 SpriteObject::OnInteraction(i);
1065 } 1006 continue;
1066 v11 = object->uLifetime; 1007 }
1067 if (item->uAttributes & ITEM_BROKEN) 1008 if ( pSpriteObjects[i].uObjectDescID )
1068 v11 = item->field_20; 1009 {
1069 } 1010 pSpriteObjects[i].uSpriteFrameID += pEventTimer->uTimeElapsed;
1070 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || item->uSpriteFrameID < v11 ) 1011 if ( object->uFlags & OBJECT_DESC_TEMPORARY )
1071 { 1012 {
1072 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 1013 if ( pSpriteObjects[i].uSpriteFrameID < 0 )
1073 SpriteObject::UpdateObject_fn0_BLV(i);
1074 else
1075 SpriteObject::UpdateObject_fn0_ODM(i);
1076 if ( pParty->bTurnBasedModeOn != 1 || !(item->uSectorID & 4) )
1077 continue;
1078 v12 = abs(pParty->vPosition.x - item->vPosition.x);
1079 v18 = abs(pParty->vPosition.y - item->vPosition.y);
1080 v19 = abs(pParty->vPosition.z - item->vPosition.z);
1081 v13 = v12;
1082 v14 = v18;
1083 v15 = v19;
1084 if ( v12 < v18 )
1085 {
1086 v13 = v18;
1087 v14 = v12;
1088 }
1089 if ( v13 < v19 )
1090 {
1091 v16 = v13;
1092 v13 = v19;
1093 v15 = v16;
1094 }
1095 if ( v14 < (signed int)v15 )
1096 {
1097 v17 = v15;
1098 v15 = v14;
1099 v14 = v17;
1100 }
1101 v0 = (unsigned int)(11 * v14) >> 5;
1102 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
1103 continue;
1104 SpriteObject::OnInteraction(i);
1105 continue;
1106 }
1107 if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
1108 { 1014 {
1109 SpriteObject::OnInteraction(i); 1015 SpriteObject::OnInteraction(i);
1110 continue; 1016 continue;
1111 } 1017 }
1112 _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i)); 1018 v11 = object->uLifetime;
1019 if (pSpriteObjects[i].uAttributes & ITEM_BROKEN)
1020 v11 = pSpriteObjects[i].field_20;
1113 } 1021 }
1022 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || pSpriteObjects[i].uSpriteFrameID < v11 )
1023 {
1024 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
1025 SpriteObject::UpdateObject_fn0_BLV(i);
1026 else
1027 SpriteObject::UpdateObject_fn0_ODM(i);
1028 if ( pParty->bTurnBasedModeOn != 1 || !(pSpriteObjects[i].uSectorID & 4) )
1029 continue;
1030 v12 = abs(pParty->vPosition.x - pSpriteObjects[i].vPosition.x);
1031 v18 = abs(pParty->vPosition.y - pSpriteObjects[i].vPosition.y);
1032 v19 = abs(pParty->vPosition.z - pSpriteObjects[i].vPosition.z);
1033 v13 = v12;
1034 v14 = v18;
1035 v15 = v19;
1036 if ( v12 < v18 )
1037 {
1038 v13 = v18;
1039 v14 = v12;
1040 }
1041 if ( v13 < v19 )
1042 {
1043 v16 = v13;
1044 v13 = v19;
1045 v15 = v16;
1046 }
1047 if ( v14 < (signed int)v15 )
1048 {
1049 v17 = v15;
1050 v15 = v14;
1051 v14 = v17;
1052 }
1053 v0 = (unsigned int)(11 * v14) >> 5;
1054 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 )
1055 continue;
1056 SpriteObject::OnInteraction(i);
1057 continue;
1058 }
1059 if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) )
1060 {
1061 SpriteObject::OnInteraction(i);
1062 continue;
1063 }
1064 _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i));
1065 }
1114 } 1066 }
1115 } 1067 }
1116 } 1068 }
1117 1069
1118 //----- (0047272C) -------------------------------------------------------- 1070 //----- (0047272C) --------------------------------------------------------
1119 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) 1071 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID)
1120 { 1072 {
1121 signed int v5; // ebx@1
1122 int result; // eax@1 1073 int result; // eax@1
1123 int v7; // [sp+10h] [bp-8h]@1 1074
1124 signed int v8; // [sp+14h] [bp-4h]@1
1125
1126 v5 = x - 2;
1127 v7 = x;
1128 v8 = y;
1129 *pSectorID = pIndoor->GetSector(x - 2, y, z + 40); 1075 *pSectorID = pIndoor->GetSector(x - 2, y, z + 40);
1130 result = collide_against_floor(v5, v8, z + 40, pSectorID, pFaceID); 1076 result = collide_against_floor(x - 2, y, z + 40, pSectorID, pFaceID);
1131 if ( result == -30000 || !*pSectorID ) 1077 if ( result == -30000 || !*pSectorID )
1132 { 1078 {
1133 *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40); 1079 *pSectorID = pIndoor->GetSector(x + 2, y, z + 40);
1134 result = collide_against_floor(v7 + 2, v8, z + 40, pSectorID, pFaceID); 1080 result = collide_against_floor(x + 2, y, z + 40, pSectorID, pFaceID);
1135 if ( result == -30000 || !*pSectorID ) 1081 if ( result == -30000 || !*pSectorID )
1136 { 1082 {
1137 *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40); 1083 *pSectorID = pIndoor->GetSector(x, y - 2, z + 40);
1138 result = collide_against_floor(v7, v8 - 2, z + 40, pSectorID, pFaceID); 1084 result = collide_against_floor(x, y - 2, z + 40, pSectorID, pFaceID);
1139 if ( result == -30000 || !*pSectorID ) 1085 if ( result == -30000 || !*pSectorID )
1140 { 1086 {
1141 *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40); 1087 *pSectorID = pIndoor->GetSector(x, y + 2, z + 40);
1142 result = collide_against_floor(v7, v8 + 2, z + 40, pSectorID, pFaceID); 1088 result = collide_against_floor(x, y + 2, z + 40, pSectorID, pFaceID);
1143 if ( result == -30000 || !*pSectorID ) 1089 if ( result == -30000 || !*pSectorID )
1144 { 1090 {
1145 *pSectorID = pIndoor->GetSector(v7, v8, z + 140); 1091 *pSectorID = pIndoor->GetSector(x, y, z + 140);
1146 result = collide_against_floor(v7, v8, z + 140, pSectorID, pFaceID); 1092 result = collide_against_floor(x, y, z + 140, pSectorID, pFaceID);
1147 } 1093 }
1148 } 1094 }
1149 } 1095 }
1150 } 1096 }
1151 return result; 1097 return result;
1270 *a2 = 0; 1216 *a2 = 0;
1271 return true; 1217 return true;
1272 } 1218 }
1273 1219
1274 //----- (00475665) -------------------------------------------------------- 1220 //----- (00475665) --------------------------------------------------------
1275 int sub_475665(BLVFace *_this, int a2, __int16 a3) 1221 int sub_475665(BLVFace *face, int a2, __int16 a3)
1276 { 1222 {
1277 unsigned int v3; // eax@1
1278 Vec3_short_ *v4; // edx@3
1279 signed int v5; // eax@4
1280 int v6; // esi@4
1281 signed int v7; // eax@7
1282 Vec3_short_ *v8; // edx@8
1283 signed int v9; // eax@9
1284 int v10; // esi@9
1285 signed int v11; // eax@11
1286 Vec3_short_ *v12; // edx@12
1287 signed int v13; // eax@13
1288 int v14; // esi@13
1289 int v15; // esi@14
1290 bool v16; // edi@14 1223 bool v16; // edi@14
1291 int v17; // ecx@16
1292 signed int v18; // edx@16
1293 int v19; // eax@17
1294 signed int v20; // ebx@18 1224 signed int v20; // ebx@18
1295 int v21; // edi@20 1225 int v21; // edi@20
1296 signed int v22; // ST14_4@22 1226 signed int v22; // ST14_4@22
1297 signed __int64 v23; // qtt@22 1227 signed __int64 v23; // qtt@22
1298 signed int result; // eax@25 1228 signed int result; // eax@25
1302 signed int v28; // [sp+30h] [bp+Ch]@2 1232 signed int v28; // [sp+30h] [bp+Ch]@2
1303 signed int v29; // [sp+30h] [bp+Ch]@7 1233 signed int v29; // [sp+30h] [bp+Ch]@7
1304 signed int v30; // [sp+30h] [bp+Ch]@11 1234 signed int v30; // [sp+30h] [bp+Ch]@11
1305 signed int v31; // [sp+30h] [bp+Ch]@14 1235 signed int v31; // [sp+30h] [bp+Ch]@14
1306 1236
1307 v3 = _this->uAttributes; 1237 if ( face->uAttributes & FACE_XY_PLANE )
1308 if ( BYTE1(v3) & 1 ) 1238 {
1309 {
1310 v28 = 0;
1311 v26 = (signed __int16)a2; 1239 v26 = (signed __int16)a2;
1312 v27 = SHIWORD(a2); 1240 v27 = SHIWORD(a2);
1313 if ( _this->uNumVertices ) 1241 if ( face->uNumVertices )
1314 { 1242 {
1315 v4 = pIndoor->pVertices; 1243 for ( v28 = 0; v28 < face->uNumVertices; v28++ )
1316 do 1244 {
1317 { 1245 word_720C10_intercepts_xs[2 * v28] = face->pXInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].x;
1318 v5 = v28; 1246 word_720B40_intercepts_zs[2 * v28] = face->pYInterceptDisplacements[v28] + pIndoor->pVertices[face->pVertexIDs[v28]].y;
1319 v6 = 2 * v28; 1247 word_720C10_intercepts_xs[2 * v28 + 1] = face->pXInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].x;
1320 word_720C10_intercepts_xs[2 * v28] = _this->pXInterceptDisplacements[v28] + v4[_this->pVertexIDs[v28]].x; 1248 word_720B40_intercepts_zs[2 * v28 + 1] = face->pYInterceptDisplacements[v28 + 1] + pIndoor->pVertices[face->pVertexIDs[v28 + 1]].y;
1321 word_720B40_intercepts_zs[2 * v28] = _this->pYInterceptDisplacements[v5] + v4[_this->pVertexIDs[v5]].y; 1249 }
1322 word_720C10_intercepts_xs[2 * v28++ + 1] = _this->pXInterceptDisplacements[v5 + 1]
1323 + v4[_this->pVertexIDs[v5 + 1]].x;
1324 word_720B40_intercepts_zs[v6 + 1] = _this->pYInterceptDisplacements[v5 + 1] + v4[_this->pVertexIDs[v5 + 1]].y;
1325 }
1326 while ( v28 < _this->uNumVertices );
1327 } 1250 }
1328 } 1251 }
1329 else 1252 else
1330 { 1253 {
1331 if ( BYTE1(v3) & 2 ) 1254 if ( face->uAttributes & FACE_XZ_PLANE )
1332 { 1255 {
1333 v26 = (signed __int16)a2; 1256 v26 = (signed __int16)a2;
1334 v7 = a3; 1257 v27 = a3;
1335 v29 = 0; 1258 if ( face->uNumVertices )
1336 v27 = v7; 1259 {
1337 if ( _this->uNumVertices ) 1260 for ( v29 = 0; v29 < face->uNumVertices; v29++ )
1338 {
1339 v8 = pIndoor->pVertices;
1340 do
1341 { 1261 {
1342 v9 = v29; 1262 word_720C10_intercepts_xs[2 * v29] = face->pXInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].x;
1343 v10 = 2 * v29; 1263 word_720B40_intercepts_zs[2 * v29] = face->pZInterceptDisplacements[v29] + pIndoor->pVertices[face->pVertexIDs[v29]].z;
1344 word_720C10_intercepts_xs[2 * v29] = _this->pXInterceptDisplacements[v29] + v8[_this->pVertexIDs[v29]].x; 1264 word_720C10_intercepts_xs[2 * v29 + 1] = face->pXInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].x;
1345 word_720B40_intercepts_zs[2 * v29] = _this->pZInterceptDisplacements[v9] + v8[_this->pVertexIDs[v9]].z; 1265 word_720B40_intercepts_zs[2 * v29 + 1] = face->pZInterceptDisplacements[v29 + 1] + pIndoor->pVertices[face->pVertexIDs[v29 + 1]].z;
1346 word_720C10_intercepts_xs[2 * v29++ + 1] = _this->pXInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].x;
1347 word_720B40_intercepts_zs[v10 + 1] = _this->pZInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].z;
1348 } 1266 }
1349 while ( v29 < _this->uNumVertices );
1350 } 1267 }
1351 } 1268 }
1352 else 1269 else
1353 { 1270 {
1354 v26 = SHIWORD(a2); 1271 v26 = SHIWORD(a2);
1355 v11 = a3; 1272 v27 = a3;
1356 v30 = 0; 1273 if ( face->uNumVertices )
1357 v27 = v11; 1274 {
1358 if ( _this->uNumVertices ) 1275 for ( v30 = 0; v30 < face->uNumVertices; v30++ )
1359 {
1360 v12 = pIndoor->pVertices;
1361 do
1362 { 1276 {
1363 v13 = v30; 1277 word_720C10_intercepts_xs[2 * v30] = face->pYInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].y;
1364 v14 = 2 * v30; 1278 word_720B40_intercepts_zs[2 * v30] = face->pZInterceptDisplacements[v30] + pIndoor->pVertices[face->pVertexIDs[v30]].z;
1365 word_720C10_intercepts_xs[2 * v30] = _this->pYInterceptDisplacements[v30] + v12[_this->pVertexIDs[v30]].y; 1279 word_720C10_intercepts_xs[2 * v30 + 1] = face->pYInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].y;
1366 word_720B40_intercepts_zs[2 * v30] = _this->pZInterceptDisplacements[v13] + v12[_this->pVertexIDs[v13]].z; 1280 word_720B40_intercepts_zs[2 * v30 + 1] = face->pZInterceptDisplacements[v30 + 1] + pIndoor->pVertices[face->pVertexIDs[v30 + 1]].z;
1367 word_720C10_intercepts_xs[2 * v30++ + 1] = _this->pYInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].y;
1368 word_720B40_intercepts_zs[v14 + 1] = _this->pZInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].z;
1369 } 1281 }
1370 while ( v30 < _this->uNumVertices ); 1282 }
1371 } 1283 }
1372 } 1284 }
1373 }
1374 v15 = 2 * _this->uNumVertices;
1375 v31 = 0; 1285 v31 = 0;
1376 word_720C10_intercepts_xs[2 * _this->uNumVertices] = word_720C10_intercepts_xs[0]; 1286 word_720C10_intercepts_xs[2 * face->uNumVertices] = word_720C10_intercepts_xs[0];
1377 word_720B40_intercepts_zs[v15] = word_720B40_intercepts_zs[0]; 1287 word_720B40_intercepts_zs[2 * face->uNumVertices] = word_720B40_intercepts_zs[0];
1378 v25 = 0;
1379 v16 = word_720B40_intercepts_zs[0] >= v27; 1288 v16 = word_720B40_intercepts_zs[0] >= v27;
1380 if ( v15 <= 0 ) 1289 if ( 2 * face->uNumVertices <= 0 )
1381 return 0; 1290 return 0;
1382 do 1291 for ( v25 = 0; v25 < 2 * face->uNumVertices; ++v25 )
1383 { 1292 {
1384 if ( v31 >= 2 ) 1293 if ( v31 >= 2 )
1385 break; 1294 break;
1386 v17 = v25; 1295 if ( v16 ^ (word_720B40_intercepts_zs[v25 + 1] >= v27) )
1387 v18 = word_720B40_intercepts_zs[v25 + 1]; 1296 {
1388 if ( v16 ^ (v18 >= v27) ) 1297 if ( word_720C10_intercepts_xs[v25 + 1] >= v26 )
1389 {
1390 v19 = word_720C10_intercepts_xs[v17 + 1];
1391 if ( v19 >= v26 )
1392 v20 = 0; 1298 v20 = 0;
1393 else 1299 else
1394 v20 = 2; 1300 v20 = 2;
1395 v21 = v20 | (word_720C10_intercepts_xs[v17] < v26); 1301 v21 = v20 | (word_720C10_intercepts_xs[v25] < v26);
1396 if ( v21 != 3 ) 1302 if ( v21 != 3 )
1397 { 1303 {
1304 v22 = word_720C10_intercepts_xs[v25 + 1] - word_720C10_intercepts_xs[v25];
1305 LODWORD(v23) = v22 << 16;
1306 HIDWORD(v23) = v22 >> 16;
1398 if ( !v21 1307 if ( !v21
1399 || (v22 = v19 - word_720C10_intercepts_xs[v17], 1308 || (word_720C10_intercepts_xs[v25] + ((signed int)(((unsigned __int64)(v23
1400 LODWORD(v23) = v22 << 16, 1309 / (word_720B40_intercepts_zs[v25 + 1] - word_720B40_intercepts_zs[v25])
1401 HIDWORD(v23) = v22 >> 16, 1310 * ((v27 - (signed int)word_720B40_intercepts_zs[v25]) << 16)) >> 16)
1402 word_720C10_intercepts_xs[v17] 1311 + 32768) >> 16) >= v26) )
1403 + ((signed int)(((unsigned __int64)(v23
1404 / (v18 - word_720B40_intercepts_zs[v17])
1405 * ((v27 - (signed int)word_720B40_intercepts_zs[v17]) << 16)) >> 16)
1406 + 32768) >> 16) >= v26) )
1407 ++v31; 1312 ++v31;
1408 } 1313 }
1409 } 1314 }
1410 ++v25; 1315 v16 = word_720B40_intercepts_zs[v25 + 1] >= v27;
1411 v16 = v18 >= v27; 1316 }
1412 }
1413 while ( v25 < v15 );
1414 result = 1; 1317 result = 1;
1415 if ( v31 != 1 ) 1318 if ( v31 != 1 )
1416 result = 0; 1319 result = 0;
1417 return result; 1320 return result;
1418 } 1321 }
1419 1322
1420 //----- (004759C9) -------------------------------------------------------- 1323 //----- (004759C9) --------------------------------------------------------
1421 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4) 1324 bool __fastcall sub_4759C9(BLVFace *face, int a2, int a3, __int16 a4)
1422 { 1325 {
1423 //unsigned int v4; // eax@1
1424 //int v5; // edx@4
1425 __int16 v6; // si@4
1426 //int v7; // edx@9
1427 __int16 v8; // si@9
1428 //int v9; // edx@13
1429 __int16 v10; // si@13
1430 int v11; // esi@14
1431 bool v12; // edi@14 1326 bool v12; // edi@14
1432 int v13; // ecx@16
1433 signed int v14; // edx@16
1434 int v15; // eax@17
1435 signed int v16; // ebx@18 1327 signed int v16; // ebx@18
1436 int v17; // edi@20 1328 int v17; // edi@20
1437 signed int v18; // ST14_4@22 1329 signed int v18; // ST14_4@22
1438 signed __int64 v19; // qtt@22 1330 signed __int64 v19; // qtt@22
1439 bool result; // eax@25 1331 bool result; // eax@25
1440 int v21; // [sp+14h] [bp-10h]@14 1332 int v21; // [sp+14h] [bp-10h]@14
1441 signed int v22; // [sp+18h] [bp-Ch]@1 1333 signed int v22; // [sp+18h] [bp-Ch]@1
1442 int v23; // [sp+1Ch] [bp-8h]@2 1334 int v23; // [sp+1Ch] [bp-8h]@2
1443 signed int v24; // [sp+20h] [bp-4h]@2 1335 signed int v24; // [sp+20h] [bp-4h]@2
1444 Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3
1445 Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8
1446 Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12
1447 signed int a4d; // [sp+30h] [bp+Ch]@14 1336 signed int a4d; // [sp+30h] [bp+Ch]@14
1448 1337
1449 //v4 = a1->uAttributes; 1338 if ( face->uAttributes & FACE_XY_PLANE )
1450 v22 = 0;
1451 if ( BYTE1(a1->uAttributes) & 1 )
1452 { 1339 {
1453 v23 = (signed __int16)a3; 1340 v23 = (signed __int16)a3;
1454 v24 = SHIWORD(a3); 1341 v24 = SHIWORD(a3);
1455 if ( a1->uNumVertices ) 1342 if ( face->uNumVertices )
1456 { 1343 {
1457 a4a = &pOutdoor->pBModels[a2].pVertices.pVertices; 1344 for ( v22 = 0; v22 < face->uNumVertices; ++v22 )
1458 do 1345 {
1459 { 1346 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
1460 //v5 = 2 * v22; 1347 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
1461 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x); 1348 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
1462 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y); 1349 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
1463 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x); 1350 }
1464 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y);
1465 ++v22;
1466 }
1467 while ( v22 < a1->uNumVertices );
1468 } 1351 }
1469 } 1352 }
1470 else 1353 else
1471 { 1354 {
1472 if ( BYTE1(a1->uAttributes) & 2 ) 1355 if ( face->uAttributes & FACE_XZ_PLANE )
1473 { 1356 {
1474 v23 = (signed __int16)a3; 1357 v23 = (signed __int16)a3;
1475 v24 = a4; 1358 v24 = a4;
1476 if ( a1->uNumVertices ) 1359 if ( face->uNumVertices )
1477 { 1360 {
1478 a4b = &pOutdoor->pBModels[a2].pVertices.pVertices; 1361 for ( v22 = 0; v22 < face->uNumVertices; ++v22 )
1479 do
1480 { 1362 {
1481 //v7 = 2 * v22; 1363 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pXInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].x);
1482 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x); 1364 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
1483 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z); 1365 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pXInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].x);
1484 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x); 1366 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
1485 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z);
1486 ++v22;
1487 } 1367 }
1488 while ( v22 < a1->uNumVertices );
1489 } 1368 }
1490 } 1369 }
1491 else 1370 else
1492 { 1371 {
1493 v23 = SHIWORD(a3); 1372 v23 = SHIWORD(a3);
1494 v24 = a4; 1373 v24 = a4;
1495 if ( a1->uNumVertices ) 1374 if ( face->uNumVertices )
1496 { 1375 {
1497 a4c = &pOutdoor->pBModels[a2].pVertices.pVertices; 1376 for ( v22 = 0; v22 < face->uNumVertices; ++v22 )
1498 do
1499 { 1377 {
1500 //v9 = 2 * v22; 1378 word_720A70_intercepts_xs_plus_xs[2 * v22] = face->pYInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].y);
1501 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y); 1379 word_7209A0_intercepts_ys_plus_ys[2 * v22] = face->pZInterceptDisplacements[v22] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22]].z);
1502 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z); 1380 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = face->pYInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].y);
1503 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y); 1381 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = face->pZInterceptDisplacements[v22 + 1] + LOWORD(pOutdoor->pBModels[a2].pVertices.pVertices[face->pVertexIDs[v22 + 1]].z);
1504 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z);
1505 ++v22;
1506 } 1382 }
1507 while ( v22 < a1->uNumVertices ); 1383 }
1508 } 1384 }
1509 } 1385 }
1510 }
1511 v11 = 2 * a1->uNumVertices;
1512 a4d = 0; 1386 a4d = 0;
1513 word_720A70_intercepts_xs_plus_xs[2 * a1->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0]; 1387 word_720A70_intercepts_xs_plus_xs[2 * face->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0];
1514 word_7209A0_intercepts_ys_plus_ys[v11] = word_7209A0_intercepts_ys_plus_ys[0]; 1388 word_7209A0_intercepts_ys_plus_ys[2 * face->uNumVertices] = word_7209A0_intercepts_ys_plus_ys[0];
1515 v21 = 0;
1516 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24; 1389 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24;
1517 if ( v11 <= 0 ) 1390 if ( 2 * face->uNumVertices <= 0 )
1518 return 0; 1391 return 0;
1519 do 1392 for ( v21 = 0; v21 < 2 * face->uNumVertices; ++v21 )
1520 { 1393 {
1521 if ( a4d >= 2 ) 1394 if ( a4d >= 2 )
1522 break; 1395 break;
1523 v13 = v21; 1396 if ( v12 ^ (word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24) )
1524 v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1]; 1397 {
1525 if ( v12 ^ (v14 >= v24) ) 1398 if ( word_720A70_intercepts_xs_plus_xs[v21 + 1] >= v23 )
1526 {
1527 v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1];
1528 if ( v15 >= v23 )
1529 v16 = 0; 1399 v16 = 0;
1530 else 1400 else
1531 v16 = 2; 1401 v16 = 2;
1532 v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v13] < v23); 1402 v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v21] < v23);
1533 if ( v17 != 3 ) 1403 if ( v17 != 3 )
1534 { 1404 {
1405 v18 = word_720A70_intercepts_xs_plus_xs[v21 + 1] - word_720A70_intercepts_xs_plus_xs[v21];
1406 LODWORD(v19) = v18 << 16;
1407 HIDWORD(v19) = v18 >> 16;
1535 if ( !v17 1408 if ( !v17
1536 || (v18 = v15 - word_720A70_intercepts_xs_plus_xs[v13], 1409 || (word_720A70_intercepts_xs_plus_xs[v21] + ((signed int)(((unsigned __int64)(v19
1537 LODWORD(v19) = v18 << 16, 1410 / (word_7209A0_intercepts_ys_plus_ys[v21 + 1] - word_7209A0_intercepts_ys_plus_ys[v21])
1538 HIDWORD(v19) = v18 >> 16, 1411 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v21]) << 16)) >> 16)
1539 word_720A70_intercepts_xs_plus_xs[v13] 1412 + 32768) >> 16) >= v23) )
1540 + ((signed int)(((unsigned __int64)(v19
1541 / (v14 - word_7209A0_intercepts_ys_plus_ys[v13])
1542 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v13]) << 16)) >> 16)
1543 + 32768) >> 16) >= v23) )
1544 ++a4d; 1413 ++a4d;
1545 } 1414 }
1546 } 1415 }
1547 ++v21; 1416 v12 = word_7209A0_intercepts_ys_plus_ys[v21 + 1] >= v24;
1548 v12 = v14 >= v24; 1417 }
1549 }
1550 while ( v21 < v11 );
1551 result = 1; 1418 result = 1;
1552 if ( a4d != 1 ) 1419 if ( a4d != 1 )
1553 result = 0; 1420 result = 0;
1554 return result; 1421 return result;
1555 } 1422 }
1615 } 1482 }
1616 1483
1617 //----- (00475F30) -------------------------------------------------------- 1484 //----- (00475F30) --------------------------------------------------------
1618 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) 1485 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
1619 { 1486 {
1620 //BLVFace *v9; // ebx@1
1621 int v10; // ST20_4@2 1487 int v10; // ST20_4@2
1622 int v11; // ST28_4@2 1488 int v11; // ST28_4@2
1623 int v12; // ST24_4@2 1489 int v12; // ST24_4@2
1624 char v13; // zf@2 1490 char v13; // zf@2
1625 int v14; // edi@2 1491 int v14; // edi@2
1626 int v15; // eax@5
1627 signed int v16; // esi@5 1492 signed int v16; // esi@5
1628 int v17; // ST20_4@9 1493 int v17; // ST20_4@9
1629 signed __int64 v18; // qtt@10 1494 signed __int64 v18; // qtt@10
1630 int v19; // ST14_4@11 1495 int v19; // ST14_4@11
1631 //int *v21; // [sp+14h] [bp-10h]@1
1632 int v22; // [sp+1Ch] [bp-8h]@2 1496 int v22; // [sp+1Ch] [bp-8h]@2
1633 int v23; // [sp+1Ch] [bp-8h]@10 1497 int v23; // [sp+1Ch] [bp-8h]@10
1634 signed int v24; // [sp+20h] [bp-4h]@10 1498 signed int v24; // [sp+20h] [bp-4h]@10
1635 1499
1636 //v9 = a2;
1637 //v21 = a1;
1638 if ( a2->Ethereal() 1500 if ( a2->Ethereal()
1639 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16, 1501 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16,
1640 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16, 1502 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16,
1641 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16, 1503 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16,
1642 v13 = v10 + v12 + v11 == 0, 1504 v13 = v10 + v12 + v11 == 0,
1643 v14 = v10 + v12 + v11, 1505 v14 = v10 + v12 + v11,
1644 v22 = v10 + v12 + v11, 1506 v22 = v10 + v12 + v11,
1645 v13) 1507 v13)
1646 || v14 > 0 && !a2->Portal()) 1508 || v14 > 0 && !a2->Portal())
1647 return 0; 1509 return 0;
1648 v15 = a4 * a2->pFacePlane_old.vNormal.y; 1510 v16 = -(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
1649 v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z);
1650 if ( v14 <= 0 ) 1511 if ( v14 <= 0 )
1651 { 1512 {
1652 if ( a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 ) 1513 if ( a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 )
1653 return 0; 1514 return 0;
1654 } 1515 }
1655 else 1516 else
1656 { 1517 {
1657 if ( v16 < 0 ) 1518 if ( v16 < 0 )
1658 return 0; 1519 return 0;
1659 } 1520 }
1660 v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14; 1521 v17 = abs(-(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14;
1661 if ( v17 > abs(v14) 1522 if ( v17 > abs(v14)
1662 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16) 1523 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16)
1663 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16), 1524 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16),
1664 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16), 1525 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16),
1665 !sub_4759C9(a2, a9, v19, 1526 !sub_4759C9(a2, a9, v19,
1724 int v37; // [sp+C8h] [bp-10h]@6 1585 int v37; // [sp+C8h] [bp-10h]@6
1725 int v38; // [sp+CCh] [bp-Ch]@1 1586 int v38; // [sp+CCh] [bp-Ch]@1
1726 float v39; // [sp+D0h] [bp-8h]@6 1587 float v39; // [sp+D0h] [bp-8h]@6
1727 int *v40; // [sp+D4h] [bp-4h]@2 1588 int *v40; // [sp+D4h] [bp-4h]@2
1728 1589
1590 __debugbreak();//
1729 v2 = (char *)&this->field_64[4 * this->uNumVertices]; 1591 v2 = (char *)&this->field_64[4 * this->uNumVertices];
1730 v38 = 0; 1592 v38 = 0;
1731 *(int *)v2 = this->field_64[0]; 1593 *(int *)v2 = this->field_64[0];
1732 v2 += 4; 1594 v2 += 4;
1733 *(int *)v2 = this->field_64[1]; 1595 *(int *)v2 = this->field_64[1];
1871 int v37; // [sp+C8h] [bp-10h]@6 1733 int v37; // [sp+C8h] [bp-10h]@6
1872 int v38; // [sp+CCh] [bp-Ch]@1 1734 int v38; // [sp+CCh] [bp-Ch]@1
1873 float v39; // [sp+D0h] [bp-8h]@6 1735 float v39; // [sp+D0h] [bp-8h]@6
1874 int *v40; // [sp+D4h] [bp-4h]@2 1736 int *v40; // [sp+D4h] [bp-4h]@2
1875 1737
1738 __debugbreak();//
1876 v2 = (char *)&this->field_64[4 * this->uNumVertices]; 1739 v2 = (char *)&this->field_64[4 * this->uNumVertices];
1877 v38 = 0; 1740 v38 = 0;
1878 *(int *)v2 = this->field_64[0]; 1741 *(int *)v2 = this->field_64[0];
1879 v2 += 4; 1742 v2 += 4;
1880 *(int *)v2 = this->field_64[1]; 1743 *(int *)v2 = this->field_64[1];
2020 float v39; // [sp+28h] [bp-8h]@9 1883 float v39; // [sp+28h] [bp-8h]@9
2021 float v40; // [sp+28h] [bp-8h]@16 1884 float v40; // [sp+28h] [bp-8h]@16
2022 float v41; // [sp+2Ch] [bp-4h]@6 1885 float v41; // [sp+2Ch] [bp-4h]@6
2023 float v42; // [sp+2Ch] [bp-4h]@9 1886 float v42; // [sp+2Ch] [bp-4h]@9
2024 1887
2025 //v1 = this; 1888 __debugbreak();//
2026 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 1889 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
2027 { 1890 {
2028 v2 = 0; 1891 v2 = 0;
2029 if ( this->uNumVertices > 0 ) 1892 if ( this->uNumVertices > 0 )
2030 { 1893 {
2131 1994
2132 //----- (00477F63) -------------------------------------------------------- 1995 //----- (00477F63) --------------------------------------------------------
2133 bool stru6_stru1_indoor_sw_billboard::sub_477F63() 1996 bool stru6_stru1_indoor_sw_billboard::sub_477F63()
2134 { 1997 {
2135 signed int v1; // ebx@1 1998 signed int v1; // ebx@1
2136 stru6_stru1_indoor_sw_billboard *v2; // esi@1
2137 double v3; // st7@2 1999 double v3; // st7@2
2138 int v4; // edx@4 2000 int v4; // edx@4
2139 char *v5; // ecx@5 2001 char *v5; // ecx@5
2140 int v6; // edi@5 2002 int v6; // edi@5
2141 float v7; // ST08_4@13 2003 float v7; // ST08_4@13
2142 signed int v9; // [sp+Ch] [bp-8h]@1 2004 signed int v9; // [sp+Ch] [bp-8h]@1
2143 float v10; // [sp+10h] [bp-4h]@2 2005 float v10; // [sp+10h] [bp-4h]@2
2144 2006
2145 stru6_stru1_indoor_sw_billboard* a1 = this; 2007 __debugbreak();// - sw hw?
2146
2147 v1 = 0; 2008 v1 = 0;
2148 v2 = a1;
2149 v9 = 0; 2009 v9 = 0;
2150 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 2010 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
2151 { 2011 {
2152 v10 = 16192.0; 2012 v10 = 16192.0;
2153 v3 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789; 2013 v3 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789;
2155 else 2015 else
2156 { 2016 {
2157 v10 = (double)pODMRenderParams->shading_dist_mist; 2017 v10 = (double)pODMRenderParams->shading_dist_mist;
2158 v3 = 8.0; 2018 v3 = 8.0;
2159 } 2019 }
2160 v4 = a1->uNumVertices; 2020 v4 = this->uNumVertices;
2161 if ( v4 <= 0 ) 2021 if ( v4 <= 0 )
2162 { 2022 {
2163 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); 2023 memcpy(&this->field_14[40], &this->field_14[20], 16 * v4);
2164 return v2->uNumVertices != 0; 2024 return this->uNumVertices != 0;
2165 } 2025 }
2166 v5 = (char *)&a1->field_14[20]; 2026 v5 = (char *)&this->field_14[20];
2167 v6 = v4; 2027 for ( v6 = v4; v6; --v6 )
2168 do
2169 { 2028 {
2170 if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 ) 2029 if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 )
2171 { 2030 {
2172 if ( v3 < *(float *)v5 ) 2031 if ( v3 < *(float *)v5 )
2173 v9 = 1; 2032 v9 = 1;
2174 else 2033 else
2175 v1 = 1; 2034 v1 = 1;
2176 } 2035 }
2177 v5 += 16; 2036 v5 += 16;
2178 --v6; 2037 }
2179 }
2180 while ( v6 );
2181 if ( !v1 ) 2038 if ( !v1 )
2182 { 2039 {
2183 if ( v9 ) 2040 if ( v9 )
2184 { 2041 {
2185 v2->_477927(v10); 2042 this->_477927(v10);
2186 return v2->uNumVertices != 0; 2043 return this->uNumVertices != 0;
2187 } 2044 }
2188 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); 2045 memcpy(&this->field_14[40], &this->field_14[20], 16 * v4);
2189 return v2->uNumVertices != 0; 2046 return this->uNumVertices != 0;
2190 } 2047 }
2191 v7 = v3; 2048 v7 = v3;
2192 _4775ED(v7); 2049 _4775ED(v7);
2193 return v2->uNumVertices != 0; 2050 return this->uNumVertices != 0;
2194 } 2051 }
2195 2052
2196 //----- (0047802A) -------------------------------------------------------- 2053 //----- (0047802A) --------------------------------------------------------
2197 int stru6_stru1_indoor_sw_billboard::sub_47802A() 2054 int stru6_stru1_indoor_sw_billboard::sub_47802A()
2198 { 2055 {
2199 double v6; // st7@4 2056 double v6; // st7@4
2200 double v12; // st7@16
2201 signed int v16; // [sp+38h] [bp-Ch]@1 2057 signed int v16; // [sp+38h] [bp-Ch]@1
2202 int a6; // [sp+3Ch] [bp-8h]@5 2058 int a6; // [sp+3Ch] [bp-8h]@5
2203 int a5; // [sp+40h] [bp-4h]@5 2059 int a5; // [sp+40h] [bp-4h]@5
2204 2060
2205 stru6_stru1_indoor_sw_billboard* a1 = this; 2061 __debugbreak(); // this->field_B4[i*4+16]
2206
2207 v16 = 0; 2062 v16 = 0;
2208 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 2063 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
2209 { 2064 {
2210 for(int i = 0; i < a1->uNumVertices; i++) 2065 for(int i = 0; i < this->uNumVertices; i++)
2211 { 2066 {
2212 v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / a1->field_B4[i*4]; 2067 v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / this->field_B4[i*4];
2213 if ( pRenderer->pRenderD3D ) 2068 if ( pRenderer->pRenderD3D )
2214 { 2069 {
2215 pGame->pIndoorCameraD3D->Project( 2070 pGame->pIndoorCameraD3D->Project(round_to_int(this->field_B4[i*4]), round_to_int(this->field_B4[i*4+1]), round_to_int(this->field_B4[i*4+2]),
2216 round(a1->field_B4[i*4]), 2071 &a5, &a6);
2217 round(a1->field_B4[i*4+1]), 2072 this->field_B4[i*4+16] = (double)a5;
2218 round(a1->field_B4[i*4+2]), 2073 this->field_B4[i*4+17] = (double)a6;
2219 &a5, 2074 this->field_B4[i*4+18] = round_to_int(this->field_B4[i*4]);
2220 &a6); 2075 }
2221 a1->field_B4[i*4+16] = (double)a5; 2076 else
2222 a1->field_B4[i*4+17] = (double)a6; 2077 {
2223 a1->field_B4[i*4+18] = round(a1->field_B4[i*4]); 2078 this->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * this->field_B4[i*4+1];
2224 } 2079 this->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * this->field_B4[i*4+2];
2225 else 2080 this->field_B4[i*4+18] = this->field_B4[i*4];
2226 { 2081 }
2227 a1->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * a1->field_B4[i*4+1]; 2082 this->field_B4[i*4+19] = this->field_B4[i*4+3];
2228 a1->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * a1->field_B4[i*4+2]; 2083 if ( (double)(signed int)pViewport->uViewportTL_X <= this->field_B4[i*4+16] && (double)(signed int)pViewport->uViewportBR_X > this->field_B4[i*4+16]
2229 a1->field_B4[i*4+18] = a1->field_B4[i*4]; 2084 && (double)(signed int)pViewport->uViewportTL_Y <= this->field_B4[i*4+17] && (double)(signed int)pViewport->uViewportBR_Y > this->field_B4[i*4+17] )
2230 } 2085 v16 = 1;
2231 a1->field_B4[i*4+19] = a1->field_B4[i*4+3];
2232 if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+16]
2233 && (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+16]
2234 && (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+17]
2235 && (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+17] )
2236 v16 = 1;
2237 } 2086 }
2238 } 2087 }
2239 else 2088 else
2240 { 2089 {
2241 for(int i = 0; i < a1->uNumVertices; i++) 2090 for(int i = 0; i < this->uNumVertices; i++)
2242 { 2091 {
2243 v12 = (double)pODMRenderParams->int_fov_rad / a1->field_B4[i*4]; 2092 this->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - (double)pODMRenderParams->int_fov_rad / this->field_B4[i*4] * this->field_B4[i*4+1];
2244 a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1]; 2093 this->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - (double)pODMRenderParams->int_fov_rad / this->field_B4[i*4] * this->field_B4[i*4+2];
2245 a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2]; 2094 *((int *)&this->field_B4[i*4+22]) = (int)this->field_B4[i*4];
2246 *((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4]; 2095 *((int *)&this->field_B4[i*4+23]) = this->field_B4[i*4+3];
2247 *((int *)&a1->field_B4[i*4+23]) = a1->field_B4[i*4+3]; 2096 if ( (double)(signed int)pViewport->uViewportTL_X <= this->field_B4[i*4+20] && (double)(signed int)pViewport->uViewportBR_X > this->field_B4[i*4+20]
2248 if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+20] 2097 && (double)(signed int)pViewport->uViewportTL_Y <= this->field_B4[i*4+21] && (double)(signed int)pViewport->uViewportBR_Y > this->field_B4[i*4+21] )
2249 && (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+20] 2098 v16 = 1;
2250 && (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+21]
2251 && (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+21] )
2252 v16 = 1;
2253 } 2099 }
2254 } 2100 }
2255 return v16; 2101 return v16;
2256 } 2102 }
2257 2103
2258 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag; 2104 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag;
2259 2105
2260 //----- (00479089) -------------------------------------------------------- 2106 //----- (00479089) --------------------------------------------------------
2261 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable) 2107 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable)
2262 { 2108 {
2263 BSPModel *v2; // eax@1
2264 int v3; // edi@1 2109 int v3; // edi@1
2265 int v4; // ebx@1 2110 int v4; // ebx@1
2266 int v5; // ST28_4@1
2267 int v6; // ecx@1
2268 int v7; // ebx@3
2269 int v8; // eax@3
2270 int v9; // eax@3 2111 int v9; // eax@3
2271 //int v10; // ebx@3
2272 signed int v11; // esi@6 2112 signed int v11; // esi@6
2273 int v12; // esi@8 2113 int v12; // esi@8
2274 bool result; // eax@9 2114 bool result; // eax@9
2275 //unsigned int v14; // [sp+Ch] [bp-20h]@1
2276 int v15; // [sp+Ch] [bp-20h]@5
2277 //int *v16; // [sp+10h] [bp-1Ch]@1
2278 int v17; // [sp+1Ch] [bp-10h]@1 2115 int v17; // [sp+1Ch] [bp-10h]@1
2279 int v18; // [sp+20h] [bp-Ch]@1
2280 int v19; // [sp+20h] [bp-Ch]@3 2116 int v19; // [sp+20h] [bp-Ch]@3
2281 int angle; // [sp+24h] [bp-8h]@1 2117 int angle; // [sp+24h] [bp-8h]@1
2282 int v21; // [sp+28h] [bp-4h]@1 2118
2283 //int v22; // [sp+28h] [bp-4h]@3 2119 angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 / 2;
2284 2120 v3 = pOutdoor->pBModels[uModelID].vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
2285 //v16 = unused; 2121 v4 = pOutdoor->pBModels[uModelID].vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
2286 angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 >> 1;
2287 //v14 = uModelID;
2288 v2 = &pOutdoor->pBModels[uModelID];
2289 v3 = v2->vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x;
2290 v4 = v2->vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y;
2291 v5 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY);
2292 v21 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
2293 v18 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX);
2294 stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX); 2122 stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX);
2295 v6 = v5; 2123 v17 = v3 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) + v4 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
2296 v17 = v3 * v5 + v4 * v21;
2297 if (pGame->pIndoorCameraD3D->sRotationX) 2124 if (pGame->pIndoorCameraD3D->sRotationX)
2298 v17 = (unsigned __int64)(v17 * (signed __int64)v18) >> 16; 2125 v17 = (unsigned __int64)(v17 * (signed __int64)stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX)) >> 16;
2299 v19 = v4 * v6 - v3 * v21; 2126 v19 = v4 * stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) - v3 * stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY);
2300 v7 = abs(v4); 2127 v9 = int_get_vector_length(abs(v3), abs(v4), 0);
2301 v8 = abs(v3);
2302 v9 = int_get_vector_length(v8, v7, 0);
2303 //v10 = v14 * 188; 2128 //v10 = v14 * 188;
2304 //v22 = v9; 2129 //v22 = v9;
2305 *reachable = false; 2130 *reachable = false;
2306 if ( v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256 ) 2131 if ( v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256 )
2307 *reachable = true; 2132 *reachable = true;
2308 v15 = stru_5C6E00->Sin(angle);
2309 if ( v19 >= 0 ) 2133 if ( v19 >= 0 )
2310 v11 = ((unsigned __int64)(v15 * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16); 2134 v11 = ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16);
2311 else 2135 else
2312 v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(v15 * (signed __int64)v17) >> 16); 2136 v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)v17) >> 16);
2313 v12 = v11 >> 16; 2137 v12 = v11 >> 16;
2314 if ( v9 <= pODMRenderParams->shading_dist_mist + 2048 ) 2138 if ( v9 <= pODMRenderParams->shading_dist_mist + 2048 )
2315 { 2139 {
2316 //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 ) 2140 //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 )
2317 if ( abs(v12) > pOutdoor->pBModels[uModelID].sBoundingRadius + 512 ) 2141 if ( abs(v12) > pOutdoor->pBModels[uModelID].sBoundingRadius + 512 )
2327 } 2151 }
2328 2152
2329 //----- (00479295) -------------------------------------------------------- 2153 //----- (00479295) --------------------------------------------------------
2330 int Polygon::_479295() 2154 int Polygon::_479295()
2331 { 2155 {
2332 ODMFace *v2; // esi@1
2333 int v3; // ecx@4 2156 int v3; // ecx@4
2334 int v4; // eax@4 2157 int v4; // eax@4
2335 int v5; // edx@4 2158 int v5; // edx@4
2336 int v6; // ST14_4@5 2159 int v6; // ST14_4@5
2337 int v7; // ST04_4@5
2338 stru149 *v8; // ecx@5
2339 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8 2160 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
2340 int v11; // [sp+18h] [bp-4h]@4 2161 int v11; // [sp+18h] [bp-4h]@4
2341 2162
2342 v2 = this->pODMFace; 2163 if ( !this->pODMFace->pFacePlane.vNormal.z )
2343 if ( !v2->pFacePlane.vNormal.z ) 2164 {
2344 { 2165 v3 = this->pODMFace->pFacePlane.vNormal.x;
2345 v3 = v2->pFacePlane.vNormal.x; 2166 v4 = -this->pODMFace->pFacePlane.vNormal.y;
2346 v4 = -v2->pFacePlane.vNormal.y;
2347 v5 = 0; 2167 v5 = 0;
2348 v11 = 65536; 2168 v11 = 65536;
2349 } 2169 }
2350 else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) 2170 else if ( (this->pODMFace->pFacePlane.vNormal.x || this->pODMFace->pFacePlane.vNormal.y)
2351 { 2171 && abs(this->pODMFace->pFacePlane.vNormal.z) < 59082 )
2352 thisa.x = -v2->pFacePlane.vNormal.y; 2172 {
2353 thisa.y = v2->pFacePlane.vNormal.x; 2173 thisa.x = -this->pODMFace->pFacePlane.vNormal.y;
2174 thisa.y = this->pODMFace->pFacePlane.vNormal.x;
2354 thisa.z = 0; 2175 thisa.z = 0;
2355 thisa.Normalize_float(); 2176 thisa.Normalize_float();
2356 v4 = thisa.x; 2177 v4 = thisa.x;
2357 v3 = thisa.y; 2178 v3 = thisa.y;
2358 v5 = 0; 2179 v5 = 0;
2363 v3 = 0; 2184 v3 = 0;
2364 v4 = 65536; 2185 v4 = 65536;
2365 v11 = 0; 2186 v11 = 0;
2366 v5 = -65536; 2187 v5 = -65536;
2367 } 2188 }
2368 v6 = v11; 2189 sTextureDeltaU = this->pODMFace->sTextureDeltaU;
2369 sTextureDeltaU = v2->sTextureDeltaU; 2190 sTextureDeltaV = this->pODMFace->sTextureDeltaV;
2370 v7 = v3; 2191 ptr_38->_48616B_frustum_odm(v4, v3, 0, 0, v5, v11);
2371 v8 = ptr_38;
2372 sTextureDeltaV = v2->sTextureDeltaV;
2373 v8->_48616B_frustum_odm(v4, v7, 0, 0, v5, v6);
2374 return 1; 2192 return 1;
2375 } 2193 }
2376 2194
2377 2195
2378 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr) 2196 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr)
3375 } 3193 }
3376 3194
3377 //----- (0048257A) -------------------------------------------------------- 3195 //----- (0048257A) --------------------------------------------------------
3378 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater) 3196 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater)
3379 { 3197 {
3380 //unsigned int v4; // ebx@1
3381 //unsigned int v5; // edi@1
3382 int result; // eax@9 3198 int result; // eax@9
3383 //int v7; // ebx@10
3384 int v8; // ebx@11 3199 int v8; // ebx@11
3385 int v9; // eax@11 3200 int v9; // eax@11
3386 int v10; // ecx@11 3201 int v10; // ecx@11
3387 //int v11; // [sp+Ch] [bp-Ch]@1
3388 //int v12; // [sp+10h] [bp-8h]@1
3389 int v13; // [sp+10h] [bp-8h]@11 3202 int v13; // [sp+10h] [bp-8h]@11
3390 signed int v14; // [sp+14h] [bp-4h]@3 3203 signed int v14; // [sp+14h] [bp-4h]@3
3391 int v15; // [sp+24h] [bp+Ch]@11 3204 int v15; // [sp+24h] [bp+Ch]@11
3392 3205
3393 //v11 = a1;
3394 //v12 = a2;
3395 unsigned int grid_x = WorldPosToGridCellX(a1); 3206 unsigned int grid_x = WorldPosToGridCellX(a1);
3396 unsigned int grid_z = WorldPosToGridCellZ(a2) - 1; 3207 unsigned int grid_z = WorldPosToGridCellZ(a2) - 1;
3397 3208
3398 int grid_x1 = GridCellToWorldPosX(grid_x), 3209 int grid_x1 = GridCellToWorldPosX(grid_x),
3399 grid_x2 = GridCellToWorldPosX(grid_x + 1); 3210 grid_x2 = GridCellToWorldPosX(grid_x + 1);
3448 } 3259 }
3449 else 3260 else
3450 return y_x1z1; 3261 return y_x1z1;
3451 } 3262 }
3452 3263
3453
3454
3455
3456
3457 //----- (00485F53) -------------------------------------------------------- 3264 //----- (00485F53) --------------------------------------------------------
3458 void sr_485F53(Vec2_int_ *v) 3265 void sr_485F53(Vec2_int_ *v)
3459 { 3266 {
3460 ++v->y; 3267 ++v->y;
3461 if ( v->y > 1000 ) 3268 if ( v->y > 1000 )
3470 } 3277 }
3471 3278
3472 //----- (00486089) -------------------------------------------------------- 3279 //----- (00486089) --------------------------------------------------------
3473 void Polygon::_normalize_v_18() 3280 void Polygon::_normalize_v_18()
3474 { 3281 {
3475 double v2; // st7@1 3282 //double v2; // st7@1
3476 double v3; // st6@1 3283 //double v3; // st6@1
3477 double v5; // st5@1 3284 //double v5; // st5@1
3478 3285
3479 //v1 = this; 3286 // v2 = (double)this->v_18.x;
3480 v2 = (double)this->v_18.x; 3287 //v3 = (double)this->v_18.y;
3481 v3 = (double)this->v_18.y; 3288 // v5 = (double)this->v_18.z;
3482 v5 = (double)this->v_18.z; 3289 float len = sqrt((double)this->v_18.z * (double)this->v_18.z + (double)this->v_18.y * (double)this->v_18.y + (double)this->v_18.x * (double)this->v_18.x);
3483 float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2);
3484 if (fabsf(len) < 1e-6f) 3290 if (fabsf(len) < 1e-6f)
3485 { 3291 {
3486 v_18.x = 0; 3292 v_18.x = 0;
3487 v_18.y = 0; 3293 v_18.y = 0;
3488 v_18.z = 65536; 3294 v_18.z = 65536;
3489 } 3295 }
3490 else 3296 else
3491 { 3297 {
3492 v_18.x = round(v2 / len * 65536.0); 3298 v_18.x = round_to_int((double)this->v_18.x / len * 65536.0);
3493 v_18.y = round(v3 / len * 65536.0); 3299 v_18.y = round_to_int((double)this->v_18.y / len * 65536.0);
3494 v_18.y = round(v5 / len * 65536.0); 3300 v_18.y = round_to_int((double)this->v_18.z / len * 65536.0);
3495 } 3301 }
3496 } 3302 }
3497 3303
3498 //----- (0048616B) -------------------------------------------------------- 3304 //----- (0048616B) --------------------------------------------------------
3499 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7) 3305 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7)
3500 { 3306 {
3501 int v7; // ebx@1 3307 int v7; // ebx@1
3502 //int v8; // esi@1
3503 int v9; // edi@1 3308 int v9; // edi@1
3504 //int v10; // eax@1
3505 int v11; // edx@1 3309 int v11; // edx@1
3506 //int v12; // esi@2
3507 //int v13; // eax@2
3508 //int v14; // ST10_4@3
3509 //int v15; // esi@3
3510 //int v16; // eax@5
3511 int v17; // ST0C_4@6 3310 int v17; // ST0C_4@6
3512 //int v18; // eax@8
3513 int v19; // ST0C_4@9 3311 int v19; // ST0C_4@9
3514 //int v20; // eax@10
3515 //int v21; // edx@10
3516 //int v22; // eax@10
3517 //int result; // eax@10
3518 int v24; // [sp+14h] [bp-14h]@1 3312 int v24; // [sp+14h] [bp-14h]@1
3519 int v25; // [sp+18h] [bp-10h]@1 3313 int v25; // [sp+18h] [bp-10h]@1
3520 //int v26; // [sp+1Ch] [bp-Ch]@1
3521 int v27; // [sp+24h] [bp-4h]@1 3314 int v27; // [sp+24h] [bp-4h]@1
3522 //int v28; // [sp+30h] [bp+8h]@10
3523 //int v29; // [sp+3Ch] [bp+14h]@10
3524 3315
3525 v25 = pGame->pIndoorCameraD3D->int_cosine_x; 3316 v25 = pGame->pIndoorCameraD3D->int_cosine_x;
3526 v7 = pGame->pIndoorCameraD3D->int_sine_y; 3317 v7 = pGame->pIndoorCameraD3D->int_sine_y;
3527 v27 = pGame->pIndoorCameraD3D->int_sine_x; 3318 v27 = pGame->pIndoorCameraD3D->int_sine_x;
3528 //v8 = -pIndoorCamera->pos.y; 3319 //v8 = -pIndoorCamera->pos.y;
3937 for (uint i = 0; i < uLevelStrFileSize; ++i) 3728 for (uint i = 0; i < uLevelStrFileSize; ++i)
3938 { 3729 {
3939 if ( !pLevelStr[i] ) 3730 if ( !pLevelStr[i] )
3940 { 3731 {
3941 pLevelStrOffsets[string_num] = i + 1; 3732 pLevelStrOffsets[string_num] = i + 1;
3942 ++string_num; 3733 ++string_num;
3943 if ( i - prev_string_offset > max_string_length ) 3734 if ( i - prev_string_offset > max_string_length )
3944 max_string_length = i - prev_string_offset; 3735 max_string_length = i - prev_string_offset;
3945 prev_string_offset = i; 3736 prev_string_offset = i;
3946 } 3737 }
3947 } 3738 }
3966 _evt_raw *test_event; 3757 _evt_raw *test_event;
3967 if ( uLevelEVT_NumEvents > 0 ) 3758 if ( uLevelEVT_NumEvents > 0 )
3968 { 3759 {
3969 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) 3760 for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
3970 { 3761 {
3971 test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT]; 3762 test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT];
3972 if ( test_event->_e_type == EVENT_OnMapLeave ) 3763 if ( test_event->_e_type == EVENT_OnMapLeave )
3973 { 3764 {
3974 EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num); 3765 EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num);
3975 } 3766 }
3976 } 3767 }
3978 } 3769 }
3979 3770
3980 //----- (00443FDC) -------------------------------------------------------- 3771 //----- (00443FDC) --------------------------------------------------------
3981 void OnMapLoad() 3772 void OnMapLoad()
3982 { 3773 {
3983 stru176 *v3; // esi@7 3774 __int16 v4; // cx@9
3984 __int16 v4; // cx@9 3775 __int16 v5; // di@9
3985 __int16 v5; // di@9 3776 int v6; // eax@9
3986 int v6; // eax@9 3777 signed __int64 v8; // qax@26
3987 signed __int64 v8; // qax@26 3778 unsigned int v9; // ecx@26
3988 unsigned int v9; // ecx@26 3779 signed __int64 v10; // qax@26
3989 signed __int64 v10; // qax@26 3780 signed __int64 v11; // qax@26
3990 signed __int64 v11; // qax@26 3781 int v12; // ST50_4@26
3991 int v12; // ST50_4@26 3782 signed __int64 v13; // qax@26
3992 signed __int64 v13; // qax@26 3783 signed __int64 v14; // qax@26
3993 signed __int64 v14; // qax@26 3784 int v15; // ST58_4@26
3994 int v15; // ST58_4@26 3785 signed __int64 v16; // qax@26
3995 signed __int64 v16; // qax@26 3786 int hours; // ebx@26
3996 int hours; // ebx@26 3787 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
3997 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 3788 signed __int64 seconds; // [sp+14h] [bp-3Ch]@26
3998 signed __int64 seconds; // [sp+14h] [bp-3Ch]@26 3789 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
3999 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 3790 int minutes; // [sp+2Ch] [bp-24h]@26
4000 int minutes; // [sp+2Ch] [bp-24h]@26 3791 int years; // [sp+34h] [bp-1Ch]@26
4001 int years; // [sp+34h] [bp-1Ch]@26 3792 int weeks; // [sp+38h] [bp-18h]@26
4002 int weeks; // [sp+38h] [bp-18h]@26 3793 int v26; // [sp+3Ch] [bp-14h]@15
4003 int v26; // [sp+3Ch] [bp-14h]@15 3794 int days; // [sp+3Ch] [bp-14h]@26
4004 int days; // [sp+3Ch] [bp-14h]@26 3795 int months; // [sp+40h] [bp-10h]@26
4005 int months; // [sp+40h] [bp-10h]@26 3796 __int16 v29; // [sp+46h] [bp-Ah]@9
4006 __int16 v29; // [sp+46h] [bp-Ah]@9 3797 __int16 v30; // [sp+48h] [bp-8h]@9
4007 __int16 v30; // [sp+48h] [bp-8h]@9 3798 __int16 v31; // [sp+4Ah] [bp-6h]@9
4008 __int16 v31; // [sp+4Ah] [bp-6h]@9 3799 __int16 v32; // [sp+4Ch] [bp-4h]@9
4009 __int16 v32; // [sp+4Ch] [bp-4h]@9 3800 __int16 v33; // [sp+4Eh] [bp-2h]@9
4010 __int16 v33; // [sp+4Eh] [bp-2h]@9 3801
4011 3802 for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
4012 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) 3803 {
4013 { 3804 EventIndex pEvent = pLevelEVT_Index[i];
4014 EventIndex pEvent = pLevelEVT_Index[i]; 3805
4015 3806 _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]);
4016 _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); 3807
4017 3808 if (_evt->_e_type == EVENT_PlaySound)
4018 if (_evt->_e_type == EVENT_PlaySound) 3809 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
4019 { 3810 else if (_evt->_e_type == EVENT_OnMapReload)
4020 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); 3811 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num);
4021 } 3812 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize)
4022 else if (_evt->_e_type == EVENT_OnMapReload) 3813 {
4023 { 3814 //v3 = &array_5B5928_timers[dword_5B65C8_timers_count];
4024 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); 3815 v20 = pOutdoor->loc_time.uLastVisitDay;
4025 } 3816 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
4026 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) 3817 v20 = pIndoor->stru1.uLastVisitDay;
4027 { 3818
4028 v3 = &array_5B5928_timers[dword_5B65C8_timers_count]; 3819 array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type = _evt->_e_type;
4029 v20 = pOutdoor->loc_time.uLastVisitDay; 3820 array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_ID = pEvent.uEventID;
4030 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) 3821 array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_seq_num = pEvent.event_sequence_num;
4031 v20 = pIndoor->stru1.uLastVisitDay; 3822
4032 3823 array_5B5928_timers[dword_5B65C8_timers_count].field_10 = _evt->v5;
4033 v3->timer_evt_type = _evt->_e_type; 3824 array_5B5928_timers[dword_5B65C8_timers_count].field_12 = _evt->v6;
4034 v3->timer_evt_ID = pEvent.uEventID; 3825 array_5B5928_timers[dword_5B65C8_timers_count].field_14 = _evt->v7;
4035 v3->timer_evt_seq_num = pEvent.event_sequence_num; 3826 array_5B5928_timers[dword_5B65C8_timers_count].field_16 = _evt->v8;
4036 3827 array_5B5928_timers[dword_5B65C8_timers_count].field_18 = _evt->v9;
4037 v3->field_10 = _evt->v5; 3828 array_5B5928_timers[dword_5B65C8_timers_count].field_1A = _evt->v10;
4038 v3->field_12 = _evt->v6; 3829
4039 v3->field_14 = _evt->v7; 3830
4040 v3->field_16 = _evt->v8; 3831 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
4041 v3->field_18 = _evt->v9; 3832
4042 v3->field_1A = _evt->v10; 3833 array_5B5928_timers[dword_5B65C8_timers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11;
4043 3834 array_5B5928_timers[dword_5B65C8_timers_count].fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11;
4044 3835 if (array_5B5928_timers[dword_5B65C8_timers_count].timer_evt_type == EVENT_Initialize && !(short)v6 )
4045 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; 3836 {
4046 3837 if ( v20 )
4047 v3->time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; 3838 v18 = pParty->uTimePlayed - v20;
4048 v3->fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11; 3839 else
4049 if (v3->timer_evt_type == EVENT_Initialize && !(short)v6 ) 3840 v18 = 0i64;
4050 { 3841 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
4051 if ( v20 ) 3842
4052 v18 = pParty->uTimePlayed - v20; 3843 if ( v26 / 7 / 4 / 12 )
4053 else 3844 {
4054 v18 = 0i64; 3845 if ( array_5B5928_timers[dword_5B65C8_timers_count].field_10 )
4055 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; 3846 {
4056 3847 ++dword_5B65C8_timers_count;
4057 if ( v26 / 7 / 4 / 12 ) 3848 array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = 0;
4058 { 3849 continue;
4059 if ( v3->field_10 ) 3850 }
4060 { 3851 }
4061 ++dword_5B65C8_timers_count; 3852 if (v26 / 7 / 4 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_12 != 0 ||
4062 v3->next_fire_time = 0; 3853 v26 / 7 != 0 && array_5B5928_timers[dword_5B65C8_timers_count].field_14 != 0 ||
4063 continue; 3854 v26 != 0 || !v20)
4064 } 3855 {
4065 } 3856 ++dword_5B65C8_timers_count;
4066 if (v26 / 7 / 4 != 0 && v3->field_12 != 0 || 3857 array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = 0;
4067 v26 / 7 != 0 && v3->field_14 != 0 || 3858 continue;
4068 v26 != 0 || !v20) 3859 }
4069 { 3860 }
4070 ++dword_5B65C8_timers_count; 3861 else
4071 v3->next_fire_time = 0; 3862 {
4072 continue; 3863 v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375);
4073 } 3864 v9 = v8;
4074 } 3865 v10 = (signed int)v8 / 60;
4075 else 3866 minutes = v10 % 60;
4076 { 3867 v11 = (signed int)(v10 / 60);
4077 v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); 3868 v12 = v11 % 24;
4078 v9 = v8; 3869 v13 = (signed int)(v11 / 24);
4079 v10 = (signed int)v8 / 60; 3870 days = v13 % 7;
4080 minutes = v10 % 60; 3871 v14 = (signed int)(v13 / 7);
4081 v11 = (signed int)(v10 / 60); 3872 v15 = v14 % 4;
4082 v12 = v11 % 24; 3873 v16 = (signed int)(v14 / 4);
4083 v13 = (signed int)(v11 / 24); 3874 years = v16 / 12;
4084 days = v13 % 7; 3875
4085 v14 = (signed int)(v13 / 7); 3876 unsigned __int64 _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32;
4086 v15 = v14 % 4; 3877 __int64 _2 = ((__int64)v9 << 32) | _1;
4087 v16 = (signed int)(v14 / 4); 3878
4088 years = v16 / 12; 3879 seconds = _2 % 60;
4089 3880 //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32,
4090 unsigned __int64 _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32; 3881 // v9)
4091 __int64 _2 = ((__int64)v9 << 32) | _1; 3882 // % 60;
4092 3883
4093 seconds = _2 % 60; 3884 hours = v12;
4094 //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32, 3885 weeks = v15;
4095 // v9) 3886 months = v16 % 12;
4096 // % 60; 3887 if ( array_5B5928_timers[dword_5B65C8_timers_count].field_10 )
4097 3888 ++years;
4098 hours = v12; 3889 else
4099 weeks = v15; 3890 {
4100 months = v16 % 12; 3891 if ( array_5B5928_timers[dword_5B65C8_timers_count].field_12 )
4101 if ( v3->field_10 ) 3892 ++months;
4102 { 3893 else
4103 ++years; 3894 {
4104 } 3895 if ( array_5B5928_timers[dword_5B65C8_timers_count].field_14 )
4105 else 3896 ++weeks;
4106 { 3897 else
4107 if ( v3->field_12 ) 3898 {
4108 { 3899 ++days;
4109 ++months; 3900 minutes = array_5B5928_timers[dword_5B65C8_timers_count].field_18;
4110 } 3901 hours = array_5B5928_timers[dword_5B65C8_timers_count].field_16;
4111 else 3902 seconds = array_5B5928_timers[dword_5B65C8_timers_count].field_1A;
4112 { 3903 }
4113 if ( v3->field_14 ) 3904 }
4114 { 3905 }
4115 ++weeks; 3906 array_5B5928_timers[dword_5B65C8_timers_count].next_fire_time = (signed __int64)((double)((seconds
4116 } 3907 + 60 * minutes
4117 else 3908 + 3600 * hours
4118 { 3909 + 0x93A80 * weeks
4119 ++days; 3910 + 0x15180 * days
4120 minutes = v3->field_18; 3911 + 0x24EA00 * (months + 12i64 * years)) << 7)
4121 hours = v3->field_16; 3912 * 0.033333335);
4122 seconds = v3->field_1A; 3913
4123 } 3914 ++dword_5B65C8_timers_count;
4124 } 3915 }
4125 } 3916 }
4126 v3->next_fire_time = (signed __int64)((double)((seconds 3917 }
4127 + 60 * minutes
4128 + 3600 * hours
4129 + 0x93A80 * weeks
4130 + 0x15180 * days
4131 + 0x24EA00 * (months + 12i64 * years)) << 7)
4132 * 0.033333335);
4133
4134 ++dword_5B65C8_timers_count;
4135 }
4136 }
4137 }
4138 } 3918 }
4139 3919
4140 //----- (00444360) -------------------------------------------------------- 3920 //----- (00444360) --------------------------------------------------------
4141 void Level_LoadEvtAndStr(const char *pLevelName) 3921 void Level_LoadEvtAndStr(const char *pLevelName)
4142 { 3922 {
4152 } 3932 }
4153 3933
4154 //----- (00444D80) -------------------------------------------------------- 3934 //----- (00444D80) --------------------------------------------------------
4155 int GetTravelTime() 3935 int GetTravelTime()
4156 { 3936 {
4157 signed int v0; // esi@1 3937 signed int new_travel_time; // esi@1
4158 3938
4159 v0 = uDefaultTravelTime_ByFoot; 3939 new_travel_time = uDefaultTravelTime_ByFoot;
4160 if ( CheckHiredNPCSpeciality(Guide) ) 3940 if ( CheckHiredNPCSpeciality(Guide) )
4161 --v0; 3941 --new_travel_time;
4162 if ( CheckHiredNPCSpeciality(Tracker) ) 3942 if ( CheckHiredNPCSpeciality(Tracker) )
4163 v0 -= 2; 3943 new_travel_time -= 2;
4164 if ( CheckHiredNPCSpeciality(Pathfinder) ) 3944 if ( CheckHiredNPCSpeciality(Pathfinder) )
4165 v0 -= 3; 3945 new_travel_time -= 3;
4166 if ( CheckHiredNPCSpeciality(Explorer) ) 3946 if ( CheckHiredNPCSpeciality(Explorer) )
4167 --v0; 3947 --new_travel_time;
4168 if ( v0 < 1 ) 3948 if ( new_travel_time < 1 )
4169 v0 = 1; 3949 new_travel_time = 1;
4170 return v0; 3950 return new_travel_time;
4171 } 3951 }
4172 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; 3952 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot;
4173 3953
4174 //----- (004451A8) -------------------------------------------------------- 3954 //----- (004451A8) --------------------------------------------------------
4175 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4) 3955 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4)
4176 { 3956 {
4177 int v3; // esi@1
4178 int v4; // edi@1
4179
4180 v3 = a2;
4181 v4 = a1;
4182 if ( !pGUIWindow2 ) 3957 if ( !pGUIWindow2 )
4183 { 3958 {
4184 if ( pParty->uFlags & 2 ) 3959 if ( pParty->uFlags & 2 )
4185 pGame->Draw(); 3960 pGame->Draw();
4186 pAudioPlayer->StopChannels(-1, -1); 3961 pAudioPlayer->StopChannels(-1, -1);
4187 pMiscTimer->Pause(); 3962 pMiscTimer->Pause();
4188 pEventTimer->Pause(); 3963 pEventTimer->Pause();
4189 dword_5C3418 = v4; 3964 dword_5C3418 = a1;
4190 dword_5C341C = v3; 3965 dword_5C341C = a2;
4191 _591094_decoration = activeLevelDecoration; 3966 _591094_decoration = activeLevelDecoration;
4192 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0); 3967 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0);
4193 pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); 3968 pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
4194 pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); 3969 pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
4195 pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); 3970 pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
4207 activeLevelDecoration = NULL; 3982 activeLevelDecoration = NULL;
4208 pEventTimer->Resume(); 3983 pEventTimer->Resume();
4209 } 3984 }
4210 3985
4211 //----- (004465DF) -------------------------------------------------------- 3986 //----- (004465DF) --------------------------------------------------------
4212 int sub_4465DF_check_season(int a1) 3987 bool sub_4465DF_check_season(int a1)
4213 { 3988 {
4214 unsigned int v1; // eax@1 3989 unsigned int v1; // eax@1
4215 unsigned int v2; // edx@1 3990 unsigned int v2; // edx@1
4216 int v3; // ecx@2 3991 int v3; // ecx@2
4217 int v4; // ecx@3 3992 int v4; // ecx@3
4218 char v6; // zf@9 3993 char v6; // zf@9
4219 3994
4220 v1 = pParty->uCurrentMonth + 1; 3995 v1 = pParty->uCurrentMonth + 1;
4221 v2 = pParty->uDaysPlayed + 1; 3996 v2 = pParty->uDaysPlayed + 1;
4222 if ( a1 ) 3997 if ((v1 == (a1 + 1) * 3 && v2 >= 21) || v1 == (a1 + 1) % 4 * 3 + 1 || v1 == (a1 + 1) % 4 * 3 + 2 || (v1 == (a1 + 2) % 4 * 3 && v2 < 21))
4223 { 3998 return true;
4224 v3 = a1 - 1; 3999 return false;
4225 if ( v3 ) 4000
4226 { 4001 switch (a1)
4227 v4 = v3 - 1; 4002 {
4228 if ( v4 ) 4003 case 3:
4229 { 4004 if (v1 != 12)//12.21 -> 3.20
4230 if ( v4 != 1 ) 4005 {
4231 return 0; 4006 if ((signed int)v1 >= 1 && (signed int)v1 <= 2)
4232 if ( v1 != 12 ) 4007 return true;
4233 { 4008 v6 = v1 == 3;
4234 if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 ) 4009 if (!v6 || (signed int)v2 >= 21)
4235 return 1; 4010 return false;
4236 v6 = v1 == 3; 4011 return true;
4237 LABEL_24: 4012 }
4238 if ( !v6 || (signed int)v2 >= 21 ) 4013 break;
4239 return 0; 4014 case 2:
4240 return 1; 4015 if (v1 != 9)//9.21 -> 12.20
4241 } 4016 {
4242 } 4017 if ((signed int)v1 >= 10 && (signed int)v1 <= 11)
4243 else 4018 return true;
4244 { 4019 v6 = v1 == 12;
4245 if ( v1 != 9 ) 4020 if (!v6 || (signed int)v2 >= 21)
4246 { 4021 return false;
4247 if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 ) 4022 return true;
4248 return 1; 4023 }
4249 v6 = v1 == 12; 4024 break;
4250 goto LABEL_24; 4025 case 1:
4251 } 4026 if (v1 != 6)//6.21 -> 9.20
4252 } 4027 {
4253 } 4028 if ((signed int)v1 >= 7 && (signed int)v1 <= 8)
4254 else 4029 return true;
4255 { 4030 v6 = v1 == 9;
4256 if ( v1 != 6 ) 4031 if (!v6 || (signed int)v2 >= 21)
4257 { 4032 return false;
4258 if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 ) 4033 return true;
4259 return 1; 4034 }
4260 v6 = v1 == 9; 4035 break;
4261 goto LABEL_24; 4036 case 0:
4262 } 4037 if (v1 != 3)//3.21 -> 9.20
4263 } 4038 {
4264 } 4039 if ((signed int)v1 >= 4 && (signed int)v1 <= 5)
4265 else 4040 return true;
4266 { 4041 v6 = v1 == 6;
4267 if ( v1 != 3 ) 4042 if (!v6 || (signed int)v2 >= 21)
4268 { 4043 return false;
4269 if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 ) 4044 return true;
4270 return 1; 4045 }
4271 v6 = v1 == 6; 4046 break;
4272 goto LABEL_24; 4047 default:
4273 } 4048 return false;
4274 } 4049 }
4275 if ( (signed int)v2 >= 21 ) 4050 if ( (signed int)v2 >= 21 )
4276 return 1; 4051 return true;
4277 return 0; 4052 return false;
4278 } 4053 }
4279 4054
4280 //----- (0044861E) -------------------------------------------------------- 4055 //----- (0044861E) --------------------------------------------------------
4281 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) 4056 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename)
4282 { 4057 {
4283 unsigned int v2; // eax@2 4058 unsigned int texture; // eax@2
4284 unsigned __int16 v3; // di@2 4059
4285 signed int v4; // esi@5
4286 BLVFace *v5; // eax@7
4287 unsigned int *v6; // eax@8
4288 char *v7; // eax@9
4289 int v8; // edi@16
4290 char *v9; // esi@16
4291 ODMFace *v10; // eax@17
4292 unsigned int *v11; // eax@19
4293 unsigned __int16 v12; // [sp+Ch] [bp-18h]@2
4294 const char *Str2; // [sp+10h] [bp-14h]@1
4295 unsigned int v14; // [sp+14h] [bp-10h]@1
4296 signed int v15; // [sp+18h] [bp-Ch]@14
4297 int v16; // [sp+1Ch] [bp-8h]@15
4298 signed int v17; // [sp+20h] [bp-4h]@4
4299 signed int v18; // [sp+20h] [bp-4h]@16
4300
4301 Str2 = pFilename;
4302 v14 = uFaceCog;
4303 if ( uFaceCog ) 4060 if ( uFaceCog )
4304 { 4061 {
4305 v2 = pBitmaps_LOD->LoadTexture(pFilename); 4062 texture = pBitmaps_LOD->LoadTexture(pFilename);
4306 v3 = v2; 4063 if ( texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0 )
4307 v12 = v2; 4064 {
4308 if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 ) 4065 pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1);
4309 {
4310 pBitmaps_LOD->pTextures[v2].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette_id1);
4311 4066
4312 if ( uCurrentlyLoadedLevelType == 1 ) 4067 if ( uCurrentlyLoadedLevelType == 1 )
4313 { 4068 {
4314 v17 = 1;
4315 if ( (signed int)pIndoor->uNumFaceExtras > 1 ) 4069 if ( (signed int)pIndoor->uNumFaceExtras > 1 )
4316 { 4070 {
4317 v4 = 1; 4071 for ( uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i )
4318 do
4319 { 4072 {
4320 if ( pIndoor->pFaceExtras[v4].sCogNumber == v14 ) 4073 if ( pIndoor->pFaceExtras[i].sCogNumber == uFaceCog )
4321 { 4074 {
4322 v5 = &pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C]; 4075 if ( BYTE1(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes) & 0x40 )
4323 if ( BYTE1(v5->uAttributes) & 0x40 )
4324 { 4076 {
4325 pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID = pTextureFrameTable->FindTextureByName( 4077 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename);
4326 Str2); 4078 if ( pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID)
4327 v6 = (unsigned int *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID;
4328 if ( *(_WORD *)v6 )
4329 { 4079 {
4330 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v6); 4080 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID);
4331 } 4081 }
4332 else 4082 else
4333 { 4083 {
4334 *(_WORD *)v6 = v3; 4084 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
4335 v7 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes; 4085 BYTE1(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes) &= 0xBFu;
4336 v7[1] &= 0xBFu;
4337 } 4086 }
4338 } 4087 }
4339 else 4088 else
4340 { 4089 {
4341 v5->uBitmapID = v3; 4090 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
4342 } 4091 }
4343 } 4092 }
4344 ++v17;
4345 ++v4;
4346 } 4093 }
4347 while ( v17 < (signed int)pIndoor->uNumFaceExtras );
4348 } 4094 }
4349 pParty->uFlags |= 2u; 4095 pParty->uFlags |= 2;
4350 } 4096 }
4351 else 4097 else
4352 { 4098 {
4353 v15 = 0; 4099 for ( uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j )
4354 if ( (signed int)pOutdoor->uNumBModels > 0 )
4355 { 4100 {
4356 v16 = 0; 4101 for ( uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i )
4357 do
4358 { 4102 {
4359 v8 = 0; 4103 if ( pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog )
4360 v9 = (char *)&pOutdoor->pBModels[v16].pVertices;
4361 v18 = 0;
4362 if ( (signed int)pOutdoor->pBModels[v16].uNumFaces > 0 )
4363 { 4104 {
4364 do 4105 if ( BYTE1(pOutdoor->pBModels[j].pFaces[i].uAttributes) & 0x40 )
4365 { 4106 {
4366 v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4)); 4107 pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename);
4367 if ( v10->sCogNumber == v14 ) 4108 if ( pOutdoor->pBModels[j].pFaces[i].uTextureID )
4109 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID);
4110 else
4368 { 4111 {
4369 if ( BYTE1(v10->uAttributes) & 0x40 ) 4112 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
4370 { 4113 BYTE1(pOutdoor->pBModels[j].pFaces[i].uAttributes) &= 0xBFu;
4371 *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName(
4372 Str2);
4373 v11 = (unsigned int *)(*((_DWORD *)v9 + 4) + v8 + 272);
4374 if ( *(_WORD *)v11 )
4375 {
4376 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v11);
4377 }
4378 else
4379 {
4380 *(_WORD *)v11 = v12;
4381 *(_BYTE *)(*((_DWORD *)v9 + 4) + v8 + 29) &= 0xBFu;
4382 }
4383 }
4384 else
4385 {
4386 v10->uTextureID = v12;
4387 }
4388 } 4114 }
4389 ++v18;
4390 v8 += 308;
4391 } 4115 }
4392 while ( v18 < *((_DWORD *)v9 + 2) ); 4116 else
4117 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
4393 } 4118 }
4394 ++v15;
4395 ++v16;
4396 } 4119 }
4397 while ( v15 < (signed int)pOutdoor->uNumBModels );
4398 } 4120 }
4399 } 4121 }
4400 pParty->uFlags |= 2u; 4122 pParty->uFlags |= 2;
4401 } 4123 }
4402 } 4124 }
4403 } 4125 }
4404 4126
4405 //----- (0044882F) -------------------------------------------------------- 4127 //----- (0044882F) --------------------------------------------------------
4418 if (bHide) 4140 if (bHide)
4419 pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; 4141 pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE;
4420 else 4142 else
4421 pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; 4143 pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE;
4422 4144
4423 pParty->uFlags |= 2u; 4145 pParty->uFlags |= 2;
4424 } 4146 }
4425 } 4147 }
4426 } 4148 }
4427 4149
4428 //----- (0044892E) -------------------------------------------------------- 4150 //----- (0044892E) --------------------------------------------------------
4429 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) 4151 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on)
4430 { 4152 {
4431 signed int v3; // esi@2
4432 signed int v4; // ecx@4
4433 char *v5; // eax@6
4434 int v6; // edi@13
4435 char *v7; // esi@13
4436 signed int v8; // ecx@13
4437 ODMFace *v9; // eax@14
4438 int v10; // [sp+0h] [bp-Ch]@1
4439 signed int v11; // [sp+4h] [bp-8h]@11
4440 int v12; // [sp+8h] [bp-4h]@12
4441
4442 v10 = sCogNumber;
4443 if ( sCogNumber ) 4153 if ( sCogNumber )
4444 { 4154 {
4445 v3 = 1;
4446 if ( uCurrentlyLoadedLevelType == 1 ) 4155 if ( uCurrentlyLoadedLevelType == 1 )
4447 { 4156 {
4448 if ( (signed int)pIndoor->uNumFaceExtras > 1 ) 4157 for ( uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i )
4449 { 4158 {
4450 v4 = 1; 4159 if ( pIndoor->pFaceExtras[i].sCogNumber == sCogNumber )
4451 do
4452 { 4160 {
4453 if ( pIndoor->pFaceExtras[v4].sCogNumber == v10 ) 4161 if ( on )
4162 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit;
4163 else
4164 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit;
4165 }
4166 }
4167 pParty->uFlags |= 2;
4168 }
4169 else
4170 {
4171 for ( uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j )
4172 {
4173 for ( uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i )
4174 {
4175 if ( pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber )
4454 { 4176 {
4455 v5 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes;
4456 if ( on ) 4177 if ( on )
4457 *(_DWORD *)v5 |= bit; 4178 pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit;
4458 else 4179 else
4459 *(_DWORD *)v5 &= ~bit; 4180 pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit;
4460 } 4181 }
4461 ++v3;
4462 ++v4;
4463 } 4182 }
4464 while ( v3 < (signed int)pIndoor->uNumFaceExtras ); 4183 }
4465 } 4184 }
4466 pParty->uFlags |= 2u; 4185 pParty->uFlags |= 2;
4467 } 4186 }
4468 else 4187 }
4469 { 4188
4470 v11 = 0;
4471 if ( (signed int)pOutdoor->uNumBModels > 0 )
4472 {
4473 v12 = 0;
4474 do
4475 {
4476 v6 = 0;
4477 v7 = (char *)&pOutdoor->pBModels[v12].pVertices;
4478 v8 = 0;
4479 if ( (signed int)pOutdoor->pBModels[v12].uNumFaces > 0 )
4480 {
4481 do
4482 {
4483 v9 = (ODMFace *)(v6 + *((_DWORD *)v7 + 4));
4484 if ( v9->sCogNumber == v10 )
4485 {
4486 if ( on )
4487 v9->uAttributes |= bit;
4488 else
4489 v9->uAttributes &= ~bit;
4490 }
4491 ++v8;
4492 v6 += 308;
4493 }
4494 while ( v8 < *((_DWORD *)v7 + 2) );
4495 }
4496 ++v11;
4497 ++v12;
4498 }
4499 while ( v11 < (signed int)pOutdoor->uNumBModels );
4500 }
4501 }
4502 pParty->uFlags |= 2u;
4503 }
4504 }
4505
4506 //----- (00448A98) --------------------------------------------------------
4507 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle)
4508 {
4509 unsigned int v3; // ebx@1
4510 unsigned int v4; // ebp@1
4511 signed int v5; // edi@1
4512 Actor *v6; // esi@4
4513 size_t v7; // ecx@10
4514 Actor *v8; // eax@11
4515 unsigned __int16 v9; // dx@14
4516
4517 v4 = uGroupID;
4518 v5 = Standing;
4519 v3 = uFlag;
4520 if ( uGroupID )
4521 {
4522 if ( bToggle )
4523 {
4524 if ( (signed int)uNumActors > Standing )
4525 {
4526 v6 = pActors.data();//[0].uAttributes;
4527 do
4528 {
4529 if ( v6->uGroup == v4 )
4530 {
4531 v6->uAttributes |= v3;
4532 if ( v3 == 0x10000 )
4533 {
4534 v6->uAIState = Disabled;
4535 v6->UpdateAnimation();
4536 }
4537 }
4538 ++v5;
4539 ++v6;
4540 }
4541 while ( v5 < (signed int)uNumActors );
4542 }
4543 }
4544 else
4545 {
4546 v7 = uNumActors;
4547 if ( (signed int)uNumActors > Standing )
4548 {
4549 v8 = pActors.data();//[0].uAIState;
4550 do
4551 {
4552 if ( v8->uGroup == v4 )
4553 {
4554 if ( v3 == 0x10000 )
4555 {
4556 v9 = v8->uAIState;
4557 if ( v8->uAIState != Dead )
4558 {
4559 if ( v9 != 4 && v9 != 11 )
4560 v8->uAIState = Standing;
4561 }
4562 }
4563 LODWORD(v8->uAttributes) &= ~v3;
4564 }
4565 ++v8;
4566 --v7;
4567 }
4568 while ( v7 );
4569 }
4570 }
4571 }
4572 }
4573 4189
4574 //----- (00448B45) -------------------------------------------------------- 4190 //----- (00448B45) --------------------------------------------------------
4575 void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) 4191 void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide)
4576 { 4192 {
4577 if ( bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft ) 4193 if ( bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft )
4650 } 4266 }
4651 4267
4652 //----- (00448CF4) -------------------------------------------------------- 4268 //----- (00448CF4) --------------------------------------------------------
4653 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName) 4269 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName)
4654 { 4270 {
4655 __int16 v8; // di@1 4271 unsigned int map_id; // eax@1
4656 __int16 v9; // si@1 4272 size_t old_num_actors; // ebx@2
4657 unsigned int v10; // eax@1
4658 size_t v11; // ebx@2
4659 signed int v12; // esi@2
4660 Actor *pActor;//Actor_uYawAngle_cr *v13; // ebx@3
4661 AIDirection a3; // [sp+Ch] [bp-50h]@2
4662 AIDirection v15; // [sp+28h] [bp-34h]@2 4273 AIDirection v15; // [sp+28h] [bp-34h]@2
4663 //SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1 4274 SpawnPointMM7 pSpawnPoint; // [sp+44h] [bp-18h]@1
4664 4275
4665 v8 = typeindex; 4276 pSpawnPoint.vPosition.x = x;
4666 v9 = level; 4277 pSpawnPoint.vPosition.y = y;
4667 4278 pSpawnPoint.vPosition.z = z;
4668 SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1 4279 pSpawnPoint.uGroup = group;
4669 //SpawnPointMM7::SpawnPointMM7(&v16); 4280 pSpawnPoint.uRadius = 32;
4670 4281 pSpawnPoint.uKind = 3;
4671 v16.vPosition.x = x; 4282 pSpawnPoint.uIndex = typeindex + 2 * level + level;
4672 v16.vPosition.y = y; 4283 map_id = pMapStats->GetMapInfo(pCurrentMapName);
4673 v16.vPosition.z = z; 4284 if ( map_id )
4674 v16.uGroup = group; 4285 {
4675 v16.uRadius = 32; 4286 old_num_actors = uNumActors;
4676 v16.uKind = 3; 4287 SpawnEncounter(&pMapStats->pInfos[map_id], &pSpawnPoint, 0, count, 0);
4677 v16.uIndex = v8 + 2 * v9 + v9; 4288 Actor::GetDirectionInfo(PID(OBJECT_Actor, old_num_actors), 4, &v15, 1);
4678 v10 = pMapStats->GetMapInfo(pCurrentMapName); 4289 for ( uint i = (unsigned int)old_num_actors; i < (unsigned int)uNumActors; ++i )
4679 if ( v10 ) 4290 {
4680 { 4291 pActors[i].PrepareSprites(0);
4681 v11 = uNumActors; 4292 pActors[i].uYawAngle = v15.uYawAngle;
4682 SpawnEncounter(&pMapStats->pInfos[v10], &v16, 0, count, 0); 4293 pActors[i].dword_000334_unique_name = uUniqueName;
4683 Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &v15, 1);
4684 v12 = v11;
4685 if ( (signed int)v11 < (signed int)uNumActors )
4686 {
4687 for ( pActor = &pActors[v11]; v12 < (signed int)uNumActors; ++pActor )
4688 {
4689 pActor->PrepareSprites(0);
4690 ++v12;
4691 pActor->uYawAngle = v15.uYawAngle;
4692 pActor->dword_000334_unique_name = uUniqueName;
4693 }
4694 } 4294 }
4695 } 4295 }
4696 } 4296 }
4697 4297
4698 4298
4699 //----- (0044987B) -------------------------------------------------------- 4299 //----- (0044987B) --------------------------------------------------------
4700 void sub_44987B(const char *pMapName, MapStartPoint start_point) 4300 void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point)
4701 { 4301 {
4702 const char *v2; // edi@1
4703
4704 v2 = pMapName;
4705 pAudioPlayer->StopChannels(-1, -1); 4302 pAudioPlayer->StopChannels(-1, -1);
4706 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); 4303 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None);
4707 if ( _stricmp(pCurrentMapName, v2) ) 4304 if ( _stricmp(pCurrentMapName, pMapName) )
4708 SaveGame(1, 0); 4305 SaveGame(1, 0);
4709 4306
4710 uGameState = GAME_STATE_2; 4307 uGameState = GAME_STATE_CHANGE_LOCATION;
4711 strcpy(pCurrentMapName, v2); 4308 strcpy(pCurrentMapName, pMapName);
4712 uLevel_StartingPointType = start_point; 4309 uLevel_StartingPointType = start_point;
4713 } 4310 }
4714 // 6BE35C: using guessed type int uLevel_StartingPointType; 4311 // 6BE35C: using guessed type int uLevel_StartingPointType;
4715 4312
4716 //----- (004498D5) -------------------------------------------------------- 4313 //----- (004498D5) --------------------------------------------------------
4717 void TeleportToStartingPoint(MapStartPoint point) 4314 void TeleportToStartingPoint(MapStartPoint point)
4718 { 4315 {
4719 //unsigned int v1; // ecx@2 4316 const char *model_name; // [sp-4h] [bp-84h]@6
4720 //int v2; // ecx@3
4721 //int v3; // ecx@4
4722 unsigned __int16 v4; // ax@11
4723 signed int v5; // ecx@12
4724 LevelDecoration *v6; // edx@13
4725 signed int v7; // ecx@17
4726 int v8; // eax@17
4727 int v9; // ecx@17
4728 const char *v10; // [sp-4h] [bp-84h]@6
4729 char pName[128]; // [sp+8h] [bp-78h]@11 4317 char pName[128]; // [sp+8h] [bp-78h]@11
4730 4318
4731 switch (point) 4319 switch (point)
4732 { 4320 {
4733 case MapStartPoint_Party: v10 = "Party Start"; break; 4321 case MapStartPoint_Party: model_name = "Party Start"; break;
4734 case MapStartPoint_North: v10 = "North Start"; break; 4322 case MapStartPoint_North: model_name = "North Start"; break;
4735 case MapStartPoint_South: v10 = "South Start"; break; 4323 case MapStartPoint_South: model_name = "South Start"; break;
4736 case MapStartPoint_East: v10 = "East Start"; break; 4324 case MapStartPoint_East: model_name = "East Start"; break;
4737 case MapStartPoint_West: v10 = "West Start"; break; 4325 case MapStartPoint_West: model_name = "West Start"; break;
4738 default: 4326 default:
4739 Error("Invalid enum value: %u", point); 4327 Error("Invalid enum value: %u", point);
4740 } 4328 }
4741 4329
4742 strcpy(pName, v10); 4330 strcpy(pName, model_name);
4743 v4 = pDecorationList->GetDecorIdByName(pName); 4331 if ( pDecorationList->GetDecorIdByName(pName) )
4744 if ( v4 ) 4332 {
4745 { 4333
4746 v5 = 0;
4747 if ( (signed int)uNumLevelDecorations > 0 ) 4334 if ( (signed int)uNumLevelDecorations > 0 )
4748 { 4335 {
4749 v6 = pLevelDecorations.data(); 4336 for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i )
4750 while ( v6->uDecorationDescID != (signed __int16)v4 ) 4337 {
4751 { 4338 if ( pLevelDecorations[i].uDecorationDescID == (signed __int16)pDecorationList->GetDecorIdByName(pName) )
4752 ++v5; 4339 {
4753 ++v6; 4340 pParty->vPosition.x = pLevelDecorations[i].vPosition.x;
4754 if ( v5 >= (signed int)uNumLevelDecorations ) 4341 pParty->vPosition.y = pLevelDecorations[i].vPosition.y;
4755 goto LABEL_20; 4342 pParty->vPosition.z = pLevelDecorations[i].vPosition.z;
4756 } 4343 pParty->uFallStartY = pParty->vPosition.z;
4757 v7 = v5; 4344 pParty->sRotationY = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[i].field_1A) / 90;
4758 pParty->vPosition.x = pLevelDecorations[v7].vPosition.x; 4345 if ( pLevelDecorations[i].field_10_y_rot )
4759 pParty->vPosition.y = pLevelDecorations[v7].vPosition.y; 4346 pParty->sRotationY = pLevelDecorations[i].field_10_y_rot;
4760 pParty->vPosition.z = pLevelDecorations[v7].vPosition.z; 4347 pParty->sRotationX = 0;
4761 pParty->uFallStartY = pParty->vPosition.z; 4348 pParty->uFallSpeed = 0;
4762 v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90; 4349 }
4763 v9 = pLevelDecorations[v7].field_10_y_rot; 4350 }
4764 pParty->sRotationY = v8; 4351 }
4765 if ( v9 )
4766 pParty->sRotationY = v9;
4767 pParty->sRotationX = 0;
4768 pParty->uFallSpeed = 0;
4769 }
4770 LABEL_20:
4771 if ( dword_5B65C0 ) 4352 if ( dword_5B65C0 )
4772 { 4353 {
4773 if ( _5B65A8_npcdata_uflags_or_other ) 4354 if ( _5B65A8_npcdata_uflags_or_other )
4774 pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other; 4355 pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other;
4775 if ( _5B65AC_npcdata_fame_or_other ) 4356 if ( _5B65AC_npcdata_fame_or_other )
4794 _5B65AC_npcdata_fame_or_other = 0; 4375 _5B65AC_npcdata_fame_or_other = 0;
4795 _5B65A8_npcdata_uflags_or_other = 0; 4376 _5B65A8_npcdata_uflags_or_other = 0;
4796 } 4377 }
4797 } 4378 }
4798 4379
4799 //----- (00449A49) --------------------------------------------------------
4800 void Door_switch_animation(unsigned int uDoorID, int a2)
4801 {
4802 int old_state; // eax@1
4803 signed int door_id; // esi@2
4804
4805 if ( !pIndoor->pDoors )
4806 return;
4807 for ( door_id = 0; door_id < 200; ++door_id )
4808 {
4809 if ( pIndoor->pDoors[door_id].uDoorID == uDoorID )
4810 break;
4811 }
4812 if ( door_id >= 200 )
4813 {
4814 Error("Unable to find Door ID: %i!", uDoorID);
4815 }
4816 old_state = pIndoor->pDoors[door_id].uState;
4817 if ( a2 == 2 )
4818 {
4819 if ( pIndoor->pDoors[door_id].uState == BLVDoor::Closing || pIndoor->pDoors[door_id].uState == BLVDoor::Opening )
4820 return;
4821 if ( pIndoor->pDoors[door_id].uState )
4822 {
4823 if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
4824 {
4825 pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
4826 if ( old_state == BLVDoor::Open )
4827 {
4828 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
4829 return;
4830 }
4831 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
4832 {
4833 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
4834 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
4835 / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
4836 return;
4837 }
4838 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
4839 }
4840 return;
4841 }
4842 }
4843 else
4844 {
4845 if ( a2 == 0 )
4846 {
4847 if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing )
4848 {
4849 pIndoor->pDoors[door_id].uState = BLVDoor::Closing;
4850 if ( old_state == BLVDoor::Open )
4851 {
4852 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
4853 return;
4854 }
4855 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
4856 {
4857 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed
4858 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed)
4859 / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed;
4860 return;
4861 }
4862 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
4863 }
4864 return;
4865 }
4866 if ( a2 != 1 )
4867 return;
4868 }
4869 if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening )
4870 {
4871 pIndoor->pDoors[door_id].uState = BLVDoor::Opening;
4872 if ( old_state == BLVDoor::Closed )
4873 {
4874 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0;
4875 return;
4876 }
4877 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 )
4878 {
4879 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uCloseSpeed
4880 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uOpenSpeed)
4881 / 128 << 7) / pIndoor->pDoors[door_id].uCloseSpeed;
4882 return;
4883 }
4884 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360;
4885 }
4886 return;
4887 }
4888
4889 //----- (00449B57) -------------------------------------------------------- 4380 //----- (00449B57) --------------------------------------------------------
4890 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 ) 4381 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 )
4891 { 4382 {
4892 return (a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8)) != 0; 4383 return (a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8)) != 0;
4893 } 4384 }
4943 _5B65B8_npcdata_hiword_house_or_other = 0; 4434 _5B65B8_npcdata_hiword_house_or_other = 0;
4944 dword_5B65BC = 0; 4435 dword_5B65BC = 0;
4945 dword_5B65C0 = 0; 4436 dword_5B65C0 = 0;
4946 4437
4947 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; 4438 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
4948 sub_44987B("nwc.blv", MapStartPoint_Party); 4439 Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party);
4949 pCurrentScreen = SCREEN_GAME; 4440 pCurrentScreen = SCREEN_GAME;
4950 return true; 4441 return true;
4951 } 4442 }
4952 4443
4953 //----- (00401000) -------------------------------------------------------- 4444 //----- (00401000) --------------------------------------------------------