Mercurial > mm7
changeset 157:8e0e2991f9d1
Слияние
author | Ritor1 |
---|---|
date | Tue, 12 Feb 2013 18:16:34 +0600 |
parents | 2cb13d295f4b (current diff) 86a2637ba125 (diff) |
children | f4ebd13c2a8e |
files | mm7_3.cpp |
diffstat | 34 files changed, 1502 insertions(+), 1526 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Actor.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -2143,7 +2143,7 @@ } else { - if ( (edx0 & 7) == 3 ) + if ( (edx0 & 7) == OBJECT_Actor) { v8 = edx0 >> 3; v6 = (AIDirection *)pActors[v8].vPosition.x; @@ -2152,7 +2152,7 @@ } else { - if ( (edx0 & 7) == 4 ) + if ( (edx0 & 7) == OBJECT_Player) { v6 = (AIDirection *)pParty->vPosition.x; v7 = (AIDirection *)pParty->vPosition.y; @@ -2176,7 +2176,7 @@ v13 = 0; if ( !arg0 ) { - v14 = Actor::GetDirectionInfo(8 * v24 | 3, a2, &a3, 0); + v14 = Actor::GetDirectionInfo(8 * v24 | OBJECT_Actor, a2, &a3, 0); v12 = &v20; memcpy(&v20, v14, sizeof(v20)); v13 = 0; @@ -2542,7 +2542,7 @@ v22 = uActorID; v3 = &pActors[uActorID]; a2 = edx0; - if ( (edx0 & 7) == 3 ) + if ( (edx0 & 7) == OBJECT_Actor) { v6 = edx0 >> 3; v4 = (AIDirection *)pActors[v6].vPosition.x; @@ -2551,7 +2551,7 @@ } else { - if ( (edx0 & 7) == 4 ) + if ( (edx0 & 7) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2573,7 +2573,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v22 | 3, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, a2, &a3, 0); v9 = &v18; memcpy(&v18, v11, sizeof(v18)); v10 = 0; @@ -2654,7 +2654,7 @@ v22 = uActorID; v3 = &pActors[uActorID]; a2 = edx0; - if ( (edx0 & 7) == 3 ) + if ( (edx0 & 7) == OBJECT_Actor) { v6 = edx0 >> 3; v4 = (AIDirection *)pActors[v6].vPosition.x; @@ -2663,7 +2663,7 @@ } else { - if ( (edx0 & 7) == 4 ) + if ( (edx0 & 7) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2685,7 +2685,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v22 | 3, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, a2, &a3, 0); v9 = &v18; memcpy(&v18, v11, sizeof(v18)); v10 = 0; @@ -2765,7 +2765,7 @@ v21 = uActorID; v3 = &pActors[uActorID]; a2 = edx0; - if ( (edx0 & 7) == 3 ) + if ( (edx0 & 7) == OBJECT_Actor) { v6 = edx0 >> 3; v4 = (AIDirection *)pActors[v6].vPosition.x; @@ -2774,7 +2774,7 @@ } else { - if ( (edx0 & 7) == 4 ) + if ( (edx0 & 7) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2796,7 +2796,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v21 | 3, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0); v9 = &v17; memcpy(&v17, v11, sizeof(v17)); v10 = 0; @@ -2861,7 +2861,7 @@ v21 = uActorID; v3 = &pActors[uActorID]; a2 = edx0; - if ( (edx0 & 7) == 3 ) + if ( (edx0 & 7) == OBJECT_Actor) { v6 = edx0 >> 3; v4 = pActors[v6].vPosition.x; @@ -2870,7 +2870,7 @@ } else { - if ( (edx0 & 7) == 4 ) + if ( (edx0 & 7) == OBJECT_Player) { v4 = pParty->vPosition.x; v5 = pParty->vPosition.y; @@ -2900,7 +2900,7 @@ v11 = 0; if ( !pDir ) { - v12 = Actor::GetDirectionInfo(8 * v21 | 3, a2, &a3, 0); + v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0); v10 = &v18; memcpy(&v18, v12, sizeof(v18)); v11 = 0; @@ -3483,7 +3483,7 @@ memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3)); memcpy(&v13, &a3, sizeof(v13)); if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) - || (a2 & 7) == 3 && (double)(signed int)v13.uDistance < 307.2 ) + || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) { if ( !uActionLength ) uActionLength = 256;
--- a/Actor.h Tue Feb 12 18:16:18 2013 +0600 +++ b/Actor.h Tue Feb 12 18:16:34 2013 +0600 @@ -40,8 +40,8 @@ /* 361 */ enum ACTOR_BUFF_INDEX { - ACTOR_BUFF_STONED = 0x5, - ACTOR_BUFF_PARALYZED = 0x6, + ACTOR_BUFF_STONED = 5, + ACTOR_BUFF_PARALYZED = 6, }; @@ -52,7 +52,7 @@ enum ObjectType { OBJECT_unk0 = 0x0, - OBJECT_unk1 = 0x1, + OBJECT_BLVDoor = 0x1, OBJECT_Item = 0x2, OBJECT_Actor = 0x3, OBJECT_Player = 0x4, @@ -88,16 +88,16 @@ Fleeing = 0x7, Stunned = 0x8, Fidgeting = 0x9, - Interacting = 0xA, - Removed = 0xB, + Interacting = 10, + Removed = 11, AttackingRanged2 = 0xC, AttackingRanged3 = 0xD, Stoned = 0xE, Paralyzed = 0xF, - Resurrected = 0x10, - Summoned = 0x11, - AttackingRanged4 = 0x12, - Disabled = 0x13, + Resurrected = 16, + Summoned = 17, + AttackingRanged4 = 18, + Disabled = 19, }; /* 265 */
--- a/AudioPlayer.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/AudioPlayer.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -90,7 +90,7 @@ do { sprintf(pSoundName, "%s", pSounds[v2].pSoundName); - // pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID); Ritor1: it's error - result: no sound + // pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID); //Ritor1: it's error - result: no sound pSoundDesc = &pSoundList->pSounds[v2]; if ( pSoundList->pSounds[v2].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[v2].pSoundName), pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID), @@ -1758,8 +1758,7 @@ signed int v2; // eax@1 v2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->Atan2(a1 - pParty->vPosition.x, a2 - pParty->vPosition.y) - - stru_5C6E00->uIntegerHalfPi - - pParty->sRotationY); + - stru_5C6E00->uIntegerHalfPi - pParty->sRotationY); if ( v2 > (signed int)stru_5C6E00->uIntegerPi ) v2 = 2 * stru_5C6E00->uIntegerPi - v2; return (v2 >> 3) - (v2 >> 10);
--- a/GUIWindow.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/GUIWindow.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -474,7 +474,7 @@ pAudioPlayer->StopChannels(-1, -1); InitializeBookFonts(); v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); - pCurrentScreen = 3; + pCurrentScreen = SCREEN_BOOKS; dword_506524 = 0; dword_506528 = 0; dword_50651C = 0; @@ -978,7 +978,7 @@ LoadSpellbook(pPlayer->pNumSpellBookPage); v3 = 0; a2 = 0; - v7 = (int)(&pPlayer->spellbook.pFireSpellbook + pPlayer->pNumSpellBookPage); + v7 = (int)&pPlayer->spellbook.pChapters[pPlayer->pNumSpellBookPage]; do { if ( *(char *)(v7 + v3) ) @@ -1156,12 +1156,10 @@ goto LABEL_56; } v4 = (char *)array_5913D8[6] - 1; - pRenderer->DrawTextureIndexed( - _4E5E50_transui_x - 4, - _4E5EE0_transui_y - 4, + pRenderer->DrawTextureIndexed(_4E5E50_transui_x - 4, _4E5EE0_transui_y - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); pRenderer->DrawTextureIndexed(_4E5E50_transui_x, _4E5EE0_transui_y, pDialogueNPCPortraits[(signed int)v4]); - if ( pCurrentScreen == 14 ) + if ( pCurrentScreen == SCREEN_E ) { CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); goto LABEL_58; @@ -1859,7 +1857,7 @@ break; case WINDOW_A: pMainScreenNum = pCurrentScreen; - pCurrentScreen = 4; + pCurrentScreen = SCREEN_NPC_DIALOGUE; pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79], //"Exit" (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); if ( pWindow->ptr_1C != (void *)1 ) @@ -1957,7 +1955,7 @@ break; case WINDOW_ChangeLocation: pMainScreenNum = pCurrentScreen; - pCurrentScreen = 17; + pCurrentScreen = SCREEN_CHANGE_LOCATION; pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x5Bu, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[156],// (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x5Au, 0, 0x59u, pWindow->Hint, @@ -1972,7 +1970,7 @@ case WINDOW_GreetingNPC: // pMainScreenNum = pCurrentScreen; pKeyActionMap->EnterText(0, 15, pWindow); - pCurrentScreen = 19; + pCurrentScreen = SCREEN_BRANCHLESS_NPC_DIALOG; break; } return pWindow; @@ -1987,7 +1985,7 @@ } if (eWindowType == WINDOW_HouseInterior) { - pCurrentScreen = 13; + pCurrentScreen = SCREEN_HOUSE; pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[80],// (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); v25 = uNumDialogueNPCPortraits; @@ -2032,7 +2030,7 @@ if (eWindowType == WINDOW_1A) { pMainScreenNum = pCurrentScreen; - pCurrentScreen = 18; + pCurrentScreen = SCREEN_INPUT_BLV; pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x19Cu, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[34],// (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x19Bu, 0, 0x59u, pWindow->Hint, @@ -2067,7 +2065,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2);// ++pIcons_LOD->uTexturePacksCount; pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = 23; + pCurrentScreen = SCREEN_CASTING; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; }
--- a/GUIWindow.h Tue Feb 12 18:16:18 2013 +0600 +++ b/GUIWindow.h Tue Feb 12 18:16:34 2013 +0600 @@ -136,8 +136,17 @@ { UIMSG_00 = 0x0, UIMSG_ChangeGameState = 0x5, + UIMSG_A = 0xA, + UIMSG_C = 0xC, + UIMSG_E = 0xE, + UIMSG_F = 0xF, UIMSG_11 = 0x11, + UIMSG_17 = 0x17, + UIMSG_19 = 0x19, + UIMSG_1B = 0x1B, + UIMSG_1C = 0x1C, UIMSG_PlayArcomage = 0x1D, + UIMSG_33 = 0x33, UIMSG_MainMenu_ShowPartyCreationWnd = 0x36, UIMSG_MainMenu_ShowLoadWindow = 0x37, UIMSG_ShowCredits = 0x38, @@ -150,38 +159,74 @@ UIMSG_PlayerCreationSelectClass = 0x41, UIMSG_PlayerCreationClickOK = 0x42, UIMSG_PlayerCreationClickReset = 0x43, + UIMSG_45 = 0x45, + UIMSG_46 = 0x46, + UIMSG_AutonotesBook = 0x47, UIMSG_PlayerCreationRemoveUpSkill = 0x4A, UIMSG_PlayerCreationRemoveDownSkill = 0x4B, - UIMSG_4B = 0x4B, + UIMSG_4E = 0x4E, + UIMSG_4F = 0x4F, + UIMSG_51 = 0x51, UIMSG_LoadGame = 0x52, UIMSG_SaveGame = 0x53, + UIMSG_54 = 0x54, + UIMSG_55 = 0x55, + UIMSG_56 = 0x56, + UIMSG_57 = 0x57, + UIMSG_58 = 0x58, + UIMSG_5A = 0x5A, + UIMSG_5B = 0x5B, UIMSG_ShowStatus_DateTime = 0x5C, UIMSG_ShowStatus_ManaHP = 0x5D, UIMSG_ShowStatus_Player = 0x5E, + UIMSG_Wait5Minutes = 0x5F, + UIMSG_Wait1Hour = 0x60, + UIMSG_61 = 0x61, UIMSG_ShowStatus_Food = 0x64, UIMSG_ShowStatus_Funds = 0x65, + UIMSG_68 = 0x68, + UIMSG_69 = 0x69, UIMSG_QuickReference = 0x6A, UIMSG_6B = 0x6B, + UIMSG_AlreadyResting = 0x6D, UIMSG_SelectCharacter = 0x6E, UIMSG_ChangeSoundVolume = 0x6F, UIMSG_ChangeMusicVolume = 0x70, UIMSG_Escape = 0x71, + UIMSG_72 = 0x72, + UIMSG_73 = 0x73, + UIMSG_74 = 0x74, + UIMSG_75 = 0x75, UIMSG_PlayerCreationSelectQuality = 0x76, + UIMSG_InventoryLeftClick = 0x78, UIMSG_SkillUp = 0x79, + UIMSG_7A = 0x7A, + UIMSG_7B = 0x7B, UIMSG_StartNewGame = 0x7C, UIMSG_Game_OpenLoadGameDialog = 0x7D, + UIMSG_Game_OpenSaveGameDialog = 0x7E, UIMSG_Game_OpenOptionsDialog = 0x7F, + UIMSG_80 = 0x80, UIMSG_SetGraphicsMode = 0x83, UIMSG_Quit = 0x84, + UIMSG_85 = 0x85, + UIMSG_86 = 0x86, + UIMSG_87 = 0x87, + UIMSG_88 = 0x88, + UIMSG_8C = 0x8C, + UIMSG_8D = 0x8D, + UIMSG_8E = 0x8E, + UIMSG_8F = 0x8F, UIMSG_PlayerCreationVoiceBack = 0x90, UIMSG_PlayerCreationVoiceForward = 0x91, + UIMSG_92 = 0x92, UIMSG_StartNPCDialogue = 0xA1, UIMSG_ArrowUp = 0xA2, UIMSG_DownArrow = 0xA3, UIMSG_LoadSlot = 0xA4, UIMSG_SelectLoadSlot = 0xA5, UIMSG_Cancel = 0xA6, - UIMSG_A7 = 0xA7, + UIMSG_ExitRest = 0xA7, UIMSG_A8 = 0xA8, UIMSG_A9 = 0xA9, UIMSG_AA = 0xAA, @@ -229,19 +274,63 @@ UIMSG_D4 = 0xD4, UIMSG_D5 = 0xD5, UIMSG_D6 = 0xD6, + UIMSG_DD = 0xDD, UIMSG_OpenHistoryBook = 0xE0, UIMSG_ToggleAlwaysRun = 0xE1, UIMSG_ToggleFlipOnExit = 0xE2, + UIMSG_16F = 0x16F, + UIMSG_170 = 0x170, + UIMSG_194 = 0x194, + UIMSG_195 = 0x195, UIMSG_OpenRestUI = 0x199, + UIMSG_19A = 0x19A, + UIMSG_19B = 0x19B, + UIMSG_19C = 0x19C, UIMSG_OpenKeyMappingOptions = 0x19F, + UIMSG_1A0 = 0x1A0, + UIMSG_1A1 = 0x1A1, UIMSG_ResetKeyMapping = 0x1A2, + UIMSG_1A3 = 0x1A3, UIMSG_OpenVideoOptions = 0x1A5, UIMSG_ToggleBloodsplats = 0x1A6, UIMSG_ToggleColoredLights = 0x1A7, UIMSG_ToggleTint = 0x1A8, + UIMSG_1A9 = 0x1A9, }; - +enum CURRENT_SCREEN +{ + SCREEN_GAME = 0x0, + SCREEN_MENU = 0x1, + SCREEN_OPTIONS = 0x2, + SCREEN_BOOKS = 0x3, + SCREEN_NPC_DIALOGUE = 0x4, + SCREEN_REST = 0x5, + SCREEN_CHARACTERS = 0x7, + SCREEN_SPELL_BOOK = 0x8, + SCREEN_CREATORS = 0x9, + SCREEN_CHEST = 0xA, + SCREEN_SAVEGAME = 0xB, + SCREEN_LOADGAME = 0xC, + SCREEN_HOUSE = 0xD, + SCREEN_E = 0xE, + SCREEN_F = 0xF, + SCREEN_VIDEO = 0x10, + SCREEN_CHANGE_LOCATION = 0x11, + SCREEN_INPUT_BLV = 0x12, + SCREEN_BRANCHLESS_NPC_DIALOG = 0x13, + SCREEN_PARTY_CREATION = 0x15, + SCREEN_PRESS_ESCAPE_MESSAGE = 0x16, + SCREEN_CASTING = 0x17, + SCREEN_19 = 0x19, + SCREEN_KEYBOARD_OPTIONS = 0x1A, + SCREEN_1B = 0x1B, + SCREEN_VIDEO_OPTIONS = 0x1C, + SCREEN_63 = 0x63, + SCREEN_64 = 0x64, + SCREEN_67 = 0x67, + SCREEN_QUICK_REFERENCE = 0x68, +};
--- a/Game.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Game.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -50,10 +50,10 @@ //----- (0044103C) -------------------------------------------------------- void Game::Draw() { - float v2; // ST24_4@11 + //float v2; // ST24_4@11 //double v3; // ST28_8@11 int v4; // edi@26 - int v5; // eax@35 + //int v5; // eax@35 uFlags2 &= 0xFFFFFFFDu; if ( pParty->_497FC5_check_party_perception_against_level() ) @@ -96,7 +96,7 @@ { if ( pRenderer->pRenderD3D ) { - v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0; + float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0; //v3 = v2 + 6.7553994e15; //pRenderer->field_1036A8_bitmapid = LODWORD(v3); pRenderer->field_1036A8_bitmapid = floorf(v2 + 0.5f); @@ -121,8 +121,8 @@ pRenderer->BeginScene(); if (pRenderer->pRenderD3D) pMouse->DrawCursorToTarget(); - if (pOtherOverlayList->field_3EC) - viewparams->bRedrawGameUI = 1; + if (pOtherOverlayList->bRedraw) + viewparams->bRedrawGameUI = true; v4 = viewparams->bRedrawGameUI; GameUI_DrawStatusBar(); if (!viewparams->bRedrawGameUI) @@ -140,15 +140,17 @@ GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2); if (v4) { - if ( !sub_4226C2() && pRenderer->pRenderD3D) + if ( !sub_4226C2() && pRenderer->pRenderD3D) // clear game viewport with transparent color pRenderer->FillRectFast(pViewport->uViewportX, pViewport->uViewportY, pViewport->uViewportZ - pViewport->uViewportX, - pViewport->uViewportW - pViewport->uViewportY + 1, pRenderer->uTargetGMask | pRenderer->uTargetBMask);//0x0000FFFF/*pRenderer->uTargetGMask | pRenderer->uTargetBMask*/ - white window + pViewport->uViewportW - pViewport->uViewportY + 1, + pRenderer->uTargetGMask | pRenderer->uTargetBMask); viewparams->field_48 = 0; } } - v5 = pOtherOverlayList->field_3EC; - pOtherOverlayList->field_3EC = 0; - viewparams->bRedrawGameUI = v5; + + viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw; + pOtherOverlayList->bRedraw = 0; + GameUI_DrawPartySpells(); if (v4 || pParty->pHirelings[0]._anim_end_time || pParty->pHirelings[1]._anim_end_time ) DrawHiredNPCs(); @@ -246,7 +248,7 @@ dword_6BE364_game_settings_1 |= 0x80; dword_6BE340 = 2; // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; if (pAsyncMouse) pAsyncMouse->Resume(); if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard ) @@ -324,7 +326,7 @@ v16 = 0; viewparams->bRedrawGameUI = true; } - //pAudioPlayer->_4AAFCF();//Ritor1: it's temporarily, game crash + //pAudioPlayer->_4AAFCF();//Ritor1: it's temporarily, game crash. decorations sounds if (uGameState == 1) //goto LABEL_96; { @@ -488,7 +490,7 @@ } break; } - pCurrentScreen = 16;// + pCurrentScreen = SCREEN_VIDEO; sub_491E3A(); }
--- a/GameUIs.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/GameUIs.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -48,7 +48,7 @@ if ( uDialogueType_ ) { pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); - if ( pCurrentScreen == 11 )//save or load + if ( pCurrentScreen == SCREEN_SAVEGAME ) { v1 = uTextureID_save_up; v2 = uTextureID_LS_saveU; @@ -124,7 +124,7 @@ //LABEL_24: pLODFile.FreeSubIndexAndIO(); - if ( pCurrentScreen == 11 ) // save/load screen + if ( pCurrentScreen == SCREEN_SAVEGAME ) { v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); v10 = (TEXTURE_TYPE)2; @@ -192,7 +192,7 @@ 8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); - if ( pCurrentScreen == 11 ) + if ( pCurrentScreen == SCREEN_SAVEGAME ) { v0 = uTextureID_save_up; v1 = uTextureID_LS_saveU;
--- a/Indoor.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Indoor.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -4221,11 +4221,11 @@ v0->uSectorID = LOWORD(stru_721530.uSectorID); stru_721530.field_70 += stru_721530.field_7C; v37 = v36 >> 3; - if ( (v36 & 7) != 3 ) + if ( (v36 & 7) != OBJECT_Actor) { - if ( (v36 & 7) != 4 ) + if ( (v36 & 7) != OBJECT_Player) { - if ( (v36 & 7) == 5 ) + if ( (v36 & 7) == OBJECT_Decoration) { _this = sub_452A9E(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); v45 = stru_5C6E00->Atan2( @@ -4242,7 +4242,7 @@ v0->vVelocity.y = WORD1(v48); goto LABEL_119; } - if ( (v36 & 7) == 6 ) + if ( (v36 & 7) == OBJECT_BModel) { stru_721530.field_84 = v36 >> 3; v38 = &pIndoor->pFaces[v37];
--- a/Keyboard.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Keyboard.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -953,28 +953,16 @@ //----- (0045B06E) -------------------------------------------------------- bool Keyboard::IsShiftHeld() { - bool result; // eax@2 - char v2; // zf@3 - if (bUsingAsynKeyboard) { if ( pAsyncKeyboard->_45B4EC(0x2Au) ) { -LABEL_6: - LOBYTE(result) = 1; - return result; + return true; } - v2 = pAsyncKeyboard->_45B4EC(0x36u) == 0; + return pAsyncKeyboard->_45B4EC(0x36u) != 0; } else - { - LOWORD(result) = GetAsyncKeyState(VK_SHIFT); - v2 = result == 0; - } - if ( !v2 ) - goto LABEL_6; - LOBYTE(result) = 0; - return result; + return GetAsyncKeyState(VK_SHIFT); } //----- (0045B0A9) --------------------------------------------------------
--- a/LOD.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/LOD.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -569,12 +569,12 @@ v3 = a2; v78 = this; - result = a2->field_10; - v58 = a2->field_10; + result = a2->_screenspace_x_scaler_packedfloat; + v58 = a2->_screenspace_x_scaler_packedfloat; if ( result <= 0 ) return result; - v5 = a2->field_14; - v6 = a2->field_10; + v5 = a2->_screenspace_y_scaler_packedfloat; + v6 = a2->_screenspace_x_scaler_packedfloat; v87 = (signed __int64)0x100000000ui64 / result; v48 = (signed __int64)0x100000000ui64 / result; v62 = (signed __int64)0x100000000ui64 / v5;
--- a/Outdoor.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Outdoor.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -126,17 +126,20 @@ pOutdoor->_47EF60(v5, v4, 1); } pGame->uFlags2 &= 0xFFFFFFFEu; - if ( pRenderer->pRenderD3D && pRenderer->bUsingSpecular ) + if (pRenderer->pRenderD3D && pRenderer->bUsingSpecular) pGame->pLightmapBuilder->uFlags |= 1u; else pGame->pLightmapBuilder->uFlags &= 0xFFFFFFFEu; + uNumDecorationsDrawnThisFrame = 0; _unused000 = 0; uNumSpritesDrawnThisFrame = 0; uNumBillboardsToDraw = 0; - DrawActors(); - if ( !pOutdoorCamera->bDoNotRenderDecorations ) - pRenderer->DrawDecorations(); + + PrepareActorsDrawList(); + if (!pOutdoorCamera->bDoNotRenderDecorations) + pRenderer->PrepareDecorationsRenderList_ODM(); + pRenderer->DrawLayingItems_Shooting_Magic_ODM(); pRenderer->TransformBillboardsAndSetPalettesODM();//Ritor1: do comment to test sub_485F53((Vec2_int_ *)unnamed_6BE060); @@ -315,7 +318,7 @@ signed int v11; // eax@23 int v12; // ST14_4@25 signed int v14; // [sp-4h] [bp-84h]@6 - char Str; // [sp+8h] [bp-78h]@3 + char Str[140]; // [sp+8h] [bp-78h]@3 int a5a; // [sp+94h] [bp+14h]@3 auto Source = this; @@ -323,9 +326,9 @@ v5 = Source; if ( a5 < 10 || strlen(Source->pLevelFilename) != 9 - || (strcpy(&Str, v5->pLevelFilename), - _strlwr(&Str), - v6 = strtok(&Str, "out"), + || (strcpy(Str, v5->pLevelFilename), + _strlwr(Str), + v6 = strtok(Str, "out"), v6[2] = 0, v7 = atoi(v6), v8 = v7, @@ -2894,16 +2897,16 @@ } //----- (0047B42C) -------------------------------------------------------- -unsigned int OutdoorLocation::DrawActors() +void OutdoorLocation::PrepareActorsDrawList() { unsigned int result; // eax@1 - Actor *v1; // edi@2 - __int16 v2; // ax@3 - int v3; // esi@5 + //Actor *v1; // edi@2 + //__int16 v2; // ax@3 + int z; // esi@5 float v4; // ST48_4@8 - double v5; // ST38_8@8 - float v6; // ST48_4@10 - double v7; // ST30_8@10 + //double v5; // ST38_8@8 + //float v6; // ST48_4@10 + //double v7; // ST30_8@10 unsigned int v8; // eax@11 int v9; // edx@11 __int16 v10; // dx@11 @@ -2925,7 +2928,7 @@ int v26; // ST54_4@45 int v27; // ecx@45 RenderBillboard *v28; // esi@45 - __int16 v29; // ax@46 + //__int16 v29; // ax@46 unsigned __int8 v30; // zf@46 unsigned __int8 v31; // sf@46 signed __int16 v32; // ax@49 @@ -2933,8 +2936,8 @@ int v34; // ecx@54 MonsterDesc *v35; // edx@54 int v36; // ecx@54 - unsigned __int8 v37; // zf@54 - unsigned __int8 v38; // sf@54 + //unsigned __int8 v37; // zf@54 + //unsigned __int8 v38; // sf@54 unsigned int v39; // [sp-8h] [bp-68h]@23 unsigned int v40; // [sp-4h] [bp-64h]@23 int v41; // [sp+24h] [bp-3Ch]@11 @@ -2950,70 +2953,64 @@ int v51; // [sp+34h] [bp-2Ch]@41 int v52; // [sp+34h] [bp-2Ch]@50 int v53; // [sp+38h] [bp-28h]@36 - int v54; // [sp+3Ch] [bp-24h]@2 + //int v54; // [sp+3Ch] [bp-24h]@2 int y; // [sp+40h] [bp-20h]@5 int x; // [sp+44h] [bp-1Ch]@5 int v57; // [sp+48h] [bp-18h]@45 int v58; // [sp+4Ch] [bp-14h]@45 - signed int v59; // [sp+50h] [bp-10h]@1 + //signed int v59; // [sp+50h] [bp-10h]@1 int X; // [sp+54h] [bp-Ch]@36 - __int16 v61; // [sp+58h] [bp-8h]@5 + //__int16 v61; // [sp+58h] [bp-8h]@5 signed __int16 v62; // [sp+5Ch] [bp-4h]@25 - result = 0; - v59 = 0; - if ( (signed int)uNumActors > 0 ) + //result = 0; + //v59 = 0; + for (int i = 0; i < uNumActors; ++i) { - v54 = 0; - v1 = pActors;//[0].vPosition.z; - do - { - v2 = v1->uAIState; - v1->uAttributes &= 0xFFFFFFF7u; - if ( v2 == 11 || v2 == 19 ) - goto LABEL_58; - v3 = v1->vPosition.z; + //v54 = 0; + //v1 = pActors;//[0].vPosition.z; + //do + //{ + auto actor = pActors + i; + //v2 = actor->uAIState; + + actor->uAttributes &= 0xFFFFFFF7u; + if (actor->uAIState == Removed || actor->uAIState == Disabled) + continue; + + z = actor->vPosition.z; v49 = 0; - x = v1->vPosition.x; - y = v1->vPosition.y; - v61 = v1->vPosition.z; - if ( v2 == 17 ) + x = actor->vPosition.x; + y = actor->vPosition.y; + if (actor->uAIState == Summoned) { - if ( (v1->uSummonerID & 7) != 3 || pActors[v1->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) + if ((actor->uSummonerID & 7) != OBJECT_Actor || + pActors[actor->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) { - v6 = (double)v1->uActorHeight * 0.5; - v7 = v6 + 6.7553994e15; - v3 += LODWORD(v7); - v61 = v3; + z += floorf(actor->uActorHeight * 0.5f + 0.5f); } else { v49 = 1; - pGame->pStru6Instance->_4A7F74(v1->vPosition.x, v1->vPosition.y, v3); - v4 = (1.0 - (double)*(signed int *)(v1 + 38) / (double)*((short *)v1 + 7)) - * (double)(2 * (signed int)v1->uActorHeight); - v5 = v4 + 6.7553994e15; - v3 -= LODWORD(v5); - v61 = v3; - if ( v3 > v1->vPosition.z ) - { - v61 = v1->vPosition.z; - v3 = v1->vPosition.z; - } + pGame->pStru6Instance->_4A7F74(actor->vPosition.x, actor->vPosition.y, z); + v4 = (1.0 - (double)actor->uCurrentActionTime / (double)actor->uCurrentActionLength) * + (double)(2 * actor->uActorHeight); + z -= floorf(v4 + 0.5f); + if ( z > actor->vPosition.z ) + z = actor->vPosition.z; } } - v8 = stru_5C6E00->Atan2( - v1->vPosition.x - pIndoorCamera->pos.x, - v1->vPosition.y - pIndoorCamera->pos.y); - LOWORD(v9) = v1->uYawAngle; + v8 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, + actor->vPosition.y - pIndoorCamera->pos.y); + LOWORD(v9) = actor->uYawAngle; v41 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v9 - v8) >> 8) & 7; - v10 = v1->uCurrentActionAnimation; + v10 = actor->uCurrentActionAnimation; if ( pParty->bTurnBasedModeOn ) { if ( v10 != 1 ) { LABEL_17: - v12 = v1->uCurrentActionTime; + v12 = actor->uCurrentActionTime; goto LABEL_18; } v11 = pMiscTimer->uTotalGameTimeElapsed; @@ -3024,11 +3021,11 @@ goto LABEL_17; v11 = pEventTimer->uTotalGameTimeElapsed; } - v12 = v54 + v11; + v12 = 32 * i + v11; LABEL_18: - if ( (signed __int64)v1->pActorBuffs[5].uExpireTime > 0 || (signed __int64)v1->pActorBuffs[6].uExpireTime > 0 ) + if ( (signed __int64)actor->pActorBuffs[5].uExpireTime > 0 || (signed __int64)actor->pActorBuffs[6].uExpireTime > 0 ) v12 = 0; - v13 = v1->uAIState; + v13 = actor->uAIState; if ( v13 == 17 && !v49 ) { v40 = v12; @@ -3038,7 +3035,7 @@ goto LABEL_25; } v40 = v12; - v39 = v1->pSpriteIDs[v10]; + v39 = actor->pSpriteIDs[v10]; if ( v13 != 16 ) goto LABEL_24; v14 = pSpriteFrameTable->GetFrameBy_x(v39, v12); @@ -3057,7 +3054,7 @@ if ( v15->uGlowRadius ) { //LOBYTE(v16) = byte_4E94D3; - pMobileLightsStack->AddLight(x, y, v3, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); + pMobileLightsStack->AddLight(x, y, z, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); } v17 = (x - pIndoorCamera->pos.x) << 16; if ( pIndoorCamera->sRotationX ) @@ -3067,13 +3064,13 @@ + ((unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); v50 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; v53 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; - v44 = (v3 - pIndoorCamera->pos.z) << 16; + v44 = (z - pIndoorCamera->pos.z) << 16; v19 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); X = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); if ( v19 < 262144 || v19 > pOutdoorCamera->shading_dist_mist << 16 ) - goto LABEL_58; + continue; v20 = v53 - v50; v42 = v53 - v50; v21 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) @@ -3086,12 +3083,12 @@ v22 = (unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; X = v22 + v51; if ( v22 + v51 < 262144 || v22 + v51 > pOutdoorCamera->shading_dist_mist << 16 ) - goto LABEL_58; + continue; v23 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; v20 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; v42 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; - v21 = (v3 - pIndoorCamera->pos.z) << 16; + v21 = (z - pIndoorCamera->pos.z) << 16; } v45 = v21; v24 = abs(v20); @@ -3111,70 +3108,67 @@ v46 = pViewport->uScreenCenterY - ((signed int)(((unsigned __int64)(v25 / X * v45) >> 16) + 32768) >> 16); result = uNumBillboardsToDraw; v28 = &pBillboardRenderList[uNumBillboardsToDraw]; - if ( (signed int)uNumBillboardsToDraw >= 500 ) - return result; + if (uNumBillboardsToDraw >= 500) + return; ++uNumBillboardsToDraw; ++uNumSpritesDrawnThisFrame; - v1->uAttributes |= 8u; + actor->uAttributes |= 8u; v28->uHwSpriteID = v15->pHwSpriteIDs[v41]; - v29 = v15->uPaletteIndex; v28->uIndoorSectorID = 0; - v28->uPalette = v29; - v28->field_0 = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16; - v30 = HIDWORD(v1->pActorBuffs[3].uExpireTime) == 0; - v31 = SHIDWORD(v1->pActorBuffs[3].uExpireTime) < 0; - v28->field_4 = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16; - if ( v31 || v31 | v30 && LODWORD(v1->pActorBuffs[3].uExpireTime) <= 0u ) + v28->uPalette = v15->uPaletteIndex; + v28->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16; + v30 = HIDWORD(actor->pActorBuffs[3].uExpireTime) == 0; + v31 = SHIDWORD(actor->pActorBuffs[3].uExpireTime) < 0; + v28->_screenspace_y_scaler_packedfloat = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16; + if ( v31 || v31 | v30 && LODWORD(actor->pActorBuffs[3].uExpireTime) <= 0u ) { - if ( (signed __int64)v1->pActorBuffs[10].uExpireTime > 0i64 ) + if ( (signed __int64)actor->pActorBuffs[10].uExpireTime > 0i64 ) { - v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F(v1) - * (signed __int64)v28->field_4) >> 16; + v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F(actor) + * (signed __int64)v28->_screenspace_y_scaler_packedfloat) >> 16; LABEL_53: LOWORD(v27) = v43; - v28->field_4 = v52; + v28->_screenspace_y_scaler_packedfloat = v52; } } else { - v32 = v1->pActorBuffs[3].uPower; + v32 = actor->pActorBuffs[3].uPower; if ( v32 ) { - v33 = v1->pActorBuffs[3].uPower; - v28->field_0 = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->field_0) >> 16; - v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->field_4) >> 16; + v33 = actor->pActorBuffs[3].uPower; + v28->_screenspace_x_scaler_packedfloat = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->_screenspace_x_scaler_packedfloat) >> 16; + v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->_screenspace_y_scaler_packedfloat) >> 16; goto LABEL_53; } } v28->uScreenSpaceX = v27; + v28->uScreenSpaceY = v46; v28->some_x = x; - v28->uScreenSpaceY = v46; v28->some_y = y; - v28->some_z = v61; + v28->some_z = z; HIWORD(v34) = HIWORD(X); LOWORD(v34) = 0; v28->uPaletteSubindex = 0; - v28->sZValue = v34 + (8 * v59 | 3); - v28->field_14 = v59; + v28->sZValue = v34 + (8 * i | OBJECT_Actor); + v28->field_14_actor_id = i; v35 = pMonsterList->pMonsters; - v36 = v1->pMonsterInfo.uID; - v37 = HIDWORD(v1->pActorBuffs[5].uExpireTime) == 0; - v38 = SHIDWORD(v1->pActorBuffs[5].uExpireTime) < 0; + v36 = actor->pMonsterInfo.uID; v28->field_1E = v62 | 0x200; v28->pSpriteFrame = v15; v28->uTintColor = *((int *)&v35[v36] - 36); - if ( !v38 && (!(v38 | v37) || LODWORD(v1->pActorBuffs[5].uExpireTime)) ) + if (actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) v28->field_1E = v62 | 0x200; } -LABEL_58: - ++v59; - v54 += 32; - result = v59; - ++v1; - } - while ( v59 < (signed int)uNumActors ); +//LABEL_58: + //++v59; + //v54 += 32; + //result = v59; + //++v1; + //} + //while ( v59 < (signed int)uNumActors ); } - return result; + //return result; } // 4E94D3: using guessed type char byte_4E94D3; // 5187E4: using guessed type int uNumSpritesDrawnThisFrame;
--- a/Outdoor.h Tue Feb 12 18:16:18 2013 +0600 +++ b/Outdoor.h Tue Feb 12 18:16:34 2013 +0600 @@ -140,7 +140,7 @@ } void ExecDraw(unsigned int bRedraw); - unsigned int DrawActors(); + void PrepareActorsDrawList(); void CreateDebugLocation(); void Release(); bool Load(const char *pFilename, ODMFace *File, size_t a4, int thisa);
--- a/Overlays.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Overlays.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -38,7 +38,7 @@ { signed int v6; // edx@1 OtherOverlayList *v7; // eax@1 - signed int result; // eax@4 + //signed int result; // eax@4 signed int v9; // esi@6 __int16 v10; // dx@9 __int16 v11; // dx@11 @@ -81,9 +81,9 @@ v7->pOverlays[0].field_6 = v11; v7->pOverlays[0].field_10 = a5; v7->pOverlays[0].field_E = a6; - result = 1; - this->field_3EC = 1; - return result; + + bRedraw = true; + return true; } //----- (00441964) --------------------------------------------------------
--- a/Overlays.h Tue Feb 12 18:16:18 2013 +0600 +++ b/Overlays.h Tue Feb 12 18:16:34 2013 +0600 @@ -25,7 +25,7 @@ struct OtherOverlayList { inline OtherOverlayList(): //----- (0045848D) - field_3E8(0), field_3EC(0) + field_3E8(0), bRedraw(false) {} int _4418B1(int a2, int a3, int a4, int a5); @@ -34,7 +34,7 @@ OtherOverlay pOverlays[50]; int field_3E8; - int field_3EC; + int bRedraw; }; #pragma pack(pop)
--- a/ParticleEngine.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/ParticleEngine.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -280,11 +280,11 @@ HIDWORD(v15) = pBLVRenderParams->field_40 >> 16; v16 = v15 / z; v17 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; - pParticle->field_58 = v16; + pParticle->_screenspace_scale = v16; uParticleID = (unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16; LODWORD(v18) = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16) >> 16); - v19 = pParticle->field_58; + v19 = pParticle->_screenspace_scale; pParticle->uScreenSpaceZ = v18; uParticleID = (unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16; v20 = pBLVRenderParams->uViewportCenterY @@ -329,11 +329,11 @@ HIDWORD(v30) = pBLVRenderParams->field_40 >> 16; v31 = v30 / z; v32 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; - pParticle->field_58 = v31; + pParticle->_screenspace_scale = v31; uParticleID = (unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16; LODWORD(v33) = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16); - v34 = pParticle->field_58; + v34 = pParticle->_screenspace_scale; pParticle->uScreenSpaceZ = v33; v35 = pBLVRenderParams->uViewportCenterY - ((signed int)((unsigned __int64)(v34 * (signed __int64)v29) >> 16) >> 16); @@ -360,10 +360,10 @@ LODWORD(v40) = pBLVRenderParams->field_40 << 16; HIDWORD(v40) = pBLVRenderParams->field_40 >> 16; v41 = v40 / z; - pParticle->field_58 = v41; + pParticle->_screenspace_scale = v41; uParticleID = (unsigned __int64)(v41 * (signed __int64)a2) >> 16; v42 = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v41 * (signed __int64)a2) >> 16) >> 16); - v43 = pParticle->field_58; + v43 = pParticle->_screenspace_scale; pParticle->uScreenSpaceX = v42; v44 = v43 * (signed __int64)v24; uParticleID = v44 >> 16; @@ -372,9 +372,9 @@ v46 = pBLVRenderParams->uViewportCenterY - v44; pParticle->uScreenSpaceY = pBLVRenderParams->uViewportCenterY - v44; v47 = v45; - v48 = _48B561_mess_with_scaling_along_z(/*v46, */v47) * (signed __int64)pParticle->field_58; + v48 = _48B561_mess_with_scaling_along_z(/*v46, */v47) * (signed __int64)pParticle->_screenspace_scale; uParticleID = v48 >> 16; - pParticle->field_58 = v48 >> 16; + pParticle->_screenspace_scale = v48 >> 16; v10 = z; goto LABEL_19; } @@ -397,11 +397,11 @@ LODWORD(v6) = 0; HIDWORD(v6) = SLOWORD(v5); v7 = pParticle->flt_28; - pParticle->field_58 = v6 / (signed int)uParticleID; + pParticle->_screenspace_scale = v6 / (signed int)uParticleID; v8 = v7; pParticle->uScreenSpaceX = HIDWORD(a5); pParticle->uScreenSpaceY = a6; - pParticle->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */v8) * (signed __int64)pParticle->field_58) >> 16; + pParticle->_screenspace_scale = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */v8) * (signed __int64)pParticle->_screenspace_scale) >> 16; v10 = uParticleID; LABEL_19: pParticle->sZValue = v10; @@ -497,8 +497,8 @@ LODWORD(v13) = 0; HIDWORD(v13) = SLOWORD(pOutdoorCamera->int_fov_rad); v14 = v13 / SHIDWORD(v12); - v6->field_58 = v14; - v15 = v6->field_58; + v6->_screenspace_scale = v14; + v15 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v14 * (signed __int64)(signed int)(((unsigned __int64)(v10 * (signed __int64)v4) >> 16) @@ -536,8 +536,8 @@ v23 = v22 / (signed int)(((unsigned __int64)(v20 * (signed __int64)v5) >> 16) + ((unsigned __int64)(uIDf * (signed __int64)v4) >> 16)); - v6->field_58 = v23; - v24 = v6->field_58; + v6->_screenspace_scale = v23; + v24 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v23 * (signed __int64)(signed int)(((unsigned __int64)(v20 * (signed __int64)v4) >> 16) @@ -565,8 +565,8 @@ LODWORD(v29) = 0; HIDWORD(v29) = SLOWORD(pOutdoorCamera->int_fov_rad); v30 = v29 / X_4; - v6->field_58 = v30; - v31 = v6->field_58; + v6->_screenspace_scale = v30; + v31 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v30 * (signed __int64)v16) >> 16) >> 16); v32 = v6->flt_28; @@ -574,7 +574,7 @@ v34 = pViewport->uScreenCenterY - v33; v6->uScreenSpaceY = pViewport->uScreenCenterY - v33; v35 = v32; - v6->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v34, */v35) * (signed __int64)v6->field_58) >> 16; + v6->_screenspace_scale = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v34, */v35) * (signed __int64)v6->_screenspace_scale) >> 16; v6->sZValue = X_4; v36 = v6->uScreenSpaceX; if ( v36 >= (signed int)pViewport->uViewportX ) @@ -625,8 +625,8 @@ if (p->uType & 0x0100) { v14 = &pParticles[i]; - v15.field_10 = v14->field_58 / 4; - v15.field_14 = v14->field_58 / 4; + v15._screenspace_x_scaler_packedfloat = v14->_screenspace_scale / 4; + v15._screenspace_y_scaler_packedfloat = v14->_screenspace_scale / 4; v15.uScreenSpaceX = v14->uScreenSpaceX; v15.uScreenSpaceY = v14->uScreenSpaceY; v15.sZValue = v14->sZValue; @@ -658,8 +658,8 @@ } if (p->uType & 0x0400) { - v15.field_10 = p->field_58; - v15.field_14 = p->field_58; + v15._screenspace_x_scaler_packedfloat = p->_screenspace_scale; + v15._screenspace_y_scaler_packedfloat = p->_screenspace_scale; v15.uScreenSpaceX = p->uScreenSpaceX; v15.uScreenSpaceY = p->uScreenSpaceY; v15.sZValue = p->sZValue; @@ -670,8 +670,8 @@ } if (p->uType & 0x0800) { - v15.field_10 = p->field_58; - v15.field_14 = p->field_58; + v15._screenspace_x_scaler_packedfloat = p->_screenspace_scale; + v15._screenspace_y_scaler_packedfloat = p->_screenspace_scale; v15.uScreenSpaceX = p->uScreenSpaceX; v15.uScreenSpaceY = p->uScreenSpaceY; v15.sZValue = p->sZValue; @@ -683,7 +683,7 @@ } else { - v11 = 13 * p->field_58 >> 16; + v11 = 13 * p->_screenspace_scale >> 16; if ( v11 > 30 ) v11 = 30; v12 = p->uScreenSpaceY - v11; @@ -743,8 +743,8 @@ if ( BYTE1(v8) & 1 ) { pParticle = &pParticleEngine->pParticles[pParticleNum]; - pBillboard.field_10 = pParticle->field_58 >> 2; - pBillboard.field_14 = pParticle->field_58 >> 2; + pBillboard._screenspace_x_scaler_packedfloat = pParticle->_screenspace_scale / 4; + pBillboard._screenspace_y_scaler_packedfloat = pParticle->_screenspace_scale / 4; pBillboard.uScreenSpaceX = pParticle->uScreenSpaceX; pBillboard.uScreenSpaceY = pParticle->uScreenSpaceY; pBillboard.sZValue = pParticle->sZValue; @@ -778,8 +778,8 @@ } if ( *(v7 - 81) & 4 ) { - pBillboard.field_10 = *(_DWORD *)(v7 + 6); - pBillboard.field_14 = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_x_scaler_packedfloat = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_y_scaler_packedfloat = *(_DWORD *)(v7 + 6); pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18); pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14); pBillboard.sZValue = *(_DWORD *)(v7 - 2); @@ -787,8 +787,8 @@ } if ( *(v7 - 81) & 8 ) { - pBillboard.field_10 = *(_DWORD *)(v7 + 6); - pBillboard.field_14 = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_x_scaler_packedfloat = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_y_scaler_packedfloat = *(_DWORD *)(v7 + 6); pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18); pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14); pBillboard.sZValue = *(_DWORD *)(v7 - 2);
--- a/ParticleEngine.h Tue Feb 12 18:16:18 2013 +0600 +++ b/ParticleEngine.h Tue Feb 12 18:16:34 2013 +0600 @@ -61,9 +61,17 @@ int uScreenSpaceY; int uScreenSpaceZ; // line end x int uScreenSpaceW; // line end y - int sZValue; + union + { + int sZValue; + struct + { + unsigned short object_pid; + short zbuffer_depth; + }; + }; int sZValue2; // line end z - int field_58; + int _screenspace_scale; float flt_5C; float flt_60; int uLightColor;
--- a/Party.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Party.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -97,7 +97,7 @@ v12 = 0; if ( pParty->bTurnBasedModeOn == 1 ) { - if ( pTurnEngine->field_4 != 2 || (pTurnEngine->pQueue[0].uPackedID & 7) != 4 ) + if ( pTurnEngine->field_4 != 2 || (pTurnEngine->pQueue[0].uPackedID & 7) != OBJECT_Player) return 0; v2 = pTurnEngine->pQueue[0].uPackedID >> 3; return v2 + 1;
--- a/Party.h Tue Feb 12 18:16:18 2013 +0600 +++ b/Party.h Tue Feb 12 18:16:34 2013 +0600 @@ -14,7 +14,11 @@ /* 355 */ -enum PARTY_FLAGS_2 : __int32 +enum PARTY_FLAGS_1: __int32 +{ + PARTY_FLAGS_1_LANDING = 0x100, +}; +enum PARTY_FLAGS_2: __int32 { PARTY_FLAGS_2_RUNNING = 0x2, }; @@ -174,6 +178,7 @@ inline bool ImmolationActive() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;} inline bool ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;} inline bool FeatherFallActive() {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;} + inline bool Invisible() {return pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0;} int field_0;
--- a/Player.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Player.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -7688,7 +7688,7 @@ v21 = v67; goto LABEL_83; } - if ( pCurrentScreen == 23 ) + if ( pCurrentScreen == SCREEN_CASTING ) return; if ( !pParty->pPlayers[a2-1].CanAct() )//if ( !((Player *)&stru_AA1058[3].pSounds[6972 * a2 + 40552])->CanAct() ) goto LABEL_89; @@ -7704,7 +7704,7 @@ pMouse->RemoveHoldingItem(); pGUIWindow_CurrentMenu->Release(); pIcons_LOD->_4114F2(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; _42777D_CastSpell_UseWand_ShootArrow(v24, a2 - 1, 0x85u, 1, 0); }
--- a/Render.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Render.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -1,3 +1,5 @@ +#include <assert.h> + #include "Render.h" #include "OutdoorCamera.h" #include "IndoorCamera.h" @@ -16,6 +18,7 @@ #include "DecorationList.h" #include "Allocator.h" #include "OSInfo.h" +#include "Actor.h" #include "Log.h" #include "mm7_data.h" @@ -195,8 +198,8 @@ soft_billboard.uScreenSpaceX = p->uScreenSpaceX; soft_billboard.uParentBillboardID = i; soft_billboard.uScreenSpaceY = p->uScreenSpaceY; - soft_billboard.field_10 = p->field_0; - soft_billboard.field_14 = p->field_4; + soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat; + soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; soft_billboard.sZValue = p->sZValue; soft_billboard.uFlags = p->field_1E; soft_billboard.uTintColor = p->uTintColor; @@ -1761,8 +1764,8 @@ uStartX = 0, uEndX = 128; uStartZ = 64 - 16, uEndZ = 128; } -// uStartX = 0, uEndX = 128; -// uStartZ = 0, uEndZ = 128; + uStartX = 0, uEndX = 128; + uStartZ = 0, uEndZ = 128; static RenderVertexSoft pTerrainVertices[128 * 128]; for (unsigned int z = uStartZ; z < uEndZ; ++z) { @@ -1824,6 +1827,8 @@ memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); } + + assert(v6 < 1000); // many random crashes here pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]); --pOutdoorCamera->numStru148s; --pOutdoorCamera->field_44; @@ -2926,32 +2931,29 @@ goto LABEL_75; } } -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); -// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); -// 4D864C: using guessed type char byte_4D864C; //----- (0047BACF) -------------------------------------------------------- void Render::TransformBillboardsAndSetPalettesODM() { - int v0; // edi@1 - char *v1; // esi@2 - unsigned int v2; // edx@3 - int v3; // eax@3 - int v4; // edi@3 - int v5; // eax@3 - __int16 v6; // di@3 - int v7; // eax@3 - int v8; // ebx@4 + //int v0; // edi@1 + //char *v1; // esi@2 + //unsigned int v2; // edx@3 + //int v3; // eax@3 + //int v4; // edi@3 + //int v5; // eax@3 + //__int16 v6; // di@3 + //int v7; // eax@3 + //int v8; // ebx@4 unsigned __int16 *v9; // eax@7 char v10; // zf@9 - DWORD v11; // eax@13 + //DWORD v11; // eax@13 int v12; // eax@13 int v13; // eax@14 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 int v15; // [sp+54h] [bp-10h]@13 - int v16; // [sp+58h] [bp-Ch]@1 - int v17; // [sp+5Ch] [bp-8h]@2 + //int v16; // [sp+58h] [bp-Ch]@1 + //int v17; // [sp+5Ch] [bp-8h]@2 int v18; // [sp+60h] [bp-4h]@13 billboard.uParentBillboardID = -1; @@ -2962,52 +2964,42 @@ billboard.uViewportY = pViewport->uViewportY; billboard.uViewportZ = pViewport->uViewportZ - 1; billboard.uViewportW = pViewport->uViewportW; - v0 = 0; pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; - v16 = 0; - if ( (signed int)uNumBillboardsToDraw > 0 ) - { - v17 = 0; - v1 = (char *)&pBillboardRenderList[0].uScreenSpaceY; - do - { - billboard.uScreenSpaceX = *((short *)v1 - 1); - v2 = *((short *)v1 - 5); - billboard.uScreenSpaceY = *(short *)v1; - v3 = *((int *)v1 - 10); - billboard.uParentBillboardID = v0; - v4 = *((int *)v1 + 1); - billboard.field_10 = v3; - v5 = *((int *)v1 - 9); - billboard.uTintColor = v4; - v6 = *((short *)v1 - 8); - billboard.field_14 = v5; - v7 = *((int *)v1 - 6); - billboard.sZValue = *((int *)v1 - 6); - billboard.uFlags = v2; - if ( v6 != -1 ) - { - v8 = *((short *)v1 + 1); - if ( pRenderer->pRenderD3D ) - { - billboard.sZValue = v7; - billboard.uFlags = v2; - pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[v6], v8, (RenderBillboard *)(v1 - 40)); - } - else - { + + for (int i = 0; i < ::uNumBillboardsToDraw; ++i) + { + auto pBillboard = pBillboardRenderList + i; + + billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; + billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; + billboard.uParentBillboardID = i; + billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; + billboard.uTintColor = pBillboard->uTintColor; + billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; + billboard.sZValue = pBillboard->sZValue; + billboard.uFlags = pBillboard->field_1E; + if (pBillboard->uHwSpriteID != -1) + { + if (pRenderer->pRenderD3D) + pRenderer->TransformBillboard(&billboard, + &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], + pBillboard->uPaletteSubindex, pBillboard); + else + { + assert(false); + + auto v1 = (char *)&pBillboard->uScreenSpaceY; if ( *(v1 - 10) & 2 ) v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); else - v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), v7, *((short *)v1 + 1)); + v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); v10 = (*(v1 - 9) & 1) == 0; billboard.pPalette = v9; if ( !v10 ) billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) { - v11 = GetTickCount(); - v12 = stru_5C6E00->SinCos(v17 + v11); + v12 = stru_5C6E00->SinCos(i * 5 + GetTickCount()); v15 = abs(v12); v18 = (unsigned __int64)(15i64 * v15) >> 16; billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); @@ -3015,14 +3007,8 @@ v13 = *((short *)v1 - 8); if ( v13 >= 0 ) pSprites_LOD->pSpriteHeaders[v13]._4ACC38(&billboard, 1); - } - } - v17 += 5; - v0 = v16 + 1; - v1 += 52; - ++v16; - } - while ( v16 < (signed int)uNumBillboardsToDraw ); + } + } } } @@ -3030,7 +3016,7 @@ //----- (0047AF11) -------------------------------------------------------- void Render::DrawLayingItems_Shooting_Magic_ODM() { - char *v0; // edi@2 + //char *v0; // edi@2 ObjectDesc *v1; // ebx@4 __int16 v2; // cx@5 RenderBillboard *v3; // esi@10 @@ -3071,19 +3057,20 @@ int a6; // [sp+20h] [bp-20h]@10 int a6a; // [sp+20h] [bp-20h]@23 int v40; // [sp+24h] [bp-1Ch]@25 - signed int v41; // [sp+28h] [bp-18h]@1 + //signed int v41; // [sp+28h] [bp-18h]@1 int v42; // [sp+2Ch] [bp-14h]@23 int y; // [sp+30h] [bp-10h]@10 int x; // [sp+34h] [bp-Ch]@10 int z; // [sp+38h] [bp-8h]@10 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 - v41 = 0; - if ( (signed int)uNumLayingItems > 0 ) - { - v0 = (char *)&pLayingItems[0].uSectorID; - do - { + //v41 = 0; + for (int i = 0; i < uNumLayingItems; ++i) + { + auto v0 = (char *)&pLayingItems[i].uSectorID; + //v0 = (char *)&pLayingItems[0].uSectorID; + //do + //{ if ( *((short *)v0 - 13) ) { v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; @@ -3096,7 +3083,7 @@ x = *((int *)v0 - 6); y = *((int *)v0 - 5); z = *((int *)v0 - 4); - v3 = &pBillboardRenderList[uNumBillboardsToDraw]; + v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, *((short *)v0 + 1)); v5 = v4; v28 = v4; @@ -3184,17 +3171,17 @@ - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); - if ( (signed int)uNumBillboardsToDraw >= 500 ) + if (::uNumBillboardsToDraw >= 500) return; - ++uNumBillboardsToDraw; + ++::uNumBillboardsToDraw; ++uNumSpritesDrawnThisFrame; *(v0 - 2) |= 1u; v3->uPalette = v28->uPaletteIndex; v3->uIndoorSectorID = a5; - v3->field_0 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; + v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; v26 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; v3->pSpriteFrame = v28; - v3->field_4 = v26; + v3->_screenspace_y_scaler_packedfloat = v26; v3->field_1E = v46; v3->some_x = x; v3->some_y = y; @@ -3204,7 +3191,7 @@ HIWORD(v26) = HIWORD(v42); LOWORD(v26) = 0; v27 = (*(v0 - 2) & 0x20) == 0; - v3->sZValue = v26 + (8 * v41 | 2); + v3->sZValue = v26 + (8 * i | OBJECT_Item); v3->uPaletteSubindex = 0; v3->uTintColor = 0; if ( !v27 ) @@ -3220,10 +3207,11 @@ } } LABEL_34: - ++v41; - v0 += 112; - } - while ( v41 < (signed int)uNumLayingItems ); + ; + //++v41; + //v0 += 112; + //} + //while ( v41 < (signed int)uNumLayingItems ); } } // 4E94D3: using guessed type char byte_4E94D3; @@ -3448,9 +3436,9 @@ //----- (0047A95E) -------------------------------------------------------- -void Render::DrawDecorations() -{ - char *v0; // esi@2 +void Render::PrepareDecorationsRenderList_ODM() +{ + //char *v0; // esi@2 DecorationDesc *v1; // ebx@6 __int16 v2; // ax@6 double v3; // st7@7 @@ -3485,7 +3473,7 @@ Particle_ local_0; // [sp+Ch] [bp-98h]@7 int x; // [sp+74h] [bp-30h]@9 int y; // [sp+78h] [bp-2Ch]@9 - int v35; // [sp+7Ch] [bp-28h]@1 + //int v35; // [sp+7Ch] [bp-28h]@1 int v36; // [sp+80h] [bp-24h]@9 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 int v38; // [sp+88h] [bp-1Ch]@9 @@ -3496,12 +3484,15 @@ int a5; // [sp+9Ch] [bp-8h]@9 int b; // [sp+A0h] [bp-4h]@22 - v35 = 0; - if ( (signed int)uNumLevelDecorations > 0 ) - { - v0 = (char *)&pLevelDecorations[0].vPosition.y; - do - { + //v35 = 0; + //if ( (signed int)uNumLevelDecorations > 0 ) + //{ + //v0 = (char *)&pLevelDecorations[0].vPosition.y; + //do + for (int i = 0; i < uNumLevelDecorations; ++i) + { + auto v0 = (char *)&pLevelDecorations[i].vPosition.y; + if ( (!(*(v0 - 6) & 0x40) || ((LevelDecoration *)(v0 - 8))->_47A825()) && !(*(v0 - 6) & 0x20) ) { v1 = &pDecorationList->pDecorations[*((short *)v0 - 4)]; @@ -3619,14 +3610,14 @@ } if ( b + v25 >= (signed int)pViewport->uViewportX && v25 - b <= (signed int)pViewport->uViewportZ ) { - if ( (signed int)uNumBillboardsToDraw >= 500 ) + if (::uNumBillboardsToDraw >= 500) return; - v27 = &pBillboardRenderList[uNumBillboardsToDraw++]; + v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; ++uNumDecorationsDrawnThisFrame; v27->uHwSpriteID = *v37; v28 = v9->uPaletteIndex; - v27->field_0 = v26; - v27->field_4 = v26; + v27->_screenspace_x_scaler_packedfloat = v26; + v27->_screenspace_y_scaler_packedfloat = v26; v29 = v38; v27->uScreenSpaceX = v25; HIBYTE(v29) |= 2u; @@ -3637,7 +3628,7 @@ v27->some_z = v36; v27->uScreenSpaceY = v40; HIWORD(v30) = HIWORD(v39); - v31 = 8 * v35 | 5; + v31 = 8 * i | OBJECT_Decoration; LOWORD(v30) = 0; v27->uIndoorSectorID = 0; v27->sZValue = v30 + v31; @@ -3688,11 +3679,11 @@ } } LABEL_38: - ++v35; - v0 += 32; - } - while ( v35 < (signed int)uNumLevelDecorations ); - } + ; + //++v35; + //v0 += 32; + } + //while ( v35 < (signed int)uNumLevelDecorations ); } // 4E94D0: using guessed type char byte_4E94D0; // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; @@ -7020,33 +7011,27 @@ { IDirectDrawSurface *pFront; // eax@3 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 - RECT *v6; // [sp-8h] [bp-8h]@3 - DWORD v7; // [sp-4h] [bp-4h]@3 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) { pFront = (IDirectDrawSurface *)this->pFrontBuffer4; - v7 = DDBLTFAST_WAIT; - v6 = a4; pBack = (IDirectDrawSurface *)this->pBackBuffer4; } else { pFront = (IDirectDrawSurface *)this->pFrontBuffer2; - v7 = DDBLTFAST_WAIT; - v6 = a4; pBack = (IDirectDrawSurface *)this->pBackBuffer2; } - pFront->BltFast(0, 0, pBack, v6, v7); + pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); } //----- (004A1B22) -------------------------------------------------------- -unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(unsigned int a1) -{ - unsigned int v2; // ebx@1 - double v4; // st7@5 - unsigned int v5; // esi@5 - int v6; // ecx@5 +unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) +{ + //unsigned int v2; // ebx@1 + //double v4; // st7@5 + //unsigned int v5; // esi@5 + //int v6; // ecx@5 unsigned int v7; // edx@6 char *v8; // ecx@12 void *v9; // edi@16 @@ -7054,35 +7039,29 @@ void *v11; // edi@21 unsigned int v12; // eax@21 - v2 = pRenderer->uNumBillboardsToDraw; - if ( (signed int)pRenderer->uNumBillboardsToDraw >= 999 ) + //v2 = uNumBillboardsToDraw; + if (uNumBillboardsToDraw >= 999 ) return 0; - if ( !pRenderer->uNumBillboardsToDraw ) - { - pRenderer->uNumBillboardsToDraw = 1; + if (!uNumBillboardsToDraw) + { + uNumBillboardsToDraw = 1; return 0; } - v4 = *(float *)&a1; - v5 = pRenderer->uNumBillboardsToDraw; - v6 = 0; - if ( (signed int)pRenderer->uNumBillboardsToDraw <= 0 ) - { - v7 = a1; - } - else - { - do - { - v7 = v6 + (signed int)(v5 - v6) / 2; - if ( v4 <= pRenderer->pBillboardRenderListD3D[v6 + (signed int)(v5 - v6) / 2].flt_88 ) - v5 = v6 + (signed int)(v5 - v6) / 2; - else - v6 = v7 + 1; - } - while ( v6 < (signed int)v5 ); - } - v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].flt_88; - if ( v4 > *(float *)v8 ) + + //v4 = *(float *)&a1; + //v5 = pRenderer->uNumBillboardsToDraw; + //v6 = 0; + for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch + { + v7 = left + (right - left) / 2; + if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) + right = v7; + else + left = v7 + 1; + } + + v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; + if (z > *(float *)v8 ) { if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) { @@ -7105,10 +7084,10 @@ ++v7; } LABEL_23: - pRenderer->uNumBillboardsToDraw = v2 + 1; + uNumBillboardsToDraw++; return v7; } - if ( v4 <= *(float *)v8 ) + if (z <= *(float *)v8 ) { if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) { @@ -7193,7 +7172,7 @@ if (pRenderD3D) { pGame->draw_debug_outlines(); - //DoRenderBillboards_D3D(); //Ritor1: it's temporarily + DoRenderBillboards_D3D(); //Ritor1: it's temporarily pGame->pStru6Instance->RenderSpecialEffects(); pRenderD3D->pDevice->EndScene(); } @@ -7991,7 +7970,7 @@ if ( this->uNumD3DSceneBegins ) { v4 = pSoftBillboard; - v5 = (double)HIWORD(pSoftBillboard->sZValue); + v5 = (double)pSoftBillboard->zbuffer_depth; pSoftBillboarda = v5; v6 = v5; v7 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v6)); @@ -8008,8 +7987,8 @@ pBillboardRenderListD3D[v9].uParentBillboardID = v4->uParentBillboardID; v25 = v4->uScreenSpaceX; v24 = v4->uScreenSpaceY; - a1 = (double)(v4->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_10); - v29 = (double)(v4->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_14); + a1 = (v4->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(v4->_screenspace_x_scaler_packedfloat); + v29 = (v4->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(v4->_screenspace_y_scaler_packedfloat); v31 = (double)((v10->uBufferWidth >> 1) - v10->uAreaX); v27 = (double)(v10->uBufferHeight - v10->uAreaY); if ( v4->uFlags & 4 ) @@ -8076,7 +8055,7 @@ pBillboardRenderListD3D[v9].pQuards[3].texcoord.y = 0.0; v23 = v10->pTexture; pBillboardRenderListD3D[v9].uNumVertices = 4; - pBillboardRenderListD3D[v9].flt_88 = pSoftBillboarda; + pBillboardRenderListD3D[v9].z_order = pSoftBillboarda; pBillboardRenderListD3D[v9].pTexture = v23; } } @@ -8131,9 +8110,9 @@ if ( this->uNumD3DSceneBegins ) { - if ( HIWORD(a2->sZValue) ) - { - v5 = (double)HIWORD(a2->sZValue); + if (a2->zbuffer_depth) + { + v5 = (double)a2->zbuffer_depth; v6 = v5; v7 = v5; v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); @@ -8143,7 +8122,7 @@ pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; v9 = a2->uScreenSpaceX; v10 = a2->uScreenSpaceY; - v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10); + v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); v12 = (double)v9; v13 = v12; v14 = (double)(v10 - 12); @@ -8249,7 +8228,7 @@ pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; pBillboardRenderListD3D[v8].pTexture = a3; - pBillboardRenderListD3D[v8].flt_88 = v6; + pBillboardRenderListD3D[v8].z_order = v6; pBillboardRenderListD3D[v8].uNumVertices = 4; pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; @@ -8307,7 +8286,7 @@ if ( this->uNumD3DSceneBegins ) { - v5 = (double)HIWORD(a2->sZValue); + v5 = (double)a2->zbuffer_depth; v6 = v5; v7 = v5; v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); @@ -8317,7 +8296,7 @@ pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; v9 = a2->uScreenSpaceX; v10 = a2->uScreenSpaceY; - v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10); + v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); v12 = (double)v9; v13 = v12; v14 = (double)(v10 - 12); @@ -8423,7 +8402,7 @@ pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; pBillboardRenderListD3D[v8].pTexture = a3; - pBillboardRenderListD3D[v8].flt_88 = v6; + pBillboardRenderListD3D[v8].z_order = v6; pBillboardRenderListD3D[v8].uNumVertices = 4; pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; @@ -8433,137 +8412,108 @@ //----- (004A4023) -------------------------------------------------------- -void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int a1a, RenderBillboard *pBillboard) -{ - RenderBillboardTransform_local0 *v5; // ebx@2 - double v6; // st7@2 - float v7; // ST08_4@2 +void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int paletteSubindex, RenderBillboard *pBillboard) +{ unsigned int v8; // esi@2 - Sprite *v9; // edi@5 - signed int v10; // eax@9 - signed int v11; // eax@9 - int v12; // eax@12 - double v13; // st7@12 double v14; // st6@14 double v15; // st5@14 - unsigned int v16; // ecx@16 - double v17; // st7@16 - double v18; // st5@16 - double v19; // st4@16 - double v20; // st5@18 - double v21; // st4@18 - IDirect3DTexture2 *v22; // eax@20 - signed int v23; // [sp+18h] [bp-18h]@5 - signed int v24; // [sp+1Ch] [bp-14h]@5 - float v25; // [sp+1Ch] [bp-14h]@12 - float v26; // [sp+20h] [bp-10h]@5 - float v27; // [sp+20h] [bp-10h]@12 - Render *a3; // [sp+24h] [bp-Ch]@1 + //unsigned int v16; // ecx@16 + //double v17; // st7@16 + //double v18; // st5@16 + //double v19; // st4@16 + //double v20; // st5@18 + //double v21; // st4@18 + //signed int v23; // [sp+18h] [bp-18h]@5 + //signed int v24; // [sp+1Ch] [bp-14h]@5 + //float v26; // [sp+20h] [bp-10h]@5 + //float v27; // [sp+20h] [bp-10h]@12 float v29; // [sp+28h] [bp-8h]@5 float v30; // [sp+2Ch] [bp-4h]@5 - float v31; // [sp+38h] [bp+8h]@2 - float pSpritea; // [sp+3Ch] [bp+Ch]@5 - float a1b; // [sp+40h] [bp+10h]@12 - float pBillboarda; // [sp+44h] [bp+14h]@12 - - auto a1 = this; - a3 = a1; - if ( a1->uNumD3DSceneBegins ) - { - v5 = a2; - v6 = (double)a2->sZValue; - v31 = v6; - v7 = v6; - v8 = Billboard_ProbablyAddToListAndSortByZOrder(v7); - if ( BYTE3(v5->uTintColor) ) - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; - else - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; - v9 = pSprite; - pBillboardRenderListD3D[v8].field_90 = v5->field_44; - pBillboardRenderListD3D[v8].sZValue = v5->sZValue; - pBillboardRenderListD3D[v8].uParentBillboardID = v5->uParentBillboardID; - v24 = v5->uScreenSpaceX; - v23 = v5->uScreenSpaceY; - v30 = (double)(v5->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_10); - v29 = (double)(v5->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_14); - pSpritea = (double)((v9->uBufferWidth >> 1) - v9->uAreaX); - v26 = (double)(v9->uBufferHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) - pSpritea = pSpritea * -1.0; - if ( v5->uTintColor & 0xFFFFFF && a3->bTinting ) - { - v10 = GetActorTintColor(a1a, 0, v31, 0, pBillboard); - v11 = sub_4A19D8(v5->uTintColor, v10); - if ( BYTE3(v5->uTintColor) ) - v11 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v11 >> 1); - } - else - { - v11 = GetActorTintColor(a1a, 0, v31, 0, pBillboard); - } - pBillboardRenderListD3D[v8].pQuards[0].diffuse = v11; - v12 = 0; - pBillboarda = (double)v24; - pBillboardRenderListD3D[v8].pQuards[0].pos.x = pBillboarda - pSpritea * v30; - a1b = (double)v23; - pBillboardRenderListD3D[v8].pQuards[0].pos.y = a1b - v26 * v29; - v27 = v31 * 1000.0; - v13 = 1.0; - pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (v27 / (double)pOutdoorCamera->shading_dist_mist); - v25 = 1.0 / v31; - pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; - if ( a3->bUsingSpecular ) - { - v12 = sub_47C3D7_get_fog_related_stuff(0, 0, v31); - v13 = 1.0; - } - pBillboardRenderListD3D[v8].pQuards[0].specular = v12; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; - v14 = (double)((v9->uBufferWidth >> 1) - v9->uAreaX); - v15 = (double)(v9->uBufferHeight - v9->uAreaHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) + //float pSpritea; // [sp+3Ch] [bp+Ch]@5 + + if (!uNumD3DSceneBegins) + return; + + v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); + + v30 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_x_scaler_packedfloat); + v29 = (a2->_screenspace_y_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_y_scaler_packedfloat); + + unsigned int diffuse = GetActorTintColor(paletteSubindex, 0, a2->zbuffer_depth, 0, pBillboard); + if (a2->uTintColor & 0x00FFFFFF && bTinting) + { + diffuse = sub_4A19D8(a2->uTintColor, diffuse); + if (a2->uTintColor & 0xFF000000) + diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); + } + + unsigned int specular = 0; + if (bUsingSpecular) + specular = sub_47C3D7_get_fog_related_stuff(0, 0, a2->zbuffer_depth); + + v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); + if (a2->uFlags & 4) + v14 *= -1.0; + pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; + pBillboardRenderListD3D[v8].pQuards[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; + pBillboardRenderListD3D[v8].pQuards[0].specular = specular; + pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; + + v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); + if ( a2->uFlags & 4 ) v14 = v14 * -1.0; - v16 = pBillboardRenderListD3D[v8].pQuards[0].diffuse; - pBillboardRenderListD3D[v8].pQuards[1].specular = v12; - pBillboardRenderListD3D[v8].pQuards[1].diffuse = v16; - pBillboardRenderListD3D[v8].pQuards[1].pos.x = pBillboarda - v14 * v30; - pBillboardRenderListD3D[v8].pQuards[1].pos.y = a1b - v15 * v29; - v17 = v13 - v13 / (v27 / (double)pOutdoorCamera->shading_dist_mist); - pBillboardRenderListD3D[v8].pQuards[1].pos.z = v17; - pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; + pBillboardRenderListD3D[v8].pQuards[1].specular = specular; + pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; + pBillboardRenderListD3D[v8].pQuards[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; - v18 = (double)(v9->uAreaWidth + v9->uAreaX + (v9->uBufferWidth >> 1) - v9->uBufferWidth); - v19 = (double)(v9->uBufferHeight - v9->uAreaHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) - v18 = v18 * -1.0; - pBillboardRenderListD3D[v8].pQuards[2].diffuse = v16; - pBillboardRenderListD3D[v8].pQuards[2].specular = v12; - pBillboardRenderListD3D[v8].pQuards[2].pos.x = v18 * v30 + pBillboarda; - pBillboardRenderListD3D[v8].pQuards[2].pos.y = a1b - v19 * v29; - pBillboardRenderListD3D[v8].pQuards[2].pos.z = v17; - pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; + + v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); + if ( a2->uFlags & 4 ) + v14 *= -1.0; + pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[2].specular = specular; + pBillboardRenderListD3D[v8].pQuards[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; + pBillboardRenderListD3D[v8].pQuards[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; - v20 = (double)(v9->uAreaWidth + v9->uAreaX + (v9->uBufferWidth >> 1) - v9->uBufferWidth); - v21 = (double)(v9->uBufferHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) - v20 = v20 * -1.0; - pBillboardRenderListD3D[v8].pQuards[3].diffuse = v16; - pBillboardRenderListD3D[v8].pQuards[3].specular = v12; - pBillboardRenderListD3D[v8].pQuards[3].pos.x = v20 * v30 + pBillboarda; - pBillboardRenderListD3D[v8].pQuards[3].pos.y = a1b - v21 * v29; - pBillboardRenderListD3D[v8].pQuards[3].pos.z = v17; - pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; + + v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); + if ( a2->uFlags & 4 ) + v14 *= -1.0; + pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[3].specular = specular; + pBillboardRenderListD3D[v8].pQuards[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; + pBillboardRenderListD3D[v8].pQuards[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; - v22 = v9->pTexture; - pBillboardRenderListD3D[v8].uNumVertices = 4; - pBillboardRenderListD3D[v8].pTexture = v22; - pBillboardRenderListD3D[v8].flt_88 = v31; - } + + pBillboardRenderListD3D[v8].uNumVertices = 4; + pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; + pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; + pBillboardRenderListD3D[v8].field_90 = a2->field_44; + pBillboardRenderListD3D[v8].sZValue = a2->sZValue; + pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; + + if (a2->uTintColor & 0xFF000000) + pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; + else + pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; } @@ -8834,7 +8784,7 @@ v13 = a1->field_10; pBillboardRenderListD3D[v5].pTexture = 0; pBillboardRenderListD3D[v5].uNumVertices = v13; - LODWORD(pBillboardRenderListD3D[v5].flt_88) = v14; + LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; } } @@ -8958,8 +8908,8 @@ Render *v3; // ebx@1 HWLTexture *result; // eax@1 HWLTexture *v5; // esi@1 - unsigned int v6; // ST18_4@2 - RenderD3D *v7; // ecx@2 + //unsigned int v6; // ST18_4@2 + //RenderD3D *v7; // ecx@2 Sprite *v8; // ebx@4 unsigned __int16 *v9; // edx@5 LPVOID v10; // eax@5 @@ -8982,9 +8932,9 @@ v2->uBufferHeight = result->field_1C; v2->uAreaWidth = result->field_20; v2->uAreaHeight = result->field_24; - v6 = v3->uMinDeviceTextureDim; - v7 = v3->pRenderD3D; - if ( !v7->CreateTexture(result->uWidth, result->uHeight, &v2->pTextureSurface, &v2->pTexture, 1u, 0, v6) ) + //v6 = v3->uMinDeviceTextureDim; + //v7 = v3->pRenderD3D; + if (!pRenderD3D->CreateTexture(result->uWidth, result->uHeight, &v2->pTextureSurface, &v2->pTexture, 1u, 0, uMinDeviceTextureDim)) Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); //pSprite = v2->pTextureSurface; //pSprite = (Sprite *)pSprite->pName; @@ -11329,18 +11279,51 @@ ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); + + /*if (pRenderer->uNumBillboardsToDraw) + { + auto p = &pRenderer->pBillboardRenderListD3D[0]; + for (int i = 0; i < p->uNumVertices; ++i) + { + p->pQuards[i].pos.z -= p->pQuards[i].pos.z * 0.6; + //p->pQuards[i].rhw = + 0.8 * (1.0f - p->pQuards[i].rhw); + } + p->pQuards[0].pos.x = 10; + p->pQuards[0].pos.y = 10; + + p->pQuards[1].pos.x = 10; + p->pQuards[1].pos.y = 200; + + p->pQuards[2].pos.x = 100; + p->pQuards[2].pos.y = 200; + + p->pQuards[3].pos.x = 100; + p->pQuards[3].pos.y = 10; + + if (p->uOpacity != RenderBillboardD3D::NoBlend) + SetBillboardBlendOptions(p->uOpacity); + + pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); + ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + p->pQuards, p->uNumVertices, + D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); + + }*/ for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) { auto p = &pRenderer->pBillboardRenderListD3D[i]; - if (p->uOpacity != RenderBillboardD3D::InvalidOpacity) + if (p->uOpacity != RenderBillboardD3D::NoBlend) SetBillboardBlendOptions(p->uOpacity); pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - p->pQuards, p->uNumVertices, D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); + ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + p->pQuards, p->uNumVertices, + D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); } if (pRenderer->bFogEnabled) @@ -11404,6 +11387,7 @@ default: Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); + assert(false); break; } }
--- a/Render.h Tue Feb 12 18:16:18 2013 +0600 +++ b/Render.h Tue Feb 12 18:16:34 2013 +0600 @@ -52,12 +52,12 @@ #pragma pack(push, 1) struct RenderBillboard { - int field_0; - int field_4; + int _screenspace_x_scaler_packedfloat; + int _screenspace_y_scaler_packedfloat; float fov_x; float fov_y; int sZValue; - int field_14; + int field_14_actor_id; unsigned __int16 uHwSpriteID; __int16 uPalette; __int16 uIndoorSectorID; @@ -177,13 +177,13 @@ Opaque_1 = 1, Opaque_2 = 2, Opaque_3 = 3, - InvalidOpacity = 0xFFFFFFFF + NoBlend = 0xFFFFFFFF }; IDirect3DTexture2 *pTexture; unsigned int uNumVertices; RenderVertexD3D3 pQuards[4]; - float flt_88; + float z_order; OpacityType uOpacity; int field_90; int sZValue; @@ -301,7 +301,7 @@ void PresentRect(RECT *a2, RECT *a3); void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags); void BltBackToFontFast(int a2, int a3, RECT *a4); - unsigned int Billboard_ProbablyAddToListAndSortByZOrder(unsigned int a1); + unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z); unsigned int GetBillboardDrawListSize(); unsigned int GetParentBillboardID(unsigned int uBillboardID); void BeginSceneD3D(); @@ -316,7 +316,7 @@ void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8); void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); - void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int a1a, RenderBillboard *pBillboard); + void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int paletteSubindex, RenderBillboard *pBillboard); void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex); int MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6); void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); @@ -349,7 +349,7 @@ int OnOutdoorRedrawSW(); void DrawSkyD3D(); int DrawSkySW(struct Span *a1, stru148 *a2, int a3); - void DrawDecorations(); + void PrepareDecorationsRenderList_ODM(); void DrawLayingItems_Shooting_Magic_ODM(); void TransformBillboardsAndSetPalettesODM(); float DrawBezierTerrain(); @@ -462,13 +462,21 @@ int *pTargetZ; int uScreenSpaceX; int uScreenSpaceY; - int field_10; - int field_14; + int _screenspace_x_scaler_packedfloat; + int _screenspace_y_scaler_packedfloat; char field_18[8]; unsigned __int16 *pPalette; unsigned __int16 *pPalette2; - int sZValue; - unsigned int uFlags; + union + { + int sZValue; + struct + { + unsigned short object_pid; + short zbuffer_depth; + }; + }; + unsigned int uFlags; // & 4 - mirror horizontally unsigned int uTargetPitch; unsigned int uViewportX; unsigned int uViewportY;
--- a/SaveLoad.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/SaveLoad.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -191,7 +191,7 @@ pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = true; @@ -325,7 +325,7 @@ strcpy(pDir.pFilename, "image.pcx"); pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); free(pScreenshot); - if (pCurrentScreen == 11) //SaveScreen + if (pCurrentScreen == SCREEN_SAVEGAME) { pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0)); @@ -636,7 +636,7 @@ } GUI_UpdateWindows(); pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; v3 = pSavegameThumbnails; viewparams->bRedrawGameUI = 1; do
--- a/Spells.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/Spells.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -51,7 +51,7 @@ if ( v2 ) { ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v2 + 105])->Reset(); - pOtherOverlayList->field_3EC = 1; + pOtherOverlayList->bRedraw = true; v1->uOverlayID = 0; } } @@ -100,7 +100,7 @@ if ( (unsigned __int16)v8 != a5 ) { ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v8 + 105])->Reset(); - pOtherOverlayList->field_3EC = 1; + pOtherOverlayList->bRedraw = true; v6->uOverlayID = 0; } }
--- a/VideoPlayer.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/VideoPlayer.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -360,7 +360,7 @@ pRenderer->ClearTarget(0); pRenderer->EndScene(); } - pCurrentScreen = 16; // + pCurrentScreen = SCREEN_VIDEO; if ( pVideoPlayer->uMovieFormat == 2 ) { if ( pVideoPlayer->pBinkMovie ) @@ -419,11 +419,11 @@ } } if ( uGameState == GAME_FINISHED ) - pCurrentScreen = 0;//MainMenuScreen + pCurrentScreen = SCREEN_GAME; pVideoPlayer->bPlayingMovie = 0; ShowCursor(1); - if ( pCurrentScreen == 16 )// - pCurrentScreen = 0; + if ( pCurrentScreen == SCREEN_VIDEO ) + pCurrentScreen = SCREEN_GAME; } }
--- a/mm7_1.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_1.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -883,7 +883,7 @@ if ( !(v16 & 0xF0) ) { if ( v16 & 1 - || pCurrentScreen != 13 ) + || pCurrentScreen != SCREEN_HOUSE ) { if ( v16 & 2 ) pRenderer->_4A6776(uCellX, uCellY, v7); @@ -1257,8 +1257,7 @@ //----- (0041AD6E) -------------------------------------------------------- void __cdecl GameUI_DrawRightPanelItems() { - if ( (signed int)((pParty->uTimePlayed - qword_507CC8) >> 32) <= 0 - && (((pParty->uTimePlayed - qword_507CC8) >> 32) & 0x80000000u) != 0i64 ) + if ( (signed int)((pParty->uTimePlayed - qword_507CC8) >> 32) <= 0 && (((pParty->uTimePlayed - qword_507CC8) >> 32) & 0x80000000u) != 0i64 ) qword_507CC8 = 0i64; if ( (((pParty->uTimePlayed - qword_507CC8) >> 32) & 0x80000000u) == 0i64 && (!(SHIDWORD(pParty->uTimePlayed) < (LODWORD(pParty->uTimePlayed) < (unsigned int)qword_507CC8) @@ -1267,24 +1266,14 @@ { qword_507CC8 = pParty->uTimePlayed; byte_50697C = byte_50697C == 0; - if ( byte_50697C - && pCurrentScreen != 5 ) + if ( byte_50697C && pCurrentScreen != SCREEN_REST ) { if ( bFlashQuestBook ) - pRenderer->DrawTextureTransparent( - 493u, - 355u, - (Texture *)(uTextureID_ib_td1_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0)); + pRenderer->DrawTextureTransparent(493, 355, (Texture *)(uTextureID_ib_td1_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0)); if ( bFlashAutonotesBook ) - pRenderer->DrawTextureTransparent( - 527u, - 353u, - (Texture *)(uTextureID_ib_td2_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td2_A] : 0)); + pRenderer->DrawTextureTransparent(527, 353, (Texture *)(uTextureID_ib_td2_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td2_A] : 0)); if ( bFlashHistoryBook ) - pRenderer->DrawTextureTransparent( - 600u, - 361u, - (Texture *)(uTextureID_ib_td5_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0)); + pRenderer->DrawTextureTransparent(600, 361, (Texture *)(uTextureID_ib_td5_A != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0)); } else { @@ -2088,7 +2077,7 @@ v12 = pWindowList[v3].field_34; if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) { - v8 = pCurrentScreen == 21; + v8 = pCurrentScreen == SCREEN_PARTY_CREATION; pWindowList[v3].pCurrentPosActiveItem -= v12; if ( v8 ) { @@ -2128,7 +2117,7 @@ v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) { - v8 = pCurrentScreen == 21; + v8 = pCurrentScreen == SCREEN_PARTY_CREATION; pWindowList[v3].pCurrentPosActiveItem = v7; if ( v8 ) { @@ -2996,8 +2985,8 @@ v106.uViewportW = v12 + 128; v106.uViewportZ = v106.uViewportX + 128; v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2; - v106.field_10 = 65536; - v106.field_14 = 65536; + v106._screenspace_x_scaler_packedfloat = 65536; + v106._screenspace_y_scaler_packedfloat = 65536; v106.uScreenSpaceY = v115 + v12 + *(short *)(v11 + 18); v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1); v106.sZValue = 0; @@ -3672,7 +3661,7 @@ pTexture_RestUI_CurrentSkyFrame = 0; pIcons_LOD->_4114F2(); pIcons_LOD->_40F9C5(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { @@ -3701,7 +3690,7 @@ if ( pCurrentScreen ) { pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; } pEventTimer->Pause(); @@ -3740,7 +3729,7 @@ ++pIcons_LOD->uTexturePacksCount; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - pCurrentScreen = 5; + pCurrentScreen = SCREEN_REST; _507CD4_RestUI_hourglass_anim_controller = 0; uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); @@ -4406,7 +4395,7 @@ v5 = rand() % 4; v6 = dword_5B5920 >> 3; v35 = v5; - if ( (dword_5B5920 & 7) == 5 ) + if ( (dword_5B5920 & 7) == OBJECT_Decoration) { v16 = v6; v14 = pLevelDecorations[v6].vPosition.x; @@ -4416,7 +4405,7 @@ } else { - if ( (dword_5B5920 & 7) != 6 ) + if ( (dword_5B5920 & 7) != OBJECT_BModel) goto LABEL_12; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { @@ -4550,7 +4539,7 @@ (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0); - pCurrentScreen = 10; + pCurrentScreen = SCREEN_CHEST; pEventTimer->Pause(); return 1; } @@ -5063,7 +5052,7 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - if ( (v18 & 7) == 6 ) // bmodel + if ( (v18 & 7) == OBJECT_BModel) { if ( v18 < (signed int)0x2000000u ) { @@ -5213,7 +5202,7 @@ if ( uNumVisibleWindows <= 0 ) { LABEL_38: - if ( pCurrentScreen == 10 ) // ChestScreen + if ( pCurrentScreen == SCREEN_CHEST ) { sub_42038D(); //goto _return; @@ -5228,7 +5217,7 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - if ( pCurrentScreen == 13 ) // HouseScreen + if ( pCurrentScreen == SCREEN_HOUSE ) { if ( dword_F8B19C != 2 || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0) @@ -5616,7 +5605,7 @@ pAudioPlayer->StopChannels(-1, -1); bRingsShownInCharScreen = 0; CharacterUI_LoadPaperdollTextures(); - pCurrentScreen = 23; + pCurrentScreen = SCREEN_CASTING; v2 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|WINDOW_Options), v1, 0); pCharacterScreen_ExitBtn = v2->CreateButton( 394u, @@ -5786,16 +5775,16 @@ pGUIWindow_CurrentMenu = GameUI_InitializeCharacterWindow(v5); return; } - if ( pCurrentScreen == 8 ) + if ( pCurrentScreen == SCREEN_SPELL_BOOK ) return; - if ( pCurrentScreen == 10 ) + if ( pCurrentScreen == SCREEN_CHEST ) { //LABEL_23: viewparams->bRedrawGameUI = 1; if ( uActiveCharacter == v1 ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = 15; + pCurrentScreen = SCREEN_F; //goto LABEL_28; uActiveCharacter = v1; return; @@ -5807,15 +5796,15 @@ uActiveCharacter = v1; return; } - if ( pCurrentScreen != 13 ) - { - if ( pCurrentScreen == 14 ) + if ( pCurrentScreen != SCREEN_HOUSE ) + { + if ( pCurrentScreen == SCREEN_E ) { //LABEL_28: uActiveCharacter = v1; return; } - if ( pCurrentScreen != 15 ) + if ( pCurrentScreen != SCREEN_F ) { viewparams->bRedrawGameUI = 1; uActiveCharacter = v1; @@ -5828,7 +5817,7 @@ if ( uActiveCharacter == v1 ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - pCurrentScreen = 15; + pCurrentScreen = SCREEN_F; //goto LABEL_28; uActiveCharacter = v1; return; @@ -6003,7 +5992,7 @@ v1 = pMouse->GetCursorPos(&a2); v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v25)->y]]; } - if ( (v0 & 7) == 2 ) + if ( (v0 & 7) == OBJECT_Item) { a2.y = (signed int)(unsigned __int16)v0 >> 3; v21 = (signed int)(unsigned __int16)v0 >> 3; @@ -6035,9 +6024,9 @@ } goto LABEL_13; } - if ( (v0 & 7) != 3 ) - { - if ( (v0 & 7) == 5 ) + if ( (v0 & 7) != OBJECT_Actor) + { + if ( (v0 & 7) == OBJECT_Decoration) { v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) @@ -6058,7 +6047,7 @@ } else { - if ( (v0 & 7) != 6 || (unsigned int)v0 >= 0x2000000 ) + if ( (v0 & 7) != OBJECT_BModel || (unsigned int)v0 >= 0x2000000 ) goto LABEL_13; v2 = (signed int)(unsigned __int16)v0 >> 3; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) @@ -6216,12 +6205,12 @@ bool __cdecl sub_4226C2() { if ( pCurrentScreen - && pCurrentScreen != 4 - && pCurrentScreen != 17 ) - { - if ( pCurrentScreen == 18 ) + && pCurrentScreen != SCREEN_NPC_DIALOGUE + && pCurrentScreen != SCREEN_CHANGE_LOCATION ) + { + if ( pCurrentScreen == SCREEN_INPUT_BLV ) return pVideoPlayer->pSmackerMovie != 0; - if ( pCurrentScreen != 19 ) + if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) return 1; } return 0;
--- a/mm7_2.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_2.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -3249,7 +3249,7 @@ do { v2 = v1->uAIState; - if ( v1->uAIState == 5 || v2 == 11 || v2 == 19 || (v3 = v1->uSummonerID) != 0 && (v3 & 7) == 4 ) + if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && (v3 & 7) == OBJECT_Player) ++v0; ++v1; --v7; @@ -4518,7 +4518,7 @@ v0 = pPlayers[uActiveCharacter]; v77 = pPlayers[uActiveCharacter]; - if ( pCurrentScreen == 14 ) + if ( pCurrentScreen == SCREEN_E ) goto LABEL_73; if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { @@ -12038,7 +12038,7 @@ GUIButton *pButton2; // [sp+0h] [bp-3Ch]@27 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 - pCurrentScreen = 0; // + pCurrentScreen = SCREEN_GAME; if (pAsyncMouse) pAsyncMouse->Resume(); if ( LOBYTE(pGame->pKeyboardInstance->bUsingAsynKeyboard) && pAsyncKeyboard ) @@ -12074,12 +12074,12 @@ pWindow = pWindow_MainMenu; if ( GetCurrentMenuID() == MENU_SAVELOAD)// { - if ( pCurrentScreen != 12 )// + if ( pCurrentScreen != SCREEN_LOADGAME ) { pTexture_PCX.Release(); pTexture_PCX.Load("lsave640.pcx", 0); pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); - pCurrentScreen = 12; // + pCurrentScreen = SCREEN_LOADGAME; GameUI_DrawLoadMenu(0);// } pWindow = pGUIWindow_CurrentMenu; @@ -12114,7 +12114,7 @@ pIcons_LOD->_4114F2(); pGUIWindow_CurrentMenu->Release(); pGUIWindow_CurrentMenu = 0; - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; } } @@ -12497,7 +12497,7 @@ goto LABEL_104; } if ( pCurrentScreen - && pCurrentScreen != 21 ) + && pCurrentScreen != SCREEN_PRESS_ESCAPE_MESSAGE ) return 0; } if ( !viewparams->field_4C ) @@ -13485,6 +13485,7 @@ pParty = new Party; + memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings)); pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile); pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile); pParty->sEyelevel = pParty->uDefaultEyelevel; @@ -15597,7 +15598,7 @@ } while ( v6 < v22 ); } - if ( (v7 & 7) == 5 ) + if ( (v7 & 7) == OBJECT_Decoration) { v16 = (unsigned int)v7 >> 3; if ( (signed int)(((unsigned int)*v21 >> 16) @@ -15696,7 +15697,7 @@ v2 = a1; switch ( a1 & 7 ) { - case 2: + case OBJECT_Item: v17 = a1 >> 3; v26 = a1 >> 3; v18 = a1 >> 3; @@ -15729,7 +15730,8 @@ } LayingItem::_42F933(v21); break; - case 3: + + case OBJECT_Actor: v12 = a1 >> 3; v13 = &pActors[a1 >> 3]; v14 = v13->uAIState; @@ -15771,7 +15773,8 @@ } } break; - case 5: + + case OBJECT_Decoration: v8 = &pLevelDecorations[a1 >> 3]; v9 = v8->field_16_event_id; if ( v9 ) @@ -15791,10 +15794,11 @@ _5C3420_pDecoration = 0; } break; + default: - if ( (a1 & 7) != 6 ) - { - MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); + if ( (a1 & 7) != OBJECT_BModel) + { + MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); return 1; } if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) @@ -15816,7 +15820,7 @@ } if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) return 1; - if ( pCurrentScreen != 19 ) + if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) goto LABEL_13; break; } @@ -15865,7 +15869,7 @@ v6 = ((v12 - v4 - 1) >> 1) + 1; do { - if ( (*(char *)v5 & 7) == 3 ) + if ( (*(char *)v5 & 7) == OBJECT_Actor) { if ( *v5 <= a3 << 16 ) { @@ -15936,7 +15940,7 @@ v3 = pRenderer->GetParentBillboardID(a1a); v4 = pBillboardRenderList[v3].sZValue; v5 = (unsigned __int16)pBillboardRenderList[v3].sZValue; - if ( (v5 & 7) == 3 ) + if ( (v5 & 7) == OBJECT_Actor) { if ( v4 <= (unsigned int)(a3 << 16) ) { @@ -16195,7 +16199,7 @@ { v19 = dword_720020_zvalues[v18] & 0xFFFF; v20 = (dword_720020_zvalues[v18] & 0xFFFFu) >> 3; - if ( (dword_720020_zvalues[v18] & 7) == 2 ) + if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Item) { if ( v20 >= 0x3E8 ) return 0; @@ -16208,16 +16212,16 @@ } goto LABEL_41; } - if ( (dword_720020_zvalues[v18] & 7) == 3 ) + if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Actor) { if ( v20 >= 0xBB8 ) return 0; v24 = (const char *)&pActors[v20]; goto LABEL_51; } - if ( (dword_720020_zvalues[v18] & 7) == 5 ) + if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Decoration) break; - if ( (dword_720020_zvalues[v18] & 7) == 6 ) + if ( (dword_720020_zvalues[v18] & 7) == OBJECT_BModel) { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { @@ -16340,7 +16344,7 @@ UI_CreateTravelDialogue(); } } - //UpdateActors_ODM();Ritor1: it's temporarily + UpdateActors_ODM();//Ritor1: it's temporarily _46CC4B_check_event_triggers(); } @@ -16549,14 +16553,14 @@ v3 = &pObjectList->pObjects[v2->uObjectDescID]; v145 = a2; v151 = a2 & 7; - if ( (a2 & 7) == 3 ) - { - if ( (v2->field_58 & 7) == 3 && !pActors[v2->field_58 >> 3].GetActorsRelation(&pActors[a2 >> 3]) ) + if ( (a2 & 7) == OBJECT_Actor) + { + if ( (v2->field_58 & 7) == OBJECT_Actor && !pActors[v2->field_58 >> 3].GetActorsRelation(&pActors[a2 >> 3]) ) return 1; } else { - if ( (a2 & 7) == 4 && (v2->field_58 & 7) == 4 ) + if ( (a2 & 7) == OBJECT_Player && (v2->field_58 & 7) == OBJECT_Player) return 1; } if ( pParty->bTurnBasedModeOn == 1 ) @@ -16568,7 +16572,7 @@ v2->uAttributes = v5 & 0xFFFB; } } - if ( v151 == 6 && (v2->field_58 & 7) != 4 ) + if ( v151 == OBJECT_BModel && (v2->field_58 & 7) != OBJECT_Player) BYTE2(pActors[v2->field_58 >> 3].uAttributes) |= 4u; v6 = v2->uItemType; v7 = v2->uItemType; @@ -16625,7 +16629,7 @@ break; } v138 = 1; - if ( v151 != 3 ) + if ( v151 != OBJECT_Actor) { if ( v6 != 9030 || v2->field_50 != 4 ) goto LABEL_246;
--- a/mm7_3.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_3.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -959,7 +959,7 @@ signed int v60; // eax@107 int v61; // eax@124 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42 - char v63; // [sp+18h] [bp-38h]@64 + int v63; // [sp+18h] [bp-38h]@64 int v64; // [sp+1Ch] [bp-34h]@64 int v65; // [sp+20h] [bp-30h]@2 int v66; // [sp+24h] [bp-2Ch]@2 @@ -995,7 +995,7 @@ v74 = v4; if ( !v0->CanAct() ) v74 = 0; - v70 = GetTerrainHeightsAroundParty(v0->vPosition.x, v0->vPosition.y); + v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); v5 = sub_46D49E_prolly_get_world_y_under_party( v0->vPosition.x, v0->vPosition.y, @@ -1088,7 +1088,7 @@ v18 = v0->vPosition.y; v19 = v0->vPosition.x; v0->vPosition.z = v7; - _46DCC8_get_gravity_direction_outdoor(v19, v18, &v62); + ODM_GetTerrainNormalAt(v19, v18, &v62); v20 = GetGravityStrength(); v21 = v62.y; v22 = v62.z; @@ -1337,8 +1337,8 @@ v70 = v0->vVelocity.z; v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16; ++v69; - v54 = __OFSUB__(v69, 100); - v10 = ((v69 - 100) & 0x80000000u) != 0; + v54 = v69 < 100; + v10 = (v69 - 100) < 0; v0->vVelocity.z = v70; if ( !(v10 ^ v54) ) break; @@ -1483,11 +1483,11 @@ { _46E44E_collide_against_faces_and_portals(0); _46E0B2_collide_against_decorations(); - if ( (v1->field_58 & 7) != 4 ) + if ( (v1->field_58 & 7) != OBJECT_Player) _46EF01_collision_chech_player(1); v13 = v1->field_58; v42 = v8; - if ( (v13 & 7) == 3 ) + if ( (v13 & 7) == OBJECT_Actor) { if ( (signed int)uNumActors > v8 ) { @@ -1575,7 +1575,7 @@ if ( v2->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) return; v15 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == 5 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) { v40 = sub_452A9E(v1->vVelocity.x * v1->vVelocity.x + v1->vVelocity.y * v1->vVelocity.y); v23 = stru_5C6E00->Atan2( @@ -1593,7 +1593,7 @@ } else { - if ( (stru_721530.uFaceID & 7) != 6 ) + if ( (stru_721530.uFaceID & 7) != OBJECT_BModel) goto LABEL_64; stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3; v16 = &pIndoor->pFaces[v15]; @@ -1826,7 +1826,7 @@ v1 = &pLayingItems[uLayingItemID]; v58 = 0; v2 = &pObjectList->pObjects[v1->uObjectDescID]; - v57 = GetTerrainHeightsAroundParty(v1->vPosition.x, v1->vPosition.y); + v57 = IsTerrainSlopeTooHigh(v1->vPosition.x, v1->vPosition.y); v3 = v1->vPosition.y; v4 = v1->vPosition.x; v5 = v2->uHeight; @@ -1864,7 +1864,7 @@ v11 = v1->vPosition.y; v12 = v1->vPosition.x; v1->vPosition.z = v8; - _46DCC8_get_gravity_direction_outdoor(v12, v11, &v51); + ODM_GetTerrainNormalAt(v12, v11, &v51); v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16; v60 = (Actor *)((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); @@ -1987,9 +1987,9 @@ v58 = v16; v18 = WorldPosToGridCellX(v17); _46E26D_collide_against_sprites(v18, v58); - if ( (v1->field_58 & 7) != 4 ) + if ( (v1->field_58 & 7) != OBJECT_Player) _46EF01_collision_chech_player(0); - if ( (v1->field_58 & 7) == 3 ) + if ( (v1->field_58 & 7) == OBJECT_Actor) { v19 = v1->field_58 >> 3; if ( v19 >= 0 ) @@ -2094,9 +2094,9 @@ return; } v30 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == 5 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) break; - if ( (stru_721530.uFaceID & 7) == 6 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) { v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; v32 = &v31->pFaces[v30 & 0x3F]; @@ -2814,7 +2814,7 @@ uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z; - if ( (stru_721530.uFaceID & 7) == 3 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) { if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) ) @@ -2822,7 +2822,7 @@ viewparams->bRedrawGameUI = 1; goto LABEL_152; } - if ( (stru_721530.uFaceID & 7) == 5 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) { v53 = sub_452A9E(v2 * v2 + v1 * v1); v80 = v53; @@ -2835,7 +2835,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == 6 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) { v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; v45 = v44->uPolygonType; @@ -2994,48 +2994,48 @@ //----- (00473893) -------------------------------------------------------- void __cdecl ODM_ProcessPartyActions() { - int _zero; // esi@1 + //int _zero; // esi@1 int v1; // edi@1 int v2; // ebx@1 int v3; // eax@14 - Player **v4; // esi@21 - int v5; // eax@24 + //Player **v4; // esi@21 + //int v5; // eax@24 int v6; // esi@45 ODMFace *v7; // ecx@45 //unsigned int v8; // eax@71 - double v9; // st7@72 + //double v9; // st7@72 //signed __int64 v10; // qax@74 - double v11; // st7@75 - int v12; // ecx@77 - int v13; // eax@84 - double v14; // st7@84 - int v15; // eax@87 - double v16; // st7@87 - int v17; // eax@88 - double v18; // st7@88 - int v19; // eax@89 - double v20; // st7@89 - int v21; // eax@92 - double v22; // st7@92 - int v23; // eax@96 - double v24; // st7@96 - int v25; // eax@97 - double v26; // st7@97 - int v27; // eax@98 - double v28; // st7@98 - signed __int64 v29; // qax@98 - unsigned int v30; // eax@103 + //double v11; // st7@75 + //int v12; // ecx@77 + //int v13; // eax@84 + //double v14; // st7@84 + //int v15; // eax@87 + //double v16; // st7@87 + //int v17; // eax@88 + //double v18; // st7@88 + //int v19; // eax@89 + //double v20; // st7@89 + //int v21; // eax@92 + //double v22; // st7@92 + //int v23; // eax@96 + //double v24; // st7@96 + //int v25; // eax@97 + //double v26; // st7@97 + //int v27; // eax@98 + //double v28; // st7@98 + //signed __int64 v29; // qax@98 + //unsigned int v30; // eax@103 int v31; // eax@130 - int v32; // ecx@141 + //int v32; // ecx@141 signed int v33; // eax@143 int v34; // esi@143 - unsigned int v35; // esi@147 + int v35; // esi@147 int v36; // eax@155 signed int v37; // esi@159 signed int v38; // eax@159 signed int i; // esi@159 int v40; // esi@162 - Player **v41; // esi@172 + //Player **v41; // esi@172 bool v42; // eax@180 signed int v43; // ecx@184 signed int v44; // edx@184 @@ -3087,14 +3087,15 @@ signed int v90; // [sp-14h] [bp-A8h]@246 signed int v91; // [sp-10h] [bp-A4h]@246 int v92; // [sp-Ch] [bp-A0h]@246 - int v93; // [sp-8h] [bp-9Ch]@104 + //int v93; // [sp-8h] [bp-9Ch]@104 unsigned int v94; // [sp-8h] [bp-9Ch]@246 - int v95; // [sp-4h] [bp-98h]@104 + //int v95; // [sp-4h] [bp-98h]@104 int v96; // [sp-4h] [bp-98h]@246 int v97; // [sp+Ch] [bp-88h]@180 - int v98; // [sp+10h] [bp-84h]@147 - int v99; // [sp+14h] [bp-80h]@147 - int v100; // [sp+18h] [bp-7Ch]@147 + Vec3_int_ v98; + //int v98; // [sp+10h] [bp-84h]@147 + //int v99; // [sp+14h] [bp-80h]@147 + //int v100; // [sp+18h] [bp-7Ch]@147 bool v101; // [sp+1Ch] [bp-78h]@33 int v102; // [sp+20h] [bp-74h]@1 int v103; // [sp+24h] [bp-70h]@1 @@ -3128,7 +3129,6 @@ v121 = pParty->uFallSpeed; v123 = pParty->vPosition.z; - _zero = 0; v1 = 0; v103 = 0; v2 = 0; @@ -3137,7 +3137,7 @@ v117 = pParty->vPosition.y; v113 = pParty->field_6F0; bJumping = 0; - v118 = GetTerrainHeightsAroundParty(pParty->vPosition.x, pParty->vPosition.y); + auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); v114 = 0; v124 = 0; v108 = 0; @@ -3183,57 +3183,52 @@ v3 = pParty->uFallStartY; if ( v3 - v123 > 512 && !bFeatherFall && v123 <= v111 + 1 ) { - if ( BYTE1(pParty->uFlags) & 1 ) - { - BYTE1(pParty->uFlags) &= 0xFEu; - } - else - { - v4 = &pPlayers[1]; // receive falling damage - do - { - if ( !(*v4)->HasEnchantedItemEquipped(72) && !(*v4)->WearsItem(529, 8) ) - { - v105 = (*v4)->GetMaxHealth(); - (*v4)->ReceiveDamage( - (signed int)((pParty->uFallStartY - v123) * (unsigned __int64)(signed __int64)((double)v105 * 0.1)) / 256, + if (pParty->uFlags & PARTY_FLAGS_1_LANDING) + { + pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; + } + else for (int _i = 0; _i < 4; ++_i) // receive falling damage + { + auto player = pParty->pPlayers + _i; + + if ( !player->HasEnchantedItemEquipped(72) && !player->WearsItem(529, 8) ) + { + player->ReceiveDamage( + (signed int)((pParty->uFallStartY - v123) * (unsigned __int64)(player->GetMaxHealth() / 10)) / 256, 4); - v5 = (*v4)->GetActualEndurance(); - v105 = 20 - (*v4)->_48EA1B_get_static_effect(v5); - (*v4)->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); - } - ++v4; - } - while ( (signed int)v4 <= (signed int)&pPlayers[4] ); - _zero = 0; + v105 = 20 - player->_48EA1B_get_static_effect(player->GetActualEndurance()); + player->SetRecoveryTime((signed __int64)((double)v105 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); + } + //} + //while ( (signed int)v4 <= (signed int)&pPlayers[4] ); } } v109 = -1; - if ( pParty->bFlying != _zero ) + if ( pParty->bFlying ) v109 = sub_46D8E3(v116, v117, v123 + pParty->uPartyHeight, (int)&v102); - v107 = v108 == _zero; + v107 = v108 == 0; v105 = v111 + 1; if ( v123 <= v111 + 1 ) { v109 = -1; - pParty->bFlying = _zero; + pParty->bFlying = false; } else { bJumping = 1; } v101 = v123 - v111 <= 32; - if ( bWalkSound != _zero && pParty->field_6F8 > _zero ) + if ( bWalkSound && pParty->field_6F8 > 0 ) pParty->field_6F8 -= pEventTimer->uTimeElapsed; - if ( !bUnderwater - && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero - && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < _zero || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= _zero) ) - pParty->bFlying = _zero; - if ( bJumping == _zero ) + if (!bUnderwater + && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0 + && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0) ) + pParty->bFlying = false; + if (!bJumping) { if ( pParty->field_6F4_packedid != (8 * v108 | OBJECT_BModel) ) { - if ( v108 != _zero ) + if (v108) { if ( v108 >> 6 < pOutdoor->uNumBModels ) { @@ -3263,18 +3258,19 @@ * stru_5C6E00->uIntegerPi) / 180)) >> 16);*/ __int64 dturn = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16; -LABEL_118: - while ( pPartyActionQueue->uNumActions ) - { - switch ( pPartyActionQueue->Next() ) + while (pPartyActionQueue->uNumActions) + { + switch (pPartyActionQueue->Next()) { case PARTY_FlyUp: - if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 ) - { - pParty->bFlying = 0; - if ( bUnderwater - || pParty->pPartyBuffs[7].uFlags & 1 - || pParty->pPlayers[pParty->pPartyBuffs[7].uCaster-1].sMana <= 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 ) + { + if (!pParty->FlyActive() && !bUnderwater) + break; + + pParty->bFlying = false; + if (bUnderwater || + pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 || + pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana <= 0 ) { if ( pParty->vPosition.z < 4000 || bJumping ) { @@ -3306,10 +3302,11 @@ v127 = (BSPModel *)1; } } - } - goto LABEL_118; + } + break; + case PARTY_FlyDown: - if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 ) + if (pParty->FlyActive() || bUnderwater) { pParty->bFlying = 0; if ( bUnderwater @@ -3329,245 +3326,222 @@ } } } - goto LABEL_118; + break; + case PARTY_TurnLeft: - //v8 = uTurnSpeed; - if ( uTurnSpeed ) - { - v12 = uTurnSpeed + _angle_y; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v9 = (double)dturn * fTurnSpeedMultiplier; - _angle_y = stru_5C6E00->uDoublePiMask & (_angle_y + (unsigned __int64)(signed __int64)v9); - } - break; + if (uTurnSpeed) + _angle_y += uTurnSpeed; //descrete turn + else + _angle_y += dturn * fTurnSpeedMultiplier; // time-based smooth turn + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_TurnRight: - //LODWORD(v10) = uTurnSpeed; - if ( uTurnSpeed ) - { - v12 = _angle_y - uTurnSpeed; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v11 = (double)dturn * fTurnSpeedMultiplier; - v12 = _angle_y - (signed __int64)v11; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - break; + if (uTurnSpeed) + _angle_y -= uTurnSpeed; + else + _angle_y -= dturn * fTurnSpeedMultiplier; + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_FastTurnLeft: - if ( uTurnSpeed ) - { - v12 = uTurnSpeed + _angle_y; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v9 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)dturn; - _angle_y = stru_5C6E00->uDoublePiMask & (_angle_y + (unsigned __int64)(signed __int64)v9); - } - break; + if (uTurnSpeed) + _angle_y += uTurnSpeed; + else + _angle_y += 2.0f * fTurnSpeedMultiplier * (double)dturn; + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_FastTurnRight: - if ( !uTurnSpeed ) - { - v11 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)dturn; - v12 = _angle_y - (signed __int64)v11; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v12 = _angle_y - uTurnSpeed; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - break; + if (!uTurnSpeed) + _angle_y -= 2.0f * fTurnSpeedMultiplier * (double)dturn; + else + _angle_y -= uTurnSpeed; + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_StrafeLeft: - v13 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v14 = (double)_walk_speed; - v126 = v13; - *(float *)&v128 = v14; - v124 = (unsigned __int64)(v13 * (signed __int64)((signed int)(signed __int64)(v14 * fWalkSpeedMultiplier) >> 1)) >> 16; - v2 -= v124; - v126 = stru_5C6E00->SinCos(_angle_y); - v124 = (unsigned __int64)(v126 - * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16; - goto LABEL_85; + { + *(float *)&v128 = pParty->uWalkSpeed; + + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0); + int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v2 -= 3 * dx / 4; + + float cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v1 += 3 * dy / 4; + + v128 = v1; + v124 = 1; + } + break; + case PARTY_StrafeRight: - v15 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v16 = (double)_walk_speed; - v126 = v15; - *(float *)&v128 = v16; - v124 = (unsigned __int64)(v15 * (signed __int64)((signed int)(signed __int64)(v16 * fWalkSpeedMultiplier) >> 1)) >> 16; - v2 += v124; - v126 = stru_5C6E00->SinCos(_angle_y); - v124 = (unsigned __int64)(v126 - * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16; - goto LABEL_90; + { + *(float *)&v128 = pParty->uWalkSpeed; + + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0); + int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v2 += 3 * dx / 4; + + float cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v1 -= 3 * dy / 4; + + v128 = v1; + v124 = 1; + } + break; + case PARTY_WalkForward: - v17 = stru_5C6E00->SinCos(_angle_y); - v18 = (double)_walk_speed; - v126 = v17; - *(float *)&v128 = v18; - v124 = (unsigned __int64)(v17 * (signed __int64)(signed int)(signed __int64)(v18 * fWalkSpeedMultiplier)) >> 16; - v2 += v124; - v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v124 = (unsigned __int64)(v126 - * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16; -LABEL_85: - v1 += v124; - goto LABEL_86; - case PARTY_WalkBackward: - v19 = stru_5C6E00->SinCos(_angle_y); - v20 = (double)_walk_speed; - v126 = v19; - *(float *)&v128 = v20; - v124 = (unsigned __int64)(v19 - * (signed __int64)(signed int)(signed __int64)(v20 * fBackwardWalkSpeedMultiplier)) >> 16; - v2 -= v124; - v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v124 = (unsigned __int64)(v126 - * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 - * fBackwardWalkSpeedMultiplier)) >> 16; -LABEL_90: - v1 -= v124; - goto LABEL_86; + { + *(float *)&v128 = _walk_speed; + + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), + cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + + int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v2 += dx; + + int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v1 += dy; + + v128 = v1; + v124 = 1; + } + break; + case PARTY_RunForward: - if ( pParty->bFlying ) - { - v21 = stru_5C6E00->SinCos(_angle_y); - v22 = (double)_walk_speed; - v126 = v21; - *(float *)&v128 = v22; - v129 = (unsigned __int64)(v21 - * (signed __int64)(signed int)(4 - * (unsigned __int64)(signed __int64)(v22 - * fWalkSpeedMultiplier))) >> 16; - v2 += v129; - v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v129 = (unsigned __int64)(v126 - * (signed __int64)(signed int)(4 - * (unsigned __int64)(signed __int64)(*(float *)&v128 - * fWalkSpeedMultiplier))) >> 16; - v1 += v129; - goto LABEL_93; - } - if ( v118 && !v108 ) - { - v23 = stru_5C6E00->SinCos(_angle_y); - v24 = (double)_walk_speed; - v126 = v23; - *(float *)&v128 = v24; - v129 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16; - v2 += v129; - v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v129 = (unsigned __int64)(v126 - * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16; - v1 += v129; - goto LABEL_86; - } - v25 = stru_5C6E00->SinCos(_angle_y); - v26 = (double)_walk_speed; - v114 = v25; - *(float *)&v128 = v26; - v129 = (unsigned __int64)(v25 - * (signed __int64)(signed int)(2 - * (unsigned __int64)(signed __int64)(v26 - * fWalkSpeedMultiplier))) >> 16; - v2 += v129; - v114 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v129 = (unsigned __int64)((signed int)v114 - * (signed __int64)(signed int)(2 - * (unsigned __int64)(signed __int64)(*(float *)&v128 - * fWalkSpeedMultiplier))) >> 16; - v1 += v129; - v114 = 1; - v128 = v1; - break; - case PARTY_RunBackward: - v27 = stru_5C6E00->SinCos(_angle_y); - v28 = (double)_walk_speed; - v126 = v27; - *(float *)&v128 = v28; - v29 = (signed __int64)(v28 * fBackwardWalkSpeedMultiplier); - if ( pParty->bFlying ) - { - v129 = (unsigned __int64)(v126 * (signed __int64)(4 * (signed int)v29)) >> 16; - v2 -= v129; - v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v129 = (unsigned __int64)(v126 - * (signed __int64)(signed int)(4 - * (unsigned __int64)(signed __int64)(*(float *)&v128 - * fBackwardWalkSpeedMultiplier))) >> 16; - v1 -= v129; -LABEL_93: + { + *(float *)&v128 = _walk_speed; + + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), + cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + + int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + + if (pParty->bFlying) + { + v2 += 4 * dx; + v1 += 4 * dy; + v128 = v1; } - else - { - v129 = (unsigned __int64)(v126 * (signed __int64)(signed int)v29) >> 16; - v2 -= v129; - v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v129 = (unsigned __int64)(v126 - * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 - * fBackwardWalkSpeedMultiplier)) >> 16; - v1 -= v129; -LABEL_86: + else if (partyAtHighSlope && !v108) + { + v2 += dx; + v1 += dy; + v128 = v1; v124 = 1; } - break; + else + { + v2 += 2 * dx; + v1 += 2 * dy; + + v128 = v1; + v114 = 1; + } + } + break; + + + case PARTY_WalkBackward: + { + *(float *)&v128 = _walk_speed; + + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), + cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + + int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; + v2 -= dx; + + int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; + v1 -= dy; + + v128 = v1; + v124 = 1; + } + break; + + + case PARTY_RunBackward: + { + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), + cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + + int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; + int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; + + if (pParty->bFlying) + { + v2 -= 4 * dx; + v1 -= 4 * dy; + v128 = v1; + } + else + { + v2 -= dx; + v1 -= dy; + + v128 = v1; + v124 = 1; + } + } + break; + + + case PARTY_CenterView: + _angle_x = 0; + break; + case PARTY_LookUp: _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); if ( _angle_x > 128 ) _angle_x = 128; - v30 = uActiveCharacter; - if ( !uActiveCharacter ) - goto LABEL_118; - v95 = 0; - v93 = 63; - goto _play_player_sound; + if (uActiveCharacter) + pPlayers[uActiveCharacter]->PlaySound(63, 0); + break; + case PARTY_LookDown: _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); if ( _angle_x < -128 ) _angle_x = -128; - v30 = uActiveCharacter; - if ( uActiveCharacter ) - { - v95 = 0; - v93 = 64; -_play_player_sound: - pPlayers[v30]->PlaySound(v93, v95); - } - goto LABEL_118; - case PARTY_CenterView: - _angle_x = 0; - goto LABEL_118; + if (uActiveCharacter) + pPlayers[uActiveCharacter]->PlaySound(64, 0); + break; + case PARTY_Jump: - if ( (!v118 || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) + if ( (!partyAtHighSlope || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) { v126 = pParty->field_24 << 6; bJumping = 1; v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121); } - goto LABEL_118; + break; + default: - goto LABEL_118; + assert(false); + case PARTY_Land: - if ( pParty->bFlying ) - { - BYTE1(pParty->uFlags) |= 1u; + if (pParty->bFlying) + { + pParty->uFlags |= PARTY_FLAGS_1_LANDING; pParty->uFallSpeed = 0; } - pParty->bFlying = 0; + pParty->bFlying = false; pPartyActionQueue->uNumActions = 0; - goto LABEL_123; - } - } + break; + } + } + LABEL_123: pParty->sRotationY = _angle_y; pParty->sRotationX = _angle_x; @@ -3582,8 +3556,7 @@ v123 = v113 + v129; if ( v127 ) v123 = v113; - if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0 - && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) ) + if (pParty->FlyActive()) stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu; pParty->uFallStartY = v123; goto LABEL_141; @@ -3597,70 +3570,70 @@ if ( pParty->bFlying ) goto LABEL_130; v113 = v123; - if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0 - && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) ) + if (pParty->FlyActive()) stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u; + LABEL_141: - v32 = 0; - if ( bJumping && !pParty->bFlying ) + if (bJumping && !pParty->bFlying) { v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength()); v34 = v121 + 2 * v33; v121 += 2 * v33; - goto LABEL_149; - } - if ( !v118 ) + goto LABEL_164; + } + if (!partyAtHighSlope) { v34 = v121; -LABEL_149: - if ( bJumping == v32 ) + if (!bJumping) goto LABEL_150; goto LABEL_164; } - if ( !bJumping ) + if (!bJumping) { if ( v108 ) goto LABEL_150; + + // rolling down the hill + // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air + // and falling to the gravity, gradually sliding downwards. nice trick v123 = v111; - _46DCC8_get_gravity_direction_outdoor(v116, v117, (Vec3_int_ *)&v98); + ODM_GetTerrainNormalAt(v116, v117, &v98); v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength(); - v129 = abs((signed __int64)v2 * (signed __int64)v98 + (signed __int64)v1 * (signed __int64)v99 + (signed __int64)v35 * (signed __int64)v100) >> 16; - v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v98) >> 16); - v2 += (int)v127; - v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v99) >> 16); - v1 += (int)v127; + v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16; + v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16; + v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16; + v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16); v128 = v1; - v127 = (BSPModel *)((unsigned __int64)(v129 * (signed __int64)v100) >> 16); - v34 = (int)((char *)v127 + v35); - v32 = 0; v121 = v34; - goto LABEL_149; + if (!bJumping) + goto LABEL_150; + goto LABEL_164; } v34 = v121; + LABEL_164: - if ( !bUnderwater && v34 <= v32 ) + if ( !bUnderwater && v34 <= 0) { if ( v34 < -500 && !pParty->bFlying && pParty->vPosition.z - v111 > 1000 - && SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 - && (SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 || !LODWORD(pParty->pPartyBuffs[5].uExpireTime)) ) - { - v41 = &pPlayers[1]; - do - { - if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(529, 8) && (*v41)->CanAct() ) - (*v41)->PlaySound(66, 0); - ++v41; - } - while ( (signed int)v41 <= (signed int)&pPlayers[4] ); - } - goto LABEL_151; - } + && !pParty->FeatherFallActive()) + { // falling scream + for (int i = 0; i < 4; ++i) + { + auto player = pParty->pPlayers + i; + if (!player->HasEnchantedItemEquipped(72) && !player->WearsItem(529, 8) && player->CanAct()) + player->PlaySound(66, 0); + } + } + } + else + { LABEL_150: pParty->uFallStartY = v123; -LABEL_151: - if ( v2 * v2 + v1 * v1 < 400 && !v118 ) + } + + if ( v2 * v2 + v1 * v1 < 400 && !partyAtHighSlope ) { *(float *)&v128 = 0.0; v2 = 0; @@ -3720,8 +3693,8 @@ &v130, &v110, 0); - v127 = (BSPModel *)GetTerrainHeightsAroundParty(_angle_x, v117); - v42 = GetTerrainHeightsAroundParty(v116, _angle_y); + v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, v117); + v42 = IsTerrainSlopeTooHigh(v116, _angle_y); v107 = 0; v118 = v42; if ( !v97 && !v110 && !v108 ) @@ -3746,7 +3719,7 @@ &v130, &v108, 0); - if ( GetTerrainHeightsAroundParty(_angle_x, _angle_y) && (signed int)v127 <= v123 ) + if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= v123 ) { v43 = 1; LABEL_197: @@ -3772,15 +3745,15 @@ v117 = _angle_y; v45 = stru_721530.uFaceID; v123 = v40; - if ( (stru_721530.uFaceID & 7) == 3 ) - { - if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0 - && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) ) - pParty->pPartyBuffs[11].Reset(); + if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) + { + if (pParty->Invisible()) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); + viewparams->bRedrawGameUI = 1; goto LABEL_234; } - if ( (stru_721530.uFaceID & 7) == 5 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) { v56 = sub_452A9E(v2 * v2 + v128 * v128); v118 = v56; @@ -3801,7 +3774,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == 6 ) + if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) { pParty->bFlying = 0; v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; @@ -9430,77 +9403,95 @@ //----- (004823F4) -------------------------------------------------------- -bool __fastcall GetTerrainHeightsAroundParty(int a1, int a2) -{ - unsigned int v2; // ebx@1 - unsigned int v3; // edi@1 - int v4; // eax@1 - int v6; // esi@5 - int v7; // ecx@6 - int v8; // edx@6 - int v9; // eax@6 - int v10; // esi@10 - int v11; // [sp+14h] [bp-8h]@1 - int v12; // [sp+18h] [bp-4h]@1 - - v12 = a1; - v11 = a2; - v2 = WorldPosToGridCellX(a1); - v3 = WorldPosToGridCellZ(v11) - 1; - dword_76D568_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2); - dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1); - dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2 + 1); - dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v2); - dword_76D558_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3); - dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3); - dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1); - dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v3 + 1); - dword_76D548_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2, v3); - dword_76D54C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3); - dword_76D550_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v2 + 1, v3 + 1); - v4 = pOutdoor->DoGetHeightOnTerrain(v2, v3 + 1); - dword_76D554_terrain_cell_world_pos_around_party_y = v4; - if ( dword_76D548_terrain_cell_world_pos_around_party_y == dword_76D54C_terrain_cell_world_pos_around_party_y - && dword_76D54C_terrain_cell_world_pos_around_party_y == dword_76D550_terrain_cell_world_pos_around_party_y - && dword_76D550_terrain_cell_world_pos_around_party_y == v4 ) - return 0; - v6 = abs(v12 - dword_76D568_terrain_cell_world_pos_around_party_x); - if ( abs(dword_76D558_terrain_cell_world_pos_around_party_z - v11) >= v6 ) - { - v7 = dword_76D554_terrain_cell_world_pos_around_party_y; - v8 = dword_76D550_terrain_cell_world_pos_around_party_y; - v9 = dword_76D548_terrain_cell_world_pos_around_party_y; - } - else - { - v7 = dword_76D54C_terrain_cell_world_pos_around_party_y; - v8 = dword_76D548_terrain_cell_world_pos_around_party_y; - v9 = dword_76D550_terrain_cell_world_pos_around_party_y; - } - if ( v7 >= v8 ) - { - v10 = v8; - if ( v8 < v9 ) +bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) +{ + //unsigned int v2; // ebx@1 + //unsigned int v3; // edi@1 + //int v4; // eax@1 + //int v6; // esi@5 + //int v7; // ecx@6 + //int v8; // edx@6 + //int v9; // eax@6 + //int v10; // esi@10 + //int v11; // [sp+14h] [bp-8h]@1 + //int v12; // [sp+18h] [bp-4h]@1 + + //v12 = a1; + //v11 = a2; + auto grid_x = WorldPosToGridCellX(pos_x); + auto grid_z = WorldPosToGridCellZ(pos_z) - 1; + + auto party_grid_x1 = GridCellToWorldPosX(grid_x); + //dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); + //dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); + //dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x); + auto party_grid_z1 = GridCellToWorldPosZ(grid_z); + //dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z); + //dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); + //dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); + auto party_x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); + auto party_x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); + auto party_x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); + auto party_x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); + //dword_76D554_terrain_cell_world_pos_around_party_y = v4; + if (party_x1z1_y == party_x2z1_y && + party_x2z1_y == party_x2z2_y && + party_x2z2_y == party_x1z2_y ) + return false; + + auto dx = abs(pos_x - party_grid_x1), + dz = abs(party_grid_z1 - pos_z); + + int y1, y2, y3; + if (dz >= dx) + { + y1 = party_x1z2_y; // lower-left triangle + y2 = party_x2z2_y; // y3 | \ + y3 = party_x1z1_y; // | \ + /* | \ + |______ \ + y1 y2 */ + } + else + { + y1 = party_x2z1_y; // upper-right + y2 = party_x1z1_y; // y2_______ y1 + y3 = party_x2z2_y; // \ | + /* \ | + \ | + y3 */ + } + + int y_min = min(y1, min(y2, y3)), + y_max = max(y1, max(y2, y3)); + return y_max - y_min > 512; + + /*if ( y1 >= y2 ) + { + y_min = y2; + if ( y2 < y3 ) goto LABEL_13; LABEL_12: - v10 = v9; + y_min = y3; goto LABEL_13; } - if ( v7 >= v9 ) + else if ( y1 >= y3 ) goto LABEL_12; - v10 = v7; + else + y_min = y1; + LABEL_13: - if ( v7 <= v8 ) - { - if ( v8 > v9 ) - v9 = v8; - } - else - { - if ( v7 > v9 ) - v9 = v7; - } - return v9 - v10 > 512; + if ( y1 <= y2 ) + { + if ( y2 > y3 ) + y3 = y2; + } + else + { + if ( y1 > y3 ) + y3 = y1; + } + return y3 - v10 > 512;*/ } @@ -12928,7 +12919,7 @@ v37 = v21 / x; LODWORD(v31) = v12->scale; v37 = v21 / x; - v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v21 / x) >> 16; + v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(SLODWORD(v31) * v21 / x) >> 16; v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16; } else @@ -12945,7 +12936,7 @@ v37 = v20 / x; LODWORD(v31) = v12->scale; v37 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16; - v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16; + v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16; v31 = v15->fov_y; v25 = v31 + 6.7553994e15; LODWORD(v20) = 0; @@ -12954,7 +12945,7 @@ v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; } HIWORD(v22) = HIWORD(x); - v15->field_4 = v37; + v15->_screenspace_y_scaler_packedfloat = v37; v15->field_1E = v30; v15->some_x = a1; v15->some_y = a2; @@ -13113,7 +13104,7 @@ LODWORD(v19) = pBLVRenderParams->field_40 << 16; HIDWORD(v19) = pBLVRenderParams->field_40 >> 16; v20 = v19 / x; - v3->field_0 = (unsigned __int64)(v24->scale * v19 / x) >> 16; + v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16; v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16; } else @@ -13121,11 +13112,11 @@ v3->fov_x = pGame->pIndoorCameraD3D->fov_x; v3->fov_y = pGame->pIndoorCameraD3D->fov_y; v18 = (int)floorf(v3->fov_x + 0.5f) / x; - v3->field_0 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16; + v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * (__int64)v18) >> 16; v31 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16; } HIWORD(v21) = HIWORD(x); - v3->field_4 = v31; + v3->_screenspace_y_scaler_packedfloat = v31; v3->field_1E = v34; v3->some_x = a1; v3->some_y = a2; @@ -13302,13 +13293,13 @@ //----- (0044100D) -------------------------------------------------------- bool __cdecl sub_44100D() { - return pCurrentScreen == 4 - || pCurrentScreen == 7 - || pCurrentScreen > 12 - && (pCurrentScreen <= 14 - || pCurrentScreen > 16 - && (pCurrentScreen <= 18 - || pCurrentScreen == 23)); + return pCurrentScreen == SCREEN_NPC_DIALOGUE + || pCurrentScreen == SCREEN_CHARACTERS + || pCurrentScreen > SCREEN_LOADGAME + && (pCurrentScreen <= SCREEN_E + || pCurrentScreen > SCREEN_VIDEO + && (pCurrentScreen <= SCREEN_INPUT_BLV + || pCurrentScreen == SCREEN_CASTING)); } // 4E28F8: using guessed type int pCurrentScreen; @@ -13321,16 +13312,16 @@ IconFrame *v3; // eax@19 if ( !pCurrentScreen - || pCurrentScreen == 1 - || pCurrentScreen == 2 - || pCurrentScreen == 5 - || pCurrentScreen == 8 - || pCurrentScreen == 10 - || pCurrentScreen == 11 - || pCurrentScreen == 12 - || pCurrentScreen == 15 - || pCurrentScreen == 3 - || pCurrentScreen == 19 ) + || pCurrentScreen == SCREEN_MENU + || pCurrentScreen == SCREEN_OPTIONS + || pCurrentScreen == SCREEN_REST + || pCurrentScreen == SCREEN_SPELL_BOOK + || pCurrentScreen == SCREEN_CHEST + || pCurrentScreen == SCREEN_SAVEGAME + || pCurrentScreen == SCREEN_LOADGAME + || pCurrentScreen == SCREEN_F + || pCurrentScreen == SCREEN_BOOKS + || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) { if ( SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) >= 0 && (SHIDWORD(pParty->pPartyBuffs[16].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[16].uExpireTime)) ) @@ -13421,7 +13412,7 @@ } while ( v1 < 14 ); if ( !pCurrentScreen - || pCurrentScreen == 4 ) + || pCurrentScreen == SCREEN_NPC_DIALOGUE ) { if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 ) { @@ -13536,8 +13527,8 @@ v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16; v10.uScreenSpaceX = *((short *)v3 - 2); v10.uScreenSpaceY = *((short *)v3 - 1); - v10.field_10 = v13; - v10.field_14 = v13; + v10._screenspace_x_scaler_packedfloat = v13; + v10._screenspace_y_scaler_packedfloat = v13; v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1); v8 = *((short *)v3 - 5); v10.sZValue = 0; @@ -13562,30 +13553,21 @@ //----- (00441D38) -------------------------------------------------------- -void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags) +void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap) { int uHeight; // ebx@6 - //unsigned int v9; // edx@9 - //unsigned int v10; // ebx@10 __int16 v11; // cx@11 - //BLVFace *v12; // ecx@17 - //unsigned int v13; // ecx@21 unsigned int v14; // ebx@23 int v15; // eax@23 - //unsigned int *v16; // ecx@28 __int16 v17; // di@30 double v18; // st7@30 float v19; // ST38_4@30 double v20; // st7@30 double v21; // st6@30 double v22; // st5@33 - //unsigned __int16 *v26; // edx@37 signed int v27; // eax@37 unsigned __int16 *v28; // ecx@37 signed int v29; // edi@40 - //int v30; // eax@42 - //unsigned __int16 *v31; // ebx@43 - //signed int v32; // edi@46 signed int v33; // ebx@50 unsigned int v34; // eax@50 signed int v35; // ecx@50 @@ -13603,7 +13585,6 @@ int v47; // eax@108 unsigned int v48; // ebx@114 unsigned int v49; // ST64_4@114 - //double v50; // ST20_8@117 unsigned int v51; // [sp-10h] [bp-64h]@79 unsigned int v52; // [sp-10h] [bp-64h]@100 unsigned int v53; // [sp-Ch] [bp-60h]@79 @@ -13615,9 +13596,7 @@ unsigned __int16 v59; // [sp-4h] [bp-58h]@100 unsigned __int16 v60; // [sp+10h] [bp-44h]@66 unsigned int v61; // [sp+10h] [bp-44h]@85 - //unsigned __int16 *v62; // [sp+14h] [bp-40h]@30 unsigned int v63; // [sp+14h] [bp-40h]@85 - //int v64; // [sp+18h] [bp-3Ch]@39 unsigned int v65; // [sp+18h] [bp-3Ch]@85 unsigned int lPitch; // [sp+20h] [bp-34h]@1 unsigned int lPitcha; // [sp+20h] [bp-34h]@23 @@ -13627,34 +13606,24 @@ unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1 signed int uBluea; // [sp+28h] [bp-2Ch]@37 int v73; // [sp+2Ch] [bp-28h]@30 - //unsigned __int8 *v74; // [sp+30h] [bp-24h]@30 int v76; // [sp+34h] [bp-20h]@91 int v77; // [sp+34h] [bp-20h]@108 - //signed int v78; // [sp+38h] [bp-1Ch]@37 int v79; // [sp+38h] [bp-1Ch]@72 - //signed int a2b; // [sp+40h] [bp-14h]@41 char *a2c; // [sp+40h] [bp-14h]@68 - //int a3a; // [sp+44h] [bp-10h]@40 signed int uCenterY; // [sp+48h] [bp-Ch]@1 signed int uCenterX; // [sp+4Ch] [bp-8h]@1 - //signed int uZb; // [sp+5Ch] [bp+8h]@27 signed int uWidth; // [sp+5Ch] [bp+8h]@30 - //signed int uZd; // [sp+5Ch] [bp+8h]@45 signed int uZe; // [sp+5Ch] [bp+8h]@67 signed int uZf; // [sp+5Ch] [bp+8h]@85 signed int uZg; // [sp+5Ch] [bp+8h]@105 unsigned int uWa; // [sp+60h] [bp+Ch]@23 float uWb; // [sp+60h] [bp+Ch]@30 - //unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37 unsigned int uWd; // [sp+60h] [bp+Ch]@95 float uZooma; // [sp+64h] [bp+10h]@117 - //signed int flagsa; // [sp+68h] [bp+14h]@42 unsigned int flagsb; // [sp+68h] [bp+14h]@66 Actor *flagsc; // [sp+68h] [bp+14h]@86 unsigned int flagsd; // [sp+68h] [bp+14h]@105 - //a3 = uY; - //a2 = uX; uCenterX = (uX + uZ) / 2; uCenterY = (uY + uW) / 2; lPitch = pRenderer->uTargetSurfacePitch; @@ -13710,78 +13679,46 @@ default: assert(false); } -//LABEL_37: - //v23 = v20 * 65536.0; - //v24 = v23 + 6.7553994e15; + assert(sizeof(pOdmMinimap) == 137 * 117 * sizeof(short)); + v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24); - //uWe = uWb * 65536.0; - //v25 = uWe + 6.7553994e15; - //v78 = v70; uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25); v27 = uBluea >> 16; v28 = &pRenderer->pTargetSurface[uX + uY * lPitch]; - if ( flags && pMapLod0) - { - auto pMinimap = (unsigned __int16 *)_56EFD8_minimap; - //if ( v74 ) - //{ + if (pMapLod0 && bRedrawOdmMinimap) + { + assert(uWidth == 137 && uHeight == 117); + //auto pMinimap = (unsigned __int16 *)pOdmMinimap; + auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; - //if ( uHeight > 0 ) - //{ - //a3a = uHeight; + v29 = v70 >> 16; - //do + for (int y = 0; y < uHeight; ++y) { - //a2b = 0; - //if ( uWidth > 0 ) - //{ auto pMapLod0Line = &pMapLod0[v27 * mapWidth]; - //flagsa = uWidth; - //a2b = uWidth; for (int x = 0; x < uWidth; ++x) - //do - { - //v31 = uWc; - //++uWc; - *pMinimap++ = pPal[pMapLod0Line[v29]]; - //v78 += v73; + { + //*pMinimap++ = pPal[pMapLod0Line[v29]]; + pOdmMinimap[y][x] = pPal[pMapLod0Line[v29]]; v29 = (v70 + x * v73) >> 16; - //--flagsa; - } - //while ( flagsa ); - //} - //v78 = v70; + } + v29 = v70 >> 16; v28 += 137 - uWidth; uBluea += v73; v27 = uBluea >> 16; - //--a3a; - } - //while ( a3a ); - //} - //} - } - - auto pMinimap = (unsigned __int16 *)_56EFD8_minimap; - //uZd = 117; - //do + } + } + for (int y = 0; y < 117; ++y) { - //v32 = 137; - //do for (int x = 0; x < 137; ++x) { - *v28++ = *pMinimap++; - //++v28; - //++v26; - //--v32; - } - //while ( v32 ); + *v28++ = pOdmMinimap[y][x]; + } v28 += lPitch - 137; - //--uZd; - } - //while ( uZd ); + } uNumBlueFacesInBLVMinimap = 0; } else @@ -13919,7 +13856,7 @@ v36 = 255; flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu); v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0); - if ( bWizardEyeActive ) + if ( bWizardEyeActive = true) { uZe = 0; //for (uint i = 0; i < uNumLayingItems; ++i) @@ -16342,7 +16279,7 @@ do { v30 = *v55; - if ( *v55 == 5 || v30 == 11 || v30 == 19 || (v31 = *((int *)v55 + 159)) != 0 && (v31 & 7) == 4 ) + if ( *v55 == Dead || v30 == Removed || v30 == Disabled || (v31 = *((int *)v55 + 159)) != 0 && (v31 & 7) == OBJECT_Player) ++pInString; v55 += 418; --*(int *)v54; @@ -17997,7 +17934,7 @@ pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((_5C3420_pDecoration == 0) + 1); sub_44987B(v99, 0); v133 = 1; - if ( pCurrentScreen == 13 ) + if ( pCurrentScreen == SCREEN_HOUSE ) { if ( uGameState == 2 ) { @@ -18010,7 +17947,7 @@ ptr_507BC0 = 0; if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; array_5913D8[6] = 0; pDialogueWindow->Release(); @@ -19500,7 +19437,7 @@ dword_5B65C0 = 0; pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; sub_44987B("nwc.blv", 0); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; result = 1; } return result; @@ -20442,12 +20379,12 @@ v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; a2 = *v20; v76 = a2 & 7; - if ( (a2 & 7) == 3 ) + if ( (a2 & 7) == OBJECT_Actor) v80 = 0.5; else v80 = 1.0; v22 = v21->uAIState; - if ( v22 == 4 || v22 == 5 || v22 == 11 || v22 == 19 || v22 == 17 ) + if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) goto LABEL_254; if ( !v21->sCurrentHP ) Actor::Die(uActorID); @@ -20965,7 +20902,7 @@ v2 = this->pQueue; do { - if ( (v2->uPackedID & 7) == 3 ) + if ( (v2->uPackedID & 7) == OBJECT_Actor ) { v3 = &pActors[v2->uPackedID >> 3]; v4 = &pActors[v2->uPackedID >> 3]; @@ -20977,7 +20914,7 @@ LOBYTE(v3->uAttributes) &= 0x7Fu; } } - if ( (v2->uPackedID & 7) == 4 ) + if ( (v2->uPackedID & 7) == OBJECT_Player) { v5 = &pParty->pPlayers[v2->uPackedID >> 3]; if ( v5->pConditions[14] @@ -21013,7 +20950,7 @@ v10 = v7->field_4; if ( v9 < v10 || v9 == v10 - && ((v11 = v8->uPackedID & 7, v11 == 4) && (v7->uPackedID & 7) == 3 + && ((v11 = v8->uPackedID & 7, v11 == OBJECT_Player) && (v7->uPackedID & 7) == OBJECT_Actor || v11 == (v7->uPackedID & 7) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) { v12 = v7->uPackedID; @@ -21042,7 +20979,7 @@ } v1->uActorQueueSize = v19; result = v1->pQueue[0].uPackedID; - if ( (v1->pQueue[0].uPackedID & 7) == 4 ) + if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) { result = (result >> 3) + 1; uActiveCharacter = result; @@ -21059,7 +20996,7 @@ v17 = v1->pQueue; do { - if ( (v17->uPackedID & 7) == 4 ) + if ( (v17->uPackedID & 7) == OBJECT_Player) pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); ++v22; ++v17;
--- a/mm7_4.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_4.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -977,118 +977,80 @@ return dword_720F20[v22]; } + +//not sure if right- or left-handed coordinate space assumed, so this could be normal of inverse normal +// for a right-handed system, that would be an inverse normal //----- (0046DCC8) -------------------------------------------------------- -signed __int64 __fastcall _46DCC8_get_gravity_direction_outdoor(int a1, int a2, Vec3_int_ *a3) -{ - int v3; // ebx@1 - int v4; // ST4C_4@1 - unsigned int v5; // ST54_4@1 - unsigned int v6; // edi@1 - unsigned int v7; // ST50_4@1 - int v8; // edi@1 - int v9; // esi@1 - int v10; // ebx@1 - int v11; // ecx@2 - int v12; // eax@2 - int v13; // edx@2 - int v14; // ebx@2 - double v15; // st7@4 - double v16; // st6@4 - double v17; // st5@4 - float v18; // ST44_4@4 - float v19; // ST54_4@4 - double v20; // st4@4 - double v21; // st5@4 - float v22; // ST44_4@6 - double v23; // st7@4 - double v24; // st7@6 - signed __int64 result; // qax@6 - int v26; // [sp+14h] [bp-44h]@1 - int v27; // [sp+18h] [bp-40h]@1 - int v28; // [sp+20h] [bp-38h]@1 - int v29; // [sp+24h] [bp-34h]@1 - int v30; // [sp+28h] [bp-30h]@1 - int v31; // [sp+2Ch] [bp-2Ch]@1 - int v32; // [sp+30h] [bp-28h]@1 - int v33; // [sp+34h] [bp-24h]@1 - int v34; // [sp+38h] [bp-20h]@1 - int v35; // [sp+3Ch] [bp-1Ch]@1 - int v36; // [sp+40h] [bp-18h]@1 - int v37; // [sp+4Ch] [bp-Ch]@2 - float v38; // [sp+4Ch] [bp-Ch]@4 - int v39; // [sp+50h] [bp-8h]@2 - float v40; // [sp+50h] [bp-8h]@4 - int v41; // [sp+54h] [bp-4h]@2 - - v3 = a1; - v4 = a2; - v5 = WorldPosToGridCellX(a1); - v6 = WorldPosToGridCellZ(v4) - 1; - v33 = GridCellToWorldPosX(v5); - v34 = GridCellToWorldPosX(v5 + 1); - v35 = GridCellToWorldPosX(v5 + 1); - v36 = GridCellToWorldPosX(v5); - v29 = GridCellToWorldPosZ(v6); - v30 = GridCellToWorldPosZ(v6); - v7 = v6 + 1; - v31 = GridCellToWorldPosZ(v6 + 1); - v32 = GridCellToWorldPosZ(v6 + 1); - v26 = pOutdoor->DoGetHeightOnTerrain(v5, v6); - v27 = pOutdoor->DoGetHeightOnTerrain(v5 + 1, v6); - v8 = pOutdoor->DoGetHeightOnTerrain(v5 + 1, v6 + 1); - v28 = pOutdoor->DoGetHeightOnTerrain(v5, v7); - v9 = v29; - v10 = abs(v3 - v33); - if ( abs(v29 - v4) >= v10 ) - { - v11 = v33; - v37 = v28; - v39 = v36; - v12 = v35; - v41 = v32; - v13 = v31; - v14 = v8; - v8 = v26; - } - else - { - v11 = v35; - v41 = v30; - v39 = v34; - v12 = v33; - v13 = v29; - v9 = v31; - v37 = v27; - v14 = v26; - } - v15 = (double)(v12 - v39); - v16 = (double)(v13 - v41); - v17 = (double)(v14 - v37); - v18 = (double)(v11 - v39); - v19 = (double)(v9 - v41); - v20 = (double)(v8 - v37); - v38 = v20 * v16 - v19 * v17; - v40 = v18 * v17 - v20 * v15; - v21 = v19 * v15 - v18 * v16; - v23 = sqrt(v21 * v21 + v40 * v40 + v38 * v38); - if ( v23 == 0.0 ) - { - a3->y = 0; - a3->x = 0; - a3->z = 65536; - } - v24 = 1.0 / v23; - a3->x = (signed __int64)(v24 * v38 * 65536.0); - a3->y = (signed __int64)(v24 * v40 * 65536.0); - v22 = v21; - result = (signed __int64)(v24 * v22 * 65536.0); - a3->z = result; - return result; -} -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); -// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); -// 47F469: using guessed type int __stdcall GridCellToWorldPosX(int); -// 47F476: using guessed type int __stdcall GridCellToWorldPosZ(int); +void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out) +{ + auto grid_x = WorldPosToGridCellX(pos_x); + auto grid_z = WorldPosToGridCellZ(pos_z) - 1; + + auto grid_pos_x1 = GridCellToWorldPosX(grid_x); + auto grid_pos_x2 = GridCellToWorldPosX(grid_x + 1); + auto grid_pos_z1 = GridCellToWorldPosZ(grid_z); + auto grid_pos_z2 = GridCellToWorldPosZ(grid_z + 1); + + auto x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); + auto x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); + auto x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); + auto x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); + + float side1_dx, side1_dy, side1_dz, + side2_dx, side2_dy, side2_dz; + + auto dx = abs(pos_x - grid_pos_x1), + dz = abs(grid_pos_z1 - pos_z); + if (dz >= dx) + { + side1_dy = (double)(x1z1_y - x1z2_y); + side2_dy = (double)(x2z2_y - x1z2_y); + side2_dx = (double)(grid_pos_x2 - grid_pos_x1); + side1_dx = (double)(grid_pos_x1 - grid_pos_x1); + side2_dz = (double)(grid_pos_z2 - grid_pos_z2); // bug? z2 - z2 + side1_dz = (double)(grid_pos_z2 - grid_pos_z2); // z1 - z2 + Log::Warning(L"%s %s %u\n", __FILE__, __FUNCTION__, __LINE__); + /* |\ + side1 | \ + |____\ + side 2 */ + } + else + { + side1_dy = (double)(x2z2_y - x2z1_y); + side2_dy = (double)(x1z1_y - x2z1_y); + side2_dx = (double)(grid_pos_x1 - grid_pos_x2); + side1_dx = (double)(grid_pos_x2 - grid_pos_x2); + side2_dz = (double)(grid_pos_z1 - grid_pos_z1); + side1_dz = (double)(grid_pos_z2 - grid_pos_z1); + + /* side 2 + _____ + \ | + \ | side 1 + \| */ + } + + float nx = side1_dy * side2_dz - side1_dz * side2_dy; + float ny = side1_dx * side2_dy - side1_dy * side2_dx; + float nz = side1_dz * side2_dx - side1_dx * side2_dz; + + float mag = sqrt(nx * nx + ny * ny + nz * nz); + if (fabsf(mag) < 1e-6f) + { + out->y = 0; + out->x = 0; + out->z = 65536; + } + else + { + float invmag = 1.0 / mag; + out->x = invmag * nx * 65536.0; + out->y = invmag * ny * 65536.0; + out->z = invmag * nz * 65536.0; + } +} + //----- (0046DEF2) -------------------------------------------------------- unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID) @@ -1303,7 +1265,7 @@ do { v4 = *v3; - if ( (v4 & 7) == 5 ) + if ( (v4 & 7) == OBJECT_Decoration) { v5 = &pLevelDecorations[(signed __int16)v4 >> 3]; if ( !(v5->field_2 & 0x20) ) @@ -3097,7 +3059,7 @@ for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) { - if (pNPCStats->pNewNPCData[i].uFlags & 0x80) + if (pNPCStats->pNewNPCData[i].uFlags == 128) { if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName)) { @@ -3273,7 +3235,7 @@ { if ( pTurnEngine->field_4 != 1 ) { - if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 ) + if ( (pTurnEngine->pQueue[0].uPackedID & 7) == OBJECT_Player) { //v14 = 0; if ( pTurnEngine->uActorQueueSize > 0 ) @@ -3283,7 +3245,7 @@ { auto pElem = pTurnEngine->pQueue + i; - if ( (pElem->uPackedID & 7) != 4 ) + if ( (pElem->uPackedID & 7) != OBJECT_Player) break; v16 = dword_5079D0; if ( pParty->uFlags & 0x10 ) @@ -4216,7 +4178,7 @@ v51 = v65; if ( v65 ) goto LABEL_135; - if ( pCurrentScreen != 5 ) + if ( pCurrentScreen != SCREEN_REST ) { v52 = (signed int)&pPlayers[1]; while ( 1 ) @@ -4232,13 +4194,13 @@ *(int *)(v53 + 20) = 0; v51 = 1; LABEL_135: - if ( pCurrentScreen != 5 + if ( pCurrentScreen != SCREEN_REST && (!v51 || dword_5C35C0) ) uGameState = 8; } if ( uActiveCharacter ) { - if ( pCurrentScreen != 5 ) + if ( pCurrentScreen != SCREEN_REST ) { v54 = pPlayers[uActiveCharacter]; if ( v54->pConditions[2] @@ -5743,7 +5705,7 @@ ++pIcons_LOD->uTexturePacksCount; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - pCurrentScreen = 21;// + pCurrentScreen = SCREEN_PARTY_CREATION; uPlayerCreationUI_ArrowAnim = 0; uPlayerCreationUI_SkySliderPos = 0; uPlayerCreationUI_SelectedCharacter = 0; @@ -6245,7 +6207,7 @@ free(pString); pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr); pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, 0x71u, 0, 0x1Bu, "", 0); - pCurrentScreen = 9; // Credits + pCurrentScreen = SCREEN_CREATORS; SetCurrentMenuID(MENU_Credits); do { @@ -6274,7 +6236,7 @@ if ( a5 >= (signed __int16)pTexture2.uHeight ) SetCurrentMenuID(MENU_MAIN); pRenderer->Present(); - pCurrentScreen = 0;//Ritor1: temporarily, must be corrected GUI_MainMenuMessageProc() + pCurrentScreen = SCREEN_GAME;//Ritor1: temporarily, must be corrected GUI_MainMenuMessageProc() GUI_MainMenuMessageProc(); } } @@ -9708,7 +9670,8 @@ } Party::TakeGold(v21); } - LOBYTE(v2->uFlags) |= 0x80u; + //LOBYTE(v2->uFlags) |= 0x80u; + v2->uFlags = 128; pParty->field_709 = 0; sub_44A56A(); if ( pParty->pHirelings[0].pName ) @@ -14728,7 +14691,7 @@ LODWORD(v20) = pBLVRenderParams->field_40 << 16; HIDWORD(v20) = pBLVRenderParams->field_40 >> 16; v21 = v20 / x; - v0->field_0 = (unsigned __int64)(v10->scale * v20 / x) >> 16; + v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16; a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16; } else @@ -14742,15 +14705,15 @@ LODWORD(v18) = 0; HIDWORD(v18) = floorf(v16 + 0.5f); v19 = v18 / x; - v0->field_0 = (unsigned __int64)(v10->scale * v18 / x) >> 16; + v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v18 / x) >> 16; a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; } - v0->field_4 = a5a; + v0->_screenspace_y_scaler_packedfloat = a5a; if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 ) { if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 ) { - a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->field_4) >> 16; + a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; goto LABEL_43; } } @@ -14759,12 +14722,12 @@ v22 = p->pActorBuffs[3].uPower; if ( v22 ) { - v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16; + v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->_screenspace_x_scaler_packedfloat) >> 16; v24 = p->pActorBuffs[3].uPower; - v0->field_0 = v23; - a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16; + v0->_screenspace_x_scaler_packedfloat = v23; + a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; LABEL_43: - v0->field_4 = a5b; + v0->_screenspace_y_scaler_packedfloat = a5b; goto LABEL_44; } }
--- a/mm7_5.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_5.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -332,8 +332,8 @@ //goto _actor_init_dlg; pActor->InitializeDialogue(v0); continue; - case UIMSG_Quit|0x2: - case 0x87: + case UIMSG_86: + case UIMSG_87: if ( bNoNPCHiring != 1 && !pCurrentScreen ) { if ( pMessageQueue_50CBD0->uNumMessages ) @@ -382,19 +382,19 @@ } } continue; - case 0x51: + case UIMSG_51: sub_4BDB56_buy_skill____(); continue; case UIMSG_AF: sub_4B2001(uMessageParam); continue; - case 0x195: + case UIMSG_195: sub_4BCACC_bounties(uMessageParam); continue; - case 0x88: + case UIMSG_88: sub_4BC49B(uMessageParam); continue; - case 0x19A: + case UIMSG_19A: _4B4224_UpdateNPCTopics(uMessageParam); continue; case UIMSG_StartNewGame: @@ -407,7 +407,7 @@ pGUIWindow_CurrentMenu->Release(); uGameState = 4; LABEL_188: - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; } else @@ -425,7 +425,7 @@ if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 12; + pCurrentScreen = SCREEN_LOADGAME; GameUI_DrawLoadMenu(v0); continue; case UIMSG_Quit: @@ -436,7 +436,7 @@ if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; if ( !uMessageParam ) pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0); @@ -451,11 +451,11 @@ //goto _release_tex_and_continue; stru_506E40.Release(); continue; - case 0x80: + case UIMSG_80: pIcons_LOD->_40F9C5(); pIcons_LOD->_4114F2(); pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 2; + pCurrentScreen = SCREEN_OPTIONS; v162 = 0; v148 = 0; pWindowType = (WindowType)8; @@ -517,7 +517,7 @@ case UIMSG_SelectLoadSlot: if ( pGUIWindow_CurrentMenu->field_40 == v0 ) pKeyActionMap->_459ED1(0); - if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != pSaveListPosition + uMessageParam ) + if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pSaveListPosition + uMessageParam ) { v10 = pSaveListPosition + uMessageParam; if ( dword_6BE138 == pSaveListPosition + uMessageParam ) @@ -572,9 +572,9 @@ //goto _release_tex_and_continue; stru_506E40.Release(); continue; - case UIMSG_StartNewGame|0x2: + case UIMSG_Game_OpenSaveGameDialog: pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 11; + pCurrentScreen = SCREEN_SAVEGAME; GameUI_DrawSaveMenu(); continue; case UIMSG_Game_OpenOptionsDialog: @@ -582,7 +582,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); viewparams->field_48 = v0; - pCurrentScreen = 2; + pCurrentScreen = SCREEN_OPTIONS; uTextureID_507C60 = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE); uTextureID_507C6C = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE); uTextureID_507C68 = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE); @@ -670,7 +670,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); viewparams->field_48 = 1; - pCurrentScreen = 26; + pCurrentScreen = SCREEN_KEYBOARD_OPTIONS; uTextureID_507BF4 = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE); uTextureID_507BF8 = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE); uTextureID_507BFC = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE); @@ -707,7 +707,7 @@ continue; //default: //continue; - case UIMSG_ResetKeyMapping|0x1: + case UIMSG_1A3: if ( dword_506E68 != -1 ) goto LABEL_623; v14 = uMessageParam; @@ -756,7 +756,7 @@ case 0x1A0: dword_506F08 = v0; continue; - case UIMSG_StartNPCDialogue|0x100: + case UIMSG_1A1: dword_506F08 = 2; continue; case UIMSG_OpenVideoOptions: @@ -764,7 +764,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); viewparams->field_48 = v0; - pCurrentScreen = 28; + pCurrentScreen = SCREEN_VIDEO_OPTIONS; uTextureID_507C10 = pIcons_LOD->LoadTexture("optvid", TEXTURE_16BIT_PALETTE); uTextureID_507C14 = pIcons_LOD->LoadTexture("opvdH-bs", TEXTURE_16BIT_PALETTE); uTextureID_507C18 = pIcons_LOD->LoadTexture("opvdH-cl", TEXTURE_16BIT_PALETTE); @@ -817,11 +817,11 @@ } } continue; - case UIMSG_ToggleTint|0x1: + case UIMSG_1A9: if ( uMessageParam == 4 ) { - --uGammaPos; - if ( (uGammaPos & 0x80000000u) != 0 ) + //--uGammaPos; + if ( (uGammaPos -- -1) < 0 ) { uGammaPos = 0; //goto LABEL_128; @@ -1117,7 +1117,7 @@ } ModalWindow(pNPCTopics[453].pText, 0); continue; - case UIMSG_SkillUp|0x2: + case UIMSG_7B: pGUIWindow_CurrentMenu->Release(); pEventTimer->Resume(); goto LABEL_188; @@ -1192,9 +1192,9 @@ back_to_game(); if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen > 15 ) - { - if ( pCurrentScreen >= 17 && (pCurrentScreen <= 18 || pCurrentScreen == 104) ) + if ( pCurrentScreen > SCREEN_F ) + { + if ( pCurrentScreen >= SCREEN_CHANGE_LOCATION && (pCurrentScreen <= SCREEN_INPUT_BLV || pCurrentScreen == SCREEN_QUICK_REFERENCE) ) { //LABEL_229: if ( dword_50CDC8 ) @@ -1207,7 +1207,7 @@ } else { - if ( pCurrentScreen >= 14 || pCurrentScreen == 4 || pCurrentScreen == 10 ) + if ( pCurrentScreen >= SCREEN_E || pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_CHEST ) { //goto LABEL_229; if ( dword_50CDC8 ) @@ -1217,7 +1217,7 @@ uMessageParam = v0; goto LABEL_232; } - if ( pCurrentScreen == 13 && !dword_50CDC8 && !dword_5C35C8 ) + if ( pCurrentScreen == SCREEN_HOUSE && !dword_50CDC8 && !dword_5C35C8 ) { CloseWindowBackground(); dword_5C35C8 = 0; @@ -1234,18 +1234,18 @@ viewparams->field_48 = v0; if ( pCurrentScreen ) { - if ( pCurrentScreen > 103 ) + if ( pCurrentScreen > SCREEN_67 ) { - if ( pCurrentScreen == 104 ) + if ( pCurrentScreen == SCREEN_QUICK_REFERENCE ) goto LABEL_321; } else { - if ( pCurrentScreen < 100 ) + if ( pCurrentScreen < SCREEN_64 ) { switch ( pCurrentScreen ) { - case 23: + case SCREEN_CASTING: pIcons_LOD->_4114F2(); if ( some_active_character ) { @@ -1267,7 +1267,7 @@ //goto LABEL_322; if ( pGUIWindow_Settings ) { - if ( pCurrentScreen == 7 ) + if ( pCurrentScreen == SCREEN_CHARACTERS ) { pMouse->SetCursorBitmap("MICON2"); } @@ -1288,11 +1288,11 @@ ptr_507BC0 = 0; pGUIWindow_CurrentMenu = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pIcons_LOD->_4355F7(); continue; - case 3: + case SCREEN_BOOKS: pBooksWindow->Release(); //crt_deconstruct_ptr_6A0118(); pBooksWindow = 0; @@ -1300,7 +1300,7 @@ //goto LABEL_322; if ( pGUIWindow_Settings ) { - if ( pCurrentScreen == 7 ) + if ( pCurrentScreen == SCREEN_CHARACTERS ) { pMouse->SetCursorBitmap("MICON2"); } @@ -1321,39 +1321,39 @@ ptr_507BC0 = 0; pGUIWindow_CurrentMenu = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pIcons_LOD->_4355F7(); continue; - case 11: - case 12: + case SCREEN_SAVEGAME: + case SCREEN_LOADGAME: pIcons_LOD->_4114F2(); //crt_deconstruct_ptr_6A0118(); //goto LABEL_291; stru_506E40.Release(); break; - case 15: - pCurrentScreen = 10; + case SCREEN_F: + pCurrentScreen = SCREEN_CHEST; continue; - case 10: + case SCREEN_CHEST: pWindow2 = pChestWindow; //goto LABEL_249; pWindow2->Release(); pIcons_LOD->_4114F2(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pEventTimer->Resume(); continue; - case 25: + case SCREEN_19: pWindow2 = ptr_507BC8; //LABEL_249: pWindow2->Release(); pIcons_LOD->_4114F2(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pEventTimer->Resume(); continue; - case 2: + case SCREEN_OPTIONS: thisa = (signed int)&uTextureID_507C60; do { @@ -1408,7 +1408,7 @@ //LABEL_291: stru_506E40.Release(); break; - case 1: + case SCREEN_MENU: pIcons_LOD->_40F9C5(); pIcons_LOD->_4114F2(); pIcons_LOD->_40F9C5(); @@ -1416,7 +1416,7 @@ //goto LABEL_291; stru_506E40.Release(); break; - case 28: + case SCREEN_VIDEO_OPTIONS: if ( pRenderer->pRenderD3D ) { WriteWindowsRegistryInt("Colored Lights", pRenderer->bUseColoredLights); @@ -1435,7 +1435,7 @@ WriteWindowsRegistryInt(v31, v30); stru_506E40.Release(); break; - case 26: + case SCREEN_KEYBOARD_OPTIONS: v197 = 1; v32 = 0; while ( *((char *)word_506E6C + v32) != 1 ) @@ -1486,7 +1486,7 @@ } } goto LABEL_623; - case 5: + case SCREEN_REST: if ( dword_506F14 ) { Rest(_506F18_num_hours_to_sleep); @@ -1507,7 +1507,7 @@ //goto LABEL_322; if ( pGUIWindow_Settings ) { - if ( pCurrentScreen == 7 ) + if ( pCurrentScreen == SCREEN_CHARACTERS ) { pMouse->SetCursorBitmap("MICON2"); } @@ -1528,16 +1528,16 @@ ptr_507BC0 = 0; pGUIWindow_CurrentMenu = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pIcons_LOD->_4355F7(); continue; - case 14: + case SCREEN_E: pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = 13; + pCurrentScreen = SCREEN_HOUSE; pIcons_LOD->_4114F2(); continue; - case 13: + case SCREEN_HOUSE: if ( uDialogueType ) uDialogueType = 0; if ( uGameState == 2 ) @@ -1557,7 +1557,7 @@ //goto LABEL_322; if ( pGUIWindow_Settings ) { - if ( pCurrentScreen == 7 ) + if ( pCurrentScreen == SCREEN_CHARACTERS ) { pMouse->SetCursorBitmap("MICON2"); } @@ -1578,11 +1578,11 @@ ptr_507BC0 = 0; pGUIWindow_CurrentMenu = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pIcons_LOD->_4355F7(); continue; - case 18: + case SCREEN_INPUT_BLV: if ( uCurrentHouse_Animation == 153 ) HousePlaySomeSound(0x99u, 3); pVideoPlayer->Unload(); @@ -1596,7 +1596,7 @@ dword_5B65CC = 0; } goto LABEL_317; - case 4: + case SCREEN_NPC_DIALOGUE: //LABEL_306: if ( dword_5B65CC ) { @@ -1607,11 +1607,11 @@ dword_5B65CC = 0; } goto LABEL_317; - case 19: + case SCREEN_BRANCHLESS_NPC_DIALOG: memset(GameUI_StatusBar_TimedString, 0, 0xC8u); sub_4452BB(); goto LABEL_317; - case 17: + case SCREEN_CHANGE_LOCATION: if ( pParty->vPosition.x < -22528 ) pParty->vPosition.x = -22528; if ( pParty->vPosition.x > 22528 ) @@ -1621,16 +1621,16 @@ if ( pParty->vPosition.y > 22528 ) pParty->vPosition.y = 22528; goto LABEL_317; - case 16: + case SCREEN_VIDEO: pVideoPlayer->Unload(); continue; - case 7: + case SCREEN_CHARACTERS: goto LABEL_319; default: //goto LABEL_322; if ( pGUIWindow_Settings ) { - if ( pCurrentScreen == 7 ) + if ( pCurrentScreen == SCREEN_CHARACTERS ) { pMouse->SetCursorBitmap("MICON2"); } @@ -1651,7 +1651,7 @@ ptr_507BC0 = 0; pGUIWindow_CurrentMenu = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pIcons_LOD->_4355F7(); continue; @@ -1659,7 +1659,7 @@ //goto LABEL_322; if ( pGUIWindow_Settings ) { - if ( pCurrentScreen == 7 ) + if ( pCurrentScreen == SCREEN_CHARACTERS ) { pMouse->SetCursorBitmap("MICON2"); } @@ -1680,7 +1680,7 @@ ptr_507BC0 = 0; pGUIWindow_CurrentMenu = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pIcons_LOD->_4355F7(); continue; @@ -1694,7 +1694,7 @@ //LABEL_322: if ( pGUIWindow_Settings ) { - if ( pCurrentScreen == 7 ) + if ( pCurrentScreen == SCREEN_CHARACTERS ) { pMouse->SetCursorBitmap("MICON2"); } @@ -1715,7 +1715,7 @@ ptr_507BC0 = 0; pGUIWindow_CurrentMenu = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; pIcons_LOD->_4355F7(); continue; @@ -1801,7 +1801,7 @@ } DrawHiredNPCs(); continue; - case UIMSG_OpenRestUI|0x2: + case UIMSG_19B: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; dword_50CDC8 = v0; @@ -1862,7 +1862,7 @@ if ( !_strcmpi(byte_6BE3B0, "d05.blv") ) pParty->uTimePlayed += 1474560i64; continue; - case 0x19C: + case UIMSG_19C: CloseWindowBackground(); pVideoPlayer->Unload(); sub_44603D(); @@ -1872,7 +1872,7 @@ v39 = GetAsyncKeyState(VK_SHIFT); v40 = CycleCharacter(v39); goto LABEL_421; - case UIMSG_LoadGame|0x8: + case UIMSG_5A: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; dword_50CDC8 = v0; @@ -1895,7 +1895,7 @@ pParty->vPosition.y = 22528; LABEL_317: sub_44603D(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; } else { @@ -1968,11 +1968,11 @@ sub_461103(); pEventTimer->Resume(); viewparams->bRedrawGameUI = 1; - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; pGameLoadingUI_ProgressBar->Release(); } goto LABEL_422; - case UIMSG_SaveGame|0x8: + case UIMSG_5B: goto LABEL_387; case UIMSG_BE: if ( pRenderer->pRenderD3D ) @@ -2083,9 +2083,9 @@ unk_50C9A0 = 0; back_to_game(); continue; - case UIMSG_ChangeGameState|0x40: - case 0x8D: - case 0x8F: + case UIMSG_45: + case UIMSG_8D: + case UIMSG_8F: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; if ( unk_50C9A0 ) @@ -2506,7 +2506,7 @@ uGameState = 0; strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2"); goto LABEL_524; - case UIMSG_D5|0x8: + case UIMSG_DD: LABEL_524: sprintf(pTmpBuf, "%s", pKeyActionMap->pPressedKeysBuffer); memcpy(&v216, texture_frame_table_txt_parser((const char *)pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216)); @@ -2613,7 +2613,7 @@ v1 = ""; v0 = 1; continue; - case 0x19: + case UIMSG_19: if ( bUnderwater == 1 ) goto LABEL_682; if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) ) @@ -2631,8 +2631,8 @@ //goto LABEL_679; _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175); continue; - case 0x46: - case UIMSG_Quit|0x8: + case UIMSG_46: + case UIMSG_8C: if ( pRenderer->pRenderD3D ) { v81 = pGame->pVisInstance->get_picked_object_zbuf_val(); @@ -2677,7 +2677,7 @@ unk_50C9A0 = 0; back_to_game(); continue; - case 0x1C: + case UIMSG_1C: if ( !uActiveCharacter || pCurrentScreen ) //goto LABEL_90; { @@ -2686,10 +2686,10 @@ continue; } ptr_507BC8 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)104, uMessageParam, 0); - pCurrentScreen = 25; + pCurrentScreen = SCREEN_19; pEventTimer->Pause(); continue; - case 0x1B: + case UIMSG_1B: if ( !uActiveCharacter ) //goto LABEL_90; { @@ -2747,7 +2747,7 @@ //LABEL_577: _42ECB5_PlayerAttacksActor(); continue; - case UIMSG_A7: + case UIMSG_ExitRest: v163 = (int)pGlobalTXT_LocalizationStrings[81];// "Exit Rest" pButton = pButton_RestUI_Exit; pButton2 = pButton_RestUI_Exit; @@ -2760,7 +2760,7 @@ v133 = 0; GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); continue; - case UIMSG_ShowStatus_Player|0x1: + case UIMSG_Wait5Minutes: if ( dword_506F14 == 2 ) //goto LABEL_621; { @@ -2772,7 +2772,7 @@ dword_506F14 = v0; _506F18_num_hours_to_sleep = 5; continue; - case 0x60: + case UIMSG_Wait1Hour: if ( dword_506F14 == 2 ) //goto LABEL_621; { @@ -2800,7 +2800,7 @@ pParty->pPlayers[1].pConditions[2] = pParty->uTimePlayed; pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed; continue; - case 0x68: + case UIMSG_68: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; if ( pCurrentScreen ) @@ -2865,7 +2865,7 @@ v176 = 0; v160 = 13; goto LABEL_619; - case 0x61: + case UIMSG_61: if ( dword_506F14 ) //goto LABEL_621; { @@ -2945,7 +2945,7 @@ pParty->pPlayers[0].pConditions[2] = pParty->uTimePlayed; } continue; - case UIMSG_ShowStatus_Funds|0x8: + case UIMSG_AlreadyResting: if ( dword_506F14 == 2 ) { //LABEL_621: @@ -2958,7 +2958,7 @@ dword_506F14 = v0; _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute; continue; - case 0x4E: + case UIMSG_4E: if ( dword_50654C && byte_506550 ) { v173 = pSpellStats->pInfos[dword_50654C + 11 * pPlayers[uActiveCharacter]->pNumSpellBookPage].pName; @@ -2977,7 +2977,7 @@ //_set_status_string_pTmpBuf_and_continue: sub_41C0B8_set_status_string(pTmpBuf); continue; - case 0x4F: + case UIMSG_4F: if ( !uActiveCharacter || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter], !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) ) continue; @@ -2999,7 +2999,7 @@ //goto LABEL_91; v0 = 1; continue; - case 0x58: + case UIMSG_58: GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, (enum WindowType)90, (int)pBtn_InstallRemoveSpell, 0); if ( !uActiveCharacter ) continue; @@ -3025,7 +3025,7 @@ pPlayer10->PlaySound(12, 0); byte_506550 = 0; continue; - case 0x33: + case UIMSG_33: if ( !uActiveCharacter ) continue; pPlayer3 = pPlayers[uActiveCharacter]; @@ -3083,7 +3083,7 @@ v130 = 0; v127 = rand() % 2 + 204; goto _play_sound_and_continue; - case UIMSG_SaveGame|0x4: + case UIMSG_57: if ( pTurnEngine->field_4 == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->pNumSpellBookPage ) continue; sub_41140B(); @@ -3098,7 +3098,7 @@ v130 = 0; v127 = rand() % 2 + 204; goto _play_sound_and_continue; - case UIMSG_LoadGame|0x4: + case UIMSG_56: if ( pTurnEngine->field_4 != 3 ) { if ( uActiveCharacter ) @@ -3111,7 +3111,7 @@ pGUIWindow_CurrentMenu->Release(); pEventTimer->Resume(); viewparams->bRedrawGameUI = v0; - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; pIcons_LOD->_4114F2(); v103 = dword_50654C + 11 * *(char *)(uNumSeconds + 6734); if ( dword_50C9E8 < 40 ) @@ -3131,7 +3131,7 @@ } } continue; - case 0x8E: + case UIMSG_8E: if ( pTurnEngine->field_4 == 3 ) continue; v175 = 0; @@ -3142,7 +3142,7 @@ v79 = uMessageParam; _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175); continue; - case 0x92: + case UIMSG_92: if ( pTurnEngine->field_4 != 3 ) { v175 = 0; @@ -3155,7 +3155,7 @@ _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175); } continue; - case 0x69: + case UIMSG_69: if ( pTurnEngine->field_4 == 3 ) continue; if ( bUnderwater == 1 ) @@ -3186,22 +3186,22 @@ //goto LABEL_693; { GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0); - pCurrentScreen = 8; + pCurrentScreen = SCREEN_SPELL_BOOK; pEventTimer->Pause(); pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0); pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0); viewparams->field_48 = v0; continue; } - if ( pCurrentScreen != 5 - && pCurrentScreen != 7 - && (pCurrentScreen <= 99 - || pCurrentScreen > 103) ) + if ( pCurrentScreen != SCREEN_REST + && pCurrentScreen != SCREEN_CHARACTERS + && (pCurrentScreen <= SCREEN_63 + || pCurrentScreen > SCREEN_67) ) { pGUIWindow_CurrentMenu->Release(); //LABEL_693: GUIWindow::Create(0x1DCu, 0x1C2u, 0, 0, (enum WindowType)90, (int)pBtn_CastSpell, 0); - pCurrentScreen = 8; + pCurrentScreen = SCREEN_SPELL_BOOK; pEventTimer->Pause(); pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)18, 0, 0); pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0); @@ -3223,19 +3223,19 @@ viewparams->bRedrawGameUI = v0; pEventTimer->Pause(); pAudioPlayer->StopChannels(-1, -1); - pCurrentScreen = 104; + pCurrentScreen = SCREEN_QUICK_REFERENCE; pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)12, 5, 0); papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE); pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, v0, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[79],// "Exit" (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); //, v179); continue; - case 0x6B: + case UIMSG_6B: if ( pCurrentScreen ) { pGUIWindow_CurrentMenu->Release(); pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v0; } stru_506E40.Release(); @@ -3268,7 +3268,7 @@ //LABEL_709: dword_506544 = v0; continue; - case 0x55: + case UIMSG_55: bRingsShownInCharScreen ^= v0; GUIButton::_41D0D8(pCharacterScreen_DetalizBtn); GUIButton::_41D0D8(pCharacterScreen_DollBtn); @@ -3291,10 +3291,10 @@ 0); pCharacterScreen_DollBtn = pGUIWindow_CurrentMenu->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, v0, 0, 0x85u, 0, 0, v1, 0); goto LABEL_422; - case UIMSG_Quit|0x1: + case UIMSG_85: OnPaperdollLeftClick(); continue; - case UIMSG_Escape|0x2: + case UIMSG_73: pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; sub_4196A0(); sub_419379(); @@ -3310,7 +3310,7 @@ v133 = 0; GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); continue; - case UIMSG_ChangeMusicVolume|0x2: + case UIMSG_72: pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101; sub_4196A0(); sub_419379(); @@ -3358,7 +3358,7 @@ //_draw_status_string_and_continue: ShowStatusBarString(v87, 2u); continue; - case UIMSG_ChangeMusicVolume|0x4: + case UIMSG_74: pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; sub_419379(); sub_4196A0(); @@ -3388,7 +3388,7 @@ v133 = 0; GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); continue; - case UIMSG_Escape|0x4: + case UIMSG_75: sub_419379(); sub_4196A0(); sub_419220(); @@ -3397,7 +3397,7 @@ (int)pCharacterScreen_AwardsBtn, 0); sub_419100(); continue; - case 71://0x47: + case UIMSG_AutonotesBook: switch ( uMessageParam ) { default: @@ -3517,18 +3517,18 @@ sprintf(pTmpBuf, "%d / %d %s %d / %d %s", v110->sHealth, v114, v113, v112, v111, v109); sub_41C0B8_set_status_string(pTmpBuf); continue; - case 0xC: - if ( pCurrentScreen == 15 ) + case UIMSG_C: + if ( pCurrentScreen == SCREEN_F ) { sub_421EA6_OnInventoryLeftClick(); continue; } sub_420E01(); continue; - case UIMSG_ChangeMusicVolume|0x8: + case UIMSG_InventoryLeftClick: sub_421EA6_OnInventoryLeftClick(); continue; - case 0xA: + case UIMSG_A: if ( !pRenderer->pRenderD3D ) //goto LABEL_772; { @@ -3578,13 +3578,13 @@ continue; } continue; - case 0xE: + case UIMSG_E: //LABEL_772: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; OnGameViewportClick(); continue; - case 0xF: + case UIMSG_F: if ( pRenderer->pRenderD3D ) { LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val(); @@ -3605,7 +3605,7 @@ v133 = 0; GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); continue; - case 0x54: + case UIMSG_54: v163 = 0; pButton2 = (GUIButton *)uMessageParam; pWindowType1 = (WindowType)22; @@ -3618,12 +3618,12 @@ //LABEL_733: GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); continue; - case 0x194: + case UIMSG_194: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; OnPressSpace(); continue; - case UIMSG_ChangeSoundVolume|0x100: + case UIMSG_16F: if ( pCurrentScreen ) continue; pParty->uFlags |= 2u; @@ -3646,7 +3646,7 @@ goto LABEL_789; viewparams->field_28 = 11; goto LABEL_788; - case UIMSG_ChangeMusicVolume|0x100: + case UIMSG_170: if ( pCurrentScreen ) continue; pParty->uFlags |= 2u; @@ -3830,7 +3830,7 @@ //main menu save/load wnd clicking on savegame lines if (pGUIWindow_CurrentMenu->field_40 == 1) pKeyActionMap->_459ED1(0); - if ( pCurrentScreen != 11 || uLoadGameUI_SelectedSlot != uNum + pSaveListPosition ) + if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != uNum + pSaveListPosition ) { //load clicked line v26 = uNum + pSaveListPosition; @@ -3960,7 +3960,7 @@ { pGUIWindow_CurrentMenu->Release(); pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; } GUIWindow::Create(602, 450, 0, 0, (enum WindowType)92, (int)pBtn_GameSettings, 0); @@ -4023,7 +4023,7 @@ v17 = pCurrentScreen; if ( v16 && !pCurrentScreen ) goto LABEL_83; - if ( pCurrentScreen == 12 ) + if ( pCurrentScreen == SCREEN_LOADGAME ) { pIcons_LOD->_4114F2(); //crt_deconstruct_ptr_6A0118(); @@ -4036,24 +4036,24 @@ pGUIWindow2->Release(); pGUIWindow2 = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v15; continue; } - if ( pCurrentScreen == 16 ) + if ( pCurrentScreen == SCREEN_VIDEO ) { pVideoPlayer->Unload(); } else { - if ( pCurrentScreen != 27 ) + if ( pCurrentScreen != SCREEN_1B ) //goto LABEL_81; { pGUIWindow_CurrentMenu->Release(); pGUIWindow2->Release(); pGUIWindow2 = 0; pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = v15; continue; } @@ -5221,7 +5221,7 @@ v61 = 0; v59 = 0; v62 = 0; - if ( (a1 & 7) == 2 ) + if ( (a1 & 7) == OBJECT_Item) { v4 = &pLayingItems[a1 >> 3]; uDamageAmount = (int)v4; @@ -6165,11 +6165,10 @@ //----- (0043AA99) -------------------------------------------------------- void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz) { - int v7; // ebx@1 +/* int v7; // ebx@1 int v8; // ST14_4@1 int v9; // edi@1 int anglea; // [sp+20h] [bp+8h]@1 - v7 = sRotX; v8 = sDepth; v9 = sRotY; @@ -6179,7 +6178,17 @@ + ((unsigned __int64)(stru_5C6E00->SinCos(v9 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)anglea) >> 16); *outz = v.z - + ((unsigned __int64)(stru_5C6E00->SinCos(v7 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v8) >> 16); + + ((unsigned __int64)(stru_5C6E00->SinCos(v7 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v8) >> 16);*/ + + float cosf_x = cosf(3.14159265f * sRotX / 1024.0f), + cosf_y = cosf(3.14159265f * sRotY / 1024.0f), + sinf_x = sinf(3.14159265f * sRotX / 1024.0f), + sinf_y = sinf(3.14159265f * sRotY / 1024.0f); + + *outx = v.x + ((unsigned __int64)((double)sDepth * cosf_y * cosf_x) >> 16); + *outy = v.y + ((unsigned __int64)((double)sDepth * sinf_y * cosf_x) >> 16); + *outz = v.z + ((unsigned __int64)((double)sDepth * sinf_x) >> 16); + } //----- (0043AB61) -------------------------------------------------------- @@ -6293,7 +6302,7 @@ a2 = uObjID; if ( !pActors[uActorID].IsAlive() ) { - if ( (a2 & 7) == 2 ) + if ( (a2 & 7) == OBJECT_Item) { v4 = &pLayingItems[(signed int)a2 >> 3]; v5 = v4->field_48; @@ -6352,7 +6361,7 @@ v4 = 0; uActorID = a2; v17 = a1; - if ( (a1 & 7) == 2 ) + if ( (a1 & 7) == OBJECT_Item) { v5 = &pLayingItems[a1 >> 3]; v4 = v5->field_60_distance_related_prolly_lod; @@ -9437,7 +9446,7 @@ while ( 1 ) { v5 = v16->uPackedID; - if ( (v16->uPackedID & 7) == 4 ) + if ( (v16->uPackedID & 7) == OBJECT_Player) break; LABEL_8: ++v17; @@ -9480,7 +9489,7 @@ v8 = v1->pQueue; do { - if ( (v8->uPackedID & 7) == 3 && ai_array_4F7DB0_actor_ids[v20] == v8->uPackedID >> 3 ) + if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_array_4F7DB0_actor_ids[v20] == v8->uPackedID >> 3 ) break; ++v18; ++v8; @@ -9559,7 +9568,7 @@ _404544(); v2 = v1->pQueue; v3 = 0; - if ( (v1->pQueue[0].uPackedID & 7) == 4 ) + if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) uActiveCharacter = (v1->pQueue[0].uPackedID >> 3) + 1; else uActiveCharacter = 0; @@ -9578,7 +9587,7 @@ goto LABEL_27; do { - if ( (v2->uPackedID & 7) != 4 ) + if ( (v2->uPackedID & 7) != OBJECT_Player) { v5 = &pActors[v2->uPackedID >> 3]; LOWORD(v6) = v5->uAIState; @@ -9636,7 +9645,7 @@ v9 = v1->pQueue; do { - if ( (v9->uPackedID & 7) != 4 ) + if ( (v9->uPackedID & 7) != OBJECT_Player) { v10 = v9->uPackedID >> 3; v11 = pActors[v10].uAIState; @@ -9688,7 +9697,7 @@ v4 = v1->pQueue[0].field_4; if ( v4 ) { - if ( (v1->pQueue[0].uPackedID & 7) == 4 ) + if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) { v5 = v1->uActorQueueSize; while ( 1 ) @@ -9769,7 +9778,7 @@ v2 = this; v3 = *(&this->field_0 + 4 * (a2 + 2)); - if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == 4 ) + if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == OBJECT_Player) { v4 = v3 >> 3; v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[v3 >> 3]; @@ -9787,7 +9796,7 @@ } v2->pQueue[a2].field_4 = v6; v2->_404544(); - if ( (v2->pQueue[0].uPackedID & 7) == 4 ) + if ( (v2->pQueue[0].uPackedID & 7) == OBJECT_Player) uActiveCharacter = (v2->pQueue[0].uPackedID >> 3) + 1; else uActiveCharacter = 0; @@ -9835,11 +9844,11 @@ { if ( !*(int *)v1 ) { - if ( (*(v1 - 4) & 7) == 4 ) + if ( (*(v1 - 4) & 7) == OBJECT_Player) return; v2 = &pActors[*((int *)v1 - 1) >> 3]; v3 = v2->uAIState; - if ( !v3 || v3 == 9 || v3 == 7 ) + if (v3 == Standing || v3 == Fleeing || v3 == Fidgeting) { v4 = pMonsterStats->pInfos[v2->pMonsterInfo.uID].uRecoveryTime; *(int *)v1 = v4; @@ -9866,7 +9875,7 @@ v1 = this; LOWORD(v2) = _404544(); if ( v1->pQueue[0].field_4 <= 0 - || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, (v1->pQueue[0].uPackedID & 7) != 4) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), + || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, (v1->pQueue[0].uPackedID & 7) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), viewparams->bRedrawGameUI = 1, v1->pQueue[0].field_4 <= 0) ) { @@ -9877,7 +9886,7 @@ do { v2 = *(int *)v4; - if ( (*(char *)v4 & 7) == 4 || *(int *)(v4 + 4) > 0 ) + if ( (*(char *)v4 & 7) == OBJECT_Player || *(int *)(v4 + 4) > 0 ) break; if ( *(int *)(v4 + 8) <= 0 ) { @@ -9935,7 +9944,7 @@ v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); v28 = v1; v3 = v1->uPackedID; - if ( (v1->uPackedID & 7) != 4 ) + if ( (v1->uPackedID & 7) != OBJECT_Player) { v4 = v3 >> 3; // turn based only stuff a2a = dword_4F6E08[v3 >> 3]; @@ -10099,7 +10108,7 @@ v9 = 0; v20 = 0; } - if ( (v22 & 7) == 3 ) + if ( (v22 & 7) == OBJECT_Actor) v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) / 3] @@ -10232,7 +10241,7 @@ while ( 1 ) { v5 = v10->uPackedID; - if ( (v10->uPackedID & 7) == 3 ) + if ( (v10->uPackedID & 7) == OBJECT_Actor) { v8 = dword_4F6E08[v5 >> 3]; memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); @@ -10271,7 +10280,7 @@ v2 = this->pQueue; do { - if ( (v2->uPackedID & 7) == 3 ) + if ( (v2->uPackedID & 7) == OBJECT_Actor) { v3 = v2->uPackedID >> 3; v8 = v3; @@ -10326,7 +10335,7 @@ { v4 = v14->uPackedID; a1 = v14->uPackedID; - if ( (a1 & 7) != 4 ) + if ( (a1 & 7) != OBJECT_Player) { v5 = v4 >> 3; v12 = v5; @@ -10410,7 +10419,7 @@ unsigned int a2a; // [sp+5Ch] [bp+8h]@7 v2 = *(&this->field_0 + 4 * (a2 + 2)); - if ( (v2 & 7) == 4 ) + if ( (v2 & 7) == OBJECT_Player) return 0; v3 = v2 >> 3; uActorID = v3; @@ -10604,7 +10613,7 @@ v14 = this->pQueue; do { - if ( (v3->uPackedID & 7) != 4 ) + if ( (v3->uPackedID & 7) != OBJECT_Player) { v4 = v3->uPackedID >> 3; uActorID = v4; @@ -14113,13 +14122,13 @@ viewparams->_443231(); if ( dword_506538 ) viewparams->_44323D(); - v6 = dword_506534; + //v6 = dword_506534; if ( dword_506534 ) { viewparams->_443225(); - v6 = dword_506534; - } - if ( dword_506548 | dword_506544 | dword_506540 | dword_50653C | dword_506538 | v6 ) + //v6 = dword_506534; + } + if ( dword_506548 | dword_506544 | dword_506540 | dword_50653C | dword_506538 | dword_506534 ) pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); dword_506548 = 0; dword_506544 = 0; @@ -14127,8 +14136,8 @@ dword_506538 = 0; dword_50653C = 0; dword_506540 = 0; - DrawSpellbook_Map_sub(0x61u, 0x31u, 0x169u, 313, 0); - pRenderer->DrawTextureTransparent(0x4Bu, 0x16u, pTexture_mapbordr); + DrawSpellbook_Map_sub(97, 49, 361, 313, 0); + pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr); v22.uFrameWidth = 460; v22.uFrameHeight = 344; v22.uFrameX = 8; @@ -14354,7 +14363,7 @@ dword_506F0C[0] = pCurrentScreen; result = GUIWindow::Create(0, 0, 640, 480, WINDOW_FinalWindow, v3, (int)v2); ptr_507BDC = result; - pCurrentScreen = 22; + pCurrentScreen = SCREEN_PRESS_ESCAPE_MESSAGE; return result; } // 4E28F8: using guessed type int pCurrentScreen; @@ -15033,7 +15042,7 @@ if ( pHint && pHint != (char *)1 ) pGUIButton3->DrawLabel(pHint, pFontCreate, 0, 0); pWindow->Release(); - if (pCurrentScreen == 11)// + if (pCurrentScreen == SCREEN_SAVEGAME) pMessageQueue_50CBD0->SendMessage(UIMSG_SaveGame, 0, 0); else pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0); @@ -15100,7 +15109,7 @@ ItemGen2.Reset(); pWindow->Release(); pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); if ( v39 > 0 ) @@ -15201,7 +15210,7 @@ pItemGen.Reset(); pWindow->Release(); pEventTimer->Resume(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); if ( v26 > 0 ) @@ -15362,7 +15371,7 @@ } pEventTimer->Resume(); ptr_507BD0->Release(); - pCurrentScreen = 0; + pCurrentScreen = SCREEN_GAME; //goto LABEL_114; viewparams->bRedrawGameUI = 1; continue; @@ -15437,13 +15446,13 @@ } else//pWindowType == 20 (0x14) WINDOW_Chest { - if ( pCurrentScreen == 10 ) + if ( pCurrentScreen == SCREEN_CHEST ) { Chest::DrawChestUI((unsigned int)pWindow->ptr_1C); } else { - if ( pCurrentScreen == 15 ) + if ( pCurrentScreen == SCREEN_F ) { pRenderer->ClearZBuffer(0, 479); draw_leather(); @@ -16160,7 +16169,7 @@ unsigned int pX; // [sp+70h] [bp-8h]@3 unsigned int pY; // [sp+74h] [bp-4h]@3 - if ( pCurrentScreen == 16 )// + if ( pCurrentScreen == SCREEN_VIDEO ) return; if ( _this ) { @@ -16198,9 +16207,9 @@ //while ( v1 < 4 ); } pEventTimer->Pause(); - if ( pCurrentScreen <= 10 ) - { - if ( pCurrentScreen == 10 )// + if ( pCurrentScreen <= SCREEN_CHEST ) + { + if ( pCurrentScreen == SCREEN_CHEST ) { __debugbreak(); if ( !pPlayers[uActiveCharacter]->CanAct() ) @@ -16229,11 +16238,11 @@ { if ( pCurrentScreen ) { - if ( pCurrentScreen != 3 ) - { - if ( pCurrentScreen != 7 ) - { - if ( pCurrentScreen == 8 )// + if ( pCurrentScreen != SCREEN_BOOKS ) + { + if ( pCurrentScreen != SCREEN_CHARACTERS ) + { + if ( pCurrentScreen == SCREEN_SPELL_BOOK ) { if ( dword_507B00_spell_info_to_draw_in_popup ) DrawSpellDescriptionPopup((void *)(dword_507B00_spell_info_to_draw_in_popup - 1)); @@ -16241,7 +16250,7 @@ goto LABEL_132; } LABEL_119: - if ( (signed int)pX > 467 && pCurrentScreen != 14 ) + if ( (signed int)pX > 467 && pCurrentScreen != SCREEN_E ) { identify_item(); goto LABEL_132; @@ -16352,9 +16361,9 @@ else v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; v6 = (unsigned __int16)v5; - if ( (v6 & 7) != 2 ) - { - if ( (v6 & 7) == 3 ) + if ( (v6 & 7) != OBJECT_Item) + { + if ( (v6 & 7) == OBJECT_Actor) { if ( pRenderer->uNumSceneBegins ) { @@ -16379,19 +16388,19 @@ GameUI_DrawItemInfo(v8); goto LABEL_132; } - if ( pCurrentScreen == 13 )// + if ( pCurrentScreen == SCREEN_HOUSE ) { if ( (signed int)pY < 345 && (signed int)pX < 469 ) sub_4B1A2D(); goto LABEL_132; } - if ( pCurrentScreen <= 13 ) + if ( pCurrentScreen <= SCREEN_HOUSE ) goto LABEL_132; - if ( pCurrentScreen <= 15 ) + if ( pCurrentScreen <= SCREEN_F ) goto LABEL_119; - if ( pCurrentScreen != 21 ) - { - v11 = pCurrentScreen == 23; + if ( pCurrentScreen != SCREEN_PARTY_CREATION ) + { + v11 = pCurrentScreen == SCREEN_CASTING; if ( !v11 ) goto LABEL_132; identify_item(); @@ -16484,7 +16493,7 @@ } //----- (004175C0) -------------------------------------------------------- -void __thiscall UI_OnMouseLeftClick(int *pXY) +void UI_OnMouseLeftClick(int *pXY) { int *pXY_; // esi@1 signed int y; // eax@7 @@ -16501,7 +16510,7 @@ unsigned int pY; // [sp+18h] [bp-4h]@7 pXY_ = pXY; - if ( pCurrentScreen == 16 + if ( pCurrentScreen == SCREEN_VIDEO || sub_4637E0_is_there_popup_onscreen() ) return; if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 ) @@ -16591,7 +16600,7 @@ else v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; v6 = (unsigned __int16)v5; - if ( (v5 & 7) == 3 + if ( (v5 & 7) == OBJECT_Actor && uActiveCharacter && v5 < 33554432 && pPlayers[uActiveCharacter]->CanAct()
--- a/mm7_6.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_6.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -3324,7 +3324,7 @@ v666 = v1; a2 = stru_50C198.FindClosesActor(5120, 1, v666); v6 = pMouse->uPointingObjectID; - if ( pMouse->uPointingObjectID != v1 && (v6 & 7) == 3 && pActors[v6 >> 3].CanAct() ) + if ( pMouse->uPointingObjectID != v1 && (v6 & 7) == OBJECT_Actor && pActors[v6 >> 3].CanAct() ) { v4 = pMouse->uPointingObjectID; LABEL_18: @@ -3333,9 +3333,9 @@ a1.uItemType = stru_4E3ACC[v3->spellnum].uItemType; if ( (short)a1.uItemType != (short)v1 ) { - if ( (a2 & 7) == 3 ) + if ( (a2 & 7) == OBJECT_Actor) { - memcpy(&v715, Actor::GetDirectionInfo((8 * v3->uPlayerID + 8) | 4, a2, &a3, 0), sizeof(v715)); + memcpy(&v715, Actor::GetDirectionInfo((8 * v3->uPlayerID + 8) | OBJECT_Player, a2, &a3, 0), sizeof(v715)); v2 = v723; v1 = 0; } @@ -3672,7 +3672,7 @@ goto LABEL_83; if ( a2 == v1 ) goto LABEL_200; - if ( (a2 & 7) != 3 ) + if ( (a2 & 7) != OBJECT_Actor) goto LABEL_1056; v699 = v1; v698 = v1; @@ -3750,7 +3750,7 @@ v47 = v38; goto LABEL_139; case 79: - if ( !pPlayer->CanCastSpell(uRequiredMana) || a2 == v1 || (a2 & 7) != 3 ) + if ( !pPlayer->CanCastSpell(uRequiredMana) || a2 == v1 || (a2 & 7) != OBJECT_Actor) goto LABEL_83; v730 = a2 >> 3; v693 = v1; @@ -3855,7 +3855,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_83; if ( a2 == v1 - || (a2 & 7) != 3 + || (a2 & 7) != OBJECT_Actor || (v730 = a2 >> 3, v721 = (int)&pActors[a2 >> 3], !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) ) @@ -3897,7 +3897,7 @@ LODWORD(v733) = v57; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_83; - if ( (a2 & 7) != 3 + if ( (a2 & 7) != OBJECT_Actor || (v721 = 836 * (a2 >> 3), LODWORD(v718) = (int)&pActors[a2 >> 3], !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u)) ) @@ -4324,7 +4324,7 @@ while ( v730b <= &pParty->pPlayers[3] ); goto LABEL_1056; case 52: - if ( pPlayer->CanCastSpell(uRequiredMana) && a2 != v1 && (a2 & 7) == 3 ) + if ( pPlayer->CanCastSpell(uRequiredMana) && a2 != v1 && (a2 & 7) == OBJECT_Actor) { v730 = a2 >> 3; v112 = &pActors[a2 >> 3]; @@ -4511,7 +4511,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_83; LODWORD(v725) = a2 & 7; - if ( (a2 & 7) == 3 ) + if ( (a2 & 7) == OBJECT_Actor) { v152 = a2 >> 3; uRequiredMana = pActors[v152].vPosition.x; @@ -5820,7 +5820,7 @@ v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[4]; goto LABEL_104; } - if ( (v342 & 7) == 3 ) + if ( (v342 & 7) == OBJECT_Actor) { v343 = v342 >> 3; HIDWORD(v344) = v1 + ((pParty->uTimePlayed + 1280) >> 32); @@ -6211,7 +6211,7 @@ case 59: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_83; - if ( a2 == v1 || (a2 & 7) != 3 ) + if ( a2 == v1 || (a2 & 7) != OBJECT_Actor) goto LABEL_1056; v417 = (int)&pActors[a2 >> 3]; v730 = v417; @@ -6303,7 +6303,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_83; v426 = a2 >> 3; - if ( (a2 & 7) != 3 ) + if ( (a2 & 7) != OBJECT_Actor) goto LABEL_1056; v730 = 836 * v426; if ( stru_50C198.GetMagicalResistance(&pActors[v426], 7u) ) @@ -6331,7 +6331,7 @@ goto LABEL_83; amount = 600 * v2; v427 = a2 >> 3; - if ( (a2 & 7) != 3 ) + if ( (a2 & 7) != OBJECT_Actor) goto LABEL_1056; v730 = 836 * v427; if ( MonsterStats::BelongsToSupertype(pActors[v427].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) @@ -6464,7 +6464,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_83; v445 = a2 >> 3; - if ( (a2 & 7) == 2 ) + if ( (a2 & 7) == OBJECT_Item) { v449 = (char *)&pLayingItems[v445].stru_24; v450 = *(int *)v449; @@ -6484,15 +6484,15 @@ } else { - if ( (a2 & 7) == 3 ) + if ( (a2 & 7) == OBJECT_Actor) { stru_50C198.LootActor(&pActors[v445]); } else { - if ( (a2 & 7) != 5 ) + if ( (a2 & 7) != OBJECT_Decoration) { - if ( (a2 & 7) != 6 ) + if ( (a2 & 7) != OBJECT_BModel) goto LABEL_1056; dword_507CD8 = 1; v677 = 1; @@ -6607,7 +6607,7 @@ } else { - if ( (v460 & 7) == 3 ) + if ( (v460 & 7) == OBJECT_Actor) { v461 = &pActors[v460 >> 3]; v462 = v461->uAIState; @@ -7431,7 +7431,7 @@ LODWORD(v733) = 29030400; LABEL_1082: v599 = a2 >> 3; - if ( (a2 & 7) != 3 ) + if ( (a2 & 7) != OBJECT_Actor) goto LABEL_1056; v730 = 836 * v599; if ( !MonsterStats::BelongsToSupertype(pActors[v599].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) @@ -7916,12 +7916,12 @@ v29 = 0; v28 = 0; v7 = pMouse->uPointingObjectID; - if ( (pMouse->uPointingObjectID & 7) != 3 || (v34 = pMouse->uPointingObjectID, !pActors[v7 >> 3].CanAct()) ) + if ( (pMouse->uPointingObjectID & 7) != OBJECT_Actor || (v34 = pMouse->uPointingObjectID, !pActors[v7 >> 3].CanAct()) ) v34 = stru_50C198.FindClosesActor(5120, 0, 0); a3.z = 0; a3.y = 0; a3.x = 0; - if ( (v34 & 7) == 3 ) + if ( (v34 & 7) == OBJECT_Actor) { a2 = v34 >> 3; v8 = &pActors[v34 >> 3]; @@ -8174,7 +8174,7 @@ { v22 = *v28; v11 = *v28 & 0xFFFF; - if ( (*(char *)v28 & 7) == 3 ) + if ( (*(char *)v28 & 7) == OBJECT_Actor) { v12 = &pActors[(unsigned int)v11 >> 3]; v13 = v12->uAIState; @@ -8921,7 +8921,7 @@ pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; } - pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; + //pParty->uFlags2 |= PARTY_FLAGS_2_RUNNING; LABEL_6: if ( !pEventTimer->bPaused ) { @@ -8949,7 +8949,7 @@ pTurnEngine->uActionPointsLeft -= 26; _do_move_forward: v5 = pActionQueue; - if ( pParty->uFlags2 & 2 ) + if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING) partyAction = PARTY_RunForward; else partyAction = PARTY_WalkForward; @@ -9115,7 +9115,7 @@ { if (pParty->bTurnBasedModeOn) { - if ( pTurnEngine->field_4 == 3 || (pTurnEngine->pQueue[0].uPackedID & 7) == 4 ) + if ( pTurnEngine->field_4 == OBJECT_Actor || (pTurnEngine->pQueue[0].uPackedID & 7) == OBJECT_Player) { pParty->bTurnBasedModeOn = 0; pTurnEngine->End(true); @@ -9184,7 +9184,7 @@ pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404; goto _send_message; } - if ( pCurrentScreen == 4 ) + if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) { v11 = pMessageQueue_50CBD0->uNumMessages; if ( pMessageQueue_50CBD0->uNumMessages ) @@ -9210,7 +9210,7 @@ break; case INPUT_CharCycle: //__debugbreak(); - if ( pCurrentScreen == 8 + if ( pCurrentScreen == SCREEN_SPELL_BOOK || dword_50C9E8 >= 40 ) break; dword_50C9EC[3 * dword_50C9E8] = 176; @@ -9311,8 +9311,8 @@ ++pMessageQueue_50CBD0->uNumMessages; goto LABEL_175; } - if ( pCurrentScreen == 4 - || pCurrentScreen == 19 ) + if ( pCurrentScreen == SCREEN_NPC_DIALOGUE + || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) { v15 = pMessageQueue_50CBD0->uNumMessages; if ( pMessageQueue_50CBD0->uNumMessages )
--- a/mm7_data.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_data.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -1466,7 +1466,7 @@ int bRingsShownInCharScreen; // weak int _unused000; // weak -unsigned __int16 _56EFD8_minimap[117][137]; +unsigned __int16 pOdmMinimap[117][137]; unsigned int uNumBlueFacesInBLVMinimap; unsigned __int16 pBlueFacesInBLVMinimapIDs[50]; int pTextureIDs_isns[14]; @@ -1763,18 +1763,18 @@ int dword_76D53C_terrain_cell_world_pos_around_party_x; // weak int dword_76D540_terrain_cell_world_pos_around_party_x; // weak int dword_76D544_terrain_cell_world_pos_around_party_x; // weak -int dword_76D548_terrain_cell_world_pos_around_party_y; // weak -int dword_76D54C_terrain_cell_world_pos_around_party_y; // weak -int dword_76D550_terrain_cell_world_pos_around_party_y; // weak -int dword_76D554_terrain_cell_world_pos_around_party_y; // weak -int dword_76D558_terrain_cell_world_pos_around_party_z; // weak -int dword_76D55C_terrain_cell_world_pos_around_party_z; // weak -int dword_76D560_terrain_cell_world_pos_around_party_z; // weak -int dword_76D564_terrain_cell_world_pos_around_party_z; // weak -int dword_76D568_terrain_cell_world_pos_around_party_x; // weak -int dword_76D56C_terrain_cell_world_pos_around_party_x; // weak -int dword_76D570_terrain_cell_world_pos_around_party_x; // weak -int dword_76D574_terrain_cell_world_pos_around_party_x; // weak +//int dword_76D548_terrain_cell_world_pos_around_party_y; // weak +//int dword_76D54C_terrain_cell_world_pos_around_party_y; // weak +//int dword_76D550_terrain_cell_world_pos_around_party_y; // weak +//int dword_76D554_terrain_cell_world_pos_around_party_y; // weak +//int dword_76D558_terrain_cell_world_pos_around_party_z; // weak +//int dword_76D55C_terrain_cell_world_pos_around_party_z; // weak +//int dword_76D560_terrain_cell_world_pos_around_party_z; // weak +//int dword_76D564_terrain_cell_world_pos_around_party_z; // weak +//int dword_76D568_terrain_cell_world_pos_around_party_x; // weak +//int dword_76D56C_terrain_cell_world_pos_around_party_x; // weak +//int dword_76D570_terrain_cell_world_pos_around_party_x; // weak +//int dword_76D574_terrain_cell_world_pos_around_party_x; // weak struct unk_F7B60C stru_76D578; // struct @ MM7.exe::0076D578 struct unk_F7B60C stru_76D590; // struct @ MM7.exe::0076D590 struct unk_F7B60C stru_76D5A8; // struct @ MM7.exe::0076D5A8
--- a/mm7_data.h Tue Feb 12 18:16:18 2013 +0600 +++ b/mm7_data.h Tue Feb 12 18:16:34 2013 +0600 @@ -1310,7 +1310,7 @@ extern int bRingsShownInCharScreen; // weak extern int _unused000; // weak -extern unsigned __int16 _56EFD8_minimap[117][137]; +extern unsigned __int16 pOdmMinimap[117][137]; extern unsigned int uNumBlueFacesInBLVMinimap; extern unsigned __int16 pBlueFacesInBLVMinimapIDs[50]; extern int pTextureIDs_isns[14]; @@ -1608,18 +1608,18 @@ extern int dword_76D53C_terrain_cell_world_pos_around_party_x; // weak extern int dword_76D540_terrain_cell_world_pos_around_party_x; // weak extern int dword_76D544_terrain_cell_world_pos_around_party_x; // weak -extern int dword_76D548_terrain_cell_world_pos_around_party_y; // weak -extern int dword_76D54C_terrain_cell_world_pos_around_party_y; // weak -extern int dword_76D550_terrain_cell_world_pos_around_party_y; // weak -extern int dword_76D554_terrain_cell_world_pos_around_party_y; // weak -extern int dword_76D558_terrain_cell_world_pos_around_party_z; // weak -extern int dword_76D55C_terrain_cell_world_pos_around_party_z; // weak -extern int dword_76D560_terrain_cell_world_pos_around_party_z; // weak -extern int dword_76D564_terrain_cell_world_pos_around_party_z; // weak -extern int dword_76D568_terrain_cell_world_pos_around_party_x; // weak -extern int dword_76D56C_terrain_cell_world_pos_around_party_x; // weak -extern int dword_76D570_terrain_cell_world_pos_around_party_x; // weak -extern int dword_76D574_terrain_cell_world_pos_around_party_x; // weak +//extern int dword_76D548_terrain_cell_world_pos_around_party_y; // weak +//extern int dword_76D54C_terrain_cell_world_pos_around_party_y; // weak +//extern int dword_76D550_terrain_cell_world_pos_around_party_y; // weak +//extern int dword_76D554_terrain_cell_world_pos_around_party_y; // weak +//extern int dword_76D558_terrain_cell_world_pos_around_party_z; // weak +//extern int dword_76D55C_terrain_cell_world_pos_around_party_z; // weak +//extern int dword_76D560_terrain_cell_world_pos_around_party_z; // weak +//extern int dword_76D564_terrain_cell_world_pos_around_party_z; // weak +//extern int dword_76D568_terrain_cell_world_pos_around_party_x; // weak +//extern int dword_76D56C_terrain_cell_world_pos_around_party_x; // weak +//extern int dword_76D570_terrain_cell_world_pos_around_party_x; // weak +//extern int dword_76D574_terrain_cell_world_pos_around_party_x; // weak extern char byte_76D5C0; extern struct unk_F7B60C stru_76D578; extern struct unk_F7B60C stru_76D590; @@ -1858,7 +1858,7 @@ void __cdecl identify_item(); void __thiscall sub_416B01(void *_this); void __thiscall sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(struct Vec2_int_ *_this); -void __thiscall UI_OnMouseLeftClick(int *pXY); // idb +void UI_OnMouseLeftClick(int *pXY); // idb void __thiscall sub_417871(int *pXY); void __cdecl sub_4178C4(); void __cdecl sub_4178E1(); @@ -2000,7 +2000,7 @@ void Load_isn_spells_21_27(); void GameUI_DrawPartySpells(); __int16 __fastcall sub_441A4E(int a1); -void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags); +void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap); int __fastcall DrawSpellbook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb int __cdecl Initialize2DA(); unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize); @@ -2163,7 +2163,7 @@ int _46CEC3_get_floor_level(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID); int __fastcall sub_46D49E_prolly_get_world_y_under_party(int a1, signed int a2, int a3, int a4, int *a5, int *a6, int a7); int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4); -signed __int64 __fastcall _46DCC8_get_gravity_direction_outdoor(int a1, int a2, Vec3_int_ *a3); +void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out); unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID); int __fastcall _46DF1A_collide_against_actor(int, int); // weak void __cdecl _46E0B2_collide_against_decorations(); @@ -2225,7 +2225,7 @@ void __cdecl sub_481ED9_MessWithOutdoorCamera(); bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5); signed int __fastcall sub_481FC9(RenderVertexSoft *_ECX, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4); -bool __fastcall GetTerrainHeightsAroundParty(int a1, int a2); +bool IsTerrainSlopeTooHigh(int pos_x, int pos_y); int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4); struct stru148 *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4, int a5); signed int __cdecl const_1_0();
--- a/stru6.cpp Tue Feb 12 18:16:18 2013 +0600 +++ b/stru6.cpp Tue Feb 12 18:16:34 2013 +0600 @@ -595,11 +595,11 @@ } //----- (004A7E89) -------------------------------------------------------- -int stru6::_4A7E89_sparkles_on_actor_after_it_casts_buff(Actor *pActor, unsigned int uDiffuse) +void stru6::_4A7E89_sparkles_on_actor_after_it_casts_buff(Actor *pActor, unsigned int uDiffuse) { Actor *v3; // edi@1 int v4; // ebx@3 - int result; // eax@5 + //int result; // eax@5 Particle_ Dst; // [sp+Ch] [bp-6Ch]@1 int v7; // [sp+74h] [bp-4h]@2 signed int pActora; // [sp+80h] [bp+8h]@1 @@ -632,7 +632,6 @@ --pActora; } while ( pActora ); - return result; } //----- (004A7F74) -------------------------------------------------------- @@ -1586,11 +1585,11 @@ v24 = 16777216; LODWORD(v18) = 0; HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportZ) - LOWORD(pViewport->uViewportX)); - vsr.field_10 = v18 / 16777216; + vsr._screenspace_x_scaler_packedfloat = v18 / 0x1000000; LODWORD(v18) = 0; HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportW) - LOWORD(pViewport->uViewportY)); v26 = v18 / 16777216; - vsr.field_14 = v18 / 16777216; + vsr._screenspace_y_scaler_packedfloat = v18 / 0x1000000; vsr.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v70->uPaletteIndex, 0, 1); vsr.uTargetPitch = pRenderer->uTargetSurfacePitch; vsr.uParentBillboardID = -1; @@ -1633,7 +1632,7 @@ { v7 = pIconsFrameTable->GetFrame(*((int *)v2 + 2), v3); pRenderer->DrawTextureTransparent(*v1, 0x181u, &pIcons_LOD->pTextures[v7->uTextureID]); - pOtherOverlayList->field_3EC = 1; + pOtherOverlayList->bRedraw = true; } else {
--- a/stru6.h Tue Feb 12 18:16:18 2013 +0600 +++ b/stru6.h Tue Feb 12 18:16:34 2013 +0600 @@ -128,7 +128,7 @@ void _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(LayingItem *a1, unsigned int uDiffuse, unsigned int uTextureID, float a4); void _4A7C07(struct LayingItem *a2); void AddProjectile(struct LayingItem *a2, int a3, unsigned int uTextureID); - int _4A7E89_sparkles_on_actor_after_it_casts_buff(struct Actor *pActor, unsigned int uDiffuse); + void _4A7E89_sparkles_on_actor_after_it_casts_buff(struct Actor *pActor, unsigned int uDiffuse); void _4A7F74(int x, int y, int z); int _4A806F(struct Actor *pActor); void _4A80DC_some_stuff_sw(struct LayingItem *a2);