Mercurial > might-and-magic-trilogy
comparison mm7_4.cpp @ 77:8b0c4d626477
Party movement
author | Nomad |
---|---|
date | Sun, 28 Oct 2012 18:51:52 +0200 |
parents | 75994455e457 |
children | 517e33e08d93 |
comparison
equal
deleted
inserted
replaced
76:75994455e457 | 77:8b0c4d626477 |
---|---|
232 } | 232 } |
233 } | 233 } |
234 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; | 234 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; |
235 | 235 |
236 //----- (0046CEC3) -------------------------------------------------------- | 236 //----- (0046CEC3) -------------------------------------------------------- |
237 int __fastcall _46CEC3_get_floor_level(signed int a1, signed int a2, int a3, unsigned int uSectorID, unsigned int *pFaceID) | 237 int _46CEC3_get_floor_level(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) |
238 { | 238 { |
239 BLVSector *v5; // edi@1 | 239 //BLVSector *v5; // edi@1 |
240 int v6; // ecx@1 | 240 //int v6; // ecx@1 |
241 Vec3_short_ *v7; // edx@1 | 241 //Vec3_short_ *v7; // edx@1 |
242 BLVFace *v8; // esi@2 | 242 //BLVFace *v8; // esi@2 |
243 int v9; // eax@8 | 243 //int v9; // eax@8 |
244 int v10; // edi@8 | 244 //int v10; // edi@8 |
245 int v11; // eax@10 | 245 //int v11; // eax@10 |
246 int v12; // ecx@10 | 246 int v12; // ecx@10 |
247 int v13; // ecx@13 | 247 int v13; // ecx@13 |
248 signed int v14; // ebx@14 | 248 signed int v14; // ebx@14 |
249 int v15; // eax@16 | 249 int v15; // eax@16 |
250 int v16; // edx@19 | 250 int v16; // edx@19 |
252 signed int v18; // edx@19 | 252 signed int v18; // edx@19 |
253 signed __int64 v19; // qtt@19 | 253 signed __int64 v19; // qtt@19 |
254 PolygonType v20; // al@25 | 254 PolygonType v20; // al@25 |
255 int v21; // eax@27 | 255 int v21; // eax@27 |
256 int v22; // ecx@29 | 256 int v22; // ecx@29 |
257 BLVFace *v23; // eax@33 | 257 //BLVFace *v23; // eax@33 |
258 int v24; // esi@39 | 258 //int v24; // esi@39 |
259 int v25; // edi@39 | 259 //int v25; // edi@39 |
260 int v26; // esi@41 | 260 int v26; // esi@41 |
261 int v27; // ecx@43 | 261 int v27; // ecx@43 |
262 signed int v28; // eax@45 | 262 signed int v28; // eax@45 |
263 int v29; // ebx@47 | 263 int v29; // ebx@47 |
264 int v30; // edx@49 | 264 int v30; // edx@49 |
268 signed int v34; // eax@54 | 268 signed int v34; // eax@54 |
269 signed int v35; // esi@56 | 269 signed int v35; // esi@56 |
270 int result; // eax@57 | 270 int result; // eax@57 |
271 int v37; // edi@61 | 271 int v37; // edi@61 |
272 int v38; // edx@62 | 272 int v38; // edx@62 |
273 int v39; // [sp+Ch] [bp-34h]@1 | 273 //int v39; // [sp+Ch] [bp-34h]@1 |
274 int v40; // [sp+10h] [bp-30h]@2 | 274 //int v40; // [sp+10h] [bp-30h]@2 |
275 int v41; // [sp+14h] [bp-2Ch]@12 | 275 int v41; // [sp+14h] [bp-2Ch]@12 |
276 unsigned __int16 *v42; // [sp+18h] [bp-28h]@1 | 276 //unsigned __int16 *v42; // [sp+18h] [bp-28h]@1 |
277 BLVSector *v43; // [sp+1Ch] [bp-24h]@1 | 277 //BLVSector *v43; // [sp+1Ch] [bp-24h]@1 |
278 int v44; // [sp+20h] [bp-20h]@10 | 278 int v44; // [sp+20h] [bp-20h]@10 |
279 int v45; // [sp+24h] [bp-1Ch]@10 | 279 int v45; // [sp+24h] [bp-1Ch]@10 |
280 signed int v46; // [sp+24h] [bp-1Ch]@38 | 280 //signed int v46; // [sp+24h] [bp-1Ch]@38 |
281 bool v47; // [sp+24h] [bp-1Ch]@43 | 281 bool v47; // [sp+24h] [bp-1Ch]@43 |
282 bool v48; // [sp+28h] [bp-18h]@10 | 282 bool v48; // [sp+28h] [bp-18h]@10 |
283 bool v49; // [sp+28h] [bp-18h]@41 | 283 bool v49; // [sp+28h] [bp-18h]@41 |
284 bool v50; // [sp+2Ch] [bp-14h]@12 | 284 bool v50; // [sp+2Ch] [bp-14h]@12 |
285 int v51; // [sp+2Ch] [bp-14h]@41 | 285 int v51; // [sp+2Ch] [bp-14h]@41 |
286 signed int v52; // [sp+30h] [bp-10h]@7 | 286 //signed int v52; // [sp+30h] [bp-10h]@7 |
287 signed int v53; // [sp+30h] [bp-10h]@10 | 287 signed int v53; // [sp+30h] [bp-10h]@10 |
288 signed int v54; // [sp+30h] [bp-10h]@41 | 288 signed int v54; // [sp+30h] [bp-10h]@41 |
289 signed int v55; // [sp+34h] [bp-Ch]@1 | 289 signed int v55; // [sp+34h] [bp-Ch]@1 |
290 signed int v56; // [sp+38h] [bp-8h]@1 | 290 //signed int v56; // [sp+38h] [bp-8h]@1 |
291 signed int v57; // [sp+3Ch] [bp-4h]@1 | 291 //signed int v57; // [sp+3Ch] [bp-4h]@1 |
292 int uSectorIDa; // [sp+4Ch] [bp+Ch]@1 | 292 //int uSectorIDa; // [sp+4Ch] [bp+Ch]@1 |
293 signed int uSectorIDb; // [sp+4Ch] [bp+Ch]@32 | 293 //signed int uSectorIDb; // [sp+4Ch] [bp+Ch]@32 |
294 | 294 |
295 __debugbreak(); | 295 LOG_DECOMPILATION_WARNING(); |
296 | 296 |
297 v5 = &pIndoor->pSectors[uSectorID]; | 297 //auto a1 = x; |
298 v57 = a2; | 298 //auto a2 = y; |
299 v56 = a1; | 299 //auto a3 = z; |
300 v6 = 0; | 300 |
301 //v5 = &pIndoor->pSectors[uSectorID]; | |
302 auto pSector = &pIndoor->pSectors[uSectorID]; | |
303 //v57 = y; | |
304 //v56 = x; | |
305 //v6 = 0; | |
301 v55 = 0; | 306 v55 = 0; |
302 v43 = v5; | 307 //v43 = v5; |
303 v42 = v5->pFloors; | 308 //v42 = v5->pFloors; |
304 v7 = pIndoor->pVertices; | 309 //v7 = pIndoor->pVertices; |
305 v39 = v5->uNumFloors; | 310 //v39 = v5->uNumFloors; |
306 for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa ) | 311 //for ( uSectorIDa = 0; uSectorIDa < v39; ++uSectorIDa ) |
307 { | 312 for (uint i = 0; i < pSector->uNumFloors; ++i) |
308 v40 = (int)&v42[v6]; | 313 { |
309 v8 = &pIndoor->pFaces[*(short *)v40]; | 314 //v40 = (int)&v42[v6]; |
310 if ( !(BYTE3(v8->uAttributes) & 0x20) | 315 //v8 = &pIndoor->pFaces[pSector->pFloors[i]]; |
311 && v56 <= v8->pBounding.x2 | 316 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; |
312 && v56 >= v8->pBounding.x1 | 317 if (pFloor->Clickable()) |
313 && v57 <= v8->pBounding.y2 | 318 continue; |
314 && v57 >= v8->pBounding.y1 ) | 319 |
315 { | 320 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && |
316 v52 = 0; | 321 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) |
317 if ( v8->uNumVertices ) | 322 { |
318 { | 323 //v52 = 0; |
319 do | 324 for (uint j = 0; j < pFloor->uNumVertices; ++j) |
320 { | 325 { |
321 v9 = v52; | 326 //v9 = v52; |
322 v10 = 2 * v52; | 327 //v10 = 2 * v52; |
323 word_721460[2 * v52] = v8->pXInterceptDisplacements[v52] + v7[v8->pVertexIDs[v52]].x; | 328 word_721460[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; |
324 word_721390[2 * v52] = v8->pYInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9]].y; | 329 word_721460[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; |
325 word_721460[2 * v52++ + 1] = v8->pXInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9 + 1]].x; | 330 word_721390[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; |
326 word_721390[v10 + 1] = v8->pYInterceptDisplacements[v9] + v7[v8->pVertexIDs[v9 + 1]].y; | 331 word_721390[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; |
327 } | 332 //} |
328 while ( v52 < v8->uNumVertices ); | 333 //while ( v52 < v8->uNumVertices ); |
329 v5 = v43; | 334 //v5 = v43; |
330 } | 335 } |
331 v44 = 2 * v8->uNumVertices; | 336 v44 = 2 * pFloor->uNumVertices; |
332 v11 = 2 * v8->uNumVertices; | 337 //v11 = 2 * pFloor->uNumVertices; |
333 word_721460[v11] = word_721460[0]; | 338 word_721460[2 * pFloor->uNumVertices] = word_721460[0]; |
334 word_721390[v11] = word_721390[0]; | 339 word_721390[2 * pFloor->uNumVertices] = word_721390[0]; |
335 v48 = word_721390[0] >= v57; | 340 |
341 v48 = word_721390[0] >= y; | |
336 v12 = 0; | 342 v12 = 0; |
337 v53 = 0; | 343 v53 = 0; |
338 v45 = 0; | 344 v45 = 0; |
339 if ( v44 > 0 ) | 345 if ( pFloor->uNumVertices > 0 ) |
340 { | 346 { |
341 do | 347 do |
342 { | 348 { |
343 if ( v53 >= 2 ) | 349 if ( v53 >= 2 ) |
344 break; | 350 break; |
345 v41 = word_721390[v12 + 1]; | 351 v41 = word_721390[v12 + 1]; |
346 v50 = word_721390[v12 + 1] >= v57; | 352 v50 = word_721390[v12 + 1] >= y; |
347 if ( v48 == v50 ) | 353 if ( v48 == v50 ) |
348 { | 354 { |
349 v13 = v45; | 355 v13 = v45; |
350 } | 356 } |
351 else | 357 else |
352 { | 358 { |
353 v13 = v45; | 359 v13 = v45; |
354 if ( word_721460[v45 + 1] >= v56 ) | 360 if ( word_721460[v45 + 1] >= x ) |
355 v14 = 0; | 361 v14 = 0; |
356 else | 362 else |
357 v14 = 2; | 363 v14 = 2; |
358 v15 = v14 | word_721460[v45] < v56; | 364 v15 = v14 | word_721460[v45] < x; |
359 if ( v15 != 3 ) | 365 if ( v15 != 3 ) |
360 { | 366 { |
361 if ( !v15 | 367 if ( !v15 |
362 || (v16 = word_721390[v45], | 368 || (v16 = word_721390[v45], |
363 v17 = v41 - v16, | 369 v17 = v41 - v16, |
364 v18 = v57 - v16, | 370 v18 = y - v16, |
365 LODWORD(v19) = v18 << 16, | 371 LODWORD(v19) = v18 << 16, |
366 HIDWORD(v19) = v18 >> 16, | 372 HIDWORD(v19) = v18 >> 16, |
367 v7 = pIndoor->pVertices, | 373 //v7 = pIndoor->pVertices, |
368 (signed int)(((unsigned __int64)(((signed int)word_721460[v45 + 1] - (signed int)word_721460[v45]) | 374 (signed int)(((unsigned __int64)(((signed int)word_721460[v45 + 1] - (signed int)word_721460[v45]) |
369 * v19 | 375 * v19 |
370 / v17) >> 16) | 376 / v17) >> 16) |
371 + word_721460[v45]) >= v56) ) | 377 + word_721460[v45]) >= x) ) |
372 ++v53; | 378 ++v53; |
373 } | 379 } |
374 } | 380 } |
375 v12 = v13 + 1; | 381 v12 = v13 + 1; |
376 v48 = v50; | 382 v48 = v50; |
377 v45 = v12; | 383 v45 = v12; |
378 } | 384 } |
379 while ( v12 < v44 ); | 385 while ( v12 < v44 ); |
386 | |
380 if ( v53 == 1 ) | 387 if ( v53 == 1 ) |
381 { | 388 { |
382 if ( v55 >= 50 ) | 389 if ( v55 >= 50 ) |
383 break; | 390 break; |
384 v20 = v8->uPolygonType; | 391 v20 = pFloor->uPolygonType; |
385 if ( v20 == 3 || v20 == 5 ) | 392 if ( v20 == 3 || v20 == 5 ) |
386 { | 393 { |
387 v21 = v7[*v8->pVertexIDs].z; | 394 v21 = pIndoor->pVertices[*pFloor->pVertexIDs].z; |
388 } | 395 } |
389 else | 396 else |
390 { | 397 { |
391 v7 = pIndoor->pVertices; | 398 //v7 = pIndoor->pVertices; |
392 v21 = ((unsigned __int64)(v8->zCalc1 * (signed __int64)v56) >> 16) | 399 v21 = ((unsigned __int64)(pFloor->zCalc1 * (signed __int64)x) >> 16) |
393 + ((unsigned __int64)(v8->zCalc2 * (signed __int64)v57) >> 16) | 400 + ((unsigned __int64)(pFloor->zCalc2 * (signed __int64)y) >> 16) |
394 + HIWORD(v8->zCalc3); | 401 + HIWORD(pFloor->zCalc3); |
395 } | 402 } |
396 v22 = v55++; | 403 v22 = v55++; |
397 dword_7212C8[v22] = v21; | 404 dword_7212C8[v22] = v21; |
398 dword_721200[v22] = *(short *)v40; | 405 dword_721200[v22] = pSector->pFloors[i]; |
399 } | 406 } |
400 } | 407 } |
401 } | 408 } |
402 v6 = uSectorIDa + 1; | 409 //v6 = uSectorIDa + 1; |
403 } | 410 } |
404 if ( v5->field_0 & 8 ) | 411 |
405 { | 412 if ( pSector->field_0 & 8 ) |
406 for ( uSectorIDb = 0; uSectorIDb < v5->uNumPortals; ++uSectorIDb ) | 413 { |
407 { | 414 for (uint i = 0; i < pSector->uNumPortals; ++i) |
408 v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]]; | 415 { |
409 if ( v23->uPolygonType == 3 | 416 //v23 = &pIndoor->pFaces[v5->pPortals[uSectorIDb]]; |
410 && v56 <= v23->pBounding.x2 | 417 auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; |
411 && v56 >= v23->pBounding.x1 | 418 if (portal->uPolygonType != POLYGON_Floor) |
412 && v57 <= v23->pBounding.y2 | 419 continue; |
413 && v57 >= v23->pBounding.y1 ) | 420 |
414 { | 421 if (x <= portal->pBounding.x2 && |
415 v46 = 0; | 422 x >= portal->pBounding.x1 && |
416 if ( v23->uNumVertices ) | 423 y <= portal->pBounding.y2 && |
417 { | 424 y >= portal->pBounding.y1 ) |
418 do | 425 { |
419 { | 426 //v46 = 0; |
420 v24 = v46; | 427 for (uint j = 0; j < portal->uNumVertices; ++j) |
421 v25 = 2 * v46; | 428 { |
422 word_721460[2 * v46] = v23->pXInterceptDisplacements[v46] + v7[v23->pVertexIDs[v46]].x; | 429 //v24 = v46; |
423 word_721390[2 * v46] = v23->pYInterceptDisplacements[v24] + v7[v23->pVertexIDs[v24]].y; | 430 //v25 = 2 * v46; |
424 word_721460[2 * v46++ + 1] = v23->pXInterceptDisplacements[v24 + 1] + v7[v23->pVertexIDs[v24 + 1]].x; | 431 word_721460[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; |
425 word_721390[v25 + 1] = v23->pYInterceptDisplacements[v24 + 1] + v7[v23->pVertexIDs[v24 + 1]].y; | 432 word_721460[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; |
426 } | 433 word_721390[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; |
427 while ( v46 < v23->uNumVertices ); | 434 word_721390[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; |
428 v5 = v43; | 435 //} |
429 } | 436 //while ( v46 < v23->uNumVertices ); |
430 v26 = 2 * v23->uNumVertices; | 437 //v5 = v43; |
431 word_721460[2 * v23->uNumVertices] = word_721460[0]; | 438 } |
432 word_721390[v26] = word_721390[0]; | 439 |
440 //v26 = 2 * v23->uNumVertices; | |
441 word_721460[2 * portal->uNumVertices] = word_721460[0]; | |
442 word_721390[2 * portal->uNumVertices] = word_721390[0]; | |
433 v54 = 0; | 443 v54 = 0; |
434 v51 = 0; | 444 v51 = 0; |
435 v49 = word_721390[0] >= v57; | 445 v49 = word_721390[0] >= y; |
436 if ( v26 > 0 ) | 446 if ( v26 > 0 ) |
437 { | 447 { |
438 do | 448 do |
439 { | 449 { |
440 if ( v54 >= 2 ) | 450 if ( v54 >= 2 ) |
441 break; | 451 break; |
442 v27 = v51; | 452 v27 = v51; |
443 v47 = word_721390[v51 + 1] >= v57; | 453 v47 = word_721390[v51 + 1] >= y; |
444 if ( v49 != v47 ) | 454 if ( v49 != v47 ) |
445 { | 455 { |
446 if ( word_721460[v27 + 1] >= v56 ) | 456 if ( word_721460[v27 + 1] >= x ) |
447 v28 = 0; | 457 v28 = 0; |
448 else | 458 else |
449 v28 = 2; | 459 v28 = 2; |
450 v29 = v28 | word_721460[v27] < v56; | 460 v29 = v28 | word_721460[v27] < x; |
451 if ( v29 != 3 ) | 461 if ( v29 != 3 ) |
452 { | 462 { |
453 if ( !v29 | 463 if ( !v29 |
454 || (v30 = word_721390[v27], | 464 || (v30 = word_721390[v27], |
455 v31 = word_721390[v51 + 1] - v30, | 465 v31 = word_721390[v51 + 1] - v30, |
456 v32 = v57 - v30, | 466 v32 = y - v30, |
457 LODWORD(v33) = v32 << 16, | 467 LODWORD(v33) = v32 << 16, |
458 HIDWORD(v33) = v32 >> 16, | 468 HIDWORD(v33) = v32 >> 16, |
459 v7 = pIndoor->pVertices, | 469 //v7 = pIndoor->pVertices, |
460 (signed int)(((unsigned __int64)(((signed int)word_721460[v27 + 1] - (signed int)word_721460[v27]) | 470 (signed int)(((unsigned __int64)(((signed int)word_721460[v27 + 1] - (signed int)word_721460[v27]) |
461 * v33 | 471 * v33 |
462 / v31) >> 16) | 472 / v31) >> 16) |
463 + word_721460[v27]) >= v56) ) | 473 + word_721460[v27]) >= x) ) |
464 ++v54; | 474 ++v54; |
465 } | 475 } |
466 } | 476 } |
467 ++v51; | 477 ++v51; |
468 v49 = v47; | 478 v49 = v47; |
472 { | 482 { |
473 if ( v55 >= 50 ) | 483 if ( v55 >= 50 ) |
474 break; | 484 break; |
475 v34 = v55++; | 485 v34 = v55++; |
476 dword_7212C8[v34] = -29000; | 486 dword_7212C8[v34] = -29000; |
477 dword_721200[v34] = v5->pPortals[uSectorIDb]; | 487 dword_721200[v34] = pSector->pPortals[i]; |
478 } | 488 } |
479 } | 489 } |
480 } | 490 } |
481 } | 491 } |
482 } | 492 } |
493 | |
483 v35 = 1; | 494 v35 = 1; |
484 if ( v55 == 1 ) | 495 if ( v55 == 1 ) |
485 { | 496 { |
486 *pFaceID = dword_721200[0]; | 497 *pFaceID = dword_721200[0]; |
487 return dword_7212C8[0]; | 498 return dword_7212C8[0]; |
490 return -30000; | 501 return -30000; |
491 *pFaceID = dword_721200[0]; | 502 *pFaceID = dword_721200[0]; |
492 result = dword_7212C8[0]; | 503 result = dword_7212C8[0]; |
493 if ( v55 > 1 ) | 504 if ( v55 > 1 ) |
494 { | 505 { |
495 v37 = a3 + 5; | 506 v37 = z + 5; |
496 while ( 1 ) | 507 while ( 1 ) |
497 { | 508 { |
498 v38 = dword_7212C8[v35]; | 509 v38 = dword_7212C8[v35]; |
499 if ( result <= v37 ) | 510 if ( result <= v37 ) |
500 break; | 511 break; |