# HG changeset patch # User Gloval # Date 1361479955 -14400 # Node ID 3abebb74fd091fd31169cda866fd8369aa38fb18 # Parent 38bfbee60146fb12c10b4a259d51f90dc5600c51# Parent 2bc1c8d68f419c5a822c40ce5427ecb0c775a6a1 Merge diff -r 38bfbee60146 -r 3abebb74fd09 Allocator.cpp --- a/Allocator.cpp Fri Feb 22 01:28:48 2013 +0600 +++ b/Allocator.cpp Fri Feb 22 00:52:35 2013 +0400 @@ -24,7 +24,7 @@ //Allocator *v4; // esi@1 unsigned int v5; // eax@7 void *result; // eax@8 - unsigned int *pNumBuffersUsed; // ebx@12 + // unsigned int *pNumBuffersUsed; // ebx@12 unsigned int v8; // edi@15 char v9; // zf@15 int v10; // eax@16 @@ -32,6 +32,59 @@ void *v12; // eax@22 unsigned int Size; // [sp+14h] [bp+Ch]@16 + int aligned_size; + + + if ( pPrevPtrValue && !aborting_app ) + AbortWithError(); + if ( !bBigBufferAllocated && !aborting_app ) + AbortWithError(); + + if (!uSize) + return 0; + + if (((uSize & 0x80000000u) != 0) && !aborting_app) + AbortWithError(); + + if (uNumBuffersUsed == 6000 && !aborting_app) + AbortWithError(); + + ++uNumBuffersUsed; + + if (!bUseBigBuffer) + { + pMemoryBuffers[uNumBuffersUsed] = malloc(uSize); + if (pMemoryBuffers[uNumBuffersUsed]) + uMemoryBuffersSizes[uNumBuffersUsed] = uSize; + else + { + if ( !aborting_app ) + AbortWithError(); + } + } + else + { + + aligned_size =(uSize&0xFFFFFFFC) + 4; + + if ((uNextFreeOffsetInBigBuffer +aligned_size) > uBigBufferSizeAligned) + { + printf("Id: %s Size: %i", pName, aligned_size); + CreateFileDump( "Memory"); + if ( !aborting_app ) + AbortWithError(); + } + + pMemoryBuffers[uNumBuffersUsed] = (char *)(pBigBufferAligned) + uNextFreeOffsetInBigBuffer; + uMemoryBuffersSizes[uNumBuffersUsed] =aligned_size; + + if (pName) + strncpy(pMemoryBuffersNames[uNumBuffersUsed], pName, 11); + uNextFreeOffsetInBigBuffer += aligned_size; + } + return pMemoryBuffers[uNumBuffersUsed]; + + /* //v4 = this; if ( pPrevPtrValue && !aborting_app ) AbortWithError(); @@ -94,7 +147,7 @@ { result = 0; } - return result; + return result;*/ } // 720018: using guessed type int aborting_app; @@ -113,7 +166,8 @@ if (!pBigMemoryBuffer) return false; - pBigBufferAligned = (char *)pBigMemoryBuffer + -((unsigned __int16)pBigMemoryBuffer & 0xFFF) + 4096; + pBigBufferAligned = (void *)((unsigned int)(pBigMemoryBuffer) & 0xFFFF0000 + 4096); + //(char *)pBigMemoryBuffer + -((unsigned __int16)pBigMemoryBuffer & 0xFFF) + 4096; uBigBufferSizeAligned = (uNumKBytes * 1024) - 4096; uNumBuffersUsed = 0; @@ -135,6 +189,49 @@ signed int j; // edx@16 char v8; // zf@20 + + + unsigned int uBuffindx; + unsigned int indx; + + if (ptr) + { + if ((!bBigBufferAllocated)&& (!aborting_app )) + AbortWithError(); + for (indx = 0; indx <=uNumBuffersUsed; ++indx) + if (pMemoryBuffers[indx] == ptr) + break; + // if ((indx>uNumBuffersUsed)&& !aborting_app ) +// AbortWithError(); to detect memory problems - uncomment + if (!bUseBigBuffer) + free(pMemoryBuffers[indx]); + pMemoryBuffers[indx] = NULL; + uMemoryBuffersSizes[indx] = 0; + pMemoryBuffersNames[indx][0] = 0; + if (indx == (uNumBuffersUsed-1)) + { + if (indx>0) + { + uBuffindx = 0; + for (j = 0; j < uNumBuffersUsed-1; ++j) + { + if (pMemoryBuffers[j]) + uBuffindx = j; + } + uNumBuffersUsed = uBuffindx + 1; + if (bUseBigBuffer) + uNextFreeOffsetInBigBuffer = + ((long)((char*)pMemoryBuffers[uBuffindx] -(char*)pBigBufferAligned)+ uMemoryBuffersSizes[uBuffindx]); + } + else + { + uNumBuffersUsed = 0; + uNextFreeOffsetInBigBuffer = 0; + } + } + } + +/* v2 = this; if ( ptr ) { @@ -177,7 +274,7 @@ v2->uNumBuffersUsed = 0; } } - } + }*/ } // 720018: using guessed type int aborting_app; diff -r 38bfbee60146 -r 3abebb74fd09 GUIWindow.cpp --- a/GUIWindow.cpp Fri Feb 22 01:28:48 2013 +0600 +++ b/GUIWindow.cpp Fri Feb 22 00:52:35 2013 +0400 @@ -985,10 +985,10 @@ { if (!chapter->bIsSpellAvailable[i]) continue; - - v4 = (12 * pPlayer->lastOpenedSpellbookPage + pSpellbookSpellIndices[pPlayer->lastOpenedSpellbookPage][i + 1]); - CreateButton(pViewport->uViewportX + pIconPos[v4].Xpos, - pViewport->uViewportY + pIconPos[v4].Ypos, //dword_4E20D0 + v4= pPlayer->lastOpenedSpellbookPage; + //v4 = (12 * pPlayer->lastOpenedSpellbookPage + pSpellbookSpellIndices[pPlayer->lastOpenedSpellbookPage][i + 1]); + CreateButton(pViewport->uViewportX + pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Xpos, + pViewport->uViewportY + pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Ypos, //dword_4E20D0 dword_506408[i + 1]->uTextureWidth, dword_506408[i + 1]->uTextureHeight, 1, 79, 0x56u, i, 0, "", 0); diff -r 38bfbee60146 -r 3abebb74fd09 Spells.cpp --- a/Spells.cpp Fri Feb 22 01:28:48 2013 +0600 +++ b/Spells.cpp Fri Feb 22 00:52:35 2013 +0400 @@ -17,10 +17,11 @@ stru324_spell stru_4E3ACC[102]; - + //9 spellbook pages 11 spells per page 9*11 =99 +1 zero struct at 0. It counted from 1! SpellData pSpellDatas[100]={ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {1, 1, 1, 1, 60, 60, 60, 40, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + + {1, 1, 1, 1, 60, 60, 60, 40, 0, 0},//0 {2, 2, 2, 2, 110, 110, 100, 90, 768, 0}, {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, {4, 4, 4, 4, 120, 120, 120, 120, 0, 0}, @@ -31,7 +32,8 @@ {20, 20, 20, 20, 100, 100, 100, 90, 264, 0}, {25, 25, 25, 25, 100, 100, 100, 90, 268, 0}, {30, 30, 30, 30, 90, 90, 90, 90, 3855, 0}, - {1, 1, 1, 0, 60, 60, 60, 60, 0, 0}, + + {1, 1, 1, 0, 60, 60, 60, 60, 0, 0}, //1 {2, 2, 2, 2, 120, 120, 120, 100, 0, 0}, {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, {4, 4, 4, 4, 110, 100, 90, 80, 258, 0}, @@ -42,7 +44,8 @@ {20, 20, 20, 20, 100, 100, 100, 90, 2570, 0}, {25, 25, 25, 25, 250, 250, 250, 250, 0, 0}, {30, 30, 30, 30, 90, 90, 90, 90, 276, 0}, - {1, 1, 1, 1, 60, 60, 60, 20, 0, 0}, + + {1, 1, 1, 1, 60, 60, 60, 20, 0, 0}, //2 {2, 2, 2, 2, 110, 100, 90, 70, 514, 0}, {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, {4, 4, 4, 4, 110, 100, 90, 80, 1024, 0}, @@ -53,7 +56,8 @@ {20, 20, 20, 20, 200, 200, 200, 200, 0, 0}, {25, 25, 25, 25, 80, 80, 80, 80, 780, 0}, {30, 30, 30, 30, 250, 250, 250, 250, 0, 0}, - {1, 1, 1, 1, 80, 80, 80, 80, 0, 0}, + + {1, 1, 1, 1, 80, 80, 80, 80, 0, 0}, //3 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0}, {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, {4, 4, 4, 4, 110, 100, 90, 80, 773, 0}, @@ -64,7 +68,8 @@ {20, 20, 20, 20, 150, 150, 150, 150, 0, 0}, {25, 25, 25, 25, 100, 100, 100, 90, 276, 0}, {30, 30, 30, 30, 90, 90, 90, 90, 25, 0}, - {1, 1, 1, 1, 100, 100, 100, 100, 0, 0}, + + {1, 1, 1, 1, 100, 100, 100, 100, 0, 0}, //4 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0}, {3, 3, 3, 3, 90, 90, 90, 90, 0, 0}, {4, 4, 4, 4, 120, 120, 120, 120, 0, 0}, @@ -75,7 +80,8 @@ {20, 20, 20, 20, 240, 240, 240, 240, 0, 0}, {25, 25, 25, 25, 150, 150, 150, 150, 0, 0}, {30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0}, - {1, 1, 1, 1, 120, 120, 120, 120, 0, 0}, + + {1, 1, 1, 1, 120, 120, 120, 120, 0, 0}, //5 {2, 2, 2, 2, 110, 110, 110, 110, 771, 0}, {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, {4, 4, 4, 4, 110, 100, 90, 80, 0, 0}, @@ -86,7 +92,8 @@ {20, 20, 20, 20, 120, 120, 120, 120, 0, 0}, {25, 25, 25, 25, 110, 110, 110, 100, 268, 0}, {30, 30, 30, 30, 120, 120, 120, 120, 0, 0}, - {1, 1, 1, 1, 120, 120, 120, 120, 0, 0}, + + {1, 1, 1, 1, 120, 120, 120, 120, 0, 0}, //6 {2, 2, 2, 2, 100, 100, 100, 100, 0, 0}, {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, {4, 4, 4, 4, 110, 100, 90, 80, 520, 0}, @@ -97,7 +104,8 @@ {20, 20, 20, 20, 120, 120, 120, 120, 0, 0}, {25, 25, 25, 25, 110, 110, 110, 100, 1310, 0}, {30, 30, 30, 30, 100, 100, 100, 100, 0, 0}, - {5, 5, 5, 5, 110, 100, 90, 80, 1024, 0}, + + {5, 5, 5, 5, 110, 100, 90, 80, 1024, 0}, //7 {10, 10, 10, 10, 120, 110, 100, 90, 4112, 0}, {15, 15, 15, 15, 120, 110, 100, 90, 0, 0}, {20, 20, 20, 20, 160, 140, 120, 100, 0, 0}, @@ -108,7 +116,8 @@ {45, 45, 45, 45, 250, 250, 250, 250, 0, 0}, {50, 50, 50, 50, 150, 150, 150, 135, 5140, 0}, {55, 55, 55, 55, 300, 300, 300, 300, 0, 0}, - {10, 10, 10, 10, 140, 140, 140, 140, 0, 0}, + + {10, 10, 10, 10, 140, 140, 140, 140, 0, 0}, //8 {15, 15, 15, 15, 120, 110, 100, 90, 2585, 0}, {20, 20, 20, 20, 120, 100, 90, 120, 0, 0}, {25, 25, 25, 25, 120, 120, 120, 120, 0, 0}, @@ -122,7 +131,7 @@ }; unsigned char pSpellbookSpellIndices[9][12] = // 4E2430 - { + { //0 1 2 3 4 5 6 7 8 9 10 11 {0, 3, 1, 8, 11, 7, 4, 10, 6, 2, 5, 9}, {0, 11, 2, 9, 6, 8, 5, 10, 3, 7, 1, 4}, {0, 4, 8, 9, 1, 10, 3, 11, 7, 6, 2, 5}, @@ -134,123 +143,43 @@ {0, 9, 3, 7, 1, 5, 2, 10, 11, 8, 6, 4} }; - struct SpellBookIconPos pIconPos[108]={ - {0, 0}, - {17, 13}, - {115, 2}, - {217, 15}, - {299, 6}, - {28, 125}, - {130, 133}, - {294, 114}, - {11, 232}, - {134, 233}, - {237, 171}, - {296, 231}, + struct SpellBookIconPos pIconPos[9][12]={ + + {{ 0, 0}, { 17, 13}, {115, 2}, {217, 15}, + {299, 6}, { 28, 125}, {130, 133}, {294, 114}, + { 11, 232}, {134, 233}, {237, 171}, {296, 231}}, - {0, 0}, - {19, 9}, - {117, 3}, - {206, 13}, - {285, 7}, - {16, 123}, - {113, 101}, - {201, 118}, - {317, 110}, - {11, 230}, - {149, 236}, - {296, 234}, + {{ 0, 0}, {19, 9}, {117, 3}, {206, 13}, + {285, 7}, {16, 123}, {113, 101}, {201, 118}, + {317, 110}, {11, 230}, {149, 236}, {296, 234}}, - {0, 0}, - {17, 9}, - {140, 0}, - {210, 34}, - {293, 5}, - {15, 98}, - {78, 121}, - {175, 136}, - {301, 115}, - {15, 226}, - {154, 225}, - {272, 220}, + {{ 0, 0}, {17, 9}, {140, 0}, {210, 34}, + {293, 5}, {15, 98}, { 78, 121}, {175, 136}, + {301, 115}, {15, 226}, {154, 225}, {272, 220}}, - {0, 0}, - {7, 9}, - {156, 2}, - {277, 9}, - {11, 117}, - {111, 82}, - {180, 102}, - {303, 108}, - {10, 229}, - {120, 221}, - {201, 217}, - {296, 225}, + {{ 0, 0}, { 7, 9}, {156, 2}, {277, 9}, + { 11, 117}, {111, 82}, {180, 102}, {303, 108}, + { 10, 229}, {120, 221}, {201, 217}, {296, 225}}, - {0, 0}, - {18, 8}, - {89, 15}, - {192, 14}, - {292, 7}, - {22, 129}, - {125, 146}, - {217, 136}, - {305, 115}, - {22, 226}, - {174, 237}, - {290, 231}, + {{ 0, 0}, {18, 8}, { 89, 15}, {192, 14}, + {292, 7}, {22, 129}, {125, 146}, {217, 136}, + {305, 115}, {22, 226}, {174, 237}, {290, 231}}, - {0, 0}, - {18, 12}, - {148, 9}, - {292, 7}, - {17, 122}, - {121, 99}, - {220, 87}, - {293, 112}, - {13, 236}, - {128, 213}, - {220, 223}, - {315, 223}, + {{ 0, 0}, { 18, 12}, {148, 9}, {292, 7}, + { 17, 122}, {121, 99}, {220, 87}, {293, 112}, + { 13, 236}, {128, 213}, {220, 223}, {315, 223}}, - {0, 0}, - {23, 14}, - {127, 8}, - {204, 0}, - {306, 8}, - {14, 115}, - {122, 132}, - {200, 116}, - {293, 122}, - {20, 228}, - {154, 228}, - {294, 239}, + {{ 0, 0}, {23, 14}, {127, 8}, {204, 0}, + {306, 8}, {14, 115}, {122, 132}, {200, 116}, + {293, 122}, {20, 228}, {154, 228}, {294, 239}}, - {0, 0}, - {19, 14}, - {124, 10}, - {283, 12}, - {8, 105}, - {113, 89}, - {190, 82}, - {298, 108}, - {18, 181}, - {101, 204}, - {204, 203}, - {285, 218}, + {{ 0, 0}, { 19, 14}, {124, 10}, {283, 12}, + { 8, 105}, {113, 89}, {190, 82}, {298, 108}, + { 18, 181}, {101, 204}, {204, 203}, {285, 218}}, - {0, 0}, - {18, 17}, - {110, 16}, - {201, 15}, - {307, 15}, - {18, 148}, - {125, 166}, - {201, 123}, - {275, 120}, - {28, 235}, - {217, 222}, - {324, 216} }; + {{ 0, 0}, {18, 17}, {110, 16}, {201, 15}, + {307, 15}, {18, 148}, {125, 166}, {201, 123}, + {275, 120}, {28, 235}, {217, 222}, {324, 216}}}; //----- (0042EB31) -------------------------------------------------------- diff -r 38bfbee60146 -r 3abebb74fd09 Spells.h --- a/Spells.h Fri Feb 22 01:28:48 2013 +0600 +++ b/Spells.h Fri Feb 22 00:52:35 2013 +0400 @@ -126,10 +126,17 @@ #pragma pack(push, 1) struct SpellData { +union + { + unsigned __int16 mana_per_skill[4]; + struct + { unsigned __int16 uNormalLevelMana; unsigned __int16 uExpertLevelMana; unsigned __int16 uMasterLevelMana; unsigned __int16 uMagisterLevelMana; + }; + }; unsigned __int16 field_8; __int16 field_A; __int16 field_C; @@ -154,7 +161,7 @@ extern struct SpellStats *pSpellStats; -extern struct SpellBookIconPos pIconPos[108]; +extern struct SpellBookIconPos pIconPos[9][12]; extern stru324_spell stru_4E3ACC[]; extern SpellData pSpellDatas[100]; \ No newline at end of file diff -r 38bfbee60146 -r 3abebb74fd09 mm7_2.cpp --- a/mm7_2.cpp Fri Feb 22 01:28:48 2013 +0600 +++ b/mm7_2.cpp Fri Feb 22 00:52:35 2013 +0400 @@ -11705,6 +11705,7 @@ { case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam); }; + v4 = lParam; if ( Msg > WM_SYSCOMMAND ) @@ -12200,6 +12201,7 @@ { if ( !(dword_6BE364_game_settings_1 & 0x100) ) { + while(initing); //ADDED spinlock to allow int players ets! Gloval dword_4E98BC_bApplicationActive = 0; if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie ) pVideoPlayer->bStopBeforeSchedule = 1; @@ -12852,6 +12854,7 @@ //----- (004651F4) -------------------------------------------------------- bool MM7_Initialize() { +initing=true; //ADDED Gloval wchar_t pCurrentDir[1024]; _wgetcwd(pCurrentDir, 1024); @@ -13235,6 +13238,7 @@ { uTurnSpeed = (unsigned int)uCPUSpeed < 0xC7 ? 128 : 64; // adjust turn speed to estimated fps } + initing=false; //ADDED Gloval return true; } diff -r 38bfbee60146 -r 3abebb74fd09 mm7_3.cpp --- a/mm7_3.cpp Fri Feb 22 01:28:48 2013 +0600 +++ b/mm7_3.cpp Fri Feb 22 00:52:35 2013 +0400 @@ -14211,168 +14211,168 @@ //----- (00443FDC) -------------------------------------------------------- void OnMapLoad() -{ - stru176 *v3; // esi@7 - __int16 v4; // cx@9 - __int16 v5; // di@9 - int v6; // eax@9 - signed __int64 v8; // qax@26 - unsigned int v9; // ecx@26 - signed __int64 v10; // qax@26 - signed __int64 v11; // qax@26 - int v12; // ST50_4@26 - signed __int64 v13; // qax@26 - signed __int64 v14; // qax@26 - int v15; // ST58_4@26 - signed __int64 v16; // qax@26 - int hours; // ebx@26 - unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 - signed __int64 seconds; // [sp+14h] [bp-3Ch]@26 - unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 - int minutes; // [sp+2Ch] [bp-24h]@26 - int month; // [sp+34h] [bp-1Ch]@26 - int weeks; // [sp+38h] [bp-18h]@26 - int v26; // [sp+3Ch] [bp-14h]@15 - int days; // [sp+3Ch] [bp-14h]@26 - int v28; // [sp+40h] [bp-10h]@26 - __int16 v29; // [sp+46h] [bp-Ah]@9 - __int16 v30; // [sp+48h] [bp-8h]@9 - __int16 v31; // [sp+4Ah] [bp-6h]@9 - __int16 v32; // [sp+4Ch] [bp-4h]@9 - __int16 v33; // [sp+4Eh] [bp-2h]@9 - - for (uint i = 0; i < uLevelEVT_NumEvents; ++i) - { - auto pEvent = pLevelEVT_Index[i]; - - auto _evt = (_evt_raw *)(pLevelEVT + pEvent.uEventOffsetInEVT); - - if (_evt->_e_type == EVENT_PlaySound) - { - pSoundList->LoadSound( - _evt->v5 + - ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8), - 0); - } - else if (_evt->_e_type == EVENT_OnMapReload) - { - start_event_seq_number = pEvent.event_sequence_num; - EventProcessor(pEvent.uEventID, 0, 0); - start_event_seq_number = 0; - } - else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_OnLongTimer) - { - v3 = &array_5B5928_timers[dword_5B65C8_timers_count]; - v20 = pOutdoor->uLastVisitDay; - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - v20 = pIndoor->stru1.uLastVisitDay; - - v3->timer_evt_type = _evt->_e_type; - v3->timer_evt_ID = pEvent.uEventID; - v3->timer_evt_seq_num = pEvent.event_sequence_num; - - v3->field_10 = _evt->v5; - v3->field_12 = _evt->v6; - v3->field_14 = _evt->v7; - v3->field_16 = _evt->v8; - v3->field_18 = _evt->v9; - v3->field_1A = _evt->v10; - - - v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; - - v3->field_C = ((unsigned short)_evt->v12 << 8) + _evt->v11; - v3->field_E = ((unsigned short)_evt->v12 << 8) + _evt->v11; - if (v3->timer_evt_type == EVENT_OnLongTimer && !(short)v6 ) - { - if ( v20 ) - v18 = pParty->uTimePlayed - v20; - else - v18 = 0i64; - v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; - - if ( v26 / 7 / 4 / 12 ) - { - if ( v5 ) - { - ++dword_5B65C8_timers_count; - v3->field_0_time = 0; - continue; - } - } - if (v26 / 7 / 4 != 0 && v33 != 0 || - v26 / 7 != 0 && v32 != 0 || - v26 != 0 || !v20) - { - ++dword_5B65C8_timers_count; - v3->field_0_time = 0; - continue; - } - } - else - { - v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); - v9 = v8; - v10 = (signed int)v8 / 60; - minutes = v10 % 60; - v11 = (signed int)(v10 / 60); - v12 = v11 % 24; - v13 = (signed int)(v11 / 24); - days = v13 % 7; - v14 = (signed int)(v13 / 7); - v15 = v14 % 4; - v16 = (signed int)(v14 / 4); - month = v16 / 12; - - auto _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32; - auto _2 = ((__int64)v9 << 32) | _1; - - seconds = _2 % 60; - //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32, - // v9) - // % 60; - - hours = v12; - weeks = v15; - v28 = v16 % 12; - if ( v5 ) - { - ++month; - } - else - { - if ( v33 ) - { - ++v28; - } - else - { - if ( v32 ) - { - ++weeks; - } - else - { - ++days; - minutes = v30; - hours = v31; - seconds = v29; - } - } - } - v3->field_0_time = (signed __int64)((double)((seconds - + 60 * minutes - + 3600 * hours - + 0x93A80 * weeks - + 0x15180 * days - + 0x24EA00 * (v28 + 12i64 * month)) << 7) - * 0.033333335); - - ++dword_5B65C8_timers_count; - } - } - } -} + { + stru176 *v3; // esi@7 + __int16 v4; // cx@9 + __int16 v5; // di@9 + int v6; // eax@9 + signed __int64 v8; // qax@26 + unsigned int v9; // ecx@26 + signed __int64 v10; // qax@26 + signed __int64 v11; // qax@26 + int v12; // ST50_4@26 + signed __int64 v13; // qax@26 + signed __int64 v14; // qax@26 + int v15; // ST58_4@26 + signed __int64 v16; // qax@26 + int hours; // ebx@26 + unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 + signed __int64 seconds; // [sp+14h] [bp-3Ch]@26 + unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 + int minutes; // [sp+2Ch] [bp-24h]@26 + int years; // [sp+34h] [bp-1Ch]@26 + int weeks; // [sp+38h] [bp-18h]@26 + int v26; // [sp+3Ch] [bp-14h]@15 + int days; // [sp+3Ch] [bp-14h]@26 + int months; // [sp+40h] [bp-10h]@26 + __int16 v29; // [sp+46h] [bp-Ah]@9 + __int16 v30; // [sp+48h] [bp-8h]@9 + __int16 v31; // [sp+4Ah] [bp-6h]@9 + __int16 v32; // [sp+4Ch] [bp-4h]@9 + __int16 v33; // [sp+4Eh] [bp-2h]@9 + + for (uint i = 0; i < uLevelEVT_NumEvents; ++i) + { + auto pEvent = pLevelEVT_Index[i]; + + auto _evt = (_evt_raw *)(pLevelEVT + pEvent.uEventOffsetInEVT); + + if (_evt->_e_type == EVENT_PlaySound) + { + pSoundList->LoadSound( + _evt->v5 + + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8), + 0); + } + else if (_evt->_e_type == EVENT_OnMapReload) + { + start_event_seq_number = pEvent.event_sequence_num; + EventProcessor(pEvent.uEventID, 0, 0); + start_event_seq_number = 0; + } + else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_OnLongTimer) + { + v3 = &array_5B5928_timers[dword_5B65C8_timers_count]; + v20 = pOutdoor->uLastVisitDay; + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + v20 = pIndoor->stru1.uLastVisitDay; + + v3->timer_evt_type = _evt->_e_type; + v3->timer_evt_ID = pEvent.uEventID; + v3->timer_evt_seq_num = pEvent.event_sequence_num; + + v3->field_10 = _evt->v5; + v3->field_12 = _evt->v6; + v3->field_14 = _evt->v7; + v3->field_16 = _evt->v8; + v3->field_18 = _evt->v9; + v3->field_1A = _evt->v10; + + + v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; + + v3->field_C = ((unsigned short)_evt->v12 << 8) + _evt->v11; + v3->field_E = ((unsigned short)_evt->v12 << 8) + _evt->v11; + if (v3->timer_evt_type == EVENT_OnLongTimer && !(short)v6 ) + { + if ( v20 ) + v18 = pParty->uTimePlayed - v20; + else + v18 = 0i64; + v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; + + if ( v26 / 7 / 4 / 12 ) + { + if ( v3->field_10 ) + { + ++dword_5B65C8_timers_count; + v3->field_0_time = 0; + continue; + } + } + if (v26 / 7 / 4 != 0 && v3->field_12 != 0 || + v26 / 7 != 0 && v3->field_14 != 0 || + v26 != 0 || !v20) + { + ++dword_5B65C8_timers_count; + v3->field_0_time = 0; + continue; + } + } + else + { + v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); + v9 = v8; + v10 = (signed int)v8 / 60; + minutes = v10 % 60; + v11 = (signed int)(v10 / 60); + v12 = v11 % 24; + v13 = (signed int)(v11 / 24); + days = v13 % 7; + v14 = (signed int)(v13 / 7); + v15 = v14 % 4; + v16 = (signed int)(v14 / 4); + years = v16 / 12; + + auto _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32; + auto _2 = ((__int64)v9 << 32) | _1; + + seconds = _2 % 60; + //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32, + // v9) + // % 60; + + hours = v12; + weeks = v15; + months = v16 % 12; + if ( v3->field_10 ) + { + ++years; + } + else + { + if ( v3->field_12 ) + { + ++months; + } + else + { + if ( v3->field_14 ) + { + ++weeks; + } + else + { + ++days; + minutes = v3->field_18; + hours = v3->field_16; + seconds = v3->field_1A; + } + } + } + v3->field_0_time = (signed __int64)((double)((seconds + + 60 * minutes + + 3600 * hours + + 0x93A80 * weeks + + 0x15180 * days + + 0x24EA00 * (months + 12i64 * years)) << 7) + * 0.033333335); + + ++dword_5B65C8_timers_count; + } + } + } + } //----- (00444360) -------------------------------------------------------- void __thiscall Level_LoadEvtAndStr(const char *pLevelName) @@ -15116,7 +15116,7 @@ strcpy(v14->pButtonName, GetProfessionActionText(pNPC->uProfession)); else if (v16 == 19) { - __debugbreak(); // learn conditions of this event + // __debugbreak(); // learn conditions of this event Scavenger Hunt auto topic = pNPCTopics[pNPC->evt_A - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { diff -r 38bfbee60146 -r 3abebb74fd09 mm7_5.cpp --- a/mm7_5.cpp Fri Feb 22 01:28:48 2013 +0600 +++ b/mm7_5.cpp Fri Feb 22 00:52:35 2013 +0400 @@ -13050,7 +13050,7 @@ } //----- (00410B28) -------------------------------------------------------- -void __thiscall DrawSpellDescriptionPopup(void *_this) +void __thiscall DrawSpellDescriptionPopup(int spell_index) { Player *v1; // edi@1 SpellInfo *v2; // esi@1 @@ -13061,14 +13061,14 @@ char *v7; // ST44_4@12 unsigned __int16 v8; // ax@12 GUIWindow a1; // [sp+Ch] [bp-68h]@4 - void *v10; // [sp+60h] [bp-14h]@1 + int v10; // [sp+60h] [bp-14h]@1 POINT a2; // [sp+64h] [bp-10h]@1 int v12; // [sp+6Ch] [bp-8h]@4 int v13; // [sp+70h] [bp-4h]@4 v1 = pPlayers[uActiveCharacter]; - v10 = _this; - v2 = &pSpellStats->pInfos[(signed int)((char *)_this + 11 * v1->lastOpenedSpellbookPage) + 1]; + v10 = spell_index; + v2 = &pSpellStats->pInfos[spell_index + 11 * v1->lastOpenedSpellbookPage + 1]; if ( pMouse->GetCursorPos(&a2)->y <= 250 ) v3 = pMouse->GetCursorPos(&a2)->y + 30; else @@ -13080,10 +13080,10 @@ a1.uFrameZ = 417; a1.uFrameW = v3 + 67; a1.Hint = 0; - a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]); - v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]); - v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]); - v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]); + a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_NORMAL]); + v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_MASTER]); + v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_EXPERT]); + v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_GRAND]); v5 = a2.y; if ( v13 > a2.y ) v5 = v13; @@ -13091,25 +13091,20 @@ v5 = v12; if ( v4 > v5 ) v5 = v4; - sprintf( - pTmpBuf2, + sprintf( pTmpBuf2, "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s", v2->pDescription, - pGlobalTXT_LocalizationStrings[431], - v5 + 3, - v5 + 10, + pGlobalTXT_LocalizationStrings[LOCSTR_NORMAL], + v5 + 3, v5 + 10, v2->pBasicSkillDesc, - pGlobalTXT_LocalizationStrings[433], - v5 + 3, - v5 + 10, + pGlobalTXT_LocalizationStrings[LOCSTR_EXPERT], + v5 + 3, v5 + 10, v2->pExpertSkillDesc, - pGlobalTXT_LocalizationStrings[432], - v5 + 3, - v5 + 10, + pGlobalTXT_LocalizationStrings[LOCSTR_MASTER], + v5 + 3, v5 + 10, v2->pMasterSkillDesc, - pGlobalTXT_LocalizationStrings[96], - v5 + 3, - v5 + 10, + pGlobalTXT_LocalizationStrings[LOCSTR_GRAND], + v5 + 3, v5 + 10, v2->pGrandmasterSkillDesc); v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2, &a1, 0, 0); a1.uFrameHeight += v6; @@ -13128,13 +13123,11 @@ a1.uFrameWidth = 108; a1.uFrameZ = a1.uFrameX + 107; a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->lastOpenedSpellbookPage + 12], 3u); - sprintf( - pTmpBuf, - "%s\n%d", - pGlobalTXT_LocalizationStrings[522], - *(&pSpellDatas[0].field_12 //temp_fix field_14 - + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->lastOpenedSpellbookPage + 12]) >> 6) - + 10 * (int)((char *)v10 + 11 * v1->lastOpenedSpellbookPage))); + sprintf( pTmpBuf, "%s\n%d", pGlobalTXT_LocalizationStrings[LOCSTR_SP_COST], + pSpellDatas[spell_index + 11 * v1->lastOpenedSpellbookPage + 1].mana_per_skill[v1->pActiveSkills[v1->lastOpenedSpellbookPage + PLAYER_SKILL_FIRE]]); + // *(&[0].field_12 //temp_fix field_14 + // + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->lastOpenedSpellbookPage + 12]) >> 6) + // + 10 * (int)((char *)v10 + 11 * v1->lastOpenedSpellbookPage))); a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf, 3u); dword_507B00_spell_info_to_draw_in_popup = 0; } @@ -13663,15 +13656,16 @@ } if ( v6->pLevelOfDetail0 ) { - v7 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]); - v19 = pViewport->uViewportY + pIconPos[v7].Ypos; - v17 = pViewport->uViewportX + pIconPos[v7].Xpos; + v7 = v0->lastOpenedSpellbookPage; + // v7 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]); + v19 = pViewport->uViewportY + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos; + v17 = pViewport->uViewportX + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos; if ( BYTE1(v6->pBits) & 2 ) pRenderer->DrawTextureTransparent(v17, v19, v6); else pRenderer->DrawTextureIndexed(v17, v19, v6); - v8 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]); - pRenderer->_4A612A(pIconPos[v8].Xpos,pIconPos[v8].Ypos, v23, v4); + pRenderer->_4A612A(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos, + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos, v23, v4); } } } @@ -13687,9 +13681,10 @@ if ( v11->pLevelOfDetail0 ) { v21 = dword_5063D8[v10]; - v12 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]); - v20 = pViewport->uViewportY + pIconPos[v12].Ypos; - v18 = pViewport->uViewportX + pIconPos[v12].Xpos; + v12 = v0->lastOpenedSpellbookPage; + // v12 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]); + v20 = pViewport->uViewportY + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Ypos; + v18 = pViewport->uViewportX + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Xpos; if ( BYTE1(v11->pBits) & 2 ) pRenderer->DrawTextureTransparent(v18, v20, v21); else @@ -16520,7 +16515,7 @@ 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)); + DrawSpellDescriptionPopup(dword_507B00_spell_info_to_draw_in_popup - 1); } goto LABEL_132; } diff -r 38bfbee60146 -r 3abebb74fd09 mm7_data.cpp --- a/mm7_data.cpp Fri Feb 22 01:28:48 2013 +0600 +++ b/mm7_data.cpp Fri Feb 22 00:52:35 2013 +0400 @@ -2304,6 +2304,8 @@ int dword_F93F20; // weak int dword_F93F70; // weak +volatile bool initing; + //int crt_F94004; // weak //int crtdword_F9400C; // weak FARPROC lpfn; // idb \ No newline at end of file diff -r 38bfbee60146 -r 3abebb74fd09 mm7_data.h --- a/mm7_data.h Fri Feb 22 01:28:48 2013 +0600 +++ b/mm7_data.h Fri Feb 22 00:52:35 2013 +0400 @@ -1720,6 +1720,8 @@ extern int dword_F93F20; // weak extern int dword_F93F70; // weak +extern volatile bool initing; //ADDED + //extern int crt_F94004; // weak //extern int crtdword_F9400C; // weak extern FARPROC lpfn; // idb @@ -1821,7 +1823,7 @@ void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue); void __fastcall sub_40F92A(int *pZBuffer, struct Texture *a2, int a3); // idb void __cdecl SetMoonPhaseNames(); -void __thiscall DrawSpellDescriptionPopup(void *_this); +void DrawSpellDescriptionPopup(int spell_index); signed int __fastcall sub_410D99_get_map_index(int a1); unsigned int __cdecl DrawLloydBeaconsScreen(); char *__cdecl DrawTownPortalScreen();