# HG changeset patch # User Grumpy7 # Date 1396781435 -7200 # Node ID dc822157c98da6b8e0b86cf35a3fe54a4585ff76 # Parent 63e1388c546336df3fc33ad7603087a61b256724 Moving functions from unsorted_subs.h pt4 diff -r 63e1388c5463 -r dc822157c98d GUIWindow.h --- a/GUIWindow.h Sun Apr 06 12:37:28 2014 +0200 +++ b/GUIWindow.h Sun Apr 06 12:50:35 2014 +0200 @@ -606,6 +606,8 @@ struct GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey); // idb int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall); void DrawBuff_remaining_time_string(int uY, struct GUIWindow *window, __int64 remaining_time, struct GUIFont *Font); +void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb +void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *window); void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue); diff -r 63e1388c5463 -r dc822157c98d Items.cpp --- a/Items.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/Items.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -16,6 +16,7 @@ #include "StorylineTextTable.h" #include "texts.h" #include "mm7_data.h" +#include "OurMath.h" struct ITEM_VARIATION diff -r 63e1388c5463 -r dc822157c98d OurMath.cpp --- a/OurMath.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/OurMath.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -198,4 +198,55 @@ int fixpoint_from_int(int lhv, int rhv) { return (lhv << 16) | rhv; -} \ No newline at end of file +} + + +//----- (00452A9E) -------------------------------------------------------- +int integer_sqrt(int val) +{ + signed int result; // eax@2 + unsigned int v2; // edx@3 + unsigned int v3; // edi@3 + //signed int v4; // ebx@3 + int v5; // esi@4 + + if (val < 1) + return val; + + v2 = 0; + v3 = val; + result = 0; + //v4 = 16; + for (uint i = 0; i < 16; ++i) + { + result *= 2; + v2 = (v3 >> 30) | 4 * v2; + v5 = 2 * result + 1; + v3 *= 4; + if ( v2 >= v5 ) + { + ++result; + v2 -= v5; + } + //--v4; + } + //while ( v4 ); + if ( val - result * result >= (unsigned int)(result - 1) ) + ++result; + return result; +} + +//----- (00452B2E) -------------------------------------------------------- +int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) +{ + int v3; // esi@1 + + v3 = 0; + if ( uDiceSides ) + { + for ( uint i = 0; i < uNumDice; ++i) + v3 += rand() % uDiceSides + 1; + return v3; + } + return 0; +} diff -r 63e1388c5463 -r dc822157c98d OurMath.h --- a/OurMath.h Sun Apr 06 12:37:28 2014 +0200 +++ b/OurMath.h Sun Apr 06 12:50:35 2014 +0200 @@ -30,6 +30,9 @@ __int64 fixpoint_sub_unknown(int, int); int fixpoint_from_float(float value); int fixpoint_from_int(int lhv, int rhv); +int integer_sqrt(int val); +int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb +inline int round_to_int(float x) { return (int)floor(x + 0.5f); } template inline int bankersRounding(const FloatType& value) diff -r 63e1388c5463 -r dc822157c98d Outdoor.cpp --- a/Outdoor.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/Outdoor.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -3147,7 +3147,7 @@ check_event_triggers(); } //----- (0041F54A) -------------------------------------------------------- -void LoadActualSkyFrame() +void OutdoorLocation::LoadActualSkyFrame() { if ( pTexture_RestUI_CurrentSkyFrame ) pTexture_RestUI_CurrentSkyFrame->Release(); diff -r 63e1388c5463 -r dc822157c98d Outdoor.h --- a/Outdoor.h Sun Apr 06 12:37:28 2014 +0200 +++ b/Outdoor.h Sun Apr 06 12:50:35 2014 +0200 @@ -168,6 +168,8 @@ void SetFog(); void Draw(); + static void LoadActualSkyFrame(); + char pLevelFilename[32]; char pLocationFileName[32]; diff -r 63e1388c5463 -r dc822157c98d Party.cpp --- a/Party.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/Party.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -849,7 +849,7 @@ pParty->UpdatePlayersAndHirelingsEmotions(); } //----- (0041F5BE) -------------------------------------------------------- -void Sleep6Hours() +void Party::Sleep6Hours() { if ( _506F18_num_minutes_to_sleep < 6 ) { @@ -857,7 +857,7 @@ { Rest(_506F18_num_minutes_to_sleep); _506F18_num_minutes_to_sleep = 0; - LoadActualSkyFrame(); + OutdoorLocation::LoadActualSkyFrame(); } if ( dword_506F14 == 2 ) { @@ -868,7 +868,7 @@ { Rest(6u); _506F18_num_minutes_to_sleep -= 6; - LoadActualSkyFrame(); + OutdoorLocation::LoadActualSkyFrame(); } viewparams->bRedrawGameUI = 1; } diff -r 63e1388c5463 -r dc822157c98d Party.h --- a/Party.h Sun Apr 06 12:37:28 2014 +0200 +++ b/Party.h Sun Apr 06 12:50:35 2014 +0200 @@ -202,6 +202,8 @@ static void TakeFood(unsigned int uNumFood); static void GiveFood(unsigned int _this); + static void Sleep6Hours(); + inline bool WizardEyeActive() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;} inline int WizardEyeSkillLevel() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;} inline bool TorchlightActive() {return pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0;} diff -r 63e1388c5463 -r dc822157c98d Player.cpp --- a/Player.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/Player.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -32,6 +32,7 @@ #include "SpriteObject.h" #include "DecalBuilder.h" #include "CastSpellInfo.h" +#include "OurMath.h" diff -r 63e1388c5463 -r dc822157c98d Spells.cpp --- a/Spells.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/Spells.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -1,6 +1,5 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include "mm7_unsorted_subs.h" #include "ErrorHandling.h" #include "Spells.h" diff -r 63e1388c5463 -r dc822157c98d Sprites.cpp --- a/Sprites.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/Sprites.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -9,7 +9,6 @@ #include "FrameTableInc.h" #include "mm7_data.h" -#include "mm7_unsorted_subs.h" #include "Outdoor.h" #include "DecorationList.h" #include "MM7.h" diff -r 63e1388c5463 -r dc822157c98d UI/UIRest.cpp --- a/UI/UIRest.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/UI/UIRest.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -64,7 +64,7 @@ uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); - LoadActualSkyFrame(); + OutdoorLocation::LoadActualSkyFrame(); pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Rest, 0, 0); pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); @@ -158,7 +158,7 @@ sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);//Год pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, Color16(10, 0, 0), pTmpBuf.data(), 0, 0, Color16(230, 214, 193)); if ( dword_506F14 ) - Sleep6Hours(); + Party::Sleep6Hours(); } else GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, diff -r 63e1388c5463 -r dc822157c98d mm7_2.cpp --- a/mm7_2.cpp Sun Apr 06 12:37:28 2014 +0200 +++ b/mm7_2.cpp Sun Apr 06 12:50:35 2014 +0200 @@ -1877,56 +1877,6 @@ + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00)); } -//----- (00452A9E) -------------------------------------------------------- -int integer_sqrt(int val) -{ - signed int result; // eax@2 - unsigned int v2; // edx@3 - unsigned int v3; // edi@3 - //signed int v4; // ebx@3 - int v5; // esi@4 - - if (val < 1) - return val; - - v2 = 0; - v3 = val; - result = 0; - //v4 = 16; - for (uint i = 0; i < 16; ++i) - { - result *= 2; - v2 = (v3 >> 30) | 4 * v2; - v5 = 2 * result + 1; - v3 *= 4; - if ( v2 >= v5 ) - { - ++result; - v2 -= v5; - } - //--v4; - } - //while ( v4 ); - if ( val - result * result >= (unsigned int)(result - 1) ) - ++result; - return result; -} - -//----- (00452B2E) -------------------------------------------------------- -int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) -{ - int v3; // esi@1 - - v3 = 0; - if ( uDiceSides ) - { - for ( uint i = 0; i < uNumDice; ++i) - v3 += rand() % uDiceSides + 1; - return v3; - } - return 0; -} - //----- (004547E4) -------------------------------------------------------- diff -r 63e1388c5463 -r dc822157c98d mm7_unsorted_subs.h --- a/mm7_unsorted_subs.h Sun Apr 06 12:37:28 2014 +0200 +++ b/mm7_unsorted_subs.h Sun Apr 06 12:50:35 2014 +0200 @@ -19,10 +19,6 @@ bool __fastcall sub_4077F1(int a1, int a2, int a3, struct ODMFace *face, struct BSPVertexBuffer *a5); bool __fastcall sub_407A1C(int x, int z, int y, struct Vec3_int_ v); // idb int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6); -void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb -void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *window); -void LoadActualSkyFrame(); -void Sleep6Hours(); void ChestUI_WritePointedObjectStatusString(); void OnChestLeftClick(); void GameUI_WritePointedObjectStatusString(); @@ -249,9 +245,6 @@ void RespawnGlobalDecorations(); bool __fastcall SpawnActor(unsigned int uMonsterID); int GetAlertStatus(); -int integer_sqrt(int val); -int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb -inline int round_to_int(float x) { return (int)floor(x + 0.5f); } inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count) { unsigned __int32* p = (unsigned __int32 *)ptr;