Mercurial > mm7
comparison mm7_1.cpp @ 1306:13b7be8b06a0
Слияние
author | Ritor1 |
---|---|
date | Sun, 23 Jun 2013 14:27:57 +0600 |
parents | dcc52e17b517 8c2f689b5f0b |
children | 65379a50e4eb |
comparison
equal
deleted
inserted
replaced
1305:1ab9bff65f01 | 1306:13b7be8b06a0 |
---|---|
37 #include "stru123.h" | 37 #include "stru123.h" |
38 #include "Time.h" | 38 #include "Time.h" |
39 #include "IconFrameTable.h" | 39 #include "IconFrameTable.h" |
40 #include "TurnEngine.h" | 40 #include "TurnEngine.h" |
41 #include "texts.h" | 41 #include "texts.h" |
42 #include "UIHouses.h" | 42 #include "UI\UIHouses.h" |
43 #include "stru367.h" | 43 #include "stru367.h" |
44 | 44 |
45 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam); | 45 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam); |
46 int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4); | 46 int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4); |
47 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive); | 47 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive); |
62 //----- (004453C0) mm6----------------------------------------------------- | 62 //----- (004453C0) mm6----------------------------------------------------- |
63 //----- (004A1760) mm6_chinese--------------------------------------------- | 63 //----- (004A1760) mm6_chinese--------------------------------------------- |
64 int fixpoint_sub0(int a1, int a2) | 64 int fixpoint_sub0(int a1, int a2) |
65 { | 65 { |
66 return ((__int64)a1 * (__int64)a2) >> 16; | 66 return ((__int64)a1 * (__int64)a2) >> 16; |
67 } | |
68 | |
69 //----- (004196A0) -------------------------------------------------------- | |
70 void CharacterUI_ReleaseButtons() | |
71 { | |
72 GUIButton *i; // esi@2 | |
73 GUIButton *j; // esi@7 | |
74 | |
75 if ( dword_507CC0_activ_ch ) | |
76 { | |
77 dword_507CC0_activ_ch = 0; | |
78 for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j ) | |
79 { | |
80 j=i->pNext; | |
81 if ( BYTE1(i->field_1C) & 0x80 ) | |
82 { | |
83 i->Release(); | |
84 pAllocator->FreeChunk(i); | |
85 } | |
86 } | |
87 for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext ) | |
88 { | |
89 if ( j->msg == UIMSG_InventoryLeftClick) | |
90 { | |
91 j->uX = dword_50698C_uX; | |
92 j->uY = dword_506988_uY; | |
93 j->uZ = dword_506984_uZ; | |
94 j->uW = dword_506980_uW; | |
95 pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0); | |
96 } | |
97 } | |
98 } | |
99 } | |
100 | |
101 //----- (0041CD4F) -------------------------------------------------------- | |
102 bool UI_OnKeyDown(unsigned int vkKey) | |
103 { | |
104 //unsigned int v1; // edi@1 | |
105 //unsigned int v2; // eax@2 | |
106 int v3; // esi@3 | |
107 int v4; // ecx@10 | |
108 GUIButton *pButton; // eax@11 | |
109 int v6; // edx@12 | |
110 int v7; // ecx@20 | |
111 char v8; // zf@21 | |
112 //GUIButton *v9; // ecx@24 | |
113 int v10; // esi@24 | |
114 //int v11; // edx@26 | |
115 int v12; // edx@28 | |
116 int v13; // esi@32 | |
117 //GUIButton *v14; // eax@37 | |
118 int v15; // edx@38 | |
119 int v17; // ecx@50 | |
120 int v18; // edx@50 | |
121 //GUIButton *v19; // ecx@54 | |
122 int v20; // esi@54 | |
123 //int v21; // edx@56 | |
124 int v22; // ecx@59 | |
125 int v23; // edx@59 | |
126 int v24; // ecx@60 | |
127 int v25; // esi@63 | |
128 //unsigned int v26; // [sp+Ch] [bp-14h]@1 | |
129 //int v27; // [sp+10h] [bp-10h]@1 | |
130 int v28; // [sp+14h] [bp-Ch]@10 | |
131 int v29; // [sp+14h] [bp-Ch]@36 | |
132 unsigned int uClickX; // [sp+18h] [bp-8h]@10 | |
133 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 | |
134 | |
135 //v1 = 0; | |
136 //v27 = uNumVisibleWindows; | |
137 if ( uNumVisibleWindows < 0 ) | |
138 return false; | |
139 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
140 for (int i = uNumVisibleWindows; i >= 0; --i) | |
141 //while ( 1 ) | |
142 { | |
143 v3 = pVisibleWindowsIdxs[i] - 1; | |
144 if (!pWindowList[v3].receives_keyboard_input) | |
145 continue; | |
146 | |
147 switch (vkKey) | |
148 { | |
149 case VK_LEFT: | |
150 { | |
151 v12 = pWindowList[v3].field_34; | |
152 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) | |
153 { | |
154 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
155 pWindowList[v3].pCurrentPosActiveItem -= v12; | |
156 if ( v8 ) | |
157 { | |
158 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
159 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
160 } | |
161 } | |
162 if ( pWindowList[v3].field_30 != 0 ) | |
163 { | |
164 break; | |
165 } | |
166 pButton = pWindowList[v3].pControlsHead; | |
167 v13 = pWindowList[v3].pCurrentPosActiveItem; | |
168 if ( v13 > 0) | |
169 { | |
170 do | |
171 { | |
172 pButton = pButton->pNext; | |
173 --v13; | |
174 } | |
175 while ( v13 ); | |
176 } | |
177 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
178 break; | |
179 } | |
180 case VK_RIGHT: | |
181 { | |
182 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; | |
183 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) | |
184 { | |
185 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
186 pWindowList[v3].pCurrentPosActiveItem = v7; | |
187 if ( v8 ) | |
188 { | |
189 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
190 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
191 } | |
192 } | |
193 if ( pWindowList[v3].field_30 != 0 ) | |
194 { | |
195 break; | |
196 } | |
197 pButton = pWindowList[v3].pControlsHead; | |
198 v10 = pWindowList[v3].pCurrentPosActiveItem; | |
199 if ( v10 > 0) | |
200 { | |
201 do | |
202 { | |
203 pButton = pButton->pNext; | |
204 --v10; | |
205 } | |
206 while ( v10 ); | |
207 } | |
208 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
209 break; | |
210 } | |
211 case VK_DOWN: | |
212 { | |
213 v17 = pWindowList[v3].pStartingPosActiveItem; | |
214 v18 = pWindowList[v3].pCurrentPosActiveItem; | |
215 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) | |
216 pWindowList[v3].pCurrentPosActiveItem = v17; | |
217 else | |
218 pWindowList[v3].pCurrentPosActiveItem = v18 + 1; | |
219 if ( pWindowList[v3].field_30 != 0 ) | |
220 return true; | |
221 pButton = pWindowList[v3].pControlsHead; | |
222 v20 = pWindowList[v3].pCurrentPosActiveItem; | |
223 if ( v20 > 0) | |
224 { | |
225 do | |
226 { | |
227 pButton = pButton->pNext; | |
228 --v20; | |
229 } | |
230 while ( v20 ); | |
231 } | |
232 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
233 return true; | |
234 } | |
235 case VK_SELECT: | |
236 { | |
237 pMouse->GetClickPos(&uClickX, &uClickY); | |
238 v4 = pWindowList[v3].pStartingPosActiveItem; | |
239 v28 = v4 + pWindowList[v3].pNumPresenceButton; | |
240 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) | |
241 { | |
242 while ( 1 ) | |
243 { | |
244 pButton = pWindowList[v3].pControlsHead; | |
245 if ( v4 > 0 ) | |
246 { | |
247 v6 = v4; | |
248 do | |
249 { | |
250 pButton = pButton->pNext; | |
251 --v6; | |
252 } | |
253 while ( v6 ); | |
254 } | |
255 if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window | |
256 && (signed int)uClickX <= (signed int)pButton->uZ | |
257 && (signed int)uClickY >= (signed int)pButton->uY | |
258 && (signed int)uClickY <= (signed int)pButton->uW ) | |
259 break; | |
260 ++v4; | |
261 if ( v4 >= v28 ) | |
262 { | |
263 //v1 = 0; | |
264 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
265 //--i; | |
266 //if ( i < 0 ) | |
267 return false; | |
268 //continue; | |
269 } | |
270 } | |
271 pWindowList[v3].pCurrentPosActiveItem = v4; | |
272 return true; | |
273 } | |
274 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
275 break; | |
276 } | |
277 case VK_UP: | |
278 { | |
279 v22 = pWindowList[v3].pCurrentPosActiveItem; | |
280 v23 = pWindowList[v3].pStartingPosActiveItem; | |
281 if ( v22 <= v23 ) | |
282 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; | |
283 else | |
284 v24 = v22 - 1; | |
285 v8 = pWindowList[v3].field_30 == 0; | |
286 pWindowList[v3].pCurrentPosActiveItem = v24; | |
287 if ( !v8 ) | |
288 return true; | |
289 pButton = pWindowList[v3].pControlsHead; | |
290 v25 = pWindowList[v3].pCurrentPosActiveItem; | |
291 if ( v25 > 0) | |
292 { | |
293 do | |
294 { | |
295 pButton = pButton->pNext; | |
296 --v25; | |
297 } | |
298 while ( v25 ); | |
299 } | |
300 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
301 return true; | |
302 } | |
303 case VK_NEXT: | |
304 { | |
305 //if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw | |
306 //{ | |
307 // pMouse->GetClickPos(&uClickX, &uClickY); | |
308 // v4 = pWindowList[v3].pStartingPosActiveItem; | |
309 // v29 = v4 + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons | |
310 // if ( v4 < v29 ) | |
311 // { | |
312 // while ( 1 ) | |
313 // { | |
314 // pButton = pWindowList[v3].pControlsHead; | |
315 // if ( v4 > 0 ) | |
316 // { | |
317 // v15 = v4; | |
318 // do | |
319 // { | |
320 // pButton = pButton->pNext; | |
321 // --v15; | |
322 // } | |
323 // while ( v15 ); | |
324 // } | |
325 // if ( (signed int)uClickX >= (signed int)pButton->uX | |
326 // && (signed int)uClickX <= (signed int)pButton->uZ | |
327 // && (signed int)uClickY >= (signed int)pButton->uY | |
328 // && (signed int)uClickY <= (signed int)pButton->uW ) | |
329 // { | |
330 // pWindowList[v3].pCurrentPosActiveItem = v4; | |
331 // return true; | |
332 // } | |
333 // ++v4; | |
334 // if ( v4 >= v29 ) | |
335 // { | |
336 // //v1 = 0; | |
337 // //v2 = pMessageQueue_50CBD0->uNumMessages; | |
338 // break; | |
339 // } | |
340 // } | |
341 // } | |
342 // else | |
343 // { | |
344 // //v2 = pMessageQueue_50CBD0->uNumMessages; | |
345 // } | |
346 //} | |
347 break; | |
348 } | |
349 default: | |
350 { | |
351 break; | |
352 } | |
353 } | |
354 } | |
355 } | 67 } |
356 | 68 |
357 //----- (0041D20D) -------------------------------------------------------- | 69 //----- (0041D20D) -------------------------------------------------------- |
358 void __fastcall sub_41D20D_buff_remaining_time_string( int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2 ) | 70 void __fastcall sub_41D20D_buff_remaining_time_string( int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2 ) |
359 { | 71 { |
421 strcat(pTmpBuf.data(), pTmpBuf2.data()); | 133 strcat(pTmpBuf.data(), pTmpBuf2.data()); |
422 } | 134 } |
423 a1->DrawText(a2, 32, uY, 0, pTmpBuf.data(), 0, 0, 0); | 135 a1->DrawText(a2, 32, uY, 0, pTmpBuf.data(), 0, 0, 0); |
424 } | 136 } |
425 | 137 |
426 //----- (0041F54A) -------------------------------------------------------- | |
427 void __cdecl LoadActualSkyFrame() | |
428 { | |
429 if ( pTexture_RestUI_CurrentSkyFrame ) | |
430 pTexture_RestUI_CurrentSkyFrame->Release(); | |
431 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
432 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
433 pIcons_LOD->SyncLoadedFilesCount(); | |
434 sprintf(pTmpBuf.data(), "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour); | |
435 pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); | |
436 } | |
437 | |
438 //----- (0041F5BE) -------------------------------------------------------- | |
439 void __cdecl Sleep6Hours() | |
440 { | |
441 if ( _506F18_num_hours_to_sleep < 6 ) | |
442 { | |
443 pParty->pPlayers[3].SetAsleep(false); | |
444 pParty->pPlayers[2].SetAsleep(false); | |
445 pParty->pPlayers[1].SetAsleep(false); | |
446 pParty->pPlayers[0].SetAsleep(false); | |
447 if ( _506F18_num_hours_to_sleep ) | |
448 { | |
449 Rest(_506F18_num_hours_to_sleep); | |
450 _506F18_num_hours_to_sleep = 0; | |
451 LoadActualSkyFrame(); | |
452 } | |
453 if ( dword_506F14 == 2 ) | |
454 { | |
455 pGUIWindow_CurrentMenu->Release(); | |
456 pEventTimer->Resume(); | |
457 if ( pTexture_RestUI_CurrentSkyFrame ) | |
458 pTexture_RestUI_CurrentSkyFrame->Release(); | |
459 if ( pTexture_RestUI_CurrentHourglassFrame ) | |
460 pTexture_RestUI_CurrentHourglassFrame->Release(); | |
461 pTexture_RestUI_CurrentHourglassFrame = 0; | |
462 pTexture_RestUI_CurrentSkyFrame = 0; | |
463 pIcons_LOD->_4114F2(); | |
464 pIcons_LOD->SyncLoadedFilesCount(); | |
465 pCurrentScreen = SCREEN_GAME; | |
466 viewparams->bRedrawGameUI = 1; | |
467 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
468 { | |
469 pOutdoor->UpdateSunlightVectors(); | |
470 pOutdoor->UpdateFog(); | |
471 } | |
472 } | |
473 dword_506F14 = 0; | |
474 } | |
475 else | |
476 { | |
477 Rest(6u); | |
478 _506F18_num_hours_to_sleep -= 6; | |
479 LoadActualSkyFrame(); | |
480 } | |
481 viewparams->bRedrawGameUI = 1; | |
482 } | |
483 | |
484 //----- (0042038D) -------------------------------------------------------- | 138 //----- (0042038D) -------------------------------------------------------- |
485 void __cdecl sub_42038D() | 139 void __cdecl sub_42038D() |
486 { | 140 { |
487 POINT *v0; // esi@2 | 141 POINT *v0; // esi@2 |
488 int v1; // ecx@2 | 142 int v1; // ecx@2 |
503 | 157 |
504 _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 | 158 _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 |
505 + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); | 159 + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); |
506 v2 = _w->GetDisplayName(); | 160 v2 = _w->GetDisplayName(); |
507 GameUI_SetFooterString(v2); | 161 GameUI_SetFooterString(v2); |
508 } | |
509 } | |
510 } | |
511 | |
512 //----- (00420C05) -------------------------------------------------------- | |
513 void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) | |
514 { | |
515 unsigned int v2; // edi@1 | |
516 int v3; // ebp@1 | |
517 unsigned int v4; // esi@1 | |
518 int v5; // ecx@6 | |
519 NPCData *v6; // eax@6 | |
520 signed int v7; // edx@8 | |
521 signed int v8; // ebx@10 | |
522 char *v9; // edi@11 | |
523 signed int v10; // ecx@17 | |
524 int v11; // eax@21 | |
525 NPCData *v12; // ecx@21 | |
526 unsigned int v13; // ecx@23 | |
527 signed int v14; // [sp+Ch] [bp-4h]@6 | |
528 | |
529 v2 = 0; | |
530 v3 = 0; | |
531 v4 = uNumGold; | |
532 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal ) | |
533 { | |
534 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) | |
535 { | |
536 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! | |
537 } | |
538 else | |
539 { | |
540 if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) | |
541 pTmpBuf2[0] = 0; | |
542 } | |
543 } | |
544 else | |
545 { | |
546 v14 = 0; | |
547 v5 = 0; | |
548 v6 = pParty->pHirelings; | |
549 do | |
550 { | |
551 if ( v6->pName ) | |
552 { | |
553 v7 = v14++; | |
554 pTmpBuf[v7] = v5; | |
555 } | |
556 ++v6; | |
557 ++v5; | |
558 } | |
559 while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); | |
560 v8 = 0; | |
561 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
562 { | |
563 v9 = (char *)pNPCStats->pNewNPCData; | |
564 do | |
565 { | |
566 if ( v9[8] & 0x80 | |
567 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName)) | |
568 && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) ) | |
569 { | |
570 v10 = v14++; | |
571 pTmpBuf[v10] = v8 + 2; | |
572 } | |
573 ++v8; | |
574 v9 += 76; | |
575 } | |
576 while ( v8 < (signed int)pNPCStats->uNumNewNPCs ); | |
577 v2 = 0; | |
578 } | |
579 if ( v14 > 0 ) | |
580 { | |
581 do | |
582 { | |
583 v11 = (unsigned __int8)pTmpBuf[v2]; | |
584 v12 = &pNPCStats->pNPCData[v11 + 499]; | |
585 if ( (unsigned __int8)pTmpBuf[v2] < 2 ) | |
586 v12 = &pParty->pHirelings[v11]; | |
587 v13 = v12->uProfession; | |
588 if ( v13 ) | |
589 v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); | |
590 ++v2; | |
591 } | |
592 while ( (signed int)v2 < v14 ); | |
593 } | |
594 if ( CheckHiredNPCSpeciality(Factor) ) | |
595 v4 += (signed int)(10 * v4) / 100; | |
596 if ( CheckHiredNPCSpeciality(Banker) ) | |
597 v4 += (signed int)(20 * v4) / 100; | |
598 if ( CheckHiredNPCSpeciality(Pirate) ) | |
599 v4 += (signed int)(10 * v4) / 100; | |
600 if ( v3 ) | |
601 { | |
602 v3 = (signed int)(v4 * v3 / 100) / 100; | |
603 if ( v3 < 1 ) | |
604 v3 = 1; | |
605 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)! | |
606 } | |
607 else | |
608 { | |
609 sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold! | |
610 } | |
611 v2 = 0; | |
612 } | |
613 pParty->uNumGold += v4 - v3; | |
614 pUIAnim_Gold->uAnimTime = v2; | |
615 pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; | |
616 if ( pTmpBuf2[0] ) | |
617 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
618 pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2); | |
619 } | |
620 | |
621 //----- (00420E01) -------------------------------------------------------- | |
622 void __cdecl OnChestLeftClick() | |
623 { | |
624 int chest_id; // edi@1 | |
625 POINT *v1; // esi@2 | |
626 int v2; // eax@2 | |
627 int v3; // ebx@4 | |
628 int v4; // esi@6 | |
629 int v5; // ecx@6 | |
630 //SpriteObject v6; // [sp+Ch] [bp-80h]@1 | |
631 POINT v7; // [sp+7Ch] [bp-10h]@2 | |
632 POINT a2; // [sp+84h] [bp-8h]@2 | |
633 | |
634 SpriteObject v6; // [sp+Ch] [bp-80h]@1 | |
635 //SpriteObject::SpriteObject(&v6); | |
636 | |
637 chest_id = pGUIWindow_CurrentMenu->par1C; | |
638 if ( pParty->pPickedItem.uItemID ) | |
639 { | |
640 if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) | |
641 pMouse->RemoveHoldingItem(); | |
642 } | |
643 else | |
644 { | |
645 v1 = pMouse->GetCursorPos(&a2); | |
646 v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF; | |
647 if ( v2 ) | |
648 { | |
649 if ( v2 ) | |
650 v3 = v2 - 1; | |
651 else | |
652 v3 = -1; | |
653 v4 = pChests[chest_id].pInventoryIndices[v3] - 1; | |
654 if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == EQUIP_GOLD ) | |
655 { | |
656 party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); | |
657 viewparams->bRedrawGameUI = 1; | |
658 } | |
659 else | |
660 { | |
661 pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]); | |
662 } | |
663 sub_420B13(v4, v3); | |
664 } | |
665 } | |
666 } | |
667 | |
668 | |
669 | |
670 //----- (00421B2C) -------------------------------------------------------- | |
671 bool __cdecl sub_421B2C_PlaceInInventory_or_DropPickedItem() | |
672 { | |
673 unsigned int v0; // eax@2 | |
674 Texture *v1; // ebx@2 | |
675 int v2; // eax@3 | |
676 Player *v3; // esi@5 | |
677 int v4; // eax@6 | |
678 unsigned __int16 v5; // dx@11 | |
679 signed int v6; // eax@11 | |
680 char *v7; // edi@12 | |
681 __int16 v8; // ax@16 | |
682 SpriteObject a1; // [sp+4h] [bp-78h]@11 | |
683 int v11; // [sp+74h] [bp-8h]@2 | |
684 int v12; // [sp+78h] [bp-4h]@5 | |
685 | |
686 if ( !pParty->pPickedItem.uItemID ) | |
687 return 1; | |
688 v0 = pIcons_LOD->LoadTexture( | |
689 pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, | |
690 TEXTURE_16BIT_PALETTE); | |
691 v1 = pIcons_LOD->GetTexture(v0); | |
692 v11 = areWeLoadingTexture; | |
693 if ( uActiveCharacter | |
694 && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) | |
695 { | |
696 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u); | |
697 pMouse->RemoveHoldingItem(); | |
698 } | |
699 else | |
700 { | |
701 v12 = 0; | |
702 v3 = pParty->pPlayers; | |
703 while ( v3 <= &pParty->pPlayers[3] ) | |
704 { | |
705 v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); | |
706 if ( v4 ) | |
707 { | |
708 memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u); | |
709 pMouse->RemoveHoldingItem(); | |
710 break; | |
711 } | |
712 ++v12; | |
713 ++v3; | |
714 } | |
715 if ( v12 == 4 ) | |
716 { | |
717 v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
718 v6 = 0; | |
719 a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; | |
720 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
721 { | |
722 LOWORD(v6) = 0; | |
723 } | |
724 else | |
725 { | |
726 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
727 while ( v5 != *(short *)v7 ) | |
728 { | |
729 ++v6; | |
730 v7 += 56; | |
731 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
732 { | |
733 LOWORD(v6) = 0; | |
734 break; | |
735 } | |
736 } | |
737 } | |
738 a1.spell_caster_pid = OBJECT_Player; | |
739 a1.uObjectDescID = v6; | |
740 a1.vPosition.y = pParty->vPosition.y; | |
741 a1.vPosition.x = pParty->vPosition.x; | |
742 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
743 a1.uSoundID = 0; | |
744 a1.uFacing = 0; | |
745 a1.uAttributes = 8; | |
746 v8 = pIndoor->GetSector( | |
747 pParty->vPosition.x, | |
748 pParty->vPosition.y, | |
749 pParty->sEyelevel + pParty->vPosition.z); | |
750 a1.uSpriteFrameID = 0; | |
751 a1.uSectorID = v8; | |
752 memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); | |
753 a1.Create(pParty->sRotationY, 184, 200, 0); | |
754 pMouse->RemoveHoldingItem(); | |
755 } | |
756 } | |
757 if ( !v11 ) | |
758 { | |
759 v1->Release(); | |
760 pIcons_LOD->SyncLoadedFilesCount(); | |
761 } | |
762 return 1; | |
763 } | |
764 | |
765 | |
766 //----- (00421EA6) -------------------------------------------------------- | |
767 void __cdecl OnInventoryLeftClick() | |
768 { | |
769 Player *v0; // ebx@1 | |
770 signed int v1; // eax@2 | |
771 signed int v2; // ecx@2 | |
772 int v3; // eax@2 | |
773 char v4; // sf@2 | |
774 int v5; // eax@2 | |
775 unsigned int v6; // eax@7 | |
776 unsigned int v7; // esi@12 | |
777 unsigned int v8; // eax@12 | |
778 unsigned int v9; // eax@16 | |
779 unsigned int v10; // eax@18 | |
780 ItemGen this_; // [sp+Ch] [bp-3Ch]@1 | |
781 POINT a2; // [sp+30h] [bp-18h]@4 | |
782 unsigned int v13; // [sp+38h] [bp-10h]@13 | |
783 unsigned int pY; // [sp+3Ch] [bp-Ch]@2 | |
784 unsigned int pX; // [sp+40h] [bp-8h]@2 | |
785 int a4; // [sp+44h] [bp-4h]@2 | |
786 | |
787 v0 = pPlayers[uActiveCharacter]; | |
788 if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) | |
789 { | |
790 pMouse->GetClickPos(&pX, &pY); | |
791 pY = pY - 17; | |
792 v2 =pX - 14; | |
793 pX = v2; | |
794 v3 = 14 * (pY >> 5); | |
795 v2 >>= 5; | |
796 v4 = v2 + v3 < 0; | |
797 v5 = v2 + v3; | |
798 a4 = v5; | |
799 if ( !v4 ) | |
800 { | |
801 if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462 | |
802 && pMouse->GetCursorPos(&a2)->x >= 14 ) | |
803 { | |
804 if ( unk_50C9A0 ) | |
805 { | |
806 v6 = v0->GetItemIDAtInventoryIndex(&a4); | |
807 if ( v6 ) | |
808 { | |
809 *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; | |
810 *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; | |
811 *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; | |
812 *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4; | |
813 ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1]; | |
814 unk_50C9A0 = 0; | |
815 if ( pMessageQueue_50CBD0->uNumMessages ) | |
816 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
817 pMouse->SetCursorBitmap("MICON1"); | |
818 dword_50C9D0 = 113; | |
819 dword_50C9D4 = 0; | |
820 dword_50C9D8 = 256; | |
821 } | |
822 return; | |
823 } | |
824 if ( ptr_50C9A4 ) | |
825 return; | |
826 v7 = pParty->pPickedItem.uItemID; | |
827 v8 = v0->GetItemIDAtInventoryIndex(&a4); | |
828 if ( !v7 ) | |
829 { | |
830 if ( !v8 ) | |
831 return; | |
832 memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); | |
833 v0->RemoveItemAtInventoryIndex(a4); | |
834 v9 = pParty->pPickedItem.uItemID; | |
835 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); | |
836 return; | |
837 } | |
838 v13 = v8; | |
839 if ( v8 ) | |
840 { | |
841 a2.y = (LONG)&v0->pInventoryItems[v8-1]; | |
842 memcpy(&this_, (const void *)a2.y, sizeof(this_)); | |
843 v0->RemoveItemAtInventoryIndex(a4); | |
844 pX = v0->AddItem2(a4, &pParty->pPickedItem); | |
845 if ( !pX ) | |
846 { | |
847 pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); | |
848 if ( !pX ) | |
849 { | |
850 v0->PutItemArInventoryIndex(&this_, v13 - 1, a4); | |
851 memcpy((void *)a2.y, &this_, sizeof(ItemGen)); | |
852 return; | |
853 } | |
854 } | |
855 v9 = this_.uItemID; | |
856 memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); | |
857 pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); | |
858 return; | |
859 } | |
860 v10 = v0->AddItem(a4, v7); | |
861 pX = v10; | |
862 if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) | |
863 { | |
864 memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u); | |
865 pMouse->RemoveHoldingItem(); | |
866 } | |
867 } | |
868 } | |
869 } | |
870 } | |
871 | |
872 //----- (0042213C) -------------------------------------------------------- | |
873 void OnGameViewportClick() | |
874 { | |
875 signed int v0; // ebx@2 | |
876 POINT *v1; // esi@3 | |
877 signed int v2; // eax@9 | |
878 BLVFace *v3; // eax@10 | |
879 unsigned int v4; // eax@11 | |
880 unsigned __int16 v5; // dx@14 | |
881 signed int v6; // eax@14 | |
882 char *v7; // esi@15 | |
883 //int *v8; // eax@19 | |
884 int v9; // eax@19 | |
885 unsigned int v10; // eax@19 | |
886 int v11; // ecx@21 | |
887 ODMFace *v12; // eax@22 | |
888 LevelDecoration *v13; // esi@24 | |
889 __int16 v14; // ax@25 | |
890 int v15; // ecx@29 | |
891 signed int v16; // edx@30 | |
892 Actor *v17; // esi@30 | |
893 int v18; // ebx@47 | |
894 unsigned __int16 v19; // ax@50 | |
895 const char *v20; // eax@51 | |
896 signed int v21; // eax@58 | |
897 ItemGen *v22; // esi@62 | |
898 unsigned int v23; // eax@62 | |
899 SpriteObject a1; // [sp+Ch] [bp-80h]@1 | |
900 //POINT v25; // [sp+7Ch] [bp-10h]@3 | |
901 POINT a2; // [sp+84h] [bp-8h]@3 | |
902 | |
903 v1 = pMouse->GetCursorPos(&a2); | |
904 if ( pRenderer->pRenderD3D ) | |
905 v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); | |
906 else | |
907 { | |
908 v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; | |
909 } | |
910 | |
911 if ( PID_TYPE(v0) == OBJECT_Item) | |
912 { | |
913 a2.y = (signed int)(unsigned __int16)v0 >> 3; | |
914 v21 = (signed int)(unsigned __int16)v0 >> 3; | |
915 if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID | |
916 && (unsigned int)v0 < 0x2000000 ) | |
917 { | |
918 v22 = &pSpriteObjects[v21].stru_24; | |
919 v23 = pSpriteObjects[v21].stru_24.uItemID; | |
920 if ( pItemsTable->pItems[v23].uEquipType == 18 ) | |
921 { | |
922 party_finds_gold(v22->uSpecEnchantmentType, 0); | |
923 viewparams->bRedrawGameUI = 1; | |
924 } | |
925 else | |
926 { | |
927 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName); | |
928 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
929 if ( v22->uItemID == 506 ) | |
930 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); | |
931 if ( v22->uItemID == 455 ) | |
932 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); | |
933 if ( !pParty->AddItem(v22) ) | |
934 pParty->SetHoldingItem(v22); | |
935 } | |
936 SpriteObject::OnInteraction(a2.y); | |
937 return; | |
938 } | |
939 v4 = pParty->pPickedItem.uItemID; | |
940 if ( !pParty->pPickedItem.uItemID ) | |
941 return; | |
942 goto LABEL_14; | |
943 } | |
944 if ( PID_TYPE(v0) != OBJECT_Actor) | |
945 { | |
946 if ( PID_TYPE(v0) == OBJECT_Decoration) | |
947 { | |
948 v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; | |
949 if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) | |
950 { | |
951 v4 = pParty->pPickedItem.uItemID; | |
952 if ( !pParty->pPickedItem.uItemID ) | |
953 return; | |
954 goto LABEL_14; | |
955 } | |
956 v14 = v13->field_16_event_id; | |
957 if ( !v14 ) | |
958 { | |
959 if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) | |
960 { | |
961 v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; | |
962 activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; | |
963 EventProcessor(v15, 0, 1); | |
964 activeLevelDecoration = NULL; | |
965 } | |
966 return; | |
967 } | |
968 v11 = v14; | |
969 } | |
970 else | |
971 { | |
972 if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 ) | |
973 { | |
974 v4 = pParty->pPickedItem.uItemID; | |
975 if ( !pParty->pPickedItem.uItemID ) | |
976 return; | |
977 goto LABEL_14; | |
978 } | |
979 v2 = PID_ID(v0); | |
980 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
981 { | |
982 v3 = &pIndoor->pFaces[v2]; | |
983 if ( !(v3->uAttributes & 0x2000000) ) | |
984 { | |
985 LABEL_11: | |
986 v4 = pParty->pPickedItem.uItemID; | |
987 if ( !pParty->pPickedItem.uItemID ) | |
988 { | |
989 ShowNothingHereStatus(); | |
990 v4 = pParty->pPickedItem.uItemID; | |
991 if ( !pParty->pPickedItem.uItemID ) | |
992 return; | |
993 } | |
994 LABEL_14: | |
995 v5 = pItemsTable->pItems[v4].uSpriteID; | |
996 v6 = 0; | |
997 a1.uType = v5; | |
998 if ( (signed int)pObjectList->uNumObjects <= 0 ) | |
999 LOWORD(v6) = 0; | |
1000 else | |
1001 { | |
1002 v7 = (char *)&pObjectList->pObjects->uObjectID; | |
1003 while ( v5 != *(short *)v7 ) | |
1004 { | |
1005 ++v6; | |
1006 v7 += 56; | |
1007 if ( v6 >= (signed int)pObjectList->uNumObjects ) | |
1008 { | |
1009 LOWORD(v6) = 0; | |
1010 break; | |
1011 } | |
1012 } | |
1013 } | |
1014 a1.uObjectDescID = v6; | |
1015 a1.vPosition.y = pParty->vPosition.y; | |
1016 a1.spell_caster_pid = OBJECT_Player; | |
1017 a1.vPosition.x = pParty->vPosition.x; | |
1018 a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; | |
1019 a1.uSoundID = 0; | |
1020 a1.uFacing = 0; | |
1021 a1.uAttributes = 8; | |
1022 a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); | |
1023 a1.uSpriteFrameID = 0; | |
1024 memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); | |
1025 | |
1026 extern int UnprojectX(int); | |
1027 v9 = UnprojectX(v1->x); | |
1028 a1.Create(pParty->sRotationY + v9, 184, 200, 0); | |
1029 v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); | |
1030 if (v10 != -1) | |
1031 pIcons_LOD->pTextures[v10].Release(); | |
1032 pMouse->RemoveHoldingItem(); | |
1033 pIcons_LOD->SyncLoadedFilesCount(); | |
1034 return; | |
1035 } | |
1036 v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; | |
1037 } | |
1038 else | |
1039 { | |
1040 v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F]; | |
1041 if ( !v12->Clickable()) | |
1042 goto LABEL_11; | |
1043 v11 = v12->sCogTriggeredID; | |
1044 } | |
1045 } | |
1046 EventProcessor(v11, (unsigned __int16)v0, 1); | |
1047 return; | |
1048 } | |
1049 v16 = (signed int)(unsigned __int16)v0 >> 3; | |
1050 a2.y = v16; | |
1051 v17 = &pActors[v16]; | |
1052 if ( v17->uAIState == 5 ) | |
1053 { | |
1054 if ( (unsigned int)v0 < 0x2000000 ) | |
1055 { | |
1056 stru_50C198.LootActor(&pActors[v16]); | |
1057 return; | |
1058 } | |
1059 v4 = pParty->pPickedItem.uItemID; | |
1060 if ( !pParty->pPickedItem.uItemID ) | |
1061 return; | |
1062 goto LABEL_14; | |
1063 } | |
1064 if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) | |
1065 { | |
1066 if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) | |
1067 { | |
1068 if ( HIWORD(v0) >= 512) | |
1069 { | |
1070 v4 = pParty->pPickedItem.uItemID; | |
1071 if ( !pParty->pPickedItem.uItemID ) | |
1072 return; | |
1073 goto LABEL_14; | |
1074 } | |
1075 if ( !v17->CanAct() ) | |
1076 return; | |
1077 v18 = a2.y; | |
1078 Actor::AI_FaceObject(a2.y, 4u, 0, 0); | |
1079 if ( !v17->sNPC_ID ) | |
1080 { | |
1081 v19 = pNPCStats->pGroups_copy[v17->uGroup]; | |
1082 if ( v19 ) | |
1083 { | |
1084 v20 = pNPCStats->pCatchPhrases[v19]; | |
1085 if ( v20 ) | |
1086 { | |
1087 pParty->uFlags |= 2u; | |
1088 strcpy(byte_5B0938.data(), v20); | |
1089 sub_4451A8_press_any_key(0, 0, 0); | |
1090 } | |
1091 } | |
1092 return; | |
1093 } | |
1094 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) | |
1095 return; | |
1096 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue; | |
1097 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18; | |
1098 LABEL_42: | |
1099 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
1100 ++pMessageQueue_50CBD0->uNumMessages; | |
1101 return;*/ | |
1102 pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); | |
1103 return; | |
1104 } | |
1105 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) | |
1106 { | |
1107 pTurnEngine->field_18 |= 8u; | |
1108 return; | |
1109 } | |
1110 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1111 { | |
1112 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; | |
1113 goto LABEL_41; | |
1114 }*/ | |
1115 pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); | |
1116 } | |
1117 else | |
1118 { | |
1119 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) | |
1120 { | |
1121 pParty->uFlags |= PARTY_FLAGS_1_FALLING; | |
1122 return; | |
1123 } | |
1124 if ( uActiveCharacter | |
1125 && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) | |
1126 { | |
1127 pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); | |
1128 /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
1129 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CastQuickSpell; | |
1130 LABEL_41: | |
1131 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; | |
1132 goto LABEL_42;*/ | |
1133 } | 162 } |
1134 } | 163 } |
1135 } | 164 } |
1136 | 165 |
1137 //----- (004226C2) -------------------------------------------------------- | 166 //----- (004226C2) -------------------------------------------------------- |
1483 --v1; | 512 --v1; |
1484 } | 513 } |
1485 while ( v1 ); | 514 while ( v1 ); |
1486 } | 515 } |
1487 | 516 |
1488 //----- (00423B5D) -------------------------------------------------------- | |
1489 int __fastcall sub_423B5D(unsigned int uFaceID) | |
1490 { | |
1491 BLVFace *pFace; // ebx@1 | |
1492 //Vec3_short_ *v2; // esi@1 | |
1493 //int v3; // ST28_4@1 | |
1494 //__int16 v4; // ST2C_2@1 | |
1495 signed int v5; // esi@1 | |
1496 //Vec3_short_ *v6; // eax@4 | |
1497 signed int v7; // edi@5 | |
1498 signed int v8; // eax@5 | |
1499 signed int v9; // ecx@10 | |
1500 int v10; // eax@10 | |
1501 int v11; // edx@11 | |
1502 int v12; // ST28_4@12 | |
1503 signed int v13; // edx@12 | |
1504 signed __int64 v14; // qtt@12 | |
1505 char *v15; // ebx@12 | |
1506 int v16; // ST28_4@14 | |
1507 signed int v17; // eax@14 | |
1508 signed __int64 v18; // qtt@14 | |
1509 signed int v19; // edx@15 | |
1510 signed int v20; // edx@17 | |
1511 signed int v21; // ebx@19 | |
1512 signed int v22; // esi@20 | |
1513 int v23; // edi@21 | |
1514 int v24; // eax@21 | |
1515 int v25; // eax@22 | |
1516 int v26; // eax@22 | |
1517 signed int v27; // ST30_4@24 | |
1518 signed __int64 v28; // qtt@24 | |
1519 int v29; // ST18_4@25 | |
1520 int v30; // eax@26 | |
1521 int v31; // eax@27 | |
1522 int v32; // eax@27 | |
1523 signed int v33; // ST30_4@29 | |
1524 signed __int64 v34; // qtt@29 | |
1525 int v35; // ST30_4@30 | |
1526 signed int v36; // edi@31 | |
1527 unsigned int v37; // eax@31 | |
1528 bool v38; // edx@31 | |
1529 int v39; // ecx@31 | |
1530 int v40; // ecx@32 | |
1531 int v41; // esi@32 | |
1532 int v42; // eax@34 | |
1533 signed int v43; // ebx@41 | |
1534 unsigned int v44; // eax@41 | |
1535 signed int v45; // ecx@42 | |
1536 int v46; // esi@42 | |
1537 int v47; // eax@44 | |
1538 signed int v48; // edi@51 | |
1539 unsigned int v49; // eax@51 | |
1540 bool v50; // edx@51 | |
1541 int v51; // ecx@51 | |
1542 int v52; // ecx@52 | |
1543 int v53; // esi@52 | |
1544 int v54; // eax@54 | |
1545 int v55; // ebx@61 | |
1546 unsigned int v56; // eax@61 | |
1547 signed int v57; // ecx@62 | |
1548 int v58; // esi@62 | |
1549 int v59; // eax@64 | |
1550 char v61; // zf@72 | |
1551 signed int v62; // edx@75 | |
1552 int v63; // ecx@76 | |
1553 int v64; // esi@76 | |
1554 int v65; // ecx@83 | |
1555 signed int v66; // [sp+14h] [bp-14h]@3 | |
1556 int v67; // [sp+14h] [bp-14h]@34 | |
1557 int v68; // [sp+14h] [bp-14h]@44 | |
1558 int v69; // [sp+14h] [bp-14h]@54 | |
1559 int v70; // [sp+14h] [bp-14h]@64 | |
1560 signed int v71; // [sp+14h] [bp-14h]@75 | |
1561 //IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1 | |
1562 bool thisa; // [sp+18h] [bp-10h]@9 | |
1563 int thisb; // [sp+18h] [bp-10h]@12 | |
1564 int thisc; // [sp+18h] [bp-10h]@20 | |
1565 bool thisd; // [sp+18h] [bp-10h]@41 | |
1566 bool thise; // [sp+18h] [bp-10h]@61 | |
1567 int thisf; // [sp+18h] [bp-10h]@74 | |
1568 signed int v79; // [sp+1Ch] [bp-Ch]@9 | |
1569 int v80; // [sp+1Ch] [bp-Ch]@76 | |
1570 bool v81; // [sp+20h] [bp-8h]@10 | |
1571 bool v82; // [sp+20h] [bp-8h]@32 | |
1572 bool v83; // [sp+20h] [bp-8h]@42 | |
1573 bool v84; // [sp+20h] [bp-8h]@52 | |
1574 bool v85; // [sp+20h] [bp-8h]@62 | |
1575 signed int v86; // [sp+24h] [bp-4h]@9 | |
1576 signed int v87; // [sp+24h] [bp-4h]@19 | |
1577 signed int v88; // [sp+24h] [bp-4h]@31 | |
1578 signed int v89; // [sp+24h] [bp-4h]@41 | |
1579 signed int v90; // [sp+24h] [bp-4h]@51 | |
1580 signed int v91; // [sp+24h] [bp-4h]@61 | |
1581 | |
1582 pFace = &pIndoor->pFaces[uFaceID]; | |
1583 //_this = pGame->pIndoorCameraD3D; | |
1584 //v2 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; | |
1585 //v3 = *(_DWORD *)&pIndoor->pVertices[pFace->pVertexIDs[0]].x; | |
1586 //v4 = pIndoor->pVertices[pFace->pVertexIDs[0]].z; | |
1587 v5 = 0; | |
1588 if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) | |
1589 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) | |
1590 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 ) | |
1591 { | |
1592 stru_50B700.field_0 = 1; | |
1593 } | |
1594 else | |
1595 { | |
1596 stru_50B700.field_0 = 0; | |
1597 if ( !(pFace->uAttributes & 1) ) | |
1598 return 0; | |
1599 } | |
1600 v66 = pFace->uNumVertices; | |
1601 if ( (signed int)pFace->uNumVertices > 0 ) | |
1602 { | |
1603 do | |
1604 { | |
1605 //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]]; | |
1606 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[v5]].x, | |
1607 pIndoor->pVertices[pFace->pVertexIDs[v5]].y, pIndoor->pVertices[pFace->pVertexIDs[v5]].z, | |
1608 &stru_50B700._view_transformed_xs[v5 + 3], &stru_50B700._view_transformed_zs[v5 + 3], | |
1609 &stru_50B700._view_transformed_ys[v5 + 3], 0); | |
1610 ++v5; | |
1611 } | |
1612 while ( v5 < v66 ); | |
1613 } | |
1614 v7 = v66; | |
1615 v8 = 0; | |
1616 if ( v66 <= 0 ) | |
1617 return 0; | |
1618 do | |
1619 { | |
1620 if ( stru_50B700._view_transformed_xs[v8 + 3] >= 524288 ) | |
1621 break; | |
1622 ++v8; | |
1623 } | |
1624 while ( v8 < v66 ); | |
1625 if ( v8 >= v66 ) | |
1626 return 0; | |
1627 v79 = 0; | |
1628 stru_50B700._view_transformed_xs[v66 + 3] = stru_50B700._view_transformed_xs[3]; | |
1629 stru_50B700._view_transformed_zs[v66 + 3] = stru_50B700._view_transformed_zs[3]; | |
1630 stru_50B700._view_transformed_ys[v66 + 3] = stru_50B700._view_transformed_ys[3]; | |
1631 thisa = stru_50B700._view_transformed_xs[3] >= 524288; | |
1632 v86 = 1; | |
1633 if ( v66 >= 1 ) | |
1634 { | |
1635 do | |
1636 { | |
1637 v9 = v86; | |
1638 v10 = stru_50B700._view_transformed_xs[v86 + 3]; | |
1639 v81 = v10 >= 524288; | |
1640 if ( thisa ^ v81 ) | |
1641 { | |
1642 v11 = stru_50B700._view_transformed_xs[v9 + 2]; | |
1643 if ( v10 >= 524288 ) | |
1644 { | |
1645 v12 = v10 - v11; | |
1646 v13 = 524288 - v11; | |
1647 LODWORD(v14) = v13 << 16; | |
1648 HIDWORD(v14) = v13 >> 16; | |
1649 v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 2]; | |
1650 stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 3] | |
1651 - stru_50B700._view_transformed_zs[v9 + 2]) | |
1652 * v14 | |
1653 / v12) >> 16) | |
1654 + stru_50B700._view_transformed_zs[v9 + 2]; | |
1655 thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 3] - stru_50B700._view_transformed_ys[v9 + 2]) | |
1656 * v14 | |
1657 / v12) >> 16; | |
1658 } | |
1659 else | |
1660 { | |
1661 v16 = v11 - v10; | |
1662 v17 = 524288 - v10; | |
1663 LODWORD(v18) = v17 << 16; | |
1664 HIDWORD(v18) = v17 >> 16; | |
1665 v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 3]; | |
1666 stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 2] | |
1667 - stru_50B700._view_transformed_zs[v9 + 3]) | |
1668 * v18 | |
1669 / v16) >> 16) | |
1670 + stru_50B700._view_transformed_zs[v9 + 3]; | |
1671 thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 2] - stru_50B700._view_transformed_ys[v9 + 3]) | |
1672 * v18 | |
1673 / v16) >> 16; | |
1674 } | |
1675 v19 = v79++; | |
1676 v7 = v66; | |
1677 stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15; | |
1678 stru_50B700._view_transformed_xs[v19] = 524288; | |
1679 } | |
1680 if ( v81 ) | |
1681 { | |
1682 v20 = v79++; | |
1683 stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[v9 + 3]; | |
1684 stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[v9 + 3]; | |
1685 stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[v9 + 3]; | |
1686 } | |
1687 ++v86; | |
1688 thisa = v81; | |
1689 } | |
1690 while ( v86 <= v7 ); | |
1691 } | |
1692 v87 = 0; | |
1693 v21 = v79; | |
1694 stru_50B700._view_transformed_xs[v79] = stru_50B700._view_transformed_xs[0]; | |
1695 stru_50B700._view_transformed_zs[v79] = stru_50B700._view_transformed_zs[0]; | |
1696 for ( stru_50B700._view_transformed_ys[v79] = stru_50B700._view_transformed_ys[0]; | |
1697 v87 < v79; | |
1698 stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 ) | |
1699 { | |
1700 v22 = v87; | |
1701 thisc = abs(stru_50B700._view_transformed_xs[v87]); | |
1702 if ( abs(stru_50B700._view_transformed_zs[v87]) >> 13 <= thisc ) | |
1703 { | |
1704 v27 = stru_50B700._view_transformed_zs[v22]; | |
1705 LODWORD(v28) = v27 << 16; | |
1706 HIDWORD(v28) = v27 >> 16; | |
1707 v26 = v28 / stru_50B700._view_transformed_xs[v22]; | |
1708 v23 = 0; | |
1709 } | |
1710 else | |
1711 { | |
1712 v23 = 0; | |
1713 v24 = 0; | |
1714 if ( stru_50B700._view_transformed_zs[v22] >= 0 ) | |
1715 { | |
1716 LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; | |
1717 v26 = ((v24 - 1) & 0xFF800000) + 4194304; | |
1718 } | |
1719 else | |
1720 { | |
1721 LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; | |
1722 v25 = v24 - 1; | |
1723 v26 = (v25 & 0x800000) - 4194304; | |
1724 } | |
1725 } | |
1726 v29 = stru_50B700._view_transformed_ys[v22]; | |
1727 stru_50B700._screen_space_x[v22 + 12] = v26; | |
1728 if ( abs(v29) >> 13 <= thisc ) | |
1729 { | |
1730 v33 = stru_50B700._view_transformed_ys[v22]; | |
1731 LODWORD(v34) = v33 << 16; | |
1732 HIDWORD(v34) = v33 >> 16; | |
1733 v32 = v34 / stru_50B700._view_transformed_xs[v22]; | |
1734 } | |
1735 else | |
1736 { | |
1737 v30 = 0; | |
1738 if ( stru_50B700._view_transformed_ys[v22] >= v23 ) | |
1739 { | |
1740 LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; | |
1741 v32 = ((v30 - 1) & 0xFF800000) + 4194304; | |
1742 } | |
1743 else | |
1744 { | |
1745 LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; | |
1746 v31 = v30 - 1; | |
1747 v32 = (v31 & 0x800000) - 4194304; | |
1748 } | |
1749 } | |
1750 stru_50B700._screen_space_y[v22 + 12] = v32; | |
1751 stru_50B700._screen_space_x[v22 + 12] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) | |
1752 * (signed __int64)stru_50B700._screen_space_x[v22 + 12]) >> 16; | |
1753 v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._screen_space_y[v22 + 12]) >> 16; | |
1754 stru_50B700._screen_space_x[v22 + 12] = pBLVRenderParams->uViewportCenterX - stru_50B700._screen_space_x[v22 + 12]; | |
1755 ++v87; | |
1756 } | |
1757 v36 = 0; | |
1758 stru_50B700._screen_space_x[v21 + 12] = stru_50B700._screen_space_x[12]; | |
1759 stru_50B700._screen_space_y[v21 + 12] = stru_50B700._screen_space_y[12]; | |
1760 v37 = pBLVRenderParams->uViewportX; | |
1761 v38 = stru_50B700._screen_space_x[12] < (signed int)pBLVRenderParams->uViewportX; | |
1762 LOBYTE(v38) = stru_50B700._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX; | |
1763 v39 = 1; | |
1764 v88 = 1; | |
1765 if ( v79 < 1 ) | |
1766 return 0; | |
1767 do | |
1768 { | |
1769 v40 = v39; | |
1770 v41 = stru_50B700._screen_space_x[v40 + 12]; | |
1771 v82 = v41 >= (signed int)v37; | |
1772 if ( v38 ^ v82 ) | |
1773 { | |
1774 if ( v41 >= (signed int)v37 ) | |
1775 { | |
1776 v67 = (signed int)(v37 - stru_50B700._screen_space_x[v40 + 11]) | |
1777 * (signed __int64)(stru_50B700._screen_space_y[v40 + 12] - stru_50B700._screen_space_y[v40 + 11]) | |
1778 / (v41 - stru_50B700._screen_space_x[v40 + 11]); | |
1779 v42 = stru_50B700._screen_space_y[v40 + 11]; | |
1780 } | |
1781 else | |
1782 { | |
1783 v67 = (signed int)(v37 - v41) | |
1784 * (signed __int64)(stru_50B700._screen_space_y[v40 + 11] - stru_50B700._screen_space_y[v40 + 12]) | |
1785 / (stru_50B700._screen_space_x[v40 + 11] - v41); | |
1786 v42 = stru_50B700._screen_space_y[v40 + 12]; | |
1787 } | |
1788 ++v36; | |
1789 stru_50B700._screen_space_y[v36 + 8] = v67 + v42; | |
1790 v37 = pBLVRenderParams->uViewportX; | |
1791 stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX; | |
1792 } | |
1793 v38 = v82; | |
1794 if ( v82 ) | |
1795 { | |
1796 stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[v40 + 12]; | |
1797 stru_50B700._screen_space_y[v36++ + 9] = stru_50B700._screen_space_y[v40 + 12]; | |
1798 } | |
1799 v39 = v88++ + 1; | |
1800 } | |
1801 while ( v88 <= v79 ); | |
1802 if ( !v36 | |
1803 || (v43 = 0, | |
1804 stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[9], | |
1805 stru_50B700._screen_space_y[v36 + 9] = stru_50B700._screen_space_y[9], | |
1806 v44 = pBLVRenderParams->uViewportZ, | |
1807 thisd = stru_50B700._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ, | |
1808 v89 = 1, | |
1809 v36 < 1) ) | |
1810 return 0; | |
1811 do | |
1812 { | |
1813 v45 = v89; | |
1814 v46 = stru_50B700._screen_space_x[v89 + 9]; | |
1815 v83 = v46 <= (signed int)v44; | |
1816 if ( thisd ^ v83 ) | |
1817 { | |
1818 if ( v46 <= (signed int)v44 ) | |
1819 { | |
1820 v68 = (signed int)(v44 - stru_50B700._screen_space_x[v45 + 8]) | |
1821 * (signed __int64)(stru_50B700._screen_space_y[v45 + 9] - stru_50B700._screen_space_y[v45 + 8]) | |
1822 / (v46 - stru_50B700._screen_space_x[v45 + 8]); | |
1823 v47 = stru_50B700._screen_space_y[v45 + 8]; | |
1824 } | |
1825 else | |
1826 { | |
1827 v68 = (signed int)(v44 - v46) | |
1828 * (signed __int64)(stru_50B700._screen_space_y[v45 + 8] - stru_50B700._screen_space_y[v45 + 9]) | |
1829 / (stru_50B700._screen_space_x[v45 + 8] - v46); | |
1830 v47 = stru_50B700._screen_space_y[v45 + 9]; | |
1831 } | |
1832 ++v43; | |
1833 stru_50B700._screen_space_y[v43 + 5] = v68 + v47; | |
1834 v44 = pBLVRenderParams->uViewportZ; | |
1835 stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ; | |
1836 } | |
1837 if ( v83 ) | |
1838 { | |
1839 stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[v45 + 9]; | |
1840 stru_50B700._screen_space_y[v43++ + 6] = stru_50B700._screen_space_y[v45 + 9]; | |
1841 } | |
1842 ++v89; | |
1843 thisd = v83; | |
1844 } | |
1845 while ( v89 <= v36 ); | |
1846 if ( !v43 | |
1847 || (v48 = 0, | |
1848 stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[6], | |
1849 stru_50B700._screen_space_y[v43 + 6] = stru_50B700._screen_space_y[6], | |
1850 v49 = pBLVRenderParams->uViewportY, | |
1851 v50 = stru_50B700._screen_space_y[6] < (signed int)pBLVRenderParams->uViewportY, | |
1852 LOBYTE(v50) = stru_50B700._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY, | |
1853 v51 = 1, | |
1854 v90 = 1, | |
1855 v43 < 1) ) | |
1856 return 0; | |
1857 do | |
1858 { | |
1859 v52 = v51; | |
1860 v53 = stru_50B700._screen_space_y[v52 + 6]; | |
1861 v84 = v53 >= (signed int)v49; | |
1862 if ( v50 ^ v84 ) | |
1863 { | |
1864 if ( v53 >= (signed int)v49 ) | |
1865 { | |
1866 v69 = (signed int)(v49 - stru_50B700._screen_space_y[v52 + 5]) | |
1867 * (signed __int64)(stru_50B700._screen_space_x[v52 + 6] - stru_50B700._screen_space_x[v52 + 5]) | |
1868 / (v53 - stru_50B700._screen_space_y[v52 + 5]); | |
1869 v54 = stru_50B700._screen_space_x[v52 + 5]; | |
1870 } | |
1871 else | |
1872 { | |
1873 v69 = (signed int)(v49 - v53) | |
1874 * (signed __int64)(stru_50B700._screen_space_x[v52 + 5] - stru_50B700._screen_space_x[v52 + 6]) | |
1875 / (stru_50B700._screen_space_y[v52 + 5] - v53); | |
1876 v54 = stru_50B700._screen_space_x[v52 + 6]; | |
1877 } | |
1878 ++v48; | |
1879 stru_50B700._screen_space_x[v48 + 2] = v69 + v54; | |
1880 v49 = pBLVRenderParams->uViewportY; | |
1881 stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY; | |
1882 } | |
1883 v50 = v84; | |
1884 if ( v84 ) | |
1885 { | |
1886 stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[v52 + 6]; | |
1887 stru_50B700._screen_space_y[v48++ + 3] = stru_50B700._screen_space_y[v52 + 6]; | |
1888 } | |
1889 v51 = v90++ + 1; | |
1890 } | |
1891 while ( v90 <= v43 ); | |
1892 if ( !v48 | |
1893 || (v55 = 0, | |
1894 stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[3], | |
1895 stru_50B700._screen_space_y[v48 + 3] = stru_50B700._screen_space_y[3], | |
1896 v56 = pBLVRenderParams->uViewportW, | |
1897 thise = stru_50B700._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW, | |
1898 v91 = 1, | |
1899 v48 < 1) ) | |
1900 return 0; | |
1901 do | |
1902 { | |
1903 v57 = v91; | |
1904 v58 = stru_50B700._screen_space_y[v91 + 3]; | |
1905 v85 = v58 <= (signed int)v56; | |
1906 if ( thise ^ v85 ) | |
1907 { | |
1908 if ( v58 <= (signed int)v56 ) | |
1909 { | |
1910 v70 = (signed int)(v56 - stru_50B700._screen_space_y[v57 + 2]) | |
1911 * (signed __int64)(stru_50B700._screen_space_x[v57 + 3] - stru_50B700._screen_space_x[v57 + 2]) | |
1912 / (v58 - stru_50B700._screen_space_y[v57 + 2]); | |
1913 v59 = stru_50B700._screen_space_x[v57 + 2]; | |
1914 } | |
1915 else | |
1916 { | |
1917 v70 = (signed int)(v56 - v58) | |
1918 * (signed __int64)(stru_50B700._screen_space_x[v57 + 2] - stru_50B700._screen_space_x[v57 + 3]) | |
1919 / (stru_50B700._screen_space_y[v57 + 2] - v58); | |
1920 v59 = stru_50B700._screen_space_x[v57 + 3]; | |
1921 } | |
1922 ++v55; | |
1923 //stru_50B700._screen_space_y[v55 + 59] = v70 + v59; | |
1924 stru_50B700._screen_space_x[v55 - 1] = v70 + v59; | |
1925 v56 = pBLVRenderParams->uViewportW; | |
1926 //stru_50B700._view_transformed_xs[v55 + 47] = pBLVRenderParams->uViewportW; | |
1927 stru_50B700._screen_space_y[v55 - 1] = pBLVRenderParams->uViewportW; | |
1928 } | |
1929 if ( v85 ) | |
1930 { | |
1931 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[v57 + 3]; | |
1932 stru_50B700._screen_space_y[v55++] = stru_50B700._screen_space_y[v57 + 3]; | |
1933 } | |
1934 ++v91; | |
1935 thise = v85; | |
1936 } | |
1937 while ( v91 <= v48 ); | |
1938 if ( !v55 ) | |
1939 return 0; | |
1940 v61 = pRenderer->pRenderD3D == 0; | |
1941 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; | |
1942 stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; | |
1943 if ( v61 && v55 > 3 ) | |
1944 { | |
1945 stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1]; | |
1946 stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1]; | |
1947 thisf = 2 * (stru_50B700.field_0 != 0) - 1; | |
1948 if ( v55 > 0 ) | |
1949 { | |
1950 v62 = 1; | |
1951 v71 = 1; | |
1952 do | |
1953 { | |
1954 v63 = v62 - 1; | |
1955 v64 = v62 + 1; | |
1956 v80 = v62 + 1; | |
1957 if ( v62 - 1 >= v55 ) | |
1958 v63 -= v55; | |
1959 if ( v62 >= v55 ) | |
1960 v62 -= v55; | |
1961 if ( v64 >= v55 ) | |
1962 v64 -= v55; | |
1963 if ( thisf | |
1964 * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63]) | |
1965 * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63]) | |
1966 - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63]) | |
1967 * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 ) | |
1968 { | |
1969 v62 = v80; | |
1970 v71 = v80; | |
1971 } | |
1972 else | |
1973 { | |
1974 v62 = v71; | |
1975 v65 = v71; | |
1976 if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) ) | |
1977 { | |
1978 memcpy( | |
1979 &stru_50B700._screen_space_y[v65], | |
1980 &stru_50B700._screen_space_y[v65 + 1], | |
1981 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); | |
1982 memcpy( | |
1983 &stru_50B700._screen_space_x[v65], | |
1984 &stru_50B700._screen_space_x[v65 + 1], | |
1985 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); | |
1986 } | |
1987 --v55; | |
1988 } | |
1989 } | |
1990 while ( v62 - 1 < v55 ); | |
1991 } | |
1992 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; | |
1993 stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; | |
1994 } | |
1995 return v55; | |
1996 } | |
1997 //----- (00424579) -------------------------------------------------------- | 517 //----- (00424579) -------------------------------------------------------- |
1998 int __fastcall sub_424579(int uFaceID, stru320 *a2) | 518 int __fastcall sub_424579(int uFaceID, stru320 *a2) |
1999 { | 519 { |
2000 __debugbreak(); | 520 __debugbreak(); |
2001 return 0; | 521 return 0; |
2264 } | 784 } |
2265 memcpy(&array_507D30[result], array_507D30, sizeof(array_507D30[result])); | 785 memcpy(&array_507D30[result], array_507D30, sizeof(array_507D30[result])); |
2266 return result;*/ | 786 return result;*/ |
2267 } | 787 } |
2268 | 788 |
2269 //----- (00424829) -------------------------------------------------------- | |
2270 bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID) | |
2271 { | |
2272 //int v4; // edi@1 | |
2273 //BspRenderer_stru2 *v5; // ebx@1 | |
2274 int v6; // eax@3 | |
2275 int min_y; // esi@5 | |
2276 int max_y; // edx@5 | |
2277 //int v9; // ecx@6 | |
2278 int v10; // eax@12 | |
2279 //int v11; // edi@13 | |
2280 //int v12; // edx@18 | |
2281 int v13; // eax@22 | |
2282 //int v14; // edi@28 | |
2283 int v15; // ecx@29 | |
2284 //int v16; // edi@30 | |
2285 //int v17; // edx@35 | |
2286 int v18; // eax@39 | |
2287 int v19; // eax@44 | |
2288 int v20; // ecx@44 | |
2289 //int v21; // edi@45 | |
2290 int v22; // edi@46 | |
2291 //__int16 *v23; // ecx@47 | |
2292 int v24; // edx@48 | |
2293 //int v25; // eax@50 | |
2294 int v26; // eax@55 | |
2295 signed int v27; // edi@55 | |
2296 //int v28; // edx@56 | |
2297 int v29; // edx@57 | |
2298 //int v30; // eax@59 | |
2299 int v31; // eax@64 | |
2300 signed int v32; // edi@64 | |
2301 //int v33; // edx@65 | |
2302 int v34; // eax@66 | |
2303 int v35; // dx@66 | |
2304 __int16 v36; // dx@67 | |
2305 __int16 v37; // di@67 | |
2306 __int16 v38; // dx@67 | |
2307 //BspRenderer_stru2 *v39; // ecx@69 | |
2308 //int v40; // edx@69 | |
2309 //int v41; // edi@70 | |
2310 //__int16 *v42; // eax@76 | |
2311 //__int16 *v43; // eax@81 | |
2312 //__int16 *v45; // eax@87 | |
2313 int v46; // edx@87 | |
2314 //__int16 v47; // cx@88 | |
2315 //int v48; // eax@93 | |
2316 int v49; // esi@93 | |
2317 //__int16 *v50; // ecx@94 | |
2318 //int v51; // eax@95 | |
2319 //int v52; // eax@97 | |
2320 int v53; // [sp+Ch] [bp-34h]@44 | |
2321 int v54; // [sp+10h] [bp-30h]@0 | |
2322 int v55; // [sp+14h] [bp-2Ch]@12 | |
2323 //__int16 *v56; // [sp+14h] [bp-2Ch]@47 | |
2324 //__int16 v57; // [sp+14h] [bp-2Ch]@76 | |
2325 //__int16 v58; // [sp+14h] [bp-2Ch]@81 | |
2326 int v59; // [sp+14h] [bp-2Ch]@87 | |
2327 //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1 | |
2328 int v61; // [sp+1Ch] [bp-24h]@29 | |
2329 int v62; // [sp+20h] [bp-20h]@0 | |
2330 signed int v63; // [sp+24h] [bp-1Ch]@3 | |
2331 signed int v64; // [sp+28h] [bp-18h]@3 | |
2332 int v65; // [sp+2Ch] [bp-14h]@5 | |
2333 //int v66; // [sp+2Ch] [bp-14h]@39 | |
2334 //int v67; // [sp+30h] [bp-10h]@22 | |
2335 int v68; // [sp+34h] [bp-Ch]@12 | |
2336 int v69; // [sp+34h] [bp-Ch]@29 | |
2337 int v70; // [sp+34h] [bp-Ch]@46 | |
2338 int v71; // [sp+34h] [bp-Ch]@75 | |
2339 int v72; // [sp+34h] [bp-Ch]@80 | |
2340 //int v73; // [sp+38h] [bp-8h]@11 | |
2341 //int v74; // [sp+3Ch] [bp-4h]@1 | |
2342 //int a3a; // [sp+48h] [bp+8h]@76 | |
2343 //int a3b; // [sp+48h] [bp+8h]@87 | |
2344 | |
2345 //try graphic engine with function returning 1 always, and without | |
2346 //return true; | |
2347 if ( pNumVertices <= 1 ) | |
2348 return false; | |
2349 min_y = stru_50B700._screen_space_y[0]; | |
2350 v65 = 0; | |
2351 max_y = stru_50B700._screen_space_y[0]; | |
2352 if ( !stru_50B700.field_0 ) | |
2353 { | |
2354 v63 = 1; | |
2355 v64 = -1; | |
2356 } | |
2357 else | |
2358 { | |
2359 v63 = -1; | |
2360 v64 = 1; | |
2361 } | |
2362 | |
2363 for ( v6 = 1; v6 < pNumVertices; ++v6 ) | |
2364 { | |
2365 if ( stru_50B700._screen_space_y[v6] >= min_y ) | |
2366 { | |
2367 if ( stru_50B700._screen_space_y[v6] > max_y ) | |
2368 max_y = stru_50B700._screen_space_y[v6]; | |
2369 } | |
2370 if ( stru_50B700._screen_space_y[v6] < min_y ) | |
2371 { | |
2372 v65 = v6; | |
2373 min_y = stru_50B700._screen_space_y[v6]; | |
2374 } | |
2375 } | |
2376 if ( max_y == min_y ) | |
2377 return false; | |
2378 | |
2379 v10 = v65; | |
2380 a2->_viewport_space_y = min_y; | |
2381 a2->_viewport_space_w = max_y; | |
2382 v55 = v65; | |
2383 | |
2384 for ( v68 = 0; v68 < pNumVertices; ++v68 ) | |
2385 { | |
2386 v10 += v64; | |
2387 if ( v10 < pNumVertices ) | |
2388 { | |
2389 if ( v10 < 0 ) | |
2390 v10 += pNumVertices; | |
2391 } | |
2392 else | |
2393 v10 -= pNumVertices; | |
2394 if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] ) | |
2395 { | |
2396 v55 = v10; | |
2397 v65 = v10; | |
2398 } | |
2399 if ( stru_50B700._screen_space_y[v10] == max_y ) | |
2400 break; | |
2401 } | |
2402 v13 = v55 + v64; | |
2403 if ( v13 < pNumVertices ) | |
2404 { | |
2405 if ( v13 < 0 ) | |
2406 v13 += pNumVertices; | |
2407 } | |
2408 else | |
2409 v13 -= pNumVertices; | |
2410 if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] ) | |
2411 { | |
2412 v62 = stru_50B700._screen_space_x[v55] << 16; | |
2413 v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]); | |
2414 a2->viewport_left_side[min_y] = LOWORD(stru_50B700._screen_space_x[v55]); | |
2415 } | |
2416 v15 = v65; | |
2417 v61 = v65; | |
2418 | |
2419 for ( v69 = 0; v69 < pNumVertices; ++v69 ) | |
2420 { | |
2421 v15 += v63; | |
2422 if ( v15 < pNumVertices ) | |
2423 { | |
2424 if ( v15 < 0 ) | |
2425 v15 += pNumVertices; | |
2426 } | |
2427 else | |
2428 v15 -= pNumVertices; | |
2429 if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] ) | |
2430 { | |
2431 v61 = v15; | |
2432 v65 = v15; | |
2433 } | |
2434 if ( stru_50B700._screen_space_y[v15] == max_y ) | |
2435 break; | |
2436 } | |
2437 v18 = v63 + v61; | |
2438 if ( v18 < pNumVertices ) | |
2439 { | |
2440 if ( v18 < 0 ) | |
2441 v18 += pNumVertices; | |
2442 } | |
2443 else | |
2444 v18 -= pNumVertices; | |
2445 v19 = v18; | |
2446 v20 = v61; | |
2447 if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] ) | |
2448 { | |
2449 v61 = stru_50B700._screen_space_x[v20] << 16; | |
2450 v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20]; | |
2451 a2->viewport_right_side[max_y] = LOWORD(stru_50B700._screen_space_x[v20]); | |
2452 } | |
2453 v22 = min_y; | |
2454 if ( min_y <= max_y ) | |
2455 { | |
2456 //v56 = &a2->array_3D8[v7]; | |
2457 //v23 = &a2->array_18[v7]; | |
2458 for ( v70 = min_y; v70 <= max_y; ++v70 ) | |
2459 { | |
2460 v24 = v13; | |
2461 if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != max_y ) | |
2462 { | |
2463 v13 = v64 + v13; | |
2464 if ( v13 < pNumVertices ) | |
2465 { | |
2466 if ( v13 < 0 ) | |
2467 v13 += pNumVertices; | |
2468 } | |
2469 else | |
2470 v13 -= pNumVertices; | |
2471 v26 = v13; | |
2472 //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; | |
2473 if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 ) | |
2474 { | |
2475 v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; | |
2476 v62 = stru_50B700._screen_space_x[v24] << 16; | |
2477 } | |
2478 } | |
2479 v29 = v18; | |
2480 if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != max_y ) | |
2481 { | |
2482 v18 += v63; | |
2483 if ( v18 < pNumVertices ) | |
2484 { | |
2485 if ( v18 < 0 ) | |
2486 v18 += pNumVertices; | |
2487 } | |
2488 else | |
2489 v18 -= pNumVertices; | |
2490 v31 = v18; | |
2491 //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; | |
2492 if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 ) | |
2493 { | |
2494 v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; | |
2495 v61 = stru_50B700._screen_space_x[v29] << 16; | |
2496 } | |
2497 } | |
2498 //v34 = (char *)a2->array_18 - (char *)a2->array_3D8; | |
2499 //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34); | |
2500 //v35 = HIWORD(v62); | |
2501 a2->viewport_left_side[v70] = HIWORD(v62); | |
2502 a2->viewport_right_side[v70] = HIWORD(v61); | |
2503 //v34 = &a2->array_3D8[v70]; | |
2504 //v35 = a2->array_3D8[v70]; | |
2505 if ( a2->viewport_left_side[v70] > a2->viewport_right_side[v70] ) | |
2506 { | |
2507 v36 = a2->viewport_left_side[v70] ^ a2->viewport_right_side[v70]; | |
2508 v37 = a2->viewport_right_side[v70]; | |
2509 a2->viewport_left_side[v70] = v36; | |
2510 v38 = v37 ^ v36; | |
2511 a2->viewport_left_side[v70] ^= v38; | |
2512 a2->viewport_right_side[v70] = v38; | |
2513 } | |
2514 //++v56; | |
2515 v62 += v54; | |
2516 v22 = v70 + 1; | |
2517 v61 += v53; | |
2518 //++v23; | |
2519 } | |
2520 } | |
2521 if ( max_y < a3->_viewport_space_y ) | |
2522 return false; | |
2523 if ( min_y > a3->_viewport_space_w ) | |
2524 return false; | |
2525 if ( min_y < a3->_viewport_space_y ) | |
2526 min_y = a3->_viewport_space_y; | |
2527 if ( max_y > a3->_viewport_space_w ) | |
2528 max_y = a3->_viewport_space_w; | |
2529 if ( min_y <= max_y ) | |
2530 { | |
2531 //a3a = (char *)a2 - (char *)a3; | |
2532 //v42 = &a3->array_3D8[v7]; | |
2533 //v57 = *(__int16 *)((char *)v42 + a3a); | |
2534 for ( v71 = min_y; v71 <= max_y; ++v71 ) | |
2535 { | |
2536 if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] ) | |
2537 break; | |
2538 //++v57; | |
2539 ++min_y; | |
2540 //++v42; | |
2541 } | |
2542 } | |
2543 if ( max_y < min_y ) | |
2544 return false; | |
2545 //a3a = (char *)a2 - (char *)a3; | |
2546 //v43 = &a3->array_3D8[v8]; | |
2547 //v58 = *(__int16 *)((char *)v43 + a3a); | |
2548 for ( v72 = max_y; v72 >= min_y; --v72 ) | |
2549 { | |
2550 if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] ) | |
2551 break; | |
2552 //--v58; | |
2553 --max_y; | |
2554 //--v43; | |
2555 //v8 = v8; | |
2556 } | |
2557 if ( min_y >= max_y ) | |
2558 return false; | |
2559 //a3b = (char *)a3 - (char *)a2; | |
2560 v59 = min_y; | |
2561 //v45 = &a2->array_18[v7]; | |
2562 | |
2563 for ( v46 = max_y - min_y + 1; v46; --v46 ) | |
2564 { | |
2565 //v47 = *(__int16 *)((char *)v45 + a3b); | |
2566 if ( a2->viewport_left_side[v59] < a3->viewport_left_side[v59] ) | |
2567 a2->viewport_left_side[v59] = a3->viewport_left_side[v59]; | |
2568 if ( a2->viewport_right_side[v59] > a3->viewport_right_side[v59] ) | |
2569 a2->viewport_right_side[v59] = a3->viewport_right_side[v59]; | |
2570 ++v59; | |
2571 //++v45; | |
2572 } | |
2573 a2->_viewport_space_y = min_y; | |
2574 a2->_viewport_space_w = max_y; | |
2575 a2->field_8 = a2->viewport_left_side[min_y]; | |
2576 //v48 = a2->viewport_right_side[v7]; | |
2577 a2->field_10 = min_y; | |
2578 a2->field_14 = min_y; | |
2579 a2->field_C = a2->viewport_right_side[min_y]; | |
2580 v49 = min_y + 1; | |
2581 if ( v49 <= max_y ) | |
2582 { | |
2583 //v50 = &a2->array_3D8[v49]; | |
2584 for ( v49; v49 <= max_y; ++v49 ) | |
2585 { | |
2586 //v51 = a2->array_18[v49]; | |
2587 if ( a2->viewport_left_side[v49] < a2->field_8 ) | |
2588 { | |
2589 a2->field_8 = a2->viewport_left_side[v49]; | |
2590 a2->field_10 = v49; | |
2591 } | |
2592 if ( a2->viewport_right_side[v49] > a2->field_C ) | |
2593 { | |
2594 a2->field_C = a2->viewport_right_side[v49]; | |
2595 a2->field_14 = v49; | |
2596 } | |
2597 //++v50; | |
2598 } | |
2599 } | |
2600 return true; | |
2601 } | |
2602 // 50B700: using guessed type int stru_50B700.field_0; | 789 // 50B700: using guessed type int stru_50B700.field_0; |
2603 | 790 |
2604 //----- (00424CD7) -------------------------------------------------------- | 791 //----- (00424CD7) -------------------------------------------------------- |
2605 signed int __fastcall sr_424CD7(unsigned int uVertexID) | 792 signed int __fastcall sr_424CD7(unsigned int uVertexID) |
2606 { | 793 { |