# HG changeset patch # User Ritor1 # Date 1360931693 -21600 # Node ID 428cbb33872cc4e6293e857c49cd754c7f446ca4 # Parent 27573ee0d4340d6f9ad6d75a67a51bbe0cbbb8b2# Parent c5bd7a825ef2ccd0ccbe0a7e13fef65427967686 Слияние diff -r 27573ee0d434 -r 428cbb33872c GUIFont.cpp --- a/GUIFont.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/GUIFont.cpp Fri Feb 15 18:34:53 2013 +0600 @@ -1,5 +1,5 @@ #include - +#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; + } diff -r 27573ee0d434 -r 428cbb33872c GUIFont.h --- a/GUIFont.h Fri Feb 15 18:34:31 2013 +0600 +++ b/GUIFont.h Fri Feb 15 18:34:53 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; diff -r 27573ee0d434 -r 428cbb33872c GUIWindow.cpp --- a/GUIWindow.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/GUIWindow.cpp Fri Feb 15 18:34:53 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) -------------------------------------------------------- diff -r 27573ee0d434 -r 428cbb33872c GUIWindow.h --- a/GUIWindow.h Fri Feb 15 18:34:31 2013 +0600 +++ b/GUIWindow.h Fri Feb 15 18:34:53 2013 +0600 @@ -25,10 +25,14 @@ enum DIALOGUE_TYPE { - DIALOGUE_ARENA_WELCOME = 0x89, - DIALOGUE_ARENA_FIGHT_NOT_OVER_YET = 0x90, - DIALOGUE_ARENA_REWARD = 0x91, - DIALOGUE_ARENA_ALREADY_WON = 0x92, + DIALOGUE_13 = 0xD, + DIALOGUE_18 = 0x12, + DIALOGUE_24 = 0x18, + DIALOGUE_77 = 0x4D, + DIALOGUE_ARENA_WELCOME = 0x59, + DIALOGUE_ARENA_FIGHT_NOT_OVER_YET = 0x5A, + DIALOGUE_ARENA_REWARD = 0x5B, + DIALOGUE_ARENA_ALREADY_WON = 0x5C, }; diff -r 27573ee0d434 -r 428cbb33872c Outdoor.cpp --- a/Outdoor.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/Outdoor.cpp Fri Feb 15 18:34:53 2013 +0600 @@ -2432,7 +2432,7 @@ if (v3 < 198) { if (v3 >= 90) - v3 = v3 + this->pTileTypes[(v3 - 90) / 18].uTileID - 36 * (v3 - 90) / 36 - 90; + v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90; } else v3 = v3 + this->pTileTypes[3].uTileID - 198; @@ -2470,13 +2470,13 @@ result = pTileTable->pTiles[v3].uAttributes; } return result;*/ - if (uX > 127 || uY > 127) - return 0; - else - { - v3 = this->pTerrain.pTilemap[128 * uY + uX]; - if ( v3 >= 90 ) - v3 = v3 + this->pTileTypes[(v3 - 90) / 18].uTileID - 36 * (v3 - 90) / 36 - 90; + if (uX > 127 || uY > 127) + return 0; + else + { + v3 = this->pTerrain.pTilemap[uY * 128 + uX]; + if ( v3 >= 90 ) + v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90; return pTileTable->pTiles[v3].uAttributes; } } @@ -2489,7 +2489,7 @@ if ( (signed int)uX < 0 || (signed int)uX > 127 || (signed int)uZ < 0 || (signed int)uZ > 127 ) result = 0; else - result = 32 * *(&this->pTerrain.pHeightmap[128 * uZ] + uX); + result = 32 * *(&this->pTerrain.pHeightmap[uZ * 128 + uX]); return result; } diff -r 27573ee0d434 -r 428cbb33872c Player.cpp --- a/Player.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/Player.cpp Fri Feb 15 18:34:53 2013 +0600 @@ -1983,9 +1983,9 @@ char *v7; // esi@7 signed int uSkillMultiplier; // [sp-4h] [bp-14h]@2 - LOBYTE(v2) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_ITEM_ID); + v2 = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_ITEM_ID); v3 = v2; - if ( HIBYTE(v2) & 1 ) + if ( v2 & 1 ) { uSkillMultiplier = 5; } @@ -1994,21 +1994,34 @@ if ( (v2 & 0x80u) == 0 ) { uSkillMult = ((v2 & 0x40) != 0) + 1; - goto LABEL_7; + v5 = uSkillMult * (v3 & 0x3F); + v6 = 0; + v7 = (char *)&pItemsTable->pItems[pItem->uItemID].pIconName; + if ( CheckHiredNPCSpeciality(4) ) + { + v6 = 1; + return v6; + } + if ( (signed int)SkillToMastery(v3) >= 4 ) + v6 = 1; + if ( v5 >= (unsigned __int8)v7[46] ) + v6 = 1; + return v6; } uSkillMultiplier = 3; } uSkillMult = uSkillMultiplier; -LABEL_7: v5 = uSkillMult * (v3 & 0x3F); v6 = 0; v7 = (char *)&pItemsTable->pItems[pItem->uItemID].pIconName; - if ( CheckHiredNPCSpeciality(4u) ) - goto LABEL_15; + if ( CheckHiredNPCSpeciality(4) ) + { + v6 = 1; + return v6; + } if ( (signed int)SkillToMastery(v3) >= 4 ) v6 = 1; if ( v5 >= (unsigned __int8)v7[46] ) -LABEL_15: v6 = 1; return v6; } diff -r 27573ee0d434 -r 428cbb33872c Render.cpp --- a/Render.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/Render.cpp Fri Feb 15 18:34:53 2013 +0600 @@ -20,6 +20,7 @@ #include "OSInfo.h" #include "Actor.h" #include "Log.h" +#include "TileFrameTable.h" #include "mm7_data.h" @@ -1711,6 +1712,7 @@ int v6; // ecx@8 //int v7; // ecx@8 struct stru148 *v8; // ebx@8 +// RenderVertexSoft *v8a; // edi@3 //char v11; // zf@8 struct stru148 *v16; unsigned int v18; // edi@22 @@ -1739,6 +1741,7 @@ int v64; // [sp+57h] [bp-1h]@2 int v62; //struct IndoorCameraD3D *pIndoorCameraD3D; + //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 v63 = 0; // basic optimizations @@ -1787,12 +1790,17 @@ v8->flags = 0; v8->field_32 = 0; //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; - //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID); + //struct TileDesc *pTile = pTileTable->GetTileById(uTileID); v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); - v6 = v8->uTileBitmapID; - v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6]; + //v6 = v8->uTileBitmapID; + v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID]; if (v8->uTileBitmapID == 0xFFFF) continue; + v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); + v8->field_32 = 0; + v8->field_59 = 1; + //v8->field_5D = (char)WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8a->vWorldPosition.z) / 2 + 0.5f)); + //v8->field_5C = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));; v8->sTextureDeltaU = 0; v8->sTextureDeltaV = 0; memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); @@ -1828,6 +1836,17 @@ array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); } + if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + { + //v80 = false; + v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + } + else + { + v6 = v8->uTileBitmapID; + //v80 = true; + } + assert(v6 < 1000); // many random crashes here pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]); --pOutdoorCamera->numStru148s; diff -r 27573ee0d434 -r 428cbb33872c Sprites.cpp --- a/Sprites.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/Sprites.cpp Fri Feb 15 18:34:53 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; diff -r 27573ee0d434 -r 428cbb33872c mm7_1.cpp --- a/mm7_1.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/mm7_1.cpp Fri Feb 15 18:34:53 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; diff -r 27573ee0d434 -r 428cbb33872c mm7_2.cpp --- a/mm7_2.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/mm7_2.cpp Fri Feb 15 18:34:53 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]; @@ -13898,9 +13898,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) { diff -r 27573ee0d434 -r 428cbb33872c mm7_3.cpp --- a/mm7_3.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/mm7_3.cpp Fri Feb 15 18:34:53 2013 +0600 @@ -20389,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)) { diff -r 27573ee0d434 -r 428cbb33872c mm7_4.cpp --- a/mm7_4.cpp Fri Feb 15 18:34:31 2013 +0600 +++ b/mm7_4.cpp Fri Feb 15 18:34:53 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; diff -r 27573ee0d434 -r 428cbb33872c mm7_data.h --- a/mm7_data.h Fri Feb 15 18:34:31 2013 +0600 +++ b/mm7_data.h Fri Feb 15 18:34:53 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();