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