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