Mercurial > mm7
comparison mm7_4.cpp @ 723:256211e8243a
ODM_GetFloorLevel & BLV_GetFloorLevel
author | Ritor1 |
---|---|
date | Thu, 21 Mar 2013 16:09:44 +0600 |
parents | 70c5a87a1307 |
children | 7037f22cd716 |
comparison
equal
deleted
inserted
replaced
722:70c5a87a1307 | 723:256211e8243a |
---|---|
236 } | 236 } |
237 } | 237 } |
238 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; | 238 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; |
239 | 239 |
240 //----- (0046CEC3) -------------------------------------------------------- | 240 //----- (0046CEC3) -------------------------------------------------------- |
241 int _46CEC3_get_floor_level(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) | 241 int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) |
242 { | 242 { |
243 //BLVSector *v5; // edi@1 | |
244 //int v6; // ecx@1 | |
245 //Vec3_short_ *v7; // edx@1 | |
246 //BLVFace *v8; // esi@2 | |
247 //int v9; // eax@8 | |
248 //int v10; // edi@8 | |
249 //int v11; // eax@10 | |
250 int v12; // ecx@10 | |
251 int v13; // ecx@13 | 243 int v13; // ecx@13 |
252 signed int v14; // ebx@14 | 244 signed int v14; // ebx@14 |
253 int v15; // eax@16 | 245 int v15; // eax@16 |
254 int v16; // edx@19 | 246 int v16; // edx@19 |
255 int v17; // ST18_4@19 | 247 int v17; // ST18_4@19 |
256 signed int v18; // edx@19 | 248 signed int v18; // edx@19 |
257 signed __int64 v19; // qtt@19 | 249 signed __int64 v19; // qtt@19 |
258 PolygonType v20; // al@25 | |
259 int v21; // eax@27 | 250 int v21; // eax@27 |
260 int v22; // ecx@29 | 251 int v22; // ecx@29 |
261 //BLVFace *v23; // eax@33 | |
262 //int v24; // esi@39 | |
263 //int v25; // edi@39 | |
264 //int v26; // esi@41 | |
265 int v27; // ecx@43 | |
266 signed int v28; // eax@45 | 252 signed int v28; // eax@45 |
267 int v29; // ebx@47 | 253 int v29; // ebx@47 |
268 int v30; // edx@49 | 254 int v30; // edx@49 |
269 int v31; // ST10_4@49 | 255 int v31; // ST10_4@49 |
270 signed int v32; // edx@49 | 256 signed int v32; // edx@49 |
271 signed __int64 v33; // qtt@49 | 257 signed __int64 v33; // qtt@49 |
272 signed int v34; // eax@54 | 258 signed int v34; // eax@54 |
273 signed int v35; // esi@56 | 259 signed int v35; // esi@56 |
274 int result; // eax@57 | 260 int result; // eax@57 |
275 int pPartyOpp; // edi@61 | |
276 int v38; // edx@62 | 261 int v38; // edx@62 |
277 //int v39; // [sp+Ch] [bp-34h]@1 | |
278 //int v40; // [sp+10h] [bp-30h]@2 | |
279 int v41; // [sp+14h] [bp-2Ch]@12 | |
280 //unsigned __int16 *v42; // [sp+18h] [bp-28h]@1 | |
281 //BLVSector *v43; // [sp+1Ch] [bp-24h]@1 | |
282 int v44; // [sp+20h] [bp-20h]@10 | 262 int v44; // [sp+20h] [bp-20h]@10 |
283 int v45; // [sp+24h] [bp-1Ch]@10 | |
284 //signed int v46; // [sp+24h] [bp-1Ch]@38 | |
285 bool v47; // [sp+24h] [bp-1Ch]@43 | 263 bool v47; // [sp+24h] [bp-1Ch]@43 |
286 bool v48; // [sp+28h] [bp-18h]@10 | 264 bool v48; // [sp+28h] [bp-18h]@10 |
287 bool v49; // [sp+28h] [bp-18h]@41 | 265 bool v49; // [sp+28h] [bp-18h]@41 |
288 bool v50; // [sp+2Ch] [bp-14h]@12 | 266 bool v50; // [sp+2Ch] [bp-14h]@12 |
289 int v51; // [sp+2Ch] [bp-14h]@41 | |
290 //signed int v52; // [sp+30h] [bp-10h]@7 | |
291 signed int v53; // [sp+30h] [bp-10h]@10 | 267 signed int v53; // [sp+30h] [bp-10h]@10 |
292 signed int v54; // [sp+30h] [bp-10h]@41 | 268 signed int v54; // [sp+30h] [bp-10h]@41 |
293 signed int v55; // [sp+34h] [bp-Ch]@1 | 269 signed int v55; // [sp+34h] [bp-Ch]@1 |
294 //signed int v56; // [sp+38h] [bp-8h]@1 | |
295 //signed int v57; // [sp+3Ch] [bp-4h]@1 | |
296 //int uSectorIDa; // [sp+4Ch] [bp+Ch]@1 | |
297 //signed int uSectorIDb; // [sp+4Ch] [bp+Ch]@32 | |
298 | 270 |
299 LOG_DECOMPILATION_WARNING(); | 271 LOG_DECOMPILATION_WARNING(); |
300 | 272 |
301 //auto a1 = x; | |
302 //auto a2 = y; | |
303 //auto a3 = z; | |
304 | |
305 //v5 = &pIndoor->pSectors[uSectorID]; | |
306 auto pSector = &pIndoor->pSectors[uSectorID]; | 273 auto pSector = &pIndoor->pSectors[uSectorID]; |
307 //v57 = y; | 274 v55 = 1; |
308 //v56 = x; | |
309 //v6 = 0; | |
310 v55 = 0; | |
311 //v43 = v5; | |
312 //v42 = v5->pFloors; | |
313 //v7 = pIndoor->pVertices; | |
314 //v39 = v5->uNumFloors; | |
315 //for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa ) | |
316 for (uint i = 0; i < pSector->uNumFloors; ++i) | 275 for (uint i = 0; i < pSector->uNumFloors; ++i) |
317 { | 276 { |
318 //v40 = (int)&v42[v6]; | |
319 //v8 = &pIndoor->pFaces[pSector->pFloors[i]]; | |
320 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; | 277 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; |
321 if (pFloor->Clickable()) | 278 if (pFloor->Clickable()) |
322 continue; | 279 continue; |
323 | 280 |
324 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && | 281 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && |
325 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) | 282 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) |
326 { | 283 { |
327 //v52 = 0; | |
328 for (uint j = 0; j < pFloor->uNumVertices; ++j) | 284 for (uint j = 0; j < pFloor->uNumVertices; ++j) |
329 { | 285 { |
330 //v9 = v52; | |
331 //v10 = 2 * v52; | |
332 word_721460[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; | 286 word_721460[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; |
333 word_721460[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; | 287 word_721460[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; |
334 word_721390[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; | 288 word_721390[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; |
335 word_721390[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; | 289 word_721390[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; |
336 //} | |
337 //while ( v52 < v8->uNumVertices ); | |
338 //v5 = v43; | |
339 } | 290 } |
340 v44 = 2 * pFloor->uNumVertices; | 291 v44 = 2 * pFloor->uNumVertices; |
341 //v11 = 2 * pFloor->uNumVertices; | |
342 word_721460[2 * pFloor->uNumVertices] = word_721460[0]; | 292 word_721460[2 * pFloor->uNumVertices] = word_721460[0]; |
343 word_721390[2 * pFloor->uNumVertices] = word_721390[0]; | 293 word_721390[2 * pFloor->uNumVertices] = word_721390[0]; |
344 | 294 |
345 v48 = word_721390[0] >= y; | 295 v48 = word_721390[0] >= y; |
346 v12 = 0; | |
347 v53 = 0; | 296 v53 = 0; |
348 v45 = 0; | |
349 if ( pFloor->uNumVertices > 0 ) | 297 if ( pFloor->uNumVertices > 0 ) |
350 { | 298 { |
351 do | 299 for ( int i = 0; i < v44; i++ ) |
352 { | 300 { |
353 if ( v53 >= 2 ) | 301 if ( v53 >= 2 ) |
354 break; | 302 break; |
355 v41 = word_721390[v12 + 1]; | 303 v50 = word_721390[i + 1] >= y; |
356 v50 = word_721390[v12 + 1] >= y; | |
357 if ( v48 == v50 ) | 304 if ( v48 == v50 ) |
358 { | 305 { |
359 v13 = v45; | 306 v13 = i; |
360 } | 307 } |
361 else | 308 else |
362 { | 309 { |
363 v13 = v45; | 310 v13 = i; |
364 if ( word_721460[v45 + 1] >= x ) | 311 v14 = word_721460[i + 1] >= x ? 0 : 2; |
365 v14 = 0; | 312 v15 = v14 | word_721460[i] < x; |
366 else | |
367 v14 = 2; | |
368 v15 = v14 | word_721460[v45] < x; | |
369 if ( v15 != 3 ) | 313 if ( v15 != 3 ) |
370 { | 314 { |
371 if ( !v15 | 315 if ( !v15 ) |
372 || (v16 = word_721390[v45], | 316 { |
373 v17 = v41 - v16, | 317 LODWORD(v19) = (y - word_721390[i]) << 16; |
374 v18 = y - v16, | 318 HIDWORD(v19) = (y - word_721390[i]) >> 16; |
375 LODWORD(v19) = v18 << 16, | 319 v16 = ((((word_721460[i + 1] - word_721460[i]) * v19 / (word_721390[i + 1] - word_721390[i])) >> 16) + word_721460[i]); |
376 HIDWORD(v19) = v18 >> 16, | 320 if ( v16 >= x) |
377 //v7 = pIndoor->pVertices, | 321 ++v53; |
378 (signed int)(((unsigned __int64)(((signed int)word_721460[v45 + 1] - (signed int)word_721460[v45]) | 322 } |
379 * v19 | |
380 / v17) >> 16) | |
381 + word_721460[v45]) >= x) ) | |
382 ++v53; | |
383 } | 323 } |
384 } | 324 } |
385 v12 = v13 + 1; | |
386 v48 = v50; | 325 v48 = v50; |
387 v45 = v12; | 326 } |
388 } | |
389 while ( v12 < v44 ); | |
390 | |
391 if ( v53 == 1 ) | 327 if ( v53 == 1 ) |
392 { | 328 { |
393 if ( v55 >= 50 ) | 329 if ( v55 >= 50 ) |
394 break; | 330 break; |
395 v20 = pFloor->uPolygonType; | 331 if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling ) |
396 if ( v20 == 3 || v20 == 5 ) | |
397 { | 332 { |
398 v21 = pIndoor->pVertices[*pFloor->pVertexIDs].z; | 333 v21 = pIndoor->pVertices[*pFloor->pVertexIDs].z; |
399 } | 334 } |
400 else | 335 else |
401 { | 336 { |
402 //v7 = pIndoor->pVertices; | 337 v21 = ((pFloor->zCalc1 * x) >> 16) + ((pFloor->zCalc2 * y) >> 16) + pFloor->zCalc3; |
403 v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16) | |
404 + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16) | |
405 + HIWORD(pFloor->zCalc3); | |
406 } | 338 } |
407 v22 = v55++; | 339 v22 = v55++; |
408 dword_7212C8[v22] = v21; | 340 dword_7212C8[v22] = v21; |
409 dword_721200[v22] = pSector->pFloors[i]; | 341 dword_721200[v22] = pSector->pFloors[i]; |
410 } | 342 } |
411 } | 343 } |
412 } | 344 } |
413 //v6 = uSectorIDa + 1; | |
414 } | 345 } |
415 | 346 |
416 if ( pSector->field_0 & 8 ) | 347 if ( pSector->field_0 & 8 ) |
417 { | 348 { |
418 for (uint i = 0; i < pSector->uNumPortals; ++i) | 349 for (uint i = 0; i < pSector->uNumPortals; ++i) |
419 { | 350 { |
420 //v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]]; | |
421 auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; | 351 auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; |
422 if (portal->uPolygonType != POLYGON_Floor) | 352 if (portal->uPolygonType != POLYGON_Floor) |
423 continue; | 353 continue; |
424 | 354 |
425 if (x <= portal->pBounding.x2 && | 355 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 && |
426 x >= portal->pBounding.x1 && | 356 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 ) |
427 y <= portal->pBounding.y2 && | 357 { |
428 y >= portal->pBounding.y1 ) | |
429 { | |
430 //v46 = 0; | |
431 for (uint j = 0; j < portal->uNumVertices; ++j) | 358 for (uint j = 0; j < portal->uNumVertices; ++j) |
432 { | 359 { |
433 //v24 = v46; | |
434 //v25 = 2 * v46; | |
435 word_721460[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; | 360 word_721460[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; |
436 word_721460[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; | 361 word_721460[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; |
437 word_721390[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; | 362 word_721390[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; |
438 word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; | 363 word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; |
439 //} | 364 } |
440 //while ( v46 < v23->uNumVertices ); | |
441 //v5 = v43; | |
442 } | |
443 | |
444 //v26 = 2 * v23->uNumVertices; | |
445 word_721460[2 * portal->uNumVertices] = word_721460[0]; | 365 word_721460[2 * portal->uNumVertices] = word_721460[0]; |
446 word_721390[2 * portal->uNumVertices] = word_721390[0]; | 366 word_721390[2 * portal->uNumVertices] = word_721390[0]; |
447 v54 = 0; | 367 v54 = 0; |
448 v51 = 0; | |
449 v49 = word_721390[0] >= y; | 368 v49 = word_721390[0] >= y; |
450 if ( portal->uNumVertices > 0 ) | 369 if ( portal->uNumVertices > 0 ) |
451 { | 370 { |
452 do | 371 for ( int i = 0; i < 2 * portal->uNumVertices; ++i ) |
453 { | 372 { |
454 if ( v54 >= 2 ) | 373 if ( v54 >= 2 ) |
455 break; | 374 break; |
456 v27 = v51; | 375 v47 = word_721390[i + 1] >= y; |
457 v47 = word_721390[v51 + 1] >= y; | |
458 if ( v49 != v47 ) | 376 if ( v49 != v47 ) |
459 { | 377 { |
460 if ( word_721460[v27 + 1] >= x ) | 378 v28 = word_721460[i + 1] >= x ? 0 : 2; |
461 v28 = 0; | 379 v29 = v28 | word_721460[i] < x; |
462 else | |
463 v28 = 2; | |
464 v29 = v28 | word_721460[v27] < x; | |
465 if ( v29 != 3 ) | 380 if ( v29 != 3 ) |
466 { | 381 { |
467 if ( !v29 | 382 if ( !v29 ) |
468 || (v30 = word_721390[v27], | 383 LODWORD(v33) = (y - word_721390[i]) << 16; |
469 v31 = word_721390[v51 + 1] - v30, | 384 HIDWORD(v33) = (y - word_721390[i]) >> 16; |
470 v32 = y - v30, | 385 v30 = ((((word_721460[i + 1] - word_721460[i]) * v33 / (word_721390[i + 1] - word_721390[i])) >> 16) + word_721460[i]); |
471 LODWORD(v33) = v32 << 16, | 386 if ( v30 >= x) |
472 HIDWORD(v33) = v32 >> 16, | 387 ++v54; |
473 //v7 = pIndoor->pVertices, | |
474 (signed int)(((unsigned __int64)(((signed int)word_721460[v27 + 1] - (signed int)word_721460[v27]) | |
475 * v33 | |
476 / v31) >> 16) | |
477 + word_721460[v27]) >= x) ) | |
478 ++v54; | |
479 } | 388 } |
480 } | 389 } |
481 ++v51; | |
482 v49 = v47; | 390 v49 = v47; |
483 } | 391 } |
484 while ( v51 < 2 * portal->uNumVertices ); | |
485 | |
486 if ( v54 == 1 ) | 392 if ( v54 == 1 ) |
487 { | 393 { |
488 if ( v55 >= 50 ) | 394 if ( v55 >= 50 ) |
489 break; | 395 break; |
490 v34 = v55++; | 396 v34 = v55++; |
493 } | 399 } |
494 } | 400 } |
495 } | 401 } |
496 } | 402 } |
497 } | 403 } |
498 | |
499 //v35 = 1; | |
500 if ( v55 == 1 ) | 404 if ( v55 == 1 ) |
501 { | 405 { |
502 *pFaceID = dword_721200[0]; | 406 *pFaceID = dword_721200[0]; |
503 return dword_7212C8[0]; | 407 return dword_7212C8[0]; |
504 } | 408 } |
506 return -30000; | 410 return -30000; |
507 *pFaceID = dword_721200[0]; | 411 *pFaceID = dword_721200[0]; |
508 result = dword_7212C8[0]; | 412 result = dword_7212C8[0]; |
509 if ( v55 > 1 ) | 413 if ( v55 > 1 ) |
510 { | 414 { |
511 pPartyOpp = z + 5; | |
512 //while ( 1 ) | |
513 for ( v35 = 1; v35 < v55; ++v35 ) | 415 for ( v35 = 1; v35 < v55; ++v35 ) |
514 { | 416 { |
515 v38 = dword_7212C8[v35]; | 417 if ( result <= z + 5 ) |
516 if ( result <= pPartyOpp ) | 418 { |
517 { | 419 if ( dword_7212C8[v35] >= result || dword_7212C8[v35] > z + 5 ) |
518 if ( v38 >= result || v38 > pPartyOpp ) | |
519 continue; | 420 continue; |
520 result = dword_7212C8[v35]; | 421 result = dword_7212C8[v35]; |
521 *pFaceID = dword_721200[v35]; | 422 *pFaceID = dword_721200[v35]; |
522 continue; | 423 continue; |
523 } | 424 } |
524 if ( v38 < result ) | 425 if ( dword_7212C8[v35] < result ) |
525 { | 426 { |
526 result = dword_7212C8[v35]; | 427 result = dword_7212C8[v35]; |
527 *pFaceID = dword_721200[v35]; | 428 *pFaceID = dword_721200[v35]; |
528 } | 429 } |
529 //LABEL_68: | |
530 //++v35; | |
531 //if ( v35 >= v55 ) | |
532 //return result; | |
533 } | 430 } |
534 } | 431 } |
535 return result; | 432 return result; |
536 } | 433 } |
537 | 434 |
538 //----- (0046D49E) -------------------------------------------------------- | 435 //----- (0046D49E) -------------------------------------------------------- |
539 int __fastcall sub_46D49E_prolly_get_world_y_under_party(int a1, signed int a2, int a3, int a4, int *a5, int *a6, int a7) | 436 int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int a4, int *a5, int *a6, int a7) |
540 { | 437 { |
541 signed int v7; // edi@1 | 438 BSPModel *pBModel; // esi@4 |
542 int v8; // ebx@1 | 439 ODMFace *pFace; // ecx@11 |
543 int v9; // eax@1 | |
544 BSPModel *v10; // esi@4 | |
545 ODMFace *v11; // ecx@11 | |
546 unsigned __int8 v12; // al@11 | |
547 char *v13; // eax@19 | |
548 int v14; // edx@20 | 440 int v14; // edx@20 |
549 int v15; // eax@22 | |
550 int v16; // edx@22 | |
551 int v17; // edi@24 | |
552 signed int v18; // edx@26 | 441 signed int v18; // edx@26 |
553 int v19; // eax@28 | 442 int v19; // eax@28 |
554 int v20; // edx@30 | 443 int v20; // edx@30 |
555 int v21; // ST1C_4@30 | 444 int v21; // ST1C_4@30 |
556 signed int v22; // edx@30 | 445 signed int v22; // edx@30 |
563 signed int v29; // edx@44 | 452 signed int v29; // edx@44 |
564 int v30; // esi@45 | 453 int v30; // esi@45 |
565 int v31; // eax@45 | 454 int v31; // eax@45 |
566 ODMFace *v32; // eax@57 | 455 ODMFace *v32; // eax@57 |
567 int v33; // ecx@59 | 456 int v33; // ecx@59 |
568 int v34; // [sp+Ch] [bp-34h]@8 | |
569 int v35; // [sp+10h] [bp-30h]@22 | |
570 int v36; // [sp+14h] [bp-2Ch]@24 | 457 int v36; // [sp+14h] [bp-2Ch]@24 |
571 int v37; // [sp+18h] [bp-28h]@22 | |
572 int v38; // [sp+1Ch] [bp-24h]@2 | 458 int v38; // [sp+1Ch] [bp-24h]@2 |
573 int v39; // [sp+20h] [bp-20h]@9 | 459 int v39; // [sp+20h] [bp-20h]@9 |
574 int v40; // [sp+24h] [bp-1Ch]@1 | 460 signed int pBModelNum; // [sp+28h] [bp-18h]@1 |
575 signed int v41; // [sp+28h] [bp-18h]@1 | 461 int pFaceNum; // [sp+2Ch] [bp-14h]@8 |
576 int v42; // [sp+2Ch] [bp-14h]@8 | |
577 bool v43; // [sp+30h] [bp-10h]@22 | 462 bool v43; // [sp+30h] [bp-10h]@22 |
578 bool v44; // [sp+34h] [bp-Ch]@24 | 463 bool v44; // [sp+34h] [bp-Ch]@24 |
579 signed int v45; // [sp+38h] [bp-8h]@1 | |
580 signed int v46; // [sp+3Ch] [bp-4h]@1 | 464 signed int v46; // [sp+3Ch] [bp-4h]@1 |
581 signed int v47; // [sp+58h] [bp+18h]@18 | |
582 signed int v48; // [sp+58h] [bp+18h]@22 | 465 signed int v48; // [sp+58h] [bp+18h]@22 |
583 signed int v49; // [sp+58h] [bp+18h]@43 | 466 signed int v49; // [sp+58h] [bp+18h]@43 |
584 | 467 |
585 v7 = a2; | |
586 v8 = a1; | |
587 v45 = a2; | |
588 v40 = a1; | |
589 v46 = 1; | 468 v46 = 1; |
590 v9 = GetTerrainHeightsAroundParty2(a1, a2, a5, a7); | |
591 dword_721160[0] = -1; | 469 dword_721160[0] = -1; |
592 dword_721110[0] = -1; | 470 dword_721110[0] = -1; |
593 dword_7211B0[0] = v9; | 471 floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, a5, a7); |
594 v41 = 0; | |
595 if ( (signed int)pOutdoor->uNumBModels <= 0 ) | 472 if ( (signed int)pOutdoor->uNumBModels <= 0 ) |
596 goto LABEL_63; | 473 { |
474 *a6 = 0; | |
475 return floor_level[0]; | |
476 } | |
597 v38 = 0; | 477 v38 = 0; |
598 while ( 1 ) | 478 for ( pBModelNum = 0; pBModelNum < (signed int)pOutdoor->uNumBModels; ++pBModelNum ) |
599 { | 479 { |
600 v10 = &pOutdoor->pBModels[v38]; | 480 pBModel = &pOutdoor->pBModels[v38]; |
601 if ( v8 <= pOutdoor->pBModels[v38].sMaxX ) | 481 if ( X <= pBModel->sMaxX && X >= pBModel->sMinX && Y <= pBModel->sMaxY && Y >= pBModel->sMinY ) |
602 { | 482 { |
603 if ( v8 >= v10->sMinX ) | 483 if ( (signed int)pBModel->uNumFaces > 0 ) |
604 { | 484 { |
605 if ( v7 <= v10->sMaxY ) | 485 v39 = 0; |
606 { | 486 for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum ) |
607 if ( v7 >= v10->sMinY ) | 487 { |
488 pFace = &pBModel->pFaces[v39]; | |
489 if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) | |
490 && !(pFace->uAttributes & 0x20000000) | |
491 && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1 | |
492 && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 ) | |
608 { | 493 { |
609 v42 = 0; | 494 if ( pFace->uNumVertices ) |
610 v34 = v10->uNumFaces; | |
611 if ( (signed int)v10->uNumFaces > 0 ) | |
612 { | 495 { |
613 v39 = 0; | 496 for ( uint i = 0; i < pFace->uNumVertices; ++i) |
614 while ( 1 ) | |
615 { | 497 { |
616 v11 = &v10->pFaces[v39]; | 498 word_721040[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; |
617 v12 = v11->uPolygonType; | 499 word_720F70[2 * i] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; |
618 if ( (v12 == 3 || v12 == 4) | 500 word_721040[2 * i + 1] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; |
619 && !(v11->uAttributes & 0x20000000) | 501 word_720F70[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; |
620 && v8 <= v11->pBoundingBox.x2 | 502 } |
621 && v8 >= v11->pBoundingBox.x1 | 503 } |
622 && v7 <= v11->pBoundingBox.y2 | 504 word_721040[2 * pFace->uNumVertices] = word_721040[0]; |
623 && v7 >= v11->pBoundingBox.y1 ) | 505 word_720F70[2 * pFace->uNumVertices] = word_720F70[0]; |
506 v43 = word_720F70[0] >= Y; | |
507 v48 = 0; | |
508 if ( 2 * pFace->uNumVertices > 0 ) | |
509 { | |
510 for ( int i = 0; i < 2 * pFace->uNumVertices; ++i ) | |
511 { | |
512 if ( v48 >= 2 ) | |
513 break; | |
514 v36 = word_720F70[i + 1]; | |
515 v44 = word_720F70[i + 1] >= Y; | |
516 if ( v43 != v44 ) | |
624 { | 517 { |
625 v47 = 0; | 518 v18 = word_721040[i + 1] >= X ? 0 : 2; |
626 if ( v11->uNumVertices ) | 519 v19 = v18 | word_721040[i] < X; |
520 if ( v19 != 3 ) | |
627 { | 521 { |
628 v13 = (char *)v11->pXInterceptDisplacements; | 522 if ( !v19 ) |
629 do | |
630 { | 523 { |
631 v14 = 2 * v47; | 524 LODWORD(v23) = (Y - word_720F70[i]) << 16; |
632 word_721040[2 * v47] = *(short *)v13 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].x); | 525 HIDWORD(v23) = (Y - word_720F70[i]) >> 16; |
633 word_720F70[2 * v47] = *((short *)v13 + 20) | 526 v22 = ((((word_721040[i + 1] - word_721040[i]) * v23 / (v36 - word_720F70[i])) >> 16) + word_721040[i]); |
634 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].y); | 527 if ( v22 >= X) |
635 word_721040[2 * v47++ + 1] = *(short *)v13 | 528 ++v48; |
636 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].x); | |
637 word_720F70[v14 + 1] = *((short *)v13 + 20) | |
638 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].y); | |
639 v13 += 2; | |
640 } | |
641 while ( v47 < v11->uNumVertices ); | |
642 v8 = v40; | |
643 } | |
644 v15 = 2 * v11->uNumVertices; | |
645 word_721040[2 * v11->uNumVertices] = word_721040[0]; | |
646 word_720F70[v15] = word_720F70[0]; | |
647 v35 = v15; | |
648 v16 = 0; | |
649 v43 = word_720F70[0] >= v45; | |
650 v48 = 0; | |
651 v37 = 0; | |
652 if ( v15 > 0 ) | |
653 { | |
654 do | |
655 { | |
656 if ( v48 >= 2 ) | |
657 break; | |
658 v17 = v16; | |
659 v8 = v40; | |
660 v36 = word_720F70[v16 + 1]; | |
661 v44 = word_720F70[v16 + 1] >= v45; | |
662 if ( v43 != v44 ) | |
663 { | |
664 v18 = word_721040[v17 + 1] >= v40 ? 0 : 2; | |
665 v19 = v18 | word_721040[v17] < v40; | |
666 if ( v19 != 3 ) | |
667 { | |
668 if ( !v19 | |
669 || (v20 = word_720F70[v17], | |
670 v21 = v36 - v20, | |
671 v22 = v45 - v20, | |
672 LODWORD(v23) = v22 << 16, | |
673 HIDWORD(v23) = v22 >> 16, | |
674 (signed int)(((unsigned __int64)(((signed int)word_721040[v17 + 1] | |
675 - (signed int)word_721040[v17]) | |
676 * v23 | |
677 / v21) >> 16) | |
678 + word_721040[v17]) >= v40) ) | |
679 ++v48; | |
680 } | |
681 } | |
682 v16 = v37 + 1; | |
683 v43 = v44; | |
684 ++v37; | |
685 } | |
686 while ( v37 < v35 ); | |
687 if ( v48 == 1 ) | |
688 { | |
689 if ( v46 >= 20 ) | |
690 break; | |
691 if ( v11->uPolygonType == 3 ) | |
692 v24 = v10->pVertices.pVertices[v11->pVertexIDs[0]].z; | |
693 else | |
694 v24 = ((unsigned __int64)(v11->zCalc1 * (signed __int64)v8) >> 16) | |
695 + ((unsigned __int64)(v11->zCalc2 * (signed __int64)v45) >> 16) | |
696 + HIWORD(v11->zCalc3); | |
697 v25 = v46++; | |
698 dword_7211B0[v25] = v24; | |
699 dword_721160[v25] = v41; | |
700 dword_721110[v25] = v42; | |
701 } | 529 } |
702 } | 530 } |
703 } | 531 } |
704 ++v42; | 532 v43 = v44; |
705 ++v39; | 533 } |
706 if ( v42 >= v34 ) | 534 if ( v48 == 1 ) |
535 { | |
536 if ( v46 >= 20 ) | |
707 break; | 537 break; |
708 v7 = v45; | 538 if ( pFace->uPolygonType == POLYGON_Floor ) |
539 v24 = pBModel->pVertices.pVertices[pFace->pVertexIDs[0]].z; | |
540 else | |
541 v24 = ((pFace->zCalc1 * X) >> 16) + ((pFace->zCalc2 * Y) >> 16) + pFace->zCalc3; | |
542 v25 = v46++; | |
543 floor_level[v25] = v24; | |
544 dword_721160[v25] = pBModelNum; | |
545 dword_721110[v25] = pFaceNum; | |
709 } | 546 } |
710 } | 547 } |
711 } | 548 } |
712 } | 549 ++v39; |
713 } | 550 } |
714 } | 551 } |
715 ++v41; | 552 } |
716 ++v38; | 553 ++v38; |
717 if ( v41 >= (signed int)pOutdoor->uNumBModels ) | |
718 break; | |
719 v7 = v45; | |
720 } | 554 } |
721 if ( v46 == 1 ) | 555 if ( v46 == 1 ) |
722 { | 556 { |
723 LABEL_63: | |
724 *a6 = 0; | 557 *a6 = 0; |
725 return dword_7211B0[0]; | 558 return floor_level[0]; |
726 } | 559 } |
727 v27 = 0; | 560 v27 = 0; |
728 v49 = 1; | |
729 if ( v46 <= 1 ) | 561 if ( v46 <= 1 ) |
730 { | |
731 LABEL_55: | |
732 *a6 = 0; | 562 *a6 = 0; |
733 goto LABEL_56; | 563 else |
734 } | 564 { |
735 v28 = 0; | 565 v28 = 0; |
736 v29 = 1; | 566 v29 = 1; |
737 do | 567 for ( v49 = 1; v49 < v46; ++v49 ) |
738 { | 568 { |
739 v30 = dword_7211B0[v29]; | 569 if ( floor_level[v29] == floor_level[v28] ) |
740 v31 = *(int *)((char *)dword_7211B0 + v28); | 570 { |
741 if ( v30 == v31 ) | 571 v27 = v49; |
742 goto LABEL_51; | 572 v28 = v29 * 4; |
743 if ( v31 > a3 + 5 ) | 573 ++v29; |
744 { | 574 break; |
745 if ( v30 >= v31 ) | 575 } |
746 goto LABEL_52; | 576 if ( floor_level[v28] > Z + 5 ) |
747 LABEL_51: | 577 { |
748 v27 = v49; | 578 if ( floor_level[v29] >= floor_level[v28] ) |
749 v28 = v29 * 4; | 579 { |
750 goto LABEL_52; | 580 ++v29; |
751 } | 581 break; |
752 if ( v30 > v31 && v30 <= a3 + 5 ) | 582 } |
753 goto LABEL_51; | 583 v27 = v49; |
754 LABEL_52: | 584 v28 = v29 * 4; |
755 ++v49; | 585 ++v29; |
756 ++v29; | 586 break; |
757 } | 587 } |
758 while ( v49 < v46 ); | 588 if ( floor_level[v29] > floor_level[v28] && floor_level[v29] <= Z + 5 ) |
759 if ( !v27 ) | 589 { |
760 goto LABEL_55; | 590 v27 = v49; |
761 *a6 = dword_721110[v27] | (dword_721160[v27] << 6); | 591 v28 = v29 * 4; |
762 LABEL_56: | 592 ++v29; |
593 } | |
594 } | |
595 if ( !v27 ) | |
596 *a6 = 0; | |
597 else | |
598 *a6 = dword_721110[v27] | (dword_721160[v27] << 6); | |
599 } | |
763 if ( v27 ) | 600 if ( v27 ) |
764 { | 601 { |
765 v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]]; | 602 v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]]; |
766 *a5 = 0; | 603 *a5 = 0; |
767 if ( v32->uAttributes & 0x10 ) | 604 if ( v32->uAttributes & 0x10 ) |
768 *a5 = 1; | 605 *a5 = 1; |
769 } | 606 } |
770 v33 = dword_7211B0[v27]; | 607 v33 = floor_level[v27]; |
771 result = dword_7211B0[0]; | 608 result = floor_level[0]; |
772 if ( v33 >= dword_7211B0[0] ) | 609 if ( v33 >= floor_level[0] ) |
773 result = v33; | 610 result = v33; |
774 return result; | 611 return result; |
775 } | 612 } |
776 | 613 |
777 //----- (0046D8E3) -------------------------------------------------------- | 614 //----- (0046D8E3) -------------------------------------------------------- |