Mercurial > mm7
changeset 180:c5bd7a825ef2
come back
author | Ritor1 |
---|---|
date | Fri, 15 Feb 2013 17:22:20 +0600 |
parents | f102bbff6fd8 |
children | 428cbb33872c 6764ce3cb9bb |
files | GUIFont.cpp GUIFont.h GUIWindow.cpp Sprites.cpp mm7_1.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_data.h |
diffstat | 9 files changed, 307 insertions(+), 410 deletions(-) [+] |
line wrap: on
line diff
--- a/GUIFont.cpp Fri Feb 15 17:14:24 2013 +0600 +++ b/GUIFont.cpp Fri Feb 15 17:22:20 2013 +0600 @@ -1,5 +1,5 @@ #include <string> - +#include "LOD.h" #include "GUIFont.h" #include "GUIWindow.h" #include "Render.h" @@ -7,7 +7,7 @@ #include "mm7_data.h" - +extern LODFile_IconsBitmaps *pIcons_LOD; struct GUIFont *pAutonoteFont; @@ -21,6 +21,33 @@ struct GUIFont *pFontComic; struct GUIFont *pFontSmallnum; +//----- (0044C448) -------------------------------------------------------- +GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...) + { + + int pallete_index; // eax@3 + GUIFont *pFont; + unsigned int palletes_count =0; + va_list palettes_ptr; + + pFont = (GUIFont *)pIcons_LOD->LoadRaw(pFontFile, 0); + va_start(palettes_ptr, pFontFile); + + while (NULL!=(pFontPalette=va_arg(palettes_ptr, const char *))) + { + pallete_index =pIcons_LOD->LoadTexture(pFontPalette, TEXTURE_16BIT_PALETTE); + if (pallete_index == -1) + { + wsprintfA(pTmpBuf, "Unable to open %s", pFontPalette); + Abortf(pTmpBuf); + } + pFont->pFontPalettes[palletes_count] = pIcons_LOD->pTextures[pallete_index].pPalette16; + ++palletes_count; + } + va_end(palettes_ptr); + pFont->palletes_count = palletes_count; + return pFont; + } @@ -267,7 +294,7 @@ //----- (0044C933) -------------------------------------------------------- -char *__fastcall GUIFont::_44C933(const char *pString, GUIFont *pFont, GUIFont *a3, int a4, int a5, int a6) +char * GUIFont::_44C933(const char *pString, GUIFont *pFont, GUIFont *a3, int a4, int a5, int a6) { const char *v6; // esi@1 size_t v8; // eax@3 @@ -576,127 +603,238 @@ } //----- (0044C59D) -------------------------------------------------------- -int GUIFont::CalcTextHeight(const char *pString, GUIWindow *pWindow, int a4, int a5) -{ - const char *v5; // ebx@1 - GUIFont *v6; // edi@1 - int v8; // esi@3 - size_t v9; // eax@3 - signed int v10; // ebx@3 - unsigned __int8 v11; // cl@4 - size_t pWindowa; // [sp+10h] [bp+8h]@3 - unsigned __int8 *uX; // [sp+14h] [bp+Ch]@3 +int GUIFont::CalcTextHeight(const char *pString, GUIWindow *pWindow, int uXOffset, int a5) + { + int uAllHeght; // esi@3 + unsigned int uStringLen; // eax@3 + char c; // cl@4 + char *test_string; // [sp+14h] [bp+Ch]@3 - v5 = pString; - v6 = this; - if ( !pString ) - return 0; - v8 = LOBYTE(this->uFontHeight) - 3; - uX = (unsigned __int8 *)FitTextInAWindow(pString, this, pWindow, a4, 0); - v9 = strlen(v5); - v10 = 0; - pWindowa = v9; - while ( v10 < (signed int)pWindowa ) - { - if ( v6->IsCharValid(v11 = *uX) ) - { - if ( v11 == 9 ) - goto LABEL_9; - switch ( v11 ) - { - case 0xAu: - v8 = v8 + LOBYTE(v6->uFontHeight) - 3; - break; - case 0xCu: - uX += 5; - v10 += 5; - break; - case 0xDu: -LABEL_9: - if ( a5 != 1 ) - { - uX += 3; - v10 += 3; - } - break; - } - } - ++v10; - ++uX; - } - return v8; -} + if (!pString) + return 0; + uAllHeght = this->uFontHeight - 3; + test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); + uStringLen = strlen(pString); + for (int i = 0; i < uStringLen; ++i) + { + c = test_string[i]; + if (IsCharValid(c)) + { + switch (c) + { + case '\n': //Line Feed 0A 10: + uAllHeght+= this->uFontHeight - 3; + break; + case '\f': //Form Feed, page eject 0C 12 + i += 5; + break; + case '\t': // Horizontal tab 09 + case '\r': //Carriage Return 0D 13 + if (a5 != 1) + i += 3; + break; + } + } + } + return uAllHeght; + } //----- (0044C51E) -------------------------------------------------------- int GUIFont::GetLineWidth(const char *pString) -{ - GUIFont *pFont; // edi@1 - size_t pNumLen; // ebp@3 - int v5; // esi@3 - signed int i; // ebx@3 - unsigned __int8 v7; // cl@4 - const char *pStr; // [sp+0h] [bp-4h]@1 + { + unsigned int str_len; // ebp@3 + int string_line_width; // esi@3 + unsigned char c; - pStr = pString; - pFont = this; - if ( !pString ) // == 0 - return 0; - pNumLen = strlen(pString); - v5 = 0; - for ( i = 0; i < (signed int)pNumLen; ++i ) - { - if ( IsCharValid(v7 = pStr[i]) ) - { - if ( v7 < 9u ) - { - if ( i > 0 ) - v5 += pFont->pMetrics[v7].uLeftSpacing; - v5 += *((int *)&pFont->cFirstChar + 3 * v7 + 9); - if ( i < (signed int)pNumLen ) - v5 += pFont->pMetrics[v7].uRightSpacing; - continue; - } - if ( v7 <= 0xAu ) - return v5; - if ( v7 != '\f' ) - { - if ( v7 == '\r' ) - return v5; - if ( i > 0 ) - v5 += pFont->pMetrics[v7].uLeftSpacing; - v5 += *((int *)&pFont->cFirstChar + 3 * v7 + 9); - if ( i < (signed int)pNumLen ) - v5 += pFont->pMetrics[v7].uRightSpacing; - continue; - } - i += 5; - } - } - return v5; -} - - + if (!pString) + return 0; + str_len = strlen(pString); + string_line_width = 0; + for ( int i = 0; i < str_len; ++i ) + { + c = pString[i]; + if (IsCharValid(c)) + { + switch (c) + { + case '\t': + case '\n': + case '\r': + return string_line_width; + case '\f': + i += 5; + break; + default: + if (i > 0) + string_line_width += this->pMetrics[c].uLeftSpacing; + string_line_width += this->pMetrics[c].uWidth; + if (i < str_len) + string_line_width +=this->pMetrics[c].uRightSpacing; + } + } + } + return string_line_width; + } //----- (0044C502) -------------------------------------------------------- int GUIFont::AlignText_Center(unsigned int uCenterX, const char *pString) { - signed int v3; // esi@1 - signed int result; // eax@2 + signed int position; // esi@1 + + position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; + if ( position >= 0 ) + return position; + else + return 0; - v3 = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; - if ( v3 >= 0 ) - result = v3; - else - result = 0; - return result; } +//----- (0044C768) -------------------------------------------------------- +char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5) + { + const char *v5; // edi@1 + GUIFont *v6; // esi@1 + unsigned int v8; // eax@3 + int v9; // edi@3 + unsigned __int8 v10; // cl@4 + int v11; // edx@10 + GUICharMetric *v12; // ecx@10 + int v13; // edx@11 + int v14; // edx@12 + int v15; // edx@13 + unsigned int v16; // esi@15 + unsigned int v17; // edx@15 + unsigned int v18; // ecx@15 + int v19; // ebx@16 + unsigned __int8 v20; // zf@16 + char v21; // sf@16 + unsigned __int8 v22; // of@16 + int v23; // edi@16 + unsigned __int8 v24; // dl@17 + int v25; // edi@39 + int v26; // eax@42 + std::string v27; // [sp-18h] [bp-40h]@2 + const char *v28; // [sp-8h] [bp-30h]@2 + int v29; // [sp-4h] [bp-2Ch]@2 + const char *v30; // [sp+Ch] [bp-1Ch]@1 + char Str[3]; // [sp+10h] [bp-18h]@42 + char v32; // [sp+13h] [bp-15h]@42 + size_t v33; // [sp+14h] [bp-14h]@3 + unsigned int v34; // [sp+18h] [bp-10h]@3 + GUIFont *v35; // [sp+1Ch] [bp-Ch]@1 + int v36; // [sp+20h] [bp-8h]@3 + int v37; // [sp+24h] [bp-4h]@3 -//----- (0044C4DE) -------------------------------------------------------- -bool GUIFont::IsCharValid(char _c) -{ - unsigned char c = _c; - return c >= cFirstChar && c <= cLastChar || c == '\f' || c == '\r' || c == '\t' || c == '\n'; -} \ No newline at end of file + v5 = pInString; + v6 = pFont; + v30 = pInString; + v35 = pFont; + if ( !pInString ) + { + MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); + return 0; + } + v33 = strlen(pInString); + strcpy(pTmpBuf3, v5); + v8 = uX; + v9 = 0; + v36 = 0; + v34 = uX; + v37 = 0; + if ( (signed int)v33 > 0 ) + { + while ( 1 ) + { + v10 = pTmpBuf3[v9]; + if ((v10 < v6->cFirstChar || v10 > v6->cLastChar) + && v10 != '\f' && v10 != '\r' && v10 != '\t' && v10 != '\n' ) + goto LABEL_34; + v11 = v10 - 9; + v12 = &v6->pMetrics[v10]; + if ( !v11 ) + { + strncpy(Str, &pTmpBuf3[v9 + 1], 3u); + v32 = 0; + v26 = atoi(Str); + v8 = uX + v26; + v25 = v9 + 3; + v34 = v8; + goto LABEL_43; + } + v13 = v11 - 1; + if ( !v13 ) + break; + v14 = v13 - 2; + if ( !v14 ) + { + v25 = v9 + 5; +LABEL_43: + v37 = v25; + goto LABEL_34; + } + v15 = v14 - 1; + if ( v15 ) + { + if ( v15 != 19 ) + { + v16 = v12->uRightSpacing; + v17 = v12->uWidth; + v18 = v12->uLeftSpacing; + if ( v8 + v16 + v18 + v17 < pWindow->uFrameWidth ) + { + if ( v37 > v36 ) + v8 += v18; + v8 += v17; + if ( v37 < (signed int)v33 ) + v8 += v16; + v6 = v35; + } + else + { + v19 = v36; + v8 = v34; + v22 = v36 > v37; + v20 = v36 == v37; + v21 = v36 - v37 < 0; + v6 = v35; + pTmpBuf3[v36] = 10; + v23 = v19; + if ( (unsigned __int8)(v21 ^ v22) | v20 ) + { + do + { + v24 = pTmpBuf3[v23]; + if ( v24 >= v6->cFirstChar && v24 <= v6->cLastChar || v24 == 12 || v24 == 13 || v24 == 9 || v24 == 10 ) + { + if ( v23 > v19 ) + v8 += v6->pMetrics[v24].uLeftSpacing; + v8 += *((int *)&v6->cFirstChar + 3 * v24 + 9); + if ( v23 < v37 ) + v8 += v6->pMetrics[v24].uRightSpacing; + } + ++v23; + } + while ( v23 <= v37 ); + } + } + goto LABEL_34; + } + v8 += v12->uWidth; + goto LABEL_41; + } + if ( !a5 ) + return (char *)v30; +LABEL_34: + v9 = v37++ + 1; + if ( v37 >= (signed int)v33 ) + return pTmpBuf3; + } + v8 = v34; +LABEL_41: + v36 = v9; + goto LABEL_34; + } + return pTmpBuf3; + }
--- a/GUIFont.h Fri Feb 15 17:14:24 2013 +0600 +++ b/GUIFont.h Fri Feb 15 17:22:20 2013 +0600 @@ -15,7 +15,9 @@ #pragma pack(push, 1) struct GUIFont { - bool IsCharValid(char c); + +//----- (0044C4DE) -------------------------------------------------------- + bool IsCharValid(char c) { return (c >= cFirstChar) && (c <= cLastChar) || (c == '\f') || (c == '\r') || (c == '\t') || (c == '\n');} int AlignText_Center(unsigned int uCenterX, const char *pString); int GetLineWidth(const char *pString); int CalcTextHeight(const char *pString, struct GUIWindow *pWindow, int a4, int a5); @@ -25,7 +27,7 @@ void DrawTextLine(unsigned int uDefaultColor, signed int uX, signed int uY, const char *Str, int a6); void _44D2FD_prolly_draw_credits_entry(GUIFont *pFont, int Str, int a4, unsigned int w, unsigned int h, unsigned __int16 a7, unsigned __int16 a8, const char *pString, unsigned __int16 *pPixels, unsigned int uPixelsWidth); - static char *__fastcall _44C933(const char *pString, GUIFont *pFont, GUIFont *a3, int a4, int a5, int a6); + static char * _44C933(const char *pString, GUIFont *pFont, GUIFont *a3, int a4, int a5, int a6); unsigned char cFirstChar; unsigned char cLastChar; @@ -34,15 +36,15 @@ char field_4; __int16 uFontHeight; char field_7; - int field_8; + int palletes_count; unsigned __int16 *pFontPalettes[5]; GUICharMetric pMetrics[256]; int field_C20[256]; }; #pragma pack(pop) - - +GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...); +char * FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5); extern struct GUIFont *pAutonoteFont;
--- a/GUIWindow.cpp Fri Feb 15 17:14:24 2013 +0600 +++ b/GUIWindow.cpp Fri Feb 15 17:22:20 2013 +0600 @@ -922,10 +922,10 @@ pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0); pTexture_mapbordr = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("mapbordr", TEXTURE_16BIT_PALETTE)]; - pBookFont = LoadFont("book.fnt", "FONTPAL", 0); - pBook2Font = LoadFont("book2.fnt", "FONTPAL", 0); - pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", 0); - pSpellFont = LoadFont("spell.fnt", "FONTPAL", 0); + pBookFont = LoadFont("book.fnt", "FONTPAL", NULL); + pBook2Font = LoadFont("book2.fnt", "FONTPAL", NULL); + pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", NULL); + pSpellFont = LoadFont("spell.fnt", "FONTPAL", NULL); } //----- (00411B59) --------------------------------------------------------
--- a/Sprites.cpp Fri Feb 15 17:14:24 2013 +0600 +++ b/Sprites.cpp Fri Feb 15 17:22:20 2013 +0600 @@ -11,7 +11,7 @@ -extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...); +//extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...); struct SpriteFrameTable *pSpriteFrameTable;
--- a/mm7_1.cpp Fri Feb 15 17:14:24 2013 +0600 +++ b/mm7_1.cpp Fri Feb 15 17:22:20 2013 +0600 @@ -1607,11 +1607,11 @@ pRenderer->ResetClip(); uTextureID_FONTPAL = pIcons_LOD->LoadTexture("FONTPAL", TEXTURE_16BIT_PALETTE); - pFontArrus = LoadFont("arrus.fnt", "FONTPAL", 0); - pFontLucida = LoadFont("lucida.fnt", "FONTPAL", 0); - pFontCreate = LoadFont("create.fnt", "FONTPAL", 0); - pFontSmallnum = LoadFont("smallnum.fnt", "FONTPAL", 0); - pFontComic = LoadFont("comic.fnt", "FONTPAL", 0); + pFontArrus = LoadFont("arrus.fnt", "FONTPAL", NULL); + pFontLucida = LoadFont("lucida.fnt", "FONTPAL", NULL); + pFontCreate = LoadFont("create.fnt", "FONTPAL", NULL); + pFontSmallnum = LoadFont("smallnum.fnt", "FONTPAL", NULL); + pFontComic = LoadFont("comic.fnt", "FONTPAL", NULL); pFontArrus->field_3 = 0; pFontLucida->field_3 = 0; pFontCreate->field_3 = 0;
--- a/mm7_2.cpp Fri Feb 15 17:14:24 2013 +0600 +++ b/mm7_2.cpp Fri Feb 15 17:22:20 2013 +0600 @@ -5104,7 +5104,7 @@ pWindow.uFrameHeight = 338; pWindow.uFrameZ = 543; pWindow.uFrameW = 397; - pFont = LoadFont("endgame.fnt", "FONTPAL", 0); + pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 99) ) { v1 = pGlobalTXT_LocalizationStrings[675]; @@ -13899,9 +13899,11 @@ unsigned int startms; // [sp+8h] [bp-24h]@55 RECT Rect; // [sp+Ch] [bp-20h]@15 int a2[4]; // [sp+1Ch] [bp-10h]@15 - +#ifdef MM7_TEXT_DLL auto mm7text_dll = LoadLibraryW(L"mm7text.dll"); sprintfex = (int (__cdecl *)(char *a1, const char *a2, ...))GetProcAddress(mm7text_dll, "_sprintfex"); +#endif + if (pCmdLine && *pCmdLine) {
--- a/mm7_3.cpp Fri Feb 15 17:14:24 2013 +0600 +++ b/mm7_3.cpp Fri Feb 15 17:22:20 2013 +0600 @@ -8366,8 +8366,8 @@ array_50AC10[3].u = 1; array_50AC10[3].v = 1 + t; pRenderer->DrawStrip(_this.uNumVertices, &_this, - pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); - return; + pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); + return; } @@ -16484,9 +16484,9 @@ } v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf, 3); pParty->GetPartyFame(); - if ( (signed int)uDialogueType > DIALOGUE_ARENA_WELCOME ) - { - if ( uDialogueType == DIALOGUE_ARENA_FIGHT_NOT_OVER_YET ) + if ( (signed int)uDialogueType > 89 ) + { + if ( uDialogueType == 90 ) { pWindow.uFrameWidth = 460; pWindow.uFrameZ = 452; @@ -16504,7 +16504,7 @@ pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0); goto LABEL_42; } - if ( uDialogueType == DIALOGUE_ARENA_REWARD ) + if ( uDialogueType == 91 ) { sprintf(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold." pInString = v4; @@ -16525,7 +16525,7 @@ pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8); goto LABEL_42; } - if ( uDialogueType == DIALOGUE_ARENA_ALREADY_WON ) + if ( uDialogueType == 92 ) { v7 = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:" v8 = 0; @@ -16549,7 +16549,7 @@ } else { - if ( uDialogueType == DIALOGUE_ARENA_WELCOME ) + if ( uDialogueType == 89 ) { v7 = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death. Remember, you are only allowed one arena combat per visit. To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:" v8 = 0; @@ -16570,7 +16570,7 @@ pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8); goto LABEL_42; } - if ( uDialogueType == DIALOGUE_13 ) + if ( uDialogueType == 13 ) { v5 = 5 * pNPC->uProfession; v6 = (char *)*(&pNPCStats->field_13A64 + v5); @@ -16593,11 +16593,11 @@ pDialogueWindow->DrawText(pOutString, 13, 354 - v12, v8, v13, v8, v8, v8); goto LABEL_42; } - if ( (signed int)uDialogueType > DIALOGUE_18 ) - { - if ( (signed int)uDialogueType > DIALOGUE_24 ) - { - if ( uDialogueType == DIALOGUE_77 ) + if ( (signed int)uDialogueType > 18 ) + { + if ( (signed int)uDialogueType > 24 ) + { + if ( uDialogueType == 77 ) { v5 = 5 * pNPC->uProfession; if ( byte_F8B1EC ) @@ -16705,9 +16705,9 @@ { v8 = 0; if ( pNPC->uFlags & 0x80 ) - v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pDismissText; - else - v9 = (char *)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; //"Invalid String Passed" + v9 = (char *)*(&pNPCStats->field_13A68 + 5 * pNPC->uProfession); + else + v9 = (char *)*(&pNPCStats->field_13A64 + 5 * pNPC->uProfession); //"Invalid String Passed" v10 = sub_495461(v9, uActiveCharacter - 1, 0, 0, 0, 0); LABEL_32: pInString = v10; @@ -16950,23 +16950,18 @@ NPCData *result; // eax@5 int v3; // esi@9 int v4; // ecx@9 - //int v5; // edx@9 - //NPCData *v6; // eax@9 + int v5; // edx@9 + NPCData *v6; // eax@9 char *v7; // ebx@14 NPCData *v8; // edi@14 char v9; // al@22 - char v10; - //std::string v10; // [sp-18h] [bp-2Ch]@4 - int v11; - //const char *v11; // [sp-8h] [bp-1Ch]@4 + std::string v10; // [sp-18h] [bp-2Ch]@4 + const char *v11; // [sp-8h] [bp-1Ch]@4 int v12; // [sp-4h] [bp-18h]@4 - int v13; - char *v14; - //std::string *v13; // [sp+Ch] [bp-8h]@4 + std::string *v13; // [sp+Ch] [bp-8h]@4 int a3; // [sp+13h] [bp-1h]@4 - int i; - - /*v1 = npcid; + + v1 = npcid; if ( (npcid & 0x80000000u) == 0 ) { if ( (signed int)npcid < 5000 ) @@ -17021,60 +17016,7 @@ else result = &pParty->pHirelings[(unsigned __int8)v9]; } - return result;*/ - v1 = npcid; - if ( npcid >= 0 ) - { - if ( npcid < 5000 ) - { - if ( npcid >= 501 ) - { - MessageBoxW(nullptr, L"NPC id exceeds MAX_DATA!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1984", 0); - } - return &pNPCStats->pNewNPCData[v1 - 1]; - } - return &pNPCStats->array_13EF4[npcid - 5000]; - } - - - if ( npcid >= 5000 ) - return &pNPCStats->array_13EF4[npcid - 5000]; - if (uDialogue_SpeakingActorNPC_ID >= 0) - { - result = 0; - } - else - { - v3 = uDialogue_SpeakingActorNPC_ID - 1; - v4 = 0; - - for (i = 0; i < 4; ++i) - { - if (pParty->pHirelings[i].pName) - pTmpBuf[v4++] = i; - } - - if (pNPCStats->uNumNewNPCs > 0) - { - for (i = 0; i < pNPCStats->uNumNewNPCs; ++i) - { - if (pNPCStats->pNewNPCData[i].uFlags & 0x80) - { - if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) - { - if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName)) - pTmpBuf[v4++] = i + 2; - } - } - } - } - - v9 = pTmpBuf[v3]; - if ( v9 >= 2 ) - result = &pNPCStats->pNPCData[499 + v9]; - else - result = &pParty->pHirelings[v9]; - } + return result; } //----- (00445B2C) -------------------------------------------------------- @@ -20447,198 +20389,11 @@ v1->z = LODWORD(v14); } -//----- (0044C448) -------------------------------------------------------- -GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...) -{ - GUIFont *result; // eax@1 - const char *v3; // edi@1 - const char **v4; // ebx@2 - unsigned int v5; // eax@3 - unsigned __int16 **v6; // ecx@6 - GUIFont *v7; // [sp+4h] [bp-Ch]@1 - int v8; // [sp+8h] [bp-8h]@1 - unsigned __int16 **v9; // [sp+Ch] [bp-4h]@2 - - result = (GUIFont *)pIcons_LOD->LoadRaw(pFontFile, 0); - v3 = pFontPalette; - v8 = 0; - v7 = result; - if ( pFontPalette ) - { - v4 = &pFontPalette; - v9 = result->pFontPalettes; - do - { - v5 = pIcons_LOD->LoadTexture(v3, TEXTURE_16BIT_PALETTE); - if ( v5 == -1 ) - { - sprintf(pTmpBuf, "Unable to open %s", v3); - Abortf(pTmpBuf); - } - ++v4; - v6 = v9; - v3 = *v4; - ++v8; - ++v9; - *v6 = (v5 != -1 ? pIcons_LOD->pTextures[v5].pPalette16 : 0); - } - while ( v3 ); - result = v7; - } - result->field_8 = v8; - return result; -} - - - - -//----- (0044C768) -------------------------------------------------------- -char *__fastcall FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5) -{ - const char *v5; // edi@1 - GUIFont *v6; // esi@1 - unsigned int v8; // eax@3 - int v9; // edi@3 - unsigned __int8 v10; // cl@4 - int v11; // edx@10 - GUICharMetric *v12; // ecx@10 - int v13; // edx@11 - int v14; // edx@12 - int v15; // edx@13 - unsigned int v16; // esi@15 - unsigned int v17; // edx@15 - unsigned int v18; // ecx@15 - int v19; // ebx@16 - unsigned __int8 v20; // zf@16 - char v21; // sf@16 - unsigned __int8 v22; // of@16 - int v23; // edi@16 - unsigned __int8 v24; // dl@17 - int v25; // edi@39 - int v26; // eax@42 - std::string v27; // [sp-18h] [bp-40h]@2 - const char *v28; // [sp-8h] [bp-30h]@2 - int v29; // [sp-4h] [bp-2Ch]@2 - const char *v30; // [sp+Ch] [bp-1Ch]@1 - char Str[3]; // [sp+10h] [bp-18h]@42 - char v32; // [sp+13h] [bp-15h]@42 - size_t v33; // [sp+14h] [bp-14h]@3 - unsigned int v34; // [sp+18h] [bp-10h]@3 - GUIFont *v35; // [sp+1Ch] [bp-Ch]@1 - int v36; // [sp+20h] [bp-8h]@3 - int v37; // [sp+24h] [bp-4h]@3 - - v5 = pInString; - v6 = pFont; - v30 = pInString; - v35 = pFont; - if ( !pInString ) - { - MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); - return 0; - } - v33 = strlen(pInString); - strcpy(pTmpBuf3, v5); - v8 = uX; - v9 = 0; - v36 = 0; - v34 = uX; - v37 = 0; - if ( (signed int)v33 > 0 ) - { - while ( 1 ) - { - v10 = pTmpBuf3[v9]; - if ((v10 < v6->cFirstChar || v10 > v6->cLastChar) - && v10 != '\f' && v10 != '\r' && v10 != '\t' && v10 != '\n' ) - goto LABEL_34; - v11 = v10 - 9; - v12 = &v6->pMetrics[v10]; - if ( !v11 ) - { - strncpy(Str, &pTmpBuf3[v9 + 1], 3u); - v32 = 0; - v26 = atoi(Str); - v8 = uX + v26; - v25 = v9 + 3; - v34 = v8; - goto LABEL_43; - } - v13 = v11 - 1; - if ( !v13 ) - break; - v14 = v13 - 2; - if ( !v14 ) - { - v25 = v9 + 5; -LABEL_43: - v37 = v25; - goto LABEL_34; - } - v15 = v14 - 1; - if ( v15 ) - { - if ( v15 != 19 ) - { - v16 = v12->uRightSpacing; - v17 = v12->uWidth; - v18 = v12->uLeftSpacing; - if ( v8 + v16 + v18 + v17 < pWindow->uFrameWidth ) - { - if ( v37 > v36 ) - v8 += v18; - v8 += v17; - if ( v37 < (signed int)v33 ) - v8 += v16; - v6 = v35; - } - else - { - v19 = v36; - v8 = v34; - v22 = v36 > v37; - v20 = v36 == v37; - v21 = v36 - v37 < 0; - v6 = v35; - pTmpBuf3[v36] = 10; - v23 = v19; - if ( (unsigned __int8)(v21 ^ v22) | v20 ) - { - do - { - v24 = pTmpBuf3[v23]; - if ( v24 >= v6->cFirstChar && v24 <= v6->cLastChar || v24 == 12 || v24 == 13 || v24 == 9 || v24 == 10 ) - { - if ( v23 > v19 ) - v8 += v6->pMetrics[v24].uLeftSpacing; - v8 += *((int *)&v6->cFirstChar + 3 * v24 + 9); - if ( v23 < v37 ) - v8 += v6->pMetrics[v24].uRightSpacing; - } - ++v23; - } - while ( v23 <= v37 ); - } - } - goto LABEL_34; - } - v8 += v12->uWidth; - goto LABEL_41; - } - if ( !a5 ) - return (char *)v30; -LABEL_34: - v9 = v37++ + 1; - if ( v37 >= (signed int)v33 ) - return pTmpBuf3; - } - v8 = v34; -LABEL_41: - v36 = v9; - goto LABEL_34; - } - return pTmpBuf3; -} + + + + + //----- (00401000) -------------------------------------------------------- void __stdcall mm7__vector_constructor(void *a1, int objSize, int numObjs, int (__thiscall *constructor)(int)) {
--- a/mm7_4.cpp Fri Feb 15 17:14:24 2013 +0600 +++ b/mm7_4.cpp Fri Feb 15 17:22:20 2013 +0600 @@ -5831,7 +5831,7 @@ (Texture *)(uTextureID_BUTTMAKE2 != -1 ? &pIcons_LOD->pTextures[uTextureID_BUTTMAKE2] : 0), 0); pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(523, 393, 20, 35, 1, 0, 0x3F, 0, 0x2D, "", pTexture_buttminu, 0); pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(613, 393, 20, 35, 1, 0, 0x3E, 1, 0x2B, "", pTexture_buttplus, 0); - pFontCChar = LoadFont("cchar.fnt", "FONTPAL", 0); + pFontCChar = LoadFont("cchar.fnt", "FONTPAL", NULL); } // 4E28F8: using guessed type int pCurrentScreen; @@ -6158,8 +6158,8 @@ Texture pTexture3; // [sp+Ch] [bp-130h]@5 a5 = 0; - pFontQuick = LoadFont("quick.fnt", "FONTPAL", 0); - pFontCChar = LoadFont("cchar.fnt", "FONTPAL", 0); + pFontQuick = LoadFont("quick.fnt", "FONTPAL", NULL); + pFontCChar = LoadFont("cchar.fnt", "FONTPAL", NULL); if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; ++pIcons_LOD->uTexturePacksCount;
--- a/mm7_data.h Fri Feb 15 17:14:24 2013 +0600 +++ b/mm7_data.h Fri Feb 15 17:22:20 2013 +0600 @@ -310,7 +310,7 @@ //------------------------------------------------------------------------- // Data declarations -extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...); +//extern int (__cdecl *sprintfex)(char *a1, const char *a2, ...); extern int pWindowList_at_506F50_minus1_indexing[1]; extern int dword_4C9890[10]; // weak @@ -2054,8 +2054,8 @@ signed int __cdecl const_2(); bool __cdecl sub_44C28F_open_nwc_dungeon(); // int __cdecl crt_deconstruct_44C42C(); -struct GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...); -char *__fastcall FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5); + + void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); void __cdecl sub_450218_prolly_generate_chests_loot();