comparison mm7_4.cpp @ 728:9f596a163257

Merge
author Nomad
date Fri, 22 Mar 2013 00:06:50 +0200
parents da130dd3092a 9d13d2ec35a6
children 8323734d58c8
comparison
equal deleted inserted replaced
727:da130dd3092a 728:9f596a163257
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 v37; // 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[0]].z;
399 } 334 }
400 else 335 else
401 { 336 {
402 //v7 = pIndoor->pVertices; 337 v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16) + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16)
403 v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16)
404 + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16)
405 + HIWORD(pFloor->zCalc3); 338 + HIWORD(pFloor->zCalc3);
406 } 339 }
407 v22 = v55++; 340 v22 = v55++;
408 dword_7212C8[v22] = v21; 341 blv_floor_level[v22] = v21;
409 dword_721200[v22] = pSector->pFloors[i]; 342 dword_721200[v22] = pSector->pFloors[i];
410 } 343 }
411 } 344 }
412 } 345 }
413 //v6 = uSectorIDa + 1;
414 } 346 }
415 347
416 if ( pSector->field_0 & 8 ) 348 if ( pSector->field_0 & 8 )
417 { 349 {
418 for (uint i = 0; i < pSector->uNumPortals; ++i) 350 for (uint i = 0; i < pSector->uNumPortals; ++i)
419 { 351 {
420 //v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]];
421 auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; 352 auto portal = &pIndoor->pFaces[pSector->pPortals[i]];
422 if (portal->uPolygonType != POLYGON_Floor) 353 if (portal->uPolygonType != POLYGON_Floor)
423 continue; 354 continue;
424 355
425 if (x <= portal->pBounding.x2 && 356 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 &&
426 x >= portal->pBounding.x1 && 357 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 )
427 y <= portal->pBounding.y2 && 358 {
428 y >= portal->pBounding.y1 )
429 {
430 //v46 = 0;
431 for (uint j = 0; j < portal->uNumVertices; ++j) 359 for (uint j = 0; j < portal->uNumVertices; ++j)
432 { 360 {
433 //v24 = v46;
434 //v25 = 2 * v46;
435 word_721460[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; 361 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; 362 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; 363 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; 364 word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y;
439 //} 365 }
440 //while ( v46 < v23->uNumVertices );
441 //v5 = v43;
442 }
443
444 //v26 = 2 * v23->uNumVertices;
445 word_721460[2 * portal->uNumVertices] = word_721460[0]; 366 word_721460[2 * portal->uNumVertices] = word_721460[0];
446 word_721390[2 * portal->uNumVertices] = word_721390[0]; 367 word_721390[2 * portal->uNumVertices] = word_721390[0];
447 v54 = 0; 368 v54 = 0;
448 v51 = 0;
449 v49 = word_721390[0] >= y; 369 v49 = word_721390[0] >= y;
450 if ( portal->uNumVertices > 0 ) 370 if ( portal->uNumVertices > 0 )
451 { 371 {
452 do 372 for ( int i = 0; i < 2 * portal->uNumVertices; ++i )
453 { 373 {
454 if ( v54 >= 2 ) 374 if ( v54 >= 2 )
455 break; 375 break;
456 v27 = v51; 376 v47 = word_721390[i + 1] >= y;
457 v47 = word_721390[v51 + 1] >= y;
458 if ( v49 != v47 ) 377 if ( v49 != v47 )
459 { 378 {
460 if ( word_721460[v27 + 1] >= x ) 379 v28 = word_721460[i + 1] >= x ? 0 : 2;
461 v28 = 0; 380 v29 = v28 | word_721460[i] < x;
462 else
463 v28 = 2;
464 v29 = v28 | word_721460[v27] < x;
465 if ( v29 != 3 ) 381 if ( v29 != 3 )
466 { 382 {
467 if ( !v29 383 if ( !v29 )
468 || (v30 = word_721390[v27], 384 LODWORD(v33) = (y - word_721390[i]) << 16;
469 v31 = word_721390[v51 + 1] - v30, 385 HIDWORD(v33) = (y - word_721390[i]) >> 16;
470 v32 = y - v30, 386 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, 387 if ( v30 >= x)
472 HIDWORD(v33) = v32 >> 16, 388 ++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 } 389 }
480 } 390 }
481 ++v51;
482 v49 = v47; 391 v49 = v47;
483 } 392 }
484 while ( v51 < 2 * portal->uNumVertices );
485
486 if ( v54 == 1 ) 393 if ( v54 == 1 )
487 { 394 {
488 if ( v55 >= 50 ) 395 if ( v55 >= 50 )
489 break; 396 break;
490 v34 = v55++; 397 v34 = v55++;
491 dword_7212C8[v34] = -29000; 398 blv_floor_level[v34] = -29000;
492 dword_721200[v34] = pSector->pPortals[i]; 399 dword_721200[v34] = pSector->pPortals[i];
493 } 400 }
494 } 401 }
495 } 402 }
496 } 403 }
497 } 404 }
498
499 v35 = 1;
500 if ( v55 == 1 ) 405 if ( v55 == 1 )
501 { 406 {
502 *pFaceID = dword_721200[0]; 407 *pFaceID = dword_721200[0];
503 return dword_7212C8[0]; 408 return blv_floor_level[0];
504 } 409 }
505 if ( !v55 ) 410 if ( !v55 )
506 return -30000; 411 return -30000;
507 *pFaceID = dword_721200[0]; 412 *pFaceID = dword_721200[0];
508 result = dword_7212C8[0]; 413 //result = blv_floor_level[0];
509 if ( v55 > 1 ) 414 if ( v55 > 1 )
510 { 415 {
511 v37 = z + 5; 416 for ( v35 = 1; v35 < v55; ++v35 )
512 while ( 1 ) 417 {
513 { 418 if ( blv_floor_level[0] <= z + 5 )
514 v38 = dword_7212C8[v35]; 419 {
515 if ( result <= v37 ) 420 if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 )
516 break; 421 continue;
517 if ( v38 < result ) 422 blv_floor_level[0] = blv_floor_level[v35];
518 goto LABEL_67; 423 *pFaceID = dword_721200[v35];
519 LABEL_68: 424 continue;
520 ++v35; 425 }
521 if ( v35 >= v55 ) 426 if ( blv_floor_level[v35] < blv_floor_level[0] )
522 return result; 427 {
523 } 428 blv_floor_level[0] = blv_floor_level[v35];
524 if ( v38 <= result || v38 > v37 ) 429 *pFaceID = dword_721200[v35];
525 goto LABEL_68; 430 }
526 LABEL_67: 431 }
527 result = dword_7212C8[v35]; 432 }
528 *pFaceID = dword_721200[v35]; 433 return blv_floor_level[0];
529 goto LABEL_68;
530 }
531 return result;
532 } 434 }
533 435
534 //----- (0046D49E) -------------------------------------------------------- 436 //----- (0046D49E) --------------------------------------------------------
535 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) 437 int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int a4, int *a5, int *a6, int a7)
536 { 438 {
537 signed int v7; // edi@1 439 BSPModel *pBModel; // esi@4
538 int v8; // ebx@1 440 ODMFace *pFace; // ecx@11
539 int v9; // eax@1
540 BSPModel *v10; // esi@4
541 ODMFace *v11; // ecx@11
542 unsigned __int8 v12; // al@11
543 char *v13; // eax@19
544 int v14; // edx@20 441 int v14; // edx@20
545 int v15; // eax@22
546 int v16; // edx@22
547 int v17; // edi@24
548 signed int v18; // edx@26 442 signed int v18; // edx@26
549 int v19; // eax@28 443 int v19; // eax@28
550 int v20; // edx@30 444 int v20; // edx@30
551 int v21; // ST1C_4@30 445 int v21; // ST1C_4@30
552 signed int v22; // edx@30 446 signed int v22; // edx@30
559 signed int v29; // edx@44 453 signed int v29; // edx@44
560 int v30; // esi@45 454 int v30; // esi@45
561 int v31; // eax@45 455 int v31; // eax@45
562 ODMFace *v32; // eax@57 456 ODMFace *v32; // eax@57
563 int v33; // ecx@59 457 int v33; // ecx@59
564 int v34; // [sp+Ch] [bp-34h]@8
565 int v35; // [sp+10h] [bp-30h]@22
566 int v36; // [sp+14h] [bp-2Ch]@24 458 int v36; // [sp+14h] [bp-2Ch]@24
567 int v37; // [sp+18h] [bp-28h]@22
568 int v38; // [sp+1Ch] [bp-24h]@2 459 int v38; // [sp+1Ch] [bp-24h]@2
569 int v39; // [sp+20h] [bp-20h]@9 460 int v39; // [sp+20h] [bp-20h]@9
570 int v40; // [sp+24h] [bp-1Ch]@1 461 signed int pBModelNum; // [sp+28h] [bp-18h]@1
571 signed int v41; // [sp+28h] [bp-18h]@1 462 int pFaceNum; // [sp+2Ch] [bp-14h]@8
572 int v42; // [sp+2Ch] [bp-14h]@8
573 bool v43; // [sp+30h] [bp-10h]@22 463 bool v43; // [sp+30h] [bp-10h]@22
574 bool v44; // [sp+34h] [bp-Ch]@24 464 bool v44; // [sp+34h] [bp-Ch]@24
575 signed int v45; // [sp+38h] [bp-8h]@1
576 signed int v46; // [sp+3Ch] [bp-4h]@1 465 signed int v46; // [sp+3Ch] [bp-4h]@1
577 signed int v47; // [sp+58h] [bp+18h]@18
578 signed int v48; // [sp+58h] [bp+18h]@22 466 signed int v48; // [sp+58h] [bp+18h]@22
579 signed int v49; // [sp+58h] [bp+18h]@43 467 signed int v49; // [sp+58h] [bp+18h]@43
580 468
581 v7 = a2;
582 v8 = a1;
583 v45 = a2;
584 v40 = a1;
585 v46 = 1; 469 v46 = 1;
586 v9 = GetTerrainHeightsAroundParty2(a1, a2, a5, a7);
587 dword_721160[0] = -1; 470 dword_721160[0] = -1;
588 dword_721110[0] = -1; 471 dword_721110[0] = -1;
589 dword_7211B0[0] = v9; 472 odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, a5, a7);
590 v41 = 0;
591 if ( (signed int)pOutdoor->uNumBModels <= 0 ) 473 if ( (signed int)pOutdoor->uNumBModels <= 0 )
592 goto LABEL_63; 474 {
475 *a6 = 0;
476 return odm_floor_level[0];
477 }
593 v38 = 0; 478 v38 = 0;
594 while ( 1 ) 479 for ( pBModelNum = 0; pBModelNum < (signed int)pOutdoor->uNumBModels; ++pBModelNum )
595 { 480 {
596 v10 = &pOutdoor->pBModels[v38]; 481 pBModel = &pOutdoor->pBModels[v38];
597 if ( v8 <= pOutdoor->pBModels[v38].sMaxX ) 482 if ( X <= pBModel->sMaxX && X >= pBModel->sMinX && Y <= pBModel->sMaxY && Y >= pBModel->sMinY )
598 { 483 {
599 if ( v8 >= v10->sMinX ) 484 if ( (signed int)pBModel->uNumFaces > 0 )
600 { 485 {
601 if ( v7 <= v10->sMaxY ) 486 v39 = 0;
602 { 487 for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum )
603 if ( v7 >= v10->sMinY ) 488 {
489 pFace = &pBModel->pFaces[v39];
490 if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall)
491 && !(pFace->uAttributes & 0x20000000)
492 && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1
493 && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 )
604 { 494 {
605 v42 = 0; 495 if ( pFace->uNumVertices )
606 v34 = v10->uNumFaces;
607 if ( (signed int)v10->uNumFaces > 0 )
608 { 496 {
609 v39 = 0; 497 for ( uint i = 0; i < pFace->uNumVertices; ++i)
610 while ( 1 )
611 { 498 {
612 v11 = &v10->pFaces[v39]; 499 word_721040[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x;
613 v12 = v11->uPolygonType; 500 word_720F70[2 * i] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y;
614 if ( (v12 == 3 || v12 == 4) 501 word_721040[2 * i + 1] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x;
615 && !(v11->uAttributes & 0x20000000) 502 word_720F70[2 * i + 1] = pFace->pXInterceptDisplacements[i + 1] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y;
616 && v8 <= v11->pBoundingBox.x2 503 }
617 && v8 >= v11->pBoundingBox.x1 504 }
618 && v7 <= v11->pBoundingBox.y2 505 word_721040[2 * pFace->uNumVertices] = word_721040[0];
619 && v7 >= v11->pBoundingBox.y1 ) 506 word_720F70[2 * pFace->uNumVertices] = word_720F70[0];
507 v43 = word_720F70[0] >= Y;
508 v48 = 0;
509 if ( 2 * pFace->uNumVertices > 0 )
510 {
511 for ( int i = 0; i < 2 * pFace->uNumVertices; ++i )
512 {
513 if ( v48 >= 2 )
514 break;
515 v36 = word_720F70[i + 1];
516 v44 = word_720F70[i + 1] >= Y;
517 if ( v43 != v44 )
620 { 518 {
621 v47 = 0; 519 v18 = word_721040[i + 1] >= X ? 0 : 2;
622 if ( v11->uNumVertices ) 520 v19 = v18 | word_721040[i] < X;
521 if ( v19 != 3 )
623 { 522 {
624 v13 = (char *)v11->pXInterceptDisplacements; 523 if ( !v19 )
625 do
626 { 524 {
627 v14 = 2 * v47; 525 LODWORD(v23) = (Y - word_720F70[i]) << 16;
628 word_721040[2 * v47] = *(short *)v13 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].x); 526 HIDWORD(v23) = (Y - word_720F70[i]) >> 16;
629 word_720F70[2 * v47] = *((short *)v13 + 20) 527 v22 = ((((word_721040[i + 1] - word_721040[i]) * v23 / (v36 - word_720F70[i])) >> 16) + word_721040[i]);
630 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 60)].y); 528 if ( v22 >= X)
631 word_721040[2 * v47++ + 1] = *(short *)v13 529 ++v48;
632 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].x);
633 word_720F70[v14 + 1] = *((short *)v13 + 20)
634 + LOWORD(v10->pVertices.pVertices[*((short *)v13 - 59)].y);
635 v13 += 2;
636 }
637 while ( v47 < v11->uNumVertices );
638 v8 = v40;
639 }
640 v15 = 2 * v11->uNumVertices;
641 word_721040[2 * v11->uNumVertices] = word_721040[0];
642 word_720F70[v15] = word_720F70[0];
643 v35 = v15;
644 v16 = 0;
645 v43 = word_720F70[0] >= v45;
646 v48 = 0;
647 v37 = 0;
648 if ( v15 > 0 )
649 {
650 do
651 {
652 if ( v48 >= 2 )
653 break;
654 v17 = v16;
655 v8 = v40;
656 v36 = word_720F70[v16 + 1];
657 v44 = word_720F70[v16 + 1] >= v45;
658 if ( v43 != v44 )
659 {
660 v18 = word_721040[v17 + 1] >= v40 ? 0 : 2;
661 v19 = v18 | word_721040[v17] < v40;
662 if ( v19 != 3 )
663 {
664 if ( !v19
665 || (v20 = word_720F70[v17],
666 v21 = v36 - v20,
667 v22 = v45 - v20,
668 LODWORD(v23) = v22 << 16,
669 HIDWORD(v23) = v22 >> 16,
670 (signed int)(((unsigned __int64)(((signed int)word_721040[v17 + 1]
671 - (signed int)word_721040[v17])
672 * v23
673 / v21) >> 16)
674 + word_721040[v17]) >= v40) )
675 ++v48;
676 }
677 }
678 v16 = v37 + 1;
679 v43 = v44;
680 ++v37;
681 }
682 while ( v37 < v35 );
683 if ( v48 == 1 )
684 {
685 if ( v46 >= 20 )
686 break;
687 if ( v11->uPolygonType == 3 )
688 v24 = v10->pVertices.pVertices[v11->pVertexIDs[0]].z;
689 else
690 v24 = ((unsigned __int64)(v11->zCalc1 * (signed __int64)v8) >> 16)
691 + ((unsigned __int64)(v11->zCalc2 * (signed __int64)v45) >> 16)
692 + HIWORD(v11->zCalc3);
693 v25 = v46++;
694 dword_7211B0[v25] = v24;
695 dword_721160[v25] = v41;
696 dword_721110[v25] = v42;
697 } 530 }
698 } 531 }
699 } 532 }
700 ++v42; 533 v43 = v44;
701 ++v39; 534 }
702 if ( v42 >= v34 ) 535 if ( v48 == 1 )
536 {
537 if ( v46 >= 20 )
703 break; 538 break;
704 v7 = v45; 539 if ( pFace->uPolygonType == POLYGON_Floor )
540 v24 = pBModel->pVertices.pVertices[pFace->pVertexIDs[0]].z;
541 else
542 v24 = ((unsigned __int64)(pFace->zCalc1 * (signed __int64)X) >> 16) + ((unsigned __int64)(pFace->zCalc2 * (signed __int64)Y) >> 16)
543 + HIWORD(pFace->zCalc3);
544 v25 = v46++;
545 odm_floor_level[v25] = v24;
546 dword_721160[v25] = pBModelNum;
547 dword_721110[v25] = pFaceNum;
705 } 548 }
706 } 549 }
707 } 550 }
708 } 551 ++v39;
709 } 552 }
710 } 553 }
711 ++v41; 554 }
712 ++v38; 555 ++v38;
713 if ( v41 >= (signed int)pOutdoor->uNumBModels )
714 break;
715 v7 = v45;
716 } 556 }
717 if ( v46 == 1 ) 557 if ( v46 == 1 )
718 { 558 {
719 LABEL_63:
720 *a6 = 0; 559 *a6 = 0;
721 return dword_7211B0[0]; 560 return odm_floor_level[0];
722 } 561 }
723 v27 = 0; 562 v27 = 0;
724 v49 = 1;
725 if ( v46 <= 1 ) 563 if ( v46 <= 1 )
726 {
727 LABEL_55:
728 *a6 = 0; 564 *a6 = 0;
729 goto LABEL_56; 565 else
730 } 566 {
731 v28 = 0; 567 //v29 = 1;
732 v29 = 1; 568 for ( v49 = 1; v49 < v46; ++v49 )
733 do 569 {
734 { 570 if ( odm_floor_level[v49] == odm_floor_level[0] )
735 v30 = dword_7211B0[v29]; 571 {
736 v31 = *(int *)((char *)dword_7211B0 + v28); 572 v27 = v49;
737 if ( v30 == v31 ) 573 //++v29;
738 goto LABEL_51; 574 break;
739 if ( v31 > a3 + 5 ) 575 }
740 { 576 if ( odm_floor_level[0] > Z + 5 )
741 if ( v30 >= v31 ) 577 {
742 goto LABEL_52; 578 if ( odm_floor_level[v49] >= odm_floor_level[0] )
743 LABEL_51: 579 {
744 v27 = v49; 580 //++v29;
745 v28 = v29 * 4; 581 break;
746 goto LABEL_52; 582 }
747 } 583 v27 = v49;
748 if ( v30 > v31 && v30 <= a3 + 5 ) 584 //++v29;
749 goto LABEL_51; 585 break;
750 LABEL_52: 586 }
751 ++v49; 587 if ( odm_floor_level[v49] > odm_floor_level[0] && odm_floor_level[v49] <= Z + 5 )
752 ++v29; 588 {
753 } 589 v27 = v49;
754 while ( v49 < v46 ); 590 //++v29;
755 if ( !v27 ) 591 }
756 goto LABEL_55; 592 }
757 *a6 = dword_721110[v27] | (dword_721160[v27] << 6); 593 if ( !v27 )
758 LABEL_56: 594 *a6 = 0;
595 else
596 *a6 = dword_721110[v27] | (dword_721160[v27] << 6);
597 }
759 if ( v27 ) 598 if ( v27 )
760 { 599 {
761 v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]]; 600 v32 = &pOutdoor->pBModels[dword_721160[v27]].pFaces[dword_721110[v27]];
762 *a5 = 0; 601 *a5 = 0;
763 if ( v32->uAttributes & 0x10 ) 602 if ( v32->uAttributes & 0x10 )
764 *a5 = 1; 603 *a5 = 1;
765 } 604 }
766 v33 = dword_7211B0[v27]; 605 if ( odm_floor_level[v27] >= odm_floor_level[0] )
767 result = dword_7211B0[0]; 606 odm_floor_level[0] = odm_floor_level[v27];
768 if ( v33 >= dword_7211B0[0] ) 607 return odm_floor_level[0];
769 result = v33;
770 return result;
771 } 608 }
772 609
773 //----- (0046D8E3) -------------------------------------------------------- 610 //----- (0046D8E3) --------------------------------------------------------
774 int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4) 611 int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4)
775 { 612 {
5919 } 5756 }
5920 5757
5921 5758
5922 5759
5923 //----- (004AD504) -------------------------------------------------------- 5760 //----- (004AD504) --------------------------------------------------------
5924 int __fastcall sub_4AD504(unsigned int uFaceID) 5761 int __fastcall sub_4AD504(signed int sFaceID)
5925 { 5762 {
5926 int result; // eax@1 5763 int result; // eax@1
5927 unsigned int v2; // ebx@1 5764 signed int v2; // ebx@1
5928 BLVFace *v3; // esi@3 5765 BLVFace *v3; // esi@3
5929 Texture *v4; // edi@6 5766 Texture *v4; // edi@6
5930 int v5; // eax@7 5767 int v5; // eax@7
5931 int v6; // edx@7 5768 int v6; // edx@7
5932 int v7; // ecx@7 5769 int v7; // ecx@7
6046 unsigned int v121; // [sp+98h] [bp-Ch]@15 5883 unsigned int v121; // [sp+98h] [bp-Ch]@15
6047 unsigned __int16 *v122; // [sp+9Ch] [bp-8h]@15 5884 unsigned __int16 *v122; // [sp+9Ch] [bp-8h]@15
6048 unsigned int v123; // [sp+A0h] [bp-4h]@13 5885 unsigned int v123; // [sp+A0h] [bp-4h]@13
6049 5886
6050 result = pRenderer->uTargetSurfacePitch; 5887 result = pRenderer->uTargetSurfacePitch;
6051 v2 = uFaceID; 5888 v2 = sFaceID;
6052 v95 = pRenderer->uTargetSurfacePitch; 5889 v95 = pRenderer->uTargetSurfacePitch;
6053 if ( (uFaceID & 0x80000000u) == 0 ) 5890 if ( sFaceID >= 0 )
6054 { 5891 {
6055 if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces ) 5892 if ( sFaceID < (signed int)pIndoor->uNumFaces )
6056 { 5893 {
6057 v3 = &pIndoor->pFaces[uFaceID]; 5894 v3 = &pIndoor->pFaces[sFaceID];
6058 v91 = &pIndoor->pFaces[uFaceID]; 5895 v91 = &pIndoor->pFaces[sFaceID];
6059 if ( !pRenderer->pRenderD3D ) 5896 if ( !pRenderer->pRenderD3D )
6060 { 5897 {
6061 result = sub_423B5D(uFaceID); 5898 result = sub_423B5D(sFaceID);
6062 if ( result ) 5899 if ( result )
6063 { 5900 {
6064 result = sub_424829(result, &stru_F8A590, pBLVRenderParams->field_7C, v2); 5901 result = sub_424829(result, &stru_F8A590, pBLVRenderParams->field_7C, v2);
6065 if ( result ) 5902 if ( result )
6066 { 5903 {
8761 a1.uFrameWidth = 148; 8598 a1.uFrameWidth = 148;
8762 a1.uFrameZ = 334; 8599 a1.uFrameZ = 334;
8763 v2 = pTransitionStrings[uHouse_ExitPic]; 8600 v2 = pTransitionStrings[uHouse_ExitPic];
8764 if ( !v2 ) 8601 if ( !v2 )
8765 { 8602 {
8766 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[411], v0); 8603 sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[411], v0);
8767 v2 = pTmpBuf; 8604 v2 = pTmpBuf;
8768 } 8605 }
8769 v3 = v2; 8606 v3 = v2;
8770 v4 = pFontCreate->CalcTextHeight(v2, &a1, 0, 0); 8607 v4 = pFontCreate->CalcTextHeight(v2, &a1, 0, 0);
8771 LOBYTE(i) = (unsigned int)a1.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, v3, 3u); 8608 LOBYTE(i) = (unsigned int)a1.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, v3, 3u);
9619 pParty->field_709 = 0; 9456 pParty->field_709 = 0;
9620 Party__CountHirelings(); 9457 Party__CountHirelings();
9621 9458
9622 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); 9459 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
9623 9460
9624 if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) 9461 if ( sDialogue_SpeakingActorNPC_ID >= 0 )
9625 pDialogue_SpeakingActor->uAIState = Removed; 9462 pDialogue_SpeakingActor->uAIState = Removed;
9626 if ( uActiveCharacter ) 9463 if ( uActiveCharacter )
9627 pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); 9464 pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
9628 } 9465 }
9629 } 9466 }
9840 9677
9841 9678
9842 9679
9843 9680
9844 //----- (004B6478) -------------------------------------------------------- 9681 //----- (004B6478) --------------------------------------------------------
9845 int __cdecl sub_4B6478() 9682 void sub_4B6478()
9846 { 9683 {
9847 GUIWindow *v0; // ebx@1 9684 GUIWindow *v0; // ebx@1
9848 Player *v1; // edi@1 9685 Player *v1; // edi@1
9849 unsigned int v2; // eax@1 9686 unsigned int v2; // eax@1
9850 signed int v3; // esi@1 9687 signed int v3; // esi@1
9851 int v4; // ebx@1 9688 int v4; // ebx@1
9948 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; 9785 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
9949 *(&pMessageQueue_50CBD0->uNumMessages + result) = v5; 9786 *(&pMessageQueue_50CBD0->uNumMessages + result) = v5;
9950 ++pMessageQueue_50CBD0->uNumMessages; 9787 ++pMessageQueue_50CBD0->uNumMessages;
9951 }*/ 9788 }*/
9952 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5); 9789 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5);
9953 return result; // void func 9790 return; // void func
9954 } 9791 }
9955 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->_guilds_member_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) ) 9792 if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->_guilds_member_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) )
9956 { 9793 {
9957 v24 = pNPCTopics[171].pText; 9794 v24 = pNPCTopics[171].pText;
9958 v25 = v31; 9795 v25 = v31;
9959 v26 = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &v28, 0, 0); 9796 v26 = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &v28, 0, 0);
9960 v28.DrawTitleText(pFontArrus, 0, (212 - v26) / 2 + 101, v25, v24, 3u); 9797 v28.DrawTitleText(pFontArrus, 0, (212 - v26) / 2 + 101, v25, v24, 3u);
9961 result = (int)pDialogueWindow;
9962 pDialogueWindow->pNumPresenceButton = 0; 9798 pDialogueWindow->pNumPresenceButton = 0;
9963 return result; 9799 return ;
9964 } 9800 }
9965 result = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); 9801
9966 if ( !result ) 9802 if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
9967 return result; 9803 return;
9968 v8 = pDialogueWindow; 9804 v8 = pDialogueWindow;
9969 v33 = 0; 9805 v33 = 0;
9970 v34 = 0; 9806 v34 = 0;
9971 v29 = pDialogueWindow; 9807 v29 = pDialogueWindow;
9972 v9 = pDialogueWindow->pStartingPosActiveItem; 9808 v9 = pDialogueWindow->pStartingPosActiveItem;
9993 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->classType]); 9829 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->classType]);
9994 strcat(pTmpBuf, "\n \n"); 9830 strcat(pTmpBuf, "\n \n");
9995 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); 9831 strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
9996 v22 = v31; 9832 v22 = v31;
9997 v23 = pFontArrus->CalcTextHeight(pTmpBuf, &v28, 0, 0); 9833 v23 = pFontArrus->CalcTextHeight(pTmpBuf, &v28, 0, 0);
9998 return (int)v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u); 9834 v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
9835 return;
9999 } 9836 }
10000 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v32); 9837 sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v32);
10001 v28.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u); 9838 v28.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
10002 v32 = (149 - v33) / v34; 9839 v32 = (149 - v33) / v34;
10003 if ( (149 - v33) / v34 > 32 ) 9840 if ( (149 - v33) / v34 > 32 )
10004 v32 = 32; 9841 v32 = 32;
10005 result = v8->pStartingPosActiveItem; 9842
10006 v35 = result; 9843 v35 = v8->pStartingPosActiveItem;
10007 v34 = (149 - v34 * v32 - v33) / 2 - v32 / 2 + 162; 9844 v34 = (149 - v34 * v32 - v33) / 2 - v32 / 2 + 162;
10008 if ( result < result + v8->pNumPresenceButton ) 9845 if ( v8->pStartingPosActiveItem < v8->pStartingPosActiveItem+ v8->pNumPresenceButton )
10009 { 9846 {
10010 v33 = 2; 9847 v33 = 2;
10011 do 9848 do
10012 { 9849 {
10013 v14 = v8->GetControl(v35); 9850 v14 = v8->GetControl(v35);
10041 v14->uY = v16; 9878 v14->uY = v16;
10042 LABEL_34: 9879 LABEL_34:
10043 v8 = v29; 9880 v8 = v29;
10044 ++v35; 9881 ++v35;
10045 ++v33; 9882 ++v33;
10046 result = v29->pNumPresenceButton + v29->pStartingPosActiveItem; 9883 }
10047 } 9884 while ( v35 <v29->pNumPresenceButton + v29->pStartingPosActiveItem );
10048 while ( v35 < result ); 9885 }
10049 } 9886 return;
10050 return result;
10051 } 9887 }
10052 9888
10053 9889
10054 9890
10055 //----- (004B6943) -------------------------------------------------------- 9891 //----- (004B6943) --------------------------------------------------------
10971 if ( !v23 ) 10807 if ( !v23 )
10972 { 10808 {
10973 v14 = pMapStats->GetMapInfo(pCurrentMapName); 10809 v14 = pMapStats->GetMapInfo(pCurrentMapName);
10974 if ( v14 ) 10810 if ( v14 )
10975 { 10811 {
10976 v20 = pMapStats->pInfos[v14].pName; 10812 sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v14].pName);
10977 v18 = pGlobalTXT_LocalizationStrings[410];
10978 LABEL_10:
10979 sprintf(sHouseName, v18, v20);
10980 goto LABEL_20; 10813 goto LABEL_20;
10981 } 10814 }
10982 v21 = pGlobalTXT_LocalizationStrings[79]; 10815 v21 = pGlobalTXT_LocalizationStrings[79];
10983 goto LABEL_19; 10816 goto LABEL_19;
10984 } 10817 }
10987 if ( *pLocationName == 48 ) 10820 if ( *pLocationName == 48 )
10988 v15 = pCurrentMapName; 10821 v15 = pCurrentMapName;
10989 v16 = pMapStats->GetMapInfo(v15); 10822 v16 = pMapStats->GetMapInfo(v15);
10990 if ( v16 ) 10823 if ( v16 )
10991 { 10824 {
10992 v20 = pMapStats->pInfos[v16].pName; 10825 sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[v16].pName);
10993 v18 = pGlobalTXT_LocalizationStrings[411]; 10826 goto LABEL_20;
10994 goto LABEL_10;
10995 } 10827 }
10996 v21 = pGlobalTXT_LocalizationStrings[73]; 10828 v21 = pGlobalTXT_LocalizationStrings[73];
10997 LABEL_19: 10829 LABEL_19:
10998 strcpy(sHouseName, v21); 10830 strcpy(sHouseName, v21);
10999 LABEL_20: 10831 LABEL_20: