Mercurial > mm7
changeset 173:a8c700f3f5ec
Слияние
author | Ritor1 |
---|---|
date | Fri, 15 Feb 2013 10:06:47 +0600 |
parents | e6db0995ac4b (current diff) 941eb1cc5846 (diff) |
children | 4ae88cd19c30 |
files | mm7_3.cpp |
diffstat | 15 files changed, 830 insertions(+), 394 deletions(-) [+] |
line wrap: on
line diff
--- a/GUIFont.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/GUIFont.cpp Fri Feb 15 10:06:47 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 10:06:36 2013 +0600 +++ b/GUIFont.h Fri Feb 15 10:06:47 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,16 +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; extern struct GUIFont *pSpellFont;
--- a/GUIWindow.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/GUIWindow.cpp Fri Feb 15 10:06:47 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/IndoorCameraD3D.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/IndoorCameraD3D.cpp Fri Feb 15 10:06:47 2013 +0600 @@ -1336,7 +1336,7 @@ v8 += 48; *(float *)(pOutNumVerticesa + v9) = *(float *)v9; *(float *)(pVerticesa + v9) = *(float *)(v9 + 28); - *(float *)((char *)&static_4371C3_array_50E5E0[0].flt_20 - (char *)v6 + v9) = *(float *)(v9 + 32); + *(float *)((char *)&static_4371C3_array_50E5E0[0]._rhw - (char *)v6 + v9) = *(float *)(v9 + 32); v9 += 48; } while ( v12 < (signed int)*v7 ); @@ -1368,7 +1368,7 @@ if ( (signed int)uNumInVertices > 0 ) { pOutVertices_ = (char *)&pOutVertices->vWorldViewProjY; - v7 = (char *)&pInVertices->flt_20; + v7 = (char *)&pInVertices->_rhw; v8 = (char *)pOutVertices - (char *)pInVertices; a2a = uNumInVertices; do @@ -1451,7 +1451,7 @@ v10 = pOutVertices; } v10[*pOutNumVertices_].vWorldViewPosition.x = v6; - v10[*pOutNumVertices_].flt_20 = 1.0 / v6; + v10[*pOutNumVertices_]._rhw = 1.0 / v6; if ( v7 ) { v13 = (unsigned int)&v10[*pOutNumVertices_]; @@ -1478,7 +1478,7 @@ if ( a1a ) { memcpy(&v10[*pOutNumVertices_], v8 - 36, sizeof(v10[*pOutNumVertices_])); - pOutVertices[*pOutNumVertices_].flt_20 = 1.0 / (*((float *)v8 - 6) + 0.0000001); + pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (*((float *)v8 - 6) + 0.0000001); pOutVertices[(*pOutNumVertices_)++].flt_2C = *((float *)v8 + 2); } v7 = a1a; @@ -1548,7 +1548,7 @@ v8 = pOutVertices; } v8[*pOutNumVertices].vWorldViewPosition.x = 8.0; - v8[*pOutNumVertices].flt_20 = 0.125; + v8[*pOutNumVertices]._rhw = 0.125; if ( v5 ) { v11 = (unsigned int)&v8[*pOutNumVertices]; @@ -1575,7 +1575,7 @@ if ( a1a ) { memcpy(&v8[*pOutNumVertices], v6 - 36, sizeof(v8[*pOutNumVertices])); - pOutVertices[(*pOutNumVertices)++].flt_20 = 1.0 / (*((float *)v6 - 6) + 0.0000001); + pOutVertices[(*pOutNumVertices)++]._rhw = 1.0 / (*((float *)v6 - 6) + 0.0000001); } v5 = a1a; v6 += 48;
--- a/Mouse.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/Mouse.cpp Fri Feb 15 10:06:47 2013 +0600 @@ -929,7 +929,7 @@ int v13; // [sp+80h] [bp-4h]@3 Dst.dwSize = 124; - result = pRenderer->LockSurface_DDraw4(a2, &Dst, 1u); + result = pRenderer->LockSurface_DDraw4(a2, &Dst, DDLOCK_WAIT); if ( result ) { v5 = a1->pPalette16;
--- a/Render.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/Render.cpp Fri Feb 15 10:06:47 2013 +0600 @@ -1825,7 +1825,7 @@ for (unsigned int k = 0; k < 4; ++k) { memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); - array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); } assert(v6 < 1000); // many random crashes here @@ -2059,19 +2059,19 @@ //goto LABEL_162; //} memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[0].u = 0.0; array_50AC10[0].v = 0.0; memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[1].u = 0.0; array_50AC10[1].v = 1.0; memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[2].u = 1.0; array_50AC10[2].v = 1.0; memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); - array_50AC10[3].flt_20 = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[3].u = 1.0; array_50AC10[3].v = 0.0; /*if ( !(byte_76D5C0 & 1) ) @@ -2199,15 +2199,15 @@ goto LABEL_112; }*/ memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[0].u = 0.0; array_50AC10[0].v = 0.0; memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; array_50AC10[1].u = 0.0; array_50AC10[1].v = 1.0; memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; array_50AC10[2].u = 1.0; array_50AC10[2].v = 1.0; static stru154 static_sub_0048034E_stru_76D590; @@ -2328,15 +2328,15 @@ goto LABEL_162; } memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[0].u = 0.0; array_50AC10[0].v = 0.0; memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; array_50AC10[1].u = 1.0; array_50AC10[1].v = 1.0; memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; array_50AC10[2].u = 1.0; array_50AC10[2].v = 0.0; static stru154 static_sub_0048034E_stru_76D578; @@ -2640,22 +2640,22 @@ goto LABEL_104; v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); memcpy(array_50AC10, v104, 0x30u); - array_50AC10[0].flt_20 = v26; + array_50AC10[0]._rhw = v26; array_50AC10[0].u = 0.0; array_50AC10[0].v = 0.0; v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / v27; + array_50AC10[1]._rhw = 1.0 / v27; array_50AC10[1].u = 0.0; array_50AC10[1].v = 1.0; v28 = v103->vWorldViewPosition.x + 0.0000001; memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / v28; + array_50AC10[2]._rhw = 1.0 / v28; array_50AC10[2].u = 1.0; array_50AC10[2].v = 1.0; v29 = v102->vWorldViewPosition.x + 0.0000001; memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); - array_50AC10[3].flt_20 = 1.0 / v29; + array_50AC10[3]._rhw = 1.0 / v29; array_50AC10[3].u = 1.0; array_50AC10[3].v = 0.0; pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); @@ -2761,17 +2761,17 @@ goto LABEL_74; v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); memcpy(array_50AC10, v104, 0x30u); - array_50AC10[0].flt_20 = v48; + array_50AC10[0]._rhw = v48; array_50AC10[0].u = 0.0; array_50AC10[0].v = 0.0; v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / v49; + array_50AC10[1]._rhw = 1.0 / v49; array_50AC10[1].u = 0.0; array_50AC10[1].v = 1.0; v50 = v103->vWorldViewPosition.x + 0.0000001; memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / v50; + array_50AC10[2]._rhw = 1.0 / v50; array_50AC10[2].u = 1.0; array_50AC10[2].v = 1.0; pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); @@ -2855,17 +2855,17 @@ } v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); memcpy(array_50AC10, v104, 0x30u); - array_50AC10[0].flt_20 = v62; + array_50AC10[0]._rhw = v62; array_50AC10[0].u = 0.0; array_50AC10[0].v = 0.0; v63 = v103->vWorldViewPosition.x + 0.0000001; memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / v63; + array_50AC10[1]._rhw = 1.0 / v63; array_50AC10[1].u = 1.0; array_50AC10[1].v = 1.0; v64 = v102->vWorldViewPosition.x + 0.0000001; memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / v64; + array_50AC10[2]._rhw = 1.0 / v64; array_50AC10[2].u = 1.0; array_50AC10[2].v = 0.0; pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); @@ -4831,7 +4831,7 @@ { memset(&Dst, 0, 0x7Cu); Dst.dwSize = 124; - if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, 1u) ) + if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) return; v28 = Dst.lpSurface; v5 = Dst.lPitch >> 1; @@ -5027,7 +5027,7 @@ { memset(&Dst, 0, 0x7Cu); Dst = 124; - if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, 1u) ) + if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) return; v42 = v20; v6 = v19 >> 1; @@ -6136,7 +6136,7 @@ { memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, 1u) ) + if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &pDesc, DDLOCK_WAIT) ) { pRenderer->pBackBuffer4->Unlock(0); v19 = ptr_400E8; @@ -6469,7 +6469,7 @@ bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) { IDirectDrawSurface4 *v4; // esi@1 - bool result; // eax@1 + HRESULT result; // eax@1 HRESULT v6; // eax@4 int v7; // [sp-8h] [bp-14h]@10 unsigned int v8; // [sp-4h] [bp-10h]@10 @@ -6839,7 +6839,7 @@ DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, 1u); + LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); *pOutSurfacePtr = pDesc.lpSurface; v4 = pDesc.lPitch; } @@ -6884,7 +6884,7 @@ DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, 1u); + LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); *pOutSurface = pDesc.lpSurface; v4 = pDesc.lPitch; } @@ -7617,7 +7617,7 @@ pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; pVertices[i].pos.z = 0.99989998; - pVertices[i].rhw = array_50AC10[i].flt_20; + pVertices[i].rhw = array_50AC10[i]._rhw; pVertices[i].diffuse = GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); v7 = 0; @@ -7659,7 +7659,7 @@ pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; pVertices[i].pos.z = 0.99989998; - pVertices[i].rhw = array_50AC10[i].flt_20; + pVertices[i].rhw = array_50AC10[i]._rhw; pVertices[i].diffuse = GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); v7 = 0; @@ -8831,7 +8831,7 @@ memset(&desc, 0, sizeof(DDSURFACEDESC2)); desc.dwSize = sizeof(DDSURFACEDESC2); - if ( LockSurface_DDraw4(pNextSurf, &desc, 0x21u) ) + if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) { Dst.sub_451007_scale_image_bicubic( pHWLTexture->pPixels, @@ -8865,7 +8865,7 @@ memset(&desc, 0, sizeof(DDSURFACEDESC2)); desc.dwSize = sizeof(DDSURFACEDESC2); - if ( LockSurface_DDraw4(*pOutSurface, &desc, 0x21u) ) + if ( LockSurface_DDraw4(*pOutSurface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) { bMipMaps = 0; v13 = pHWLTexture->pPixels; @@ -8941,7 +8941,7 @@ //v8 = pSprite; memset(&Dst, 0, 0x7Cu); Dst.dwSize = 124; - if ( LockSurface_DDraw4((IDirectDrawSurface4 *)v2->pTextureSurface, &Dst, 0x21u) ) + if ( LockSurface_DDraw4((IDirectDrawSurface4 *)v2->pTextureSurface, &Dst, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) { v9 = v5->pPixels; v10 = Dst.lpSurface; @@ -8999,7 +8999,7 @@ { memset(&Dst, 0, 0x7Cu); Dst.dwSize = 124; - if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x801u) ) + if ( LockSurface_DDraw4(v1->pColorKeySurface4, &Dst, 0x800 | DDLOCK_WAIT) ) { v1->pTargetSurface = (unsigned __int16 *)Dst.lpSurface; v3 = Dst.lPitch >> 1;
--- a/Render.h Fri Feb 15 10:06:36 2013 +0600 +++ b/Render.h Fri Feb 15 10:06:47 2013 +0600 @@ -26,7 +26,7 @@ Vec3_float_ vWorldViewPosition; float vWorldViewProjX; float vWorldViewProjY; - float flt_20; + float _rhw; float u; float v; float flt_2C;
--- a/Sprites.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/Sprites.cpp Fri Feb 15 10:06:47 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 10:06:36 2013 +0600 +++ b/mm7_1.cpp Fri Feb 15 10:06:47 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; @@ -3062,7 +3062,7 @@ { memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - if ( !pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, 1u) ) + if ( !pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT)) goto LABEL_51; v20 = (char *)v124; v110 = pDesc.lpSurface; @@ -3109,7 +3109,7 @@ } memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, 1u) ) + if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)v222, &pDesc, DDLOCK_WAIT) ) { v108 = (unsigned __int16 *)pDesc.lpSurface; a2 = (Player *)v124; @@ -7740,7 +7740,7 @@ v3 = (char *)&array_507D30[0].vWorldViewPosition.z; v4 = (char *)&array_507D30[0].vWorldViewPosition.y; v5 = v1; - v23 = (char *)&array_507D30[0].flt_20; + v23 = (char *)&array_507D30[0]._rhw; v21 = array_507D30; v18 = (char *)&array_507D30[0].vWorldViewPosition.z; v19 = (char *)&array_507D30[0].vWorldViewPosition.y;
--- a/mm7_2.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/mm7_2.cpp Fri Feb 15 10:06:47 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]; @@ -11248,7 +11248,7 @@ pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); memset(&Dst, 0, 0x7Cu); Dst.dwSize = 124; - if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, 1u) ) + if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) { v9 = (unsigned __int16 *)Dst.lpSurface; v10 = 0; @@ -13882,7 +13882,7 @@ - +bool new_sky = false; //----- (00462C94) -------------------------------------------------------- bool MM_Main(const wchar_t *pCmdLine) @@ -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) { @@ -13927,6 +13929,8 @@ } if (wcsstr(pCmdLine, L"-nocd")) bNoCD = true; + if (wcsstr(pCmdLine, L"-new_sky")) + new_sky = true; } stru_51076C.registry_debug_flags = ReadWindowsRegistryInt("debug flags", 0);
--- a/mm7_3.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/mm7_3.cpp Fri Feb 15 10:06:47 2013 +0600 @@ -6989,7 +6989,7 @@ memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28])); ++v28; --v29; - array_50A2B0[v28 + 49].flt_20 = v30; + array_50A2B0[v28 + 49]._rhw = v30; } while ( v29 ); pFace = v46; @@ -7356,7 +7356,7 @@ v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001); memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31])); ++v31; - array_50A2B0[v31 + 49].flt_20 = v32; + array_50A2B0[v31 + 49]._rhw = v32; v84 = v12->sTextureDeltaU + *(short *)(v30 - 40); array_50A2B0[v31 + 49].u = (double)v84 * v28; v33 = v12->sTextureDeltaV + *(short *)v30; @@ -7719,6 +7719,478 @@ return result; } + + +unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr) +{ + #pragma pack(push, 1) + struct TGAHeader + { + unsigned char tgaSkip; + unsigned char colourmaptype; // type of colour map 0=none, 1=has palette + unsigned char tgaType; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed + + short colourmapstart; // first colour map entry in palette + short colourmaplength; // number of colours in palette + char colourmapbits; // number of bits per palette entry 15,16,24,32 + + //unsigned char tgaDontCare2[9]; + short xstart; // image x origin + short ystart; // image y origin + + unsigned short tgaWidth; + unsigned short tgaHeight; + unsigned char tgaBPP; + + char descriptor; // image descriptor bits: 00vhaaaa + // h horizontal flip + // v vertical flip + // a alpha bits + }; + #pragma pack(pop) + + if (out_width) + *out_width = 0; + if (out_height) + *out_height = 0; + + DWORD w; + auto file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); + if (file == INVALID_HANDLE_VALUE) + return nullptr; + + TGAHeader header; + ReadFile(file, &header, sizeof(header), &w, nullptr); + SetFilePointer(file, header.tgaSkip, nullptr, FILE_CURRENT); + + if (header.tgaBPP != 24 || header.tgaType != 2) + { + CloseHandle(file); + return nullptr; + } + + int imgSize = header.tgaWidth * header.tgaHeight * 3; + auto pixels = new unsigned char[imgSize]; + ReadFile(file, pixels, imgSize, &w, nullptr); + CloseHandle(file); + + if (w != imgSize) + { + delete [] pixels; + return nullptr; + } + + if (out_width) + *out_width = header.tgaWidth; + if (out_height) + *out_height = header.tgaHeight; + + auto pixels_16bit = new unsigned short[imgSize / 3]; + for (int i = 0; i < imgSize / 3; ++i) + { + pixels_16bit[i] = (pixels[i * 3] / 8 & 0x1F) | + ((pixels[i * 3 + 1] / 4 & 0x3F) << 5) | + ((pixels[i * 3 + 2] / 8 & 0x1F) << 11); + } + delete [] pixels; + return pixels_16bit; +} + +unsigned short *skybox_xn, *skybox_xp, + *skybox_yn, *skybox_yp, + *skybox_zn, *skybox_zp; +int skybox_width, skybox_height; +IDirect3DTexture2 *skybox_texture; +IDirectDrawSurface4 *skybox_surface; +bool Skybox_Initialize(const wchar_t *skybox_name) +{ + wchar_t xn_filename[1024], xp_filename[1024], + yn_filename[1024], yp_filename[1024], + zn_filename[1024], zp_filename[1024]; + swprintf(xn_filename, L"%s_xn.tga", skybox_name); swprintf(xp_filename, L"%s_xp.tga", skybox_name); + swprintf(yn_filename, L"%s_yn.tga", skybox_name); swprintf(yp_filename, L"%s_yp.tga", skybox_name); + swprintf(zn_filename, L"%s_zn.tga", skybox_name); swprintf(zp_filename, L"%s_zp.tga", skybox_name); + + int xn_width, xn_height; + skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height); + if (!skybox_xn) + return false; + + int xp_width, xp_height; + skybox_xp = LoadTgaTexture(xp_filename, &xp_width, &xp_height); + if (!skybox_xp || xp_width != xn_width || xp_height != xn_height) + { + delete [] skybox_xn; + if (skybox_xp) delete [] skybox_xp; + return false; + } + + int yn_width, yn_height; + skybox_yn = LoadTgaTexture(yn_filename, &yn_width, &yn_height); + if (!skybox_yn || yn_width != xn_width || yn_height != xn_height) + { + delete [] skybox_xn; + if (skybox_xp) delete [] skybox_xp; + if (skybox_yn) delete [] skybox_yn; + return false; + } + + int yp_width, yp_height; + skybox_yp = LoadTgaTexture(yp_filename, &yp_width, &yp_height); + if (!skybox_yp || yp_width != xn_width || yp_height != xn_height) + { + delete [] skybox_xn; + if (skybox_xp) delete [] skybox_xp; + if (skybox_yn) delete [] skybox_yn; + if (skybox_yp) delete [] skybox_yp; + return false; + } + + int zn_width, zn_height; + skybox_zn = LoadTgaTexture(zn_filename, &zn_width, &zn_height); + if (!skybox_zn || zn_width != xn_width || zn_height != xn_height) + { + delete [] skybox_xn; + if (skybox_xp) delete [] skybox_xp; + if (skybox_yn) delete [] skybox_yn; + if (skybox_yp) delete [] skybox_yp; + if (skybox_zn) delete [] skybox_zn; + return false; + } + + int zp_width, zp_height; + skybox_zp = LoadTgaTexture(zp_filename, &zp_width, &zp_height); + if (!skybox_zp || zp_width != xn_width || zp_height != xn_height) + { + delete [] skybox_xn; + if (skybox_xp) delete [] skybox_xp; + if (skybox_yn) delete [] skybox_yn; + if (skybox_yp) delete [] skybox_yp; + if (skybox_zn) delete [] skybox_zn; + if (skybox_zp) delete [] skybox_zp; + return false; + } + + skybox_width = xn_width; + skybox_height = xn_height; + + + if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture, + false, false, pRenderer->uMinDeviceTextureDim)) + return false; + + return true; +} + + +struct vector +{ + float x, y, z; +}; +struct matrix +{ + float m[4][4]; +}; +void VectorNormalize(vector *v) +{ + float invmag = 1.0f / sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); + v->x *= invmag; + v->y *= invmag; + v->z *= invmag; +} +void MatrixRotationAxis(matrix *pout, CONST vector *pv, float angle) +{ + memset(pout, 0, sizeof(matrix)); + pout->m[3][0] = 0; + pout->m[3][1] = 0; + pout->m[3][2] = 0; + pout->m[3][3] = 1; + + vector v; + v.x = pv->x; v.y = pv->y; v.z = pv->z; + VectorNormalize(&v); + + pout->m[0][0] = (1.0f - cos(angle)) * v.x * v.x + cos(angle); + pout->m[1][0] = (1.0f - cos(angle)) * v.x * v.y - sin(angle) * v.z; + pout->m[2][0] = (1.0f - cos(angle)) * v.x * v.z + sin(angle) * v.y; + pout->m[0][1] = (1.0f - cos(angle)) * v.y * v.x + sin(angle) * v.z; + pout->m[1][1] = (1.0f - cos(angle)) * v.y * v.y + cos(angle); + pout->m[2][1] = (1.0f - cos(angle)) * v.y * v.z - sin(angle) * v.x; + pout->m[0][2] = (1.0f - cos(angle)) * v.z * v.x - sin(angle) * v.y; + pout->m[1][2] = (1.0f - cos(angle)) * v.z * v.y + sin(angle) * v.x; + pout->m[2][2] = (1.0f - cos(angle)) * v.z * v.z + cos(angle); +} +void VectorTransform(const matrix *m, const vector *v, vector *out) +{ + out->x = m->m[0][0] * v->x + m->m[1][0] * v->y + m->m[2][0] * v->z + m->m[3][0]; + out->y = m->m[0][1] * v->x + m->m[1][1] * v->y + m->m[2][1] * v->z + m->m[3][1]; + out->z = m->m[0][2] * v->x + m->m[1][2] * v->y + m->m[2][2] * v->z + m->m[3][2]; +} + + +bool DrawSkyD3D_Skybox() +{ + static bool initialized = false, + initialization_failed = false; + if (initialization_failed) + return false; + + static int last_camera_rot_y, + last_camera_rot_x; + if (!initialized) + { + if (!Skybox_Initialize(L"data/skybox/stars")) + { + initialization_failed = true; + return false; + } + initialized = true; + + last_camera_rot_y = pParty->sRotationY + 1; // force update for the first run + last_camera_rot_x = pParty->sRotationX + 1; + } + + /* + r(y) = +cos y 0 sin y 0 +0 1 0 0 +-sin y 0 cos y 0 +0 0 0 1 + +x cos y - z sin y +y +x sin y + z cos y +1 + + + +r(x) = // should be r(right) actually +1 0 0 0 +0 cos x -sin x 0 +0 sin x cos x 0 +0 0 0 1 + + +x +y cos x + z sin x +-y sin x + z cos x +1 + + */ + + if (last_camera_rot_y == pParty->sRotationY && + last_camera_rot_x == pParty->sRotationX) + { +draw: + struct RenderVertexD3D3 v[6]; + + v[0].pos.x = pViewport->uScreenX; + v[0].pos.y = pViewport->uScreenY; + v[0].pos.z = 0.99989998; + v[0].rhw = 1; + v[0].diffuse = 0xFFFFFFFF; + v[0].specular = 0; + v[0].texcoord.x = 0; + v[0].texcoord.y = 0; + + v[1].pos.x = pViewport->uScreenX + pViewport->uScreenWidth; + v[1].pos.y = pViewport->uScreenY + pViewport->uScreenHeight; + v[1].pos.z = 0.99989998; + v[1].rhw = 1; + v[1].diffuse = 0xFFFFFFFF; + v[1].specular = 0; + v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; + v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; + + v[2].pos.x = pViewport->uScreenX + pViewport->uScreenWidth; + v[2].pos.y = pViewport->uScreenY; + v[2].pos.z = 0.99989998; + v[2].rhw = 1; + v[2].diffuse = 0xFFFFFFFF; + v[2].specular = 0; + v[2].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; + v[2].texcoord.y = 0; + + memcpy(&v[3], &v[0], sizeof(*v)); + + v[4].pos.x = pViewport->uScreenX; + v[4].pos.y = pViewport->uScreenY + pViewport->uScreenHeight; + v[4].pos.z = 0.99989998; + v[4].rhw = 1; + v[4].diffuse = 0xFFFFFFFF; + v[4].specular = 0; + v[4].texcoord.x = 0; + v[4].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; + + memcpy(&v[5], &v[1], sizeof(*v)); + + pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); + pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture); + pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); + //pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v + 1, 3, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); + + return true; + } + + + DDSURFACEDESC2 desc; + desc.dwSize = sizeof(desc); + if (!pRenderer->LockSurface_DDraw4(skybox_surface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY)) + return false; + + last_camera_rot_y = pParty->sRotationY; + last_camera_rot_x = pParty->sRotationX; + + float aspect = (float)pViewport->uScreenWidth / (float)pViewport->uScreenHeight; + float fov_x = 3.141592f * (pOutdoorCamera->uCameraFovInDegrees + 0) / 360.0f; + float fov_y = fov_x / aspect; + + float ray_dx = fov_x / (float)pViewport->uScreenWidth, + ray_dy = fov_y / (float)pViewport->uScreenHeight; + float party_angle_x = 2 * 3.141592653589 * pParty->sRotationX / 2048.0, + party_angle_y = 2 * 3.141592653589 * pParty->sRotationY / 2048.0; + for (int y = 0; y < pViewport->uScreenHeight; ++y) + for (int x = 0; x < pViewport->uScreenWidth; ++x) + { + float angle_x = party_angle_x - (y - pViewport->uScreenHeight / 2) * ray_dy; + float angle_y = party_angle_y - (x - pViewport->uScreenWidth / 2) * ray_dx; + + float _dir_x_ = 1, + _dir_y_ = 0, + _dir_z_ = 0; + + float dir_x_ = _dir_x_ * cosf(angle_y);// - _dir_z_ * sinf(angle_y); // rotation around y + //float dir_y_ = _dir_y_; + float dir_z_ = _dir_x_ * sinf(angle_y);// + _dir_z_ * cosf(angle_y); + + //float dir_x = dir_x_; // rotation around x + //float dir_y = /*dir_y_ * cosf(angle_x)*/ + dir_z_ * sinf(angle_x); + //float dir_z = /*-dir_y_ * sinf(angle_x)*/ + dir_z_ * cosf(angle_x); + + vector right; // rotate around right actually to avoid space distortion + right.x = /*dir_y * 0*/ - dir_z_ * 1; + right.y = /*dir_z_ * 0 - dir_x_ * */0; + right.z = dir_x_ * 1/* - dir_y_ * 0*/; + //VectorNormalize(&right); + + matrix rightMatrix; + MatrixRotationAxis(&rightMatrix, &right, angle_x); + + vector v1, v2; + v1.x = dir_x_; v1.y = 0; v1.z = dir_z_; + VectorTransform(&rightMatrix, &v1, &v2); + + float dir_x = v2.x, + dir_y = v2.y, + dir_z = v2.z; + + float abs_dir_x = fabsf(dir_x), + abs_dir_y = fabsf(dir_y), + abs_dir_z = fabsf(dir_z); + + unsigned short color = (0x1F << 11) | (0x1F << 5) | (5); //default to orange + if (abs_dir_x >= abs_dir_y) + { + if (abs_dir_x >= abs_dir_z) + { + if (dir_x >= 0) + { + float instersect_y = dir_y / (2.0f * dir_x); // plane equation for this side is x + 0.5 = 0 + float instersect_z = dir_z / (2.0f * dir_x); + + float u = 1.0f - (instersect_z + 0.5f), + v = 1.0f - (instersect_y + 0.5f); + + int tx = u * (skybox_width - 1), + ty = v * (skybox_height - 1); + + color = skybox_xp[ty * skybox_width + tx]; + //color = ty * 0x1F / skybox_height; + } + else + { + float instersect_y = dir_y / (2.0f * dir_x); + float instersect_z = dir_z / (2.0f * dir_x); + + float u = 1.0f - (instersect_z + 0.5f), + v = instersect_y + 0.5f; + + int tx = u * (skybox_width - 1), + ty = v * (skybox_height - 1); + + color = skybox_xn[ty * skybox_width + tx]; + //color = tx * 0x1F / skybox_height; + } + } + else if (dir_z >= 0) + goto DIR_ZP; + else + goto DIR_ZN; + } + else if (abs_dir_y >= abs_dir_z) + { + if (dir_y >= 0) + { + float instersect_x = dir_x / (2.0f * dir_y); + float instersect_z = dir_z / (2.0f * dir_y); + + float u = instersect_x + 0.5f, + v = instersect_z + 0.5f; + + int tx = u * (skybox_width - 1), + ty = v * (skybox_height - 1); + + color = skybox_yp[ty * skybox_width + tx]; + //color = tx * 0x1F / skybox_height; + } + /*else should never be seen i guess + { + __debugbreak(); + // -y + //Log::Warning(L"(%03u, %03u): -y", x, y); + }*/ + } + else if (dir_z >= 0) + { +DIR_ZP: + // +z + float instersect_x = dir_x / (2.0f * dir_z); + float instersect_y = dir_y / (2.0f * dir_z); + //float intersect_z = 0.5f; + + float u = instersect_x + 0.5f, + v = -instersect_y + 0.5f; + + int tx = u * (skybox_width - 1), + ty = v * (skybox_height - 1); + + color = skybox_zp[ty * skybox_width + tx]; + } + else + { +DIR_ZN: + // -z + float instersect_x = -dir_x / (2.0f * dir_z); + float instersect_y = -dir_y / (2.0f * dir_z); + //float intersect_z = -0.5f; + + float u = 1.0f - instersect_x - 0.5f, + v = -instersect_y + 0.5f; + + int tx = u * (skybox_width - 1), + ty = v * (skybox_height - 1); + + color = skybox_zn[ty * skybox_width + tx]; + } + + //pRenderer->pTargetSurface[(pViewport->uScreenY + y) * pRenderer->uTargetSurfacePitch + pViewport->uScreenX + x] = color; + ((unsigned __int16 *)((char *)desc.lpSurface + y * desc.lPitch))[x] = color; + } + + ErrD3D((skybox_surface)->Unlock(0)); + goto draw; +} + //----- (00479543) -------------------------------------------------------- void Render::DrawSkyD3D() { @@ -7763,6 +8235,13 @@ int v38; // [sp+158h] [bp-Ch]@1 int v39; // [sp+15Ch] [bp-8h]@4 int v40; // [sp+160h] [bp-4h]@7 + + extern bool new_sky; + if (new_sky) + { + if (DrawSkyD3D_Skybox()) + return; + } v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z) / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY); @@ -7772,9 +8251,10 @@ _this._48607B(&stru_8019C8); _this.ptr_38->_48694B(); _this.uTileBitmapID = pOutdoor->uSky_TextureID; - _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? (int)&pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0); + _this.pTexture = (Texture *)(SLOWORD(pOutdoor->uSky_TextureID) != -1 ? &pBitmaps_LOD->pTextures[SLOWORD(pOutdoor->uSky_TextureID)] : 0); if (pOutdoor->uSky_TextureID == -1) return; + _this.field_58 = 0; _this.uNumVertices = 4; _this.v_18.x = -stru_5C6E00->SinCos(pIndoorCamera->sRotationX - stru_5C6E00->uIntegerHalfPi + 16); @@ -7859,7 +8339,7 @@ v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8; array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; - array_50AC10[i].flt_20 = 1.0 / (double)(v17 / 65536); + array_50AC10[i]._rhw = 1.0 / (double)(v17 / 65536); array_50AC10[i].u = (double)v35 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth); array_50AC10[i].v = (double)v36 / (65536.0 * pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID].uTextureWidth); } @@ -7867,22 +8347,22 @@ float t = (GetTickCount() % 96000) / 96000.0f; array_50AC10[0].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; - array_50AC10[0].flt_20 = 1; + array_50AC10[0]._rhw = 1; array_50AC10[0].u = 0; array_50AC10[0].v = 0 + t; array_50AC10[1].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; - array_50AC10[1].flt_20 = 1; + array_50AC10[1]._rhw = 1; array_50AC10[1].u = 0; array_50AC10[1].v = 1 + t; array_50AC10[2].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; - array_50AC10[2].flt_20 = 1; + array_50AC10[2]._rhw = 1; array_50AC10[2].u = 1; array_50AC10[2].v = 0 + t; array_50AC10[3].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; - array_50AC10[3].flt_20 = 1; + array_50AC10[3]._rhw = 1; array_50AC10[3].u = 1; array_50AC10[3].v = 1 + t; pRenderer->DrawStrip(_this.uNumVertices, &_this, @@ -9290,7 +9770,7 @@ v5 = uNumVertices; do { - v6 = v1 * array_507D30[v4].flt_20; + v6 = v1 * array_507D30[v4]._rhw; v7 = v6 * array_507D30[v4].vWorldViewPosition.y; memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4])); array_50AC10[v4].vWorldViewProjX = v2 - v7; @@ -18976,7 +19456,7 @@ double v2; // st7@1 v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001); - v->flt_20 = v1; + v->_rhw = v1; v2 = v1 * (double)pOutdoorCamera->int_fov_rad; v->vWorldViewProjX = (double)pViewport->uScreenCenterX - v2 * v->vWorldViewPosition.y; v->vWorldViewProjY = (double)pViewport->uScreenCenterY - v2 * v->vWorldViewPosition.z; @@ -19968,198 +20448,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 10:06:36 2013 +0600 +++ b/mm7_4.cpp Fri Feb 15 10:06:47 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; @@ -6758,7 +6758,7 @@ { memset(&Dst, 0, 0x7Cu); Dst.dwSize = 124; - if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, 1u) ) + if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) { //v26 = Dst.lpSurface; pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
--- a/mm7_6.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/mm7_6.cpp Fri Feb 15 10:06:47 2013 +0600 @@ -91,7 +91,7 @@ v5 = (char *)&array_507D30[0].vWorldViewPosition.y; v6 = v1; v23 = (char *)&array_507D30[0].flt_2C; - v26 = (char *)&array_507D30[0].flt_20; + v26 = (char *)&array_507D30[0]._rhw; v24 = array_507D30; v20 = (char *)&array_507D30[0].vWorldViewPosition.z; v21 = (char *)&array_507D30[0].vWorldViewPosition.y; @@ -228,7 +228,7 @@ return 0; v2 = (char *)&array_507D30[0].vWorldViewPosition.z; v3 = (char *)&array_507D30[0].vWorldViewPosition.y; - v24 = (char *)&array_507D30[0].flt_20; + v24 = (char *)&array_507D30[0]._rhw; v22 = array_507D30; v19 = (char *)&array_507D30[0].vWorldViewPosition.z; v20 = (char *)&array_507D30[0].vWorldViewPosition.y; @@ -359,7 +359,7 @@ return 0; v3 = (char *)&array_507D30[0].vWorldViewPosition.z; v4 = (char *)&array_507D30[0].vWorldViewPosition.y; - v25 = (char *)&array_507D30[0].flt_20; + v25 = (char *)&array_507D30[0]._rhw; v23 = array_507D30; v20 = (char *)&array_507D30[0].vWorldViewPosition.z; v21 = (char *)&array_507D30[0].vWorldViewPosition.y; @@ -718,7 +718,7 @@ v137 = (char *)&array_50A2B0[0].vWorldViewProjX; v128 = (char *)&array_50A2B0[0].vWorldViewProjY; v121 = (char *)&array_50A2B0[0].flt_2C; - v114 = (char *)&array_50A2B0[0].flt_20; + v114 = (char *)&array_50A2B0[0]._rhw; v7 = (char *)&array_50AC10[0].flt_2C; do { @@ -804,14 +804,14 @@ v24 = SLODWORD(v23) <= (signed int)pViewport->uViewportZ, v110 < 1) ) goto LABEL_112; - v25 = (char *)&array_509950[0].flt_20; + v25 = (char *)&array_509950[0]._rhw; v138 = array_509950; v129 = (char *)&array_50A2B0[0].vWorldViewProjX; v118 = (char *)&array_50A2B0[0].vWorldViewProjY; v133 = (char *)&array_509950[0].vWorldViewProjX; v122 = (char *)&array_509950[0].vWorldViewProjY; v124 = (char *)&array_509950[0].flt_2C; - v111 = (char *)&array_509950[0].flt_20; + v111 = (char *)&array_509950[0]._rhw; v26 = (char *)&array_50A2B0[0].flt_2C; while ( 2 ) { @@ -906,7 +906,7 @@ v119 = (char *)&array_508FF0[0].vWorldViewProjX; v139 = (char *)&array_508FF0[0].vWorldViewProjY; v125 = (char *)&array_508FF0[0].flt_2C; - v134 = (char *)&array_508FF0[0].flt_20; + v134 = (char *)&array_508FF0[0]._rhw; v45 = (char *)&array_509950[0].flt_2C; v112 = v115; while ( 2 ) @@ -997,7 +997,7 @@ v120 = (char *)&array_508690[0].vWorldViewProjX; v140 = (char *)&array_508690[0].vWorldViewProjY; v126 = (char *)&array_508690[0].flt_2C; - v135 = (char *)&array_508690[0].flt_20; + v135 = (char *)&array_508690[0]._rhw; v64 = (char *)&array_508FF0[0].flt_2C; v113 = v123; while ( 2 )
--- a/mm7_data.h Fri Feb 15 10:06:36 2013 +0600 +++ b/mm7_data.h Fri Feb 15 10:06:47 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();
--- a/stru9.cpp Fri Feb 15 10:06:36 2013 +0600 +++ b/stru9.cpp Fri Feb 15 10:06:47 2013 +0600 @@ -127,7 +127,7 @@ v14 = (VertexBuffer *)((char *)v14 + 48); *(float *)v15 = *(float *)&v15[(char *)&static_AE33A0 - (char *)pVertices]; *((float *)v15 + 1) = *(float *)&v15[i]; - *((float *)v15 + 8) = *(float *)&v15[(char *)&static_AE33A0.pVertices[0].flt_20 - (char *)pVertices]; + *((float *)v15 + 8) = *(float *)&v15[(char *)&static_AE33A0.pVertices[0]._rhw - (char *)pVertices]; *((float *)v15 + 9) = *(float *)&v15[(char *)&static_AE33A0.pVertices[0].u - (char *)pVertices]; v13 = static_AE33A0.uNumVertices; v15 += 48;