Mercurial > mm7
annotate mm7_2.cpp @ 1414:110eac219e5a
ChestUI_WritePointedObjectStatusString
author | Nomad |
---|---|
date | Sat, 27 Jul 2013 16:32:20 +0200 |
parents | 3881d2f94eb1 |
children | ff495bf260d9 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1150
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1150
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1150
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1150
diff
changeset
|
4 |
0 | 5 #include <io.h> |
6 #include <direct.h> | |
7 #include <assert.h> | |
1016 | 8 #include <windows.h> |
9 | |
10 | |
1262 | 11 #include "Texture.h" |
12 #include "mm7_data.h" | |
1016 | 13 #include "VideoPlayer.h" |
14 #include "Sprites.h" | |
15 #include "BSPModel.h" | |
16 #include "OutdoorCamera.h" | |
17 | |
18 #include "LightmapBuilder.h" | |
19 #include "DecalBuilder.h" | |
20 #include "ParticleEngine.h" | |
21 #include "Mouse.h" | |
22 #include "Keyboard.h" | |
23 #include "CShow.h" | |
24 #include "GammaControl.h" | |
25 #include "stru6.h" | |
26 | |
27 #include "Vis.h" | |
0 | 28 #include "MapInfo.h" |
29 #include "Game.h" | |
30 #include "GUIWindow.h" | |
31 #include "GUIFont.h" | |
32 #include "Party.h" | |
33 #include "AudioPlayer.h" | |
34 #include "Outdoor.h" | |
35 #include "IndoorCamera.h" | |
36 #include "Overlays.h" | |
37 #include "Arcomage.h" | |
38 #include "LOD.h" | |
39 #include "Actor.h" | |
40 #include "Allocator.h" | |
41 #include "Events.h" | |
42 #include "Viewport.h" | |
43 #include "FrameTableInc.h" | |
44 #include "Math.h" | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
45 #include "SpriteObject.h" |
0 | 46 #include "ObjectList.h" |
47 #include "Chest.h" | |
48 #include "PaletteManager.h" | |
49 #include "DecorationList.h" | |
50 #include "SaveLoad.h" | |
51 #include "stru123.h" | |
522 | 52 #include "stru176.h" |
0 | 53 #include "Time.h" |
54 #include "IconFrameTable.h" | |
55 #include "GUIProgressBar.h" | |
56 #include "Bink_Smacker.h" | |
57 #include "PlayerFrameTable.h" | |
58 #include "TurnEngine.h" | |
59 #include "FactionTable.h" | |
60 #include "StorylineTextTable.h" | |
61 #include "Random.h" | |
924 | 62 #include "CastSpellInfo.h" |
0 | 63 #include "stru298.h" |
64 #include "Events2D.h" | |
65 #include "Log.h" | |
1299 | 66 #include "UI\UIHouses.h" |
189 | 67 #include "texts.h" |
522 | 68 #include "MM7.h" |
1262 | 69 #include "Lights.h" |
0 | 70 |
71 //----- (004BB756) -------------------------------------------------------- | |
1413 | 72 int UseNPCSkill(NPCProf profession) |
0 | 73 { |
1413 | 74 switch (profession) |
75 { | |
76 case Healer: | |
77 { | |
78 for (int i = 0; i < 4; ++i) | |
79 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth(); | |
80 } | |
81 break; | |
82 | |
83 case ExpertHealer: | |
84 { | |
85 for (int i = 0; i < 4; ++i) | |
86 { | |
87 auto player = &pParty->pPlayers[i]; | |
88 player->sHealth = player->GetMaxHealth(); | |
89 | |
90 for (int j = 0; j < 14; ++j) | |
91 player->pConditions[i] = 0; | |
92 player->pConditions[18] = 0; | |
93 } | |
94 } | |
95 break; | |
96 | |
97 case MasterHealer: | |
98 { | |
99 for (int i = 0; i < 4; ++i) | |
100 { | |
101 auto player = &pParty->pPlayers[i]; | |
102 player->sHealth = player->GetMaxHealth(); | |
103 | |
104 auto v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32); | |
105 auto v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31); | |
106 memset(player->pConditions, 0, 0xA0u); | |
107 | |
108 __debugbreak(); | |
109 *(int *)&player->pActiveSkills[8] = v5; | |
110 *(int *)&player->pActiveSkills[10] = v6; | |
111 } | |
112 } | |
113 break; | |
114 | |
115 case Cook: | |
116 { | |
117 if (pParty->uNumFoodRations >= 13) | |
118 return 1; | |
119 | |
120 Party::GiveFood(1); | |
121 } | |
122 break; | |
123 | |
124 case Chef: | |
125 { | |
126 if (pParty->uNumFoodRations >= 13) | |
127 return 1; | |
128 | |
129 if (pParty->uNumFoodRations == 13) | |
130 Party::GiveFood(1); | |
131 else | |
132 Party::GiveFood(2); | |
133 } | |
134 break; | |
135 | |
136 case WindMaster: | |
0 | 137 { |
1413 | 138 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
139 { | |
140 ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); | |
141 pAudioPlayer->PlaySound(SOUND_203, 0, 0, -1, 0, 0, 0, 0); | |
142 } | |
143 else | |
144 { | |
145 auto v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); | |
146 pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 60 * (256 * 2), 3, 1, v19, 0); | |
147 pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; | |
148 pAudioPlayer->PlaySound(SOUND_11090, 0, 0, -1, 0, 0, 0, 0); | |
149 } | |
150 } | |
151 break; | |
152 | |
153 case WaterMaster: | |
154 { | |
155 auto v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); | |
156 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 60 * (256 * (2 + 1)), 3, 0, v20, 0); | |
157 pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; | |
158 pAudioPlayer->PlaySound(SOUND_12040, 0, 0, -1, 0, 0, 0, 0); | |
159 } | |
160 break; | |
161 | |
162 case GateMaster: | |
163 { | |
164 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); | |
165 dword_50C9DC = 195; | |
166 ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); | |
167 } | |
168 break; | |
169 | |
170 case Acolyte: _42777D_CastSpell_UseWand_ShootArrow(46, 0, 133, 0, 0); break; | |
171 case Piper: _42777D_CastSpell_UseWand_ShootArrow(51, 0, 133, 0, 0); break; | |
172 case FallenWizard: _42777D_CastSpell_UseWand_ShootArrow(86, 0, 133, 0, 0); break; | |
173 | |
174 case Teacher: | |
175 case Instructor: | |
176 case Armsmaster: | |
177 case Weaponsmaster: | |
178 case Apprentice: | |
179 case Mystic: | |
180 case Spellmaster: | |
181 case Trader: | |
182 case Merchant: | |
183 case Scout: | |
184 case Herbalist: | |
185 case Apothecary: | |
186 case Tinker: | |
187 case Locksmith: | |
188 case Fool: | |
189 case ChimneySweep: | |
190 case Porter: | |
191 case QuarterMaster: | |
192 case Factor: | |
193 case Banker: | |
194 case Horseman: | |
195 case Bard: | |
196 case Enchanter: | |
197 case Cartographer: | |
198 case Explorer: | |
199 case Pirate: | |
200 case Squire: | |
201 case Psychic: | |
202 case Gypsy: | |
203 case Diplomat: | |
204 case Duper: | |
205 case Burglar: | |
206 case Acolyte2: | |
207 case Initiate: | |
208 case Prelate: | |
209 case Monk: | |
210 case Sage: | |
211 case Hunter: | |
212 break; | |
213 | |
214 default: | |
215 assert(false && "Invalid enum value"); | |
216 } | |
217 return 0; | |
0 | 218 } |
219 | |
220 //----- (004BBA85) -------------------------------------------------------- | |
221 const char *sub_4BBA85_bounties() | |
222 { | |
223 int v0; // edi@1 | |
224 signed __int64 v1; // qax@2 | |
225 int i; // eax@2 | |
226 int v3; // edx@3 | |
227 int v4; // edi@14 | |
228 __int16 v5; // ax@14 | |
229 char v6; // zf@14 | |
230 Player *v7; // ebx@16 | |
231 const char *result; // eax@19 | |
232 | |
233 uDialogueType = 83; | |
234 pDialogueWindow->Release(); | |
235 pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0); | |
832 | 236 pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" |
945 | 237 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); |
832 | 238 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); |
239 pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0); | |
972 | 240 pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); |
747 | 241 dialog_menu_id = HOUSE_DIALOGUE_OTHER; |
336 | 242 v0 = (int)((char *)window_SpeakInHouse->ptr_1C - 102); |
0 | 243 if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v0 + 1], pParty->field_3C.field_0[2 * v0]) < (signed __int64)pParty->uTimePlayed ) |
244 { | |
245 pParty->field_75A[v0] = 0; | |
630 | 246 __debugbreak(); // starting year-related constant here; |
0 | 247 v1 = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) |
248 * 0.033333335); | |
249 pParty->field_3C.field_0[2 * v0] = v1; | |
250 pParty->field_3C.field_0[2 * v0 + 1] = HIDWORD(v1); | |
251 for ( i = rand(); ; i = rand() ) | |
252 { | |
253 v3 = i % 258 + 1; | |
254 pParty->field_750[v0] = v3; | |
255 if ( (unsigned __int16)v3 < 0x73u || (unsigned __int16)v3 > 0x84u ) | |
256 { | |
257 if ( ((unsigned __int16)v3 < 0xEBu || (unsigned __int16)v3 > 0xFCu) | |
258 && ((unsigned __int16)v3 < 0x85u || (unsigned __int16)v3 > 0x96u) | |
259 && ((unsigned __int16)v3 < 0x97u || (unsigned __int16)v3 > 0xBAu) | |
260 && ((unsigned __int16)v3 < 0xC4u || (unsigned __int16)v3 > 0xC6u) ) | |
261 break; | |
262 } | |
263 } | |
264 } | |
265 v4 = v0; | |
266 v5 = pParty->field_750[v4]; | |
267 v6 = pParty->field_75A[v4] == 0; | |
268 word_F8B1A0 = pParty->field_750[v4]; | |
269 if ( v6 ) | |
270 { | |
271 v6 = v5 == 0; | |
272 result = pNPCTopics[351].pText; | |
273 if ( v6 ) | |
274 result = pNPCTopics[353].pText; | |
275 } | |
276 else | |
277 { | |
278 if ( v5 ) | |
279 { | |
280 party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v5].uLevel, 0); | |
281 v7 = pParty->pPlayers; | |
282 do | |
283 { | |
284 v7->SetVariable(VAR_Award, 86); | |
285 ++v7; | |
286 } | |
287 while ( (signed int)v7 < (signed int)pParty->pHirelings ); | |
288 pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v4]].uLevel; | |
289 pParty->field_750[v4] = 0; | |
290 pParty->field_75A[v4] = 0; | |
291 } | |
292 result = pNPCTopics[352].pText; | |
293 } | |
294 dword_F8B1A4 = (char *)result; | |
295 return result; | |
296 } | |
297 | |
298 //----- (004BBCDD) -------------------------------------------------------- | |
299 void __cdecl sub_4BBCDD() | |
300 { | |
301 signed int v0; // ebp@3 | |
90 | 302 Actor *v1; // eax@4 |
0 | 303 __int16 v2; // cx@5 |
304 int v3; // esi@8 | |
305 Player *v4; // esi@14 | |
306 GUIButton *v5; // eax@18 | |
307 GUIButton *v6; // esi@19 | |
308 size_t v7; // [sp+10h] [bp-4h]@4 | |
309 | |
310 if ( pParty->field_7B5_in_arena_quest ) | |
311 { | |
312 if ( pParty->field_7B5_in_arena_quest == -1 ) | |
313 { | |
314 uDialogueType = 92; | |
315 } | |
316 else | |
317 { | |
318 v0 = 0; | |
90 | 319 if ( (signed int)uNumActors > 0 ) |
320 { | |
1202 | 321 v1 = pActors.data();//[0].uAIState; |
90 | 322 v7 = uNumActors; |
323 do | |
324 { | |
325 v2 = v1->uAIState; | |
848 | 326 if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && PID_TYPE(v3) == OBJECT_Player) |
90 | 327 ++v0; |
328 ++v1; | |
329 --v7; | |
330 } | |
331 while ( v7 ); | |
332 } | |
333 if ( v0 >= (signed int)uNumActors || (signed int)uNumActors <= 0) | |
334 { | |
0 | 335 uDialogueType = 91; |
336 v4 = pParty->pPlayers; | |
337 ++*((char *)&pParty->field_75A[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1); | |
338 do | |
339 { | |
340 v4->SetVariable(VAR_Award, (unsigned __int8)pParty->field_7B5_in_arena_quest + 3); | |
341 ++v4; | |
342 } | |
343 while ( (signed int)v4 < (signed int)pParty->pHirelings ); | |
267 | 344 party_finds_gold(gold_transaction_amount, 0); |
0 | 345 pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0); |
346 pParty->field_7B5_in_arena_quest = -1; | |
347 } | |
348 else | |
349 { | |
350 uDialogueType = 90; | |
351 pParty->vPosition.x = 3849; | |
352 pParty->vPosition.y = 5770; | |
353 pParty->vPosition.z = 1; | |
354 pParty->uFallStartY = 1; | |
355 pParty->sRotationY = 512; | |
356 pParty->sRotationX = 0; | |
357 pParty->uFallSpeed = 0; | |
358 pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0); | |
359 } | |
360 } | |
361 } | |
362 else | |
363 { | |
364 uDialogueType = 89; | |
365 v5 = pDialogueWindow->pControlsHead; | |
366 if ( v5 ) | |
367 { | |
368 do | |
369 { | |
370 v6 = v5->pNext; | |
371 pAllocator->FreeChunk(v5); | |
372 v5 = v6; | |
373 } | |
374 while ( v6 ); | |
375 } | |
376 pDialogueWindow->pControlsHead = 0; | |
377 pDialogueWindow->pControlsTail = 0; | |
378 pDialogueWindow->uNumControls = 0; | |
832 | 379 pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], |
945 | 380 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); |
832 | 381 pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x55u, 0, "", 0); |
382 pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x56u, 0, "", 0); | |
383 pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x57u, 0, "", 0); | |
384 pDialogueWindow->CreateButton(0x1E0u, 0xFAu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x58u, 0, "", 0); | |
972 | 385 pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1); |
0 | 386 } |
387 } | |
388 | |
389 //----- (004BC109) -------------------------------------------------------- | |
390 void __cdecl ArenaFight() | |
391 { | |
392 int v0; // edi@1 | |
393 char *v1; // eax@7 | |
394 Player *v2; // edi@9 | |
395 int v3; // eax@10 | |
396 signed int v4; // esi@10 | |
397 signed __int64 v5; // qax@18 | |
398 signed int v6; // ebx@34 | |
399 char *v7; // edi@34 | |
400 int v8; // eax@37 | |
401 int v9; // esi@43 | |
402 int v10; // eax@44 | |
403 unsigned __int8 v11; // sf@44 | |
404 unsigned __int8 v12; // of@44 | |
405 signed int v13; // eax@49 | |
406 int v14; // esi@49 | |
407 int v15; // edx@50 | |
408 int v16; // eax@51 | |
409 signed int v17; // ecx@51 | |
410 int v18; // edx@53 | |
411 int i; // edi@55 | |
412 int monster_y; // ST18_4@56 | |
413 int v21; // eax@56 | |
414 signed int v22; // [sp-4h] [bp-144h]@51 | |
415 __int16 v23[100]; // [sp+Ch] [bp-134h]@39 | |
416 GUIWindow window; // [sp+D4h] [bp-6Ch]@1 | |
417 __int16 monster_ids[6]; // [sp+128h] [bp-18h]@56 | |
418 int v26; // [sp+134h] [bp-Ch]@1 | |
419 int v27; // [sp+138h] [bp-8h]@23 | |
420 int num_monsters; // [sp+13Ch] [bp-4h]@17 | |
421 | |
422 v26 = 0; | |
423 pParty->field_7B5_in_arena_quest = uDialogueType; | |
424 memcpy(&window, pDialogueWindow, sizeof(window)); | |
819 | 425 window.uFrameWidth = game_viewport_width; |
0 | 426 window.uFrameZ = 452; |
427 v0 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[575], &window, 13, 0) + 7; | |
428 pRenderer->BeginSceneD3D(); | |
429 | |
430 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
431 pIndoor->Draw(); | |
432 else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
433 pOutdoor->Draw(); | |
434 | |
435 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
436 pRenderer->BeginScene(); | |
437 if ( pRenderer->pRenderD3D ) | |
438 pRenderer->FillRectFast( | |
693 | 439 pViewport->uViewportTL_X, |
440 pViewport->uViewportTL_Y, | |
441 pViewport->uViewportBR_X - pViewport->uViewportTL_X, | |
442 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, | |
0 | 443 pRenderer->uTargetGMask | pRenderer->uTargetBMask); |
444 | |
945 | 445 auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); |
446 pRenderer->_4A6A68(8, 352 - v0, pTex, pTex->uTextureHeight - v0); | |
0 | 447 |
448 pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428); | |
449 v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0); | |
450 pDialogueWindow->DrawText(pFontArrus, 13, 354 - v0, 0, v1, 0, 0, 0); | |
451 pRenderer->EndScene(); | |
452 pRenderer->Present(); | |
453 pParty->vPosition.x = 3849; | |
454 pParty->vPosition.y = 5770; | |
455 pParty->vPosition.z = 1; | |
456 pParty->uFallStartY = 1; | |
457 pParty->sRotationY = 512; | |
458 pParty->sRotationX = 0; | |
459 pParty->uFallSpeed = 0; | |
437 | 460 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) |
0 | 461 { |
990 | 462 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; |
0 | 463 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; |
464 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
465 ++pMessageQueue_50CBD0->uNumMessages; | |
437 | 466 }*/ |
467 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); | |
0 | 468 v2 = pParty->pPlayers; |
469 do | |
470 { | |
471 v3 = v2->GetActualLevel(); | |
472 v4 = v26; | |
473 if ( v3 > v26 ) | |
474 { | |
475 v26 = v2->GetActualLevel(); | |
476 v4 = v26; | |
477 } | |
478 ++v2; | |
479 } | |
480 while ( (signed int)v2 < (signed int)pParty->pHirelings ); | |
481 if ( uDialogueType == 85 ) | |
482 { | |
483 num_monsters = v4; | |
484 goto LABEL_22; | |
485 } | |
486 if ( uDialogueType == 86 ) | |
487 { | |
488 v5 = (signed __int64)((double)v26 * 1.5); | |
489 goto LABEL_20; | |
490 } | |
491 if ( uDialogueType == 87 ) | |
492 { | |
493 LODWORD(v5) = 2 * v4; | |
494 LABEL_20: | |
495 num_monsters = v5; | |
496 LABEL_22: | |
497 v4 /= 2; | |
498 goto LABEL_24; | |
499 } | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1408
diff
changeset
|
500 __debugbreak(); // warning C4700: uninitialized local variable 'v27' used |
0 | 501 if ( uDialogueType == 88 ) |
502 num_monsters = 2 * v4; | |
503 else | |
504 v4 = v27; | |
505 LABEL_24: | |
506 if ( v4 < 1 ) | |
507 v4 = 1; | |
508 if ( v4 > 100 ) | |
509 v4 = 100; | |
510 if ( num_monsters > 100 ) | |
511 num_monsters = 100; | |
512 if ( v4 < 2 ) | |
513 v4 = 2; | |
514 if ( num_monsters < 2 ) | |
515 num_monsters = 2; | |
516 v6 = 0; | |
517 v27 = 1; | |
518 v7 = (char *)&pMonsterStats->pInfos[1].uLevel; | |
519 do | |
520 { | |
521 if ( v7[8] != 1 ) | |
522 { | |
523 if ( !MonsterStats::BelongsToSupertype(*((short *)v7 + 22), MONSTER_SUPERTYPE_8) ) | |
524 { | |
525 v8 = (unsigned __int8)*v7; | |
526 if ( v8 >= v4 ) | |
527 { | |
528 if ( v8 <= num_monsters ) | |
529 v23[v6++] = v27; | |
530 } | |
531 } | |
532 } | |
533 ++v27; | |
534 v7 += 88; | |
535 } | |
536 while ( (signed int)v7 <= (signed int)&pMonsterStats->pInfos[258].uLevel ); | |
537 num_monsters = 6; | |
538 if ( v6 < 6 ) | |
539 num_monsters = v6; | |
540 v9 = 0; | |
541 if ( num_monsters > 0 ) | |
542 { | |
543 do | |
544 { | |
545 v10 = rand(); | |
546 ++v9; | |
547 v12 = __OFSUB__(v9, num_monsters); | |
548 v11 = v9 - num_monsters < 0; | |
549 *((short *)&window.pControlsTail + v9 + 1) = v23[v10 % v6]; | |
550 } | |
551 while ( v11 ^ v12 ); | |
552 } | |
553 if ( uDialogueType == 85 ) | |
554 { | |
555 v16 = rand(); | |
556 v17 = 3; | |
557 v22 = 50; | |
558 goto LABEL_53; | |
559 } | |
560 if ( uDialogueType == 86 ) | |
561 { | |
562 v16 = rand(); | |
563 v17 = 7; | |
564 v22 = 100; | |
565 LABEL_53: | |
566 v18 = v16 % v17; | |
567 v13 = v22; | |
568 v14 = v18 + 6; | |
569 goto LABEL_55; | |
570 } | |
571 if ( uDialogueType == 87 ) | |
572 { | |
573 v15 = rand() % 11; | |
574 v13 = 200; | |
575 v14 = v15 + 10; | |
576 } | |
577 else | |
578 { | |
579 if ( uDialogueType == 88 ) | |
580 { | |
581 v13 = 500; | |
582 v14 = 20; | |
583 } | |
584 else | |
585 { | |
586 v14 = v27; | |
267 | 587 v13 = gold_transaction_amount; |
0 | 588 } |
589 } | |
590 LABEL_55: | |
591 i = 0; | |
267 | 592 for ( gold_transaction_amount = v26 * v13; i < v14; ++i ) |
0 | 593 { |
594 monster_y = pMonsterArenaPlacements[i].y; | |
595 v21 = rand(); | |
596 _4BBF61_summon_actor((unsigned __int16)monster_ids[v21 % num_monsters], pMonsterArenaPlacements[i].x, monster_y, 1); | |
597 } | |
598 pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0); | |
599 } | |
600 | |
601 //----- (004BD8B5) -------------------------------------------------------- | |
602 signed int __cdecl sub_4BD8B5() | |
603 { | |
604 int v0; // eax@4 | |
605 int v1; // eax@29 | |
606 unsigned int v2; // esi@30 | |
735 | 607 //const char *v3; // ebx@31 |
0 | 608 |
609 if ( pMessageQueue_50CBD0->uNumMessages ) | |
610 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
1038 | 611 pKeyActionMap->SetWindowInputStatus(3); |
0 | 612 pKeyActionMap->ResetKeys(); |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
519
diff
changeset
|
613 activeLevelDecoration = NULL; |
827 | 614 current_npc_text = 0; |
459 | 615 if ( pDialogueNPCCount ) |
0 | 616 { |
607 | 617 v0 = dialog_menu_id; |
749 | 618 if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD |
619 && dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL | |
620 && dialog_menu_id != HOUSE_DIALOGUE_97 | |
621 && dialog_menu_id != HOUSE_DIALOGUE_SHOP_REPAIR | |
622 && dialog_menu_id != HOUSE_DIALOGUE_SHOP_IDENTIFY | |
496 | 623 && ShopTexture ) |
624 { | |
625 ShopTexture->Release(); | |
607 | 626 v0 = dialog_menu_id; |
496 | 627 ShopTexture = 0; |
0 | 628 } |
629 if ( v0 && v0 != 1 ) | |
630 { | |
631 if ( v0 == -1 ) | |
632 { | |
459 | 633 _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1)); |
589 | 634 //LABEL_33: |
0 | 635 pVideoPlayer->_4BF5B2(); |
636 return 1; | |
637 } | |
638 if ( v0 != 94 && v0 != 96 && v0 != 101 ) | |
639 { | |
640 if ( v0 == 3 || v0 == 5 || v0 == 4 ) | |
641 { | |
423 | 642 UI_CreateEndConversationButton(); |
747 | 643 dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT; |
1411 | 644 InitializaDialogueOptions_Shops(in_current_building_type); |
0 | 645 } |
646 else | |
647 { | |
648 if ( v0 != 102 && v0 != 103 && v0 != 104 ) | |
649 { | |
650 pVideoPlayer->_4BF5B2(); | |
589 | 651 //LABEL_28: |
747 | 652 dialog_menu_id = HOUSE_DIALOGUE_MAIN; |
1411 | 653 InitializaDialogueOptions(in_current_building_type); |
0 | 654 return 1; |
655 } | |
656 pVideoPlayer->_4BF5B2(); | |
423 | 657 UI_CreateEndConversationButton(); |
747 | 658 dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN; |
1411 | 659 InitializaDialogueOptions_Tavern(in_current_building_type); |
0 | 660 } |
661 return 1; | |
662 } | |
663 pVideoPlayer->_4BF5B2(); | |
423 | 664 UI_CreateEndConversationButton(); |
747 | 665 dialog_menu_id = HOUSE_DIALOGUE_MAIN; |
1411 | 666 InitializaDialogueOptions(in_current_building_type); |
589 | 667 return 1; |
0 | 668 } |
459 | 669 pDialogueNPCCount = 0; |
0 | 670 pDialogueWindow->Release(); |
747 | 671 dialog_menu_id = HOUSE_DIALOGUE_NULL; |
0 | 672 pDialogueWindow = 0; |
1006 | 673 pIcons_LOD->SyncLoadedFilesCount(); |
0 | 674 v1 = uNumDialogueNPCPortraits; |
675 if ( uNumDialogueNPCPortraits != 1 ) | |
676 { | |
677 v2 = 0; | |
336 | 678 pBtn_ExitCancel = window_SpeakInHouse->pControlsHead; |
0 | 679 if ( uNumDialogueNPCPortraits > 0 ) |
680 { | |
735 | 681 //v3 = byte_591180; |
0 | 682 do |
683 { | |
1211 | 684 dword_5913F4[v2] = window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2], |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
685 0x3Fu, 0x49u, 1, 0, UIMSG_ClickHouseNPCPortrait, v2, 0, byte_591180[v2].data(), 0, 0, 0); |
0 | 686 v1 = uNumDialogueNPCPortraits; |
687 ++v2; | |
735 | 688 //v3 += 100; |
0 | 689 } |
690 while ( (signed int)v2 < uNumDialogueNPCPortraits ); | |
691 } | |
589 | 692 pVideoPlayer->_4BF5B2(); |
693 return 1; | |
0 | 694 } |
695 } | |
696 return 0; | |
697 } | |
698 | |
699 //----- (004BF91E) -------------------------------------------------------- | |
700 unsigned int __thiscall GameOverMenu(void *ecx0) | |
701 { | |
702 char *v1; // eax@2 | |
703 unsigned int result; // eax@3 | |
89 | 704 Player *v3; // eax@7 |
0 | 705 char *v4; // ST24_4@9 |
706 int v5; // eax@9 | |
707 char *v6; // eax@10 | |
708 char *v7; // edx@10 | |
709 char *v8; // ecx@12 | |
710 char *v9; // eax@14 | |
711 unsigned int v10; // eax@25 | |
712 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1 | |
713 MSG Msg; // [sp+88h] [bp-48h]@22 | |
714 unsigned int v14; // [sp+A4h] [bp-2Ch]@5 | |
715 void *v15; // [sp+A8h] [bp-28h]@1 | |
716 char *pInString; // [sp+ACh] [bp-24h]@5 | |
717 unsigned int v17; // [sp+B0h] [bp-20h]@5 | |
718 unsigned int v18; // [sp+B4h] [bp-1Ch]@5 | |
719 unsigned int v19; // [sp+B8h] [bp-18h]@5 | |
720 int v20; // [sp+BCh] [bp-14h]@7 | |
89 | 721 Player *i; // [sp+C0h] [bp-10h]@7 |
0 | 722 GUIFont *pFont; // [sp+C4h] [bp-Ch]@1 |
723 unsigned __int64 v23; // [sp+C8h] [bp-8h]@5 | |
724 | |
725 v15 = ecx0; | |
726 | |
727 RGBTexture _this; // [sp+Ch] [bp-C4h]@1 | |
728 //RGBTexture::RGBTexture(&this); | |
729 | |
730 BYTE1(dword_6BE364_game_settings_1) &= 0xBFu; | |
731 bGameoverLoop = 1; | |
732 pVideoPlayer->bStopBeforeSchedule = 0; | |
733 pAudioPlayer->StopChannels(-1, -1); | |
734 pRenderer->BeginScene(); | |
735 pRenderer->ClearBlack(); | |
736 pRenderer->EndScene(); | |
737 pRenderer->Present(); | |
165 | 738 pVideoPlayer->pResetflag = 0; |
484 | 739 _449B57_test_bit(pParty->_quest_bits, 99); |
0 | 740 _this.Load("winbg.pcx", 2); |
741 pRenderer->BeginScene(); | |
742 pRenderer->DrawTextureRGB(0, 0, &_this); | |
743 pRenderer->EndScene(); | |
744 free(_this.pPixels); | |
745 _this.pPixels = 0; | |
336 | 746 window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); |
0 | 747 pWindow.uFrameX = 75; |
748 pWindow.uFrameY = 60; | |
749 pWindow.uFrameWidth = 469; | |
750 pWindow.uFrameHeight = 338; | |
751 pWindow.uFrameZ = 543; | |
752 pWindow.uFrameW = 397; | |
180 | 753 pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); |
1359
60cdc3eac407
_449B57_test_bit(pParty->_quest_bits, 99) and _449B57_test_bit(pParty->_quest_bits, 100) changed to Party::IsPartyGood, Party::IsPartyEvil, respectively
Grumpy7
parents:
1330
diff
changeset
|
754 if ( pParty->IsPartyGood() ) |
0 | 755 { |
756 v1 = pGlobalTXT_LocalizationStrings[675]; | |
757 } | |
758 else | |
759 { | |
1359
60cdc3eac407
_449B57_test_bit(pParty->_quest_bits, 99) and _449B57_test_bit(pParty->_quest_bits, 100) changed to Party::IsPartyGood, Party::IsPartyEvil, respectively
Grumpy7
parents:
1330
diff
changeset
|
760 result = pParty->IsPartyEvil(); |
0 | 761 if ( !(short)result ) |
762 return result; | |
763 v1 = pGlobalTXT_LocalizationStrings[676]; | |
764 } | |
765 pInString = v1; | |
766 v23 = pParty->uTimePlayed - 138240; | |
767 v19 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 0x18; | |
768 v14 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 0x18 / 0x1C / 0xC; | |
769 v18 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 0x18 / 0x1C % 0xC; | |
770 v17 = v19 % 0x1C; | |
771 if ( !v19 ) | |
772 v19 = 1; | |
773 pRenderer->BeginScene(); | |
774 pWindow.DrawTitleText(pFont, 1u, 0x23u, 1u, pGlobalTXT_LocalizationStrings[9], 3u); | |
89 | 775 v3 = pParty->pPlayers;//[0].pName; |
0 | 776 v23 = 0i64; |
777 v20 = 0; | |
89 | 778 //for ( i = (int)pParty->pPlayers[0].pName; ; v3 = (char *)i ) |
779 for ( i = pParty->pPlayers; ; v3 = i ) | |
780 { | |
135 | 781 v4 = pClassNames[v3->classType]; |
89 | 782 v5 = v3->GetBaseLevel(); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
783 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], i->pName, v5, v4); |
0 | 784 pWindow.DrawTitleText( |
785 pFont, | |
786 1u, | |
787 v20 * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, | |
788 1u, | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
789 pTmpBuf.data(), |
0 | 790 3u); |
89 | 791 v23 += i->uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8)); |
0 | 792 ++v20; |
89 | 793 ++i; |
794 if ( i > &pParty->pPlayers[3] ) | |
0 | 795 break; |
796 } | |
797 v23 = (signed __int64)v23 / v19; | |
798 v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xCu, 0); | |
799 pWindow.DrawTitleText(pFont, 1u, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1u, v6, 0); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
800 strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]); |
0 | 801 v7 = pGlobalTXT_LocalizationStrings[56]; |
802 if ( v17 != 1 ) | |
803 v7 = pGlobalTXT_LocalizationStrings[57]; | |
804 v8 = pGlobalTXT_LocalizationStrings[146]; | |
805 if ( v18 != 1 ) | |
806 v8 = pGlobalTXT_LocalizationStrings[148]; | |
807 v9 = pGlobalTXT_LocalizationStrings[245]; | |
808 if ( v14 != 1 ) | |
809 v9 = pGlobalTXT_LocalizationStrings[132]; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
810 sprintf(pTmpBuf2.data(), " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
811 strcat(pTmpBuf.data(), pTmpBuf2.data()); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
812 pWindow.DrawTitleText(pFont, 1u, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1u, pTmpBuf.data(), 3u); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
813 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[94], v23); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
814 pWindow.DrawTitleText(pFont, 1u, pWindow.uFrameHeight, 1u, pTmpBuf.data(), 3u); |
0 | 815 BYTE1(dword_6BE364_game_settings_1) |= 0x40u; |
816 pRenderer->EndScene(); | |
817 pRenderer->Present(); | |
818 if ( pRenderer->pRenderD3D ) | |
819 pRenderer->pBeforePresentFunction(); | |
820 pRenderer->_49F1BC("MM7_Win.Pcx"); | |
821 pAllocator->FreeChunk(pFont); | |
336 | 822 window_SpeakInHouse->Release(); |
823 window_SpeakInHouse = 0; | |
0 | 824 if ( v15 == (void *)2 ) |
825 { | |
826 result = pMessageQueue_50CBD0->uNumMessages; | |
827 } | |
828 else | |
829 { | |
830 LODWORD(v23) = GetTickCount() + 5000; | |
831 while ( (unsigned int)v23 > GetTickCount() ) | |
832 ; | |
833 while ( 1 ) | |
834 { | |
835 v10 = PeekMessageA(&Msg, 0, 0, 0, 1u); | |
836 if ( !v10 ) | |
837 break; | |
838 if ( Msg.message == 18 ) | |
839 Game_DeinitializeAndTerminate(0); | |
840 TranslateMessage(&Msg); | |
841 DispatchMessageA(&Msg); | |
842 } | |
843 if ( pMessageQueue_50CBD0->uNumMessages ) | |
844 { | |
845 LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
846 pMessageQueue_50CBD0->uNumMessages = v10; | |
847 } | |
848 pKeyActionMap->ResetKeys(); | |
849 pKeyActionMap->uLastKeyPressed = 0; | |
850 do | |
851 { | |
852 while ( PeekMessageA(&Msg, 0, 0, 0, 1u) ) | |
853 { | |
854 if ( Msg.message == 18 ) | |
855 Game_DeinitializeAndTerminate(0); | |
856 TranslateMessage(&Msg); | |
857 DispatchMessageA(&Msg); | |
858 } | |
859 } | |
860 while ( !pKeyActionMap->uLastKeyPressed ); | |
861 result = pMessageQueue_50CBD0->uNumMessages; | |
862 if ( pMessageQueue_50CBD0->uNumMessages ) | |
863 { | |
864 result = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
865 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
866 } | |
867 } | |
868 if ( v15 ) | |
869 { | |
437 | 870 /*if ( (signed int)result < 40 ) |
871 { | |
872 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; | |
0 | 873 goto LABEL_42; |
437 | 874 }*/ |
875 pMessageQueue_50CBD0->AddMessage(UIMSG_Quit, 1, 0); | |
876 goto LABEL_43; | |
0 | 877 } |
878 else | |
879 { | |
437 | 880 pMessageQueue_50CBD0->AddMessage(UIMSG_ShowFinalWindow, 1, 0); |
881 goto LABEL_43; | |
882 /*if ( (signed int)result < 40 ) | |
883 { | |
884 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; | |
0 | 885 LABEL_42: |
886 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
887 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; | |
888 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; | |
889 ++pMessageQueue_50CBD0->uNumMessages; | |
890 goto LABEL_43; | |
437 | 891 }*/ |
0 | 892 } |
893 LABEL_43: | |
894 bGameoverLoop = 0; | |
895 return result; | |
896 } | |
897 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1359
diff
changeset
|
898 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1359
diff
changeset
|
899 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1359
diff
changeset
|
900 |
0 | 901 |
902 //----- (00451007) -------------------------------------------------------- | |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
903 int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch, //changing this to some library function might be a good idea |
0 | 904 unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch, |
905 int a10, int a11) | |
906 { | |
907 int result; // eax@1 | |
908 float v17; // ST3C_4@12 | |
909 float v18; // ST38_4@12 | |
910 unsigned int v19; // esi@12 | |
911 int v21; // eax@18 | |
912 unsigned int v22; // ecx@25 | |
913 unsigned int v23; // eax@29 | |
1146
b4ade2580ae3
sub_451007_scale_image_bicubic cleanup - some variable renaming, code shuffling
Grumpy7
parents:
1145
diff
changeset
|
914 unsigned int heightRatioPlusOne; // [sp+Ch] [bp-7Ch]@12 |
b4ade2580ae3
sub_451007_scale_image_bicubic cleanup - some variable renaming, code shuffling
Grumpy7
parents:
1145
diff
changeset
|
915 unsigned int widthRatio; // [sp+Ch] [bp-7Ch]@218 |
b4ade2580ae3
sub_451007_scale_image_bicubic cleanup - some variable renaming, code shuffling
Grumpy7
parents:
1145
diff
changeset
|
916 unsigned int heightRatio; // [sp+14h] [bp-74h]@12 |
b4ade2580ae3
sub_451007_scale_image_bicubic cleanup - some variable renaming, code shuffling
Grumpy7
parents:
1145
diff
changeset
|
917 unsigned int widthRatioPlusOne; // [sp+14h] [bp-74h]@218 |
0 | 918 int v160; // [sp+3Ch] [bp-4Ch]@13 |
919 unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13 | |
920 unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7 | |
921 signed int v231; // [sp+78h] [bp-10h]@7 | |
922 __int64 v240; // [sp+7Ch] [bp-Ch]@12 | |
923 unsigned int v251; // [sp+80h] [bp-8h]@218 | |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
924 unsigned int v252; // [sp+84h] [bp-4h]@218 |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
925 float a6s; // [sp+A0h] [bp+18h]@218 |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
926 float a6t; // [sp+A0h] [bp+18h]@218 |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
927 unsigned int a6b; // [sp+A0h] [bp+18h]@218 |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
928 int field_0_bits; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
929 int field_20_bits; |
1131
71ba92960bc5
banker's rounding template made as fast as before and a bit more safe
Grumpy7
parents:
1130
diff
changeset
|
930 |
1146
b4ade2580ae3
sub_451007_scale_image_bicubic cleanup - some variable renaming, code shuffling
Grumpy7
parents:
1145
diff
changeset
|
931 int field0value = this->field_0.field_C; |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
932 switch(field0value) |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
933 { |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
934 case 8: field_0_bits = 1; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
935 break; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
936 case 16: field_0_bits = 2; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
937 break; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
938 case 32: field_0_bits = 4; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
939 break; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
940 default: |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
941 return field0value; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
942 } |
1144
f544cd6f7168
sub_451007_scale_image_bicubic cleanup - preparations for further condition body extractions
Grumpy7
parents:
1140
diff
changeset
|
943 int field20value = this->field_20.field_C; |
f544cd6f7168
sub_451007_scale_image_bicubic cleanup - preparations for further condition body extractions
Grumpy7
parents:
1140
diff
changeset
|
944 switch(field20value) |
1129
9362028fccd1
sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
Grumpy7
parents:
1128
diff
changeset
|
945 { |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
946 case 8: field_20_bits = 1; |
1129
9362028fccd1
sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
Grumpy7
parents:
1128
diff
changeset
|
947 break; |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
948 case 16: field_20_bits = 2; |
1129
9362028fccd1
sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
Grumpy7
parents:
1128
diff
changeset
|
949 break; |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
950 case 32: field_20_bits = 4; |
1129
9362028fccd1
sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
Grumpy7
parents:
1128
diff
changeset
|
951 break; |
9362028fccd1
sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
Grumpy7
parents:
1128
diff
changeset
|
952 default: |
1144
f544cd6f7168
sub_451007_scale_image_bicubic cleanup - preparations for further condition body extractions
Grumpy7
parents:
1140
diff
changeset
|
953 return field20value; |
1129
9362028fccd1
sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
Grumpy7
parents:
1128
diff
changeset
|
954 } |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
955 |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
956 result = (int)pDst; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
957 v193 = pDst; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
958 v231 = 0; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
959 if ( dstHeight <= 0 ) |
1129
9362028fccd1
sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
Grumpy7
parents:
1128
diff
changeset
|
960 return result; |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
961 do |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
962 { |
1149
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
963 for (int counter = 0; counter < dstWidth; counter++) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
964 { |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
965 a6s = (double)counter / (double)dstWidth * (double)srcWidth; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
966 widthRatio = bankersRounding(a6s); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
967 a6t = (double)(counter + 1) / (double)dstWidth * (double)srcWidth; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
968 widthRatioPlusOne = bankersRounding(a6t); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
969 v17 = (double)v231 / (double)dstHeight * (double)srcHeight; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
970 heightRatio = bankersRounding(v17); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
971 v18 = (double)(v231 + 1) / (double)dstHeight * (double)srcHeight; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
972 heightRatioPlusOne = bankersRounding(v18); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
973 v251 = 0; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
974 v19 = (heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
975 v252 = 0; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
976 a6b = 0; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
977 v240 = 0i64; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
978 |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
979 v175 = (unsigned short*)((char *)pSrc + field_0_bits * (widthRatio + srcPitch * heightRatio)); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
980 for (int heightDiff = 0; heightDiff < heightRatioPlusOne - heightRatio; heightDiff++) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
981 { |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
982 int ratioDiff = widthRatioPlusOne - widthRatio; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
983 for(int i = 0; i < ratioDiff; i++) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
984 { |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
985 if(field0value == 32) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
986 v21 = _450FB1((int)v175[i]); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
987 else if(field0value == 16) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
988 v21 = _450FB1((_WORD)v175[i]); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
989 else |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
990 v21 = _450FB1((unsigned __int8)v175[i]); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
991 v240 += ((unsigned int)v21 >> 24); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
992 a6b += BYTE2(v21); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
993 v252 += BYTE1(v21); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
994 v251 += (unsigned __int8)v21; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
995 } |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
996 if(field0value == 32) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
997 v175 += 2 * srcPitch; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
998 else if(field0value == 16) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
999 v175 += srcPitch; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1000 else |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1001 v175 = (unsigned short*)((char *)v175 + 2 * srcPitch); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1002 } |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1003 v22 = (unsigned int)v240 / ((heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio)); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1004 if ( v19 ) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1005 { |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1006 a6b /= v19; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1007 v252 /= v19; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1008 v251 /= v19; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1009 } |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1010 if ( v22 != 255 ) |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1011 v22 &= 0x7FFFFFFFu; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1012 v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8)); |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1013 *(_DWORD *)v193 = v23; |
05b30ed00d7c
sub_451007_scale_image_bicubic cleanup - changing if+dowhile pair to for
Grumpy7
parents:
1148
diff
changeset
|
1014 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits); |
1148
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
1015 } |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
1016 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth)); |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
1017 ++v231; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
1018 result = v231; |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
1019 } |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
1020 while(v231 < dstHeight); |
ee6bccef32e8
sub_451007_scale_image_bicubic cleanup - final condition collapsing, remaining labels removed, etc
Grumpy7
parents:
1147
diff
changeset
|
1021 return result; |
0 | 1022 } |
1023 | |
1024 //----- (0044F57C) -------------------------------------------------------- | |
1025 void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) | |
1026 { | |
1027 //MapInfo *v5; // esi@1 | |
1028 //SpawnPointMM7 *v6; // ebx@1 | |
1029 int v7; // eax@2 | |
1030 char v8; // zf@5 | |
1031 int v9; // edi@9 | |
1032 int v10; // eax@9 | |
1033 int v11; // ecx@9 | |
1034 int v12; // edx@9 | |
1035 int v13; // eax@9 | |
1036 int v14; // eax@14 | |
1037 int v15; // ecx@14 | |
1038 int v16; // eax@19 | |
1039 int v17; // ecx@19 | |
1040 int v18; // esi@31 | |
1041 //int pPosX; // ecx@32 | |
1042 //int v20; // edx@32 | |
1043 //int v21; // eax@32 | |
1044 Actor *pMonster; // esi@35 | |
1045 int v23; // edx@36 | |
1046 signed int v24; // edi@36 | |
1047 int v25; // ecx@36 | |
1048 unsigned __int16 v26; // ax@47 | |
1049 MonsterDesc *v27; // edi@48 | |
1050 signed int v28; // eax@48 | |
1051 __int16 v29; // cx@50 | |
1052 __int16 v30; // ax@50 | |
1053 __int16 v31; // ax@50 | |
1054 int v32; // eax@50 | |
1055 int v33; // edi@50 | |
1056 int v34; // eax@50 | |
1057 int v35; // eax@50 | |
1058 int v36; // eax@50 | |
1059 int v37; // eax@51 | |
1060 int v38; // eax@52 | |
1061 int v39; // edi@52 | |
1062 std::string v40; // [sp-18h] [bp-100h]@60 | |
1063 void *v41; // [sp-14h] [bp-FCh]@50 | |
1064 //void *v42; // [sp-10h] [bp-F8h]@50 | |
1065 //size_t v43; // [sp-Ch] [bp-F4h]@50 | |
1066 const char *v44; // [sp-8h] [bp-F0h]@13 | |
1067 char *pTexture; // [sp-4h] [bp-ECh]@9 | |
1068 char Str[32]; // [sp+Ch] [bp-DCh]@60 | |
1069 char Str2[120]; // [sp+2Ch] [bp-BCh]@29 | |
1070 unsigned int uFaceID; // [sp+A4h] [bp-44h]@52 | |
1071 MonsterInfo *Src; // [sp+A8h] [bp-40h]@50 | |
1072 int v50; // [sp+ACh] [bp-3Ch]@47 | |
1073 char Source[32]; // [sp+B0h] [bp-38h]@20 | |
1074 int v52; // [sp+D0h] [bp-18h]@34 | |
1075 int v53; // [sp+D4h] [bp-14h]@34 | |
1076 int pSector; // [sp+D8h] [bp-10h]@32 | |
1077 int pPosX; // [sp+DCh] [bp-Ch]@32 | |
1078 int v56; // [sp+E0h] [bp-8h]@8 | |
1079 int v57; // [sp+E4h] [bp-4h]@1 | |
1080 | |
1081 //auto a2 = spawn; | |
1082 v57 = 0; | |
1083 //v5 = pMapInfo; | |
1084 //v6 = spawn; | |
1085 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1086 v7 = pOutdoor->ddm.field_C_alert; | |
1087 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
1088 v7 = pIndoor->dlv.field_C_alert; | |
1089 else | |
1090 v7 = 0; | |
1091 if (v7) | |
1092 v8 = (spawn->uAttributes & 1) == 0; | |
1093 else | |
1094 v8 = (spawn->uAttributes & 1) == 1; | |
1095 if (v8) | |
1096 return; | |
1097 //result = (void *)(spawn->uIndex - 1); | |
1098 v56 = 1; | |
1099 switch (spawn->uIndex - 1) | |
1100 { | |
1101 case 0u: | |
1102 v9 = pMapInfo->uEncounterMonster1AtLeast; | |
1103 v10 = rand(); | |
1104 v11 = pMapInfo->uEncounterMonster1AtMost; | |
1105 pTexture = pMapInfo->pEncounterMonster1Texture; | |
1106 v12 = v10 % (v11 - v9 + 1); | |
237 | 1107 v13 = pMapInfo->Dif_M1; |
0 | 1108 goto LABEL_20; |
1109 case 3u: | |
1110 pTexture = pMapInfo->pEncounterMonster1Texture; | |
1111 v44 = "%s A"; | |
1112 goto LABEL_25; | |
1113 case 4u: | |
1114 pTexture = pMapInfo->pEncounterMonster2Texture; | |
1115 v44 = "%s A"; | |
1116 goto LABEL_25; | |
1117 case 5u: | |
1118 pTexture = pMapInfo->pEncounterMonster3Texture; | |
1119 v44 = "%s A"; | |
1120 goto LABEL_25; | |
1121 case 1u: | |
1122 v9 = pMapInfo->uEncounterMonster2AtLeast; | |
1123 v14 = rand(); | |
1124 v15 = pMapInfo->uEncounterMonster2AtMost; | |
1125 pTexture = pMapInfo->pEncounterMonster2Texture; | |
1126 v12 = v14 % (v15 - v9 + 1); | |
237 | 1127 v13 = pMapInfo->Dif_M2; |
0 | 1128 goto LABEL_20; |
1129 case 6u: | |
1130 pTexture = pMapInfo->pEncounterMonster1Texture; | |
1131 v44 = "%s B"; | |
1132 goto LABEL_25; | |
1133 case 7u: | |
1134 pTexture = pMapInfo->pEncounterMonster2Texture; | |
1135 v44 = "%s B"; | |
1136 goto LABEL_25; | |
1137 case 8u: | |
1138 pTexture = pMapInfo->pEncounterMonster3Texture; | |
1139 v44 = "%s B"; | |
1140 goto LABEL_25; | |
1141 case 2u: | |
1142 v9 = pMapInfo->uEncounterMonster3AtLeast; | |
1143 v16 = rand(); | |
1144 v17 = pMapInfo->uEncounterMonster3AtMost; | |
1145 pTexture = pMapInfo->pEncounterMonster3Texture; | |
1146 v12 = v16 % (v17 - v9 + 1); | |
237 | 1147 v13 = pMapInfo->Dif_M3; |
0 | 1148 LABEL_20: |
1149 v57 = v13; | |
1150 v56 = v9 + v12; | |
1151 strcpy(Source, pTexture); | |
1152 goto LABEL_26; | |
1153 case 9u: | |
1154 pTexture = pMapInfo->pEncounterMonster1Texture; | |
1155 v44 = "%s C"; | |
1156 goto LABEL_25; | |
1157 case 0xAu: | |
1158 pTexture = pMapInfo->pEncounterMonster2Texture; | |
1159 v44 = "%s C"; | |
1160 goto LABEL_25; | |
1161 case 0xBu: | |
1162 pTexture = pMapInfo->pEncounterMonster3Texture; | |
1163 v44 = "%s C"; | |
1164 LABEL_25: | |
1165 sprintf(Source, v44, pTexture); | |
1166 LABEL_26: | |
1167 if (Source[0] == '0') | |
1168 return; | |
1169 v57 += a3; | |
1170 if ( v57 > 4 ) | |
1171 v57 = 4; | |
1172 strcpy(Str2, Source); | |
1173 if ( a4 ) | |
1174 v56 = a4; | |
1175 v18 = v56; | |
1176 if ( (signed int)(v56 + uNumActors) >= 500 ) | |
1177 return; | |
1178 pSector = 0; | |
1179 pPosX = spawn->vPosition.x; | |
1180 a4 = spawn->vPosition.y; | |
1181 a3 = spawn->vPosition.z; | |
1182 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1183 pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); | |
1184 v53 = 0; | |
1185 v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; | |
1186 if ( v18 <= 0 ) | |
1187 return; | |
1188 break; | |
1189 default: | |
1190 return; | |
1191 } | |
1192 for (uint i = v53; i < v56; ++i) | |
1193 { | |
1194 pMonster = &pActors[uNumActors]; | |
1195 pActors[uNumActors].Reset(); | |
1196 if ( v57 ) | |
1197 { | |
1198 v23 = rand() % 100; | |
1199 v24 = 3; | |
1200 v25 = (unsigned __int16)word_4E8152[3 * v57]; | |
1201 if ( v23 >= v25 ) | |
1202 { | |
1203 if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] ) | |
1204 v24 = 2; | |
1205 } | |
1206 else | |
1207 { | |
1208 v24 = 1; | |
1209 } | |
1210 if ( v24 == 1 ) | |
1211 { | |
1212 pTexture = Source; | |
1213 v44 = "%s A"; | |
1214 } | |
1215 else | |
1216 { | |
1217 if ( v24 == 2 ) | |
1218 { | |
1219 pTexture = Source; | |
1220 v44 = "%s B"; | |
1221 } | |
1222 else | |
1223 { | |
1224 if ( v24 != 3 ) | |
1225 goto LABEL_58; | |
1226 pTexture = Source; | |
1227 v44 = "%s C"; | |
1228 } | |
1229 } | |
1230 sprintf(Str2, v44, pTexture); | |
1231 } | |
751 | 1232 v50 = pMonsterList->GetMonsterIDByName(Str2); |
0 | 1233 pTexture = Str2; |
751 | 1234 if ( (signed __int16)v50 == -1 ) |
0 | 1235 { |
1236 sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture); | |
1237 MessageBoxA(nullptr, Str, nullptr, 0); | |
1238 ExitProcess(0); | |
1239 } | |
751 | 1240 v27 = &pMonsterList->pMonsters[(signed __int16)v50]; |
1241 v28 = pMonsterStats->FindMonsterByTextureName(pTexture); | |
0 | 1242 if ( !v28 ) |
1243 v28 = 1; | |
1244 Src = &pMonsterStats->pInfos[v28]; | |
1245 strcpy(pMonster->pActorName, Src->pName); | |
1246 pMonster->sCurrentHP = Src->uHP; | |
1247 assert(sizeof(MonsterInfo) == 88); | |
1248 memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo)); | |
1249 pMonster->word_000086_some_monster_id = v50 + 1; | |
1250 pMonster->uActorRadius = v27->uMonsterRadius; | |
1251 pMonster->uActorHeight = v27->uMonsterHeight; | |
1252 pMonster->uMovementSpeed = v27->uMovementSpeed; | |
1253 pMonster->vInitialPosition.x = spawn->vPosition.x; | |
1254 pMonster->vPosition.x = spawn->vPosition.x; | |
1255 pMonster->uTetherDistance = 256; | |
1256 pMonster->vInitialPosition.y = a4; | |
1257 pMonster->vPosition.y = a4; | |
1258 pTexture = 0; | |
1259 pMonster->vInitialPosition.z = a3; | |
1260 pMonster->vPosition.z = a3; | |
1261 pMonster->uSectorID = pSector; | |
1262 pMonster->uGroup = spawn->uGroup; | |
1263 pMonster->PrepareSprites((char)pTexture); | |
1264 pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
1265 v32 = rand(); | |
1266 v33 = v32 % 2048; | |
323 | 1267 v34 = stru_5C6E00->Cos(v32 % 2048); |
0 | 1268 a4 = v34; |
1269 a3 = (unsigned __int64)(v34 * (signed __int64)v52) >> 16; | |
1270 pPosX = a3 + spawn->vPosition.x; | |
323 | 1271 v35 = stru_5C6E00->Sin(v33); |
0 | 1272 a4 = v35; |
1273 a3 = (unsigned __int64)(v35 * (signed __int64)v52) >> 16; | |
1274 a4 = a3 + spawn->vPosition.y; | |
1275 v36 = spawn->vPosition.z; | |
1276 a3 = spawn->vPosition.z; | |
1277 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
1278 goto LABEL_55; | |
1279 v37 = pIndoor->GetSector(pPosX, a4, v36); | |
1280 if ( v37 == pSector ) | |
1281 { | |
723 | 1282 v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID); |
0 | 1283 v39 = v38; |
1284 if ( v38 != -30000 ) | |
1285 { | |
1286 if ( abs(v38 - a3) <= 1024 ) | |
1287 { | |
1288 a3 = v39; | |
1289 LABEL_55: | |
1290 if ( a5 ) | |
1291 pMonster->uAttributes |= 0x080000; | |
1292 ++uNumActors; | |
1293 goto LABEL_58; | |
1294 } | |
1295 } | |
1296 } | |
1297 LABEL_58: | |
1298 ; | |
1299 //v53 = (char *)v53 + 1; | |
1300 //result = v53; | |
1301 } | |
1302 //while ( (signed int)v53 < v56 ); | |
1303 } | |
1304 | |
1305 //----- (0044FA4C) -------------------------------------------------------- | |
1306 signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3) | |
1307 { | |
1308 signed int v3; // ecx@6 | |
90 | 1309 Actor *v4; // edx@7 |
0 | 1310 signed int result; // eax@13 |
1311 Actor *v6; // esi@16 | |
1312 char *v7; // ebx@16 | |
1313 MonsterDesc *v8; // edi@16 | |
1314 unsigned __int16 v9; // ax@16 | |
1315 int v10; // ebx@16 | |
1052 | 1316 //int v11; // edi@16 |
1317 //int v12; // eax@16 | |
1318 //int v13; // ecx@16 | |
1319 //int v14; // ebx@16 | |
0 | 1320 const char *v15; // [sp-4h] [bp-24h]@2 |
1052 | 1321 //unsigned __int16 v16; // [sp+0h] [bp-20h]@1 |
1322 //int v17; // [sp+4h] [bp-1Ch]@1 | |
0 | 1323 unsigned int uFaceID; // [sp+8h] [bp-18h]@16 |
1324 int v19; // [sp+Ch] [bp-14h]@16 | |
1325 size_t v20; // [sp+10h] [bp-10h]@6 | |
1326 int v21; // [sp+14h] [bp-Ch]@14 | |
1052 | 1327 //int v22; // [sp+18h] [bp-8h]@14 |
0 | 1328 unsigned int v23; // [sp+1Ch] [bp-4h]@6 |
1329 | |
1052 | 1330 //v16 = a2; |
1331 //v17 = a1; | |
0 | 1332 if ( a2 == 4 ) |
1333 { | |
1334 v15 = "Elemental Light C"; | |
1335 } | |
1052 | 1336 else if ( a2 == 3 ) |
0 | 1337 v15 = "Elemental Light B"; |
1338 else | |
1339 v15 = "Elemental Light A"; | |
1052 | 1340 |
751 | 1341 v23 = pMonsterList->GetMonsterIDByName(v15); |
0 | 1342 v3 = 0; |
1343 v20 = uNumActors; | |
1344 if ( (signed int)uNumActors > 0 ) | |
1345 { | |
1202 | 1346 v4 = pActors.data();//[0].uAIState; |
90 | 1347 while ( v4->uAIState != Removed ) |
0 | 1348 { |
1052 | 1349 ++v3; |
90 | 1350 ++v4; |
0 | 1351 if ( v3 >= (signed int)uNumActors ) |
90 | 1352 break; |
1353 } | |
1354 if( v3 < (signed int)uNumActors ) | |
1355 v20 = v3; | |
1356 } | |
0 | 1357 if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) ) |
1358 { | |
1359 v21 = 0; | |
1052 | 1360 //v22 = pParty->vPosition.z; |
0 | 1361 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
1362 v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1363 v6 = &pActors[v20]; | |
1364 v7 = (char *)&pMonsterStats->pInfos[v23 + 1]; | |
1365 v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; | |
1366 v6->Reset(); | |
1367 v8 = &pMonsterList->pMonsters[v23]; | |
1368 strcpy(v6->pActorName, *(const char **)v7); | |
1369 v6->sCurrentHP = *((short *)v7 + 32); | |
1370 memcpy(&v6->pMonsterInfo, v7, 0x58u); | |
1371 v6->word_000086_some_monster_id = v23 + 1; | |
1372 v6->uActorRadius = v8->uMonsterRadius; | |
1373 v6->uActorHeight = v8->uMonsterHeight; | |
1374 v9 = v8->uMovementSpeed; | |
1375 v6->pMonsterInfo.uTreasureDiceRolls = 0; | |
1376 v6->pMonsterInfo.uTreasureType = 0; | |
1377 v6->pMonsterInfo.uExp = 0; | |
1378 v6->uMovementSpeed = v9; | |
1379 v10 = rand() % 2048; | |
1052 | 1380 //v11 = pParty->vPosition.x + fixpoint_sub0(stru_5C6E00->Cos(v10), v19); |
323 | 1381 uFaceID = stru_5C6E00->Sin(v10); |
1052 | 1382 //v12 = pParty->vPosition.y; |
1383 //v13 = fixpoint_sub0(uFaceID, v19); | |
1384 //v14 = pParty->vPosition.y + fixpoint_sub0(uFaceID, v19); | |
1385 //LOWORD(v12) = v22; | |
1386 v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_sub0(stru_5C6E00->Cos(v10), v19); | |
1387 v6->vPosition.x = v6->vInitialPosition.x; | |
1388 v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_sub0(uFaceID, v19); | |
1389 v6->vPosition.y = v6->vInitialPosition.y; | |
1390 v6->vInitialPosition.z = pParty->vPosition.z; | |
1391 v6->vPosition.z = v6->vInitialPosition.z; | |
1392 //LOWORD(v12) = v21; | |
0 | 1393 v6->uTetherDistance = 256; |
1052 | 1394 v6->uSectorID = v21; |
0 | 1395 v6->PrepareSprites(0); |
1396 v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
1397 v6->uAlly = 9999; | |
1398 v6->uGroup = 0; | |
1399 v6->uCurrentActionTime = 0; | |
1400 v6->uAIState = Summoned; | |
1401 v6->uCurrentActionLength = 256; | |
1402 v6->UpdateAnimation(); | |
1403 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor | |
1052 | 1404 || (result = pIndoor->GetSector(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z), |
0 | 1405 result == v21) |
1052 | 1406 && (result = BLV_GetFloorLevel(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z, result, &uFaceID), result != -30000) |
1407 && (result = abs(result - pParty->vPosition.z), result <= 1024) ) | |
0 | 1408 { |
1409 if ( v20 == uNumActors ) | |
1410 ++uNumActors; | |
1052 | 1411 v6->uSummonerID = PID(OBJECT_Player, a1); |
1412 result = v6->pActorBuffs[2].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f, | |
1413 a2, | |
1414 a1, | |
0 | 1415 0, |
1416 0); | |
1417 } | |
1418 } | |
1419 return result; | |
1420 } | |
1421 | |
1422 //----- (0044FFD8) -------------------------------------------------------- | |
1423 int MapInfo::SpawnRandomTreasure(SpawnPointMM7 *a2) | |
1424 { | |
472 | 1425 //MapInfo *v2; // ebx@1 |
1426 //SpawnPointMM7 *v3; // esi@1 | |
1427 //int v4; // eax@1 | |
0 | 1428 int v5; // edx@1 |
1429 int v6; // eax@1 | |
1430 int v7; // ecx@1 | |
1431 int v8; // ebx@1 | |
1432 int v9; // eax@1 | |
1433 signed int v10; // ebx@1 | |
1434 signed int result; // eax@1 | |
1435 signed __int64 v12; // qtt@1 | |
1436 int v13; // ebx@1 | |
1437 int v14; // edx@10 | |
1438 signed int v15; // ebx@20 | |
1439 unsigned __int16 v16; // dx@20 | |
1440 char *v17; // ecx@21 | |
1441 unsigned __int16 v18; // ax@24 | |
1442 int v19; // ST0C_4@27 | |
1443 int v20; // ST08_4@27 | |
1444 int v21; // ST04_4@27 | |
1445 int v22; // eax@27 | |
1446 signed int v23; // ebx@29 | |
1447 unsigned __int16 v24; // dx@29 | |
1448 char *v25; // ecx@30 | |
1449 unsigned __int16 v26; // ax@33 | |
472 | 1450 //int v27; // ecx@35 |
1451 //int v28; // eax@35 | |
1452 //int v29; // esi@35 | |
1453 //__int16 v30; // ax@35 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
1454 SpriteObject a1a; // [sp+Ch] [bp-7Ch]@1 |
472 | 1455 //int v32; // [sp+7Ch] [bp-Ch]@1 |
1456 //int v33; // [sp+80h] [bp-8h]@1 | |
0 | 1457 int v34; // [sp+84h] [bp-4h]@1 |
1458 | |
472 | 1459 //auto a1 = this; |
1460 //v2 = a1; | |
1461 //v3 = a2; | |
1462 //v4 = rand(); | |
0 | 1463 v34 = 0; |
472 | 1464 v5 = rand() % 100; |
436 | 1465 // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; |
472 | 1466 v7 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob]; |
1467 v8 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob + 1]; | |
1468 //v32 = v5; | |
1469 //v33 = v7; | |
0 | 1470 v9 = rand(); |
472 | 1471 v10 = v8 - v7 + 1; |
0 | 1472 v12 = v9; |
1473 result = v9 / v10; | |
472 | 1474 v13 = v7 + (unsigned __int64)(v12 % v10); |
0 | 1475 if ( v13 < 7 ) |
1476 { | |
472 | 1477 if ( v5 < 20 ) |
0 | 1478 return result; |
472 | 1479 if ( v5 >= 60 ) |
1480 { | |
1481 v19 = a2->vPosition.z; | |
1482 v20 = a2->vPosition.y; | |
1483 v21 = a2->vPosition.x; | |
0 | 1484 v22 = rand(); |
1485 return sub_450521_ProllyDropItemAt(v13, v22 % 27 + 20, v21, v20, v19, 0); | |
1486 } | |
472 | 1487 if ( a2->uIndex == 1 ) |
0 | 1488 { |
1489 v14 = rand() % 51 + 50; | |
1490 } | |
1491 else | |
1492 { | |
472 | 1493 if ( a2->uIndex != 2 ) |
1494 { | |
1495 if ( a2->uIndex == 3 ) | |
0 | 1496 { |
1497 v14 = rand() % 301 + 200; | |
1498 } | |
1499 else | |
1500 { | |
472 | 1501 if ( a2->uIndex != 4 ) |
1502 { | |
1503 if ( a2->uIndex == 5 ) | |
0 | 1504 { |
1505 v14 = rand() % 1001 + 1000; | |
1506 } | |
1507 else | |
1508 { | |
472 | 1509 if ( a2->uIndex != 6 ) |
0 | 1510 { |
1511 LABEL_20: | |
1512 v15 = 0; | |
1513 v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
1514 a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; |
0 | 1515 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1516 { | |
1517 LABEL_24: | |
1518 v18 = 0; | |
1519 } | |
1520 else | |
1521 { | |
1522 v17 = (char *)&pObjectList->pObjects->uObjectID; | |
1523 while ( v16 != *(short *)v17 ) | |
1524 { | |
1525 ++v15; | |
1526 v17 += 56; | |
1527 if ( v15 >= (signed int)pObjectList->uNumObjects ) | |
1528 goto LABEL_24; | |
1529 } | |
1530 v18 = v15; | |
1531 } | |
315 | 1532 a1a.stru_24.SetIdentified(); |
0 | 1533 a1a.uObjectDescID = v18; |
377 | 1534 a1a.stru_24.uSpecEnchantmentType = v34; |
0 | 1535 goto LABEL_35; |
1536 } | |
1537 v14 = rand() % 3001 + 2000; | |
1538 } | |
1539 a1a.stru_24.uItemID = 199; | |
1540 LABEL_19: | |
1541 v34 = v14; | |
1542 goto LABEL_20; | |
1543 } | |
1544 v14 = rand() % 501 + 500; | |
1545 } | |
1546 a1a.stru_24.uItemID = 198; | |
1547 goto LABEL_19; | |
1548 } | |
1549 v14 = rand() % 101 + 100; | |
1550 } | |
1551 a1a.stru_24.uItemID = 197; | |
1552 goto LABEL_19; | |
1553 } | |
1554 result = a1a.stru_24.GenerateArtifact(); | |
1555 if ( !result ) | |
1556 return result; | |
1557 v23 = 0; | |
1558 v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
1559 a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; |
0 | 1560 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1561 { | |
1562 LABEL_33: | |
1563 v26 = 0; | |
1564 } | |
1565 else | |
1566 { | |
1567 v25 = (char *)&pObjectList->pObjects->uObjectID; | |
1568 while ( v24 != *(short *)v25 ) | |
1569 { | |
1570 ++v23; | |
1571 v25 += 56; | |
1572 if ( v23 >= (signed int)pObjectList->uNumObjects ) | |
1573 goto LABEL_33; | |
1574 } | |
1575 v26 = v23; | |
1576 } | |
1577 a1a.uObjectDescID = v26; | |
1578 a1a.stru_24.Reset(); | |
472 | 1579 |
0 | 1580 LABEL_35: |
472 | 1581 a1a.vPosition.y = a2->vPosition.y; |
0 | 1582 a1a.uAttributes = 0; |
1583 a1a.uSoundID = 0; | |
1584 a1a.uFacing = 0; | |
472 | 1585 a1a.vPosition.z = a2->vPosition.z; |
1586 a1a.vPosition.x = a2->vPosition.x; | |
822 | 1587 a1a.spell_skill = 0; |
1588 a1a.spell_level = 0; | |
1589 a1a.spell_id = 0; | |
823 | 1590 a1a.spell_target_pid = 0; |
822 | 1591 a1a.spell_caster_pid = 0; |
0 | 1592 a1a.uSpriteFrameID = 0; |
472 | 1593 a1a.uSectorID = pIndoor->GetSector(a2->vPosition.x, a2->vPosition.y, a2->vPosition.z);; |
0 | 1594 return a1a.Create(0, 0, 0, 0); |
1595 } | |
1596 | |
1597 //----- (00450521) -------------------------------------------------------- | |
1598 signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6) | |
1599 { | |
1600 int v6; // edi@1 | |
1601 int v7; // esi@1 | |
1602 signed int v8; // edi@1 | |
1603 unsigned __int16 v9; // cx@1 | |
1604 char *v10; // edx@2 | |
1605 unsigned __int16 v11; // ax@5 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
1606 SpriteObject a1; // [sp+8h] [bp-70h]@1 |
0 | 1607 |
1608 v6 = ecx0; | |
1609 v7 = a2; | |
1610 pItemsTable->GenerateItem(v6, v7, &a1.stru_24); | |
1611 v8 = 0; | |
1612 v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
1613 a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; |
0 | 1614 if ( (signed int)pObjectList->uNumObjects <= 0 ) |
1615 { | |
1616 LABEL_5: | |
1617 v11 = 0; | |
1618 } | |
1619 else | |
1620 { | |
1621 v10 = (char *)&pObjectList->pObjects->uObjectID; | |
1622 while ( v9 != *(short *)v10 ) | |
1623 { | |
1624 ++v8; | |
1625 v10 += 56; | |
1626 if ( v8 >= (signed int)pObjectList->uNumObjects ) | |
1627 goto LABEL_5; | |
1628 } | |
1629 v11 = v8; | |
1630 } | |
1631 a1.uObjectDescID = v11; | |
1632 a1.vPosition.y = a4; | |
1633 a1.vPosition.x = a3; | |
1634 a1.vPosition.z = a5; | |
1635 a1.uFacing = a6; | |
1636 a1.uAttributes = 0; | |
1637 a1.uSectorID = pIndoor->GetSector(a3, a4, a5); | |
1638 a1.uSpriteFrameID = 0; | |
1639 return a1.Create(0, 0, 0, 0); | |
1640 } | |
1641 | |
1642 //----- (0045063B) -------------------------------------------------------- | |
1643 int __fastcall sub_45063B(MapInfo *a1, int a2) | |
1644 { | |
1645 signed int v2; // edi@1 | |
1646 Actor *v3; // esi@2 | |
1647 signed __int64 v4; // qax@3 | |
1648 int result; // eax@8 | |
1649 int v6; // edi@11 | |
1650 int v7; // ebx@11 | |
1651 int v8; // edi@11 | |
1652 int v9; // ebx@12 | |
1653 int v10; // eax@12 | |
1654 char v11; // zf@16 | |
1655 int v12; // edi@20 | |
1656 int v13; // eax@20 | |
1657 int v14; // ebx@20 | |
1658 int v15; // eax@20 | |
1659 int v16; // eax@20 | |
1660 int v17; // eax@20 | |
1661 int v18; // eax@21 | |
1662 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 | |
1663 int v20; // [sp+24h] [bp-20h]@11 | |
1664 MapInfo *v21; // [sp+28h] [bp-1Ch]@1 | |
1665 int v22; // [sp+2Ch] [bp-18h]@3 | |
1666 int v23; // [sp+30h] [bp-14h]@11 | |
1667 int v24; // [sp+34h] [bp-10h]@1 | |
1668 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 | |
1669 int v26; // [sp+3Ch] [bp-8h]@11 | |
1670 int v27; // [sp+40h] [bp-4h]@11 | |
1671 | |
1672 v21 = a1; | |
1673 v24 = a2; | |
1674 v2 = 0; | |
1675 if ( (signed int)uNumActors <= 0 ) | |
1676 goto LABEL_8; | |
1202 | 1677 v3 = pActors.data(); |
0 | 1678 while ( 1 ) |
1679 { | |
1680 v22 = v3->pMonsterInfo.uID - 1; | |
1681 v4 = (signed __int64)((double)v22 * 0.3333333333333333); | |
1682 if ( (int)v4 != 40 ) | |
1683 { | |
1684 if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) | |
1685 break; | |
1686 } | |
1687 ++v2; | |
1688 ++v3; | |
1689 if ( v2 >= (signed int)uNumActors ) | |
1690 goto LABEL_8; | |
1691 } | |
1692 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
1693 { | |
1694 v22 = 0; | |
1695 uFaceID = 0; | |
1696 while ( 1 ) | |
1697 { | |
1698 ++uFaceID; | |
1699 v6 = rand() % 1024 + 512; | |
1700 v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; | |
323 | 1701 v20 = stru_5C6E00->Cos(v7); |
0 | 1702 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; |
1703 v19.vPosition.x = pParty->vPosition.x + v23; | |
323 | 1704 v20 = stru_5C6E00->Sin(v7); |
0 | 1705 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; |
1706 v8 = 0; | |
1707 v19.uIndex = v24; | |
1708 v19.vPosition.y = v23 + pParty->vPosition.y; | |
1709 v19.vPosition.z = pParty->vPosition.z; | |
1710 v26 = 0; | |
1711 v27 = 0; | |
723 | 1712 v19.vPosition.z = ODM_GetFloorLevel( |
0 | 1713 v19.vPosition.x, |
1714 v23 + pParty->vPosition.y, | |
1715 pParty->vPosition.z, | |
1716 0, | |
1717 &v26, | |
1718 &v27, | |
1719 0); | |
1720 v23 = 0; | |
1721 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
1722 { | |
1723 while ( 1 ) | |
1724 { | |
1725 v9 = abs(v19.vPosition.y - pOutdoor->pBModels[v8].vBoundingCenter.y); | |
1726 v10 = abs(v19.vPosition.x - pOutdoor->pBModels[v8].vBoundingCenter.x); | |
322 | 1727 if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 ) |
0 | 1728 break; |
1729 ++v23; | |
1730 ++v8; | |
1731 if ( v23 >= (signed int)pOutdoor->uNumBModels ) | |
1732 goto LABEL_16; | |
1733 } | |
1734 v22 = 1; | |
1735 } | |
1736 LABEL_16: | |
1737 v11 = uFaceID == 100; | |
1738 if ( uFaceID >= 100 ) | |
1739 break; | |
1740 if ( v22 ) | |
1741 { | |
1742 v11 = uFaceID == 100; | |
1743 break; | |
1744 } | |
1745 } | |
1746 } | |
1747 else | |
1748 { | |
1749 v26 = 0; | |
1750 v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1751 do | |
1752 { | |
1753 ++v26; | |
1754 v12 = rand() % 512 + 256; | |
1755 v13 = rand(); | |
1756 v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; | |
323 | 1757 v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); |
0 | 1758 v20 = v15; |
1759 v23 = (unsigned __int64)(v15 * (signed __int64)v12) >> 16; | |
1760 v19.vPosition.x = pParty->vPosition.x + v23; | |
323 | 1761 v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); |
0 | 1762 v20 = v16; |
1763 v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; | |
1764 v19.vPosition.y = v23 + pParty->vPosition.y; | |
1765 v19.vPosition.z = pParty->vPosition.z; | |
1766 v19.uIndex = v24; | |
1767 v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); | |
1768 if ( v17 == v22 ) | |
1769 { | |
723 | 1770 v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); |
0 | 1771 v19.vPosition.z = v18; |
1772 if ( v18 != -30000 ) | |
1773 { | |
1774 if ( abs(v18 - pParty->vPosition.z) <= 1024 ) | |
1775 break; | |
1776 } | |
1777 } | |
1778 } | |
1779 while ( v26 < 100 ); | |
1780 v11 = v26 == 100; | |
1781 } | |
1782 if ( v11 ) | |
1783 { | |
1784 LABEL_8: | |
1785 result = 0; | |
1786 } | |
1787 else | |
1788 { | |
1789 SpawnEncounter(v21, &v19, 0, 0, 1); | |
1790 result = v24; | |
1791 } | |
1792 return result; | |
1793 } | |
1794 | |
1795 //----- (00450929) -------------------------------------------------------- | |
1796 int LevelDecoration::GetGlobalEvent() | |
1797 { | |
1798 LevelDecoration *v1; // esi@1 | |
1799 signed int v2; // eax@1 | |
1800 int v3; // eax@5 | |
1801 int v4; // eax@6 | |
1802 int v5; // eax@7 | |
1803 int v6; // eax@8 | |
1804 int v7; // eax@9 | |
1805 int result; // eax@14 | |
1806 int v9; // eax@18 | |
1807 int v10; // eax@19 | |
1808 int v11; // eax@20 | |
1809 int v12; // eax@21 | |
1810 int v13; // eax@22 | |
1811 | |
1812 v1 = this; | |
1813 rand(); | |
1814 v2 = v1->uDecorationDescID; | |
1815 if ( v2 > 208 ) | |
1816 { | |
1817 switch ( v2 ) | |
1818 { | |
1819 case 209: | |
1820 result = rand() % 7 + 183; | |
1821 break; | |
1822 case 210: | |
1823 result = 150; | |
1824 break; | |
1825 case 211: | |
1826 result = 151; | |
1827 break; | |
1828 case 212: | |
1829 result = 152; | |
1830 break; | |
1831 case 213: | |
1832 result = 153; | |
1833 break; | |
1834 case 214: | |
1835 result = 154; | |
1836 break; | |
1837 case 215: | |
1838 result = 155; | |
1839 break; | |
1840 case 216: | |
1841 result = 156; | |
1842 break; | |
1843 case 217: | |
1844 result = 157; | |
1845 break; | |
1846 case 218: | |
1847 result = 158; | |
1848 break; | |
1849 case 219: | |
1850 result = 159; | |
1851 break; | |
1852 case 220: | |
1853 result = 160; | |
1854 break; | |
1855 case 221: | |
1856 result = 161; | |
1857 break; | |
1858 default: | |
1859 goto LABEL_45; | |
1860 } | |
1861 } | |
1862 else | |
1863 { | |
1864 if ( v2 == 208 ) | |
1865 { | |
1866 result = rand() % 7 + 176; | |
1867 } | |
1868 else | |
1869 { | |
1870 if ( v2 > 24 ) | |
1871 { | |
1872 v9 = v2 - 34; | |
1873 if ( !v9 ) | |
1874 return rand() % 6 + 4; | |
1875 v10 = v9 - 150; | |
1876 if ( !v10 ) | |
1877 return 33; | |
1878 v11 = v10 - 3; | |
1879 if ( !v11 || (v12 = v11 - 3) == 0 ) | |
1880 return 37; | |
1881 v13 = v12 - 16; | |
1882 if ( !v13 ) | |
1883 return rand() % 7 + 162; | |
1884 if ( v13 == 1 ) | |
1885 return rand() % 7 + 169; | |
1886 } | |
1887 else | |
1888 { | |
1889 if ( v2 == 24 ) | |
1890 return 36; | |
1891 v3 = v2 - 4; | |
1892 if ( !v3 ) | |
1893 return 16; | |
1894 v4 = v3 - 1; | |
1895 if ( !v4 ) | |
1896 return 32; | |
1897 v5 = v4 - 1; | |
1898 if ( !v5 ) | |
1899 return rand() % 4 + 12; | |
1900 v6 = v5 - 5; | |
1901 if ( !v6 ) | |
1902 return 34; | |
1903 v7 = v6 - 2; | |
1904 if ( !v7 ) | |
1905 return 17; | |
1906 if ( v7 == 1 ) | |
1907 return 18; | |
1908 } | |
1909 LABEL_45: | |
1910 result = 0; | |
1911 } | |
1912 } | |
1913 return result; | |
1914 } | |
1915 | |
1916 //----- (00450AAA) -------------------------------------------------------- | |
1917 void RespawnGlobalDecorations() | |
1918 { | |
1919 memset(stru_5E4C90._decor_events, 0, 125); | |
1920 | |
1921 uint decorEventIdx = 0; | |
1922 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
1923 { | |
1202 | 1924 auto decor = &pLevelDecorations[i]; |
0 | 1925 |
1926 if (!decor->field_16_event_id) | |
1927 { | |
1928 if (decor->IsInteractive()) | |
1929 { | |
1930 if (decorEventIdx < 124) | |
1931 { | |
1932 decor->_idx_in_stru123 = decorEventIdx + 75; | |
1933 stru_5E4C90._decor_events[decorEventIdx++] = decor->GetGlobalEvent(); | |
1934 } | |
1935 } | |
1936 } | |
1937 } | |
1938 } | |
1939 | |
1940 //----- (00450B0A) -------------------------------------------------------- | |
1941 bool __fastcall SpawnActor(unsigned int uMonsterID) | |
1942 { | |
1943 unsigned int v1; // ebx@1 | |
1944 bool result; // eax@2 | |
1945 MonsterDesc *v3; // esi@5 | |
1946 MonsterInfo *v4; // edi@5 | |
1947 Vec3_int_ v5; // ST08_12@5 | |
1948 unsigned int v6; // ecx@5 | |
1949 Actor *v7; // eax@7 | |
1950 Actor actor; // [sp+4h] [bp-350h]@5 | |
1951 Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5 | |
1952 | |
1953 v1 = uMonsterID; | |
1954 if ( uNumActors == 499 ) | |
1955 { | |
1956 result = 0; | |
1957 } | |
1958 else | |
1959 { | |
1960 if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters ) | |
1961 v1 = 0; | |
1962 v3 = &pMonsterList->pMonsters[v1]; | |
1963 v4 = &pMonsterStats->pInfos[v1 + 1]; | |
1964 memset(&actor, 0, 0x344u); | |
1965 strcpy(actor.pActorName, v4->pName); | |
1966 actor.sCurrentHP = LOWORD(v4->uHP); | |
1967 memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u); | |
1968 actor.word_000086_some_monster_id = v1 + 1; | |
1969 actor.uActorRadius = v3->uMonsterRadius; | |
1970 actor.uActorHeight = v3->uMonsterHeight; | |
1971 actor.uMovementSpeed = v3->uMovementSpeed; | |
1972 v5 = pParty->vPosition; | |
1973 Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y); | |
1974 actor.vInitialPosition.x = pOut.x; | |
1975 actor.vPosition.x = pOut.x; | |
1976 actor.uTetherDistance = 256; | |
1977 actor.vInitialPosition.y = LOWORD(pOut.z); | |
1978 actor.vPosition.y = LOWORD(pOut.z); | |
1979 actor.vInitialPosition.z = LOWORD(pOut.y); | |
1980 actor.vPosition.z = LOWORD(pOut.y); | |
1981 pSprites_LOD->DeleteSomeSprites(); | |
1982 pPaletteManager->ResetNonTestLocked(); | |
1983 v6 = uNumActors - 1; | |
1984 if ( dword_5C6DF8 == 1 ) | |
1985 { | |
1986 dword_5C6DF8 = 0; | |
1987 v6 = uNumActors++; | |
1988 } | |
1989 v7 = &pActors[v6]; | |
1990 memcpy(v7, &actor, 0x344u); | |
1991 v7->PrepareSprites(1); | |
1992 result = 1; | |
1993 } | |
1994 return result; | |
1995 } | |
1996 // 5C6DF8: using guessed type int dword_5C6DF8; | |
1997 | |
1998 //----- (00450DA3) -------------------------------------------------------- | |
1999 int __cdecl GetAlertStatus() | |
2000 { | |
2001 int result; // eax@2 | |
2002 | |
2003 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
2004 result = pOutdoor->ddm.field_C_alert; | |
2005 else | |
2006 result = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0; | |
2007 return result; | |
2008 } | |
2009 | |
2010 //----- (00450DDE) -------------------------------------------------------- | |
2011 stru350 *stru350::_450DDE() | |
2012 { | |
2013 _450DF1(&stru_4E82A4, &stru_4E82A4); | |
2014 return this; | |
2015 } | |
2016 | |
2017 //----- (00450DF1) -------------------------------------------------------- | |
2018 bool stru350::_450DF1(const stru355 *p1, const stru355 *p2) | |
2019 { | |
2020 //stru350 *v3; // esi@1 | |
2021 //void *result; // eax@1 | |
2022 unsigned int v5; // ecx@2 | |
2023 int v6; // edi@2 | |
2024 int v7; // edx@2 | |
2025 unsigned int v8; // ecx@8 | |
2026 int v9; // edi@8 | |
2027 int v10; // edx@8 | |
2028 int v11; // ecx@12 | |
2029 int v12; // edi@12 | |
2030 unsigned int v13; // ecx@12 | |
2031 int v14; // edx@12 | |
2032 int v15; // ecx@16 | |
2033 unsigned int v16; // edx@16 | |
2034 int v17; // ecx@16 | |
2035 int v18; // edi@16 | |
2036 char v19; // zf@20 | |
2037 unsigned int v20; // ecx@21 | |
2038 int v21; // edi@21 | |
2039 int v22; // edx@21 | |
2040 unsigned int v23; // ecx@27 | |
2041 int v24; // edi@27 | |
2042 int v25; // edx@27 | |
2043 int v26; // ecx@31 | |
2044 int v27; // edi@31 | |
2045 unsigned int v28; // ecx@31 | |
2046 int v29; // edx@31 | |
2047 int v30; // ebx@35 | |
2048 int v31; // ecx@35 | |
2049 int v32; // edi@35 | |
2050 int v33; // edx@35 | |
2051 unsigned int i; // ecx@35 | |
2052 int v35; // ecx@39 | |
2053 unsigned int v36; // edx@39 | |
2054 int v37; // ecx@39 | |
2055 int v38; // ebx@39 | |
2056 | |
2057 //v3 = this; | |
2058 memcpy(&field_0, p1, sizeof(stru355)); | |
2059 memcpy(&field_20, p2, sizeof(stru355)); | |
2060 //result = memcpy(&v3->field_20, p2, 0x20u); | |
2061 //LOBYTE(result) = 1; | |
2062 if (field_0.field_4 & 1) | |
2063 { | |
2064 v5 = field_0.field_1C; | |
2065 v6 = 0; | |
2066 v7 = 0; | |
2067 while ( !(v5 & 1) ) | |
2068 { | |
2069 ++v6; | |
2070 v5 >>= 1; | |
2071 } | |
2072 do | |
2073 { | |
2074 v5 >>= 1; | |
2075 ++v7; | |
2076 } | |
2077 while ( v5 & 1 ); | |
2078 field_40 = 32 - v7 - v6; | |
2079 } | |
2080 else | |
2081 { | |
2082 field_40 = 0; | |
2083 } | |
2084 v8 = field_0.field_10; | |
2085 v9 = 0; | |
2086 v10 = 0; | |
2087 while ( !(v8 & 1) ) | |
2088 { | |
2089 ++v9; | |
2090 v8 >>= 1; | |
2091 } | |
2092 do | |
2093 { | |
2094 v8 >>= 1; | |
2095 ++v10; | |
2096 } | |
2097 while ( v8 & 1 ); | |
2098 v11 = 24 - v10 - v9; | |
2099 v12 = 0; | |
2100 field_48 = v11; | |
2101 v13 = field_0.field_14; | |
2102 v14 = 0; | |
2103 while ( !(v13 & 1) ) | |
2104 { | |
2105 ++v12; | |
2106 v13 >>= 1; | |
2107 } | |
2108 do | |
2109 { | |
2110 v13 >>= 1; | |
2111 ++v14; | |
2112 } | |
2113 while ( v13 & 1 ); | |
2114 v15 = 16 - v14; | |
2115 v16 = field_0.field_18; | |
2116 field_50 = v15 - v12; | |
2117 v17 = 0; | |
2118 v18 = 0; | |
2119 while ( !(v16 & 1) ) | |
2120 { | |
2121 ++v17; | |
2122 v16 >>= 1; | |
2123 } | |
2124 do | |
2125 { | |
2126 v16 >>= 1; | |
2127 ++v18; | |
2128 } | |
2129 while ( v16 & 1 ); | |
2130 v19 = (field_20.field_4 & 1) == 0; | |
2131 field_58 = v17 - v18 + 8; | |
2132 if ( v19 ) | |
2133 { | |
2134 field_44 = 0; | |
2135 } | |
2136 else | |
2137 { | |
2138 v20 = field_20.field_1C; | |
2139 v21 = 0; | |
2140 v22 = 0; | |
2141 while ( !(v20 & 1) ) | |
2142 { | |
2143 ++v21; | |
2144 v20 >>= 1; | |
2145 } | |
2146 do | |
2147 { | |
2148 v20 >>= 1; | |
2149 ++v22; | |
2150 } | |
2151 while ( v20 & 1 ); | |
2152 field_44 = 32 - v22 - v21; | |
2153 } | |
2154 v23 = field_20.field_10; | |
2155 v24 = 0; | |
2156 v25 = 0; | |
2157 while ( !(v23 & 1) ) | |
2158 { | |
2159 ++v24; | |
2160 v23 >>= 1; | |
2161 } | |
2162 do | |
2163 { | |
2164 v23 >>= 1; | |
2165 ++v25; | |
2166 } | |
2167 while ( v23 & 1 ); | |
2168 v26 = 24 - v25 - v24; | |
2169 v27 = 0; | |
2170 field_4C = v26; | |
2171 v28 = field_20.field_14; | |
2172 v29 = 0; | |
2173 while ( !(v28 & 1) ) | |
2174 { | |
2175 ++v27; | |
2176 v28 >>= 1; | |
2177 } | |
2178 do | |
2179 { | |
2180 v28 >>= 1; | |
2181 ++v29; | |
2182 } | |
2183 while ( v28 & 1 ); | |
2184 v30 = 0; | |
2185 v31 = 16 - v29 - v27; | |
2186 v32 = field_20.field_18; | |
2187 field_54 = v31; | |
2188 v33 = 0; | |
2189 for ( i = v32; !(i & 1); i >>= 1 ) | |
2190 ++v30; | |
2191 do | |
2192 { | |
2193 i >>= 1; | |
2194 ++v33; | |
2195 } | |
2196 while ( i & 1 ); | |
2197 v35 = 32 - v33; | |
2198 v36 = v32; | |
2199 field_5C = v35 - v30; | |
2200 v37 = 0; | |
2201 v38 = 0; | |
2202 while ( !(v36 & 1) ) | |
2203 { | |
2204 ++v37; | |
2205 v36 >>= 1; | |
2206 } | |
2207 do | |
2208 { | |
2209 v36 >>= 1; | |
2210 ++v38; | |
2211 } | |
2212 while ( v36 & 1 ); | |
2213 field_5C = v37 - v38 + 8; | |
2214 return true; | |
2215 } | |
2216 | |
2217 //----- (00450F55) -------------------------------------------------------- | |
2218 unsigned int stru350::_450F55(int a2) | |
2219 { | |
2220 int v2 = a2 & stru_4E82A4.field_1C; | |
2221 if (field_20.field_4 & 1) | |
2222 v2 = (unsigned int)v2 >> this->field_44; | |
2223 return v2 & field_20.field_1C | | |
2224 field_20.field_10 & ((a2 & (unsigned int)stru_4E82A4.field_10) >> field_4C) | | |
2225 field_20.field_14 & ((a2 & (unsigned int)stru_4E82A4.field_14) >> field_54) | | |
2226 field_20.field_18 & ((a2 & (unsigned int)stru_4E82A4.field_18) >> field_5C); | |
2227 } | |
2228 | |
2229 //----- (00450FB1) -------------------------------------------------------- | |
2230 int stru350::_450FB1(int a2) | |
2231 { | |
2232 int v2 = 0; | |
2233 int v4 = field_0.field_4 & 1; | |
2234 if ( v4 ) | |
2235 v2 = a2 & field_0.field_1C; | |
2236 if ( v4 ) | |
2237 v2 <<= field_40; | |
2238 return v2 | ((a2 & field_0.field_10) << field_48) | ((a2 & field_0.field_14) << field_50) | ((a2 & field_0.field_18) << field_58); | |
2239 } | |
2240 | |
2241 //----- (00452442) -------------------------------------------------------- | |
2242 unsigned int __fastcall sub_452442(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4) | |
2243 { | |
2244 int v4; // ebx@0 | |
2245 __int16 v5; // ST14_2@1 | |
2246 __int16 v6; // dx@1 | |
2247 int v7; // ecx@1 | |
2248 __int16 v8; // ST10_2@1 | |
2249 int v9; // edi@1 | |
2250 unsigned __int16 v10; // dh@1@1 | |
2251 int v11; // ebx@1 | |
2252 int v12; // ebx@1 | |
2253 __int16 a3a; // [sp+1Ch] [bp+8h]@1 | |
2254 | |
2255 v5 = a2 >> 2; | |
2256 v6 = (unsigned __int16)a4 >> 2; | |
2257 v8 = a1 >> 2; | |
2258 a3a = (unsigned __int16)a3 >> 2; | |
2259 LOWORD(v7) = a3a; | |
2260 v9 = v7; | |
2261 LOWORD(v4) = ((unsigned __int16)a4 >> 2) & 0xE0; | |
2262 LOWORD(v7) = a3a & 0xE0; | |
2263 LOWORD(v9) = v9 & 0x1C00; | |
2264 v11 = v7 + v4; | |
2265 LOWORD(v7) = v5 & 0xE0; | |
2266 v12 = v7 + v11; | |
2267 LOWORD(v7) = v8 & 0xE0; | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1408
diff
changeset
|
2268 __debugbreak(); // warning C4700: uninitialized local variable 'v10' used |
848 | 2269 return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00) |
0 | 2270 + (v5 & 0x1C00) |
2271 + v9 | |
2272 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00)); | |
2273 } | |
2274 | |
2275 //----- (0045281E) -------------------------------------------------------- | |
2276 // Calculates atan2(y/x) | |
2277 // return value: angle in integer format (multiplier of Pi/1024) | |
2278 unsigned int stru193_math::Atan2(int x, int y) | |
2279 { | |
2280 signed int quadrant; | |
2281 __int64 dividend; | |
2282 int quotient; | |
2283 int lowIdx; | |
2284 int highIdx; | |
2285 int angle; | |
2286 | |
2287 auto X = x; | |
2288 auto Y = y; | |
2289 | |
2290 if ( abs(X) < 65536 ) | |
2291 { | |
2292 if ( (abs(Y) >> 15) >= abs(X) ) | |
2293 X = 0; | |
2294 } | |
2295 | |
2296 if ( !X ) | |
2297 { | |
2298 if ( Y > 0 ) | |
2299 { | |
2300 return uIntegerHalfPi; //Pi/2 | |
2301 } | |
2302 else | |
2303 { | |
2304 return uIntegerHalfPi + uIntegerPi; //3*(Pi/2) | |
2305 } | |
2306 } | |
2307 | |
2308 if ( Y ) | |
2309 { | |
2310 if ( X < 0 ) | |
2311 { | |
2312 X = -X; | |
2313 if ( Y > 0 ) | |
2314 { | |
2315 quadrant = 4; | |
2316 } | |
2317 else | |
2318 { | |
2319 quadrant = 3; | |
2320 } | |
2321 } | |
2322 else | |
2323 { | |
2324 if ( Y > 0 ) | |
2325 { | |
2326 quadrant = 1; | |
2327 } | |
2328 else | |
2329 { | |
2330 quadrant = 2; | |
2331 } | |
2332 } | |
2333 | |
2334 if ( Y < 0 ) | |
2335 Y = -Y; | |
2336 | |
2337 LODWORD(dividend) = Y << 16; | |
2338 HIDWORD(dividend) = Y >> 16; | |
2339 quotient = dividend / X; | |
2340 | |
2341 //looks like binary search | |
2342 { | |
2343 int i; | |
2344 highIdx = uIntegerHalfPi; | |
2345 lowIdx = 0; | |
2346 | |
2347 for (i = 0; i < 6; ++i) | |
2348 { | |
2349 if (quotient <= pTanTable[(lowIdx + highIdx) / 2]) | |
2350 highIdx = (lowIdx + highIdx) / 2; | |
2351 else | |
2352 lowIdx = (lowIdx + highIdx) / 2; | |
2353 } | |
2354 } | |
2355 | |
2356 angle = lowIdx + 1; | |
2357 while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] ) | |
2358 ++angle; | |
2359 | |
2360 switch (quadrant) | |
2361 { | |
2362 case 1: //X > 0, Y > 0 | |
2363 return angle; | |
2364 | |
2365 case 2: //X > 0, Y < 0 | |
2366 return uIntegerDoublePi - angle; //2*Pi - angle | |
2367 | |
2368 case 3: //X > 0, Y < 0 | |
2369 return uIntegerPi + angle; //Pi + angle | |
2370 | |
2371 case 4: //X < 0, Y > 0 | |
2372 return uIntegerPi - angle; //Pi - angle | |
2373 } | |
2374 | |
2375 //should newer get here | |
2376 return 0; | |
2377 } | |
2378 | |
2379 if ( X < 0 ) //Y == 0, X < 0 | |
2380 return uIntegerPi; | |
2381 | |
2382 return 0; | |
2383 } | |
2384 | |
2385 //----- (00452969) -------------------------------------------------------- | |
2386 stru193_math::stru193_math() | |
2387 { | |
2388 double v3; // ST18_8@2 | |
1214
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2389 |
0 | 2390 this->pTanTable[0] = 0; |
2391 this->pCosTable[0] = 65536; | |
2392 this->pInvCosTable[0] = 65536; | |
1214
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2393 for(int i = 1; i < (signed int)this->uIntegerHalfPi; i++) |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2394 { |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2395 v3 = (double)i * 3.141592653589793 / (double)uIntegerPi; |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2396 pTanTable[i] = (signed __int64)(tan(v3) * (double)this->pCosTable[0] + 0.5); |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2397 pCosTable[i] = (signed __int64)(cos(v3) * (double)this->pCosTable[0] + 0.5); |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2398 pInvCosTable[i] = (signed __int64)(1.0 / cos(v3) * (double)this->pCosTable[0] + 0.5); |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2399 } |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2400 for(int i = this->uIntegerHalfPi; i < 520; i++) |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2401 { |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2402 this->pTanTable[i] = 0xEFFFFFFFu; |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2403 this->pCosTable[i] = 0; |
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
2404 this->pInvCosTable[i] = 0xEFFFFFFFu; |
0 | 2405 } |
2406 } | |
2407 | |
2408 //----- (00452A9E) -------------------------------------------------------- | |
295 | 2409 int integer_sqrt(int val) |
0 | 2410 { |
2411 signed int result; // eax@2 | |
295 | 2412 unsigned int v2; // edx@3 |
271 | 2413 unsigned int v3; // edi@3 |
2414 //signed int v4; // ebx@3 | |
0 | 2415 int v5; // esi@4 |
2416 | |
295 | 2417 if (val < 1) |
2418 return val; | |
271 | 2419 |
2420 | |
0 | 2421 v2 = 0; |
295 | 2422 v3 = val; |
0 | 2423 result = 0; |
271 | 2424 //v4 = 16; |
2425 for (uint i = 0; i < 16; ++i) | |
2426 { | |
0 | 2427 result *= 2; |
271 | 2428 v2 = (v3 >> 30) | 4 * v2; |
0 | 2429 v5 = 2 * result + 1; |
2430 v3 *= 4; | |
295 | 2431 if ( v2 >= v5 ) |
0 | 2432 { |
2433 ++result; | |
2434 v2 -= v5; | |
2435 } | |
271 | 2436 //--v4; |
2437 } | |
2438 //while ( v4 ); | |
295 | 2439 if ( val - result * result >= (unsigned int)(result - 1) ) |
0 | 2440 ++result; |
295 | 2441 return result; |
0 | 2442 } |
2443 | |
2444 //----- (00452AE2) -------------------------------------------------------- | |
2445 int __fastcall MakeColorMaskFromBitDepth(int a1) | |
2446 { | |
2447 signed __int64 v1; // qax@1 | |
2448 | |
2449 v1 = 4294967296i64; | |
2450 if ( a1 > 0 ) | |
2451 { | |
2452 do | |
2453 { | |
2454 LODWORD(v1) = HIDWORD(v1) + v1; | |
2455 HIDWORD(v1) *= 2; | |
2456 --a1; | |
2457 } | |
2458 while ( a1 ); | |
2459 } | |
2460 return v1; | |
2461 } | |
2462 | |
2463 //----- (00452AF3) -------------------------------------------------------- | |
2464 void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels) | |
2465 { | |
2466 void *v3; // edi@1 | |
2467 unsigned int v4; // eax@1 | |
2468 unsigned __int16 *v5; // edi@3 | |
2469 unsigned int i; // ecx@3 | |
2470 | |
2471 v3 = pPixels; | |
2472 v4 = a1 | (a1 << 16); | |
2473 if ( (unsigned __int8)pPixels & 2 ) // first 2 pixels | |
2474 { | |
2475 *pPixels = v4; | |
2476 v3 = pPixels + 1; | |
2477 --uNumPixels; | |
2478 } | |
2479 memset32(v3, v4, uNumPixels >> 1); // 4 pixels at once | |
2480 v5 = (unsigned __int16 *)((char *)v3 + 4 * (uNumPixels >> 1)); | |
2481 for ( i = uNumPixels & 1; i; --i ) // leftover pixels | |
2482 { | |
2483 *v5 = v4; | |
2484 ++v5; | |
2485 } | |
2486 } | |
2487 | |
2488 //----- (00452B2E) -------------------------------------------------------- | |
2489 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) | |
2490 { | |
2491 signed int v2; // edi@1 | |
2492 int v3; // esi@1 | |
2493 int result; // eax@2 | |
2494 unsigned int v5; // ebx@4 | |
2495 | |
2496 v2 = uDiceSides; | |
2497 v3 = 0; | |
2498 if ( uDiceSides ) | |
2499 { | |
2500 if ( (signed int)uNumDice > 0 ) | |
2501 { | |
2502 v5 = uNumDice; | |
2503 do | |
2504 { | |
2505 --v5; | |
2506 v3 += rand() % v2 + 1; | |
2507 } | |
2508 while ( v5 ); | |
2509 } | |
2510 result = v3; | |
2511 } | |
2512 else | |
2513 { | |
2514 result = 0; | |
2515 } | |
2516 return result; | |
2517 } | |
2518 | |
2519 //----- (00453F62) -------------------------------------------------------- | |
2520 void MapStats::Initialize() | |
2521 { | |
237 | 2522 char work_str[32]; // [sp+Ch] [bp-34h]@3 |
2523 int work_str_pos; | |
2524 int work_str_len; | |
2525 int i; | |
2526 char* test_string; | |
2527 unsigned char c; | |
2528 bool break_loop; | |
2529 unsigned int temp_str_len; | |
2530 char* tmp_pos; | |
2531 int decode_step; | |
2532 int item_counter; | |
2533 | |
0 | 2534 if ( pMapStatsTXT_Raw ) |
2535 pAllocator->FreeChunk(pMapStatsTXT_Raw); | |
237 | 2536 pMapStatsTXT_Raw = NULL; |
0 | 2537 pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); |
2538 strtok(pMapStatsTXT_Raw, "\r"); | |
237 | 2539 strtok(NULL, "\r"); |
2540 strtok(NULL, "\r"); | |
2541 | |
2542 for (i=1; i<77; ++i) | |
2543 { | |
2544 test_string = strtok(NULL, "\r") + 1; | |
2545 break_loop = false; | |
2546 decode_step=0; | |
2547 do | |
2548 { | |
2549 c = *(unsigned char*)test_string; | |
2550 temp_str_len = 0; | |
2551 while((c!='\t')&&(c>0)) | |
2552 { | |
2553 ++temp_str_len; | |
2554 c=test_string[temp_str_len]; | |
2555 } | |
2556 tmp_pos=test_string+temp_str_len; | |
2557 if (*tmp_pos == 0) | |
2558 break_loop = true; | |
2559 *tmp_pos = 0; | |
2560 if (temp_str_len) | |
2561 { | |
2562 switch (decode_step) | |
2563 { | |
2564 case 1: | |
2565 pInfos[i].pName = RemoveQuotes(test_string); | |
2566 break; | |
2567 case 2: | |
2568 pInfos[i].pFilename = RemoveQuotes(test_string); | |
2569 break; | |
2570 case 3: | |
2571 pInfos[i].uNumResets = atoi(test_string); | |
2572 break; | |
2573 case 4: | |
2574 pInfos[i].uFirstVisitedAt = atoi(test_string); | |
2575 break; | |
2576 case 5: | |
2577 pInfos[i]._per = atoi(test_string); | |
2578 break; | |
2579 case 6: | |
2580 pInfos[i].uRespawnIntervalDays = atoi(test_string); | |
2581 break; | |
2582 case 7: | |
2583 pInfos[i]._alert_days = atoi(test_string); | |
2584 break; | |
2585 case 8: | |
2586 pInfos[i]._steal_perm = atoi(test_string); | |
2587 break; | |
2588 case 9: | |
2589 pInfos[i].LockX5 = atoi(test_string); | |
2590 break; | |
2591 case 10: | |
2592 pInfos[i].Trap_D20 = atoi(test_string); | |
2593 break; | |
2594 case 11: | |
2595 pInfos[i].Treasure_prob = atoi(test_string); | |
2596 break; | |
2597 case 12: | |
2598 pInfos[i].Encounter_percent = atoi(test_string); | |
2599 break; | |
2600 case 13: | |
2601 pInfos[i].EncM1percent = atoi(test_string); | |
2602 break; | |
2603 case 14: | |
2604 pInfos[i].EncM2percent = atoi(test_string); | |
2605 break; | |
2606 case 15: | |
2607 pInfos[i].EncM3percent = atoi(test_string); | |
2608 break; | |
2609 case 16: | |
2610 pInfos[i].pEncounterMonster1Texture = RemoveQuotes(test_string); | |
2611 break; | |
2612 case 18: | |
2613 pInfos[i].Dif_M1 = atoi(test_string); | |
2614 break; | |
2615 case 19: | |
2616 pInfos[i].uEncounterMonster1AtLeast = 1; | |
2617 pInfos[i].uEncounterMonster1AtMost = 1; | |
2618 strcpy(work_str, test_string); | |
2619 work_str_pos = 0; | |
2620 work_str_len=strlen(work_str); | |
2621 if (work_str_len ) | |
2622 { | |
2623 while (work_str[work_str_pos] != '-' ) | |
2624 { | |
2625 ++work_str_pos; | |
2626 if (work_str_pos >= work_str_len ) | |
2627 break; | |
2628 } | |
2629 work_str[work_str_pos] = 0; | |
2630 pInfos[i].uEncounterMonster1AtLeast = atoi(work_str); | |
2631 if ( work_str_pos < work_str_len ) | |
2632 pInfos[i].uEncounterMonster1AtMost = atoi(&work_str[work_str_pos + 1]); | |
2633 else | |
2634 pInfos[i].uEncounterMonster1AtMost = pInfos[i].uEncounterMonster1AtLeast; | |
2635 } | |
2636 break; | |
2637 case 20: | |
2638 pInfos[i].pEncounterMonster2Texture = RemoveQuotes(test_string); | |
2639 break; | |
2640 case 22: | |
2641 pInfos[i].Dif_M2 = atoi(test_string); | |
2642 break; | |
2643 case 23: | |
2644 pInfos[i].uEncounterMonster2AtLeast = 1; | |
2645 pInfos[i].uEncounterMonster2AtMost = 1; | |
2646 strcpy(work_str, test_string); | |
2647 work_str_pos = 0; | |
2648 work_str_len=strlen(work_str); | |
2649 if (work_str_len ) | |
2650 { | |
2651 while (work_str[work_str_pos] != '-' ) | |
2652 { | |
2653 ++work_str_pos; | |
2654 if (work_str_pos >= work_str_len ) | |
2655 break; | |
2656 } | |
2657 work_str[work_str_pos] = 0; | |
2658 pInfos[i].uEncounterMonster2AtLeast = atoi(work_str); | |
2659 if ( work_str_pos < work_str_len ) | |
2660 pInfos[i].uEncounterMonster2AtMost = atoi(&work_str[work_str_pos + 1]); | |
2661 else | |
2662 pInfos[i].uEncounterMonster2AtMost = pInfos[i].uEncounterMonster2AtLeast; | |
2663 } | |
2664 break; | |
2665 case 24: | |
2666 pInfos[i].pEncounterMonster3Texture = RemoveQuotes(test_string); | |
2667 break; | |
2668 case 26: | |
2669 pInfos[i].Dif_M3 = atoi(test_string); | |
2670 break; | |
2671 case 27: | |
2672 pInfos[i].uEncounterMonster3AtLeast = 1; | |
2673 pInfos[i].uEncounterMonster3AtMost = 1; | |
2674 strcpy(work_str, test_string); | |
2675 work_str_pos = 0; | |
2676 work_str_len=strlen(work_str); | |
2677 if (work_str_len ) | |
2678 { | |
2679 while (work_str[work_str_pos] != '-' ) | |
2680 { | |
2681 ++work_str_pos; | |
2682 if (work_str_pos >= work_str_len ) | |
2683 break; | |
2684 } | |
2685 work_str[work_str_pos] = 0; | |
2686 pInfos[i].uEncounterMonster3AtLeast = atoi(work_str); | |
2687 if ( work_str_pos < work_str_len ) | |
2688 pInfos[i].uEncounterMonster3AtMost = atoi(&work_str[work_str_pos + 1]); | |
2689 else | |
2690 pInfos[i].uEncounterMonster3AtMost = pInfos[i].uEncounterMonster3AtLeast; | |
2691 } | |
2692 break; | |
2693 case 28: | |
2694 pInfos[i].uRedbookTrackID = atoi(test_string); | |
2695 break; | |
2696 case 29: | |
2697 { | |
2698 if ( !strcmp(test_string, "CAVE") ) | |
2699 { | |
2700 pInfos[i].uEAXEnv = 8; | |
2701 break; | |
2702 } | |
2703 if ( !strcmp(test_string, "STONEROOM") ) | |
2704 { | |
2705 pInfos[i].uEAXEnv = 5; | |
2706 break; | |
2707 } | |
2708 if ( !strcmp(test_string, "MOUNTAINS") ) | |
2709 { | |
2710 pInfos[i].uEAXEnv = 17; | |
2711 break; | |
2712 } | |
2713 if ( !strcmp(test_string, "PLAIN") ) | |
2714 { | |
2715 pInfos[i].uEAXEnv = 19; | |
2716 break; | |
2717 } | |
2718 if ( !strcmp(test_string, "FOREST") ) | |
2719 { | |
2720 pInfos[i].uEAXEnv = 15; | |
2721 break; | |
2722 } | |
2723 if ( !strcmp(test_string, "CITY") ) | |
2724 { | |
2725 pInfos[i].uEAXEnv = 16; | |
2726 break; | |
2727 } | |
2728 if ( !strcmp(test_string, "UNDERWATER") ) | |
2729 { | |
2730 pInfos[i].uEAXEnv = 22; | |
2731 break; | |
2732 } | |
2733 if ( !strcmp(test_string, "ARENA") ) | |
2734 { | |
2735 pInfos[i].uEAXEnv = 9; | |
2736 break; | |
2737 } | |
2738 if ( !strcmp(test_string, "GENERIC") ) | |
2739 { | |
2740 pInfos[i].uEAXEnv = 0; | |
2741 break; | |
2742 } | |
2743 if ( !strcmp(test_string, "PADDEDCELL") ) | |
2744 { | |
2745 pInfos[i].uEAXEnv = 1; | |
2746 break; | |
2747 } | |
2748 if ( !strcmp(test_string, "ROOM") ) | |
2749 { | |
2750 pInfos[i].uEAXEnv = 2; | |
2751 break; | |
2752 } | |
2753 if ( !strcmp(test_string, "BATHROOM") ) | |
2754 { | |
2755 pInfos[i].uEAXEnv = 3; | |
2756 break; | |
2757 } | |
2758 if ( !strcmp(test_string, "LIVINGROOM") ) | |
2759 { | |
2760 pInfos[i].uEAXEnv = 4; | |
2761 break; | |
2762 } | |
2763 if ( !strcmp(test_string, "AUDITORIUM") ) | |
2764 { | |
2765 pInfos[i].uEAXEnv = 6; | |
2766 break; | |
2767 } | |
2768 if ( !strcmp(test_string, "CONCERTHALL") ) | |
2769 { | |
2770 pInfos[i].uEAXEnv = 7; | |
2771 break; | |
2772 } | |
2773 if ( !strcmp(test_string, "HANGAR") ) | |
2774 { | |
2775 pInfos[i].uEAXEnv = 10; | |
2776 break; | |
2777 } | |
2778 if ( !strcmp(test_string, "CARPETEDHALLWAY") ) | |
2779 { | |
2780 pInfos[i].uEAXEnv = 11; | |
2781 break; | |
2782 } | |
2783 if ( !strcmp(test_string, "HALLWAY") ) | |
2784 { | |
2785 pInfos[i].uEAXEnv = 12; | |
2786 break; | |
2787 } | |
2788 if ( !strcmp(test_string, "STONECORRIDOR") ) | |
2789 { | |
2790 pInfos[i].uEAXEnv = 13; | |
2791 break; | |
2792 } | |
2793 if ( !strcmp(test_string, "ALLEY") ) | |
2794 { | |
2795 pInfos[i].uEAXEnv = 14; | |
2796 break; | |
2797 } | |
2798 if ( !strcmp(test_string, "QUARRY") ) | |
2799 { | |
2800 pInfos[i].uEAXEnv = 18; | |
2801 break; | |
2802 } | |
2803 if ( !strcmp(test_string, "PARKINGLOT") ) | |
2804 { | |
2805 pInfos[i].uEAXEnv = 20; | |
2806 break; | |
2807 } | |
2808 if ( !strcmp(test_string, "SEWERPIPE") ) | |
2809 { | |
2810 pInfos[i].uEAXEnv = 21; | |
2811 break; | |
2812 } | |
2813 if ( !strcmp(test_string, "DRUGGED") ) | |
2814 { | |
2815 pInfos[i].uEAXEnv = 23; | |
2816 break; | |
2817 } | |
2818 if ( !strcmp(test_string, "DIZZY") ) | |
2819 { | |
2820 pInfos[i].uEAXEnv = 24; | |
2821 break; | |
2822 } | |
2823 if ( !strcmp(test_string, "PSYCHOTIC") ) | |
2824 { | |
2825 pInfos[i].uEAXEnv = 25; | |
2826 break; | |
2827 } | |
2828 pInfos[i].uEAXEnv = 26; | |
2829 | |
2830 } | |
2831 break; | |
2832 } | |
2833 } | |
2834 else | |
2835 { | |
2836 break_loop = true; | |
2837 } | |
2838 ++decode_step; | |
2839 test_string=tmp_pos+1; | |
2840 } while ((decode_step<31)&&!break_loop); | |
2841 } | |
2842 | |
2843 uNumMaps = 77; | |
0 | 2844 } |
2845 // 453F62: using guessed type char Str[32]; | |
2846 | |
2847 //----- (004547A3) -------------------------------------------------------- | |
767 | 2848 MAP_TYPE MapStats::GetMapInfo(const char *Str2) |
2849 { | |
2850 assert(uNumMaps >= 2); | |
2851 | |
2852 for (uint i = 1; i < uNumMaps; ++i) | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1150
diff
changeset
|
2853 if (!_stricmp(pInfos[i].pFilename, Str2)) |
767 | 2854 return (MAP_TYPE)i; |
2855 | |
2856 assert(false && "Map not found!"); | |
0 | 2857 } |
2858 | |
2859 //----- (004547E4) -------------------------------------------------------- | |
2860 void FactionTable::Initialize() | |
2861 { | |
237 | 2862 int i; |
2863 char* test_string; | |
2864 unsigned char c; | |
2865 bool break_loop; | |
2866 unsigned int temp_str_len; | |
2867 char* tmp_pos; | |
2868 int decode_step; | |
2869 int item_counter; | |
2870 | |
0 | 2871 if ( pHostileTXT_Raw ) |
2872 pAllocator->FreeChunk(pHostileTXT_Raw); | |
237 | 2873 pHostileTXT_Raw = NULL; |
0 | 2874 pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); |
2875 strtok(pHostileTXT_Raw, "\r"); | |
237 | 2876 for (i=0; i<89; ++i) |
2877 { | |
2878 test_string = strtok(NULL, "\r") + 1; | |
2879 break_loop = false; | |
2880 decode_step=0; | |
2881 do | |
2882 { | |
2883 c = *(unsigned char*)test_string; | |
2884 temp_str_len = 0; | |
2885 while((c!='\t')&&(c>0)) | |
2886 { | |
2887 ++temp_str_len; | |
2888 c=test_string[temp_str_len]; | |
2889 } | |
2890 tmp_pos=test_string+temp_str_len; | |
2891 if (*tmp_pos == 0) | |
2892 break_loop = true; | |
2893 *tmp_pos = 0; | |
2894 if (temp_str_len) | |
2895 { | |
2896 if ( decode_step >= 1 && decode_step < 90 ) | |
2897 relations[decode_step-1][i] = atoi(test_string); | |
2898 } | |
2899 else | |
2900 { | |
2901 break_loop = true; | |
2902 } | |
2903 ++decode_step; | |
2904 test_string=tmp_pos+1; | |
2905 } while ((decode_step<92)&&!break_loop); | |
2906 } | |
2907 if ( pHostileTXT_Raw) | |
0 | 2908 { |
2909 pAllocator->FreeChunk(pHostileTXT_Raw); | |
237 | 2910 pHostileTXT_Raw = NULL; |
0 | 2911 } |
2912 } | |
2913 | |
2914 //----- (00458244) -------------------------------------------------------- | |
1064 | 2915 int SkillToMastery( unsigned int skill_value ) |
1067 | 2916 { |
1064 | 2917 switch (skill_value & 0x1C0) |
983 | 2918 { |
2919 case 0x100: return 4; // Grandmaster | |
2920 case 0x80: return 3; // Master | |
2921 case 0x40: return 2; // Expert | |
2922 case 0x00: return 1; // Normal | |
1409
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1408
diff
changeset
|
2923 } |
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1408
diff
changeset
|
2924 assert(false); |
c9e3b93ec570
Highlighted locations with "using uninitialized variable" warning.
Nomad
parents:
1408
diff
changeset
|
2925 return 0; |
0 | 2926 } |
2927 | |
2928 //----- (0045828B) -------------------------------------------------------- | |
2929 unsigned int __fastcall GetSpellColor(signed int a1) | |
2930 { | |
2931 unsigned __int16 v1; // dx@3 | |
2932 unsigned __int16 v2; // cx@6 | |
2933 unsigned __int16 v4; // [sp-4h] [bp-4h]@3 | |
2934 | |
2935 if ( a1 < 1 ) | |
2936 { | |
2937 if ( a1 < 12 ) | |
2938 { | |
2939 if ( a1 < 23 ) | |
2940 { | |
2941 if ( a1 < 34 ) | |
2942 { | |
2943 if ( a1 < 45 ) | |
2944 { | |
2945 if ( a1 < 56 ) | |
2946 { | |
2947 if ( a1 < 67 ) | |
2948 { | |
2949 if ( a1 < 78 ) | |
2950 { | |
2951 if ( a1 < 89 ) | |
2952 goto LABEL_31; | |
2953 goto LABEL_28; | |
2954 } | |
2955 LABEL_25: | |
2956 if ( a1 < 89 ) | |
2957 { | |
2958 v4 = 155; | |
2959 v2 = 255; | |
2960 goto LABEL_30; | |
2961 } | |
2962 LABEL_28: | |
2963 if ( a1 < 100 ) | |
2964 { | |
2965 v4 = 240; | |
2966 v2 = 192; | |
2967 goto LABEL_30; | |
2968 } | |
2969 LABEL_31: | |
2970 v4 = 0; | |
2971 v1 = 0; | |
2972 goto LABEL_32; | |
2973 } | |
2974 LABEL_21: | |
2975 if ( a1 < 78 ) | |
2976 { | |
2977 v4 = 0; | |
2978 v1 = 128; | |
2979 goto LABEL_23; | |
2980 } | |
2981 goto LABEL_25; | |
2982 } | |
2983 LABEL_18: | |
2984 if ( a1 < 67 ) | |
2985 { | |
2986 v4 = 255; | |
2987 v1 = 15; | |
2988 v2 = 235; | |
949 | 2989 return TargetColor(v2, v1, v4); |
0 | 2990 } |
2991 goto LABEL_21; | |
2992 } | |
2993 LABEL_15: | |
2994 if ( a1 < 56 ) | |
2995 { | |
2996 v2 = 225; | |
2997 goto LABEL_13; | |
2998 } | |
2999 goto LABEL_18; | |
3000 } | |
3001 LABEL_11: | |
3002 if ( a1 < 45 ) | |
3003 { | |
3004 v2 = 128; | |
3005 LABEL_13: | |
3006 v4 = v2; | |
3007 LABEL_30: | |
3008 v1 = v2; | |
949 | 3009 return TargetColor(v2, v1, v4); |
0 | 3010 } |
3011 goto LABEL_15; | |
3012 } | |
3013 LABEL_8: | |
3014 if ( a1 < 34 ) | |
3015 { | |
3016 v4 = 255; | |
3017 v1 = 128; | |
3018 LABEL_32: | |
3019 v2 = 0; | |
949 | 3020 return TargetColor(v2, v1, v4); |
0 | 3021 } |
3022 goto LABEL_11; | |
3023 } | |
3024 } | |
3025 else | |
3026 { | |
3027 if ( a1 < 12 ) | |
3028 { | |
3029 v4 = 0; | |
3030 v1 = 85; | |
3031 LABEL_23: | |
3032 v2 = 255; | |
949 | 3033 return TargetColor(v2, v1, v4); |
0 | 3034 } |
3035 } | |
3036 if ( a1 >= 23 ) | |
3037 goto LABEL_8; | |
3038 v4 = 255; | |
3039 v1 = 212; | |
3040 v2 = 150; | |
949 | 3041 return TargetColor(v2, v1, v4); |
0 | 3042 } |
3043 | |
3044 //----- (004610AA) -------------------------------------------------------- | |
3045 void __fastcall PrepareToLoadODM(unsigned int bLoading, OutdoorCamera *a2) | |
3046 { | |
3047 unsigned int v2; // edi@1 | |
3048 OutdoorCamera *v3; // esi@1 | |
3049 | |
3050 v2 = bLoading; | |
3051 v3 = a2; | |
3052 pGameLoadingUI_ProgressBar->Reset(0x1Bu); | |
3053 pSoundList->_4A9D79(0); | |
3054 uCurrentlyLoadedLevelType = (LEVEL_TYPE)2; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
3055 ODM_LoadAndInitialize(pCurrentMapName.data(), v3); |
0 | 3056 if ( !v2 ) |
3057 TeleportToStartingPoint(uLevel_StartingPointType); | |
3058 viewparams->_443365(); | |
3059 PlayLevelMusic(); | |
3060 } | |
3061 // 6BE35C: using guessed type int uLevel_StartingPointType; | |
3062 | |
3063 //----- (00461103) -------------------------------------------------------- | |
3064 void __cdecl sub_461103() | |
3065 { | |
3066 //GUIProgressBar *v0; // ebx@1 | |
3067 //signed int v1; // ebp@1 | |
3068 //char *v2; // esi@2 | |
3069 __int16 v3; // cx@3 | |
3070 int v4; // edx@8 | |
3071 //size_t v5; // edi@14 | |
3072 signed int v6; // esi@14 | |
3073 //char *v7; // edx@15 | |
3074 signed int v8; // ecx@16 | |
3075 int v9; // ecx@23 | |
3076 MonsterInfo *v10; // ebx@23 | |
3077 //int *v11; // esi@23 | |
3078 int v12; // esi@25 | |
3079 int v13; // eax@26 | |
3080 __int16 v14; // ax@41 | |
3081 //signed int v15; // [sp+10h] [bp-4Ch]@1 | |
3082 //signed int v16; // [sp+10h] [bp-4Ch]@14 | |
3083 signed int v17; // [sp+14h] [bp-48h]@3 | |
3084 signed int v18; // [sp+14h] [bp-48h]@23 | |
3085 int v19; // [sp+18h] [bp-44h]@1 | |
3086 signed int v20; // [sp+18h] [bp-44h]@14 | |
3087 int v21[16]; // [sp+1Ch] [bp-40h]@17 | |
3088 | |
598 | 3089 GenerateItemsInChest(); |
0 | 3090 //v0 = pGameLoadingUI_ProgressBar; |
3091 pGameLoadingUI_ProgressBar->Progress(); | |
3092 pParty->uFlags |= 2u; | |
3093 pParty->field_7B5_in_arena_quest = 0; | |
3094 //v1 = 0; | |
3095 dword_5C6DF8 = 1; | |
291 | 3096 pNPCStats->uNewlNPCBufPos = 0; |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
3097 v19 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 3098 |
3099 //v15 = 0; | |
3100 for (uint i = 0; i < uNumActors; ++i) | |
3101 //if ( (signed int)uNumActors > 0 ) | |
3102 { | |
1202 | 3103 auto pActor = &pActors[i]; |
0 | 3104 //v2 = (char *)&pActors[0].uNPC_ID; |
3105 //do | |
3106 //{ | |
3107 v3 = pActor->pMonsterInfo.uID; | |
3108 v17 = 0; | |
3109 if ( v3 >= 115 && v3 <= 186 || v3 >= 232 && v3 <= 249 ) | |
3110 v17 = 1; | |
3111 //v1 = 0; | |
3112 v4 = (v3 - 1) % 3; | |
3113 if ( 2 == v4 ) | |
3114 { | |
602 | 3115 if ( pActor->sNPC_ID && pActor->sNPC_ID < 5000 ) |
0 | 3116 continue; |
3117 } | |
3118 else | |
3119 { | |
3120 if ( v4 != 1 ) | |
3121 { | |
602 | 3122 if ( v4 != 0 || pActor->sNPC_ID ) |
0 | 3123 continue; |
3124 goto LABEL_12; | |
3125 } | |
3126 } | |
602 | 3127 if ( pActor->sNPC_ID > 0 && pActor->sNPC_ID < 5000 ) |
0 | 3128 continue; |
3129 if ( v17 ) | |
3130 { | |
291 | 3131 pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], v3, 0, v19); |
3132 v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000; | |
3133 ++pNPCStats->uNewlNPCBufPos; | |
602 | 3134 pActor->sNPC_ID = v14; |
0 | 3135 continue; |
3136 } | |
3137 LABEL_12: | |
602 | 3138 pActor->sNPC_ID = 0; |
0 | 3139 //LABEL_13: |
3140 //++v15; | |
3141 //v2 += 836; | |
3142 //} | |
3143 //while ( v15 < (signed int)uNumActors ); | |
3144 } | |
3145 | |
3146 pGameLoadingUI_ProgressBar->Progress(); | |
3147 | |
3148 //v5 = uNumActors; | |
3149 v6 = 0; | |
3150 v20 = 0; | |
3151 //v16 = v1; | |
3152 | |
3153 for (uint i = 0; i < uNumActors; ++i) | |
3154 { | |
1202 | 3155 auto pActor = &pActors[i]; |
0 | 3156 //v7 = (char *)&pActors[0].pMonsterInfo; |
3157 //do | |
3158 //{ | |
3159 v8 = 0; | |
3160 if ( v6 > 0 ) | |
3161 { | |
3162 do | |
3163 { | |
3164 if ( v21[v8] == pActor->pMonsterInfo.uID - 1 ) | |
3165 break; | |
3166 ++v8; | |
3167 } | |
3168 while ( v8 < v6 ); | |
3169 } | |
3170 | |
3171 if ( v8 == v6 ) | |
3172 { | |
3173 v21[v6++] = pActor->pMonsterInfo.uID - 1; | |
3174 v20 = v6; | |
3175 if ( v6 == 16 ) | |
3176 break; | |
3177 } | |
3178 //++v16; | |
3179 //v7 += 836; | |
3180 //} | |
3181 //while ( v16 < (signed int)v5 ); | |
3182 } | |
3183 | |
3184 pGameLoadingUI_ProgressBar->Progress(); | |
3185 | |
3186 if ( v6 > 0 ) | |
3187 { | |
3188 int _v0 = 0; | |
3189 do | |
3190 { | |
3191 v9 = v21[_v0]; | |
3192 v18 = 4; | |
3193 v10 = &pMonsterStats->pInfos[v9 + 1]; | |
3194 //v11 = (int *)pMonsterList->pMonsters[v9].pSoundSampleIDs; | |
3195 auto v11 = &pMonsterList->pMonsters[v9]; | |
3196 do | |
3197 { | |
3198 pSoundList->LoadSound(v11->pSoundSampleIDs[4 - v18], 0); | |
3199 //v11 = (int *)((char *)v11 + 2); | |
3200 --v18; | |
3201 } | |
3202 while ( v18 ); | |
3203 v12 = 0; | |
3204 do | |
3205 v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[v10->uSpell1ID], 1); | |
3206 while ( v13 ); | |
3207 ++_v0; | |
3208 } | |
3209 while ( _v0 < v6 ); | |
3210 //v0 = pGameLoadingUI_ProgressBar; | |
3211 //v1 = 0; | |
3212 } | |
3213 | |
3214 pGameLoadingUI_ProgressBar->Progress(); | |
3215 | |
3216 if ( dword_6BE368_debug_settings_2 & 4 ) | |
3217 uNumActors = 0; | |
3218 if ( dword_6BE368_debug_settings_2 & 8 ) | |
3219 uNumLevelDecorations = 0; | |
3220 sub_4613C4(); | |
3221 | |
3222 pGameLoadingUI_ProgressBar->Progress(); | |
3223 | |
3224 pIndoorCamera->pos.y = 0; | |
3225 pIndoorCamera->pos.x = 0; | |
3226 pIndoorCamera->pos.z = 100; | |
3227 pIndoorCamera->sRotationY = 0; | |
3228 pIndoorCamera->sRotationX = 0; | |
3229 viewparams->bRedrawGameUI = 1; | |
783 | 3230 uLevel_StartingPointType = MapStartPoint_Party; |
0 | 3231 pSprites_LOD->_461397(); |
3232 pPaletteManager->LockTestAll(); | |
3233 if ( pParty->pPickedItem.uItemID != 0 ) | |
3234 pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID); | |
3235 } | |
3236 | |
3237 //----- (004613C4) -------------------------------------------------------- | |
3238 int __cdecl sub_4613C4() | |
3239 { | |
3240 unsigned __int16 v0; // ax@1 | |
3241 size_t v1; // ecx@1 | |
3242 int v2; // esi@1 | |
3243 int result; // eax@1 | |
3244 LevelDecoration *v4; // edx@2 | |
3245 int v5; // edi@4 | |
3246 | |
3247 _6836C8_num_decorations_6807E8 = 0; | |
3248 v0 = pDecorationList->GetDecorIdByName("Event Trigger"); | |
3249 v1 = uNumLevelDecorations; | |
3250 v2 = (signed __int16)v0; | |
3251 result = 0; | |
3252 if ( (signed int)uNumLevelDecorations > 0 ) | |
3253 { | |
1202 | 3254 v4 = pLevelDecorations.data(); |
0 | 3255 do |
3256 { | |
3257 if ( v4->uDecorationDescID == v2 ) | |
3258 { | |
3259 v5 = _6836C8_num_decorations_6807E8++; | |
3260 _6807E8_level_decorations_ids[v5] = result; | |
3261 } | |
3262 ++result; | |
3263 ++v4; | |
3264 } | |
3265 while ( result < (signed int)v1 ); | |
3266 } | |
3267 return result; | |
3268 } | |
3269 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; | |
3270 | |
3271 //----- (004621DA) -------------------------------------------------------- | |
1408 | 3272 int int_get_vector_length(signed int x, signed int y, signed int z) |
0 | 3273 { |
3274 signed int v3; // eax@2 | |
1408 | 3275 |
3276 if ( x < y ) | |
3277 { | |
3278 v3 = x; | |
3279 x = y; | |
3280 y = v3; | |
3281 } | |
3282 if ( x < z ) | |
3283 { | |
3284 v3 = x; | |
3285 x = z; | |
3286 z = v3; | |
3287 } | |
3288 if ( y < z ) | |
3289 { | |
3290 v3 = y; | |
3291 y = z; | |
3292 z = v3; | |
3293 } | |
3294 return (11 * y >> 5) + x + (z >> 2); | |
0 | 3295 } |
3296 | |
3297 OPENFILENAMEA ofn; | |
3298 //----- (0046271C) -------------------------------------------------------- | |
3299 void __cdecl crt_init_globals_46271C() | |
3300 { | |
3301 ofn.lStructSize = 0x4Cu; | |
3302 ofn.hwndOwner = hWnd; | |
3303 ofn.hInstance = 0; | |
3304 ofn.lpstrFilter = "Indoor BLV Files (*.blv)"; | |
3305 ofn.lpstrCustomFilter = 0; | |
3306 ofn.nMaxCustFilter = 0; | |
3307 ofn.nFilterIndex = 0; | |
3308 ofn.lpstrFile = 0; | |
3309 ofn.nMaxFile = 260; | |
3310 ofn.nMaxFileTitle = 512; | |
3311 ofn.lpstrInitialDir = "levels"; | |
3312 ofn.lpstrTitle = "Might and Magic® VII - Load Which Level?"; | |
3313 ofn.Flags = 4; | |
3314 ofn.nFileOffset = 0; | |
3315 ofn.nFileExtension = 0; | |
3316 ofn.lpstrDefExt = "blv"; | |
3317 ofn.lCustData = 0; | |
3318 ofn.lpfnHook = 0; | |
3319 ofn.lpTemplateName = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
3320 ofn.lpstrFileTitle = pTmpBuf.data(); |
0 | 3321 } |
3322 | |
3323 //----- (004627B7) -------------------------------------------------------- | |
762 | 3324 void MainMenu_Loop() |
0 | 3325 { |
3326 GUIButton *pButton; // eax@27 | |
3327 unsigned int pControlParam; // ecx@35 | |
3328 int v10; // ecx@36 | |
3329 int v11; // ecx@37 | |
3330 unsigned int pY; // [sp-18h] [bp-54h]@39 | |
3331 Texture *pTexture; // [sp-14h] [bp-50h]@39 | |
3332 GUIButton *pButton2; // [sp+0h] [bp-3Ch]@27 | |
3333 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 | |
3334 | |
151 | 3335 pCurrentScreen = SCREEN_GAME; |
1038 | 3336 |
0 | 3337 pGUIWindow2 = 0; |
3338 pAudioPlayer->StopChannels(-1, -1); | |
3339 pMouse->RemoveHoldingItem(); | |
762 | 3340 |
3341 pIcons_LOD->_inlined_sub2(); | |
3342 | |
165 | 3343 pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); |
3344 auto pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); | |
0 | 3345 auto pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); |
3346 auto pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); | |
3347 auto pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); | |
948 | 3348 |
3349 pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); | |
3350 pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); | |
3351 pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); | |
3352 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); | |
3353 | |
0 | 3354 pTexture_PCX.Release(); |
3355 pTexture_PCX.Load("title.pcx", 0); | |
3356 SetCurrentMenuID(MENU_MAIN); | |
3357 SetForegroundWindow(hWnd); | |
3358 SendMessageW(hWnd, WM_ACTIVATEAPP, 1, 0); | |
3359 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) | |
3360 { | |
3361 POINT pt; | |
3362 pMouse->GetCursorPos(&pt); | |
3363 pWindow = pWindow_MainMenu; | |
165 | 3364 if ( GetCurrentMenuID() == MENU_SAVELOAD) |
0 | 3365 { |
151 | 3366 if ( pCurrentScreen != SCREEN_LOADGAME ) |
0 | 3367 { |
3368 pTexture_PCX.Release(); | |
3369 pTexture_PCX.Load("lsave640.pcx", 0); | |
3370 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); | |
151 | 3371 pCurrentScreen = SCREEN_LOADGAME; |
1033 | 3372 LoadUI_Load(0); |
0 | 3373 } |
3374 pWindow = pGUIWindow_CurrentMenu; | |
3375 } | |
3376 | |
3377 MSG msg; | |
165 | 3378 while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) ) |
0 | 3379 { |
3380 if (msg.message == WM_QUIT) | |
3381 Game_DeinitializeAndTerminate(0); | |
3382 TranslateMessage(&msg); | |
3383 DispatchMessageA(&msg); | |
3384 } | |
3385 if (dword_6BE364_game_settings_1 & 0x0100) | |
3386 { | |
3387 WaitMessage(); | |
3388 } | |
3389 else | |
3390 { | |
3391 pRenderer->BeginScene(); | |
3392 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); | |
1038 | 3393 |
165 | 3394 GUI_MainMenuMessageProc(); |
0 | 3395 GUI_UpdateWindows(); |
1038 | 3396 |
165 | 3397 if (GetCurrentMenuID() != MENU_MAIN) |
3398 { | |
961 | 3399 if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) |
0 | 3400 { |
1405
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
3401 pIcons_LOD->RemoveTexturesPackFromTextureList(); |
0 | 3402 pGUIWindow_CurrentMenu->Release(); |
3403 pGUIWindow_CurrentMenu = 0; | |
151 | 3404 pCurrentScreen = SCREEN_GAME; |
0 | 3405 viewparams->bRedrawGameUI = 1; |
3406 } | |
3407 } | |
3408 else | |
3409 { | |
3410 if ( !ptr_507BDC )// ??? | |
3411 { | |
3412 pButton = pWindow->pControlsHead; | |
3413 for ( pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext ) | |
3414 { | |
3415 if ( pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ | |
3416 && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW | |
3417 && pWindow == pWindow_MainMenu ) | |
3418 { | |
832 | 3419 pControlParam = pButton->msg_param; |
0 | 3420 switch (pControlParam) // ïîäñâåòêà êíîïîê |
3421 { | |
3422 case 0: | |
3423 pTexture = pNew; | |
3424 pY = 172; | |
3425 break; | |
3426 case 1: | |
3427 pTexture = pLoad; | |
3428 pY = 227; | |
3429 break; | |
3430 case 2: | |
3431 pTexture = pCredits; | |
3432 pY = 282; | |
3433 break; | |
3434 case 3: | |
3435 pTexture = pExit; | |
3436 pY = 337; | |
3437 break; | |
3438 } | |
3439 pRenderer->DrawTextureIndexed(495, pY, pTexture); //ïîäñâåòêà êíîïîê | |
3440 } | |
3441 } | |
3442 } | |
3443 } | |
3444 pRenderer->EndScene(); | |
3445 pRenderer->Present(); | |
3446 } | |
3447 } | |
970 | 3448 GUI_MainMenuMessageProc(); |
0 | 3449 pRenderer->BeginScene(); |
3450 GUI_UpdateWindows(); | |
3451 pRenderer->EndScene(); | |
3452 pRenderer->Present(); | |
961 | 3453 pTexture_PCX.Release(); |
0 | 3454 if ( pGUIWindow2 ) |
3455 { | |
3456 pGUIWindow2->Release(); | |
3457 pGUIWindow2 = 0; | |
3458 } | |
3459 pWindow_MainMenu->Release(); | |
1405
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
3460 pIcons_LOD->RemoveTexturesPackFromTextureList(); |
0 | 3461 } |
3462 | |
3463 //----- (004637EB) -------------------------------------------------------- | |
3464 int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) | |
3465 { | |
3466 HANDLE v6; // eax@32 | |
3467 HDC v10; // edi@50 | |
3468 int v11; // esi@50 | |
3469 signed int v13; // eax@135 | |
3470 char v29; // dl@209 | |
3471 bool v31; // ebx@211 | |
3472 float v33; // ST04_4@246 | |
3473 float v34; // ST04_4@254 | |
3474 struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13 | |
3475 int pXY[2]; // [sp+64h] [bp-8h]@261 | |
3476 int a2; // [sp+7Ch] [bp+10h]@50 | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1150
diff
changeset
|
3477 |
0 | 3478 switch (Msg) |
3479 { | |
3480 case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam); | |
832 | 3481 case WM_CHAR: |
3482 { | |
3483 if (!pKeyActionMap->_459F10(wParam) && !viewparams->field_4C) | |
3484 GUI_HandleHotkey(wParam); | |
3485 } | |
3486 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
922 | 3487 |
3488 case WM_COMMAND: | |
3489 { | |
3490 switch (wParam) | |
3491 { | |
947 | 3492 case 103: pRenderer->SavePCXScreenshot(); return 0; |
3493 | |
3494 case 101: // Quit game | |
922 | 3495 case 40001: |
1067 | 3496 SendMessageA(::hWnd, WM_DESTROY, 0, 0); |
922 | 3497 return 0; |
3498 | |
3499 | |
3500 case 104: | |
3501 pRenderer->ChangeBetweenWinFullscreenModes(); | |
3502 if ( pArcomageGame->bGameInProgress ) | |
3503 pArcomageGame->field_F6 = 1; | |
3504 return 0; | |
3505 | |
952 | 3506 //SubMenu "Party" |
947 | 3507 case 40007: pParty->SetGold(pParty->uNumGold + 10000); return 0; |
3508 case 40008: GivePartyExp(20000); return 0; | |
3509 case 40013: pParty->SetGold(0); return 0; | |
922 | 3510 |
3511 case 40059: | |
3512 for (uint i = 0; i < 4; ++i) | |
3513 pParty->pPlayers[i].uSkillPoints = 50; | |
3514 return 0; | |
947 | 3515 |
3516 case 40029: pPlayers[uActiveCharacter]->SetPertified(true); return 0; | |
3517 case 40030: pPlayers[uActiveCharacter]->SetWeak(true); return 0; | |
3518 case 40031: pPlayers[uActiveCharacter]->SetPoison3(true); return 0; | |
3519 case 40032: pPlayers[uActiveCharacter]->SetPoison2(true); return 0; | |
3520 case 40033: pPlayers[uActiveCharacter]->SetPoison1(true); return 0; | |
3521 case 40034: pPlayers[uActiveCharacter]->SetDisease3(true); return 0; | |
3522 case 40035: pPlayers[uActiveCharacter]->SetDisease2(true); return 0; | |
3523 case 40036: pPlayers[uActiveCharacter]->SetDisease1(true); return 0; | |
3524 case 40037: pPlayers[uActiveCharacter]->SetCursed(true); return 0; | |
3525 case 40038: pPlayers[uActiveCharacter]->SetInsane(true); return 0; | |
3526 case 40039: pPlayers[uActiveCharacter]->SetDrunk(true); return 0; | |
3527 case 40040: pPlayers[uActiveCharacter]->SetUnconcious(true); return 0; | |
3528 case 40041: pPlayers[uActiveCharacter]->SetDead(true); return 0; | |
3529 case 40042: pPlayers[uActiveCharacter]->SetEradicated(true); return 0; | |
3530 case 40043: pPlayers[uActiveCharacter]->SetAsleep(true); return 0; | |
3531 case 40044: pPlayers[uActiveCharacter]->SetAfraid(true); return 0; | |
3532 case 40045: pPlayers[uActiveCharacter]->SetParalyzed(true); return 0; | |
3533 case 40073: pPlayers[uActiveCharacter]->SetZombie(true); return 0; | |
952 | 3534 |
3535 case 40006: pParty->SetFood(pParty->uNumFoodRations + 20); return 0; | |
3536 | |
957 | 3537 case 40062: |
3538 pParty->alignment = PartyAlignment_Good; | |
3539 SetUserInterface(pParty->alignment, true); | |
3540 return 0; | |
3541 case 40063: | |
3542 pParty->alignment = PartyAlignment_Neutral; | |
3543 SetUserInterface(pParty->alignment, true); | |
3544 return 0; | |
3545 case 40064: | |
3546 pParty->alignment = PartyAlignment_Evil; | |
3547 SetUserInterface(pParty->alignment, true); | |
3548 return 0; | |
952 | 3549 |
3550 //SubMenu "Time" | |
1031 | 3551 case 40009: pParty->uTimePlayed += Timer::Day; return 0; |
3552 case 40010: pParty->uTimePlayed += Timer::Week; return 0; | |
3553 case 40011: pParty->uTimePlayed += Timer::Month; return 0; | |
3554 case 40012: pParty->uTimePlayed += Timer::Year; return 0; | |
952 | 3555 |
3556 //SubMenu "Items" | |
957 | 3557 case 40015: |
3558 { | |
3559 int pItemID = rand() % 500; | |
3560 for ( uint i = 0; i < 500; ++i ) | |
3561 { | |
3562 if ( pItemID + i > 499 ) | |
3563 pItemID = 0; | |
3564 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 1 ) | |
3565 { | |
3566 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
3567 return 0; | |
3568 } | |
3569 } | |
3570 } | |
3571 return 0; | |
3572 case 40016: | |
3573 { | |
3574 int pItemID = rand() % 500; | |
3575 for ( uint i = 0; i < 500; ++i ) | |
3576 { | |
3577 if ( pItemID + i > 499 ) | |
3578 pItemID = 0; | |
3579 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 2 ) | |
3580 { | |
3581 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
3582 return 0; | |
3583 } | |
3584 } | |
3585 } | |
3586 return 0; | |
3587 case 40017: | |
3588 { | |
3589 int pItemID = rand() % 500; | |
3590 for ( uint i = 0; i < 500; ++i ) | |
3591 { | |
3592 if ( pItemID + i > 499 ) | |
3593 pItemID = 0; | |
3594 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 3 ) | |
3595 { | |
3596 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
3597 return 0; | |
3598 } | |
3599 } | |
3600 } | |
3601 return 0; | |
3602 case 40018: | |
3603 { | |
3604 int pItemID = rand() % 500; | |
3605 for ( uint i = 0; i < 500; ++i ) | |
3606 { | |
3607 if ( pItemID + i > 499 ) | |
3608 pItemID = 0; | |
3609 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 4 ) | |
3610 { | |
3611 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
3612 return 0; | |
3613 } | |
3614 } | |
3615 } | |
3616 return 0; | |
3617 case 40019: | |
3618 { | |
3619 int pItemID = rand() % 500; | |
3620 for ( uint i = 0; i < 500; ++i ) | |
3621 { | |
3622 if ( pItemID + i > 499 ) | |
3623 pItemID = 0; | |
3624 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 5 ) | |
3625 { | |
3626 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
3627 return 0; | |
3628 } | |
3629 } | |
3630 } | |
3631 return 0; | |
3632 case 40020: | |
3633 { | |
3634 int pItemID = rand() % 500; | |
3635 for ( uint i = 0; i < 500; ++i ) | |
3636 { | |
3637 if ( pItemID + i > 499 ) | |
3638 pItemID = 0; | |
3639 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St == 6 ) | |
3640 { | |
3641 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
3642 return 0; | |
3643 } | |
3644 } | |
3645 } | |
3646 return 0; | |
3647 case 40061: | |
3648 { | |
3649 int pItemID = rand() % 500; | |
3650 for ( uint i = 0; i < 500; ++i ) | |
3651 { | |
3652 if ( pItemID + i > 499 ) | |
3653 pItemID = 0; | |
3654 if ( pItemsTable->pItems[pItemID + i].uItemID_Rep_St > 6 ) | |
3655 { | |
3656 pPlayers[uActiveCharacter]->AddItem(-1, pItemID + i); | |
3657 return 0; | |
3658 } | |
3659 } | |
3660 } | |
3661 return 0; | |
952 | 3662 |
922 | 3663 } |
3664 } | |
3665 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
0 | 3666 }; |
3667 | |
3668 if ( Msg > WM_SYSCOMMAND ) | |
3669 { | |
3670 switch ( Msg ) | |
3671 { | |
3672 case WM_DEVICECHANGE: | |
3673 if ( wParam == 0x8000 ) | |
3674 PostMessageA(hInsertCDWindow, WM_CHOOSEFONT_GETLOGFONT, 0, 0); | |
3675 return 0; | |
3676 case WM_SIZING: | |
3677 return 1; | |
3678 case WM_LBUTTONDOWN: | |
3679 if ( pArcomageGame->bGameInProgress ) | |
3680 { | |
3681 pArcomageGame->stru1.field_0 = 7; | |
920 | 3682 ArcomageGame::OnMouseClick(0, 1); |
3683 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
0 | 3684 } |
972 | 3685 goto __handle_mouse_click; |
3686 | |
0 | 3687 case WM_RBUTTONDOWN: |
3688 v31 = 0; | |
3689 if ( !pArcomageGame->bGameInProgress ) | |
920 | 3690 //goto LABEL_240; |
3691 { | |
3692 if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 ) | |
3693 pVideoPlayer->bStopBeforeSchedule = 1; | |
1038 | 3694 |
3695 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); | |
920 | 3696 if (pGame) |
3697 { | |
3698 v33 = pGame->pIndoorCameraD3D->GetPickDepth(); | |
3699 pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter); | |
3700 } | |
1038 | 3701 |
920 | 3702 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); |
3703 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
1038 | 3704 |
3705 } | |
3706 | |
0 | 3707 pArcomageGame->stru1.field_0 = 8; |
920 | 3708 ArcomageGame::OnMouseClick(1, 1); |
3709 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
0 | 3710 case WM_LBUTTONUP: |
3711 if ( !pArcomageGame->bGameInProgress ) | |
920 | 3712 //goto LABEL_218; |
3713 { | |
0 | 3714 back_to_game(); |
832 | 3715 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3716 } |
920 | 3717 pArcomageGame->stru1.field_0 = 3; |
3718 ArcomageGame::OnMouseClick(0, 0); | |
3719 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
3720 case WM_RBUTTONUP: | |
3721 if ( !pArcomageGame->bGameInProgress ) | |
3722 { | |
3723 //LABEL_218: | |
1038 | 3724 |
920 | 3725 back_to_game(); |
3726 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
3727 } | |
0 | 3728 pArcomageGame->stru1.field_0 = 4; |
1250
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3729 ArcomageGame::OnMouseClick(1, false); |
920 | 3730 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
972 | 3731 |
0 | 3732 case WM_LBUTTONDBLCLK: |
3733 if ( pArcomageGame->bGameInProgress ) | |
3734 { | |
3735 pArcomageGame->stru1.field_0 = 7; | |
832 | 3736 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3737 } |
972 | 3738 |
3739 __handle_mouse_click: | |
0 | 3740 if ( pVideoPlayer->pVideoFrame.pPixels ) |
3741 pVideoPlayer->bStopBeforeSchedule = 1; | |
972 | 3742 |
0 | 3743 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); |
972 | 3744 |
3745 if (GetCurrentMenuID() != MENU_CREATEPARTY) | |
3746 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); | |
3747 else | |
3748 { | |
3749 UI_OnKeyDown(VK_SELECT); | |
3750 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); | |
3751 } | |
3752 | |
1038 | 3753 |
972 | 3754 if (pGame) |
3755 pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, false, &vis_sprite_filter_3, &vis_door_filter); | |
3756 | |
0 | 3757 UI_OnMouseLeftClick(0); |
1038 | 3758 |
920 | 3759 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
972 | 3760 |
0 | 3761 case WM_RBUTTONDBLCLK: |
3762 v31 = 0; | |
3763 if ( !pArcomageGame->bGameInProgress ) | |
3764 { | |
920 | 3765 //LABEL_240: |
0 | 3766 if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 ) |
3767 pVideoPlayer->bStopBeforeSchedule = 1; | |
1038 | 3768 |
0 | 3769 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); |
3770 if (pGame) | |
3771 { | |
871 | 3772 v33 = pGame->pIndoorCameraD3D->GetPickDepth(); |
194 | 3773 pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter); |
0 | 3774 } |
1038 | 3775 |
0 | 3776 sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); |
832 | 3777 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
1038 | 3778 |
3779 } | |
0 | 3780 pArcomageGame->stru1.field_0 = 8; |
832 | 3781 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3782 case WM_MBUTTONDOWN: |
3783 if ( pRenderer->pRenderD3D ) | |
3784 { | |
1038 | 3785 if ( pGame ) |
0 | 3786 { |
871 | 3787 v34 = pGame->pIndoorCameraD3D->GetPickDepth(); |
194 | 3788 pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &vis_sprite_filter_3, &vis_face_filter); |
832 | 3789 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3790 } |
3791 } | |
3792 if ( !pGame ) | |
920 | 3793 //goto _def_wnd_proc; |
3794 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
0 | 3795 sub_417871(0); |
832 | 3796 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3797 case WM_MOUSEMOVE: |
3798 if ( pArcomageGame->bGameInProgress ) | |
3799 { | |
3800 pXY[0] = (unsigned __int16)lParam; | |
3801 pXY[1] = lParam >> 16; | |
3802 ArcomageGame::OnMouseMove((POINT *)pXY); | |
3803 ArcomageGame::OnMouseClick(0, wParam & 1); | |
3804 v29 = (wParam >> 1) & 1; | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1104
diff
changeset
|
3805 ArcomageGame::OnMouseClick(1, v29 != 0); |
0 | 3806 } |
3807 else | |
3808 { | |
3809 pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); | |
3810 } | |
832 | 3811 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
920 | 3812 default: |
3813 //goto _def_wnd_proc; | |
3814 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
0 | 3815 } |
3816 } | |
3817 if ( Msg == WM_SYSCOMMAND ) | |
3818 { | |
3819 if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER ) | |
3820 return 0; | |
920 | 3821 //goto _def_wnd_proc; |
3822 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
0 | 3823 } |
3824 if ( Msg > WM_ACTIVATEAPP ) | |
3825 { | |
3826 if ( Msg == WM_WINDOWPOSCHANGED ) | |
3827 { | |
1250
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3828 if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer) |
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3829 { |
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3830 BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0); |
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3831 } |
920 | 3832 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3833 } |
3834 if ( Msg != WM_KEYFIRST ) | |
3835 { | |
1250
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3836 if ( Msg == WM_KEYUP && wParam == VK_CONTROL ) |
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3837 { |
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3838 dword_507B98_ctrl_pressed = 0; |
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3839 } |
c515e406df4a
aWinProc cleanup - removing unused vars, unnesting conditions, removeing a few DefWindowProcA calls
Grumpy7
parents:
1249
diff
changeset
|
3840 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3841 } |
1031 | 3842 if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 ) |
0 | 3843 { |
3844 pKeyActionMap->_459F10(wParam); | |
832 | 3845 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 3846 } |
3847 if ( !pArcomageGame->bGameInProgress ) | |
3848 { | |
3849 if ( pVideoPlayer->pVideoFrame.pPixels ) | |
3850 pVideoPlayer->bStopBeforeSchedule = 1; | |
1067 | 3851 if ( wParam == VK_RETURN ) |
3852 { | |
3853 if ( !viewparams->field_4C ) | |
3854 UI_OnKeyDown(wParam); | |
3855 return 0; | |
3856 } | |
3857 if ( wParam == VK_CONTROL ) | |
3858 { | |
3859 dword_507B98_ctrl_pressed = 1; | |
3860 return 0; | |
3861 } | |
3862 if ( wParam == VK_ESCAPE ) | |
3863 { | |
3864 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0); | |
3865 return 0; | |
3866 } | |
3867 if ( wParam <= VK_HOME ) | |
3868 return 0; | |
3869 if ( wParam > VK_DOWN ) | |
3870 { | |
3871 if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() ) | |
0 | 3872 return 0; |
1067 | 3873 SendMessageA(hWnd, WM_COMMAND, 104, 0); |
3874 return 0; | |
3875 } | |
3876 if ( wParam >= VK_LEFT && wParam <= VK_DOWN ) | |
3877 { | |
3878 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_PRESS_ESCAPE_MESSAGE ) | |
3879 { | |
3880 if ( !viewparams->field_4C ) | |
3881 UI_OnKeyDown(wParam); | |
441 | 3882 return 0; |
0 | 3883 } |
1067 | 3884 } |
3885 if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_PRESS_ESCAPE_MESSAGE ) | |
3886 return 0; | |
0 | 3887 } |
1248
d3bf0d4fb753
aWinProc cleanup - fixing bad condition, exctracting common code from conditions, part 1
Grumpy7
parents:
1215
diff
changeset
|
3888 |
0 | 3889 pArcomageGame->stru1.field_0 = 1; |
1249
bbde4964e9b7
aWinProc cleanup - extracting conditions to a separate function
Grumpy7
parents:
1248
diff
changeset
|
3890 |
bbde4964e9b7
aWinProc cleanup - extracting conditions to a separate function
Grumpy7
parents:
1248
diff
changeset
|
3891 v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u); |
bbde4964e9b7
aWinProc cleanup - extracting conditions to a separate function
Grumpy7
parents:
1248
diff
changeset
|
3892 set_stru1_field_8_InArcomage(v13); |
920 | 3893 if ( wParam == 27 ) |
3894 { | |
1197 | 3895 pArcomageGame->GameOver = 1; |
920 | 3896 pArcomageGame->field_F4 = 1; |
3897 pArcomageGame->uGameResult = 2; | |
3898 pArcomageGame->field_B0 = -2; | |
3899 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
3900 } | |
3901 if ( wParam != 114 ) | |
3902 { | |
3903 if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() ) | |
1249
bbde4964e9b7
aWinProc cleanup - extracting conditions to a separate function
Grumpy7
parents:
1248
diff
changeset
|
3904 SendMessageA(hWnd, 0x111u, 0x68u, 0); |
920 | 3905 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
3906 } | |
1067 | 3907 SendMessageA(hWnd, WM_COMMAND, 103, 0); |
920 | 3908 return 0; |
0 | 3909 } |
3910 if ( Msg == WM_ACTIVATEAPP ) | |
3911 { | |
3912 if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) ) | |
3913 { | |
3914 if ( BYTE1(dword_6BE364_game_settings_1) & 1 ) | |
3915 { | |
3916 dword_4E98BC_bApplicationActive = 1; | |
3917 if ( pRenderer->bWindowMode ) | |
3918 { | |
3919 v10 = GetDC(0); | |
3920 a2 = GetDeviceCaps(v10, BITSPIXEL); | |
3921 v11 = GetDeviceCaps(v10, PLANES); | |
3922 ReleaseDC(0, v10); | |
3923 if ( a2 != 16 || v11 != 1 ) | |
3924 Abortf(pGlobalTXT_LocalizationStrings[62]); | |
3925 } | |
3926 BYTE1(dword_6BE364_game_settings_1) &= 0xFEu; | |
1038 | 3927 |
0 | 3928 if ( pArcomageGame->bGameInProgress ) |
3929 { | |
3930 pArcomageGame->field_F9 = 1; | |
3931 } | |
3932 else | |
3933 { | |
3934 if ( BYTE1(dword_6BE364_game_settings_1) & 2 ) | |
3935 BYTE1(dword_6BE364_game_settings_1) &= 0xFDu; | |
3936 else | |
3937 pEventTimer->Resume(); | |
3938 if ( BYTE1(dword_6BE364_game_settings_1) & 4 ) | |
3939 BYTE1(dword_6BE364_game_settings_1) &= 0xFBu; | |
3940 else | |
3941 pMiscTimer->Resume(); | |
1038 | 3942 |
3943 viewparams->bRedrawGameUI = true; | |
0 | 3944 if ( pVideoPlayer->pSmackerMovie ) |
3945 { | |
3946 pRenderer->RestoreFrontBuffer(); | |
3947 pRenderer->_4A184C(); | |
3948 pVideoPlayer->_4BF5B2(); | |
3949 } | |
3950 } | |
3951 if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie ) | |
3952 AIL_redbook_resume(pAudioPlayer->hAILRedbook); | |
3953 } | |
3954 } | |
3955 else | |
3956 { | |
3957 if ( !(dword_6BE364_game_settings_1 & 0x100) ) | |
3958 { | |
920 | 3959 while(initing); //ADDED spinlock to allow int players ets! Gloval |
3960 dword_4E98BC_bApplicationActive = 0; | |
0 | 3961 if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie ) |
3962 pVideoPlayer->bStopBeforeSchedule = 1; | |
1038 | 3963 |
0 | 3964 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) |
3965 SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); | |
3966 ClipCursor(0); | |
3967 dword_6BE364_game_settings_1 |= 0x100u; | |
3968 if ( pEventTimer->bPaused ) | |
3969 BYTE1(dword_6BE364_game_settings_1) |= 2u; | |
3970 else | |
3971 pEventTimer->Pause(); | |
3972 if ( pMiscTimer->bPaused ) | |
3973 BYTE1(dword_6BE364_game_settings_1) |= 4u; | |
3974 else | |
3975 pMiscTimer->Pause(); | |
1038 | 3976 |
0 | 3977 pAudioPlayer->StopChannels(-1, -1); |
3978 if ( pAudioPlayer->hAILRedbook ) | |
3979 AIL_redbook_pause(pAudioPlayer->hAILRedbook); | |
3980 } | |
3981 } | |
3982 return 0; | |
3983 } | |
3984 if (Msg == WM_CREATE) | |
3985 { | |
3986 auto hDC = GetDC(hWnd); | |
3987 { | |
3988 if (GetDeviceCaps(hDC, BITSPIXEL) < 8) | |
3989 { | |
3990 ReleaseDC(hWnd, hDC); | |
3991 Log::Warning(L"You must be running in 256 color mode or higher."); | |
3992 Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon."); | |
3993 } | |
3994 } | |
3995 ReleaseDC(hWnd, hDC); | |
3996 return 0; | |
3997 } | |
3998 if ( Msg == WM_DESTROY ) | |
3999 { | |
4000 v6 = GetCurrentProcess(); | |
4001 SetPriorityClass(v6, 0x20u); | |
4002 if ( pGame ) | |
4003 { | |
1038 | 4004 |
4005 } | |
4006 | |
0 | 4007 PostQuitMessage(0); |
4008 return 0; | |
4009 } | |
4010 if ( Msg == WM_SETFOCUS ) | |
4011 { | |
4012 if ( ::hWnd == (HWND)wParam ) | |
4013 { | |
4014 dword_4E98BC_bApplicationActive = 0; | |
4015 if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) | |
4016 SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); | |
4017 ClipCursor(0); | |
1038 | 4018 |
0 | 4019 } |
920 | 4020 //_def_wnd_proc: |
832 | 4021 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
0 | 4022 } |
4023 if ( Msg != WM_KILLFOCUS ) | |
4024 { | |
4025 if ( Msg == WM_PAINT ) | |
4026 { | |
4027 if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode ) | |
4028 return 0; | |
4029 BeginPaint(hWnd, &Paint); | |
4030 if ( pArcomageGame->bGameInProgress ) | |
4031 { | |
4032 pArcomageGame->field_F9 = 1; | |
4033 } | |
4034 else | |
4035 { | |
4036 if ( !pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() || !AreRenderSurfacesOk() ) | |
920 | 4037 //goto LABEL_20; |
4038 { | |
4039 EndPaint(hWnd, &Paint); | |
4040 return 0; | |
4041 } | |
0 | 4042 } |
4043 pRenderer->Present(); | |
920 | 4044 //LABEL_20: |
0 | 4045 EndPaint(hWnd, &Paint); |
4046 return 0; | |
4047 } | |
920 | 4048 //goto _def_wnd_proc; |
4049 return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
0 | 4050 } |
1038 | 4051 if ( ::hWnd != (HWND)wParam || (dword_4E98BC_bApplicationActive = 1, pRenderer->bWindowMode) || true ) |
832 | 4052 return DefWindowProcA(hWnd, Msg, wParam, lParam); |
1038 | 4053 |
0 | 4054 } |
4055 | |
4056 //----- (00464479) -------------------------------------------------------- | |
4057 void __cdecl ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() | |
4058 { | |
4059 int v0; // esi@9 | |
4060 | |
4061 if (pMouse) | |
4062 pMouse->SetCursorBitmap("MICON1"); | |
4063 | |
4064 pPaletteManager->ResetNonLocked(); | |
4065 pBitmaps_LOD->ReleaseAll2(); | |
4066 pSprites_LOD->DeleteSomeOtherSprites(); | |
4067 pIcons_LOD->ReleaseAll2(); | |
4068 if (pRenderer->pRenderD3D) | |
4069 { | |
4070 pRenderer->field_1036B8 = 0; | |
4071 pRenderer->_gpu_memory_used = 0; | |
4072 } | |
4073 sub_46080D(); | |
4074 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
4075 pIndoor->Release(); | |
4076 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
4077 pOutdoor->Release2(); | |
4078 | |
4079 pAudioPlayer->StopChannels(-1, -1); | |
4080 pSoundList->_4A9D79(0); | |
4081 uCurrentlyLoadedLevelType = LEVEL_null; | |
4082 pSpriteFrameTable->ResetSomeSpriteFlags(); | |
4083 v0 = uNumVisibleWindows; | |
349 | 4084 pParty->armageddon_timer = 0; |
0 | 4085 while ( v0 > 0 ) |
4086 pWindowList[pVisibleWindowsIdxs[v0--] - 1].Release(); | |
4087 } | |
4088 | |
4089 //----- (004646F0) -------------------------------------------------------- | |
4090 void PrepareWorld(unsigned int this_) | |
4091 { | |
4092 unsigned int v1; // ebx@1 | |
4093 | |
4094 v1 = this_; | |
4095 if ( pRenderer->pRenderD3D ) | |
4096 pGame->pVisInstance->_4C1A02(); | |
4097 pEventTimer->Pause(); | |
4098 pMiscTimer->Pause(); | |
4099 pParty->uFlags = 2; | |
1202 | 4100 pCastSpellInfo.data()->_427D48(1); |
0 | 4101 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); |
4102 DoPrepareWorld(0, (v1 == 0) + 1); | |
4103 pMiscTimer->Resume(); | |
4104 pEventTimer->Resume(); | |
4105 } | |
4106 | |
4107 //----- (00464761) -------------------------------------------------------- | |
4108 void __thiscall Game_DeinitializeAndTerminate(int exitCode) | |
4109 { | |
4110 int v1; // esi@1 | |
4111 HANDLE v2; // eax@1 | |
4112 | |
4113 v1 = exitCode; | |
4114 v2 = GetCurrentProcess(); | |
4115 SetPriorityClass(v2, 0x20u); | |
4116 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
4117 pGame->Deinitialize(); | |
4118 pRenderer->Release2(); | |
4119 if ( !DestroyWindow(hWnd) ) | |
4120 GetLastError(); | |
4121 hWnd = 0; | |
4122 exit(v1); | |
4123 } | |
4124 | |
4125 //----- (004647AB) -------------------------------------------------------- | |
762 | 4126 void FinalInitialization() |
0 | 4127 { |
4128 pViewport->SetScreen(viewparams->uSomeX, viewparams->uSomeY, viewparams->uSomeZ, viewparams->uSomeW); | |
4129 pViewport->_4C02F8((signed __int64)(flt_6BE3A0 * 65536.0)); | |
4130 | |
4131 pIndoorCamera = new IndoorCamera; | |
762 | 4132 pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1, |
4133 viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1); | |
0 | 4134 |
4135 InitializeTurnBasedAnimations(&stru_50C198); | |
762 | 4136 pBitmaps_LOD->_inlined_sub1(); |
4137 pSprites_LOD->_inlined_sub1(); | |
4138 pIcons_LOD->_inlined_sub1(); | |
0 | 4139 } |
4140 // 6BE3A0: using guessed type float flt_6BE3A0; | |
4141 | |
4142 //----- (00464839) -------------------------------------------------------- | |
4143 char __cdecl Is_out15odm_underwater() | |
4144 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
4145 return _stricmp(pCurrentMapName.data(), "out15.odm") == 0; |
0 | 4146 } |
4147 | |
4148 //----- (00464851) -------------------------------------------------------- | |
4149 void __cdecl SetUnderwaterFog() | |
4150 { | |
4151 day_fogrange_1 = 50; | |
4152 day_fogrange_2 = 5000; | |
4153 } | |
4154 | |
4155 //----- (00464866) -------------------------------------------------------- | |
4156 void __fastcall DoPrepareWorld(unsigned int bLoading, int a2) | |
4157 { | |
4158 int v2; // esi@1 | |
4159 char *v3; // eax@1 | |
4160 //char *v4; // eax@1 | |
4161 unsigned int v5; // eax@3 | |
4162 //size_t v6; // ecx@10 | |
4163 //char *v7; // eax@11 | |
4164 char Str1[20]; // [sp+Ch] [bp-18h]@1 | |
4165 unsigned int v9; // [sp+20h] [bp-4h]@1 | |
4166 | |
4167 v2 = a2; | |
4168 v9 = bLoading; | |
4169 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
4170 pDecalBuilder->Reset(0); | |
434 | 4171 pGameLoadingUI_ProgressBar->Initialize((GUIProgressBar::Type)v2); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
4172 strcpy(Str1, pCurrentMapName.data()); |
0 | 4173 v3 = strtok(Str1, "."); |
4174 strcpy(Str1, v3); | |
4175 Level_LoadEvtAndStr(Str1); | |
4176 LoadLevel_InitializeLevelEvt(); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
4177 strcpy(Str1, pCurrentMapName.data()); |
0 | 4178 _strrev(Str1); |
4179 strtok(Str1, "."); | |
4180 _strrev(Str1); | |
4181 | |
4182 for (uint i = 0; i < 1000; ++i) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
4183 pSpriteObjects[i].uObjectDescID = 0; |
0 | 4184 |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
4185 v5 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 4186 bUnderwater = 0; |
4187 uLevelMapStatsID = v5; | |
4188 pGame->uFlags2 &= 0xFFFFFFF7u; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
4189 if ( !_stricmp(pCurrentMapName.data(), "out15.odm") ) |
0 | 4190 { |
4191 bUnderwater = 1; | |
4192 pGame->uFlags2 |= 8u; | |
4193 } | |
831 | 4194 pParty->floor_face_pid = 0; |
1104 | 4195 if ( _stricmp(Str1, "blv") ) |
0 | 4196 PrepareToLoadODM(v9, 0); |
4197 else | |
4198 PrepareToLoadBLV(v9); | |
4199 pAudioPlayer->SetMapEAX(); | |
4200 sub_461103(); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
4201 if ( !_stricmp(pCurrentMapName.data(), "d11.blv") || !_stricmp(pCurrentMapName.data(), "d10.blv") ) |
0 | 4202 { |
4203 //spawning grounds & good analogue - no loot & exp from monsters | |
4204 | |
4205 for (uint i = 0; i < uNumActors; ++i) | |
4206 { | |
4207 pActors[i].pMonsterInfo.uTreasureType = 0; | |
4208 pActors[i].pMonsterInfo.uTreasureDiceRolls = 0; | |
4209 pActors[i].pMonsterInfo.uExp = 0; | |
4210 } | |
4211 } | |
4212 bDialogueUI_InitializeActor_NPC_ID = 0; | |
4213 OnMapLoad(); | |
4214 pGameLoadingUI_ProgressBar->Progress(); | |
49 | 4215 memset(&pRenderer->pBillboardRenderListD3D, 0, sizeof(pRenderer->pBillboardRenderListD3D)); |
0 | 4216 pGameLoadingUI_ProgressBar->Release(); |
4217 _flushall(); | |
4218 } | |
4219 | |
4220 //----- (004649EF) -------------------------------------------------------- | |
4221 int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue) | |
4222 { | |
4223 int v3; // [sp+4h] [bp-24h]@1 | |
4224 DWORD cbData; // [sp+8h] [bp-20h]@1 | |
4225 LPCSTR lpValueName; // [sp+Ch] [bp-1Ch]@1 | |
4226 DWORD dwDisposition; // [sp+10h] [bp-18h]@2 | |
4227 BYTE Data[4]; // [sp+14h] [bp-14h]@5 | |
4228 HKEY hKey; // [sp+18h] [bp-10h]@1 | |
4229 HKEY phkResult; // [sp+1Ch] [bp-Ch]@1 | |
4230 HKEY v10; // [sp+20h] [bp-8h]@1 | |
4231 HKEY v11; // [sp+24h] [bp-4h]@1 | |
4232 | |
4233 v3 = uDefValue; | |
4234 lpValueName = pKey; | |
4235 v11 = 0; | |
4236 v10 = 0; | |
4237 hKey = 0; | |
4238 phkResult = 0; | |
4239 cbData = 4; | |
27 | 4240 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )// for 64 bit |
0 | 4241 { |
4242 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) ) | |
4243 { | |
4244 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v10, &dwDisposition) ) | |
4245 { | |
4246 if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, 0xF003Fu, 0, &v11, &dwDisposition) ) | |
4247 { | |
4248 if ( RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) ) | |
4249 { | |
4250 *(int *)Data = v3; | |
4251 RegSetValueExA(v11, lpValueName, 0, 4u, Data, 4u); | |
4252 } | |
4253 RegCloseKey(v11); | |
4254 } | |
4255 RegCloseKey(v10); | |
4256 } | |
4257 RegCloseKey(phkResult); | |
4258 } | |
4259 RegCloseKey(hKey); | |
4260 } | |
4261 return *(int *)Data; | |
4262 } | |
4263 | |
4264 //----- (00464B02) -------------------------------------------------------- | |
4265 void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString) | |
4266 { | |
4267 size_t v2; // eax@5 | |
4268 const char *lpValueName; // [sp+4h] [bp-1Ch]@1 | |
4269 const char *Str; // [sp+8h] [bp-18h]@1 | |
4270 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 | |
4271 HKEY hKey; // [sp+10h] [bp-10h]@1 | |
4272 HKEY phkResult; // [sp+14h] [bp-Ch]@1 | |
4273 HKEY v8; // [sp+18h] [bp-8h]@1 | |
4274 HKEY v9; // [sp+1Ch] [bp-4h]@1 | |
4275 | |
4276 Str = pString; | |
4277 lpValueName = pKey; | |
4278 v9 = 0; | |
4279 v8 = 0; | |
4280 hKey = 0; | |
4281 phkResult = 0; | |
4282 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) ) | |
4283 { | |
4284 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) ) | |
4285 { | |
4286 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) ) | |
4287 { | |
4288 if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, 0xF003Fu, 0, &v9, &dwDisposition) ) | |
4289 { | |
4290 v2 = strlen(Str); | |
4291 RegSetValueExA(v9, lpValueName, 0, 1u, (const BYTE *)Str, v2 + 1); | |
4292 RegCloseKey(v9); | |
4293 } | |
4294 RegCloseKey(v8); | |
4295 } | |
4296 RegCloseKey(phkResult); | |
4297 } | |
4298 RegCloseKey(hKey); | |
4299 } | |
4300 } | |
4301 | |
4302 //----- (00464BEF) -------------------------------------------------------- | |
4303 void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue) | |
4304 { | |
4305 LSTATUS (__stdcall *v4)(HKEY); // esi@1 | |
4306 LSTATUS result; // eax@7 | |
4307 DWORD Type; // [sp+Ch] [bp-24h]@5 | |
4308 LPCSTR lpValueName; // [sp+10h] [bp-20h]@1 | |
4309 DWORD cbData; // [sp+14h] [bp-1Ch]@1 | |
4310 LPBYTE Dest; // [sp+18h] [bp-18h]@1 | |
4311 DWORD dwDisposition; // [sp+1Ch] [bp-14h]@2 | |
4312 HKEY phkResult; // [sp+20h] [bp-10h]@1 | |
4313 HKEY hKey; // [sp+24h] [bp-Ch]@1 | |
4314 HKEY v13; // [sp+28h] [bp-8h]@1 | |
4315 HKEY v14; // [sp+2Ch] [bp-4h]@1 | |
4316 | |
4317 cbData = uBufLen; | |
4318 Dest = (LPBYTE)pOutString; | |
4319 lpValueName = pKeyName; | |
4320 v14 = 0; | |
4321 v13 = 0; | |
4322 hKey = 0; | |
4323 phkResult = 0; | |
4324 v4 = RegCloseKey; | |
4325 if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) | |
4326 || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) | |
4327 || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition) | |
4328 || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) ) | |
4329 goto LABEL_7; | |
4330 if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) | |
4331 { | |
4332 RegCloseKey(v14); | |
4333 v14 = 0; | |
4334 LABEL_7: | |
4335 result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); | |
4336 goto LABEL_8; | |
4337 } | |
4338 v4 = RegCloseKey; | |
4339 RegCloseKey(v14); | |
4340 v14 = 0; | |
4341 RegCloseKey(v13); | |
4342 v13 = 0; | |
4343 RegCloseKey(phkResult); | |
4344 phkResult = 0; | |
4345 result = RegCloseKey(hKey); | |
4346 hKey = 0; | |
4347 LABEL_8: | |
4348 if ( v14 ) | |
4349 result = v4(v14); | |
4350 if ( v13 ) | |
4351 result = v4(v13); | |
4352 if ( hKey ) | |
4353 result = v4(hKey); | |
4354 if ( phkResult ) | |
4355 result = v4(phkResult); | |
4356 } | |
4357 | |
4358 //----- (00464D32) -------------------------------------------------------- | |
4359 void __fastcall WriteWindowsRegistryInt(const char *pKey, int val) | |
4360 { | |
4361 const char *lpValueName; // [sp+4h] [bp-1Ch]@1 | |
4362 BYTE Data[4]; // [sp+8h] [bp-18h]@1 | |
4363 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 | |
4364 HKEY hKey; // [sp+10h] [bp-10h]@1 | |
4365 HKEY phkResult; // [sp+14h] [bp-Ch]@1 | |
4366 HKEY v7; // [sp+18h] [bp-8h]@1 | |
4367 HKEY v8; // [sp+1Ch] [bp-4h]@1 | |
4368 | |
4369 *(int *)Data = val; | |
4370 lpValueName = pKey; | |
4371 v8 = 0; | |
4372 v7 = 0; | |
4373 hKey = 0; | |
4374 phkResult = 0; | |
4375 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) ) | |
4376 { | |
4377 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) ) | |
4378 { | |
4379 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v7, &dwDisposition) ) | |
4380 { | |
4381 if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) ) | |
4382 { | |
4383 RegSetValueExA(v8, lpValueName, 0, 4u, Data, 4u); | |
4384 RegCloseKey(v8); | |
4385 } | |
4386 RegCloseKey(v7); | |
4387 } | |
4388 RegCloseKey(phkResult); | |
4389 } | |
4390 RegCloseKey(hKey); | |
4391 } | |
4392 } | |
4393 | |
4394 //----- (00464E17) -------------------------------------------------------- | |
4395 bool __fastcall CheckMM7CD(char c) | |
4396 { | |
4397 char DstBuf[256]; // [sp+Ch] [bp-218h]@1 | |
4398 char strCommand[256]; // [sp+10Ch] [bp-118h]@1 | |
4399 char Filename[20]; // [sp+20Ch] [bp-18h]@1 | |
4400 | |
4401 | |
4402 wchar_t pMagicPath[1024]; | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1150
diff
changeset
|
4403 swprintf(pMagicPath, wcslen(L"%C:\\anims\\magic7.vid"), L"%C:\\anims\\magic7.vid", c); |
0 | 4404 if (GetFileAttributesW(pMagicPath) == -1) |
4405 return false; | |
4406 | |
4407 wsprintfA(strCommand, "open %c: type cdaudio alias CD", c); | |
4408 if (!mciSendStringA(strCommand, DstBuf, 0xFFu, 0)) | |
4409 { | |
4410 wsprintfA(strCommand, "info CD UPC wait"); | |
4411 mciSendStringA(strCommand, DstBuf, 0xFFu, 0); | |
4412 wsprintfA(strCommand, "close CD"); | |
4413 mciSendStringA(strCommand, DstBuf, 0xFFu, 0); | |
4414 } | |
4415 | |
4416 memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename)); | |
4417 *Filename = c; | |
4418 | |
4419 auto f = fopen(Filename, "rb"); | |
4420 if (!f) | |
4421 return false; | |
4422 | |
4423 if (!fseek(f, 0, SEEK_END)) | |
4424 { | |
4425 if (!fseek(f, -100, SEEK_CUR)) | |
4426 fread(DstBuf, 1u, 0x64u, f); | |
4427 | |
4428 fclose(f); | |
4429 return true; | |
4430 } | |
4431 fclose(f); | |
4432 return false; | |
4433 } | |
4434 | |
4435 //----- (00464F1B) -------------------------------------------------------- | |
4436 signed int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4) | |
4437 { | |
4438 char v4; // zf@3 | |
4439 int v6; // eax@10 | |
4440 int v7; // eax@11 | |
4441 int v8; // eax@12 | |
4442 int v9; // eax@13 | |
4443 BOOL (__stdcall *v10)(HWND, int, LPCSTR); // edi@15 | |
4444 const CHAR *v11; // [sp-Ch] [bp-Ch]@15 | |
4445 INT_PTR v12; // [sp-4h] [bp-4h]@5 | |
4446 | |
4447 if ( a2 == 272 ) | |
4448 { | |
4449 hInsertCDWindow = hDlg; | |
4450 v6 = (GetUserDefaultLangID() & 0x3FF) - 7; | |
4451 if ( v6 ) | |
4452 { | |
4453 v7 = v6 - 3; | |
4454 if ( v7 ) | |
4455 { | |
4456 v8 = v7 - 2; | |
4457 if ( v8 ) | |
4458 { | |
4459 v9 = v8 - 4; | |
4460 if ( v9 ) | |
4461 { | |
4462 if ( v9 != 5 ) | |
4463 return 0; | |
4464 SetWindowTextA(hDlg, "Wloz CD-ROM numer 2"); | |
4465 v10 = SetDlgItemTextA; | |
4466 SetDlgItemTextA(hDlg, 1010, "Wloz CD-ROM numer 2 Might and Magic® VII."); | |
4467 v11 = "Odwolaj"; | |
4468 } | |
4469 else | |
4470 { | |
4471 SetWindowTextA(hDlg, "Inserire il secondo CD"); | |
4472 v10 = SetDlgItemTextA; | |
4473 SetDlgItemTextA(hDlg, 1010, "Inserire il secondo CD di Might and Magic® VII."); | |
4474 v11 = "Annulla"; | |
4475 } | |
4476 } | |
4477 else | |
4478 { | |
4479 SetWindowTextA(hDlg, "Insérez le CD 2"); | |
4480 v10 = SetDlgItemTextA; | |
4481 SetDlgItemTextA(hDlg, 1010, "Insérez Might & Magic® VII CD 2."); | |
4482 v11 = "Supprimer"; | |
4483 } | |
4484 } | |
4485 else | |
4486 { | |
4487 SetWindowTextA(hDlg, "Por favor, inserte disco 2"); | |
4488 v10 = SetDlgItemTextA; | |
4489 SetDlgItemTextA(hDlg, 1010, "Por favor, inserte disco 2 de Might & Magic® VII."); | |
4490 v11 = "Cancelar"; | |
4491 } | |
4492 } | |
4493 else | |
4494 { | |
4495 SetWindowTextA(hDlg, "Bitte CD 2 einlegen"); | |
4496 v10 = SetDlgItemTextA; | |
4497 SetDlgItemTextA(hDlg, 1010, "Bitte CD 2 von Might and Magic® VII einlegen."); | |
4498 v11 = "Abbrechen"; | |
4499 } | |
4500 v10(hDlg, 2, v11); | |
4501 return 0; | |
4502 } | |
4503 if ( a2 == 273 ) | |
4504 { | |
4505 if ( a3 == 2 ) | |
4506 { | |
4507 v12 = 0; | |
4508 LABEL_9: | |
4509 EndDialog(hDlg, v12); | |
4510 return 1; | |
4511 } | |
4512 v4 = a3 == 1; | |
4513 } | |
4514 else | |
4515 { | |
4516 v4 = a2 == 1025; | |
4517 } | |
4518 if ( v4 ) | |
4519 { | |
4520 v12 = 1; | |
4521 goto LABEL_9; | |
4522 } | |
4523 return 0; | |
4524 } | |
4525 | |
4526 //----- (00465061) -------------------------------------------------------- | |
4527 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive) | |
4528 { | |
4529 char drive[4] = {'X', ':', '\\', 0}; | |
4530 | |
4531 bool bGotCDFromRegistry = false; | |
4532 | |
4533 HKEY hSoftware = nullptr, | |
4534 hNWC = nullptr, | |
4535 hMM7 = nullptr, | |
4536 hVersion = nullptr; | |
4537 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hSoftware)) | |
4538 { | |
4539 if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, 0x2001Fu, &hNWC)) | |
4540 { | |
4541 if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, 0x2001Fu, &hMM7)) | |
4542 { | |
4543 if (!RegOpenKeyExA(hMM7, "1.0", 0, 0x2001Fu, &hVersion)) | |
4544 { | |
4545 DWORD cbData = 3; | |
4546 if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData)) | |
4547 bGotCDFromRegistry = true; | |
4548 } | |
4549 RegCloseKey(hVersion); | |
4550 } | |
4551 RegCloseKey(hMM7); | |
4552 } | |
4553 RegCloseKey(hNWC); | |
4554 } | |
4555 RegCloseKey(hSoftware); | |
4556 | |
4557 if (bGotCDFromRegistry) | |
4558 if (CheckMM7CD(*drive)) | |
4559 { | |
4560 cMM7GameCDDriveLetter = *drive; | |
4561 return true; | |
4562 } | |
4563 | |
4564 while (true) | |
4565 { | |
4566 for (uint i = 0; i < 26; ++i) | |
4567 { | |
4568 drive[0] = 'A' + i; | |
4569 | |
4570 if (GetDriveTypeA(drive) == DRIVE_CDROM) | |
4571 if (CheckMM7CD(*drive)) | |
4572 { | |
4573 cMM7GameCDDriveLetter = *drive; | |
4574 WriteWindowsRegistryString("CDDrive", drive); | |
4575 return true; | |
4576 } | |
4577 } | |
4578 | |
4579 if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", ::hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0)) | |
4580 continue; | |
4581 return false; | |
4582 } | |
4583 } | |
4584 | |
4585 //----- (004651F4) -------------------------------------------------------- | |
4586 bool MM7_Initialize() | |
4587 { | |
363 | 4588 initing=true; //ADDED Gloval |
0 | 4589 wchar_t pCurrentDir[1024]; |
4590 _wgetcwd(pCurrentDir, 1024); | |
4591 | |
4592 wchar_t pMM6IniFile[1024]; | |
293 | 4593 wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); |
0 | 4594 |
4595 bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); | |
4596 if (bNoCD) | |
4597 bCanLoadFromCD = false; | |
4598 if (bCanLoadFromCD) | |
4599 { | |
4600 if (!FindMM7CD(hWnd, &cMM7GameCDDriveLetter)) | |
4601 return false; | |
4602 } | |
4603 | |
4604 | |
4605 srand(GetTickCount()); | |
4606 | |
4607 WNDCLASSEXW wcxw; | |
4608 { | |
4609 wcxw.cbSize = sizeof(wcxw); | |
4610 wcxw.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; | |
4611 wcxw.lpfnWndProc = (WNDPROC)aWinProc; | |
4612 wcxw.cbClsExtra = 0; | |
4613 wcxw.cbWndExtra = 0; | |
4614 wcxw.hInstance = GetModuleHandleW(nullptr); | |
4615 wcxw.hCursor = 0; | |
4616 wcxw.hIcon = wcxw.hIconSm = LoadIconW(wcxw.hInstance, L"MM7_ICON"); | |
4617 wcxw.lpszMenuName = nullptr; | |
4618 wcxw.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); | |
4619 wcxw.lpszClassName = L"M&MTrilogy"; | |
4620 } | |
4621 if (!RegisterClassExW(&wcxw)) | |
4622 { | |
4623 Log::Warning(L"Cannot register window class"); | |
4624 return false; | |
4625 } | |
4626 | |
4627 auto hDesktopDC = GetDC(nullptr); | |
4628 uint uDesktopWidth = GetDeviceCaps(hDesktopDC, HORZRES); | |
4629 uint uDesktopHeight = GetDeviceCaps(hDesktopDC, VERTRES); | |
4630 | |
4631 if (GetDeviceCaps(hDesktopDC, BITSPIXEL) != 16 || | |
4632 GetDeviceCaps(hDesktopDC, PLANES) != 1 ) | |
4633 dword_6BE364_game_settings_1 |= 2; | |
4634 | |
4635 ReleaseDC(nullptr, hDesktopDC); | |
4636 | |
4637 uint uTotalWinWidth = 2 * GetSystemMetrics(SM_CXFRAME) + 640; | |
4638 uint uTotalWinHeight = GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYFRAME) + 480; | |
4639 | |
4640 uint uWinCenteredPosX = (uDesktopWidth - uTotalWinWidth) / 2; | |
4641 uint uWinCenteredPosY = (uDesktopHeight - uTotalWinHeight) / 2; | |
4642 | |
4643 uWindowX = ReadWindowsRegistryInt("window X", uWinCenteredPosX); | |
748 | 4644 uWindowX = uDesktopWidth / 2 - 640 / 2; |
0 | 4645 WriteWindowsRegistryInt("window X", uWindowX); |
4646 | |
4647 uWindowY = ReadWindowsRegistryInt("window Y", uWinCenteredPosY); | |
748 | 4648 uWindowY = uDesktopHeight / 2 - 480 / 2; |
0 | 4649 WriteWindowsRegistryInt("window Y", uWindowY); |
4650 | |
4651 hWnd = CreateWindowExW(0, wcxw.lpszClassName, L"Might and Magic® VII", | |
4652 uWindowStyle = WS_SYSMENU | WS_GROUP | WS_DLGFRAME | WS_BORDER, | |
4653 uWindowX, uWindowY, | |
4654 640, 480, | |
4655 nullptr, | |
4656 hOSMenu = nullptr, | |
4657 wcxw.hInstance, | |
4658 nullptr); | |
4659 SetWindowTextW(hWnd, L"Might and Magic® VII"); | |
736 | 4660 |
4661 HMENU menu = CreateMenu(); | |
748 | 4662 { |
4663 HMENU file = CreatePopupMenu(); | |
4664 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)file, L"&File"); | |
4665 { | |
4666 AppendMenuW(file, MF_ENABLED | MF_STRING, 40001, L"Exit"); | |
4667 } | |
4668 | |
4669 HMENU debug = CreatePopupMenu(); | |
4670 AppendMenuW(menu, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug, L"&Debug"); | |
4671 { | |
4672 HMENU debug_party = CreatePopupMenu(); | |
4673 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party, L"&Party"); | |
4674 { | |
4675 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40007, L"Give Gold (10 000)"); | |
4676 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40008, L"Give Exp (20 000)"); | |
4677 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40059, L"Give Skills (50 each)"); | |
4678 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40013, L"Remove Gold"); | |
4679 | |
4680 HMENU debug_party_setconditions = CreatePopupMenu(); | |
4681 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_setconditions, L"Set Condition"); | |
4682 { | |
4683 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40044, L"Afraid"); | |
4684 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40043, L"Asleep"); | |
4685 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40037, L"Curse"); | |
4686 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40036, L"Disease1"); | |
4687 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40035, L"Disease2"); | |
4688 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40034, L"Disease3"); | |
4689 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40041, L"Dead"); | |
4690 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40039, L"Drunk"); | |
4691 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40042, L"Eradicated"); | |
4692 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40038, L"Insane"); | |
4693 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40045, L"Paralyzed"); | |
4694 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40033, L"Poison1"); | |
4695 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40032, L"Poison2"); | |
4696 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40031, L"Poison3"); | |
4697 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40029, L"&Stone"); | |
4698 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40040, L"Unconscious"); | |
4699 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40030, L"Weak"); | |
4700 AppendMenuW(debug_party_setconditions, MF_ENABLED | MF_STRING, 40073, L"Zombie"); | |
4701 } | |
4702 | |
4703 AppendMenuW(debug_party, MF_ENABLED | MF_STRING, 40006, L"Set Food (20)"); | |
4704 | |
4705 HMENU debug_party_alignment = CreatePopupMenu(); | |
4706 AppendMenuW(debug_party, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_party_alignment, L"Alignment"); | |
4707 { | |
4708 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40062, L"Good"); | |
4709 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING | MF_CHECKED, 40063, L"Neutral"); | |
4710 AppendMenuW(debug_party_alignment, MF_ENABLED | MF_STRING, 40064, L"Evil"); | |
4711 } | |
4712 } | |
4713 | |
4714 HMENU debug_time = CreatePopupMenu(); | |
4715 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_time, L"&Time"); | |
4716 { | |
4717 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40009, L"Add 1 Day"); | |
4718 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40010, L"Add 1 Week"); | |
4719 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40011, L"Add 1 Month"); | |
4720 AppendMenuW(debug_time, MF_ENABLED | MF_STRING, 40012, L"Add 1 Year"); | |
4721 } | |
4722 | |
4723 HMENU debug_items = CreatePopupMenu(); | |
4724 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_items, L"&Items"); | |
4725 { | |
4726 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40015, L"Generate level &1 item"); | |
4727 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40016, L"Generate level &2 item"); | |
4728 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40017, L"Generate level &3 item"); | |
4729 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40018, L"Generate level &4 item"); | |
4730 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40019, L"Generate level &5 item"); | |
4731 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40020, L"Generate level &6 item"); | |
4732 AppendMenuW(debug_items, MF_ENABLED | MF_STRING, 40061, L"Generate special item"); | |
4733 } | |
4734 | |
4735 HMENU debug_graphics = CreatePopupMenu(); | |
4736 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_graphics, L"&Graphics"); | |
4737 { | |
4738 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40023, L"Lighting Mode"); | |
4739 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40024, L"Lighting Geometry"); | |
4740 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING | MF_GRAYED, 40104, L"Lights Off"); | |
4741 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40105, L"Colored Lights"); | |
4742 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40025, L"Debug Lights"); | |
4743 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40101, L"Debug Decals"); | |
4744 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40027, L"HWID Portals"); | |
4745 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40047, L"SWID Portals"); | |
4746 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40051, L"OD Frustum"); | |
4747 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40054, L"SWOD Constant Redraw"); | |
4748 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40055, L"SWOD Lit Rasterizer"); | |
4749 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40056, L"Party Light off"); | |
4750 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40060, L"SWOD Nice Lighting off"); | |
4751 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40067, L"HWOD Additive Fog Lights"); | |
4752 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40072, L"HWID Nice Lighting"); | |
4753 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40048, L"Wireframe"); | |
4754 AppendMenuW(debug_graphics, MF_ENABLED | MF_STRING, 40049, L"Fog"); | |
4755 } | |
4756 | |
4757 HMENU debug_misc = CreatePopupMenu(); | |
4758 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_misc, L"&Misc"); | |
4759 { | |
4760 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40066, L"Object Viewcone Culling"); | |
4761 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40068, L"Red Tint"); | |
4762 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40071, L"Display Secrets"); | |
4763 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40102, L"Massive Bloodsplat"); | |
4764 AppendMenuW(debug_misc, MF_ENABLED | MF_STRING, 40103, L"Underwater Gravity"); | |
4765 } | |
4766 | |
4767 HMENU debug_eax = CreatePopupMenu(); | |
4768 AppendMenuW(debug, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)debug_eax, L"EAX Environs"); | |
4769 { | |
4770 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40074, L"NONE"); | |
4771 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40075, L"GENERIC"); | |
4772 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40076, L"PADDEDCELL"); | |
4773 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40077, L"ROOM"); | |
4774 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40078, L"BATHROOM"); | |
4775 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40079, L"LIVINGROOM"); | |
4776 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40080, L"STONEROOM"); | |
4777 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40081, L"AUDITORIUM"); | |
4778 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40082, L"CONCERTHALL"); | |
4779 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40083, L"CAVE"); | |
4780 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40084, L"ARENA"); | |
4781 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40085, L"HANGAR"); | |
4782 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40086, L"CARPETEDHALLWAY"); | |
4783 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40087, L"HALLWAY"); | |
4784 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40088, L"STONECORRIDOR"); | |
4785 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40089, L"ALLEY"); | |
4786 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40090, L"FOREST"); | |
4787 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40091, L"CITY"); | |
4788 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40092, L"MOUNTAINS"); | |
4789 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40093, L"QUARRY"); | |
4790 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40094, L"PLAIN"); | |
4791 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40095, L"PARKINGLOT"); | |
4792 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40096, L"SEWERPIPE"); | |
4793 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40097, L"UNDERWATER"); | |
4794 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40098, L"DRUGGED"); | |
4795 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40099, L"DIZZY"); | |
4796 AppendMenuW(debug_eax, MF_ENABLED | MF_STRING, 40100, L"PSICHOTIC"); | |
4797 } | |
4798 } | |
4799 } | |
736 | 4800 SetMenu(hWnd, menu); |
492 | 4801 |
0 | 4802 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); |
4803 | |
4804 pRenderer = Render::Create(); | |
4805 if (!pRenderer) | |
4806 { | |
4807 Log::Warning(L"Render creation failed"); | |
4808 return false; | |
4809 } | |
4810 else | |
4811 { | |
4812 bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false); | |
4813 uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1); | |
4814 bool bColoredLights = ReadWindowsRegistryInt("Colored Lights", false); | |
4815 uint uLevelOfDetail = ReadWindowsRegistryInt("Detail Level", 1); | |
4816 uint bTinting = ReadWindowsRegistryInt("Tinting", 1) != 0; | |
4817 | |
4818 if (!pRenderer->Initialize(bWindowMode, uDefaultDevice, bColoredLights, uLevelOfDetail, bTinting)) | |
4819 { | |
4820 Log::Warning(L"Render failed to initialize"); | |
4821 return false; | |
4822 } | |
4823 } | |
492 | 4824 |
0 | 4825 pAllocator = Allocator::Create(); |
650
14d13880daa9
Sleeping in tavern crash fixed - memory allocation rised to 48mb
Nomad
parents:
648
diff
changeset
|
4826 if (!pAllocator->Initialize(48 * 1024)) |
0 | 4827 { |
4828 MessageBoxW(nullptr, | |
650
14d13880daa9
Sleeping in tavern crash fixed - memory allocation rised to 48mb
Nomad
parents:
648
diff
changeset
|
4829 L"Unable to Allocate 48Mb of RAM", |
0 | 4830 L"More RAM Memory Required", MB_ICONEXCLAMATION); |
4831 return false; | |
4832 } | |
492 | 4833 |
351 | 4834 game_starting_year = 1168; |
0 | 4835 |
4836 pParty = new Party; | |
147 | 4837 memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings)); |
0 | 4838 pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile); |
4839 pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile); | |
4840 pParty->sEyelevel = pParty->uDefaultEyelevel; | |
4841 pParty->uDefaultPartyHeight = GetPrivateProfileIntW(L"party", L"height", 192, pMM6IniFile); | |
4842 pParty->uPartyHeight = pParty->uDefaultPartyHeight; | |
4843 | |
4844 bUseRegistry = GetPrivateProfileIntW(L"settings", L"registry", 1, pMM6IniFile); | |
4845 MM6_Initialize(pMM6IniFile); | |
4846 | |
4847 pKeyActionMap = new KeyboardActionMapping; | |
4848 | |
4849 pEventTimer = Timer::Create(); | |
4850 pEventTimer->Initialize(); | |
4851 | |
4852 OnTimer(1); | |
4853 GameUI_StatusBar_UpdateTimedString(1); | |
4854 pGame = Game::Create(); | |
4855 pMouse = pGame->pMouseInstance; | |
4856 | |
4857 | |
4858 RECT rcWindow; | |
4859 GetWindowRect(hWnd, &rcWindow); | |
4860 | |
4861 RECT rcClient; | |
4862 GetClientRect(hWnd, &rcClient); | |
4863 uWindowWidth = rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640; | |
4864 uWindowHeight = rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480; | |
4865 MoveWindow(hWnd, uWindowX, uWindowY, | |
4866 rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640, | |
4867 rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0); | |
4868 ShowWindow(hWnd, SW_SHOWNORMAL); | |
4869 | |
4870 pIcons_LOD = new LODFile_IconsBitmaps; | |
4871 if (!pIcons_LOD->LoadIconsOrEvents("data\\icons.lod")) | |
4872 { | |
4873 MessageBoxW(nullptr, | |
4874 L"Some files are missing\n\nPlease Reinstall.", | |
4875 L"Files Missing", MB_ICONEXCLAMATION); | |
4876 return false; | |
4877 } | |
4878 pIcons_LOD->dword_011BA4 = 0; | |
4879 | |
4880 pEvents_LOD = new LODFile_IconsBitmaps; | |
4881 if (!pEvents_LOD->LoadIconsOrEvents("data\\events.lod")) | |
4882 { | |
4883 MessageBoxW(nullptr, | |
4884 L"Some files are missing\n\nPlease Reinstall.", | |
4885 L"Files Missing", MB_ICONEXCLAMATION); | |
4886 return false; | |
4887 } | |
4888 | |
4889 InitializeGameText(); | |
4890 | |
4891 pBitmaps_LOD = new LODFile_IconsBitmaps; | |
4892 if (!pBitmaps_LOD->LoadBitmaps("data\\bitmaps.lod")) | |
4893 { | |
4894 MessageBoxA(nullptr, | |
4895 pGlobalTXT_LocalizationStrings[63], | |
4896 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); | |
4897 return false; | |
4898 } | |
4899 | |
4900 if (bUseRegistry) | |
4901 bUseLoResSprites = ReadWindowsRegistryInt("resolution", 0); | |
4902 else | |
4903 bUseLoResSprites = GetPrivateProfileIntW(L"settings", L"resolution", 0, pMM6IniFile); | |
4904 | |
4905 const char *pSpritesFile = nullptr; | |
4906 if (bUseLoResSprites) | |
4907 pSpritesFile = "data\\spriteLO.lod"; | |
4908 else | |
4909 pSpritesFile = "data\\sprites.lod"; | |
4910 | |
4911 pSprites_LOD = new LODFile_Sprites; | |
4912 if (!pSprites_LOD->LoadSprites(pSpritesFile)) | |
4913 { | |
4914 MessageBoxA(nullptr, | |
4915 pGlobalTXT_LocalizationStrings[63], | |
4916 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); | |
4917 return false; | |
4918 } | |
4919 | |
4920 if (bDebugResouces) | |
4921 { | |
4922 pSpriteFrameTable = new SpriteFrameTable; | |
4923 if (!pSpriteFrameTable->FromFileTxt("data\\sft.txt")) | |
4924 Abortf("Unable to open sft.txt"); | |
4925 | |
4926 pDecorationList = new DecorationList; | |
4927 if (!pDecorationList->FromFileTxt("data\\declist.txt")) | |
4928 Abortf("Unable to open declist.txt"); | |
4929 | |
4930 pObjectList = new ObjectList; | |
4931 if (!pObjectList->FromFileTxt("data\\objlist.txt")) | |
4932 Abortf("Unable to open objlist.txt"); | |
4933 | |
4934 pMonsterList = new MonsterList; | |
4935 if (!pMonsterList->FromFileTxt("data\\monlist.txt")) | |
4936 Abortf("Unable to open monlist.txt"); | |
4937 | |
4938 pIconsFrameTable = new IconFrameTable; | |
4939 if (!pIconsFrameTable->FromFileTxt("data\\ift.txt")) | |
4940 Abortf("Unable to open ift.txt"); | |
4941 | |
4942 pTextureFrameTable = new TextureFrameTable; | |
4943 if (!pTextureFrameTable->FromFileTxt("data\\tft.def")) | |
4944 Abortf("Unable to open tft.def"); | |
4945 | |
4946 pTileTable = new TileTable; | |
4947 if (!pTileTable->FromFileTxt("data\\tile.def")) | |
4948 Abortf("Unable to open tile.def"); | |
4949 | |
4950 pPlayerFrameTable = new PlayerFrameTable; | |
4951 if (!pPlayerFrameTable->FromFileTxt("data\\pft.def")) | |
4952 Abortf("Unable to open pft.def"); | |
4953 | |
4954 pChestList = new ChestList; | |
4955 if (!pChestList->FromFileTxt("data\\chest.def")) | |
4956 Abortf("Unable to open chest.def"); | |
4957 | |
4958 pOverlayList = new OverlayList; | |
4959 if (!pOverlayList->FromFileTxt("data\\overlay.def")) | |
4960 Abortf("Unable to open overlay.def"); | |
4961 | |
4962 pSoundList = new SoundList; | |
4963 if (!pSoundList->FromFileTxt("data\\sounds.def")) | |
4964 Abortf("Unable to open sounds.def"); | |
4965 } | |
4966 else | |
4967 { | |
4968 auto pSFT = pEvents_LOD->LoadRaw("dsft.bin", 1); | |
4969 pSpriteFrameTable = new SpriteFrameTable; | |
4970 pSpriteFrameTable->FromFile(pSFT); | |
4971 free(pSFT); | |
4972 | |
4973 auto pTFT = pEvents_LOD->LoadRaw("dtft.bin", 1); | |
4974 pTextureFrameTable = new TextureFrameTable; | |
4975 pTextureFrameTable->FromFile(pTFT); | |
4976 free(pTFT); | |
4977 | |
4978 auto pTiles = pEvents_LOD->LoadRaw("dtile.bin", 1); | |
4979 pTileTable = new TileTable; | |
4980 pTileTable->FromFile(pTiles); | |
4981 free(pTiles); | |
4982 | |
4983 auto pPFT = pEvents_LOD->LoadRaw("dpft.bin", 1); | |
4984 pPlayerFrameTable = new PlayerFrameTable; | |
4985 pPlayerFrameTable->FromFile(pPFT); | |
4986 free(pPFT); | |
4987 | |
4988 auto pIFT = pEvents_LOD->LoadRaw("dift.bin", 1); | |
4989 pIconsFrameTable = new IconFrameTable; | |
4990 pIconsFrameTable->FromFile(pIFT); | |
4991 free(pIFT); | |
4992 | |
4993 auto pDecs = pEvents_LOD->LoadRaw("ddeclist.bin", 1); | |
4994 pDecorationList = new DecorationList; | |
4995 pDecorationList->FromFile(pDecs); | |
4996 free(pDecs); | |
4997 | |
4998 auto pObjs = pEvents_LOD->LoadRaw("dobjlist.bin", 1); | |
4999 pObjectList = new ObjectList; | |
5000 pObjectList->FromFile(pObjs); | |
5001 free(pObjs); | |
5002 | |
5003 auto pMons = pEvents_LOD->LoadRaw("dmonlist.bin", 1); | |
5004 pMonsterList = new MonsterList; | |
5005 pMonsterList->FromFile(pMons); | |
5006 free(pMons); | |
5007 | |
5008 auto pChests = pEvents_LOD->LoadRaw("dchest.bin", 1); | |
5009 pChestList = new ChestList; | |
5010 pChestList->FromFile(pChests); | |
5011 free(pChests); | |
5012 | |
5013 auto pOverlays = pEvents_LOD->LoadRaw("doverlay.bin", 1); | |
5014 pOverlayList = new OverlayList; | |
5015 pOverlayList->FromFile(pOverlays); | |
5016 free(pOverlays); | |
5017 | |
5018 auto pSounds = pEvents_LOD->LoadRaw("dsounds.bin", 1); | |
5019 pSoundList = new SoundList; | |
5020 pSoundList->FromFile(pSounds); | |
5021 free(pSounds); | |
5022 } | |
5023 | |
5024 | |
5025 if (bDebugResouces) | |
5026 { | |
5027 pSpriteFrameTable->ToFile(); | |
5028 pDecorationList->ToFile(); | |
5029 pObjectList->ToFile(); | |
5030 pMonsterList->ToFile(); | |
5031 pIconsFrameTable->ToFile(); | |
5032 pTextureFrameTable->ToFile(); | |
5033 pTileTable->ToFile(); | |
5034 pPlayerFrameTable->ToFile(); | |
5035 pChestList->ToFile(); | |
5036 pOverlayList->ToFile(); | |
5037 pSoundList->ToFile(); | |
5038 } | |
5039 | |
492 | 5040 |
0 | 5041 if (dword_6BE364_game_settings_1 & 2 || !(dword_6BE368_debug_settings_2 & 1))// |
5042 // color depth != 16 | |
5043 // or | |
5044 // not in window | |
5045 { | |
5046 SetMenu(hWnd, 0); | |
5047 SetWindowLongA(hWnd, GWL_EXSTYLE, 0); | |
5048 SetWindowLongA(hWnd, GWL_STYLE, WS_VISIBLE); | |
5049 pRenderer->InitializeFullscreen(hWnd); | |
5050 } | |
5051 else | |
5052 { | |
5053 ClipCursor(nullptr); | |
5054 pRenderer->SwitchToWindow(hWnd); | |
5055 } | |
5056 | |
5057 uSoundVolumeMultiplier = ReadWindowsRegistryInt("soundflag", 9); | |
5058 if (uSoundVolumeMultiplier > 9) | |
5059 uSoundVolumeMultiplier = 9; | |
5060 uMusicVolimeMultiplier = ReadWindowsRegistryInt("musicflag", 9); | |
5061 if (uMusicVolimeMultiplier > 9) | |
5062 uMusicVolimeMultiplier = 9; | |
5063 uVoicesVolumeMultiplier = ReadWindowsRegistryInt("CharVoices", 9); | |
5064 if (uVoicesVolumeMultiplier > 9) | |
5065 uVoicesVolumeMultiplier = 9; | |
5066 bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0; | |
5067 byte_6BE388_graphicsmode = ReadWindowsRegistryInt("graphicsmode", 1); | |
5068 if (byte_6BE388_graphicsmode < 0 || byte_6BE388_graphicsmode > 2) | |
5069 byte_6BE388_graphicsmode = 0; | |
5070 | |
5071 uGammaPos = ReadWindowsRegistryInt("GammaPos", 4); | |
733 | 5072 if (uGammaPos > 9) |
0 | 5073 uGammaPos = 4; |
5074 pGame->pGammaController->Initialize(uGammaPos * 0.1 + 0.6); | |
5075 | |
5076 if ( ReadWindowsRegistryInt("Bloodsplats", 1) ) | |
591 | 5077 pGame->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS; |
0 | 5078 else |
733 | 5079 pGame->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS; |
0 | 5080 |
5081 uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 0); | |
5082 dword_6BE384_2dacceloff = ReadWindowsRegistryInt("2dacceloff", 0); | |
5083 | |
5084 if (!bNoSound) | |
5085 pAudioPlayer->Initialize(hWnd); | |
5086 | |
1262 | 5087 pVideoPlayer = new VideoPlayer(); |
0 | 5088 pVideoPlayer->Initialize(); |
5089 | |
5090 dword_6BE364_game_settings_1 |= 0x4000; | |
5091 | |
5092 switch ( uTurnSpeed ) | |
5093 { | |
731 | 5094 case 0: // undefined turn option |
1067 | 5095 __debugbreak(); // really shouldn't use this mode |
731 | 5096 uTurnSpeed = (unsigned int)uCPUSpeed < 199 ? 128 : 64; // adjust turn speed to estimated fps |
5097 break; | |
5098 | |
5099 case 1u: // 16x | |
5100 Log::Warning(L"x16 Turn Speed"); // really shouldn't use this mode | |
0 | 5101 uTurnSpeed = 128; |
731 | 5102 break; |
5103 | |
5104 case 2u: // 32x | |
5105 Log::Warning(L"x32 Turn Speed"); // really shouldn't use this mode | |
0 | 5106 uTurnSpeed = 64; |
731 | 5107 break; |
5108 | |
5109 case 3u: // smooth | |
0 | 5110 uTurnSpeed = 0; |
731 | 5111 break; |
5112 } | |
5113 | |
5114 initing = false; //ADDED Gloval | |
0 | 5115 return true; |
5116 } | |
5117 | |
5118 //----- (00465D0B) -------------------------------------------------------- | |
5119 void __cdecl SecondaryInitialization() | |
5120 { | |
5121 __int16 v4; // ax@4 | |
5122 signed int v5; // esi@5 | |
5123 int v6; // ecx@6 | |
5124 int v7; // edx@7 | |
5125 ObjectDesc *v8; // eax@7 | |
5126 char pContainer[32]; // [sp+10h] [bp-Ch]@9 | |
5127 | |
5128 pMouse->Initialize(hWnd); | |
5129 | |
5130 pItemsTable = new ItemsTable; | |
5131 pItemsTable->Initialize(); | |
5132 | |
5133 pBitmaps_LOD->dword_011BA8 = 1; | |
5134 pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
5135 pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
5136 pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
762 | 5137 |
5138 pPaletteManager->SetMistColor(128, 128, 128); | |
0 | 5139 pPaletteManager->RecalculateAll(); |
5140 pSprites_LOD->field_ECAC = 1; | |
5141 pObjectList->InitializeSprites(); | |
5142 pOverlayList->InitializeSprites(); | |
5143 if (!bNoSound) | |
5144 pSoundList->Initialize(); | |
5145 | |
5146 static const char *pUIAnimNames[4] = | |
5147 { | |
5148 "glow03", "glow05", | |
5149 "torchA", "wizeyeA" | |
5150 }; | |
5151 static unsigned short _4E98D0[4][4] = | |
5152 { | |
5153 {479, 0, 329, 0}, | |
5154 {585, 0, 332, 0}, | |
5155 {468, 0, 0, 0}, | |
5156 {606, 0, 0, 0} | |
5157 }; | |
5158 | |
5159 | |
5160 for (uint i = 0; i < 4; ++i) | |
5161 { | |
5162 pUIAnims[i]->uIconID = pIconsFrameTable->FindIcon(pUIAnimNames[i]); | |
5163 pIconsFrameTable->InitializeAnimation(pUIAnims[i]->uIconID); | |
5164 | |
5165 pUIAnims[i]->uAnimLength = 0; | |
5166 pUIAnims[i]->uAnimTime = 0; | |
5167 pUIAnims[i]->x = _4E98D0[i][0]; | |
5168 pUIAnims[i]->y = _4E98D0[i][2]; | |
5169 } | |
5170 | |
5171 v5 = 0; | |
5172 if ( (signed int)pObjectList->uNumObjects > 0 ) | |
5173 { | |
5174 v6 = 0; | |
5175 do | |
5176 { | |
5177 BYTE3(v7) = 0; | |
5178 v8 = &pObjectList->pObjects[v6]; | |
5179 ++v6; | |
5180 *(short *)((char *)&v7 + 1) = v8->uParticleTrailColorR; | |
5181 LOBYTE(v7) = v8->uParticleTrailColorG; | |
5182 ++v5; | |
5183 v8->uParticleTrailColor = v8->uParticleTrailColorB | (v7 << 8); | |
5184 } | |
5185 while ( v5 < (signed int)pObjectList->uNumObjects ); | |
5186 } | |
5187 flt_6BE3A0 = 0.55000001f; | |
5188 MainMenuUI_Create(); | |
5189 pGame->pStru6Instance->LoadAnimations(); | |
5190 | |
5191 for (uint i = 0; i < 7; ++i) | |
5192 { | |
5193 sprintf(pContainer, "HDWTR%03u", i); | |
5194 pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(pContainer); | |
5195 } | |
5196 | |
5197 pNPCStats = new NPCStats; | |
110 | 5198 memset(pNPCStats->pNPCData, 0, 0x94BCu); |
0 | 5199 pNPCStats->Initialize(); |
5200 | |
5201 Initialize_GlobalEVT(); | |
762 | 5202 pBitmaps_LOD->_inlined_sub0(); |
5203 pSprites_LOD->_inlined_sub0(); | |
0 | 5204 pPaletteManager->LockAll(); |
5205 | |
5206 _mkdir("Saves"); | |
5207 for (uint i = 0; i < 5; ++i) | |
5208 for (uint j = 0; j < 6; ++j) | |
5209 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5210 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5211 remove(pTmpBuf.data()); |
0 | 5212 } |
5213 | |
5214 Initialize_GamesLOD_NewLOD(); | |
1051 | 5215 _576E2C_current_minimap_zoom = 512; |
0 | 5216 dword_576E28 = 9; |
5217 } | |
5218 | |
522 | 5219 void IntegrityTest() |
5220 { | |
5221 assert(sizeof(RenderVertexSoft) == 0x30); | |
5222 assert(sizeof(RenderBillboard) == 0x34); | |
5223 assert(sizeof(Texture) == 0x48); | |
5224 assert(sizeof(RGBTexture) == 0x28); | |
5225 assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4); // + virtual dtor ptr | |
5226 assert(sizeof(AudioPlayer) == 0xC84); | |
5227 assert(sizeof(SoundDesc) == 0x78); | |
5228 assert(sizeof(stru339_spell_sound) == 0xAFD8); | |
5229 assert(sizeof(VideoPlayer) == 0x108 + 4); | |
5230 assert(sizeof(MovieHeader) == 0x2C); | |
5231 assert(sizeof(DecorationDesc) == 0x54); | |
5232 assert(sizeof(ObjectDesc) == 0x38); | |
5233 assert(sizeof(OverlayDesc) == 0x8); | |
5234 assert(sizeof(ChestDesc) == 0x24); | |
5235 assert(sizeof(TileDesc) == 0x1A); | |
5236 assert(sizeof(MonsterDesc) == 0x98); | |
5237 assert(sizeof(Timer) == 0x28); | |
5238 assert(sizeof(OtherOverlay) == 0x14); | |
5239 assert(sizeof(ItemGen) == 0x24); | |
5240 assert(sizeof(SpriteObject) == 0x70); | |
5241 assert(sizeof(ItemDesc) == 0x30); | |
5242 assert(sizeof(ItemsTable) == 0x117A0); | |
5243 assert(sizeof(Chest) == 0x14CC); | |
5244 assert(sizeof(MapInfo) == 0x44); | |
5245 assert(sizeof(SpellInfo) == 0x24); | |
5246 assert(sizeof(SpellData) == 0x14); | |
5247 assert(sizeof(SpellBuff) == 0x10); | |
5248 assert(sizeof(AIDirection) == 0x1C); | |
5249 assert(sizeof(ActorJob) == 0xC); | |
5250 assert(sizeof(Actor) == 0x344); | |
5251 assert(sizeof(LevelDecoration) == 0x20); | |
5252 assert(sizeof(KeyboardActionMapping) == 0x20C); | |
5253 assert(sizeof(UIAnimation) == 0xD); | |
5254 assert(sizeof(SpawnPointMM7) == 0x18); | |
5255 assert(sizeof(ODMFace) == 0x134); | |
5256 assert(sizeof(BSPNode) == 0x8); | |
5257 assert(sizeof(BSPModel) == 0xBC); | |
5258 assert(sizeof(OutdoorLocation) == 0x1C28C); | |
5259 assert(sizeof(BLVFace) == 0x60); | |
5260 assert(sizeof(BLVFaceExtra) == 0x24); | |
5261 assert(sizeof(BLVSector) == 0x74); | |
5262 assert(sizeof(BLVLightMM7) == 0x10); | |
5263 assert(sizeof(BLVDoor) == 0x50); | |
5264 assert(sizeof(IndoorLocation) == 0x690); | |
5265 assert(sizeof(OutdoorCamera) == 0x74); | |
5266 assert(sizeof(Mouse) == 0x114); | |
619 | 5267 assert(sizeof(Particle_sw) == 0x68); |
522 | 5268 assert(sizeof(Particle) == 0x68); |
5269 assert(sizeof(ParticleEngine) == 0xE430); | |
5270 assert(sizeof(Lightmap) == 0xC1C); | |
5271 assert(sizeof(LightmapBuilder) == 0x3CBC38); | |
5272 assert(sizeof(Vis_SelectionList) == 0x2008); | |
5273 assert(sizeof(Vis) == 0x20D0); | |
5274 assert(sizeof(PlayerBuffAnim) == 0x10); | |
5275 assert(sizeof(ProjectileAnim) == 0x1C); | |
5276 assert(sizeof(stru6) == 0x5F8); | |
5277 assert(sizeof(IndoorCameraD3D_Vec3) == 0x10); | |
5278 assert(sizeof(IndoorCameraD3D_Vec4) == 0x18); //should be 14 (10 vec3 + 4 vdtor) but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3 | |
5279 assert(sizeof(IndoorCameraD3D) == 0x1A1384); | |
5280 assert(sizeof(StationaryLight) == 0xC); | |
5281 assert(sizeof(LightsStack_StationaryLight_) == 0x12C8); | |
5282 assert(sizeof(MobileLight) == 0x12); | |
5283 assert(sizeof(LightsStack_MobileLight_) == 0x1C28); | |
5284 assert(sizeof(Game) == 0xE78); | |
5285 assert(sizeof(stru141) == 0xA8); | |
5286 assert(sizeof(ActionQueue) == 0x7C); | |
5287 assert(sizeof(NPCData) == 0x4C); | |
5288 assert(sizeof(NPCStats) == 0x17FFC); | |
5289 assert(sizeof(BspRenderer) == 0x53740); | |
5290 assert(sizeof(PaletteManager) == 0x267AF0); | |
5291 assert(sizeof(ViewingParams) == 0x26C); | |
5292 assert(sizeof(IndoorCamera) == 0x50); | |
5293 assert(sizeof(Bloodsplat) == 0x28); | |
5294 assert(sizeof(BloodsplatContainer) == 0xA0C); | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
5295 assert(sizeof(TrailParticle) == 0x18); |
522 | 5296 assert(sizeof(EventIndex) == 0xC); |
5297 assert(sizeof(_2devent) == 0x34); | |
5298 assert(sizeof(stru176) == 0x20); | |
5299 assert(sizeof(SavegameHeader) == 0x64); | |
5300 assert(sizeof(SavegameList) == 0x3138); | |
571 | 5301 assert(sizeof(StorylineText) == 0x160); |
522 | 5302 assert(sizeof(FactionTable) == 0x1EF1); |
5303 assert(sizeof(Decal) == 0xC20); | |
5304 assert(sizeof(DecalBuilder) == 0x30C038); | |
5305 assert(sizeof(MonsterInfo) == 0x58); | |
5306 assert(sizeof(MonsterStats) == 0x5BA0); | |
5307 assert(sizeof(RenderD3D) == 0x148); | |
5308 assert(sizeof(Render) == 0x129844); | |
5309 assert(sizeof(Player) == 0x1B3C); | |
5310 assert(sizeof(Party_stru0) == 0x678); | |
5311 assert(sizeof(Party) == 0x16238); | |
5312 assert(sizeof(GUIButton) == 0xBC); | |
5313 assert(sizeof(GUIWindow) == 0x54); | |
5314 assert(sizeof(GUIProgressBar) == 0x1B8); | |
5315 assert(sizeof(GUIFont) == 0x1020); | |
1330 | 5316 // assert(sizeof(stru262_TurnBased) == 0x40); |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
548
diff
changeset
|
5317 assert(sizeof(ArcomageGame) == 0xFB); |
924 | 5318 assert(sizeof(CastSpellInfo) == 0x14); |
522 | 5319 assert(sizeof(ArcomageCard) == 0x6C); |
5320 assert(sizeof(stru320) == 0x3FC); | |
5321 assert(sizeof(TravelInfo) == 0x20); | |
5322 assert(sizeof(stru336) == 0x798); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5323 assert(sizeof(Vec3_short_) == 6); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5324 assert(sizeof(BLVFace) == 96); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5325 assert(sizeof(BLVFaceExtra) == 36); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5326 assert(sizeof(BLVSector) == 116); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5327 assert(sizeof(LevelDecoration) == 32); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5328 assert(sizeof(BLVLightMM7) == 16); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5329 assert(sizeof(BSPNode) == 8); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5330 assert(sizeof(SpawnPointMM7) == 24); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5331 assert(sizeof(DDM_DLV_Header) == 40); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5332 assert(sizeof(Actor) == 836); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5333 assert(sizeof(SpriteObject) == 112); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5334 assert(sizeof(Chest) == 5324); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5335 assert(sizeof(stru123) == 0xC8); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
668
diff
changeset
|
5336 assert(sizeof(BLVMapOutline) == 12); |
700
1d05543f522d
Some occasional crashes in PaletteManager and sprite loading fixed.
Nomad
parents:
698
diff
changeset
|
5337 assert(sizeof(LODSprite) == 0x28); |
522 | 5338 } |
5339 | |
168 | 5340 bool new_sky = false; |
670 | 5341 bool change_seasons = false; |
894 | 5342 bool all_magic = true; |
0 | 5343 |
5344 //----- (00462C94) -------------------------------------------------------- | |
5345 bool MM_Main(const wchar_t *pCmdLine) | |
5346 { | |
5347 HWND hPrevWnd; // eax@1 | |
5348 HWND hPrevWnd_; // esi@1 | |
5349 HWND v6; // eax@4 | |
5350 int v8; // eax@15 | |
5351 //bool v9; // edx@16 | |
5352 //OtherOverlay *v10; // esi@44 | |
5353 //signed int v11; // edi@44 | |
982 | 5354 //unsigned int v12; // ecx@56 |
0 | 5355 HANDLE v13; // eax@68 |
5356 unsigned int startms; // [sp+8h] [bp-24h]@55 | |
5357 RECT Rect; // [sp+Ch] [bp-20h]@15 | |
5358 int a2[4]; // [sp+1Ch] [bp-10h]@15 | |
522 | 5359 |
5360 IntegrityTest(); | |
246 | 5361 char test[1024]; |
522 | 5362 sprintfex(test, "^Pi[%s]: çíàõàð^R[ü;êà;]", "Çîëòàí"); |
5363 | |
1052 | 5364 bool bNoMargareth = false; |
0 | 5365 if (pCmdLine && *pCmdLine) |
5366 { | |
5367 if (wcsstr(pCmdLine, L"-usedefs")) | |
5368 bDebugResouces = 1; | |
5369 if (wcsstr(pCmdLine, L"-window")) | |
5370 dword_6BE368_debug_settings_2 |= 1u; | |
5371 | |
5372 if (wcsstr(pCmdLine, L"-nointro")) | |
5373 bNoIntro = true;//dword_6BE364_game_settings_1 |= 4; | |
5374 if (wcsstr(pCmdLine, L"-nologo")) | |
5375 bNoLogo = true;//dword_6BE364_game_settings_1 |= 8; | |
5376 if (wcsstr(pCmdLine, L"-nosound")) | |
5377 bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10; | |
5378 | |
5379 bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0; | |
5380 if (wcsstr(pCmdLine, L"-nowalksound")) | |
5381 bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20; | |
256 | 5382 if (wcsstr(pCmdLine, L"-novideo")) |
0 | 5383 { |
5384 dword_6BE364_game_settings_1 |= 0x40; | |
5385 bNoVideo = true; | |
5386 } | |
5387 if (wcsstr(pCmdLine, L"-nocd")) | |
5388 bNoCD = true; | |
168 | 5389 if (wcsstr(pCmdLine, L"-new_sky")) |
5390 new_sky = true; | |
1052 | 5391 if (wcsstr(pCmdLine, L"-nomarg")) |
5392 bNoMargareth = true; | |
0 | 5393 } |
5394 | |
5395 | |
731 | 5396 /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2); |
0 | 5397 Rect.left = *(int *)v8; |
5398 Rect.top = *(int *)(v8 + 4); | |
5399 Rect.right = *(int *)(v8 + 8); | |
5400 Rect.bottom = *(int *)(v8 + 12); | |
731 | 5401 uCPUSpeed = Rect.bottom;*/ |
5402 uCPUSpeed = 2048; // about 2GHz | |
4 | 5403 |
5404 | |
734 | 5405 if (!MM7_Initialize()) |
5406 { | |
5407 Log::Warning(L"MM init: failed"); | |
5408 pGame->Deinitialize(); | |
5409 return 1; | |
5410 } | |
5411 Log::Warning(L"MM init: ok"); | |
0 | 5412 |
5413 pEventTimer->Pause(); | |
1397 | 5414 |
373 | 5415 SetUserInterface(PartyAlignment_Neutral, false); |
0 | 5416 ShowIntroVideo_and_LoadingScreen(); |
5417 WriteWindowsRegistryInt("Ran once", 1); | |
5418 dword_6BE364_game_settings_1 |= 0x4000; | |
5419 pGame->InitializeGammaController(); | |
5420 SecondaryInitialization(); | |
709 | 5421 pRenderer->SetRasterClipRect(0, 0, 639u, 479u); |
0 | 5422 FinalInitialization(); |
5423 | |
5424 Log::Warning(L"MM: entering main loop"); | |
5425 while ( 1 ) | |
5426 { | |
165 | 5427 MainMenu_Loop(); |
982 | 5428 uGameState = GAME_STATE_PLAYING; |
0 | 5429 //LABEL_21: |
5430 while ( 1 ) | |
5431 { | |
982 | 5432 if (uGameState == GAME_FINISHED || |
5433 GetCurrentMenuID() == MENU_EXIT_GAME) | |
5434 { | |
5435 pGame->Deinitialize(); | |
5436 return true; | |
5437 } | |
5438 | |
165 | 5439 if (GetCurrentMenuID() == MENU_NEWGAME) |
0 | 5440 { |
5441 if ( pAudioPlayer->hAILRedbook ) | |
165 | 5442 AIL_redbook_stop(pAudioPlayer->hAILRedbook); |
5443 pParty->Reset(); | |
783 | 5444 pOtherOverlayList->Reset(); |
5445 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5446 strcpy(pCurrentMapName.data(), pStartingMapName.data()); |
165 | 5447 pParty->CreateDefaultParty(0); |
0 | 5448 PlayerCreationUI_Initialize(); |
165 | 5449 if ( PlayerCreationUI_Loop() ) |
0 | 5450 { |
5451 DeleteCCharFont(); | |
165 | 5452 break; |
0 | 5453 } |
5454 DeleteCCharFont(); | |
5455 bFlashQuestBook = true; | |
1397 | 5456 PlayFullscreenMovie(MOVIE_Emerald); |
5457 //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); | |
837 | 5458 SaveNewGame(); |
1052 | 5459 |
5460 if (bNoMargareth) | |
5461 _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); | |
165 | 5462 pGame->Loop(); |
982 | 5463 |
5464 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
165 | 5465 { |
5466 SetCurrentMenuID(MENU_NEWGAME); | |
982 | 5467 uGameState = GAME_STATE_PLAYING; |
165 | 5468 continue; |
5469 } | |
982 | 5470 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) |
5471 break; | |
5472 | |
5473 assert(false && "Invalid game state"); | |
165 | 5474 } |
5475 if (GetCurrentMenuID() == MENU_CREDITS) | |
0 | 5476 { |
5477 if ( pAudioPlayer->hAILRedbook ) | |
165 | 5478 AIL_redbook_stop(pAudioPlayer->hAILRedbook); |
1033 | 5479 MainMenuUI_Credits_Loop(); |
0 | 5480 break; |
5481 } | |
961 | 5482 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) |
2 | 5483 { |
982 | 5484 uGameState = GAME_STATE_PLAYING; |
2 | 5485 } |
4 | 5486 else |
961 | 5487 { |
5488 if (GetCurrentMenuID() != MENU_10) | |
0 | 5489 goto LABEL_49; |
5490 pMouse->Activate(0); | |
1038 | 5491 |
0 | 5492 pParty->Reset(); |
5493 pParty->CreateDefaultParty(1); | |
5494 crt_init_globals_46271C(); | |
5495 extern OPENFILENAMEA ofn; | |
5496 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) | |
5497 { | |
5498 pMouse->Activate(1); | |
1038 | 5499 |
0 | 5500 break; |
5501 } | |
5502 _chdir("..\\"); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5503 strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle); |
0 | 5504 pMouse->Activate(1); |
492 | 5505 } |
0 | 5506 //LABEL_48: |
165 | 5507 pGame->Loop(); |
2 | 5508 LABEL_49: |
1214
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
5509 if ( uGameState == GAME_STATE_LOADING_GAME ) |
961 | 5510 { |
982 | 5511 SetCurrentMenuID(MENU_5); |
5512 uGameState = GAME_STATE_PLAYING; | |
0 | 5513 continue; |
961 | 5514 } |
165 | 5515 if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) |
101 | 5516 { |
5517 SetCurrentMenuID(MENU_NEWGAME); | |
982 | 5518 uGameState = GAME_STATE_PLAYING; |
0 | 5519 continue; |
101 | 5520 } |
907 | 5521 if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game |
5522 { | |
0 | 5523 pAudioPlayer->StopChannels(-1, -1); |
982 | 5524 uGameState = GAME_STATE_PLAYING; |
0 | 5525 break; |
907 | 5526 } |
0 | 5527 } |
5528 if (!bNoSound && pAudioPlayer->hAILRedbook) | |
5529 { | |
328 | 5530 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
0 | 5531 AIL_redbook_stop(pAudioPlayer->hAILRedbook); |
5532 unsigned int end_ms; | |
5533 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &startms, &end_ms); | |
5534 AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); | |
5535 } | |
5536 } | |
734 | 5537 |
0 | 5538 pGame->Deinitialize(); |
734 | 5539 return 1; |
0 | 5540 } |
5541 | |
5542 //----- (004637E0) -------------------------------------------------------- | |
5543 char __cdecl sub_4637E0_is_there_popup_onscreen() | |
5544 { | |
5545 return dword_507BF0_is_there_popup_onscreen == 1; | |
5546 } | |
5547 // 507BF0: using guessed type int dword_507BF0_is_there_popup_onscreen; | |
5548 | |
5549 //----- (00466082) -------------------------------------------------------- | |
5550 void MM6_Initialize(const wchar_t *pIniFilename) | |
5551 { | |
5552 //int v0; // eax@1 | |
5553 UINT v1; // eax@18 | |
5554 size_t v2; // eax@31 | |
5555 size_t v3; // ebx@32 | |
5556 size_t v4; // edi@36 | |
5557 //char v5[120]; // [sp+Ch] [bp-17Ch]@1 | |
5558 //char String[120]; // [sp+84h] [bp-104h]@32 | |
5559 char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32 | |
5560 //char pIniFilename[120]; // [sp+10Ch] [bp-7Ch]@1 | |
5561 unsigned int v9; // [sp+184h] [bp-4h]@28 | |
5562 | |
5563 //_getcwd(v5, 120); | |
5564 //sprintfex(pIniFilename, "%s\\mm6.ini", v5); | |
5565 viewparams = new ViewingParams; | |
819 | 5566 game_viewport_x = viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename); |
5567 game_viewport_y = viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename); | |
5568 game_viewport_z = viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename); | |
5569 game_viewport_w = viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename); | |
5570 game_viewport_width = game_viewport_z - game_viewport_x; | |
5571 game_viewport_height = game_viewport_w - game_viewport_y + 1; | |
0 | 5572 |
5573 | |
5574 pAudioPlayer = new AudioPlayer; | |
5575 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename); | |
5576 if ( pAudioPlayer->uMixerChannels > 16 ) | |
5577 pAudioPlayer->uMixerChannels = 16; | |
5578 | |
5579 | |
5580 if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename)) | |
5581 dword_6BE368_debug_settings_2 |= 4; | |
5582 if (bUseRegistry) | |
5583 v1 = ReadWindowsRegistryInt("startinwindow", 0); | |
5584 else | |
5585 v1 = GetPrivateProfileIntW(L"debug", L"startinwindow", 0, pIniFilename); | |
5586 if (v1) | |
5587 dword_6BE368_debug_settings_2 |= 1; | |
5588 if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename)) | |
5589 dword_6BE368_debug_settings_2 |= 2; | |
5590 if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename)) | |
5591 dword_6BE368_debug_settings_2 |= 0x10; | |
5592 if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename)) | |
5593 dword_6BE368_debug_settings_2 |= 8; | |
5594 | |
5595 wchar_t pStartingMapNameW[1024]; | |
5596 GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5597 sprintf(pStartingMapName.data(), "%S", pStartingMapNameW); |
0 | 5598 |
5599 v9 = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5600 if ( strlen(pStartingMapName.data()) ) |
0 | 5601 { |
5602 do | |
5603 { | |
5604 if ( pStartingMapName[v9] == 32 ) | |
5605 pStartingMapName[v9] = 0; | |
5606 ++v9; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5607 v2 = strlen(pStartingMapName.data()); |
0 | 5608 } |
5609 while ( v9 < v2 ); | |
5610 } | |
5611 | |
5612 pOutdoorCamera = new OutdoorCamera; | |
5613 outdoor_day_top_r = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.r", 81, pIniFilename); | |
5614 outdoor_day_top_g = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.g", 121, pIniFilename); | |
5615 outdoor_day_top_b = GetPrivateProfileIntW(L"outdoor", L"RGBDayTop.b", 236, pIniFilename); | |
5616 outdoor_day_bottom_r = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.r", 153, pIniFilename); | |
5617 outdoor_day_bottom_g = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.g", 193, pIniFilename); | |
5618 outdoor_day_bottom_b = GetPrivateProfileIntW(L"outdoor", L"RGBDayBottom.b", 237, pIniFilename); | |
5619 outdoor_night_top_r = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.r", 0, pIniFilename); | |
5620 outdoor_night_top_g = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.g", 0, pIniFilename); | |
5621 outdoor_night_top_b = GetPrivateProfileIntW(L"outdoor", L"RGBNightTop.b", 0, pIniFilename); | |
5622 outdoor_night_bottom_r = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.r", 11, pIniFilename); | |
5623 outdoor_night_bottom_g = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.g", 41, pIniFilename); | |
5624 outdoor_night_bottom_b = GetPrivateProfileIntW(L"outdoor", L"RGBNightBottom.b", 129, pIniFilename); | |
5625 pOutdoorCamera->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename); | |
5626 pOutdoorCamera->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename); | |
5627 pOutdoorCamera->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename); | |
5628 pOutdoorCamera->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename); | |
5629 outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename); | |
5630 outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename); | |
5631 outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename); | |
5632 pOutdoorCamera->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename); | |
5633 pOutdoorCamera->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename); | |
5634 mipmapping_terrain_mm1 = GetPrivateProfileIntW(L"mipmapping", L"ter_mm1", 2048, pIniFilename); | |
5635 mipmapping_terrain_mm2 = GetPrivateProfileIntW(L"mipmapping", L"ter_mm2", 4096, pIniFilename); | |
5636 mipmapping_terrain_mm3 = GetPrivateProfileIntW(L"mipmapping", L"ter_mm3", 8192, pIniFilename); | |
5637 mipmapping_building_mm1 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm1", 1024, pIniFilename); | |
5638 mipmapping_building_mm2 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm2", 2048, pIniFilename); | |
5639 mipmapping_building_mm3 = GetPrivateProfileIntW(L"mipmapping", L"bld_mm3", 4096, pIniFilename); | |
5640 pOutdoorCamera->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename); | |
5641 pOutdoorCamera->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename); | |
5642 pOutdoorCamera->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 8192, pIniFilename); | |
5643 | |
5644 wchar_t pDefaultSkyTextureW[1024]; | |
5645 GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5646 sprintf(pDefaultSkyTexture.data(), "%S", pDefaultSkyTextureW); |
0 | 5647 |
5648 wchar_t pDefaultGroundTextureW[1024]; | |
5649 GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename); | |
5650 sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW); | |
5651 | |
5652 wchar_t pFloat[1024]; | |
5653 GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename); | |
5654 swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1); | |
5655 | |
5656 GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename); | |
5657 swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2); | |
5658 | |
5659 flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667; | |
5660 | |
5661 v3 = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5662 if ( strlen(pDefaultSkyTexture.data()) ) |
0 | 5663 { |
5664 do | |
5665 { | |
5666 if ( pDefaultSkyTexture[v3] == ' ' ) | |
5667 pDefaultSkyTexture[v3] = 0; | |
5668 ++v3; | |
5669 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5670 while ( v3 < strlen(pDefaultSkyTexture.data()) ); |
0 | 5671 } |
5672 v4 = 0; | |
5673 if ( strlen(pDefaultGroundTexture) ) | |
5674 { | |
5675 do | |
5676 { | |
5677 if ( pDefaultGroundTexture[v4] == ' ' ) | |
5678 pDefaultGroundTexture[v4] = 0; | |
5679 ++v4; | |
5680 } | |
5681 while ( v4 < strlen(pDefaultGroundTexture) ); | |
5682 } | |
5683 | |
5684 texmapping_terrain_subdivsize = GetPrivateProfileIntW(L"texmapping", L"terrain_subdivsize", 16, pIniFilename); | |
5685 texmapping_terrain_subdivpow2 = GetPrivateProfileIntW(L"texmapping", L"terrain_subdivpow2", 4, pIniFilename); | |
5686 texmapping_building_subdivsize = GetPrivateProfileIntW(L"texmapping", L"building_subdivsize", 32, pIniFilename); | |
5687 texmapping_building_subdivpow2 = GetPrivateProfileIntW(L"texmapping", L"building_subdivpow2", 5, pIniFilename); | |
5688 | |
5689 MM7Initialization(); | |
5690 } | |
5691 | |
5692 //----- (004666D5) -------------------------------------------------------- | |
5693 void __cdecl MM7Initialization() | |
5694 { | |
5695 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
5696 { | |
5697 if ( !byte_6BE388_graphicsmode ) | |
5698 { | |
5699 outdoor_grid_band_1 = 10; | |
5700 outdoor_grid_band_2 = 15; | |
5701 outdoor_grid_band_3 = 20; | |
5702 pOutdoorCamera->shading_dist_mist = 8192; | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
5703 pOutdoorCamera->bNoSky = false; |
0 | 5704 LOBYTE(viewparams->field_20) = 0; |
5705 } | |
5706 mipmapping_terrain_mm1 = 1024; | |
5707 mipmapping_terrain_mm2 = 2048; | |
5708 mipmapping_building_mm1 = 1024; | |
5709 mipmapping_building_mm2 = 2048; | |
5710 pOutdoorCamera->shading_dist_shade = 2048; | |
5711 pOutdoorCamera->terrain_gamma = 0; | |
5712 pOutdoorCamera->building_gamme = 0; | |
5713 mipmapping_terrain_mm3 = 4096; | |
5714 mipmapping_building_mm3 = 4096; | |
5715 pOutdoorCamera->shading_dist_shademist = 4096; | |
5716 pOutdoorCamera->outdoor_no_wavy_water = 0; | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
5717 //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
5718 { |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
5719 pOutdoorCamera->outdoor_grid_band_3 = outdoor_grid_band_3; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
5720 pOutdoorCamera->uPickDepth = outdoor_grid_band_3 * 512; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
5721 } |
0 | 5722 } |
5723 else | |
5724 { | |
5725 LOBYTE(viewparams->field_20) = 0; | |
5726 } | |
5727 pParty->uFlags |= 2u; | |
692 | 5728 viewparams->uSomeY = viewparams->uScreen_topL_Y; |
5729 viewparams->uSomeX = viewparams->uScreen_topL_X; | |
5730 viewparams->uSomeZ = viewparams->uScreen_BttmR_X; | |
5731 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; | |
5732 | |
5733 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y); | |
0 | 5734 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
5735 pOutdoorCamera->_485F64(); | |
5736 } | |
5737 | |
5738 //----- (00466B8C) -------------------------------------------------------- | |
5739 int __cdecl AbortWithError() | |
5740 { | |
5741 if ( !aborting_app ) | |
5742 { | |
5743 ClipCursor(0); | |
5744 aborting_app = 1; | |
5745 if ( !pRenderer->bWindowMode ) | |
5746 pRenderer->ChangeBetweenWinFullscreenModes(); | |
5747 if ( MessageBoxA(0, pGlobalTXT_LocalizationStrings[176], pGlobalTXT_LocalizationStrings[59], 0x34u) == 6 ) | |
5748 SaveGame(1, 0); // "Internal Error" | |
5749 // "Might and Magic VII has detected an internal error and will be forced to close. Would you like us to autosave your game before closing?" | |
5750 Game_DeinitializeAndTerminate(1); | |
5751 } | |
5752 return 0; | |
5753 } | |
5754 // 720018: using guessed type int aborting_app; | |
5755 | |
5756 //----- (00466BE5) -------------------------------------------------------- | |
5757 void Abortf(const char *Format, ...) | |
5758 { | |
5759 va_list va; // [sp+8h] [bp+8h]@1 | |
5760 | |
5761 va_start(va, Format); | |
5762 if ( !pRenderer->bWindowMode ) | |
5763 pRenderer->ChangeBetweenWinFullscreenModes(); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5764 vsprintf(pTmpBuf.data(), Format, va); |
0 | 5765 if ( pMouse ) |
5766 pMouse->Activate(0); | |
5767 ClipCursor(0); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
5768 MessageBoxA(0, pTmpBuf.data(), "Error", 0x30u); |
0 | 5769 Game_DeinitializeAndTerminate(1); |
5770 } | |
5771 | |
5772 //----- (00466C40) -------------------------------------------------------- | |
5773 const wchar_t *MENU_STATE_to_string(MENU_STATE m) | |
5774 { | |
5775 switch (m) | |
5776 { | |
982 | 5777 case -1: return L"-1"; |
5778 case MENU_MAIN: return L"MENU_MAIN"; | |
5779 case MENU_NEWGAME: return L"MENU_NEWGAME"; | |
5780 case MENU_CREDITS: return L"MENU_CREDITS"; | |
5781 case MENU_SAVELOAD: return L"MENU_SAVELOAD"; | |
5782 case MENU_EXIT_GAME: return L"MENU_EXIT_GAME"; | |
5783 case MENU_5: return L"MENU_5"; | |
5784 case MENU_CREATEPARTY: return L"MENU_CREATEPARTY"; | |
165 | 5785 case MENU_NAMEPANELESC: return L"MENU_NAMEPANELESC"; |
982 | 5786 case MENU_CREDITSPROC: return L"MENU_CREDITSPROC"; |
961 | 5787 case MENU_LoadingProcInMainMenu: return L"MENU_LoadingProcInMainMenu"; |
982 | 5788 case MENU_10: return L"MENU_10"; |
165 | 5789 case MENU_CREDITSCLOSE: return L"MENU_CREDITSCLOSE"; |
982 | 5790 default: return L"unk"; |
0 | 5791 }; |
5792 }; | |
5793 void SetCurrentMenuID(MENU_STATE uMenu) | |
5794 { | |
5795 uCurrentMenuID = uMenu; | |
5796 | |
5797 Log::Warning(L"CurrentMenu = %s", MENU_STATE_to_string(uMenu)); | |
5798 } | |
5799 | |
5800 //----- (00466CA0) -------------------------------------------------------- | |
5801 MENU_STATE GetCurrentMenuID() | |
5802 { | |
5803 return uCurrentMenuID; | |
5804 } | |
5805 | |
5806 // 720980: using guessed type int uTextureID_720980; | |
5807 | |
5808 // 4E28F8: using guessed type int pCurrentScreen; | |
5809 | |
5810 //----- (0046A6AC) -------------------------------------------------------- | |
5811 int __fastcall sub_46A6AC(int a1, int a2, int a3) | |
5812 { | |
5813 int result; // eax@2 | |
5814 unsigned int v4; // edx@3 | |
5815 int *v5; // esi@6 | |
5816 unsigned int v6; // ebx@6 | |
5817 signed int v7; // edi@9 | |
5818 unsigned __int16 v8; // ax@9 | |
5819 int i; // eax@14 | |
5820 int v10; // ecx@19 | |
5821 int v11; // [sp+0h] [bp-18h]@1 | |
5822 unsigned int v12; // [sp+4h] [bp-14h]@3 | |
5823 unsigned int v13; // [sp+8h] [bp-10h]@4 | |
5824 int v14; // [sp+Ch] [bp-Ch]@1 | |
5825 int *v15; // [sp+10h] [bp-8h]@4 | |
5826 int v16; // [sp+14h] [bp-4h]@3 | |
5827 | |
5828 v11 = a2; | |
5829 v14 = a1; | |
5830 if ( pRenderer->pRenderD3D ) | |
5831 { | |
5832 result = sub_46A7C8(a1, a2, a3); | |
5833 } | |
5834 else | |
5835 { | |
5836 v16 = 0; | |
692 | 5837 v4 = viewparams->uScreen_topL_X; |
5838 v12 = viewparams->uScreen_BttmR_X; | |
5839 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) | |
5840 { | |
5841 v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; | |
5842 v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1; | |
0 | 5843 do |
5844 { | |
5845 if ( (signed int)v4 < (signed int)v12 ) | |
5846 { | |
5847 v5 = v15; | |
5848 v6 = ((v12 - v4 - 1) >> 1) + 1; | |
5849 do | |
5850 { | |
848 | 5851 if ( PID_TYPE(*(char *)v5) == OBJECT_Actor) |
0 | 5852 { |
5853 if ( *v5 <= a3 << 16 ) | |
5854 { | |
848 | 5855 v7 = PID_ID((signed int)(unsigned __int16)*v5); |
0 | 5856 v8 = pActors[v7].uAIState; |
5857 if ( v8 != 5 ) | |
5858 { | |
5859 if ( v8 != 4 && v8 != 11 && v8 != 17 && v8 != 19 ) | |
5860 { | |
5861 for ( i = 0; i < v16; ++i ) | |
5862 { | |
5863 if ( *(int *)(v14 + 4 * i) == v7 ) | |
5864 break; | |
5865 } | |
5866 if ( i == v16 ) | |
5867 { | |
5868 if ( i < v11 - 1 ) | |
5869 { | |
5870 v10 = v16++; | |
5871 *(int *)(v14 + 4 * v10) = v7; | |
5872 } | |
5873 } | |
5874 } | |
5875 } | |
5876 } | |
5877 } | |
5878 v5 += 2; | |
5879 --v6; | |
5880 } | |
5881 while ( v6 ); | |
5882 } | |
5883 v15 += 1280; | |
5884 --v13; | |
5885 } | |
5886 while ( v13 ); | |
5887 } | |
5888 result = v16; | |
5889 } | |
5890 return result; | |
5891 } | |
5892 | |
5893 //----- (0046A7C8) -------------------------------------------------------- | |
5894 int __fastcall sub_46A7C8(int a1, int a2, signed int a3) | |
5895 { | |
5896 unsigned int v3; // eax@2 | |
5897 int v4; // ecx@2 | |
5898 unsigned int v5; // eax@2 | |
5899 unsigned int v6; // eax@4 | |
5900 unsigned int v7; // edi@4 | |
5901 unsigned __int16 v8; // ax@4 | |
5902 float v9; // ST00_4@9 | |
5903 int v10; // ecx@11 | |
5904 unsigned int v12; // [sp+10h] [bp-14h]@1 | |
5905 int v13; // [sp+14h] [bp-10h]@1 | |
5906 int v14; // [sp+18h] [bp-Ch]@1 | |
5907 int v15; // [sp+1Ch] [bp-8h]@1 | |
5908 unsigned int a1a; // [sp+20h] [bp-4h]@1 | |
5909 | |
5910 v13 = a1; | |
5911 v14 = a2; | |
5912 v15 = 0; | |
5913 a1a = 0; | |
5914 v12 = pRenderer->GetBillboardDrawListSize(); | |
5915 if ( (signed int)v12 > 0 ) | |
5916 { | |
5917 do | |
5918 { | |
5919 v3 = pRenderer->GetParentBillboardID(a1a); | |
5920 v4 = pBillboardRenderList[v3].sZValue; | |
194 | 5921 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; |
848 | 5922 if ( PID_TYPE(v5) == OBJECT_Actor) |
0 | 5923 { |
5924 if ( v4 <= (unsigned int)(a3 << 16) ) | |
5925 { | |
848 | 5926 v6 = PID_ID(v5); |
0 | 5927 v7 = v6; |
5928 v8 = pActors[v6].uAIState; | |
1038 | 5929 if ( v8 != Dead ) |
5930 { | |
5931 if ( v8 != Dying ) | |
5932 { | |
5933 if ( v8 != Removed ) | |
0 | 5934 { |
1038 | 5935 if ( v8 != Disabled ) |
0 | 5936 { |
1038 | 5937 if ( v8 != Summoned ) |
0 | 5938 { |
5939 v9 = (double)a3; | |
5940 if ( pGame->pVisInstance->DoesRayIntersectBillboard(v9, a1a) ) | |
5941 { | |
5942 if ( v15 < v14 - 1 ) | |
5943 { | |
5944 v10 = v15++; | |
5945 *(int *)(v13 + 4 * v10) = v7; | |
5946 } | |
5947 } | |
5948 } | |
5949 } | |
5950 } | |
5951 } | |
5952 } | |
5953 } | |
5954 } | |
5955 ++a1a; | |
5956 } | |
5957 while ( (signed int)a1a < (signed int)v12 ); | |
5958 } | |
5959 return v15; | |
5960 } | |
5961 | |
5962 //----- (0046A89E) -------------------------------------------------------- | |
5963 int __fastcall sub_46A89E(int a1, int a2, signed int a3) | |
5964 { | |
5965 signed int v3; // edi@1 | |
90 | 5966 Actor *v4; // esi@2 |
0 | 5967 int v5; // ebx@3 |
5968 int v6; // eax@3 | |
5969 int v7; // ebx@3 | |
5970 unsigned int v8; // ecx@3 | |
5971 int v9; // edx@4 | |
5972 unsigned int v10; // edx@6 | |
5973 unsigned int v11; // edx@8 | |
5974 __int16 v12; // ax@10 | |
5975 int v13; // ecx@15 | |
5976 int v15; // [sp+4h] [bp-18h]@1 | |
5977 int v16; // [sp+8h] [bp-14h]@1 | |
5978 int v17; // [sp+Ch] [bp-10h]@3 | |
5979 int v18; // [sp+10h] [bp-Ch]@3 | |
5980 int v19; // [sp+18h] [bp-4h]@1 | |
5981 | |
5982 v3 = 0; | |
5983 v15 = a2; | |
5984 v16 = a1; | |
5985 v19 = 0; | |
5986 if ( (signed int)uNumActors > 0 ) | |
5987 { | |
1202 | 5988 v4 = pActors.data();//[0].uAIState; |
0 | 5989 do |
5990 { | |
90 | 5991 v5 = abs(v4->vPosition.x - pParty->vPosition.x); |
5992 v17 = abs(v4->vPosition.y - pParty->vPosition.y); | |
5993 v18 = abs(v4->vPosition.z - pParty->vPosition.z); | |
0 | 5994 v6 = v5; |
5995 v7 = v17; | |
5996 v8 = v18; | |
5997 if ( v6 < v17 ) | |
5998 { | |
5999 v9 = v6; | |
6000 v6 = v17; | |
6001 v7 = v9; | |
6002 } | |
6003 if ( v6 < v18 ) | |
6004 { | |
6005 v10 = v6; | |
6006 v6 = v18; | |
6007 v8 = v10; | |
6008 } | |
6009 if ( v7 < (signed int)v8 ) | |
6010 { | |
6011 v11 = v8; | |
6012 v8 = v7; | |
6013 v7 = v11; | |
6014 } | |
6015 if ( (signed int)(((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6) <= a3 ) | |
6016 { | |
90 | 6017 v12 = v4->uAIState; |
6018 if ( v4->uAIState != 5 ) | |
0 | 6019 { |
6020 if ( v12 != 4 ) | |
6021 { | |
6022 if ( v12 != 11 ) | |
6023 { | |
6024 if ( v12 != 19 ) | |
6025 { | |
6026 if ( v12 != 17 ) | |
6027 { | |
6028 v13 = v19++; | |
6029 *(int *)(v16 + 4 * v13) = v3; | |
6030 if ( v19 >= v15 - 1 ) | |
6031 break; | |
6032 } | |
6033 } | |
6034 } | |
6035 } | |
6036 } | |
6037 } | |
6038 ++v3; | |
90 | 6039 ++v4; |
0 | 6040 } |
6041 while ( v3 < (signed int)uNumActors ); | |
6042 } | |
6043 return v19; | |
6044 } | |
6045 | |
6046 //----- (0046A99B) -------------------------------------------------------- | |
6047 int __cdecl sub_46A99B() | |
6048 { | |
6049 int v0; // ebx@1 | |
6050 signed int v1; // ecx@1 | |
6051 signed int v2; // esi@1 | |
6052 int v3; // edx@1 | |
6053 signed int v4; // eax@1 | |
6054 int v5; // ecx@2 | |
6055 int *v6; // eax@3 | |
6056 int v7; // ecx@3 | |
6057 int v8; // edx@5 | |
6058 int v9; // edi@6 | |
6059 unsigned __int8 v10; // zf@14 | |
6060 char v11; // sf@14 | |
6061 char v12; // of@14 | |
6062 int *v14; // esi@19 | |
6063 signed int v15; // ebx@19 | |
6064 int i; // edi@20 | |
6065 int v17; // ecx@21 | |
6066 int v18; // edi@26 | |
6067 int v19; // esi@27 | |
6068 unsigned int v20; // ecx@27 | |
6069 BLVFace *v21; // eax@32 | |
6070 unsigned int v22; // ecx@33 | |
6071 const char *v23; // eax@35 | |
6072 const char *v24; // ecx@36 | |
6073 LevelDecoration *v25; // ecx@43 | |
6074 LevelDecoration *v26; // edi@43 | |
6075 __int16 v27; // ax@43 | |
6076 int v28; // [sp+Ch] [bp-18h]@1 | |
6077 int v29; // [sp+14h] [bp-10h]@2 | |
6078 int v30; // [sp+18h] [bp-Ch]@1 | |
6079 signed int v31; // [sp+1Ch] [bp-8h]@3 | |
6080 int v32; // [sp+20h] [bp-4h]@1 | |
6081 | |
6082 v0 = 0; | |
692 | 6083 v1 = (signed int)(viewparams->uScreen_BttmR_Y + viewparams->uScreen_topL_Y) >> 1; |
6084 v2 = (signed int)(viewparams->uScreen_topL_X + viewparams->uScreen_BttmR_X) >> 1; | |
0 | 6085 v3 = v1 - 50; |
6086 v32 = 0; | |
6087 v4 = 100; | |
6088 v30 = v1 - 50; | |
6089 v28 = v1 + 50; | |
6090 if ( v1 - 50 >= v1 + 50 ) | |
6091 return 0; | |
6092 v5 = 640 * v3; | |
6093 v29 = 640 * v3; | |
6094 while ( 2 ) | |
6095 { | |
6096 v31 = 100; | |
6097 v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2]; | |
6098 v7 = v0; | |
6099 while ( 1 ) | |
6100 { | |
6101 v8 = *v6; | |
6102 --v31; | |
6103 if ( (unsigned int)*v6 <= 0x2000000 ) | |
6104 { | |
6105 v9 = 0; | |
6106 if ( v7 > 0 ) | |
6107 { | |
6108 do | |
6109 { | |
6110 if ( dword_7201B0_zvalues[v9] == (unsigned __int16)v8 ) | |
6111 break; | |
6112 ++v9; | |
6113 } | |
6114 while ( v9 < v0 ); | |
6115 } | |
6116 if ( v9 == v0 ) | |
6117 { | |
6118 if ( v8 & 7 ) | |
6119 { | |
6120 dword_720020_zvalues[v7] = v8; | |
6121 dword_7201B0_zvalues[v7] = (unsigned __int16)v8; | |
6122 ++v7; | |
6123 ++v0; | |
6124 v32 = v0; | |
6125 if ( v7 == 99 ) | |
6126 { | |
6127 v12 = 0; | |
6128 v10 = v0 == 0; | |
6129 v11 = v0 < 0; | |
6130 goto LABEL_18; | |
6131 } | |
6132 } | |
6133 } | |
6134 } | |
6135 if ( !v31 ) | |
6136 break; | |
6137 ++v6; | |
6138 } | |
6139 v4 = -1; | |
6140 ++v30; | |
6141 v5 = v29 + 640; | |
6142 v29 += 640; | |
6143 if ( v30 < v28 ) | |
6144 continue; | |
6145 break; | |
6146 } | |
6147 v12 = 0; | |
6148 v10 = v0 == 0; | |
6149 v11 = v0 < 0; | |
6150 if ( !v0 ) | |
6151 return 0; | |
6152 LABEL_18: | |
6153 if ( !((unsigned __int8)(v11 ^ v12) | v10) ) | |
6154 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1203
diff
changeset
|
6155 v14 = dword_720020_zvalues.data(); |
0 | 6156 v15 = 1; |
6157 do | |
6158 { | |
6159 for ( i = v15; i < v32; ++i ) | |
6160 { | |
6161 v17 = dword_720020_zvalues[i]; | |
6162 if ( v17 < *v14 ) | |
6163 { | |
6164 dword_720020_zvalues[i] = *v14; | |
6165 *v14 = v17; | |
6166 } | |
6167 } | |
6168 ++v15; | |
6169 ++v14; | |
6170 } | |
6171 while ( v15 - 1 < v32 ); | |
6172 v0 = v32; | |
6173 } | |
6174 v18 = 0; | |
6175 if ( v0 <= 0 ) | |
6176 return 0; | |
6177 while ( 1 ) | |
6178 { | |
6179 v19 = dword_720020_zvalues[v18] & 0xFFFF; | |
848 | 6180 v20 = PID_ID(dword_720020_zvalues[v18]); |
6181 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Item) | |
0 | 6182 { |
6183 if ( v20 >= 0x3E8 ) | |
6184 return 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6185 if ( !(pSpriteObjects[v20].uAttributes & 0x10) ) |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6186 { |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6187 v23 = pSpriteObjects[v20].stru_24.GetDisplayName(); |
0 | 6188 LABEL_36: |
6189 v24 = v23; | |
6190 goto LABEL_51; | |
6191 } | |
6192 goto LABEL_41; | |
6193 } | |
848 | 6194 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor) |
0 | 6195 { |
6196 if ( v20 >= 0xBB8 ) | |
6197 return 0; | |
6198 v24 = (const char *)&pActors[v20]; | |
6199 goto LABEL_51; | |
6200 } | |
848 | 6201 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration) |
0 | 6202 break; |
848 | 6203 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel) |
0 | 6204 { |
6205 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
6206 { | |
6207 v21 = &pIndoor->pFaces[v20]; | |
6208 if ( !(BYTE3(v21->uAttributes) & 2) ) | |
6209 goto LABEL_41; | |
6210 v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID; | |
6211 } | |
6212 else | |
6213 { | |
6214 if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels ) | |
6215 goto LABEL_41; | |
848 | 6216 v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID; |
0 | 6217 } |
6218 if ( v22 ) | |
6219 { | |
428 | 6220 v23 = GetEventHintString(v22); |
0 | 6221 if ( v23 ) |
6222 goto LABEL_36; | |
6223 } | |
6224 } | |
6225 LABEL_41: | |
6226 ++v18; | |
6227 if ( v18 >= v0 ) | |
6228 return 0; | |
6229 } | |
6230 v25 = &pLevelDecorations[v20]; | |
6231 v26 = v25; | |
6232 v27 = v25->field_16_event_id; | |
6233 if ( v27 ) | |
6234 { | |
428 | 6235 v23 = GetEventHintString(v27); |
0 | 6236 if ( !v23 ) |
6237 return v19; | |
6238 goto LABEL_36; | |
6239 } | |
6240 if ( v25->IsInteractive() ) | |
6241 v24 = pNPCTopics[stru_5E4C90._decor_events[v26->_idx_in_stru123 - 75] + 379].pTopic; | |
6242 else | |
6243 v24 = pDecorationList->pDecorations[v26->uDecorationDescID].field_20; | |
6244 LABEL_51: | |
994 | 6245 GameUI_SetFooterString(v24); |
0 | 6246 return v19; |
6247 } | |
6248 | |
6249 //----- (0046BDA8) -------------------------------------------------------- | |
6250 unsigned int __cdecl GetGravityStrength() | |
6251 { | |
6252 int v0; // eax@1 | |
6253 | |
6254 v0 = ~LOBYTE(pGame->uFlags2) & 8; | |
6255 LOBYTE(v0) = v0 | 2; | |
6256 return (unsigned int)v0 >> 1; | |
6257 } | |
6258 | |
6259 //----- (0046BDC0) -------------------------------------------------------- | |
783 | 6260 void __cdecl UpdateUserInput_and_MapSpecificStuff() |
0 | 6261 { |
6262 if ( dword_6BE364_game_settings_1 & 0x80 ) | |
6263 { | |
6264 LOBYTE(dword_6BE364_game_settings_1) = dword_6BE364_game_settings_1 & 0x7F; | |
6265 } | |
6266 else | |
6267 { | |
630 | 6268 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
0 | 6269 BLV_UpdateUserInputAndOther(); |
630 | 6270 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
0 | 6271 ODM_UpdateUserInputAndOther(); |
630 | 6272 |
783 | 6273 area_of_effect__damage_evaluate(); |
0 | 6274 } |
6275 } | |
6276 | |
6277 //----- (0046BFFA) -------------------------------------------------------- | |
6278 bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2) | |
6279 { | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6280 SpriteObject *v2; // esi@1 |
0 | 6281 ObjectDesc *v3; // ebx@1 |
6282 unsigned __int16 v5; // cx@9 | |
6283 unsigned __int16 v6; // cx@14 | |
6284 signed int v7; // edx@14 | |
6285 unsigned int v8; // eax@19 | |
6286 unsigned int v9; // edi@19 | |
6287 signed int v10; // ebx@19 | |
6288 char *v11; // edx@20 | |
6289 unsigned __int16 v12; // ax@23 | |
6290 int v13; // eax@27 | |
6291 unsigned int v14; // ebx@33 | |
6292 unsigned __int16 v15; // ax@35 | |
6293 int v16; // eax@36 | |
6294 unsigned int v17; // eax@37 | |
6295 __int16 v18; // di@37 | |
6296 signed int v19; // edx@37 | |
6297 unsigned __int8 v20; // sf@37 | |
6298 char *v21; // ecx@38 | |
6299 unsigned __int16 v22; // ax@41 | |
6300 unsigned int v23; // eax@46 | |
6301 signed int v24; // ebx@46 | |
6302 char *v25; // edx@47 | |
6303 int v26; // edx@54 | |
6304 int v27; // edx@55 | |
6305 int v28; // edx@56 | |
6306 int v29; // edx@57 | |
6307 unsigned __int16 v30; // ax@60 | |
6308 unsigned int v31; // ecx@60 | |
6309 int v32; // edi@60 | |
6310 unsigned int v33; // eax@65 | |
6311 signed int v34; // edx@65 | |
6312 char *v35; // ecx@66 | |
6313 unsigned __int16 v36; // ax@69 | |
6314 int v37; // ST14_4@72 | |
6315 int v38; // eax@72 | |
6316 int v39; // ST10_4@72 | |
6317 int v40; // ST0C_4@72 | |
6318 int v41; // edx@76 | |
6319 int v42; // edx@77 | |
6320 int v43; // edx@78 | |
6321 unsigned __int8 v44; // zf@79 | |
6322 int v45; // edx@79 | |
6323 unsigned __int16 v46; // ax@80 | |
6324 int v47; // eax@81 | |
6325 int v48; // edx@87 | |
6326 int v49; // edx@88 | |
6327 int v50; // edx@89 | |
6328 unsigned int v51; // eax@93 | |
6329 signed int v52; // ebx@93 | |
6330 char *v53; // edx@94 | |
6331 unsigned __int16 v54; // ax@98 | |
6332 unsigned int v55; // ecx@98 | |
6333 signed int v56; // ebx@98 | |
6334 char *v57; // edx@99 | |
6335 unsigned __int16 v58; // ax@102 | |
6336 unsigned __int16 v59; // ax@107 | |
6337 unsigned int v60; // ecx@107 | |
6338 signed int v61; // ebx@107 | |
6339 char *v62; // edx@108 | |
6340 unsigned __int16 v63; // ax@111 | |
6341 int v64; // ebx@114 | |
6342 signed int v65; // eax@114 | |
6343 unsigned int v66; // edi@123 | |
6344 unsigned __int16 v67; // ax@124 | |
6345 unsigned int v68; // ecx@124 | |
6346 signed int v69; // ebx@124 | |
6347 char *v70; // edx@125 | |
6348 unsigned __int16 v71; // ax@128 | |
6349 unsigned int v72; // ebx@131 | |
6350 int v73; // ST14_4@132 | |
6351 int v74; // ST10_4@132 | |
6352 int v75; // ebx@132 | |
6353 int v76; // ST0C_4@132 | |
6354 unsigned __int16 v77; // ax@132 | |
6355 int v78; // eax@133 | |
6356 char v79; // zf@139 | |
6357 unsigned int v80; // eax@140 | |
6358 signed int v81; // edx@140 | |
6359 char *v82; // ecx@141 | |
6360 unsigned __int16 v83; // ax@144 | |
6361 unsigned __int16 v84; // ax@151 | |
6362 unsigned int v85; // ecx@151 | |
6363 signed int v86; // ebx@151 | |
6364 char *v87; // edx@152 | |
6365 unsigned __int16 v88; // ax@155 | |
6366 unsigned int v89; // eax@158 | |
6367 int v90; // ST34_4@159 | |
6368 int v91; // eax@159 | |
6369 unsigned int v92; // eax@163 | |
6370 unsigned int v93; // eax@177 | |
6371 char *v94; // ecx@178 | |
6372 unsigned __int16 v95; // ax@181 | |
6373 unsigned __int16 v96; // ax@184 | |
6374 int v97; // eax@185 | |
6375 unsigned __int16 v98; // ax@191 | |
6376 unsigned int v99; // ecx@191 | |
6377 char v100; // ST18_1@198 | |
6378 int v101; // ST14_4@198 | |
6379 int v102; // eax@198 | |
6380 int v103; // ST10_4@198 | |
6381 int v104; // ST0C_4@198 | |
6382 unsigned __int16 v105; // ax@200 | |
6383 signed int v106; // eax@208 | |
6384 unsigned int v107; // edx@220 | |
6385 signed int v108; // ebx@225 | |
6386 unsigned int v109; // eax@234 | |
6387 signed int v110; // ebx@234 | |
6388 char *v111; // ecx@235 | |
6389 unsigned __int16 v112; // ax@238 | |
6390 unsigned __int16 v113; // si@241 | |
6391 int v114; // eax@242 | |
6392 int v115; // eax@245 | |
6393 signed int v116; // eax@245 | |
6394 unsigned __int16 v117; // ax@251 | |
6395 unsigned int v118; // ecx@251 | |
6396 signed int v119; // ebx@251 | |
6397 char *v120; // edx@252 | |
6398 unsigned __int16 v121; // ax@255 | |
6399 unsigned int v122; // eax@260 | |
6400 char *v123; // edx@261 | |
6401 int v124; // eax@267 | |
6402 int v125; // [sp-20h] [bp-4Ch]@28 | |
6403 signed int v126; // [sp-1Ch] [bp-48h]@27 | |
6404 unsigned int v127; // [sp-18h] [bp-44h]@27 | |
6405 signed int v128; // [sp-14h] [bp-40h]@27 | |
6406 signed int v129; // [sp-10h] [bp-3Ch]@27 | |
6407 int v130; // [sp-Ch] [bp-38h]@27 | |
6408 unsigned int v131; // [sp-8h] [bp-34h]@27 | |
6409 char v132; // [sp-8h] [bp-34h]@131 | |
6410 int v133; // [sp-4h] [bp-30h]@27 | |
6411 char v134; // [sp-4h] [bp-30h]@131 | |
6412 signed int v135; // [sp-4h] [bp-30h]@217 | |
6413 int v136; // [sp+Ch] [bp-20h]@208 | |
6414 int v137; // [sp+10h] [bp-1Ch]@208 | |
6415 signed int v138; // [sp+14h] [bp-18h]@207 | |
6416 signed int v139; // [sp+18h] [bp-14h]@208 | |
6417 char *v140; // [sp+1Ch] [bp-10h]@61 | |
6418 signed int v141; // [sp+1Ch] [bp-10h]@117 | |
6419 unsigned int v142; // [sp+1Ch] [bp-10h]@158 | |
6420 signed int v143; // [sp+1Ch] [bp-10h]@172 | |
6421 char *v144; // [sp+1Ch] [bp-10h]@192 | |
6422 signed int v145; // [sp+20h] [bp-Ch]@1 | |
6423 signed int v146; // [sp+20h] [bp-Ch]@60 | |
6424 int v147; // [sp+20h] [bp-Ch]@72 | |
6425 signed int v148; // [sp+20h] [bp-Ch]@158 | |
6426 int v149; // [sp+20h] [bp-Ch]@198 | |
6427 unsigned __int16 v150; // [sp+20h] [bp-Ch]@208 | |
6428 int v151; // [sp+24h] [bp-8h]@1 | |
6429 signed int v152; // [sp+24h] [bp-8h]@208 | |
6430 unsigned int v153; // [sp+28h] [bp-4h]@1 | |
6431 | |
6432 v153 = uLayingItemID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6433 v2 = &pSpriteObjects[uLayingItemID]; |
0 | 6434 v3 = &pObjectList->pObjects[v2->uObjectDescID]; |
6435 v145 = a2; | |
848 | 6436 v151 = PID_TYPE(a2); |
6437 if ( PID_TYPE(a2) == OBJECT_Actor) | |
6438 { | |
6439 if ( PID_TYPE(v2->spell_caster_pid) == OBJECT_Actor && !pActors[PID_ID(v2->spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) ) | |
0 | 6440 return 1; |
6441 } | |
6442 else | |
6443 { | |
848 | 6444 if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(v2->spell_caster_pid) == OBJECT_Player) |
0 | 6445 return 1; |
6446 } | |
6447 if ( pParty->bTurnBasedModeOn == 1 ) | |
6448 { | |
6449 v5 = v2->uAttributes; | |
6450 if ( v5 & 4 ) | |
6451 { | |
6452 --pTurnEngine->field_1C; | |
6453 v2->uAttributes = v5 & 0xFFFB; | |
6454 } | |
6455 } | |
848 | 6456 if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player) |
1280 | 6457 { |
6458 if (PID_ID(v2->spell_caster_pid)<500) //bugfix PID_ID(v2->spell_caster_pid)==1000 | |
6459 BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4; | |
6460 } | |
6461 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6462 v6 = v2->uType; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6463 v7 = v2->uType; |
0 | 6464 if ( v7 > 3060 ) |
6465 { | |
6466 if ( v7 > 6090 ) | |
6467 { | |
6468 if ( v7 > 8090 ) | |
6469 { | |
6470 if ( v7 == 9010 ) | |
6471 goto LABEL_247; | |
6472 if ( v7 != 9030 ) | |
6473 { | |
6474 if ( v7 != 9040 ) | |
6475 { | |
6476 if ( v7 != 9080 ) | |
6477 return 0; | |
6478 LABEL_191: | |
6479 v98 = v6 + 1; | |
6480 v99 = pObjectList->uNumObjects; | |
6481 v32 = 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6482 v2->uType = v98; |
0 | 6483 v146 = 0; |
6484 if ( (signed int)v99 > 0 ) | |
6485 { | |
6486 v144 = (char *)&pObjectList->pObjects->uObjectID; | |
6487 while ( v98 != *(short *)v144 ) | |
6488 { | |
6489 ++v146; | |
6490 v144 += 56; | |
6491 if ( v146 >= (signed int)v99 ) | |
6492 goto LABEL_195; | |
6493 } | |
6494 goto LABEL_80; | |
6495 } | |
6496 LABEL_195: | |
6497 v46 = 0; | |
6498 goto LABEL_196; | |
6499 } | |
6500 goto LABEL_93; | |
6501 } | |
6502 LABEL_172: | |
6503 v143 = 17030; | |
6504 switch ( v6 ) | |
6505 { | |
6506 case 0x1798u: | |
6507 v143 = 15040; | |
6508 break; | |
6509 case 0xFAAu: | |
6510 v143 = 13010; | |
6511 break; | |
6512 case 0x2346u: | |
6513 v143 = 18030; | |
6514 break; | |
6515 } | |
6516 v138 = 1; | |
141 | 6517 if ( v151 != OBJECT_Actor) |
0 | 6518 { |
822 | 6519 if ( v6 != 9030 || v2->spell_skill != 4 ) |
0 | 6520 goto LABEL_246; |
1119 | 6521 v2->_46BEF1_apply_spells_aoe(); |
0 | 6522 LABEL_233: |
6523 if ( !v138 ) | |
6524 { | |
6525 v109 = pObjectList->uNumObjects; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6526 ++v2->uType; |
0 | 6527 v110 = 0; |
6528 if ( (signed int)v109 <= 0 ) | |
6529 { | |
6530 LABEL_238: | |
6531 v112 = 0; | |
6532 } | |
6533 else | |
6534 { | |
6535 v111 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6536 while ( v2->uType != *(short *)v111 ) |
0 | 6537 { |
6538 ++v110; | |
6539 v111 += 56; | |
6540 if ( v110 >= (signed int)v109 ) | |
6541 goto LABEL_238; | |
6542 } | |
6543 v112 = v110; | |
6544 } | |
6545 v2->uObjectDescID = v112; | |
6546 if ( !v112 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6547 SpriteObject::OnInteraction(v153); |
0 | 6548 v2->vVelocity.z = 0; |
6549 v2->vVelocity.y = 0; | |
6550 v2->vVelocity.x = 0; | |
6551 v2->uSpriteFrameID = 0; | |
6552 v113 = v2->uSoundID; | |
6553 if ( v113 ) | |
6554 v114 = (signed __int16)v113 + 4; | |
6555 else | |
6556 v114 = 0; | |
6557 v133 = 0; | |
6558 v131 = 0; | |
6559 v130 = v114; | |
6560 v115 = 8 * v153; | |
6561 v129 = 0; | |
6562 v128 = -1; | |
862 | 6563 LOBYTE(v115) = PID(OBJECT_Item,v153); |
0 | 6564 v127 = 0; |
6565 v126 = v115; | |
6566 v116 = v143; | |
6567 goto LABEL_269; | |
6568 } | |
6569 LABEL_246: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6570 SpriteObject::OnInteraction(v153); |
0 | 6571 return 0; |
6572 } | |
6573 v106 = v145; | |
6574 v150 = 0; | |
848 | 6575 v139 = PID_ID(v106); |
822 | 6576 v137 = v2->spell_level; |
6577 v152 = v2->spell_skill; | |
6578 v136 = v2->spell_id; | |
0 | 6579 if ( v6 == 9030 ) |
6580 { | |
6581 v150 = 2; | |
6582 if ( v152 == 2 ) | |
6583 { | |
6584 v150 = 3; | |
6585 } | |
6586 else | |
6587 { | |
6588 if ( v152 >= 3 ) | |
6589 v150 = 4; | |
6590 } | |
6591 BYTE2(pActors[v139].uAttributes) |= 8u; | |
6592 } | |
6593 if ( v7 == 6040 ) | |
6594 { | |
6595 v135 = 7; | |
6596 } | |
6597 else | |
6598 { | |
6599 if ( v7 == 8030 ) | |
6600 { | |
6601 v135 = 9; | |
6602 } | |
6603 else | |
6604 { | |
6605 if ( v7 != 9030 ) | |
6606 { | |
6607 v107 = v136; | |
6608 LABEL_222: | |
6609 if ( v6 != 9030 || v152 != 4 ) | |
6610 { | |
6611 v108 = v139; | |
6612 if ( stru_50C198.GetMagicalResistance(&pActors[v139], v107) ) | |
6613 { | |
6614 v138 = 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6615 if ( v2->uType == 8030 ) |
0 | 6616 { |
6617 pActors[v108].uAIState = Standing; | |
6618 pActors[v108].UpdateAnimation(); | |
6619 } | |
90 | 6620 pActors[v108].pActorBuffs[v136].Apply( |
0 | 6621 pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335), |
6622 v152, | |
6623 v150, | |
6624 0, | |
6625 0); | |
6626 } | |
6627 } | |
6628 else | |
6629 { | |
1119 | 6630 v2->_46BEF1_apply_spells_aoe(); |
0 | 6631 } |
822 | 6632 v2->spell_level = 0; |
6633 v2->spell_skill = 0; | |
6634 v2->spell_id = 0; | |
0 | 6635 goto LABEL_233; |
6636 } | |
6637 v135 = 10; | |
6638 } | |
6639 } | |
6640 v107 = v135; | |
6641 goto LABEL_222; | |
6642 } | |
6643 if ( v7 == 8090 || v7 == 7030 || v7 == 7090 || v7 == 8000 ) | |
6644 goto LABEL_93; | |
6645 if ( v7 == 8010 ) | |
6646 { | |
6647 if ( v151 == 3 | |
848 | 6648 && MonsterStats::BelongsToSupertype(pActors[PID_ID(v145)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) |
0 | 6649 sub_43A97E(v153, v145); |
6650 v93 = pObjectList->uNumObjects; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6651 ++v2->uType; |
0 | 6652 v9 = 0; |
6653 v52 = 0; | |
6654 if ( (signed int)v93 > 0 ) | |
6655 { | |
6656 v94 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6657 while ( v2->uType != *(short *)v94 ) |
0 | 6658 { |
6659 ++v52; | |
6660 v94 += 56; | |
6661 if ( v52 >= (signed int)v93 ) | |
6662 goto LABEL_181; | |
6663 } | |
6664 goto LABEL_202; | |
6665 } | |
6666 goto LABEL_181; | |
6667 } | |
6668 v79 = v7 == 8030; | |
6669 } | |
6670 else | |
6671 { | |
6672 if ( v7 == 6090 ) | |
6673 goto LABEL_93; | |
6674 if ( v7 <= 4070 ) | |
6675 { | |
6676 if ( v7 != 4070 ) | |
6677 { | |
6678 v48 = v7 - 3090; | |
6679 if ( v48 ) | |
6680 { | |
6681 v49 = v48 - 2; | |
6682 if ( v49 ) | |
6683 { | |
6684 v50 = v49 - 908; | |
6685 if ( !v50 ) | |
6686 goto LABEL_93; | |
6687 v45 = v50 - 30; | |
6688 v44 = v45 == 0; | |
6689 goto LABEL_91; | |
6690 } | |
6691 v54 = v6 - 1; | |
6692 v55 = pObjectList->uNumObjects; | |
6693 v9 = 0; | |
6694 v56 = 0; | |
6695 v44 = pObjectList->uNumObjects == 0; | |
6696 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6697 v2->uType = v54; |
0 | 6698 if ( v20 | v44 ) |
6699 { | |
6700 LABEL_102: | |
6701 v58 = 0; | |
6702 } | |
6703 else | |
6704 { | |
6705 v57 = (char *)&pObjectList->pObjects->uObjectID; | |
6706 while ( v54 != *(short *)v57 ) | |
6707 { | |
6708 ++v56; | |
6709 v57 += 56; | |
6710 if ( v56 >= (signed int)v55 ) | |
6711 goto LABEL_102; | |
6712 } | |
6713 v58 = v56; | |
6714 } | |
6715 v2->uObjectDescID = v58; | |
6716 if ( !v58 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6717 SpriteObject::OnInteraction(v153); |
0 | 6718 v14 = v153; |
6719 v2->vVelocity.z = 0; | |
6720 v2->vVelocity.y = 0; | |
6721 v2->vVelocity.x = 0; | |
6722 v2->uSpriteFrameID = 0; | |
6723 sub_43A97E(v153, v145); | |
6724 LABEL_35: | |
6725 v15 = v2->uSoundID; | |
6726 if ( v15 == (short)v9 ) | |
6727 v16 = 0; | |
6728 else | |
6729 v16 = (signed __int16)v15 + 4; | |
6730 v133 = v9; | |
6731 v131 = v9; | |
6732 v130 = v16; | |
6733 v92 = v14; | |
6734 LABEL_267: | |
6735 v124 = 8 * v92; | |
6736 v129 = v9; | |
6737 v128 = -1; | |
6738 LOBYTE(v124) = v124 | 2; | |
6739 v127 = v9; | |
6740 v126 = v124; | |
6741 LABEL_268: | |
1319 | 6742 v116 = word_4EE088_sound_ids[v2->spell_id - 1]; |
0 | 6743 LABEL_269: |
6744 v125 = v116 + 1; | |
6745 goto LABEL_29; | |
6746 } | |
6747 v59 = v6 + 2; | |
6748 v60 = pObjectList->uNumObjects; | |
6749 v9 = 0; | |
6750 v61 = 0; | |
6751 v44 = pObjectList->uNumObjects == 0; | |
6752 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6753 v2->uType = v59; |
0 | 6754 if ( v20 | v44 ) |
6755 { | |
6756 LABEL_111: | |
6757 v63 = 0; | |
6758 } | |
6759 else | |
6760 { | |
6761 v62 = (char *)&pObjectList->pObjects->uObjectID; | |
6762 while ( v59 != *(short *)v62 ) | |
6763 { | |
6764 ++v61; | |
6765 v62 += 56; | |
6766 if ( v61 >= (signed int)v60 ) | |
6767 goto LABEL_111; | |
6768 } | |
6769 v63 = v61; | |
6770 } | |
6771 v2->uObjectDescID = v63; | |
6772 if ( !v63 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6773 SpriteObject::OnInteraction(v153); |
0 | 6774 v64 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; |
822 | 6775 v44 = v2->spell_skill == 4; |
0 | 6776 v2->vVelocity.z = 0; |
6777 v2->vVelocity.y = 0; | |
6778 v2->vVelocity.x = 0; | |
6779 v65 = 7; | |
6780 if ( v44 ) | |
6781 v65 = 9; | |
6782 if ( v65 > 0 ) | |
6783 { | |
6784 v141 = v65; | |
6785 do | |
6786 { | |
6787 v64 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1; | |
6788 v2->Create(v64, 0, 1000, 0); | |
6789 --v141; | |
6790 } | |
6791 while ( v141 ); | |
6792 } | |
6793 LABEL_160: | |
6794 v14 = v153; | |
6795 LABEL_34: | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6796 SpriteObject::OnInteraction(v14); |
0 | 6797 goto LABEL_35; |
6798 } | |
6799 if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) ) | |
6800 return 1; | |
6801 v67 = v6 + 1; | |
6802 v68 = pObjectList->uNumObjects; | |
6803 v69 = 0; | |
6804 v44 = pObjectList->uNumObjects == 0; | |
6805 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6806 v2->uType = v67; |
0 | 6807 if ( v20 | v44 ) |
6808 { | |
6809 LABEL_128: | |
6810 v71 = 0; | |
6811 } | |
6812 else | |
6813 { | |
6814 v70 = (char *)&pObjectList->pObjects->uObjectID; | |
6815 while ( v67 != *(short *)v70 ) | |
6816 { | |
6817 ++v69; | |
6818 v70 += 56; | |
6819 if ( v69 >= (signed int)v68 ) | |
6820 goto LABEL_128; | |
6821 } | |
6822 v71 = v69; | |
6823 } | |
6824 v2->uObjectDescID = v71; | |
6825 if ( !v71 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6826 SpriteObject::OnInteraction(v153); |
0 | 6827 v134 = 0; |
6828 v72 = v153; | |
6829 v132 = 0; | |
6830 LABEL_132: | |
6831 v73 = v2->vPosition.z; | |
6832 v74 = v2->vPosition.y; | |
862 | 6833 v75 = PID(OBJECT_Item,v72); |
0 | 6834 v2->vVelocity.z = v66; |
6835 v2->vVelocity.y = v66; | |
6836 v76 = v2->vPosition.x; | |
6837 v2->vVelocity.x = v66; | |
6838 v2->uSpriteFrameID = v66; | |
6839 stru_50FE08.Add(v75, 512, v76, v74, v73, v132, v134); | |
6840 v77 = v2->uSoundID; | |
6841 if ( v77 == (short)v66 ) | |
6842 v78 = 0; | |
6843 else | |
6844 v78 = (signed __int16)v77 + 4; | |
6845 v133 = v66; | |
6846 v131 = v66; | |
6847 v130 = v78; | |
6848 v129 = v66; | |
6849 v128 = -1; | |
6850 v127 = v66; | |
6851 v126 = v75; | |
6852 goto LABEL_268; | |
6853 } | |
6854 if ( v7 == 4090 ) | |
6855 { | |
6856 v84 = v6 + 2; | |
6857 v85 = pObjectList->uNumObjects; | |
6858 v9 = 0; | |
6859 v86 = 0; | |
6860 v44 = pObjectList->uNumObjects == 0; | |
6861 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6862 v2->uType = v84; |
0 | 6863 if ( v20 | v44 ) |
6864 { | |
6865 LABEL_155: | |
6866 v88 = 0; | |
6867 } | |
6868 else | |
6869 { | |
6870 v87 = (char *)&pObjectList->pObjects->uObjectID; | |
6871 while ( v84 != *(short *)v87 ) | |
6872 { | |
6873 ++v86; | |
6874 v87 += 56; | |
6875 if ( v86 >= (signed int)v85 ) | |
6876 goto LABEL_155; | |
6877 } | |
6878 v88 = v86; | |
6879 } | |
6880 v2->uObjectDescID = v88; | |
6881 if ( !v88 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6882 SpriteObject::OnInteraction(v153); |
0 | 6883 v89 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; |
6884 v2->vVelocity.z = 0; | |
6885 v2->vVelocity.y = 0; | |
6886 v2->vVelocity.x = 0; | |
6887 v142 = v89; | |
6888 v148 = 7; | |
6889 do | |
6890 { | |
6891 pRnd->SetRange(-128, 128); | |
6892 v90 = pRnd->GetInRange(); | |
6893 pRnd->SetRange(5, 500); | |
6894 v91 = pRnd->GetInRange(); | |
6895 v142 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1; | |
6896 v2->Create(v90 + v142, 0, v91, 0); | |
6897 --v148; | |
6898 } | |
6899 while ( v148 ); | |
6900 goto LABEL_160; | |
6901 } | |
6902 if ( v7 == 4092 ) | |
6903 { | |
6904 v80 = pObjectList->uNumObjects; | |
6905 v66 = 0; | |
6906 v81 = 0; | |
6907 v44 = pObjectList->uNumObjects == 0; | |
6908 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6909 v2->uType = 4091; |
0 | 6910 if ( v20 | v44 ) |
6911 { | |
6912 LABEL_144: | |
6913 v83 = 0; | |
6914 } | |
6915 else | |
6916 { | |
6917 v82 = (char *)&pObjectList->pObjects->uObjectID; | |
6918 while ( *(short *)v82 != 4091 ) | |
6919 { | |
6920 ++v81; | |
6921 v82 += 56; | |
6922 if ( v81 >= (signed int)v80 ) | |
6923 goto LABEL_144; | |
6924 } | |
6925 v83 = v81; | |
6926 } | |
6927 v2->uObjectDescID = v83; | |
6928 if ( !v83 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6929 SpriteObject::OnInteraction(v153); |
0 | 6930 v134 = 0; |
6931 v72 = v153; | |
6932 v132 = v2->field_61; | |
6933 goto LABEL_132; | |
6934 } | |
6935 if ( v7 == 4100 || v7 == 6010 ) | |
6936 goto LABEL_93; | |
6937 v79 = v7 == 6040; | |
6938 } | |
6939 if ( !v79 ) | |
6940 return 0; | |
6941 goto LABEL_172; | |
6942 } | |
6943 if ( v7 == 3060 ) | |
6944 goto LABEL_93; | |
6945 if ( v7 <= 555 ) | |
6946 { | |
6947 if ( v7 == 555 ) | |
6948 { | |
6949 sub_43A97E(v153, v145); | |
6950 v23 = pObjectList->uNumObjects; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6951 ++v2->uType; |
0 | 6952 v18 = 0; |
6953 v24 = 0; | |
6954 if ( (signed int)v23 <= 0 ) | |
6955 { | |
6956 LABEL_41: | |
6957 v22 = 0; | |
6958 } | |
6959 else | |
6960 { | |
6961 v25 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6962 while ( v2->uType != *(short *)v25 ) |
0 | 6963 { |
6964 ++v24; | |
6965 v25 += 56; | |
6966 if ( v24 >= (signed int)v23 ) | |
6967 goto LABEL_41; | |
6968 } | |
6969 v22 = v24; | |
6970 } | |
6971 LABEL_42: | |
6972 v2->uObjectDescID = v22; | |
6973 if ( v22 == v18 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6974 SpriteObject::OnInteraction(v153); |
0 | 6975 v2->vVelocity.z = v18; |
6976 v2->vVelocity.y = v18; | |
6977 v2->vVelocity.x = v18; | |
6978 v2->uSpriteFrameID = v18; | |
6979 } | |
6980 else | |
6981 { | |
6982 switch ( v7 ) | |
6983 { | |
6984 case 500: | |
6985 case 505: | |
6986 case 510: | |
6987 case 515: | |
6988 case 520: | |
6989 case 525: | |
6990 case 530: | |
6991 case 535: | |
6992 case 540: | |
6993 sub_43A97E(v153, v145); | |
6994 v8 = pObjectList->uNumObjects; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
6995 ++v2->uType; |
0 | 6996 v9 = 0; |
6997 v10 = 0; | |
6998 if ( (signed int)v8 <= 0 ) | |
6999 goto LABEL_23; | |
7000 v11 = (char *)&pObjectList->pObjects->uObjectID; | |
7001 break; | |
7002 case 545: | |
7003 case 550: | |
377 | 7004 if ( v2->stru_24.uItemID != 405 && v2->stru_24.uSpecEnchantmentType != 3 ) |
0 | 7005 { |
7006 v14 = v153; | |
7007 v9 = 0; | |
7008 v2->vVelocity.z = 0; | |
7009 v2->vVelocity.y = 0; | |
7010 v2->vVelocity.x = 0; | |
7011 v2->uSpriteFrameID = 0; | |
7012 sub_43A97E(v153, v145); | |
7013 goto LABEL_34; | |
7014 } | |
7015 v17 = pObjectList->uNumObjects; | |
7016 v18 = 0; | |
7017 v19 = 0; | |
7018 v44 = pObjectList->uNumObjects == 0; | |
7019 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7020 v2->uType = 600; |
0 | 7021 if ( v20 | v44 ) |
7022 goto LABEL_41; | |
7023 v21 = (char *)&pObjectList->pObjects->uObjectID; | |
7024 while ( *(short *)v21 != 600 ) | |
7025 { | |
7026 ++v19; | |
7027 v21 += 56; | |
7028 if ( v19 >= (signed int)v17 ) | |
7029 goto LABEL_41; | |
7030 } | |
7031 v22 = v19; | |
7032 goto LABEL_42; | |
7033 default: | |
7034 return 0; | |
7035 } | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7036 while ( v2->uType != *(short *)v11 ) |
0 | 7037 { |
7038 ++v10; | |
7039 v11 += 56; | |
7040 if ( v10 >= (signed int)v8 ) | |
7041 { | |
7042 LABEL_23: | |
7043 v12 = 0; | |
7044 goto LABEL_24; | |
7045 } | |
7046 } | |
7047 v12 = v10; | |
7048 LABEL_24: | |
7049 v2->uObjectDescID = v12; | |
7050 if ( !v12 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7051 SpriteObject::OnInteraction(v153); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7052 v44 = v2->uType == 555; |
0 | 7053 v2->vVelocity.z = 0; |
7054 v2->vVelocity.y = 0; | |
7055 v2->vVelocity.x = 0; | |
7056 v2->uSpriteFrameID = 0; | |
7057 if ( !v44 ) | |
7058 goto LABEL_27; | |
7059 } | |
7060 return 0; | |
7061 } | |
7062 if ( v7 > 1100 ) | |
7063 { | |
7064 v41 = v7 - 2030; | |
7065 if ( !v41 ) | |
7066 goto LABEL_247; | |
7067 v42 = v41 - 30; | |
7068 if ( v42 ) | |
7069 { | |
7070 v43 = v42 - 40; | |
7071 if ( !v43 ) | |
7072 goto LABEL_59; | |
7073 v45 = v43 - 910; | |
7074 v44 = v45 == 0; | |
7075 LABEL_91: | |
7076 if ( !v44 && v45 != 20 ) | |
7077 return 0; | |
7078 } | |
7079 LABEL_93: | |
7080 sub_43A97E(v153, v145); | |
7081 v51 = pObjectList->uNumObjects; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7082 ++v2->uType; |
0 | 7083 v9 = 0; |
7084 v52 = 0; | |
7085 if ( (signed int)v51 > 0 ) | |
7086 { | |
7087 v53 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7088 while ( v2->uType != *(short *)v53 ) |
0 | 7089 { |
7090 ++v52; | |
7091 v53 += 56; | |
7092 if ( v52 >= (signed int)v51 ) | |
7093 goto LABEL_181; | |
7094 } | |
7095 goto LABEL_202; | |
7096 } | |
7097 LABEL_181: | |
7098 v95 = 0; | |
7099 LABEL_182: | |
7100 v2->uObjectDescID = v95; | |
7101 if ( v95 == (short)v9 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7102 SpriteObject::OnInteraction(v153); |
0 | 7103 v96 = v2->uSoundID; |
7104 v2->vVelocity.z = v9; | |
7105 v2->vVelocity.y = v9; | |
7106 v2->vVelocity.x = v9; | |
7107 v2->uSpriteFrameID = v9; | |
7108 if ( v96 == (short)v9 ) | |
7109 v97 = 0; | |
7110 else | |
7111 v97 = (signed __int16)v96 + 4; | |
7112 v133 = v9; | |
7113 v131 = v9; | |
7114 v130 = v97; | |
7115 v92 = v153; | |
7116 goto LABEL_267; | |
7117 } | |
7118 if ( v7 == 1100 ) | |
7119 goto LABEL_93; | |
7120 v26 = v7 - 600; | |
7121 if ( !v26 ) | |
7122 { | |
7123 v33 = pObjectList->uNumObjects; | |
7124 v34 = 0; | |
7125 v44 = pObjectList->uNumObjects == 0; | |
7126 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7127 v2->uType = 601; |
0 | 7128 if ( v20 | v44 ) |
7129 { | |
7130 LABEL_69: | |
7131 v36 = 0; | |
7132 } | |
7133 else | |
7134 { | |
7135 v35 = (char *)&pObjectList->pObjects->uObjectID; | |
7136 while ( *(short *)v35 != 601 ) | |
7137 { | |
7138 ++v34; | |
7139 v35 += 56; | |
7140 if ( v34 >= (signed int)v33 ) | |
7141 goto LABEL_69; | |
7142 } | |
7143 v36 = v34; | |
7144 } | |
7145 v2->uObjectDescID = v36; | |
7146 if ( !v36 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7147 SpriteObject::OnInteraction(v153); |
0 | 7148 v37 = v2->vPosition.z; |
7149 v2->vVelocity.z = 0; | |
7150 v38 = 8 * v153; | |
7151 v39 = v2->vPosition.y; | |
862 | 7152 LOBYTE(v38) = PID(OBJECT_Item,v153); |
0 | 7153 v2->vVelocity.y = 0; |
7154 v2->vVelocity.x = 0; | |
7155 v40 = v2->vPosition.x; | |
7156 v2->uSpriteFrameID = 0; | |
7157 v147 = v38; | |
7158 stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0); | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
7159 if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
7160 trail_particle_generator.GenerateTrailParticles(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v3->uParticleTrailColor); |
0 | 7161 v133 = 0; |
7162 v131 = 0; | |
7163 v130 = 0; | |
7164 v129 = 0; | |
7165 v128 = -1; | |
7166 v127 = 0; | |
7167 v126 = v147; | |
7168 goto LABEL_28; | |
7169 } | |
7170 v27 = v26 - 410; | |
7171 if ( !v27 ) | |
7172 goto LABEL_93; | |
7173 v28 = v27 - 40; | |
7174 if ( !v28 ) | |
7175 goto LABEL_191; | |
7176 v29 = v28 - 10; | |
7177 if ( v29 ) | |
7178 { | |
7179 if ( v29 != 20 ) | |
7180 return 0; | |
7181 LABEL_59: | |
7182 if ( v151 != 3 ) | |
7183 { | |
7184 v30 = v6 + 1; | |
7185 v31 = pObjectList->uNumObjects; | |
7186 v32 = 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7187 v2->uType = v30; |
0 | 7188 v146 = 0; |
7189 if ( (signed int)v31 > 0 ) | |
7190 { | |
7191 v140 = (char *)&pObjectList->pObjects->uObjectID; | |
7192 while ( v30 != *(short *)v140 ) | |
7193 { | |
7194 ++v146; | |
7195 v140 += 56; | |
7196 if ( v146 >= (signed int)v31 ) | |
7197 goto LABEL_195; | |
7198 } | |
7199 LABEL_80: | |
7200 v46 = v146; | |
7201 LABEL_196: | |
7202 v2->uObjectDescID = v46; | |
7203 if ( v46 == (short)v32 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7204 SpriteObject::OnInteraction(v153); |
0 | 7205 v100 = v2->field_61; |
7206 v101 = v2->vPosition.z; | |
7207 v2->uSpriteFrameID = v32; | |
7208 v102 = 8 * v153; | |
7209 v103 = v2->vPosition.y; | |
862 | 7210 LOBYTE(v102) = PID(OBJECT_Item,v153); |
0 | 7211 v2->vVelocity.x = v32; |
7212 v2->vVelocity.y = v32; | |
7213 v104 = v2->vPosition.x; | |
7214 v2->vVelocity.z = v32; | |
7215 v149 = v102; | |
7216 stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
7217 if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1409
diff
changeset
|
7218 trail_particle_generator.GenerateTrailParticles( |
0 | 7219 v2->vPosition.x, |
7220 v2->vPosition.y, | |
7221 v2->vPosition.z, | |
7222 v3->uParticleTrailColor); | |
7223 v105 = v2->uSoundID; | |
7224 if ( v105 == (short)v32 ) | |
7225 v47 = 0; | |
7226 else | |
7227 v47 = (signed __int16)v105 + 4; | |
7228 v133 = v32; | |
7229 v131 = v32; | |
7230 v130 = v47; | |
7231 v129 = v32; | |
7232 v128 = -1; | |
7233 v127 = v32; | |
7234 v126 = v149; | |
7235 goto LABEL_268; | |
7236 } | |
7237 goto LABEL_195; | |
7238 } | |
7239 return 1; | |
7240 } | |
7241 LABEL_247: | |
7242 if ( v151 == 6 || v151 == 5 || (v9 = 0, !v151) ) | |
7243 return 1; | |
7244 if ( v151 != 2 ) | |
7245 { | |
7246 sub_43A97E(v153, v145); | |
7247 v122 = pObjectList->uNumObjects; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7248 ++v2->uType; |
0 | 7249 v52 = 0; |
7250 if ( (signed int)v122 > 0 ) | |
7251 { | |
7252 v123 = (char *)&pObjectList->pObjects->uObjectID; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7253 while ( v2->uType != *(short *)v123 ) |
0 | 7254 { |
7255 ++v52; | |
7256 v123 += 56; | |
7257 if ( v52 >= (signed int)v122 ) | |
7258 goto LABEL_181; | |
7259 } | |
7260 LABEL_202: | |
7261 v95 = v52; | |
7262 goto LABEL_182; | |
7263 } | |
7264 goto LABEL_181; | |
7265 } | |
7266 v117 = v6 + 1; | |
7267 v118 = pObjectList->uNumObjects; | |
7268 v119 = 0; | |
7269 v44 = pObjectList->uNumObjects == 0; | |
7270 v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7271 v2->uType = v117; |
0 | 7272 if ( v20 | v44 ) |
7273 { | |
7274 LABEL_255: | |
7275 v121 = 0; | |
7276 } | |
7277 else | |
7278 { | |
7279 v120 = (char *)&pObjectList->pObjects->uObjectID; | |
7280 while ( v117 != *(short *)v120 ) | |
7281 { | |
7282 ++v119; | |
7283 v120 += 56; | |
7284 if ( v119 >= (signed int)v118 ) | |
7285 goto LABEL_255; | |
7286 } | |
7287 v121 = v119; | |
7288 } | |
7289 v2->uObjectDescID = v121; | |
7290 if ( !v121 ) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
496
diff
changeset
|
7291 SpriteObject::OnInteraction(v153); |
0 | 7292 v2->vVelocity.z = 0; |
7293 v2->vVelocity.y = 0; | |
7294 v2->vVelocity.x = 0; | |
7295 v2->uSpriteFrameID = 0; | |
7296 LABEL_27: | |
7297 v133 = v9; | |
7298 v131 = v9; | |
7299 v130 = v9; | |
7300 v13 = 8 * v153; | |
7301 v129 = v9; | |
7302 v128 = -1; | |
862 | 7303 LOBYTE(v13) = PID(OBJECT_Item,v153); |
0 | 7304 v127 = v9; |
7305 v126 = v13; | |
7306 LABEL_28: | |
7307 v125 = 8; | |
7308 LABEL_29: | |
7309 pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); | |
7310 return 0; | |
7311 } |