comparison mm7_5.cpp @ 1449:27b7ee003c7c

Merge
author Gloval
date Tue, 06 Aug 2013 00:56:33 +0400
parents 5a5d0c713d47 8b4f4c723edd
children 8ff3c675a726
comparison
equal deleted inserted replaced
1448:5a5d0c713d47 1449:27b7ee003c7c
14 #include "LightmapBuilder.h" 14 #include "LightmapBuilder.h"
15 #include "DecalBuilder.h" 15 #include "DecalBuilder.h"
16 #include "Mouse.h" 16 #include "Mouse.h"
17 #include "Keyboard.h" 17 #include "Keyboard.h"
18 #include "GammaControl.h" 18 #include "GammaControl.h"
19 #include "stru11.h"
20 #include "mm7_data.h" 19 #include "mm7_data.h"
21 #include "FactionTable.h" 20 #include "FactionTable.h"
22 #include "Vis.h" 21 #include "Vis.h"
23 #include "mm7.h" 22 #include "mm7.h"
24 #include "Game.h" 23 #include "Game.h"
111 int v54; // eax@432 110 int v54; // eax@432
112 int v55; // ecx@432 111 int v55; // ecx@432
113 int v56; // edx@432 112 int v56; // edx@432
114 int v57; // eax@432 113 int v57; // eax@432
115 Player *pPlayer; // edx@442 114 Player *pPlayer; // edx@442
116 unsigned int v59; // eax@445 115 unsigned int pMapNum; // eax@445
117 signed int v60; // ST64_4@459 116 signed int v60; // ST64_4@459
118 NPCData *pNPCData2; // eax@467 117 //NPCData *pNPCData2; // eax@467
119 unsigned __int64 v62; // kr00_8@467 118 //unsigned __int64 v62; // kr00_8@467
120 __int16 v63; // dx@479 119 __int16 v63; // dx@479
121 unsigned int v64; // eax@486 120 unsigned int v64; // eax@486
122 int v65; // ecx@486 121 int v65; // ecx@486
123 int v66; // eax@488 122 int v66; // eax@488
124 char *v67; // eax@489 123 char *v67; // eax@489
204 int v153; // [sp-4h] [bp-600h]@135 203 int v153; // [sp-4h] [bp-600h]@135
205 //int v154; // [sp-4h] [bp-600h]@149 204 //int v154; // [sp-4h] [bp-600h]@149
206 int v155; // [sp-4h] [bp-600h]@165 205 int v155; // [sp-4h] [bp-600h]@165
207 int v156; // [sp-4h] [bp-600h]@204 206 int v156; // [sp-4h] [bp-600h]@204
208 //const char *v157; // [sp-4h] [bp-600h]@444 207 //const char *v157; // [sp-4h] [bp-600h]@444
209 unsigned int v158; // [sp-4h] [bp-600h]@449 208 //unsigned int v158; // [sp-4h] [bp-600h]@449
210 //__int16 v159; // [sp-4h] [bp-600h]@550 209 //__int16 v159; // [sp-4h] [bp-600h]@550
211 int v160; // [sp-4h] [bp-600h]@599 210 int v160; // [sp-4h] [bp-600h]@599
212 const char *v161; // [sp-4h] [bp-600h]@637 211 const char *v161; // [sp-4h] [bp-600h]@637
213 //int v162; // [sp+0h] [bp-5FCh]@56 212 //int v162; // [sp+0h] [bp-5FCh]@56
214 //int v163; // [sp+0h] [bp-5FCh]@59 213 //int v163; // [sp+0h] [bp-5FCh]@59
231 //signed int _this; // [sp+14h] [bp-5E8h]@22 230 //signed int _this; // [sp+14h] [bp-5E8h]@22
232 signed int thisa; // [sp+14h] [bp-5E8h]@251 231 signed int thisa; // [sp+14h] [bp-5E8h]@251
233 signed int thisb; // [sp+14h] [bp-5E8h]@272 232 signed int thisb; // [sp+14h] [bp-5E8h]@272
234 Player *pPlayer7; // [sp+14h] [bp-5E8h]@373 233 Player *pPlayer7; // [sp+14h] [bp-5E8h]@373
235 Player *pPlayer8; // [sp+14h] [bp-5E8h]@377 234 Player *pPlayer8; // [sp+14h] [bp-5E8h]@377
236 char *thise; // [sp+14h] [bp-5E8h]@445 235 char *pMapName; // [sp+14h] [bp-5E8h]@445
237 Player *pPlayer9; // [sp+14h] [bp-5E8h]@455 236 Player *pPlayer9; // [sp+14h] [bp-5E8h]@455
238 int thisg; // [sp+14h] [bp-5E8h]@467 237 int thisg; // [sp+14h] [bp-5E8h]@467
239 int thish; // [sp+14h] [bp-5E8h]@528 238 int thish; // [sp+14h] [bp-5E8h]@528
240 signed int thisi; // [sp+14h] [bp-5E8h]@535 239 signed int thisi; // [sp+14h] [bp-5E8h]@535
241 MapInfo *pMapInfo; // [sp+14h] [bp-5E8h]@604 240 MapInfo *pMapInfo; // [sp+14h] [bp-5E8h]@604
258 POINT v207; // [sp+68h] [bp-594h]@155 257 POINT v207; // [sp+68h] [bp-594h]@155
259 POINT v208; // [sp+70h] [bp-58Ch]@397 258 POINT v208; // [sp+70h] [bp-58Ch]@397
260 POINT v209; // [sp+78h] [bp-584h]@777 259 POINT v209; // [sp+78h] [bp-584h]@777
261 POINT v210; // [sp+80h] [bp-57Ch]@397 260 POINT v210; // [sp+80h] [bp-57Ch]@397
262 POINT v211; // [sp+88h] [bp-574h]@704 261 POINT v211; // [sp+88h] [bp-574h]@704
263 __int64 v212; // [sp+90h] [bp-56Ch]@467 262 //__int64 v212; // [sp+90h] [bp-56Ch]@467
264 int v213; // [sp+98h] [bp-564h]@385 263 int v213; // [sp+98h] [bp-564h]@385
265 char pLevelName[32]; // [sp+9Ch] [bp-560h]@380 264 char pLevelName[32]; // [sp+9Ch] [bp-560h]@380
266 char pOut[32]; // [sp+BCh] [bp-540h]@370 265 char pOut[32]; // [sp+BCh] [bp-540h]@370
267 FrameTableTxtLine v216; // [sp+DCh] [bp-520h]@524 266 FrameTableTxtLine v216; // [sp+DCh] [bp-520h]@524
268 int v217[9]; // [sp+158h] [bp-4A4h]@652 267 int v217[9]; // [sp+158h] [bp-4A4h]@652
389 continue; 388 continue;
390 case UIMSG_StartNewGame: 389 case UIMSG_StartNewGame:
391 if ( dword_6BE138 == 124 || uMessageParam ) 390 if ( dword_6BE138 == 124 || uMessageParam )
392 { 391 {
393 pIcons_LOD->SyncLoadedFilesCount(); 392 pIcons_LOD->SyncLoadedFilesCount();
394 pIcons_LOD->_4114F2(); 393 pIcons_LOD->RemoveTexturesPackFromTextureList();
395 if ( pMessageQueue_50CBD0->uNumMessages ) 394 if ( pMessageQueue_50CBD0->uNumMessages )
396 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 395 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
397 pGUIWindow_CurrentMenu->Release(); 396 pGUIWindow_CurrentMenu->Release();
398 uGameState = GAME_STATE_NEWGAME_OUT_GAMEMENU; 397 uGameState = GAME_STATE_NEWGAME_OUT_GAMEMENU;
399 pCurrentScreen = SCREEN_GAME; 398 pCurrentScreen = SCREEN_GAME;
407 } 406 }
408 stru_506E40.Release(); 407 stru_506E40.Release();
409 continue; 408 continue;
410 case UIMSG_Game_OpenLoadGameDialog: 409 case UIMSG_Game_OpenLoadGameDialog:
411 pIcons_LOD->SyncLoadedFilesCount(); 410 pIcons_LOD->SyncLoadedFilesCount();
412 pIcons_LOD->_4114F2(); 411 pIcons_LOD->RemoveTexturesPackFromTextureList();
413 if ( pMessageQueue_50CBD0->uNumMessages ) 412 if ( pMessageQueue_50CBD0->uNumMessages )
414 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 413 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
415 pGUIWindow_CurrentMenu->Release(); 414 pGUIWindow_CurrentMenu->Release();
416 pCurrentScreen = SCREEN_LOADGAME; 415 pCurrentScreen = SCREEN_LOADGAME;
417 LoadUI_Load(1); 416 LoadUI_Load(1);
418 continue; 417 continue;
419 case UIMSG_Quit: 418 case UIMSG_Quit:
420 if ( dword_6BE138 == 132 || uMessageParam ) 419 if ( dword_6BE138 == 132 || uMessageParam )
421 { 420 {
422 pIcons_LOD->SyncLoadedFilesCount(); 421 pIcons_LOD->SyncLoadedFilesCount();
423 pIcons_LOD->_4114F2(); 422 pIcons_LOD->RemoveTexturesPackFromTextureList();
424 if ( pMessageQueue_50CBD0->uNumMessages ) 423 if ( pMessageQueue_50CBD0->uNumMessages )
425 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 424 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
426 pGUIWindow_CurrentMenu->Release(); 425 pGUIWindow_CurrentMenu->Release();
427 pCurrentScreen = SCREEN_GAME; 426 pCurrentScreen = SCREEN_GAME;
428 viewparams->bRedrawGameUI = 1; 427 viewparams->bRedrawGameUI = 1;
439 stru_506E40.Release(); 438 stru_506E40.Release();
440 continue; 439 continue;
441 case UIMSG_80: 440 case UIMSG_80:
442 __debugbreak(); 441 __debugbreak();
443 pIcons_LOD->SyncLoadedFilesCount(); 442 pIcons_LOD->SyncLoadedFilesCount();
444 pIcons_LOD->_4114F2(); 443 pIcons_LOD->RemoveTexturesPackFromTextureList();
445 pGUIWindow_CurrentMenu->Release(); 444 pGUIWindow_CurrentMenu->Release();
446 pCurrentScreen = SCREEN_OPTIONS; 445 pCurrentScreen = SCREEN_OPTIONS;
447 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_8, 0, 0); 446 pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_8, 0, 0);
448 continue; 447 continue;
449 case UIMSG_ArrowUp: 448 case UIMSG_ArrowUp:
993 { 992 {
994 if ( pCurrentScreen > SCREEN_67 ) 993 if ( pCurrentScreen > SCREEN_67 )
995 { 994 {
996 if ( pCurrentScreen == SCREEN_QUICK_REFERENCE ) 995 if ( pCurrentScreen == SCREEN_QUICK_REFERENCE )
997 { 996 {
998 pIcons_LOD->_4114F2(); 997 pIcons_LOD->RemoveTexturesPackFromTextureList();
999 if ( pGUIWindow_Settings ) 998 if ( pGUIWindow_Settings )
1000 { 999 {
1001 if ( pCurrentScreen == SCREEN_CHARACTERS ) 1000 if ( pCurrentScreen == SCREEN_CHARACTERS )
1002 { 1001 {
1003 pMouse->SetCursorBitmap("MICON2"); 1002 pMouse->SetCursorBitmap("MICON2");
1019 window_SpeakInHouse = 0; 1018 window_SpeakInHouse = 0;
1020 pGUIWindow_CurrentMenu = 0; 1019 pGUIWindow_CurrentMenu = 0;
1021 pEventTimer->Resume(); 1020 pEventTimer->Resume();
1022 pCurrentScreen = SCREEN_GAME; 1021 pCurrentScreen = SCREEN_GAME;
1023 viewparams->bRedrawGameUI = 1; 1022 viewparams->bRedrawGameUI = 1;
1024 pIcons_LOD->_4355F7(); 1023 pIcons_LOD->RemoveTexturesFromTextureList();
1025 continue; 1024 continue;
1026 } 1025 }
1027 } 1026 }
1028 else 1027 else
1029 { 1028 {
1030 if ( pCurrentScreen < SCREEN_64 ) 1029 if ( pCurrentScreen < SCREEN_64 )
1031 { 1030 {
1032 switch ( pCurrentScreen ) 1031 switch ( pCurrentScreen )
1033 { 1032 {
1034 case SCREEN_CASTING: 1033 case SCREEN_CASTING:
1035 pIcons_LOD->_4114F2(); 1034 pIcons_LOD->RemoveTexturesPackFromTextureList();
1036 if ( some_active_character ) 1035 if ( some_active_character )
1037 { 1036 {
1038 uActiveCharacter = some_active_character; 1037 uActiveCharacter = some_active_character;
1039 uActiveCharacter = pParty->GetNextActiveCharacter(); 1038 uActiveCharacter = pParty->GetNextActiveCharacter();
1040 some_active_character = 0; 1039 some_active_character = 0;
1073 window_SpeakInHouse = 0; 1072 window_SpeakInHouse = 0;
1074 pGUIWindow_CurrentMenu = 0; 1073 pGUIWindow_CurrentMenu = 0;
1075 pEventTimer->Resume(); 1074 pEventTimer->Resume();
1076 pCurrentScreen = SCREEN_GAME; 1075 pCurrentScreen = SCREEN_GAME;
1077 viewparams->bRedrawGameUI = 1; 1076 viewparams->bRedrawGameUI = 1;
1078 pIcons_LOD->_4355F7(); 1077 pIcons_LOD->RemoveTexturesFromTextureList();
1079 continue; 1078 continue;
1080 case SCREEN_BOOKS: 1079 case SCREEN_BOOKS:
1081 pBooksWindow->Release(); 1080 pBooksWindow->Release();
1082 //crt_deconstruct_ptr_6A0118(); 1081 //crt_deconstruct_ptr_6A0118();
1083 pBooksWindow = 0; 1082 pBooksWindow = 0;
1105 window_SpeakInHouse = 0; 1104 window_SpeakInHouse = 0;
1106 pGUIWindow_CurrentMenu = 0; 1105 pGUIWindow_CurrentMenu = 0;
1107 pEventTimer->Resume(); 1106 pEventTimer->Resume();
1108 pCurrentScreen = SCREEN_GAME; 1107 pCurrentScreen = SCREEN_GAME;
1109 viewparams->bRedrawGameUI = 1; 1108 viewparams->bRedrawGameUI = 1;
1110 pIcons_LOD->_4355F7(); 1109 pIcons_LOD->RemoveTexturesFromTextureList();
1111 continue; 1110 continue;
1112 case SCREEN_SAVEGAME: 1111 case SCREEN_SAVEGAME:
1113 case SCREEN_LOADGAME: 1112 case SCREEN_LOADGAME:
1114 pIcons_LOD->_4114F2(); 1113 pIcons_LOD->RemoveTexturesPackFromTextureList();
1115 //crt_deconstruct_ptr_6A0118(); 1114 //crt_deconstruct_ptr_6A0118();
1116 stru_506E40.Release(); 1115 stru_506E40.Release();
1117 break; 1116 break;
1118 case SCREEN_CHEST_INVENTORY: 1117 case SCREEN_CHEST_INVENTORY:
1119 pCurrentScreen = SCREEN_CHEST; 1118 pCurrentScreen = SCREEN_CHEST;
1120 continue; 1119 continue;
1121 case SCREEN_CHEST: 1120 case SCREEN_CHEST:
1122 pWindow2 = pChestWindow; 1121 pWindow2 = pChestWindow;
1123 pWindow2->Release(); 1122 pWindow2->Release();
1124 pIcons_LOD->_4114F2(); 1123 pIcons_LOD->RemoveTexturesPackFromTextureList();
1125 pCurrentScreen = SCREEN_GAME; 1124 pCurrentScreen = SCREEN_GAME;
1126 viewparams->bRedrawGameUI = 1; 1125 viewparams->bRedrawGameUI = 1;
1127 pEventTimer->Resume(); 1126 pEventTimer->Resume();
1128 continue; 1127 continue;
1129 case SCREEN_19: 1128 case SCREEN_19:
1130 __debugbreak(); 1129 __debugbreak();
1131 pWindow2 = ptr_507BC8; 1130 pWindow2 = ptr_507BC8;
1132 pWindow2->Release(); 1131 pWindow2->Release();
1133 pIcons_LOD->_4114F2(); 1132 pIcons_LOD->RemoveTexturesPackFromTextureList();
1134 pCurrentScreen = SCREEN_GAME; 1133 pCurrentScreen = SCREEN_GAME;
1135 viewparams->bRedrawGameUI = 1; 1134 viewparams->bRedrawGameUI = 1;
1136 pEventTimer->Resume(); 1135 pEventTimer->Resume();
1137 continue; 1136 continue;
1138 case SCREEN_OPTIONS://Close 1137 case SCREEN_OPTIONS://Close
1166 WriteWindowsRegistryInt("TurnDelta", 1); 1165 WriteWindowsRegistryInt("TurnDelta", 1);
1167 stru_506E40.Release(); 1166 stru_506E40.Release();
1168 break; 1167 break;
1169 case SCREEN_MENU: 1168 case SCREEN_MENU:
1170 pIcons_LOD->SyncLoadedFilesCount(); 1169 pIcons_LOD->SyncLoadedFilesCount();
1171 pIcons_LOD->_4114F2(); 1170 pIcons_LOD->RemoveTexturesPackFromTextureList();
1172 pIcons_LOD->SyncLoadedFilesCount(); 1171 pIcons_LOD->SyncLoadedFilesCount();
1173 pIcons_LOD->_4114F2(); 1172 pIcons_LOD->RemoveTexturesPackFromTextureList();
1174 stru_506E40.Release(); 1173 stru_506E40.Release();
1175 break; 1174 break;
1176 case SCREEN_VIDEO_OPTIONS: 1175 case SCREEN_VIDEO_OPTIONS:
1177 if ( pRenderer->pRenderD3D ) 1176 if ( pRenderer->pRenderD3D )
1178 { 1177 {
1244 } 1243 }
1245 break; 1244 break;
1246 case SCREEN_REST://close rest screen 1245 case SCREEN_REST://close rest screen
1247 if ( dword_506F14 ) 1246 if ( dword_506F14 )
1248 { 1247 {
1249 Rest(_506F18_num_hours_to_sleep); 1248 Rest(_506F18_num_minutes_to_sleep);
1250 pParty->pPlayers[3].pConditions[2] = 0i64; 1249 pParty->pPlayers[3].pConditions[2] = 0i64;
1251 pParty->pPlayers[2].pConditions[2] = 0i64; 1250 pParty->pPlayers[2].pConditions[2] = 0i64;
1252 pParty->pPlayers[1].pConditions[2] = 0i64; 1251 pParty->pPlayers[1].pConditions[2] = 0i64;
1253 pParty->pPlayers[0].pConditions[2] = 0i64; 1252 pParty->pPlayers[0].pConditions[2] = 0i64;
1254 } 1253 }
1255 pTexture_RestUI_CurrentSkyFrame->Release(); 1254 pTexture_RestUI_CurrentSkyFrame->Release();
1256 pTexture_RestUI_CurrentHourglassFrame->Release(); 1255 pTexture_RestUI_CurrentHourglassFrame->Release();
1257 pTexture_RestUI_CurrentHourglassFrame = 0; 1256 pTexture_RestUI_CurrentHourglassFrame = 0;
1258 pTexture_RestUI_CurrentSkyFrame = 0; 1257 pTexture_RestUI_CurrentSkyFrame = 0;
1259 pIcons_LOD->SyncLoadedFilesCount(); 1258 pIcons_LOD->SyncLoadedFilesCount();
1260 pIcons_LOD->_4114F2(); 1259 pIcons_LOD->RemoveTexturesPackFromTextureList();
1261 _506F18_num_hours_to_sleep = 0; 1260 _506F18_num_minutes_to_sleep = 0;
1262 dword_506F14 = 0; 1261 dword_506F14 = 0;
1263 dword_507B94 = 1; 1262 dword_507B94 = 1;
1264 if ( pGUIWindow_Settings ) 1263 if ( pGUIWindow_Settings )
1265 { 1264 {
1266 if ( pCurrentScreen == SCREEN_CHARACTERS ) 1265 if ( pCurrentScreen == SCREEN_CHARACTERS )
1284 window_SpeakInHouse = 0; 1283 window_SpeakInHouse = 0;
1285 pGUIWindow_CurrentMenu = 0; 1284 pGUIWindow_CurrentMenu = 0;
1286 pEventTimer->Resume(); 1285 pEventTimer->Resume();
1287 pCurrentScreen = SCREEN_GAME; 1286 pCurrentScreen = SCREEN_GAME;
1288 viewparams->bRedrawGameUI = 1; 1287 viewparams->bRedrawGameUI = 1;
1289 pIcons_LOD->_4355F7(); 1288 pIcons_LOD->RemoveTexturesFromTextureList();
1290 continue; 1289 continue;
1291 case SCREEN_E: 1290 case SCREEN_E:
1292 __debugbreak(); 1291 __debugbreak();
1293 pGUIWindow_CurrentMenu->Release(); 1292 pGUIWindow_CurrentMenu->Release();
1294 pCurrentScreen = SCREEN_HOUSE; 1293 pCurrentScreen = SCREEN_HOUSE;
1295 pIcons_LOD->_4114F2(); 1294 pIcons_LOD->RemoveTexturesPackFromTextureList();
1296 continue; 1295 continue;
1297 case SCREEN_HOUSE: 1296 case SCREEN_HOUSE:
1298 if ( uDialogueType ) 1297 if ( uDialogueType )
1299 uDialogueType = 0; 1298 uDialogueType = 0;
1300 if ( uGameState == GAME_STATE_2 ) 1299 if ( uGameState == GAME_STATE_2 )
1305 else 1304 else
1306 { 1305 {
1307 if ( sub_4BD8B5() ) 1306 if ( sub_4BD8B5() )
1308 continue; 1307 continue;
1309 } 1308 }
1310 sub_4B1D27(); 1309 GetHouseGoodbyeSpeech();
1311 pAudioPlayer->PlaySound(SOUND_7, 814, 0, -1, 0, 0, 0, 0); 1310 pAudioPlayer->PlaySound(SOUND_7, 814, 0, -1, 0, 0, 0, 0);
1312 pVideoPlayer->Unload(); 1311 pVideoPlayer->Unload();
1313 pGUIWindow_CurrentMenu = window_SpeakInHouse; 1312 pGUIWindow_CurrentMenu = window_SpeakInHouse;
1314 if ( pGUIWindow_Settings ) 1313 if ( pGUIWindow_Settings )
1315 { 1314 {
1334 window_SpeakInHouse = 0; 1333 window_SpeakInHouse = 0;
1335 pGUIWindow_CurrentMenu = 0; 1334 pGUIWindow_CurrentMenu = 0;
1336 pEventTimer->Resume(); 1335 pEventTimer->Resume();
1337 pCurrentScreen = SCREEN_GAME; 1336 pCurrentScreen = SCREEN_GAME;
1338 viewparams->bRedrawGameUI = true; 1337 viewparams->bRedrawGameUI = true;
1339 pIcons_LOD->_4355F7(); 1338 pIcons_LOD->RemoveTexturesFromTextureList();
1340 continue; 1339 continue;
1341 case SCREEN_INPUT_BLV://click escape 1340 case SCREEN_INPUT_BLV://click escape
1342 if ( uCurrentHouse_Animation == 153 ) 1341 if ( uCurrentHouse_Animation == 153 )
1343 PlayHouseSound(0x99u, HouseSound_Greeting_2); 1342 PlayHouseSound(0x99u, HouseSound_Greeting_2);
1344 pVideoPlayer->Unload(); 1343 pVideoPlayer->Unload();
1392 pVideoPlayer->Unload(); 1391 pVideoPlayer->Unload();
1393 continue; 1392 continue;
1394 case SCREEN_CHARACTERS: 1393 case SCREEN_CHARACTERS:
1395 CharacterUI_ReleaseButtons(); 1394 CharacterUI_ReleaseButtons();
1396 sub_419379(); 1395 sub_419379();
1397 pIcons_LOD->_4114F2(); 1396 pIcons_LOD->RemoveTexturesPackFromTextureList();
1398 if ( pGUIWindow_Settings ) 1397 if ( pGUIWindow_Settings )
1399 { 1398 {
1400 if ( pCurrentScreen == SCREEN_CHARACTERS ) 1399 if ( pCurrentScreen == SCREEN_CHARACTERS )
1401 { 1400 {
1402 pMouse->SetCursorBitmap("MICON2"); 1401 pMouse->SetCursorBitmap("MICON2");
1418 window_SpeakInHouse = 0; 1417 window_SpeakInHouse = 0;
1419 pGUIWindow_CurrentMenu = 0; 1418 pGUIWindow_CurrentMenu = 0;
1420 pEventTimer->Resume(); 1419 pEventTimer->Resume();
1421 pCurrentScreen = SCREEN_GAME; 1420 pCurrentScreen = SCREEN_GAME;
1422 viewparams->bRedrawGameUI = true; 1421 viewparams->bRedrawGameUI = true;
1423 pIcons_LOD->_4355F7(); 1422 pIcons_LOD->RemoveTexturesFromTextureList();
1424 continue; 1423 continue;
1425 default: 1424 default:
1426 if ( pGUIWindow_Settings ) 1425 if ( pGUIWindow_Settings )
1427 { 1426 {
1428 if ( pCurrentScreen == SCREEN_CHARACTERS ) 1427 if ( pCurrentScreen == SCREEN_CHARACTERS )
1446 window_SpeakInHouse = 0; 1445 window_SpeakInHouse = 0;
1447 pGUIWindow_CurrentMenu = 0; 1446 pGUIWindow_CurrentMenu = 0;
1448 pEventTimer->Resume(); 1447 pEventTimer->Resume();
1449 pCurrentScreen = SCREEN_GAME; 1448 pCurrentScreen = SCREEN_GAME;
1450 viewparams->bRedrawGameUI = 1; 1449 viewparams->bRedrawGameUI = 1;
1451 pIcons_LOD->_4355F7(); 1450 pIcons_LOD->RemoveTexturesFromTextureList();
1452 continue; 1451 continue;
1453 } 1452 }
1454 if ( pGUIWindow_Settings ) 1453 if ( pGUIWindow_Settings )
1455 { 1454 {
1456 if ( pCurrentScreen == SCREEN_CHARACTERS ) 1455 if ( pCurrentScreen == SCREEN_CHARACTERS )
1474 window_SpeakInHouse = 0; 1473 window_SpeakInHouse = 0;
1475 pGUIWindow_CurrentMenu = 0; 1474 pGUIWindow_CurrentMenu = 0;
1476 pEventTimer->Resume(); 1475 pEventTimer->Resume();
1477 pCurrentScreen = SCREEN_GAME; 1476 pCurrentScreen = SCREEN_GAME;
1478 viewparams->bRedrawGameUI = true; 1477 viewparams->bRedrawGameUI = true;
1479 pIcons_LOD->_4355F7(); 1478 pIcons_LOD->RemoveTexturesFromTextureList();
1480 continue; 1479 continue;
1481 } 1480 }
1482 CharacterUI_ReleaseButtons(); 1481 CharacterUI_ReleaseButtons();
1483 sub_419379(); 1482 sub_419379();
1484 pIcons_LOD->_4114F2(); 1483 pIcons_LOD->RemoveTexturesPackFromTextureList();
1485 } 1484 }
1486 if ( pGUIWindow_Settings ) 1485 if ( pGUIWindow_Settings )
1487 { 1486 {
1488 if ( pCurrentScreen == SCREEN_CHARACTERS ) 1487 if ( pCurrentScreen == SCREEN_CHARACTERS )
1489 { 1488 {
1506 window_SpeakInHouse = 0; 1505 window_SpeakInHouse = 0;
1507 pGUIWindow_CurrentMenu = 0; 1506 pGUIWindow_CurrentMenu = 0;
1508 pEventTimer->Resume(); 1507 pEventTimer->Resume();
1509 pCurrentScreen = SCREEN_GAME; 1508 pCurrentScreen = SCREEN_GAME;
1510 viewparams->bRedrawGameUI = true; 1509 viewparams->bRedrawGameUI = true;
1511 pIcons_LOD->_4355F7(); 1510 pIcons_LOD->RemoveTexturesFromTextureList();
1512 continue; 1511 continue;
1513 } 1512 }
1514 if ( !pGUIWindow_Settings )//Draw Menu 1513 if ( !pGUIWindow_Settings )//Draw Menu
1515 { 1514 {
1516 dword_6BE138 = -1; 1515 dword_6BE138 = -1;
1665 case UIMSG_OnTravelByFoot: 1664 case UIMSG_OnTravelByFoot:
1666 if ( pMessageQueue_50CBD0->uNumMessages ) 1665 if ( pMessageQueue_50CBD0->uNumMessages )
1667 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 1666 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
1668 dword_50CDC8 = 1; 1667 dword_50CDC8 = 1;
1669 sub_42FBDD(); 1668 sub_42FBDD();
1670 pNPCData4 = (NPCData *)GetTravelTime(); 1669 //pNPCData4 = (NPCData *)GetTravelTime();
1671 strcpy(pOutdoor->pLevelFilename, pCurrentMapName.data()); 1670 strcpy(pOutdoor->pLevelFilename, pCurrentMapName.data());
1672 if ( bUnderwater != 1 && pParty->bFlying 1671 if ( bUnderwater != 1 && pParty->bFlying
1673 || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 20) != 1 ) 1672 || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 20) != 1 )
1674 { 1673 {
1675 viewparams->bRedrawGameUI = 1; 1674 viewparams->bRedrawGameUI = 1;
1694 pEventTimer->Pause(); 1693 pEventTimer->Pause();
1695 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box); 1694 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box);
1696 ++pGameLoadingUI_ProgressBar->uProgressMax; 1695 ++pGameLoadingUI_ProgressBar->uProgressMax;
1697 SaveGame(1, 0); 1696 SaveGame(1, 0);
1698 pGameLoadingUI_ProgressBar->Progress(); 1697 pGameLoadingUI_ProgressBar->Progress();
1699 RestAndHeal(1440 * (signed int)pNPCData4); 1698 RestAndHeal(1440 * (signed int)GetTravelTime());
1700 if ( pParty->uNumFoodRations ) 1699 if ( pParty->uNumFoodRations )
1701 { 1700 {
1702 pParty->RestAndHeal(); 1701 pParty->RestAndHeal();
1703 if ( ((pParty->uNumFoodRations - (signed int)pNPCData4) & 0x80000000u) != 0 ) 1702 if ( ((pParty->uNumFoodRations - (signed int)GetTravelTime()) & 0x80000000u) != 0 )
1704 { 1703 {
1705 pPlayer7 = pParty->pPlayers; 1704 pPlayer7 = pParty->pPlayers;
1706 do 1705 do
1707 { 1706 {
1708 pPlayer7->SetCondition(1, 0); 1707 pPlayer7->SetCondition(1, 0);
1709 ++pPlayer7; 1708 ++pPlayer7;
1710 } 1709 }
1711 while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings ); 1710 while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings );
1712 ++pParty->days_played_without_rest; 1711 ++pParty->days_played_without_rest;
1713 } 1712 }
1714 Party::TakeFood((unsigned int)pNPCData4); 1713 Party::TakeFood((unsigned int)GetTravelTime());
1715 } 1714 }
1716 else 1715 else
1717 { 1716 {
1718 pPlayer8 = pParty->pPlayers; 1717 pPlayer8 = pParty->pPlayers;
1719 do 1718 do
1963 continue; 1962 continue;
1964 pPlayer = pPlayers[_506348_current_lloyd_playerid + 1]; 1963 pPlayer = pPlayers[_506348_current_lloyd_playerid + 1];
1965 uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam]; 1964 uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam];
1966 if ( bRecallingBeacon ) 1965 if ( bRecallingBeacon )
1967 { 1966 {
1968 if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) ) 1967 if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) )
1969 continue; 1968 continue;
1970 v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName; 1969 v173 = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName;
1971 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s" 1970 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s"
1972 GameUI_SetFooterString(pTmpBuf.data()); 1971 GameUI_SetFooterString(pTmpBuf.data());
1973 continue; 1972 continue;
1974 } 1973 }
1975 v59 = pMapStats->GetMapInfo(pCurrentMapName.data()); 1974 pMapNum = pMapStats->GetMapInfo(pCurrentMapName.data());
1976 thise = "Not in Map Stats"; 1975 pMapName = "Not in Map Stats";
1977 if ( v59 ) 1976 if ( pMapNum )
1978 thise = pMapStats->pInfos[v59].pName; 1977 pMapName = pMapStats->pInfos[pMapNum].pName;
1979 if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) || !v59 ) 1978 if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) || !pMapNum )
1980 { 1979 {
1981 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], thise);// "Set to %s" 1980 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], pMapName);// "Set to %s"
1982 GameUI_SetFooterString(pTmpBuf.data()); 1981 GameUI_SetFooterString(pTmpBuf.data());
1983 continue; 1982 continue;
1984 } 1983 }
1985 v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName; 1984 v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName;
1986 v158 = (unsigned int)thise; 1985 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s"
1987 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], v158, v174);// "Set %s over %s"
1988 GameUI_SetFooterString(pTmpBuf.data()); 1986 GameUI_SetFooterString(pTmpBuf.data());
1989 continue; 1987 continue;
1990 case UIMSG_CloseAfterInstallBeacon: 1988 case UIMSG_CloseAfterInstallBeacon:
1991 dword_50CDC8 = 1; 1989 dword_50CDC8 = 1;
1992 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); 1990 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
1997 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; 1995 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
1998 ++pMessageQueue_50CBD0->uNumMessages;*/ 1996 ++pMessageQueue_50CBD0->uNumMessages;*/
1999 continue; 1997 continue;
2000 case UIMSG_InstallBeacon: 1998 case UIMSG_InstallBeacon:
2001 pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1]; 1999 pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1];
2002 pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam]; 2000 if ( !pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime && bRecallingBeacon )
2003 if ( !*(_QWORD *)&pNPCData4->pName && bRecallingBeacon )
2004 continue; 2001 continue;
2005 byte_506360 = 1; 2002 byte_506360 = 1;
2006 pPlayer9->CanCastSpell(uRequiredMana); 2003 pPlayer9->CanCastSpell(uRequiredMana);
2007 if ( pParty->bTurnBasedModeOn ) 2004 if ( pParty->bTurnBasedModeOn )
2008 { 2005 {
2016 pPlayer9->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333)); 2013 pPlayer9->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333));
2017 } 2014 }
2018 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0); 2015 pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0);
2019 if ( bRecallingBeacon ) 2016 if ( bRecallingBeacon )
2020 { 2017 {
2021 if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) ) 2018 if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]) )
2022 { 2019 {
2023 SaveGame(1, 0); 2020 SaveGame(1, 0);
2024 OnMapLeave(); 2021 OnMapLeave();
2025 strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]); 2022 strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]);
2026 dword_6BE364_game_settings_1 |= 1; 2023 dword_6BE364_game_settings_1 |= 1;
2027 uGameState = GAME_STATE_2; 2024 uGameState = GAME_STATE_2;
2028 _5B65A8_npcdata_uflags_or_other = pNPCData4->uFlags; 2025 _5B65A8_npcdata_uflags_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X;
2029 _5B65AC_npcdata_fame_or_other = pNPCData4->fame; 2026 _5B65AC_npcdata_fame_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y;
2030 _5B65B0_npcdata_rep_or_other = pNPCData4->rep; 2027 _5B65B0_npcdata_rep_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z;
2031 _5B65B4_npcdata_loword_house_or_other = LOWORD(pNPCData4->Location2D); 2028 _5B65B4_npcdata_loword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X;
2032 _5B65B8_npcdata_hiword_house_or_other = HIWORD(pNPCData4->Location2D); 2029 _5B65B8_npcdata_hiword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y;
2033 dword_5B65C0 = 1; 2030 dword_5B65C0 = 1;
2034 } 2031 }
2035 else 2032 else
2036 { 2033 {
2037 pParty->vPosition.x = pNPCData4->uFlags; 2034 pParty->vPosition.x = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X;
2038 pParty->vPosition.y = pNPCData4->fame; 2035 pParty->vPosition.y = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y;
2039 pParty->vPosition.z = pNPCData4->rep; 2036 pParty->vPosition.z = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z;
2040 pParty->uFallStartY = pParty->vPosition.z; 2037 pParty->uFallStartY = pParty->vPosition.z;
2041 pParty->sRotationY = LOWORD(pNPCData4->Location2D); 2038 pParty->sRotationY = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X;
2042 pParty->sRotationX = HIWORD(pNPCData4->Location2D); 2039 pParty->sRotationX = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y;
2043 } 2040 }
2044 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); 2041 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0);
2045 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
2046 {
2047 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
2048 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0;
2049 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
2050 ++pMessageQueue_50CBD0->uNumMessages;
2051 }*/
2052 //crt_deconstruct_ptr_6A0118();
2053 pBooksWindow->Release(); 2042 pBooksWindow->Release();
2054 pGUIWindow_CurrentMenu->Release(); 2043 pGUIWindow_CurrentMenu->Release();
2055 pBooksWindow = 0; 2044 pBooksWindow = 0;
2056 pGUIWindow_CurrentMenu = 0; 2045 pGUIWindow_CurrentMenu = 0;
2057 } 2046 }
2058 else 2047 else
2059 { 2048 {
2060 sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1); 2049 sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1);
2061 SaveScreenshot(a1); 2050 SaveScreenshot(a1);
2062 LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1); 2051 LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1);
2063 v212 = qword_506350 << 7; 2052 pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335);
2064 pNPCData2 = pNPCData4; 2053 pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X = pParty->vPosition.x;
2065 thisg = 0; 2054 pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y = pParty->vPosition.y;
2066 v62 = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335); 2055 pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z = pParty->vPosition.z;
2067 pNPCData4->pName = (char *)v62; 2056 pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X = LOWORD(pParty->sRotationY);
2068 pNPCData2->uPortraitID = HIDWORD(v62); 2057 pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y = LOWORD(pParty->sRotationX);
2069 pNPCData2->uFlags = pParty->vPosition.x;
2070 pNPCData2->fame = pParty->vPosition.y;
2071 pNPCData2->rep = pParty->vPosition.z;
2072 LOWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationY);
2073 HIWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationX);
2074 if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 ) 2058 if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 )
2075 continue; 2059 continue;
2076 uAction = 0; 2060 for ( thisg = 0; thisg < (signed int)pGames_LOD->uNumSubDirs / 2; ++thisg )
2077 while ( _stricmp((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName.data()) ) 2061 {
2078 { 2062 if ( !_stricmp((const char *)pGames_LOD->pSubIndices[thisg].pFilename, pCurrentMapName.data()) )
2079 ++thisg; 2063 pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID = thisg;
2080 uAction += 32; 2064 }
2081 if ( thisg >= (signed int)pGames_LOD->uNumSubDirs / 2 )
2082 continue;
2083 }
2084 HIWORD(pNPCData4->uProfession) = thisg;
2085 } 2065 }
2086 continue; 2066 continue;
2087 case UIMSG_ClickTownInTP: 2067 case UIMSG_ClickTownInTP:
2088 if ( uMessageParam ) 2068 if ( uMessageParam )
2089 { 2069 {
2197 v69 = pMapStats->pInfos[7].pName; 2177 v69 = pMapStats->pInfos[7].pName;
2198 break; 2178 break;
2199 default: 2179 default:
2200 if ( uMessageParam != 5 ) 2180 if ( uMessageParam != 5 )
2201 { 2181 {
2182 __debugbreak(); // warning C4700: uninitialized local variable 'v200' used
2202 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); 2183 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200);
2203 GameUI_SetFooterString(pTmpBuf.data()); 2184 GameUI_SetFooterString(pTmpBuf.data());
2204 continue; 2185 continue;
2205 } 2186 }
2206 v69 = pMapStats->pInfos[8].pName; 2187 v69 = pMapStats->pInfos[8].pName;
2263 } 2244 }
2264 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v69); 2245 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v69);
2265 GameUI_SetFooterString(pTmpBuf.data()); 2246 GameUI_SetFooterString(pTmpBuf.data());
2266 continue; 2247 continue;
2267 case UIMSG_ShowFinalWindow: 2248 case UIMSG_ShowFinalWindow:
2268 sprintf(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." 2249 sprintfex(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer."
2269 pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." 2250 pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment."
2270 pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team." 2251 pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team."
2271 ModalWindow(pFinalMessage.data(), 196); 2252 ModalWindow(pFinalMessage.data(), 196);
2272 uGameState = GAME_STATE_FINAL_WINDOW; 2253 uGameState = GAME_STATE_FINAL_WINDOW;
2273 continue; 2254 continue;
2462 continue; 2443 continue;
2463 } 2444 }
2464 GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, WINDOW_PressedButton2, 2445 GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, WINDOW_PressedButton2,
2465 (int)pButton_RestUI_Wait5Minutes, pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes" 2446 (int)pButton_RestUI_Wait5Minutes, pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes"
2466 dword_506F14 = 1; 2447 dword_506F14 = 1;
2467 _506F18_num_hours_to_sleep = 5; 2448 _506F18_num_minutes_to_sleep = 5;
2468 continue; 2449 continue;
2469 case UIMSG_Wait1Hour: 2450 case UIMSG_Wait1Hour:
2470 if ( dword_506F14 == 2 ) 2451 if ( dword_506F14 == 2 )
2471 { 2452 {
2472 ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" 2453 ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!"
2474 continue; 2455 continue;
2475 } 2456 }
2476 GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, WINDOW_PressedButton2, 2457 GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, WINDOW_PressedButton2,
2477 (int)pButton_RestUI_Wait1Hour, pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour" 2458 (int)pButton_RestUI_Wait1Hour, pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour"
2478 dword_506F14 = 1; 2459 dword_506F14 = 1;
2479 _506F18_num_hours_to_sleep = 60; 2460 _506F18_num_minutes_to_sleep = 60;
2480 continue; 2461 continue;
2481 case UIMSG_RentRoom: 2462 case UIMSG_RentRoom:
2482 dword_506F14 = 2; 2463 dword_506F14 = 2;
2483 RestUI_Load(); 2464 RestUI_Load();
2484 v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute; 2465 v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute;
2485 _506F18_num_hours_to_sleep = v86; 2466 _506F18_num_minutes_to_sleep = v86;
2486 if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) 2467 if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) // 107 = Emerald Isle tavern
2487 _506F18_num_hours_to_sleep = v86 + 720; 2468 _506F18_num_minutes_to_sleep = v86 + 12 * 60;
2488 dword_506F14 = 2; 2469 dword_506F14 = 2;
2489 pParty->RestAndHeal(); 2470 pParty->RestAndHeal();
2490 pParty->days_played_without_rest = 0; 2471 pParty->days_played_without_rest = 0;
2491 pParty->pPlayers[3].SetAsleep(1); 2472 pParty->pPlayers[3].SetAsleep(1);
2492 pParty->pPlayers[2].SetAsleep(1); 2473 pParty->pPlayers[2].SetAsleep(1);
2567 v93 = v91 + 1; 2548 v93 = v91 + 1;
2568 if ( v93 > v92 ) 2549 if ( v93 > v92 )
2569 pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2); 2550 pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2);
2570 else 2551 else
2571 pNPCData4 = (NPCData *)1; 2552 pNPCData4 = (NPCData *)1;
2572 if ( !sub_45063B(pMapInfo, (int)pNPCData4) ) 2553 if ( !_45063B_spawn_some_monster(pMapInfo, (int)pNPCData4) )
2573 pNPCData4 = 0; 2554 pNPCData4 = 0;
2574 if ( pNPCData4 ) 2555 if ( pNPCData4 )
2575 { 2556 {
2576 pPlayerNum = rand() % 4; 2557 pPlayerNum = rand() % 4;
2577 LODWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0; 2558 LODWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0;
2578 HIDWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0; 2559 HIDWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0;
2579 v95 = rand(); 2560 v95 = rand();
2580 Rest(v95 % 6 + 60); 2561 Rest(v95 % 6 + 60);
2581 _506F18_num_hours_to_sleep = 0; 2562 _506F18_num_minutes_to_sleep = 0;
2582 dword_506F14 = 0; 2563 dword_506F14 = 0;
2583 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) 2564 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
2584 { 2565 {
2585 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; 2566 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
2586 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; 2567 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
2592 pAudioPlayer->PlaySound((SoundID)227, 0, 0, -1, 0, 0, 0, 0); 2573 pAudioPlayer->PlaySound((SoundID)227, 0, 0, -1, 0, 0, 0, 0);
2593 continue; 2574 continue;
2594 } 2575 }
2595 } 2576 }
2596 Party::TakeFood(uRestUI_FoodRequiredToRest); 2577 Party::TakeFood(uRestUI_FoodRequiredToRest);
2597 _506F18_num_hours_to_sleep = 480; 2578 _506F18_num_minutes_to_sleep = 480;
2598 dword_506F14 = 2; 2579 dword_506F14 = 2;
2599 pParty->RestAndHeal(); 2580 pParty->RestAndHeal();
2600 pParty->days_played_without_rest = 0; 2581 pParty->days_played_without_rest = 0;
2601 pParty->pPlayers[3].SetAsleep(1); 2582 pParty->pPlayers[3].SetAsleep(1);
2602 pParty->pPlayers[2].SetAsleep(1); 2583 pParty->pPlayers[2].SetAsleep(1);
2613 } 2594 }
2614 GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_PressedButton2, 2595 GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_PressedButton2,
2615 (int)pButton_RestUI_WaitUntilDawn, pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn" 2596 (int)pButton_RestUI_WaitUntilDawn, pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn"
2616 v97 = _494820_training_time(pParty->uCurrentHour); 2597 v97 = _494820_training_time(pParty->uCurrentHour);
2617 dword_506F14 = 1; 2598 dword_506F14 = 1;
2618 _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute; 2599 _506F18_num_minutes_to_sleep = 60 * v97 - pParty->uCurrentMinute;
2619 continue; 2600 continue;
2620 case UIMSG_HintSelectRemoveQuickSpellBtn: 2601 case UIMSG_HintSelectRemoveQuickSpellBtn:
2621 if ( quick_spell_at_page && byte_506550 ) 2602 if ( quick_spell_at_page && byte_506550 )
2622 { 2603 {
2623 v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName; 2604 v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName;
2665 pAudioPlayer->PlaySound((SoundID)203, 0, 0, -1, 0, 0, 0, 0); 2646 pAudioPlayer->PlaySound((SoundID)203, 0, 0, -1, 0, 0, 0, 0);
2666 continue; 2647 continue;
2667 } 2648 }
2668 v99 = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage; 2649 v99 = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage;
2669 pPlayers[uActiveCharacter]->uQuickSpell = v99; 2650 pPlayers[uActiveCharacter]->uQuickSpell = v99;
2670 stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter); 2651 stru_AA1058[uActiveCharacter - 1]._494836(v99, uActiveCharacter);
2671 if ( uActiveCharacter ) 2652 if ( uActiveCharacter )
2672 pPlayer10->PlaySound(SPEECH_12, 0); 2653 pPlayer10->PlaySound(SPEECH_12, 0);
2673 byte_506550 = 0; 2654 byte_506550 = 0;
2674 continue; 2655 continue;
2675 case UIMSG_SpellBook_PressTab: 2656 case UIMSG_SpellBook_PressTab:
2711 { 2692 {
2712 ++uAction; 2693 ++uAction;
2713 if ( uAction >= (signed int)pNPCData4 ) 2694 if ( uAction >= (signed int)pNPCData4 )
2714 uAction = 0; 2695 uAction = 0;
2715 } 2696 }
2716 sub_41140B(); 2697 OnCloseSpellBookPage();
2717 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]); 2698 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]);
2718 pGUIWindow_CurrentMenu->OpenSpellBook(); 2699 pGUIWindow_CurrentMenu->OpenSpellBook();
2719 v127 = rand() % 2 + 204; 2700 v127 = rand() % 2 + 204;
2720 pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); 2701 pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0);
2721 continue; 2702 continue;
2722 case UIMSG_OpenSpellbookPage: 2703 case UIMSG_OpenSpellbookPage:
2723 if ( pTurnEngine->turn_stage == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage ) 2704 if ( pTurnEngine->turn_stage == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage )
2724 continue; 2705 continue;
2725 sub_41140B(); 2706 OnCloseSpellBookPage();
2726 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam; 2707 pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam;
2727 pGUIWindow_CurrentMenu->OpenSpellBook(); 2708 pGUIWindow_CurrentMenu->OpenSpellBook();
2728 v127 = rand() % 2 + 204; 2709 v127 = rand() % 2 + 204;
2729 pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); 2710 pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0);
2730 continue; 2711 continue;
2744 { 2725 {
2745 pGUIWindow_CurrentMenu->Release(); 2726 pGUIWindow_CurrentMenu->Release();
2746 pEventTimer->Resume(); 2727 pEventTimer->Resume();
2747 viewparams->bRedrawGameUI = 1; 2728 viewparams->bRedrawGameUI = 1;
2748 pCurrentScreen = SCREEN_GAME; 2729 pCurrentScreen = SCREEN_GAME;
2749 pIcons_LOD->_4114F2(); 2730 pIcons_LOD->RemoveTexturesPackFromTextureList();
2750 v103 = quick_spell_at_page + 11 * player->lastOpenedSpellbookPage; 2731 v103 = quick_spell_at_page + 11 * player->lastOpenedSpellbookPage;
2751 /*if ( dword_50C9E8 < 40 ) 2732 /*if ( dword_50C9E8 < 40 )
2752 { 2733 {
2753 dword_50C9EC[3 * dword_50C9E8] = UIMSG_CastSpellFromBook; 2734 dword_50C9EC[3 * dword_50C9E8] = UIMSG_CastSpellFromBook;
2754 dword_50C9EC[3 * dword_50C9E8 + 1] = v103; 2735 dword_50C9EC[3 * dword_50C9E8 + 1] = v103;
2860 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; 2841 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
2861 ++pMessageQueue_50CBD0->uNumMessages;*/ 2842 ++pMessageQueue_50CBD0->uNumMessages;*/
2862 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); 2843 pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
2863 continue; 2844 continue;
2864 case UIMSG_ClickAwardScrollBar: 2845 case UIMSG_ClickAwardScrollBar:
2865 dword_50651C = 1; 2846 books_page_number = 1;
2866 if ( pMouse->GetCursorPos(&v211)->y > 178 ) 2847 if ( pMouse->GetCursorPos(&v211)->y > 178 )
2867 dword_50651C = -1; 2848 books_page_number = -1;
2868 continue; 2849 continue;
2869 case UIMSG_ClickAwardsUpBtn: 2850 case UIMSG_ClickAwardsUpBtn:
2870 GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Up, 0); 2851 GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Up, 0);
2871 BtnUp_flag = 1; 2852 BtnUp_flag = 1;
2872 continue; 2853 continue;
3015 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; 2996 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
3016 GameUI_OnPlayerPortraitLeftClick(uMessageParam); 2997 GameUI_OnPlayerPortraitLeftClick(uMessageParam);
3017 continue; 2998 continue;
3018 case UIMSG_ShowStatus_Funds: 2999 case UIMSG_ShowStatus_Funds:
3019 v174 = (char *)pParty->uNumGoldInBank; 3000 v174 = (char *)pParty->uNumGoldInBank;
3020 v158 = pParty->uNumGold + pParty->uNumGoldInBank; 3001 //v158 = pParty->uNumGold + pParty->uNumGoldInBank;
3021 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], v158, v174);// "You have %d total gold, %d in the Bank" 3002 sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], pParty->uNumGold + pParty->uNumGoldInBank, v174);// "You have %d total gold, %d in the Bank"
3022 GameUI_SetFooterString(pTmpBuf.data()); 3003 GameUI_SetFooterString(pTmpBuf.data());
3023 continue; 3004 continue;
3024 case UIMSG_ShowStatus_DateTime: 3005 case UIMSG_ShowStatus_DateTime:
3025 pNPCData4 = (NPCData *)pParty->uCurrentHour; 3006 pNPCData4 = (NPCData *)pParty->uCurrentHour;
3026 if ( (signed int)pParty->uCurrentHour <= 12 ) 3007 if ( (signed int)pParty->uCurrentHour <= 12 )
3433 pGUIWindow_CurrentMenu->ptr_1C = v3; 3414 pGUIWindow_CurrentMenu->ptr_1C = v3;
3434 break; 3415 break;
3435 case UIMSG_ChangeGameState: 3416 case UIMSG_ChangeGameState:
3436 uGameState = GAME_FINISHED; 3417 uGameState = GAME_FINISHED;
3437 break; 3418 break;
3438 case UIMSG_11: 3419 case UIMSG_ChangeCursor:
3439 pMouse->SetCursorBitmap("MICON2"); 3420 pMouse->SetCursorBitmap("MICON2");
3440 break; 3421 break;
3441 case UIMSG_3A: 3422 case UIMSG_3A:
3442 SetCurrentMenuID(MENU_10); 3423 SetCurrentMenuID(MENU_10);
3443 break; 3424 break;
3546 pMessageQueue_50CBD0->AddMessage(UIMSG_ChangeGameState, 0, 0); 3527 pMessageQueue_50CBD0->AddMessage(UIMSG_ChangeGameState, 0, 0);
3547 break; 3528 break;
3548 } 3529 }
3549 if ( pCurrentScreen == SCREEN_LOADGAME ) 3530 if ( pCurrentScreen == SCREEN_LOADGAME )
3550 { 3531 {
3551 pIcons_LOD->_4114F2(); 3532 pIcons_LOD->RemoveTexturesPackFromTextureList();
3552 //crt_deconstruct_ptr_6A0118(); 3533 //crt_deconstruct_ptr_6A0118();
3553 pTexture_PCX.Release(); 3534 pTexture_PCX.Release();
3554 pTexture_PCX.Load("title.pcx", 0); 3535 pTexture_PCX.Load("title.pcx", 0);
3555 SetCurrentMenuID(MENU_MAIN); 3536 SetCurrentMenuID(MENU_MAIN);
3556 v15 = 1; 3537 v15 = 1;
3581 //VideoPlayer::dtor(); 3562 //VideoPlayer::dtor();
3582 } 3563 }
3583 break; 3564 break;
3584 case UIMSG_PlayerCreationRemoveDownSkill: 3565 case UIMSG_PlayerCreationRemoveDownSkill:
3585 uPlayerCreationUI_SelectedCharacter = pParam; 3566 uPlayerCreationUI_SelectedCharacter = pParam;
3567 __debugbreak();
3586 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7 3568 pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7
3587 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; 3569 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam;
3588 pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(3) 3570 pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(3)
3589 + 3486 * uPlayerCreationUI_SelectedCharacter] = 0; 3571 + 3486 * uPlayerCreationUI_SelectedCharacter] = 0;
3590 break; 3572 break;
3597 } 3579 }
3598 3580
3599 //----- (00436427) -------------------------------------------------------- 3581 //----- (00436427) --------------------------------------------------------
3600 double __cdecl get_shading_dist_mist() 3582 double __cdecl get_shading_dist_mist()
3601 { 3583 {
3602 double result; // st7@2 3584 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3603 3585 return (double)pOutdoorCamera->shading_dist_mist;
3604 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3605 result = (double)pOutdoorCamera->shading_dist_mist;
3606 else 3586 else
3607 result = 16192.0; 3587 return 16192.0;
3608 return result;
3609 } 3588 }
3610 3589
3611 //----- (0043648F) -------------------------------------------------------- 3590 //----- (0043648F) --------------------------------------------------------
3612 void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2) 3591 void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2)
3613 { 3592 {
3624 this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x; 3603 this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x;
3625 this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y; 3604 this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y;
3626 this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z; 3605 this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z;
3627 } 3606 }
3628 3607
3629 //----- (00438526) --------------------------------------------------------
3630 stru11::stru11()
3631 {
3632 stru11 *v1; // esi@1
3633 signed int v2; // eax@1
3634 char *v3; // edx@1
3635
3636 v1 = this;
3637 v2 = 0;
3638 this->cpuid_00000000_eax_numops = 0;
3639 this->cpuid_00000001_eax = 0;
3640 this->cpuid_00000001_edx = 0;
3641 this->field_38 = 0;
3642 this->field_3C = 0;
3643 this->cpuid_80000000_edx = 0;
3644 this->cpuid_80000001_eax = 0;
3645 this->cpuid_80000001_edx = 0;
3646 this->cpuid_80000005_ebx = 0;
3647 this->cpuid_80000005_ecx = 0;
3648 this->cpuid_80000005_edx = 0;
3649 this->cpuid_80000006_ecx = 0;
3650 this->field_AC = 0;
3651 this->uProcessorManufacturer = 0;
3652 LOBYTE(this->cpuid_80000002_registers2[0]) = 0;
3653 v3 = (char *)&this->cpuid_00000002_eax;
3654 do
3655 {
3656 if ( v2 < 3 )
3657 *((int *)v3 - 9) = 0;
3658 if ( v2 < 4 )
3659 *(int *)v3 = 0;
3660 if ( v2 < 12 )
3661 *((int *)v3 + 17) = 0;
3662 if ( v2 < 13 )
3663 this->pCPUString[v2] = 0;
3664 if ( v2 < 30 )
3665 *((char *)this->field_40 + v2) = 0;
3666 *((char *)&this->cpuid_80000002_registers2[0] + v2++ + 1) = 0;
3667 v3 += 4;
3668 }
3669 while ( v2 < 48 );
3670 CheckCPU();
3671 }
3672
3673 //----- (004385B5) --------------------------------------------------------
3674 void stru11::CheckCPU()
3675 {
3676 LOG_DECOMPILATION_WARNING();
3677 /*
3678 int v5; // [sp-4h] [bp-10h]@0
3679 signed int v6; // [sp+4h] [bp-8h]@1
3680 signed int v7; // [sp+8h] [bp-4h]@1
3681
3682 _CF = 0;
3683 _OF = 0;
3684 _ZF = 1;
3685 _SF = 0;
3686 v7 = 0;
3687 __asm { pushf }
3688 v6 = 3;
3689 if ( v5 != (v5 ^ 0x40000) )
3690 {
3691 __asm { popf }
3692 v6 = 4;
3693 __asm { pushf }
3694 if ( v5 != (v5 ^ 0x200000) )
3695 {
3696 v7 = 1;
3697 v6 = 0;
3698 }
3699 }
3700 if ( v6 == 3 )
3701 {
3702 this->field_AC = 1;
3703 }
3704 else
3705 {
3706 if ( v6 == 4 )
3707 {
3708 this->field_AC = 2;
3709 }
3710 else
3711 {
3712 if ( v7 )
3713 {
3714 this->field_AC = 2;
3715 RunCPUID();
3716 }
3717 else
3718 {
3719 this->field_AC = 0;
3720 }
3721 }
3722 }*/
3723 }
3724
3725 //----- (00438659) --------------------------------------------------------
3726 void stru11::RunCPUID()
3727 {
3728 __debugbreak();
3729 /*stru11 *v6; // esi@1
3730 unsigned int uNumOps; // edi@1
3731 int uNumExtOps; // edi@16
3732 char pCyrixString[16]; // [sp+Ch] [bp-60h]@1
3733 char pCentaurString[16]; // [sp+1Ch] [bp-50h]@1
3734 char pAMDString[16]; // [sp+2Ch] [bp-40h]@1
3735 char pIntelString[16]; // [sp+3Ch] [bp-30h]@1
3736 char pCPUString[16]; // [sp+4Ch] [bp-20h]@1
3737 stru11 *thisa; // [sp+5Ch] [bp-10h]@1
3738 char *v35; // [sp+60h] [bp-Ch]@1
3739 int v36; // [sp+64h] [bp-8h]@1
3740 int v37; // [sp+68h] [bp-4h]@1
3741
3742 thisa = this;
3743 *(int *)pIntelString = *(int *)"GenuineIntel";
3744 *(int *)&pIntelString[4] = *(int *)"ineIntel";
3745 *(int *)&pIntelString[8] = *(int *)"ntel";
3746 pIntelString[12] = aGenuineintel[12];
3747 *(int *)pAMDString = *(int *)"AuthenticAMD";
3748 *(int *)&pAMDString[4] = *(int *)"enticAMD";
3749 *(int *)&pAMDString[8] = *(int *)"cAMD";
3750 pAMDString[12] = aAuthenticamd[12];
3751 *(int *)pCyrixString = *(int *)"CyrixInstead";
3752 *(int *)&pCyrixString[4] = *(int *)"xInstead";
3753 *(int *)&pCyrixString[8] = *(int *)"tead";
3754 pCyrixString[12] = aCyrixinstead[12];
3755 *(int *)pCentaurString = *(int *)"CentaurHauls";
3756 *(int *)&pCentaurString[4] = *(int *)"aurHauls";
3757 *(int *)&pCentaurString[8] = *(int *)"auls";
3758 v37 = 0;
3759 v36 = 0;
3760 pCentaurString[12] = aCentaurhauls[12];
3761 v35 = pCPUString;
3762 pCPUString[12] = 0;
3763 _EAX = 0;
3764 __asm { cpuid }
3765 v37 = _EAX;
3766 *(int *)pCPUString = _EBX;
3767 *(int *)&pCPUString[4] = _EDX;
3768 *(int *)&pCPUString[8] = _ECX;
3769 v6 = thisa;
3770 uNumOps = _EAX;
3771 thisa->cpuid_00000000_ebx_vendorstr1 = _EBX;
3772 v6->cpuid_00000000_edx_vendorstr2 = *(int *)&pCPUString[4];
3773 v6->cpuid_00000000_ecx_vendorstr3 = *(int *)&pCPUString[8];
3774 v6->cpuid_00000000_eax_numops = _EAX;
3775 strcpy(v6->pCPUString, pCPUString);
3776 if ( strcmp(pIntelString, pCPUString) )
3777 {
3778 if ( strcmp(pAMDString, pCPUString) )
3779 {
3780 if ( strcmp(pCyrixString, pCPUString) )
3781 {
3782 if ( strcmp(pCentaurString, pCPUString) )
3783 v6->uProcessorManufacturer = 0;
3784 else
3785 v6->uProcessorManufacturer = 4;
3786 }
3787 else
3788 {
3789 v6->uProcessorManufacturer = 3;
3790 }
3791 }
3792 else
3793 {
3794 v6->uProcessorManufacturer = 2;
3795 }
3796 }
3797 else
3798 {
3799 v6->uProcessorManufacturer = 1;
3800 }
3801 if ( uNumOps >= 1 )
3802 RunCPUID_op1();
3803 if ( uNumOps >= 2 )
3804 RunCPUID_op2();
3805 _EAX = 0x80000000u;
3806 __asm { cpuid }
3807 if ( !(_EAX & 0x80000000) )
3808 _EAX = 0x80000000u;
3809 v36 = _EAX;
3810 v6->cpuid_80000000_edx = _EAX;
3811 uNumExtOps = _EAX ^ 0x80000000;
3812 if ( (_EAX ^ 0x80000000u) >= 1 )
3813 {
3814 _EAX = 0x80000001u;
3815 __asm { cpuid }
3816 thisa = (stru11 *)_EAX;
3817 v35 = (char *)_EDX;
3818 v6->cpuid_80000001_eax = _EAX;
3819 v6->cpuid_80000001_edx = (int)v35;
3820 }
3821 if ( (unsigned int)uNumExtOps >= 4 )
3822 RunCPUID_ext2_3_4();
3823 if ( (unsigned int)uNumExtOps >= 5 )
3824 {
3825 _EAX = 0x80000005u;
3826 __asm { cpuid }
3827 thisa = (stru11 *)_EBX;
3828 v35 = (char *)_ECX;
3829 v36 = _EDX;
3830 v6->cpuid_80000005_ebx = _EBX;
3831 v6->cpuid_80000005_ecx = (int)v35;
3832 v6->cpuid_80000005_edx = v36;
3833 }
3834 if ( (unsigned int)uNumExtOps >= 6 )
3835 {
3836 _EAX = 0x80000006u;
3837 __asm { cpuid }
3838 v6->cpuid_80000006_ecx = _ECX;
3839 }*/
3840 }
3841
3842 //----- (00438821) --------------------------------------------------------
3843 void stru11::RunCPUID_op1()
3844 {
3845 __debugbreak();
3846 /*stru11 *v1; // esi@1
3847 unsigned int v7; // ecx@1
3848 int v8; // eax@3
3849 int v9; // eax@10
3850 signed int v10; // eax@11
3851 int v11; // ecx@11
3852 int v12; // eax@15
3853 signed int v13; // eax@19
3854 int v14; // ecx@19
3855 signed int v15; // eax@25
3856 int v16; // ecx@25
3857 signed int v17; // eax@34
3858 int v18; // ecx@34
3859
3860 v1 = this;
3861 _EAX = 1;
3862 __asm { cpuid }
3863 v7 = _EAX;
3864 v1->cpuid_00000001_edx = _EDX;
3865 v1->cpuid_00000001_eax = _EAX;
3866 if ( (_EAX & 0x3000) == 8192 )
3867 {
3868 LOBYTE(v1->cpuid_80000002_registers2[0]) = 1;
3869 v7 = 0;
3870 }
3871 v8 = (v7 >> 8) & 0xF;
3872 switch ( v8 )
3873 {
3874 case 4:
3875 v1->field_AC = 2;
3876 break;
3877 case 5:
3878 v1->field_AC = 15;
3879 break;
3880 case 6:
3881 v1->field_AC = 36;
3882 break;
3883 default:
3884 v1->field_AC = 49;
3885 break;
3886 }
3887 v9 = v1->uProcessorManufacturer;
3888 if ( v9 == 1 )
3889 {
3890 v10 = 0;
3891 v11 = v7 & 0x3FF0;
3892 while ( v11 != dword_4E4948[2 * v10] )
3893 {
3894 ++v10;
3895 if ( v10 >= 17 )
3896 return;
3897 }
3898 v12 = dword_4E494C[2 * v10];
3899 goto LABEL_39;
3900 }
3901 if ( v9 == 2 )
3902 {
3903 if ( (v7 & 0xF00) == dword_4E49D0[0] )
3904 {
3905 v12 = dword_4E49D4[0];
3906 }
3907 else
3908 {
3909 v13 = 1;
3910 v14 = v7 & 0x3FF0;
3911 while ( v14 != dword_4E49D0[2 * v13] )
3912 {
3913 ++v13;
3914 if ( v13 >= 9 )
3915 return;
3916 }
3917 v12 = dword_4E49D4[2 * v13];
3918 }
3919 goto LABEL_39;
3920 }
3921 if ( v9 != 3 )
3922 {
3923 if ( v9 != 4 )
3924 return;
3925 v17 = 0;
3926 v18 = v7 & 0x3FF0;
3927 while ( v18 != dword_4E4A40[2 * v17] )
3928 {
3929 ++v17;
3930 if ( v17 >= 2 )
3931 return;
3932 }
3933 v12 = dword_4E4A44[2 * v17];
3934 goto LABEL_39;
3935 }
3936 v15 = 1;
3937 v16 = v7 & 0x3FF0;
3938 while ( v16 != dword_4E4A18[2 * v15] )
3939 {
3940 ++v15;
3941 if ( v15 >= 5 )
3942 goto LABEL_30;
3943 }
3944 v1->field_AC = dword_4E4A1C[2 * v15];
3945 LABEL_30:
3946 v12 = 24;
3947 if ( v1->field_AC == 24 )
3948 {
3949 if ( _EDX != 1 )
3950 v12 = (((_EDX != 261) - 1) & 0xA) + 15;
3951 LABEL_39:
3952 v1->field_AC = v12;
3953 }*/
3954 }
3955
3956 //----- (00438992) --------------------------------------------------------
3957 void stru11::RunCPUID_op2()
3958 {
3959 __debugbreak();
3960 /*
3961 stru11 *v1; // edi@1
3962 int v7; // eax@1
3963 signed int v8; // ecx@2
3964 unsigned __int8 v9; // al@3
3965 signed int v10; // ecx@14
3966 unsigned __int8 v11; // al@15
3967 int v12; // [sp+Ch] [bp-14h]@1
3968 int v13; // [sp+10h] [bp-10h]@1
3969 int v14; // [sp+14h] [bp-Ch]@1
3970 int v15; // [sp+18h] [bp-8h]@1
3971 int *v16; // [sp+1Ch] [bp-4h]@1
3972
3973 v1 = this;
3974 v16 = &v12;
3975 _EAX = 2;
3976 __asm { cpuid }
3977 v12 = _EAX;
3978 v13 = _EBX;
3979 v14 = _ECX;
3980 v15 = _EDX;
3981 v1->cpuid_00000002_eax = _EAX;
3982 v1->cpuid_00000002_ebx = v13;
3983 v1->cpuid_00000002_ecx = v14;
3984 v1->cpuid_00000002_edx = v15;
3985 v7 = v1->field_AC;
3986 if ( v7 == 40 )
3987 {
3988 v8 = 0;
3989 while ( 1 )
3990 {
3991 v9 = *((char *)&v12 + v8);
3992 if ( v9 == 64 )
3993 {
3994 v1->field_AC = 43;
3995 return;
3996 }
3997 if ( v9 >= 0x41u && v9 <= 0x43u )
3998 {
3999 v1->field_AC = 41;
4000 return;
4001 }
4002 if ( v9 >= 0x44u && v9 <= 0x45u )
4003 break;
4004 ++v8;
4005 if ( v8 >= 16 )
4006 return;
4007 }
4008 v1->field_AC = 42;
4009 }
4010 else
4011 {
4012 if ( v7 == 45 )
4013 {
4014 v10 = 0;
4015 while ( 1 )
4016 {
4017 v11 = *((char *)&v12 + v10);
4018 if ( v11 >= 0x40u && v11 <= 0x43u )
4019 {
4020 v1->field_AC = 46;
4021 return;
4022 }
4023 if ( v11 >= 0x44u && v11 <= 0x45u )
4024 break;
4025 ++v10;
4026 if ( v10 >= 16 )
4027 return;
4028 }
4029 v1->field_AC = 47;
4030 }
4031 }*/
4032 }
4033
4034 //----- (00438A67) --------------------------------------------------------
4035 void stru11::RunCPUID_ext2_3_4()
4036 {
4037 __debugbreak();
4038 /*stru11 *v1; // edi@1
4039 stru11 *v17; // eax@1
4040 int v18[3][4]; // [sp+Ch] [bp-38h]@1
4041 stru11 *v19; // [sp+3Ch] [bp-8h]@1
4042
4043 v1 = this;
4044 v19 = this;
4045 _EAX = 0x80000002u;
4046 __asm { cpuid }
4047 v18[0][0] = _EAX;
4048 *(_QWORD *)&v18[0][1] = __PAIR__(_ECX, _EBX);
4049 v18[0][3] = _EDX;
4050 _EAX = 0x80000003u;
4051 __asm { cpuid }
4052 v18[1][0] = _EAX;
4053 *(_QWORD *)&v18[1][1] = __PAIR__(_ECX, _EBX);
4054 v18[1][3] = _EDX;
4055 _EAX = 0x80000004u;
4056 __asm { cpuid }
4057 v18[2][0] = _EAX;
4058 *(_QWORD *)&v18[2][1] = __PAIR__(_ECX, _EBX);
4059 v18[2][3] = _EDX;
4060 v17 = v19;
4061 memcpy(v1->cpuid_80000002_registers, v18, 0x30u);
4062 memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u);*/
4063 }
4064
4065 //----- (00438F8F) -------------------------------------------------------- 3608 //----- (00438F8F) --------------------------------------------------------
4066 void __cdecl area_of_effect__damage_evaluate() 3609 void area_of_effect__damage_evaluate()
4067 { 3610 {
4068 int v0; // edx@1 3611 int v0; // edx@1
4069 char *v1; // esi@2 3612 char *v1; // esi@2
4070 int v2; // ecx@3 3613 int v2; // ecx@3
4071 signed int v3; // eax@3 3614 signed int v3; // eax@3
4293 // 4D864C: using guessed type char byte_4D864C; 3836 // 4D864C: using guessed type char byte_4D864C;
4294 3837
4295 //----- (0043A97E) -------------------------------------------------------- 3838 //----- (0043A97E) --------------------------------------------------------
4296 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) 3839 void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2)
4297 { 3840 {
4298 if ( PID_TYPE(a2) == OBJECT_BLVDoor) 3841 if (PID_TYPE(a2) == OBJECT_BLVDoor)
4299 { 3842 {
4300 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; 3843 layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x;
4301 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; 3844 layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y;
4302 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; 3845 layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z;
4303 3846
4550 } 4093 }
4551 } 4094 }
4552 } 4095 }
4553 } 4096 }
4554 4097
4555 // A750D8: using guessed type __int64 qword_A750D8;
4556
4557
4558 // A750D8: using guessed type __int64 qword_A750D8;
4559
4560
4561 // A750D8: using guessed type __int64 qword_A750D8;
4562 4098
4563 //----- (0043F515) -------------------------------------------------------- 4099 //----- (0043F515) --------------------------------------------------------
4564 void FindBillboardsLightLevels_BLV() 4100 void FindBillboardsLightLevels_BLV()
4565 { 4101 {
4566 for (uint i = 0; i < uNumBillboardsToDraw; ++i) 4102 for (uint i = 0; i < uNumBillboardsToDraw; ++i)
5155 v28 = v17; 4691 v28 = v17;
5156 v18 = dword_4F5CC4_ys[1] >= v8; 4692 v18 = dword_4F5CC4_ys[1] >= v8;
5157 v19 = 0; 4693 v19 = 0;
5158 v29 = 0; 4694 v29 = 0;
5159 if ( v17 <= 0 ) 4695 if ( v17 <= 0 )
5160 goto LABEL_29; 4696 return 0;
5161 do 4697 do
5162 { 4698 {
5163 if ( a3a >= 2 ) 4699 if ( a3a >= 2 )
5164 break; 4700 break;
5165 v20 = v19; 4701 v20 = v19;
5190 v19 = v29++ + 1; 4726 v19 = v29++ + 1;
5191 } 4727 }
5192 while ( v29 < v28 ); 4728 while ( v29 < v28 );
5193 result = 1; 4729 result = 1;
5194 if ( a3a != 1 ) 4730 if ( a3a != 1 )
5195 LABEL_29:
5196 result = 0; 4731 result = 0;
5197 return result; 4732 return result;
5198 } 4733 }
5199 4734
5200 //----- (004077F1) -------------------------------------------------------- 4735 //----- (004077F1) --------------------------------------------------------
5290 dword_4F5BF4_xs[v15 + 1] = dword_4F5BF4_xs[1]; 4825 dword_4F5BF4_xs[v15 + 1] = dword_4F5BF4_xs[1];
5291 dword_4F5B24_ys[v15 + 1] = dword_4F5B24_ys[1]; 4826 dword_4F5B24_ys[v15 + 1] = dword_4F5B24_ys[1];
5292 v25 = 0; 4827 v25 = 0;
5293 v16 = dword_4F5B24_ys[1] >= a3; 4828 v16 = dword_4F5B24_ys[1] >= a3;
5294 if ( v15 <= 0 ) 4829 if ( v15 <= 0 )
5295 goto LABEL_29; 4830 return 0;
5296 do 4831 do
5297 { 4832 {
5298 if ( a5a >= 2 ) 4833 if ( a5a >= 2 )
5299 break; 4834 break;
5300 v17 = v25; 4835 v17 = v25;
5325 v16 = v18 >= a3; 4860 v16 = v18 >= a3;
5326 } 4861 }
5327 while ( v25 < v15 ); 4862 while ( v25 < v15 );
5328 result = 1; 4863 result = 1;
5329 if ( a5a != 1 ) 4864 if ( a5a != 1 )
5330 LABEL_29:
5331 result = 0; 4865 result = 0;
5332 return result; 4866 return result;
5333 } 4867 }
5334 4868
5335 //----- (004088E9) -------------------------------------------------------- 4869 //----- (004088E9) --------------------------------------------------------
5349 v8 = abs(a4 - v10); 4883 v8 = abs(a4 - v10);
5350 result = integer_sqrt(v11 * v11 + v8 * v8); 4884 result = integer_sqrt(v11 * v11 + v8 * v8);
5351 if ( result ) 4885 if ( result )
5352 result = abs((v7 * (v10 - a6) - (a4 - v10) * (v6 - a5)) / result); 4886 result = abs((v7 * (v10 - a6) - (a4 - v10) * (v6 - a5)) / result);
5353 return result; 4887 return result;
5354 }
5355
5356 //----- (0040DEDB) --------------------------------------------------------
5357 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor)
5358 {
5359 return TargetColor((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
5360 } 4888 }
5361 4889
5362 //----- (0040DEF3) -------------------------------------------------------- 4890 //----- (0040DEF3) --------------------------------------------------------
5363 unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b ) 4891 unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
5364 { 4892 {
5615 pOut.y = SkillToMastery(v8); 5143 pOut.y = SkillToMastery(v8);
5616 v10 = pOut.z; 5144 v10 = pOut.z;
5617 if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE ) 5145 if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE )
5618 { 5146 {
5619 LABEL_116: 5147 LABEL_116:
5620 GameUI_DrawItemInfo(&v0->pInventoryItems[v10]); 5148 GameUI_DrawItemInfo(&v0->pInventoryItemList[v10]);
5621 return; 5149 return;
5622 } 5150 }
5623 if ( (signed int)pParty->pPickedItem.uItemID < 200 5151 if ( (signed int)pParty->pPickedItem.uItemID < 200
5624 || (signed int)pParty->pPickedItem.uItemID > 219 5152 || (signed int)pParty->pPickedItem.uItemID > 219
5625 || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) ) 5153 || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) )
5632 if ( pParty->pPickedItem.uItemID != 236 5160 if ( pParty->pPickedItem.uItemID != 236
5633 && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250) 5161 && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250)
5634 && pParty->pPickedItem.uItemID != 263 5162 && pParty->pPickedItem.uItemID != 263
5635 && pParty->pPickedItem.uItemID != 233 ) 5163 && pParty->pPickedItem.uItemID != 233 )
5636 goto LABEL_116; 5164 goto LABEL_116;
5637 v27 = &v0->pInventoryItems[pOut.z]; 5165 v27 = &v0->pInventoryItemList[pOut.z];
5638 v28 = v27->uItemID; 5166 v28 = v27->uItemID;
5639 v51 = pItemsTable->pItems[v27->uItemID].uEquipType; 5167 v51 = pItemsTable->pItems[v27->uItemID].uEquipType;
5640 v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType); 5168 v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType);
5641 if ( pParty->pPickedItem.uItemID != 233 ) 5169 if ( pParty->pPickedItem.uItemID != 233 )
5642 { 5170 {
5643 if ( pParty->pPickedItem.uItemID == 236 ) 5171 if ( pParty->pPickedItem.uItemID == 236 )
5644 { 5172 {
5645 v35 = v27->uAttributes; 5173 v35 = v27->uAttributes;
5646 if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 ) 5174 if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 )
5647 goto LABEL_92; 5175 {
5176 pMouse->RemoveHoldingItem();
5177 dword_50CDCC = 1;
5178 return;
5179 }
5648 LOWORD(v35) = v35 | 0x210; 5180 LOWORD(v35) = v35 | 0x210;
5649 v27->uAttributes = v35; 5181 v27->uAttributes = v35;
5650 } 5182 }
5651 else 5183 else
5652 { 5184 {
5653 if ( (signed int)pParty->pPickedItem.uItemID <= 245 ) 5185 if ( (signed int)pParty->pPickedItem.uItemID <= 245 )
5654 goto LABEL_92; 5186 {
5187 pMouse->RemoveHoldingItem();
5188 dword_50CDCC = 1;
5189 return;
5190 }
5655 if ( (signed int)pParty->pPickedItem.uItemID <= 250 ) 5191 if ( (signed int)pParty->pPickedItem.uItemID <= 250 )
5656 { 5192 {
5657 v27->UpdateTempBonus(pParty->uTimePlayed); 5193 v27->UpdateTempBonus(pParty->uTimePlayed);
5658 v33 = v27->uItemID; 5194 v33 = v27->uItemID;
5659 if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65 5195 if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65
5660 || (pOut.y = v27->uAttributes, pOut.y & 2) 5196 || (pOut.y = v27->uAttributes, pOut.y & 2)
5661 || v27->uSpecEnchantmentType 5197 || v27->uSpecEnchantmentType
5662 || v27->uEnchantmentType 5198 || v27->uEnchantmentType
5663 || v51 && v51 != 1 && v51 != 2 5199 || v51 && v51 != 1 && v51 != 2
5664 || (signed int)v33 >= 500 ) 5200 || (signed int)v33 >= 500 )
5665 goto LABEL_92; 5201 {
5202 pMouse->RemoveHoldingItem();
5203 dword_50CDCC = 1;
5204 return;
5205 }
5666 v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4]; 5206 v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4];
5667 a2.y = (int)v29 << 7; 5207 a2.y = (int)v29 << 7;
5668 v31 = (double)(signed int)((int)v29 << 7); 5208 v31 = (double)(signed int)((int)v29 << 7);
5669 v27->uSpecEnchantmentType = v34; 5209 v27->uSpecEnchantmentType = v34;
5670 } 5210 }
5676 || (pOut.y = v27->uAttributes, pOut.y & 2) 5216 || (pOut.y = v27->uAttributes, pOut.y & 2)
5677 || v27->uSpecEnchantmentType 5217 || v27->uSpecEnchantmentType
5678 || v27->uEnchantmentType 5218 || v27->uEnchantmentType
5679 || v51 && v51 != 1 && v51 != 2 5219 || v51 && v51 != 1 && v51 != 2
5680 || (signed int)v30 >= 500 ) 5220 || (signed int)v30 >= 500 )
5681 goto LABEL_92; 5221 {
5222 pMouse->RemoveHoldingItem();
5223 dword_50CDCC = 1;
5224 return;
5225 }
5682 a2.y = (int)v29 << 7; 5226 a2.y = (int)v29 << 7;
5683 v27->uSpecEnchantmentType = 40; 5227 v27->uSpecEnchantmentType = 40;
5684 v31 = (double)a2.y; 5228 v31 = (double)a2.y;
5685 } 5229 }
5686 v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335); 5230 v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335);
5689 LOBYTE(v32) = LOBYTE(pOut.y) | 0x18; 5233 LOBYTE(v32) = LOBYTE(pOut.y) | 0x18;
5690 HIDWORD(v27->uExpireTime) = HIDWORD(v32); 5234 HIDWORD(v27->uExpireTime) = HIDWORD(v32);
5691 v27->uAttributes = v32; 5235 v27->uAttributes = v32;
5692 } 5236 }
5693 _50C9A8_item_enchantment_timer = 256; 5237 _50C9A8_item_enchantment_timer = 256;
5694 goto LABEL_92; 5238 pMouse->RemoveHoldingItem();
5239 dword_50CDCC = 1;
5240 return;
5695 } 5241 }
5696 v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; 5242 v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01;
5697 if ( v36 < 0.0 ) 5243 if ( v36 < 0.0 )
5698 v36 = 0.0; 5244 v36 = 0.0;
5699 if ( v51 != 12 ) 5245 if ( v51 != 12 )
5703 } 5249 }
5704 a2.y = v27->uMaxCharges; 5250 a2.y = v27->uMaxCharges;
5705 v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y); 5251 v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y);
5706 v27->uMaxCharges = v37; 5252 v27->uMaxCharges = v37;
5707 v27->uNumCharges = (unsigned __int8)v37; 5253 v27->uNumCharges = (unsigned __int8)v37;
5708 goto LABEL_92; 5254 pMouse->RemoveHoldingItem();
5255 dword_50CDCC = 1;
5256 return;
5709 } 5257 }
5710 v14 = v13 - 222; 5258 v14 = v13 - 222;
5711 v15 = pParty->pPickedItem.uItemID - 222; 5259 v15 = pParty->pPickedItem.uItemID - 222;
5712 v47 = v14; 5260 v47 = v14;
5713 y.y = 0; 5261 y.y = 0;
5772 goto LABEL_53; 5320 goto LABEL_53;
5773 } 5321 }
5774 LABEL_54: 5322 LABEL_54:
5775 pOut.y = 0; 5323 pOut.y = 0;
5776 pOut.x = v10 + 1; 5324 pOut.x = v10 + 1;
5777 v17 = (int)v0->pInventoryIndices; 5325 v17 = (int)v0->pInventoryMatrix;
5778 while ( *(int *)v17 != pOut.x ) 5326 while ( *(int *)v17 != pOut.x )
5779 { 5327 {
5780 ++pOut.y; 5328 ++pOut.y;
5781 v17 += 4; 5329 v17 += 4;
5782 if ( pOut.y >= 126 ) 5330 if ( pOut.y >= 126 )
5834 v19 = v0->AddItem(-1, 0xDCu); 5382 v19 = v0->AddItem(-1, 0xDCu);
5835 if ( v19 ) 5383 if ( v19 )
5836 // *(int *)&v0->field_1F5[36 * v19 + 15] = 1; 5384 // *(int *)&v0->field_1F5[36 * v19 + 15] = 1;
5837 v0->pOwnItems[v19-1].uAttributes=ITEM_IDENTIFIED; 5385 v0->pOwnItems[v19-1].uAttributes=ITEM_IDENTIFIED;
5838 v20 = v47 + 50 * v15; 5386 v20 = v47 + 50 * v15;
5839 v0->pInventoryItems[pOut.z].uItemID = v51; 5387 v0->pInventoryItemList[pOut.z].uItemID = v51;
5840 v0->pInventoryItems[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType 5388 v0->pInventoryItemList[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType
5841 + v0->pInventoryItems[pOut.z].uEnchantmentType) 5389 + v0->pInventoryItemList[pOut.z].uEnchantmentType)
5842 / 2; 5390 / 2;
5843 v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 5391 v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388
5844 LABEL_74: 5392 LABEL_74:
5845 v22 = (int)((char *)v0 + 36 * pOut.z); 5393 v22 = (int)((char *)v0 + 36 * pOut.z);
5846 if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) ) 5394 if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) )
5847 *(int *)(v22 + 552) |= 1u; 5395 *(int *)(v22 + 552) |= 1u;
5848 if ( !dword_4E455C ) 5396 if ( !dword_4E455C )
5849 goto LABEL_92; 5397 {
5398 pMouse->RemoveHoldingItem();
5399 dword_50CDCC = 1;
5400 return;
5401 }
5850 v0->PlaySound(SPEECH_16, 0); 5402 v0->PlaySound(SPEECH_16, 0);
5851 goto LABEL_91; 5403 dword_4E455C = 0;
5404 pMouse->RemoveHoldingItem();
5405 dword_50CDCC = 1;
5406 return;
5852 } 5407 }
5853 if ( v45 ) 5408 if ( v45 )
5854 { 5409 {
5855 if ( *(int *)(a2.y + 532) == 221 ) 5410 if ( *(int *)(a2.y + 532) == 221 )
5856 *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID; 5411 *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID;
5885 if ( dword_4E455C ) 5440 if ( dword_4E455C )
5886 { 5441 {
5887 if ( v0->CanAct() ) 5442 if ( v0->CanAct() )
5888 v0->PlaySound(SPEECH_17, 0); 5443 v0->PlaySound(SPEECH_17, 0);
5889 ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u); 5444 ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u);
5890 LABEL_91:
5891 dword_4E455C = 0; 5445 dword_4E455C = 0;
5892 } 5446 }
5893 LABEL_92:
5894 pMouse->RemoveHoldingItem(); 5447 pMouse->RemoveHoldingItem();
5895 dword_50CDCC = 1; 5448 dword_50CDCC = 1;
5896 return; 5449 return;
5897 } 5450 }
5898 *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice; 5451 *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice;
5901 case 0xC8u: 5454 case 0xC8u:
5902 case 0xC9u: 5455 case 0xC9u:
5903 case 0xCAu: 5456 case 0xCAu:
5904 case 0xCBu: 5457 case 0xCBu:
5905 case 0xCCu: 5458 case 0xCCu:
5906 v0->pInventoryItems[pOut.z].uItemID = 222; 5459 v0->pInventoryItemList[pOut.z].uItemID = 222;
5907 break; 5460 break;
5908 case 0xCDu: 5461 case 0xCDu:
5909 case 0xCEu: 5462 case 0xCEu:
5910 case 0xCFu: 5463 case 0xCFu:
5911 case 0xD0u: 5464 case 0xD0u:
5912 case 0xD1u: 5465 case 0xD1u:
5913 v0->pInventoryItems[pOut.z].uItemID = 223; 5466 v0->pInventoryItemList[pOut.z].uItemID = 223;
5914 break; 5467 break;
5915 case 0xD2u: 5468 case 0xD2u:
5916 case 0xD3u: 5469 case 0xD3u:
5917 case 0xD4u: 5470 case 0xD4u:
5918 case 0xD5u: 5471 case 0xD5u:
5919 case 0xD6u: 5472 case 0xD6u:
5920 v0->pInventoryItems[pOut.z].uItemID = 224; 5473 v0->pInventoryItemList[pOut.z].uItemID = 224;
5921 break; 5474 break;
5922 case 0xD7u: 5475 case 0xD7u:
5923 case 0xD8u: 5476 case 0xD8u:
5924 case 0xD9u: 5477 case 0xD9u:
5925 case 0xDAu: 5478 case 0xDAu:
5926 case 0xDBu: 5479 case 0xDBu:
5927 v0->pInventoryItems[pOut.z].uItemID = 221; 5480 v0->pInventoryItemList[pOut.z].uItemID = 221;
5928 break; 5481 break;
5929 default: 5482 default:
5930 break; 5483 break;
5931 } 5484 }
5932 pMouse->RemoveHoldingItem(); 5485 pMouse->RemoveHoldingItem();
5936 v0->PlaySound(SPEECH_16, 0); 5489 v0->PlaySound(SPEECH_16, 0);
5937 dword_4E455C = 0; 5490 dword_4E455C = 0;
5938 } 5491 }
5939 } 5492 }
5940 5493
5941 //----- (004179BC) --------------------------------------------------------
5942 void __fastcall sub_4179BC_draw_tooltip( const char *a1, const char *a2 )
5943 {
5944 const char *v2; // ebx@1
5945 const char *v3; // edi@1
5946 unsigned int v4; // eax@1
5947 GUIWindow Dst; // [sp+Ch] [bp-5Ch]@1
5948 POINT v6; // [sp+60h] [bp-8h]@1
5949
5950 v2 = a2;
5951 v3 = a1;
5952 memset(&Dst, 0, 0x54u);
5953 Dst.uFrameWidth = 384;
5954 Dst.uFrameHeight = 256;
5955 Dst.uFrameX = 128;
5956 Dst.uFrameY = pMouse->GetCursorPos(&v6)->y + 30;
5957 Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(v2, &Dst, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24;
5958 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
5959 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
5960 Dst.DrawMessageBox(0);
5961 Dst.uFrameX += 12;
5962 Dst.uFrameWidth -= 24;
5963 Dst.uFrameY += 12;
5964 Dst.uFrameHeight -= 12;
5965 Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
5966 Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
5967 v4 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
5968 sprintf(pTmpBuf.data(), format_4E2D80, v4, v3);
5969 Dst.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u);
5970 Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0);
5971 }
5972
5973 //----- (00417AD4) -------------------------------------------------------- 5494 //----- (00417AD4) --------------------------------------------------------
5974 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) 5495 unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level)
5975 { 5496 {
5976 int v8; // eax@10 5497 switch (uPlayerClass % 4)
5977 int v12; // eax@14
5978 unsigned int yellow; // [sp+Ch] [bp-Ch]@1
5979 unsigned int red; // [sp+10h] [bp-8h]@1
5980 unsigned int white; // [sp+14h] [bp-4h]@1
5981
5982 white = TargetColor(0xFFu, 0xFFu, 0xFFu);
5983 red = TargetColor(0xFFu, 0, 0);
5984 yellow = TargetColor(0xFFu, 0xFFu, 0);
5985 if ( !(uPlayerClass % 4) )
5986 { 5498 {
5987 if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level ) 5499 case 0:
5988 return white;
5989 if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level
5990 && byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level )
5991 { 5500 {
5992 v12 = byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType]; 5501 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level)
5993 if ( v12 < skill_level ) 5502 return ui_character_skillinfo_can_learn;
5994 return red; 5503 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level &&
5504 byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level)
5505 {
5506 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType] < skill_level)
5507 return ui_character_skillinfo_cant_learn;
5508 }
5509 return ui_character_skillinfo_can_learn_gm;
5995 } 5510 }
5996 return yellow; 5511 break;
5512
5513 case 1:
5514 {
5515 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level)
5516 return ui_character_skillinfo_can_learn;
5517 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level)
5518 {
5519 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level)
5520 return ui_character_skillinfo_cant_learn;
5521 }
5522 return ui_character_skillinfo_can_learn_gm;
5523 }
5524 break;
5525
5526 case 2:
5527 case 3:
5528 {
5529 if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level)
5530 return ui_character_skillinfo_cant_learn;
5531 return ui_character_skillinfo_can_learn;
5532 }
5533 break;
5997 } 5534 }
5998 if ( (uPlayerClass % 4) == 1 ) 5535 assert(false);
5999 { 5536 return 0;
6000 if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level )
6001 return white;
6002 if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level )
6003 {
6004 v8 = byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType];
6005 if ( v8 < skill_level)
6006 return red;
6007 }
6008 return yellow;
6009 }
6010 if ( (uPlayerClass % 4) == 2 || (uPlayerClass % 4) == 3 )
6011 {
6012 if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level )
6013 return red;
6014 }
6015 return white;
6016 } 5537 }