Mercurial > mm7
changeset 1225:42b41aaecd87
Слияние
author | Ritor1 |
---|---|
date | Wed, 05 Jun 2013 21:00:45 +0600 |
parents | 23632c91ed0a (current diff) 64cda98b739c (diff) |
children | 33b30398e286 |
files | Items.cpp mm7_1.cpp |
diffstat | 56 files changed, 1149 insertions(+), 1217 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Actor.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h>
--- a/Allocator.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Allocator.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <string.h> #include <stdio.h> #include "OSAPI.h"
--- a/Arcomage.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Arcomage.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <string> #include <assert.h>
--- a/AudioPlayer.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/AudioPlayer.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <string> #include <assert.h>
--- a/Chest.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Chest.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <stdio.h> #include <assert.h>
--- a/Events.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Events.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include <stdlib.h> @@ -1095,7 +1099,7 @@ if (v83 == 21 || // gold well on emerald isle v83 == 22 || v83 == 23 || v83 == 24 ) { - __debugbreak(); // find out what these decorations are + //__debugbreak(); // bonfire viewparams->bRedrawGameUI = true; } ++curr_seq_num;
--- a/GUIFont.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/GUIFont.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <string> #include <assert.h> @@ -27,600 +31,453 @@ char pTmpBuf3[10000]; +void DrawCharToBuff(unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight, unsigned __int16* pFontPalette, __int16 draw_color, int line_width); + + //----- (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; +{ + 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); + 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; - } + 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; +} //----- (0044D2FD) -------------------------------------------------------- -void GUIFont::_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) -{ - int v11; // ebx@1 - int v12; // edi@1 - char *v13; // eax@1 - char *v14; // eax@1 - unsigned __int16 *v15; // esi@1 - GUIFont *v16; // edi@4 - signed int v17; // ecx@4 - signed int v18; // eax@6 - int v19; // [sp+Ch] [bp-5Ch]@1 - int v20; // [sp+10h] [bp-58h]@1 - unsigned int v21; // [sp+14h] [bp-54h]@1 - unsigned int v22; // [sp+18h] [bp-50h]@1 - unsigned int v23; // [sp+1Ch] [bp-4Ch]@1 - unsigned int v24; // [sp+20h] [bp-48h]@1 - GUIFont *v25; // [sp+60h] [bp-8h]@1 - GUIFont *v26; // [sp+64h] [bp-4h]@1 - char *Stra; // [sp+70h] [bp+8h]@1 - int a4a; // [sp+74h] [bp+Ch]@4 - int a7a; // [sp+80h] [bp+18h]@2 +void GUIFont::_44D2FD_prolly_draw_credits_entry( GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h, + unsigned __int16 firstColor, unsigned __int16 secondColor, const char *pString, + unsigned __int16 *pPixels, unsigned int uPixelsWidth ) + { + char *work_string; // eax@1 + unsigned __int16 *curr_pixel_pos; // esi@1 + GUIFont *currentFont; // edi@4 + signed int start_str_pos; // ecx@4 + signed int line_w; // eax@6 + GUIWindow draw_window; // [sp+Ch] [bp-5Ch]@ + int currentColor; // [sp+74h] [bp+Ch]@4 + int half_frameX; // [sp+80h] [bp+18h]@2 - v11 = a7; - v22 = h; - v12 = Str; - v26 = this; - v24 = a4 + h - 1; - v21 = w; - v25 = pFont; - v23 = Str + w - 1; - ui_current_text_color = a7; - v19 = Str; - v20 = a4; - v13 = GUIFont::_44C933(pString, this, pFont, (int)&v19, 0, 1); - v14 = strtok(v13, "\n"); - Stra = v14; - v15 = &pPixels[uPixelsWidth * a4]; - if ( v14 ) + draw_window.uFrameHeight = h; + draw_window.uFrameW = uFrameY + h - 1; + draw_window.uFrameWidth = w; + draw_window.uFrameZ = uFrameX + w - 1; + ui_current_text_color = firstColor; + draw_window.uFrameX = uFrameX; + draw_window.uFrameY = uFrameY; + + work_string = GUIFont::FitTwoFontStringINWindow(pString, this, pSecondFont, &draw_window, 0, 1); + work_string = strtok(work_string, "\n"); + curr_pixel_pos = &pPixels[uPixelsWidth * uFrameY]; + if ( work_string ) { - a7a = v12 >> 1; + half_frameX = uFrameX >> 1; while ( 1 ) { - v16 = v26; - ui_current_text_color = v11; - v17 = 0; - a4a = v11; - if ( *v14 == '_' ) + currentFont = this; + ui_current_text_color = firstColor; + start_str_pos = 0; + currentColor = firstColor; + if ( *work_string == '_' ) { - v16 = v25; - a4a = a8; - ui_current_text_color = a8; - v17 = 1; + currentFont = pSecondFont; + currentColor = secondColor; + ui_current_text_color = secondColor; + start_str_pos = 1; } - v18 = (signed int)(w - v16->GetLineWidth(&v14[v17])) >> 1; - if ( v18 < 0 ) - v18 = 0; - v16->_44D0B5(a4a, a8, (int)&v15[v18 + a7a], Stra, uPixelsWidth); - v15 += uPixelsWidth * (LOBYTE(v16->uFontHeight) - 3); - Stra = strtok(0, "\n"); - if ( !Stra ) + line_w = (signed int)(w - currentFont->GetLineWidth(&work_string[start_str_pos]))/2; + if ( line_w < 0 ) + line_w = 0; + currentFont->DrawTextLineToBuff(currentColor, secondColor, &curr_pixel_pos[line_w + half_frameX], work_string, uPixelsWidth); + curr_pixel_pos += uPixelsWidth * (currentFont->uFontHeight - 3); + work_string = strtok(0, "\n"); + if ( !work_string ) break; - v14 = Stra; - } - } -} -// 5C6DB4: using guessed type int ui_current_text_color; - - -//----- (0044D1E7) -------------------------------------------------------- -void GUIFont::DrawTextLine(unsigned int uDefaultColor, signed int uX, signed int uY, const char *Str, int a6) -{ - size_t v6; // ebx@1 - GUIFont *pFont; // esi@1 - signed int v8; // edi@3 - unsigned __int8 v9; // cl@4 - int v10; // eax@5 - int v11; // ecx@5 - int v12; // ecx@6 - int v13; // ecx@7 - int v14; // ecx@9 - unsigned int v15; // edx@9 - unsigned __int16 v16; // cx@12 - unsigned __int8 *v17; // eax@12 - char Dest[20]; // [sp+Ch] [bp-1Ch]@16 - //char v19; // [sp+11h] [bp-17h]@16 - size_t v20; // [sp+20h] [bp-8h]@2 - int v21; // [sp+24h] [bp-4h]@1 - int uXa; // [sp+30h] [bp+8h]@9 - - v6 = 0; - v21 = uDefaultColor; - pFont = this; - if ( Str ) - { - v21 = ui_current_text_color; - v20 = strlen(Str); - if ( (signed int)v20 > 0 ) - { - v8 = uX; - do - { - if ( pFont->IsCharValid(v9 = Str[v6]) ) - { - v10 = v9; - v11 = v9 - 9; - if ( v11 ) - { - v12 = v11 - 1; - if ( !v12 ) - return; - v13 = v12 - 2; - if ( v13 ) - { - if ( v13 != 1 ) - { - v14 = 3 * v10 + 9; - v15 = *((int *)&pFont->cFirstChar + v14); - uXa = *((int *)&pFont->cFirstChar + v14); - if ( v15 ) - { - if ( (signed int)v6 > 0 ) - v8 += pFont->pMetrics[v10].uLeftSpacing; - v16 = v21; - v17 = (unsigned __int8 *)((char *)&pFont[1] + pFont->field_C20[v10]); - if ( !v21 ) - v16 = -1; - pRenderer->DrawText(v8, uY, v17, v15, pFont->uFontHeight, pFont->pFontPalettes[0], v16, 0); - v8 += uXa; - if ( (signed int)v6 < (signed int)v20 ) - v8 += pFont->pMetrics[(unsigned __int8)Str[v6]].uRightSpacing; - } - } - } - else - { - strncpy(Dest, &Str[v6 + 1], 5u); - Dest[5] = 0; - v21 = atoi(Dest); - ui_current_text_color = v21; - v6 += 5; - } - } - } - ++v6; - } - while ( (signed int)v6 < (signed int)v20 ); } } } -// 5C6DB4: using guessed type int ui_current_text_color; + + + +//----- (0044D1E7) -------------------------------------------------------- +void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY, + const char *text, int max_len_pix ) +{ + signed int uX_pos; // edi@3 + unsigned char c; // cl@4 + unsigned __int16 draw_color; // cx@12 + unsigned __int8 *pCharPixels; // eax@12 + char color_code[20]; // [sp+Ch] [bp-1Ch]@16 + int text_length; // [sp+20h] [bp-8h]@2 + int text_color; // [sp+24h] [bp-4h]@1 + int uCharWidth; // [sp+30h] [bp+8h]@9 + if ( !text ) + return; + text_color = ui_current_text_color; + text_length = strlen(text); + uX_pos=uX; + for (int i=0; i<text_length; ++i ) + { + c = text[i]; + if ( IsCharValid(c) ) + { + switch (c) + { + case '\n': //Line Feed 0A 10: + return; + break; + case '\f': //Form Feed, page eject 0C 12 + strncpy(color_code, &text[i + 1], 5); + color_code[5] = 0; + text_color = atoi(color_code); + ui_current_text_color = text_color; + i += 5; + break; + case '\t': // Horizontal tab 09 + case '\r': //Carriage Return 0D 13 + break; + default: + uCharWidth = pMetrics[c].uWidth; + if ( uCharWidth ) + { + if ( i > 0 ) + uX_pos += pMetrics[c].uLeftSpacing; + draw_color = text_color; + pCharPixels = &pFontData[font_pixels_offset[c]]; + if ( !text_color ) + draw_color = -1; + pRenderer->DrawText(uX_pos, uY, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, 0); + uX_pos += uCharWidth; + if ( i < text_length ) + uX_pos += pMetrics[c].uRightSpacing; + } + } + } + } + +} + +//----- (0040F845) -------------------------------------------------------- +void DrawCharToBuff( unsigned short* uXpos,unsigned char* pCharPixels, int uCharWidth, int uCharHeight, + unsigned __int16* pFontPalette, __int16 draw_color, int line_width ) + { + unsigned __int16* draw_buff; // edi@1 + unsigned char* pPixels; // esi@1 + unsigned char char_pxl; // eax@3 + + draw_buff = uXpos; + pPixels = pCharPixels; + for(int i=0; i<uCharHeight; ++i) + { + for(int j=0; j<uCharWidth; ++j) + { + char_pxl = *pPixels++; + if ( char_pxl ) + { + if ( char_pxl == 1 ) + *draw_buff = pFontPalette[1]; + else + *draw_buff = draw_color; + } + ++draw_buff; + } + draw_buff+=line_width-uCharWidth; + } + +} //----- (0044D0B5) -------------------------------------------------------- -void GUIFont::_44D0B5(int a2, int a3, int a4, const char *pString, int a6) -{ - int v6; // ebx@1 - GUIFont *v7; // esi@1 - int v8; // edi@3 - unsigned __int8 v9; // cl@4 - int v10; // eax@5 - int v11; // ecx@5 - int v12; // ecx@6 - int v13; // ecx@7 - int v14; // ecx@8 - int v15; // ebx@10 - int v16; // edx@13 - __int16 v17; // ax@13 - char Dest; // [sp+Ch] [bp-20h]@17 - char v19; // [sp+11h] [bp-1Bh]@17 - size_t v20; // [sp+20h] [bp-Ch]@2 - int v21; // [sp+24h] [bp-8h]@1 - int v22; // [sp+28h] [bp-4h]@2 - const char *v23; // [sp+38h] [bp+Ch]@4 +void GUIFont::DrawTextLineToBuff( int uColor, int a3, unsigned short* uX_buff_pos, const char *text, int line_width ) + { + + unsigned short* uX_pos; // edi@3 + unsigned char c; // cl@4 + unsigned __int16 draw_color; // cx@12 + unsigned __int8 *pCharPixels; // eax@12 + char color_code[20]; // [sp+Ch] [bp-1Ch]@16 + int text_length; // [sp+20h] [bp-8h]@2 + int text_color; // [sp+24h] [bp-4h]@1 + int uCharWidth; // [sp+30h] [bp+8h]@9 - v6 = 0; - v21 = a2; - v7 = this; - if ( pString ) - { - v21 = ui_current_text_color; - v20 = strlen(pString); - v22 = 0; - if ( (signed int)v20 > 0 ) - { - v8 = a4; - do + if ( !text ) + return; + text_color = ui_current_text_color; + text_length = strlen(text); + uX_pos=uX_buff_pos; + for (int i=0; i<text_length; ++i ) { - v23 = &pString[v6]; - if ( v7->IsCharValid(v9 = pString[v6]) ) - { - v10 = v9; - v11 = v9 - 9; - if ( v11 ) + c = text[i]; + if ( IsCharValid(c) ) { - v12 = v11 - 1; - if ( !v12 ) + switch (c) + { + case '\n': //Line Feed 0A 10: return; - v13 = v12 - 2; - if ( v13 ) - { - v14 = v13 - 1; - if ( v14 ) - { - if ( v14 != 82 ) - { - v15 = *((int *)&v7->cFirstChar + 3 * v10 + 9); - if ( v15 ) + break; + case '\f': //Form Feed, page eject 0C 12 + strncpy(color_code, &text[i + 1], 5); + color_code[5] = 0; + text_color = atoi(color_code); + ui_current_text_color = text_color; + i += 5; + break; + case '\t': // Horizontal tab 09 + case '_': + break; + default: + uCharWidth = pMetrics[c].uWidth; + if ( uCharWidth ) { - if ( v22 > 0 ) - v8 += 2 * v7->pMetrics[v10].uLeftSpacing; - v16 = (int)((char *)&v7[1] + v7->field_C20[v10]); - v17 = v21; - if ( !v21 ) - v17 = -1; - sub_40F845(v8, v16, v15, LOBYTE(v7->uFontHeight), (int)v7->pFontPalettes[0], v17, 2 * a6); - v8 += 2 * v15; - if ( v22 < (signed int)v20 ) - v8 += 2 * v7->pMetrics[(unsigned __int8)*v23].uRightSpacing; + if ( i > 0 ) + uX_pos += pMetrics[c].uLeftSpacing; + draw_color = text_color; + pCharPixels = &pFontData[font_pixels_offset[c]]; + if ( !text_color ) + draw_color = -1; + DrawCharToBuff(uX_pos, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, line_width); + uX_pos += uCharWidth; + if ( i < text_length ) + uX_pos += pMetrics[c].uRightSpacing; } - } } - } - else - { - strncpy(&Dest, &pString[v6 + 1], 5u); - v19 = 0; - v21 = atoi(&Dest); - ui_current_text_color = v21; - v22 = v6 + 5; - } } - } - v6 = v22++ + 1; } - while ( v22 < (signed int)v20 ); - } - } } -// 5C6DB4: using guessed type int ui_current_text_color; + //----- (0044C933) -------------------------------------------------------- -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 - size_t v9; // edi@3 - int v10; // eax@3 - GUIFont *v11; // esi@3 - int v12; // ebx@3 - char v13; // cl@5 - int v14; // edx@11 - int v15; // ecx@11 - int v16; // edx@12 - int v17; // edx@13 - int v18; // edx@14 - int v19; // edx@15 - int v20; // edi@17 - int v21; // edx@17 - int v22; // ecx@17 - int v23; // edi@18 - char v24; // zf@18 - int v25; // ecx@19 - int v26; // eax@19 - char v27; // dl@24 - int v28; // eax@46 - std::string v29; // [sp-18h] [bp-48h]@2 - const char *v30; // [sp-8h] [bp-38h]@2 - int v31; // [sp-4h] [bp-34h]@2 - const char *v32; // [sp+Ch] [bp-24h]@1 - char Str; // [sp+10h] [bp-20h]@46 - char v34; // [sp+13h] [bp-1Dh]@46 - GUIFont *v35; // [sp+14h] [bp-1Ch]@1 - int v36; // [sp+18h] [bp-18h]@3 - int v37; // [sp+1Ch] [bp-14h]@3 - int v38; // [sp+20h] [bp-10h]@4 - int v39; // [sp+24h] [bp-Ch]@3 - int v40; // [sp+28h] [bp-8h]@3 - int i; // [sp+2Ch] [bp-4h]@17 - std::string *v42; // [sp+38h] [bp+8h]@2 +char * GUIFont::FitTwoFontStringINWindow( const char *pString, GUIFont *pFontMain, GUIFont *pFontSecond, GUIWindow* pWindow, int startPixlOff, int a6 ) + { + + GUIFont *currentFont; // esi@3 + unsigned char c; + int uInStrLen; + char digits[4]; + int possible_transition_point; + int string_pixel_Width; + int start_pixel_offset; + + if (!pString) + { + MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:445", 0); + return 0; + } + currentFont=pFontMain; // esi@3 + uInStrLen = strlen(pString); + assert(uInStrLen < sizeof(pTmpBuf3)); + strcpy(pTmpBuf3, pString); + if (uInStrLen==0) + return pTmpBuf3; - v6 = pString; - v35 = pFont; - v32 = pString; - if ( !pString ) - { - MessageBoxW(nullptr, L"Invalid string passed !", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Font.cpp:558", 0); - return 0; - } - v8 = strlen(pString); - v9 = v8; - v39 = v8; + start_pixel_offset=string_pixel_Width=startPixlOff; + possible_transition_point=0; + for(int i=0; i<uInStrLen; ++i) + { + c=pTmpBuf3[i]; + if (pFontMain->IsCharValid(c)) + { + switch (c) + { + case '\t': // Horizontal tab 09 + { + strncpy(digits, &pTmpBuf3[i+1],3); + digits[3]=0; + string_pixel_Width = atoi(digits)+startPixlOff; + i+=3; + break; + } + case '\n': //Line Feed 0A 10 + { + string_pixel_Width=start_pixel_offset; + possible_transition_point=i; + currentFont=pFontMain; + break; + } + case '\f': //Form Feed, page eject 0C 12 + { + i+=5; + break; + } + case '\r': //Carriage Return 0D 13 + { + if (!a6) + return (char*)pString; + break; + } + case ' ' : + { + string_pixel_Width+=currentFont->pMetrics[c].uWidth; + possible_transition_point=i; + break; + } + case '_' : + currentFont=pFontSecond; + break; + default: - assert(strlen(v6) < sizeof(pTmpBuf3)); - strcpy(pTmpBuf3, v6); - v10 = a5; - v11 = v35; - v12 = 0; - v40 = 0; - v37 = a5; - v36 = 0; - if ( (signed int)v9 > 0 ) - { - v38 = v9 - 1; - do - { - v13 = pTmpBuf3[v12]; - if ( (unsigned __int8)v13 >= v11->cFirstChar && (unsigned __int8)v13 <= v11->cLastChar - || v13 == '\f' - || v13 == '\r' - || v13 == '\t' - || v13 == '\n' ) - { - v14 = (unsigned __int8)v13 - 9; - v15 = (int)&v11->pMetrics[(unsigned __int8)v13]; - if ( v14 ) - { - v16 = v14 - 1; - if ( v16 ) - { - v17 = v16 - 2; - if ( v17 ) - { - v18 = v17 - 1; - if ( v18 ) - { - v19 = v18 - 19; - if ( v19 ) - { - if ( v19 == 63 ) - { - v11 = a3; - } - else + if ((string_pixel_Width+currentFont->pMetrics[c].uWidth+ currentFont->pMetrics[c].uLeftSpacing+ + currentFont->pMetrics[c].uRightSpacing)<pWindow->uFrameWidth) { - v20 = *(int *)(v15 + 8); - v21 = *(int *)(v15 + 4); - v22 = *(int *)v15; - i = v20; - if ( (unsigned int)(v10 + v20 + v22 + v21) < *(int *)(a4 + 8) ) - { - v12 = v36; - if ( v36 > v40 ) - v10 += v22; - v10 += v21; - if ( v36 < v39 ) - v10 += i; - } - else - { - v23 = v40; - v24 = v11 == a3; - pTmpBuf3[v40] = 10; - if ( v24 ) - { - v25 = v38; - v26 = v23 + 1; - while ( v25 >= v26 ) - { - pTmpBuf3[v25] = byte_5C45AF[v25]; - --v25; - } - ++v39; - ++v38; - pTmpBuf3[v23++ + 1] = 95; - v40 = v26; - } - v12 = v36; - v10 = v37; - for ( i = v23; i <= v36; ++i ) + if(i>possible_transition_point) + string_pixel_Width+=currentFont->pMetrics[c].uLeftSpacing; + string_pixel_Width+=currentFont->pMetrics[c].uWidth; + if (i<uInStrLen) + string_pixel_Width+=currentFont->pMetrics[c].uRightSpacing; + } + else + { + pTmpBuf3[possible_transition_point]='\n'; + + if ( currentFont== pFontSecond) { - v27 = pTmpBuf3[i]; - if ( (unsigned __int8)v27 >= v11->cFirstChar && (unsigned __int8)v27 <= v11->cLastChar - || v27 == 12 - || v27 == 13 - || v27 == 9 - || v27 == 10 ) - { - if ( i > v23 ) - v10 += v11->pMetrics[(unsigned __int8)v27].uLeftSpacing; - v10 += *((int *)&v11->cFirstChar + 3 * (unsigned __int8)v27 + 9); - if ( i < v36 ) - v10 += v11->pMetrics[(unsigned __int8)v27].uRightSpacing; - } + + for(int k=uInStrLen-1; k>=possible_transition_point+1; --k) + pTmpBuf3[k] = pTmpBuf3[k-1]; + + ++uInStrLen; + ++possible_transition_point; + pTmpBuf3[possible_transition_point] = '_'; + } - } + string_pixel_Width=start_pixel_offset; + + for(int j=possible_transition_point;j<i; ++j ) + { + c=pTmpBuf3[j]; + if (pFontMain->IsCharValid(c)) + { + if(j>possible_transition_point) + string_pixel_Width+=pFontMain->pMetrics[c].uLeftSpacing; + string_pixel_Width+=pFontMain->pMetrics[c].uWidth; + if (j<i) + string_pixel_Width+=pFontMain->pMetrics[c].uRightSpacing; + + } + } } - } - else - { - v10 += *(int *)(v15 + 4); - v40 = v12; - } - } - else - { - if ( !a6 ) - return (char *)v32; } - } - else - { - v12 += 5; - } } - else - { - v10 = v37; - v11 = v35; - v40 = v12; - } - } - else - { - strncpy(&Str, &pTmpBuf3[v12 + 1], 3u); - v34 = 0; - v28 = atoi(&Str); - v10 = a5 + v28; - v12 += 3; - v37 = v10; - } } - ++v12; - v36 = v12; - } - while ( v12 < v39 ); - } return pTmpBuf3; + } //----- (0044C6C2) -------------------------------------------------------- -int GUIFont::_44C6C2(const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5) -{ - const char *v5; // esi@1 - int v6; // edi@1 - unsigned __int8 *v8; // ebx@3 - size_t v9; // eax@3 - signed int v10; // esi@3 - int v11; // edx@4 - unsigned int v12; // cl@4 - GUIFont *v13; // [sp+Ch] [bp-4h]@1 - size_t uXa; // [sp+1Ch] [bp+Ch]@3 +char* GUIFont::_44C6C2( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) + { + int text_height; // edi@1 + char *text_str; // ebx@3 + int i; + unsigned char c; // cl@4 + int text_length; - auto pFont = this; - v5 = pInString; - v6 = 0; - v13 = pFont; + text_height = 0; + if ( !pInString ) return 0; - v8 = (unsigned __int8 *)FitTextInAWindow(pInString, pFont, pWindow, uX, 0); - v9 = strlen(v5); - v10 = 0; - uXa = v9; - if ( (signed int)v9 > 0 ) - { - while ( v10 < (signed int)uXa ) - { - if(IsCharValid(*v8)) - { - v12=(unsigned int)v8; - if ( v12 != 9 ) - { - if ( v12 == 10 ) - { - v6 = v6 + *(char *)(v11 + 5) - 3; - if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) - return (int)(v8 + 1); - if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) - return (int)v8; - } - else if ( v12 == 12 ) - { - v8 += 5; - v10 += 5; - if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) - return (int)v8; - } - else if ( v12 != 13 ) - { - if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) - return (int)v8; - } - } - if(v12 == 13 || v12 == 9) - { - v8 += 3; - v10 += 3; - } - if ( v6 >= (signed int)(a5 * pWindow->uFrameHeight) ) - return (int)v8; - } - ++v10; - ++v8; - } - } - return (int)v8; + text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); + text_length = strlen(text_str); + for (i=0; i<text_length; ++i ) + { + c = text_str[i]; + if ( IsCharValid(c) ) + { + switch (c) + { + case '\n': //Line Feed 0A 10: + text_height = text_height + uFontHeight - 3; + if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) + return &text_str[i+1]; + break; + case '\f': //Form Feed, page eject 0C 12 + i += 5; + break; + case '\t': // Horizontal tab 09 + case '\r': //Carriage Return 0D 13 + i += 3; + break; + } + if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) + break; + } + } + return &text_str[i]; } //----- (0044C62E) -------------------------------------------------------- -int GUIFont::GetStringHeight2(GUIFont *a2, const char *Str, int a4, int a5, int a6) -{ - GUIFont *v6; // edi@1 - int v8; // esi@3 - unsigned __int8 *v9; // ebx@3 - size_t v10; // eax@3 - unsigned __int8 v11; // cl@4 - signed int Stra; // [sp+Ch] [bp+8h]@3 - size_t v13; // [sp+14h] [bp+10h]@3 - - auto a1 = this; - v6 = a1; - if ( !Str ) - return 0; - v8 = LOBYTE(a1->uFontHeight) - 3; - v9 = (unsigned __int8 *)GUIFont::_44C933(Str, a1, a2, a4, a5, 0); - v10 = strlen(Str); - Stra = 0; - v13 = v10; - while ( Stra < (signed int)v13 ) - { - if ( GUIFont::IsCharValid(v11 = *v9) ) +int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 ) { - if ( v11 == 9 ) - goto LABEL_9; - switch ( v11 ) + + int uAllHeght; + int uStringLen; + unsigned char c; + char *test_string; + + if ( !text_str ) + return 0; + uAllHeght = uFontHeight - 3; + test_string = FitTwoFontStringINWindow(text_str, this, secondFont, pWindow, startX, 0); + uStringLen = strlen(test_string); + for (int i = 0; i < uStringLen; ++i) { - case 0xAu: - v8 = v8 + LOBYTE(v6->uFontHeight) - 3; - break; - case 0xCu: - v9 += 5; - Stra += 5; - break; - case 0xDu: -LABEL_9: - if ( a6 != 1 ) + c = test_string[i]; + if (IsCharValid(c)) { - v9 += 3; - Stra += 3; + switch (c) + { + case '\n': //Line Feed 0A 10: + uAllHeght+= 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 (a6 != 1) + i += 3; + break; + } } - break; } - } - ++Stra; - ++v9; - } - return v8; + + return uAllHeght; } //----- (0044C59D) -------------------------------------------------------- -int GUIFont::CalcTextHeight(const char *pString, GUIWindow *pWindow, int uXOffset, int a5) - { +int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) + { int uAllHeght; - unsigned int uStringLen; - char c; + int uStringLen; + unsigned char c; char *test_string; if (!pString) return 0; - uAllHeght = this->uFontHeight - 3; + uAllHeght = uFontHeight - 3; test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); uStringLen = strlen(pString); for (int i = 0; i < uStringLen; ++i) @@ -631,7 +488,7 @@ switch (c) { case '\n': //Line Feed 0A 10: - uAllHeght+= this->uFontHeight - 3; + uAllHeght+= uFontHeight - 3; break; case '\f': //Form Feed, page eject 0C 12 i += 5; @@ -651,7 +508,7 @@ //----- (0044C51E) -------------------------------------------------------- int GUIFont::GetLineWidth(const char *pString) { - unsigned int str_len; // ebp@3 + int str_len; // ebp@3 int string_line_width; // esi@3 unsigned char c; @@ -675,10 +532,10 @@ break; default: if (i > 0) - string_line_width += this->pMetrics[c].uLeftSpacing; - string_line_width += this->pMetrics[c].uWidth; + string_line_width += pMetrics[c].uLeftSpacing; + string_line_width += pMetrics[c].uWidth; if (i < str_len) - string_line_width +=this->pMetrics[c].uRightSpacing; + string_line_width +=pMetrics[c].uRightSpacing; } } } @@ -703,7 +560,7 @@ char * FitTextInAWindow( const char *pInString, GUIFont *pFont, GUIWindow *pWindow, signed int uX, int a5 ) { unsigned char c; - unsigned int uInStrLen; + int uInStrLen; char digits[4]; int possible_transition_point; int string_pixel_Width;
--- a/GUIFont.h Wed Jun 05 21:00:11 2013 +0600 +++ b/GUIFont.h Wed Jun 05 21:00:45 2013 +0600 @@ -20,26 +20,29 @@ bool IsCharValid(unsigned 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); - int GetStringHeight2(GUIFont *a2, const char *Str, int a4, int a5, int a6); - int _44C6C2(const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5); - void _44D0B5(int a2, int a3, int a4, const char *pString, int a6); - 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); + int CalcTextHeight(const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5); + int GetStringHeight2(GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6); + char* _44C6C2(const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5); + void DrawTextLineToBuff(int uColor, int a3, unsigned short* uX_buff_pos, const char *text, int line_width); + void DrawTextLine(unsigned int uDefaultColor, signed int uX, signed int uY, const char *text, int max_len_pix); + void _44D2FD_prolly_draw_credits_entry(GUIFont *pSecondFont, int uFrameX, int uFrameY, unsigned int w, unsigned int h, + unsigned __int16 firstColor, unsigned __int16 secondColor, const char *pString, + unsigned __int16 *pPixels, unsigned int uPixelsWidth); - static char * _44C933(const char *pString, GUIFont *pFont, GUIFont *a3, int a4, int a5, int a6); + static char * FitTwoFontStringINWindow(const char *pString, GUIFont *pFontMain, GUIFont *pFontSecond, GUIWindow* pWindow, int startPixlOff, int a6); - unsigned char cFirstChar; - unsigned char cLastChar; + unsigned char cFirstChar; //0 + unsigned char cLastChar; //1 char field_2; char field_3; char field_4; - __int16 uFontHeight; + __int16 uFontHeight; //5-6 char field_7; int palletes_count; unsigned __int16 *pFontPalettes[5]; GUICharMetric pMetrics[256]; - int field_C20[256]; + int font_pixels_offset[256]; + unsigned char pFontData[0]; //array of font pixels }; #pragma pack(pop)
--- a/GUIProgressBar.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/GUIProgressBar.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "GUIProgressBar.h"
--- a/GUIWindow.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/GUIWindow.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "GUIWindow.h" #include "GUIFont.h" #include "Party.h" @@ -1379,7 +1383,7 @@ v28 = *((int *)&v10->cFirstChar + 3 * v15 + 9); if ( v14 > 0 ) v12 += v10->pMetrics[v15].uLeftSpacing; - v17 = (int)((char *)&v10[1] + v10->field_C20[v15]); + v17 = (int)((char *)&v10[1] + v10->font_pixels_offset[v15]); if ( (short)uFontColor ) pRenderer->DrawText( v12, @@ -1546,7 +1550,7 @@ v34 = *((int *)&pFont->cFirstChar + 3 * v16 + 9); if ( (signed int)Str1b > 0 ) v13 += pFont->pMetrics[v16].uLeftSpacing; - v21 = (int)((char *)&pFont[1] + pFont->field_C20[v16]); + v21 = (int)((char *)&pFont[1] + pFont->font_pixels_offset[v16]); if ( (short)uColor ) pRenderer->DrawText(v13, v14, (unsigned __int8 *)v21, v20, LOBYTE(pFont->uFontHeight), pFont->pFontPalettes[0], uColor, 0); else
--- a/Game.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Game.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "Vis.h"
--- a/Indoor.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Indoor.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "LightmapBuilder.h" @@ -1722,7 +1726,7 @@ signed int v2; // esi@1 for (uint i = 0; i < 11; ++i) - if (!strcmpi(Str1, _4E6BDC_loc_names[i])) + if (!_stricmp(Str1, _4E6BDC_loc_names[i])) return i + 1; return 0; } @@ -2781,7 +2785,7 @@ if (dword_6BE364_game_settings_1 & 0x2000 ) _i = 29030400; bool _a = false; - if ( a3 - dlv.uLastRepawnDay >= _i && strcmpi(pCurrentMapName, "d29.dlv") ) + if ( a3 - dlv.uLastRepawnDay >= _i && _stricmp(pCurrentMapName, "d29.dlv") ) _a = true; //v154 = 875; @@ -4190,14 +4194,14 @@ } if ( v0->GetActorsRelation(0) ) { - v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[11].uExpireTime), v22); - v49 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == v22; - v50 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) - v22 < 0; + v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22); + v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22; + v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0; v0->vVelocity.y = v22; v0->vVelocity.x = v22; if ( !(v50 ^ v51) - && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v22) ) - pParty->pPartyBuffs[11].Reset(); + && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > v22) ) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = 1; goto LABEL_119; }
--- a/Items.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Items.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <stdlib.h> #include <assert.h> @@ -790,7 +794,7 @@ { for(int ii=0; ii<24; ++ii) { - if (stricmp(test_string,pEnchantments[ii].pBonusStat)) + if (_stricmp(test_string,pEnchantments[ii].pBonusStat)) { pItems[item_counter]._bonus_type=ii+1; break; @@ -800,7 +804,7 @@ { for(int ii=0; ii<72; ++ii) { - if (stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement)) + if (_stricmp(test_string,pSpecialEnchantments[ii].pBonusStatement)) { pItems[item_counter]._additional_value=ii+1; }
--- a/Keyboard.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Keyboard.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "OSAPI.h" #include "Keyboard.h"
--- a/LOD.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/LOD.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "LOD.h" #include "Render.h" #include "Allocator.h" @@ -2015,7 +2019,7 @@ if (bLinearSearch) { for (uint i = 0; i < uNumSubDirs; ++i) - if (!strcmpi(pContainer_Name, pSubIndices[i].pFilename)) + if (!_stricmp(pContainer_Name, pSubIndices[i].pFilename)) { v4 = pSubIndices[i].uOfsetFromSubindicesStart; fseek(pFile, uOffsetToSubIndex + v4, SEEK_SET); @@ -2640,9 +2644,9 @@ ptr_011BB4 = new char[1000]; memset(ptr_011BB4, 0, 1000); } - if (strnicmp(pContainer, "wtrdr", 5))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' ) + if (_strnicmp(pContainer, "wtrdr", 5))//*v4 != 'w' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'd' || v4[4] != 'r' ) { - if (strnicmp(pContainer, "WtrTyl", 6))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' ) + if (_strnicmp(pContainer, "WtrTyl", 6))//if ( *v4 != 'W' || v4[1] != 't' || v4[2] != 'r' || v4[3] != 'T' || v4[4] != 'y' || v4[5] != 'l' ) { v14 = uNumLoadedFiles; } @@ -2899,7 +2903,7 @@ areWeLoadingTexture = 1; for (uint i = 0; i < uNumLoadedFiles; ++i) - if (!strcmpi(pContainer, pTextures[i].pName)) + if (!_stricmp(pContainer, pTextures[i].pName)) return i; // if (!uNumLoadedFiles)
--- a/MM7.h Wed Jun 05 21:00:11 2013 +0600 +++ b/MM7.h Wed Jun 05 21:00:45 2013 +0600 @@ -5,20 +5,6 @@ #include <string> typedef unsigned int uint; -#define LOWORD(a) (*((unsigned short *)&a)) -#define HIWORD(a) (*((unsigned short *)&a + 1)) -#define SHIWORD(a) (*((short *)&a + 1)) - -#define LODWORD(a) (*((unsigned int *)&a)) -#define HIDWORD(a) (*((unsigned int *)&a + 1)) -#define SLODWORD(a) (*((int *)&a)) -#define SHIDWORD(a) (*((int *)&a + 1)) - -#define LOBYTE(a) (*((unsigned char *)&a)) -#define HIBYTE(a) (*((unsigned char *)&a + sizeof(a) - 1)) -#define BYTE1(a) (*((unsigned char *)&a + 1)) -#define BYTE2(a) (*((unsigned char *)&a + 2)) -#define BYTE3(a) (*((unsigned char *)&a + 3)) #define PID(type, id) (unsigned int)((((8 * (id))) | (type)) & 0xFFFF) // packed id #define PID_TYPE(pid) (unsigned int)((pid) & 7) // extract type
--- a/Monsters.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Monsters.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <stdlib.h> #include <stdio.h> #include <string.h>
--- a/Mouse.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Mouse.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "OSAPI.h" #include "VideoPlayer.h" @@ -31,7 +35,7 @@ void Mouse::RemoveHoldingItem() { pParty->pPickedItem.Reset(); - if (strcmpi(pCurrentCursorName, "MICON2")) + if (_stricmp(pCurrentCursorName, "MICON2")) SetCursorBitmap("MICON1"); }
--- a/NPC.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/NPC.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,4 +1,6 @@ - +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif #include "Allocator.h" #include "texts.h"
--- a/Outdoor.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Outdoor.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "stru6.h"
--- a/Overlays.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Overlays.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <stdlib.h> #include "Overlays.h"
--- a/PaletteManager.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/PaletteManager.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "PaletteManager.h"
--- a/Party.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Party.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "Party.h" @@ -838,8 +842,8 @@ int v3; // eax@9 unsigned int v4; // [sp+8h] [bp-4h]@4 - if ( (signed __int64)pParty->pPartyBuffs[11].uExpireTime > 0 ) - pParty->pPartyBuffs[11].Reset(); + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); if ( pParty->bTurnBasedModeOn != 1 ) { v4 = 0;
--- a/Player.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Player.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "stru6.h" @@ -1075,10 +1079,10 @@ PlaySound((PlayerSpeech)30, 0); break; case Condition_Weak: - if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 ) - {--pParty->pPartyBuffs[13].uPower; - if ( pParty->pPartyBuffs[13].uPower < 1u ) - pParty->pPartyBuffs[13].Reset(); + if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 ) + {--pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); return 0; } @@ -1111,11 +1115,11 @@ case Condition_Poison3: if ( a3 == 1 ) { - if ( (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0i64 ) + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) { - --pParty->pPartyBuffs[13].uPower; - if ( pParty->pPartyBuffs[13].uPower < 1u ) - pParty->pPartyBuffs[13].Reset(); + --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); } if ( HasEnchantedItemEquipped(21) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) @@ -1133,11 +1137,11 @@ case Condition_Disease3: if ( a3 == 1 ) { - if ( pParty->pPartyBuffs[13].uExpireTime > 0i64 ) + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) { - --pParty->pPartyBuffs[13].uPower; - if ( pParty->pPartyBuffs[13].uPower < 1u ) - pParty->pPartyBuffs[13].Reset(); + --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); return 0; } @@ -1151,11 +1155,11 @@ case Condition_Paralyzed: if ( a3 == 1 ) { - if ( pParty->pPartyBuffs[13].uExpireTime > 0i64 ) + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) { - --pParty->pPartyBuffs[13].uPower; - if ( pParty->pPartyBuffs[13].uPower < 1u ) - pParty->pPartyBuffs[13].Reset(); + --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); return 0; } @@ -1172,11 +1176,11 @@ sHealth = 0; break; case Condition_Dead: - if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0i64 && pParty->pPartyBuffs[13].uSkill >= 4u ) + if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u ) { - --pParty->pPartyBuffs[13].uPower; - if ( pParty->pPartyBuffs[13].uPower < 1u ) - pParty->pPartyBuffs[13].Reset(); + --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); } PlaySound((PlayerSpeech)33, 0); @@ -1187,7 +1191,7 @@ break; case Condition_Pertified: if ( a3 == 1 - &&((pParty->pPartyBuffs[13].uExpireTime > 0i64) + &&((pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64) || HasEnchantedItemEquipped(23)|| WearsItem(ITEM_RELIC_KELEBRIM, EQIUP_ANY) || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || @@ -1197,11 +1201,11 @@ PlaySound((PlayerSpeech)34, 0); break; case Condition_Eradicated: - if ( a3 == 1 && ((signed __int64)pParty->pPartyBuffs[13].uExpireTime > 0 )&&( pParty->pPartyBuffs[13].uSkill >= 4u )) + if ( a3 == 1 && ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 )&&( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u )) { - --pParty->pPartyBuffs[13].uPower; - if ( pParty->pPartyBuffs[13].uPower < 1u ) - pParty->pPartyBuffs[13].Reset(); + --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); return 0; } PlaySound(SPEECH_35, 0); @@ -5333,25 +5337,25 @@ { case CHARACTER_ATTRIBUTE_RESIST_BODY: v3 = this->pPlayerBuffs[2].uPower; - v4 = pParty->pPartyBuffs[1].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_BODY].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_AIR: v3 = this->pPlayerBuffs[0].uPower; - v4 = pParty->pPartyBuffs[0].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_WATER: v3 = this->pPlayerBuffs[22].uPower; - v4 = pParty->pPartyBuffs[17].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].uPower; break; case CHARACTER_ATTRIBUTE_RESIST_EARTH: v3 = this->pPlayerBuffs[3].uPower; - v4 = pParty->pPartyBuffs[4].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].uPower; break; default: if ( a2 != 14 ) return result; v3 = this->pPlayerBuffs[9].uPower; - v4 = pParty->pPartyBuffs[12].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].uPower; break; } return v4 + v3; @@ -5361,7 +5365,7 @@ if ( a2 == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) { v3 = this->pPlayerBuffs[8].uPower; - v4 = pParty->pPartyBuffs[9].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_HEROISM].uPower; return v4 + v3; } if ( a2 != CHARACTER_ATTRIBUTE_RANGED_ATTACK ) @@ -5372,7 +5376,7 @@ if ( a2 == 10 ) { v3 = this->pPlayerBuffs[5].uPower; - v4 = pParty->pPartyBuffs[6].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].uPower; return v4 + v3; } switch ( a2 ) @@ -5398,11 +5402,11 @@ case CHARACTER_ATTRIBUTE_LUCK: v3 = pPlayerBuffs[18].uPower; LABEL_5: - v4 = pParty->pPartyBuffs[2].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].uPower; return v4 + v3; case CHARACTER_ATTRIBUTE_AC_BONUS: v3 = this->pPlayerBuffs[14].uPower; - v4 = pParty->pPartyBuffs[15].uPower; + v4 = pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].uPower; return v4 + v3; default: return result; @@ -7402,7 +7406,7 @@ switch ( VarNum ) { case VAR_Invisible: - if ( pParty->pPartyBuffs[11].uExpireTime >0 ) + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime >0 ) return true; return false; case VAR_NumDeaths: @@ -7491,7 +7495,7 @@ return v6; case VAR_IsFlying: if ( pParty->bFlying - && (pParty->pPartyBuffs[7].uExpireTime> 0) ) + && (pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime> 0) ) return true; return false; case VAR_HiredNPCHasSpeciality:
--- a/Player.h Wed Jun 05 21:00:11 2013 +0600 +++ b/Player.h Wed Jun 05 21:00:45 2013 +0600 @@ -201,7 +201,7 @@ }; /* 328 */ -enum PLAYER_SKILL_TYPE: __int8 +enum PLAYER_SKILL_TYPE: signed __int8 { PLAYER_SKILL_STAFF = 0, PLAYER_SKILL_SWORD = 1, @@ -591,31 +591,31 @@ bool Recover(signed int a2); bool CanCastSpell(unsigned int uRequiredMana); - inline bool Weak() {return pConditions[Condition::Condition_Weak] != 0;} - inline bool Dead() {return pConditions[Condition::Condition_Dead] != 0;} - inline bool Eradicated() {return pConditions[Condition::Condition_Eradicated] != 0;} - inline bool Zombie() {return pConditions[Condition::Condition_Zombie] != 0;} - inline bool Cursed() {return pConditions[Condition::Condition_Cursed] != 0;} - inline bool Pertified() {return pConditions[Condition::Condition_Pertified] != 0;} + inline bool Weak() {return pConditions[Condition_Weak] != 0;} + inline bool Dead() {return pConditions[Condition_Dead] != 0;} + inline bool Eradicated() {return pConditions[Condition_Eradicated] != 0;} + inline bool Zombie() {return pConditions[Condition_Zombie] != 0;} + inline bool Cursed() {return pConditions[Condition_Cursed] != 0;} + inline bool Pertified() {return pConditions[Condition_Pertified] != 0;} - inline void SetCursed(bool state) {pConditions[Condition::Condition_Cursed] = state;} - inline void SetWeak(bool state) {pConditions[Condition::Condition_Weak] = state;} - inline void SetAsleep(bool state) {pConditions[Condition::Condition_Sleep] = state;} - inline void SetAfraid(bool state) {pConditions[Condition::Condition_Fear] = state;} - inline void SetDrunk(bool state) {pConditions[Condition::Condition_Drunk] = state;} - inline void SetInsane(bool state) {pConditions[Condition::Condition_Insane] = state;} - inline void SetPoison1(bool state) {pConditions[Condition::Condition_Poison1] = state;} - inline void SetDisease1(bool state) {pConditions[Condition::Condition_Disease1] = state;} - inline void SetPoison2(bool state) {pConditions[Condition::Condition_Poison2] = state;} - inline void SetDisease2(bool state) {pConditions[Condition::Condition_Disease2] = state;} - inline void SetPoison3(bool state) {pConditions[Condition::Condition_Poison3] = state;} - inline void SetDisease3(bool state) {pConditions[Condition::Condition_Disease3] = state;} - inline void SetParalyzed(bool state) {pConditions[Condition::Condition_Paralyzed] = state;} - inline void SetUnconcious(bool state) {pConditions[Condition::Condition_Unconcious] = state;} - inline void SetDead(bool state) {pConditions[Condition::Condition_Dead] = state;} - inline void SetPertified(bool state) {pConditions[Condition::Condition_Pertified] = state;} - inline void SetEradicated(bool state) {pConditions[Condition::Condition_Eradicated] = state;} - inline void SetZombie(bool state) {pConditions[Condition::Condition_Zombie] = state;} + inline void SetCursed(bool state) {pConditions[Condition_Cursed] = state;} + inline void SetWeak(bool state) {pConditions[Condition_Weak] = state;} + inline void SetAsleep(bool state) {pConditions[Condition_Sleep] = state;} + inline void SetAfraid(bool state) {pConditions[Condition_Fear] = state;} + inline void SetDrunk(bool state) {pConditions[Condition_Drunk] = state;} + inline void SetInsane(bool state) {pConditions[Condition_Insane] = state;} + inline void SetPoison1(bool state) {pConditions[Condition_Poison1] = state;} + inline void SetDisease1(bool state) {pConditions[Condition_Disease1] = state;} + inline void SetPoison2(bool state) {pConditions[Condition_Poison2] = state;} + inline void SetDisease2(bool state) {pConditions[Condition_Disease2] = state;} + inline void SetPoison3(bool state) {pConditions[Condition_Poison3] = state;} + inline void SetDisease3(bool state) {pConditions[Condition_Disease3] = state;} + inline void SetParalyzed(bool state) {pConditions[Condition_Paralyzed] = state;} + inline void SetUnconcious(bool state) {pConditions[Condition_Unconcious] = state;} + inline void SetDead(bool state) {pConditions[Condition_Dead] = state;} + inline void SetPertified(bool state) {pConditions[Condition_Pertified] = state;} + inline void SetEradicated(bool state) {pConditions[Condition_Eradicated] = state;} + inline void SetZombie(bool state) {pConditions[Condition_Zombie] = state;}
--- a/Render.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Render.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "VideoPlayer.h" @@ -904,7 +908,7 @@ int v30; // ecx@64 int v31; // ecx@68 int v32; // eax@70 - int v33; // ecx@71 + //int v33; // ecx@71 int v34; // eax@73 int v35; // ecx@77 int v36; // ecx@81 @@ -913,7 +917,7 @@ int v39; // ecx@88 int v40; // eax@90 int v41; // edx@94 - int v42; // ecx@95 + //int v42; // ecx@95 int v43; // ecx@98 int v44; // ecx@102 int v45; // eax@104 @@ -931,7 +935,7 @@ int v57; // ecx@140 int v58; // eax@142 int v59; // ecx@146 - int v60; // ecx@147 + //int v60; // ecx@147 int v61; // ecx@150 int v62; // ecx@155 int v63; // eax@157 @@ -946,7 +950,7 @@ //int v72; // ecx@178 //int x; // ebx@180 //int v74; // eax@182 - int v75; // eax@184 + //int v75; // eax@184 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 int uStartZ; // ecx@184 int v79; // ebx@185 @@ -992,11 +996,11 @@ v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 - v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; - v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16; + v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;//88 + v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;// 66 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; - v2 = pOutdoorCamera->uCameraFovInDegrees + 15; + v2 = pOutdoorCamera->uCameraFovInDegrees + 15;//90 i = v124 - pOutdoorCamera->outdoor_grid_band_3; v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; @@ -1005,42 +1009,50 @@ v3 = (v2 << 11) / 720; v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); + v106 = stru_5C6E00->Cos(v4); uEndZ = stru_5C6E00->Sin(v4); + v111 = stru_5C6E00->Cos(v5); v6 = stru_5C6E00->Sin(v5); + v7 = v4 & stru_5C6E00->uPiMask; - if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; else v8 = stru_5C6E00->pTanTable[v7]; v112 = abs(v8); + v9 = v5 & stru_5C6E00->uPiMask; if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; else v10 = stru_5C6E00->pTanTable[v9]; v108 = abs(v10); + //v11 = v124; //v12 = v123; v114 = 0; v115 = 0; pIndoorCameraD3D_4 = 0; v125 = 0; - v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; v126 = v124; v118 = v123; + + v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; - terrain_76E1C8[0] = 65535; + v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; + uint _i = 1; - v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; uint j = 1; - terrain_76E3C8[0] = 65535; - terrain_76DDC8[0] = 65535; - terrain_76DFC8[0] = 65535; - for( _i = 1; _i < 128; _i++) + + terrain_76DDC8[0] = -1; + terrain_76DFC8[0] = -1; + terrain_76E1C8[0] = -1; + terrain_76E3C8[0] = -1; + + for( uint _i = 1; _i < 128; _i++) { if ( v112 >= 0x10000 ) { @@ -1112,6 +1124,7 @@ v126 = 0; v17 = j - 1; v18 = _i - 1; + switch ( v105 ) { case 0: @@ -1223,13 +1236,8 @@ { v106 = v122; memset32(terrain_76DBC8, v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1)); - v32 = v122; - do - { - v33 = v126++; - terrain_76D9C8[v33] = v32++; - } - while ( v32 <= terrain_76DDC8[v17] ); + for ( v32 = v122; v32 <= terrain_76DDC8[v17]; v32++) + terrain_76D9C8[v126++] = v32; if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) { do @@ -1296,10 +1304,9 @@ v41 = terrain_76E1C8[v18]; while ( v41 <= v123 ) { - v42 = terrain_76E3C8[v18]; terrain_76D5C8[v16] = v41; - terrain_76D7C8[v16] = v42; - if ( v42 == 65535 ) + terrain_76D7C8[v16] = terrain_76E3C8[v18]; + if ( terrain_76E3C8[v18] == 65535 ) { terrain_76D7C8[v16] = v124; break; @@ -1326,10 +1333,8 @@ { v106 = v119; memset32(terrain_76DBC8, i, 4 * (v119 - terrain_76DDC8[v17] + 1)); - v45 = v119; - do - terrain_76D9C8[v126++] = v45--; - while ( v45 >= terrain_76DDC8[v17] ); + for ( v45 = v119; v45 >= terrain_76DDC8[v17]; v45--) + terrain_76D9C8[v126++] = v45; if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) { do @@ -1450,9 +1455,9 @@ if ( v59 > v124 ) break; terrain_76DBC8[v16] = v59; - v60 = terrain_76DDC8[v17]; - terrain_76D9C8[v16] = v60; - if ( v60 == 65535 ) + //v60 = terrain_76DDC8[v17]; + terrain_76D9C8[v16] = terrain_76DDC8[v17]; + if ( terrain_76DDC8[v17] == 65535 ) { terrain_76D9C8[v16] = v123; break; @@ -1549,30 +1554,33 @@ //v74 = terrain_76D7C8[i]; if ( terrain_76D7C8[i] <= 0 ) terrain_76D7C8[i] = -terrain_76D7C8[i]; - v75 = terrain_76D7C8[i] + 2; + uEndZ = terrain_76D7C8[i] + 2; //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; - uEndZ = v75; + //uEndZ = v75; //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; uStartZ = terrain_76DBC8[i] - 2; - if ( terrain_76DBC8[i] - 2 < v75 ) + if ( terrain_76DBC8[i] - 2 < uEndZ ) { v127 = 0; //v79 = (v73 - 66) << 9; //v116 = v77; //pHeight = v79; - v111 = v75 - uStartZ; + v111 = uEndZ - uStartZ; for (int z = uStartZ; z < uEndZ; ++z) { ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); + ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512; ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); + if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) { pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); + pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); } @@ -1586,7 +1594,8 @@ v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); if ( pRenderer->pRenderD3D )//Ritor1: do comment to test - Render::DrawTerrainD3D(v111, 0, v103, v104);//Render::RenderTerrainD3D(); + Render::DrawTerrainD3D(v111, 0, v103, v104); + //Render::RenderTerrainD3D(); else Render::DrawTerrainSW(v111, 0, v103, v104); } @@ -1622,18 +1631,12 @@ //do for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 ) { - //v93 = v116; - //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 64) << 9; ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9; - //*(float *)&pHeight = (double)pHeight; ptr_801A08[v86].vWorldPosition.y = v92; - //v106 = ; - //v97 = v116; ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116); - //v106 = (*(int *)((char *)terrain_76DBC8 + v86) - 63) << 9; + ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9; ptr_801A04[v86].vWorldPosition.y = v92; - //pHeight = pOutdoor->GetHeightOnTerrain(*(int *)((char *)terrain_76DBC8 + v86) + 1, v97); ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116); if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) { @@ -1831,7 +1834,7 @@ assert(v6 < 1000); // many random crashes here // for all shore tiles - draw a tile water under them since they're half-empty - if (!strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX + if (!_strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX { pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE); // no Z writing: the shore tile will be draw in the same place, so taking care about z-fighting pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); @@ -1982,7 +1985,7 @@ v90 = (float)pOutdoor->vSunlight.x / 65536.0; v91 = (float)pOutdoor->vSunlight.y / 65536.0; v92 = (float)pOutdoor->vSunlight.z / 65536.0; - if ( a1 - 1 > 0 ) +/* if ( a1 - 1 > 0 ) { while ( 1 ) { @@ -2012,11 +2015,11 @@ !byte_4D864C) || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ - if ( !&stru_76E5C8[(v5 << 7) + v6] ) - goto LABEL_162; + /*if ( !&stru_76E5C8[(v5 << 7) + v6] ) + goto LABEL_162*/ v8 = &pVerticesSR_806210[v4]; - pVertices2 = &pVerticesSR_801A10[v4 + 1]; - v102 = v8; + //pVertices2 = &pVerticesSR_801A10[v4 + 1]; + //v102 = v8; if (!v82) { pVertices = &pVerticesSR_801A10[v4]; @@ -2031,12 +2034,12 @@ sY = floorf(v8->vWorldPosition.z + 0.5f); v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); - WorldPosToGridCellX(sX); + /*WorldPosToGridCellX(sX); WorldPosToGridCellZ(sY); if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) - break; + break;*/ v16 = &array_77EC08[pOutdoorCamera->numStru148s]; v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); if ( v16->uTileBitmapID != -1 ) @@ -2174,7 +2177,7 @@ if ( ++v88 >= v84 ) return; } - v40 = &array_77EC08[pOutdoorCamera->numStru148s]; + /* v40 = &array_77EC08[pOutdoorCamera->numStru148s]; v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); if ( v40->uTileBitmapID == -1 ) goto LABEL_162; @@ -2211,7 +2214,7 @@ --pOutdoorCamera->numStru148s; goto LABEL_112; }*/ - memcpy(&array_50AC10[0], v102, 0x30u); + /*memcpy(&array_50AC10[0], v102, 0x30u); array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); array_50AC10[0].u = 0.0; array_50AC10[0].v = 0.0; @@ -2236,7 +2239,7 @@ stru148(stru_76D590); atexit(loc_48118F); }*/ - v96 = pGame->pLightmapBuilder; + /*v96 = pGame->pLightmapBuilder; pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); uNumVertices = 3; @@ -2359,7 +2362,7 @@ __init_flag1 = true; stru154::stru154(&static_sub_0048034E_stru_76D578); }*/ - v96 = pGame->pLightmapBuilder; + /* v96 = pGame->pLightmapBuilder; pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); v100 = 3; @@ -2439,7 +2442,7 @@ OutdoorCamera::Project(v73); goto LABEL_154; } - } + }*/ // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); // 4D864C: using guessed type char byte_4D864C; @@ -6518,7 +6521,7 @@ bool Render::LockSurface_DDraw2(IDirectDrawSurface2 *pSurface, DDSURFACEDESC *pDesc, unsigned int uLockFlags) { IDirectDrawSurface2 *v4; // esi@1 - bool v5; // eax@1 + HRESULT v5; // eax@1 HRESULT v6; // eax@2 int v7; // [sp-8h] [bp-10h]@8 unsigned int v8; // [sp-4h] [bp-Ch]@8 @@ -8437,116 +8440,83 @@ //----- (004A49D0) -------------------------------------------------------- void Render::DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9) { - int v10; // eax@1 - unsigned int v11; // ebx@1 - unsigned int v12; // ecx@1 - int v13; // edx@2 - int v14; // edx@4 - unsigned int v15; // edx@6 + int absXDifference; // eax@1 + int absYDifference; // eax@1 + unsigned int smallerabsdiff; // ebx@1 + unsigned int largerabsdiff; double v16; // st7@7 double v17; // st7@7 double v18; // st6@7 - double v19; // st4@7 double v20; // st4@8 double v21; // st4@10 double v22; // st4@10 double v23; // st4@10 - double v24; // st4@10 double v25; // st4@11 double v26; // st4@13 - double v27; // st5@13 double v28; // st4@13 RenderVertexD3D3 v29[4]; // [sp+0h] [bp-94h]@7 - double v30; // [sp+80h] [bp-14h]@1 - int v31; // [sp+88h] [bp-Ch]@1 + int xDifference; // [sp+88h] [bp-Ch]@1 signed int v32; // [sp+8Ch] [bp-8h]@1 - int X; // [sp+90h] [bp-4h]@1 - float a3a; // [sp+A4h] [bp+10h]@10 - float a4a; // [sp+A8h] [bp+14h]@10 - - *(float *)&X = dstX - srcX; - v30 = *(float *)&X + 6.7553994e15; - v31 = LODWORD(v30); - *(float *)&v32 = dstY - srcY; - v30 = *(float *)&v32 + 6.7553994e15; - X = LODWORD(v30); - HIDWORD(v30) = abs(COERCE_UNSIGNED_INT64(*(float *)&v32 + 6.7553994e15)); - v10 = abs(v31); - v32 = v10; - v11 = HIDWORD(v30); - v12 = 0; - if ( v10 < SHIDWORD(v30) ) - { - v13 = v10; - v10 = HIDWORD(v30); - v11 = v13; - } - if ( v10 < 0 ) - { - v14 = v10; - v10 = 0; - v12 = v14; - } - if ( (signed int)v11 < (signed int)v12 ) - { - v15 = v12; - v12 = v11; - v11 = v15; - } - v32 = (11 * v11 >> 5) + (v12 >> 2) + v10; + int yDifference; // [sp+90h] [bp-4h]@1 + + xDifference = bankersRounding(dstX - srcX); + yDifference = bankersRounding(dstY - srcY); + absYDifference = abs(yDifference); + absXDifference = abs(xDifference); + smallerabsdiff = min(absXDifference, absYDifference); + largerabsdiff = max(absXDifference, absYDifference); + v32 = (11 * smallerabsdiff >> 5) + largerabsdiff; v16 = 1.0 / (double)v32; - *(float *)&v31 = (double)v31 * v16; - *(float *)&X = (double)X * v16; - v17 = *(float *)&X * a4; + v17 = (double)yDifference * v16 * a4; + v18 = (double)xDifference * v16 * a4; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + { + v20 = a3 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; + v25 = a7 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; + } + else + { + v20 = a3 * 0.061758894; + v25 = a7 * 0.061758894; + } + v21 = 1.0 / a3; + v22 = (double)yDifference * v16 * a8; + v23 = (double)xDifference * v16 * a8; + v26 = 1.0 - 1.0 / v25; + v28 = 1.0 / a7; v29[0].pos.x = srcX + v17; - v18 = *(float *)&v31 * a4; v29[0].pos.y = srcY - v18; - v19 = a3; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - v20 = v19 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; - else - v20 = v19 * 0.061758894; + v29[0].pos.z = 1.0 - 1.0 / v20; + v29[0].rhw = v21; v29[0].diffuse = -1; v29[0].specular = 0; - v29[0].pos.z = 1.0 - 1.0 / v20; - v21 = 1.0 / a3; - *((float *)&v30 + 1) = v21; - v29[0].rhw = v21; v29[0].texcoord.x = 1.0; v29[0].texcoord.y = 0.0; - v22 = *(float *)&X * a8; - a3a = v22; + v29[1].pos.x = v22 + dstX; - v23 = *(float *)&v31 * a8; - a4a = v23; v29[1].pos.y = dstY - v23; - v24 = a7; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - v25 = v24 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; - else - v25 = v24 * 0.061758894; - v29[2].diffuse = -1; - v29[3].diffuse = -1; - *(_QWORD *)&v29[3].pos.z = __PAIR__(HIDWORD(v30), LODWORD(v29[0].pos.z)); + v29[1].pos.z = v26; + v29[1].rhw = v28; v29[1].diffuse = -16711936; v29[1].specular = 0; - v29[2].specular = 0; - v29[3].specular = 0; - v26 = 1.0 - 1.0 / v25; - v29[1].pos.z = v26; - v27 = v26; - v28 = 1.0 / a7; - v29[1].rhw = v28; v29[1].texcoord.x = 1.0; v29[1].texcoord.y = 1.0; - v29[2].pos.x = dstX - a3a; - v29[2].pos.y = a4a + dstY; - v29[2].pos.z = v27; + + v29[2].pos.x = dstX - v22; + v29[2].pos.y = v23 + dstY; + v29[2].pos.z = v26; v29[2].rhw = v28; + v29[2].diffuse = -1; + v29[2].specular = 0; v29[2].texcoord.x = 0.0; v29[2].texcoord.y = 1.0; + v29[3].pos.x = srcX - v17; v29[3].pos.y = v18 + srcY; + v29[3].pos.z = v29[0].pos.z; + v29[3].rhw = v21; + v29[3].diffuse = -1; + v29[3].specular = 0; v29[3].texcoord.x = 0.0; v29[3].texcoord.y = 0.0; ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); @@ -10588,27 +10558,19 @@ void Render::ChangeBetweenWinFullscreenModes() { float v0; // ST14_4@17 - bool v1; // edx@24 - signed int v2; // ecx@24 - int v3; // esi@25 int v4; // edx@26 ObjectDesc *v5; // eax@26 RGBTexture *v6; // esi@33 - const char *v7; // eax@34 const char *v8; // [sp-4h] [bp-28h]@33 - int v9; // [sp+0h] [bp-24h]@33 struct tagRECT Rect; // [sp+14h] [bp-10h]@15 - if ( pRenderer->bWindowMode ) - goto LABEL_52; - if ( dword_6BE364_game_settings_1 & 2 ) + if ( !pRenderer->bWindowMode && (dword_6BE364_game_settings_1 & 2) ) { ModalWindow(pGlobalTXT_LocalizationStrings[62], 0);// "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." return; } - if ( !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) - { -LABEL_52: + if ( pRenderer->bWindowMode || !pRenderer->pRenderD3D || pRenderer->pRenderD3D->pAvailableDevices->bIsDeviceCompatible ) + { if ( pEventTimer->bPaused ) BYTE1(dword_6BE364_game_settings_1) |= 8u; else @@ -10651,59 +10613,49 @@ pBitmaps_LOD->_410423_move_textures_to_device(); pSprites_LOD->MoveSpritesToVideoMemory(); } - if ( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits + if (!( pPaletteManager->uNumTargetBBits == pRenderer->uTargetBBits && pPaletteManager->uNumTargetGBits == pRenderer->uTargetGBits - && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits ) - goto LABEL_38; - pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); - pPaletteManager->RecalculateAll(); - pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); - pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); - v2 = 0; - if ( (signed int)pObjectList->uNumObjects > 0 ) - { - v3 = 0; - do + && pPaletteManager->uNumTargetRBits == pRenderer->uTargetRBits )) + { + pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); + pPaletteManager->RecalculateAll(); + pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); + pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); + for (int i = 0; i < pObjectList->uNumObjects; i++) { BYTE3(v4) = 0; - v5 = &pObjectList->pObjects[v3]; - ++v3; + v5 = &pObjectList->pObjects[i]; *(short *)((char *)&v4 + 1) = v5->uParticleTrailColorR; LOBYTE(v4) = v5->uParticleTrailColorG; v5->uParticleTrailColor = v5->uParticleTrailColorB | (v4 << 8); - ++v2; - } - while ( v2 < (signed int)pObjectList->uNumObjects ); - } - LOBYTE(v1) = 1; - SetUserInterface(pParty->alignment, v1); - if ( pVideoPlayer->pVideoFrame.pPixels ) - pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); - if ( uCurrentMenuID ) - { + } + SetUserInterface(pParty->alignment, true); + if ( pVideoPlayer->pVideoFrame.pPixels ) + pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); if ( uCurrentMenuID != 6 ) { if ( uCurrentMenuID == 8 ) - dword_A74C88 = 1; - goto LABEL_38; - } - v6 = &pTexture_PCX; - pTexture_PCX.Release(); - v9 = 0; - v8 = "makeme.pcx"; - } - else - { - v6 = &pTexture_PCX; - pTexture_PCX.Release(); - v7 = "title.pcx"; - if ( uCurrentMenuID ) - v7 = "lsave640.pcx"; - v9 = 0; - v8 = v7; - } - v6->Load(v8, v9); -LABEL_38: + dword_A74C88 = 1; + } + else + { + if ( uCurrentMenuID ) + { + v6 = &pTexture_PCX; + pTexture_PCX.Release(); + v8 = "makeme.pcx"; + } + else + { + v6 = &pTexture_PCX; + pTexture_PCX.Release(); + v8 = "title.pcx"; + if ( uCurrentMenuID ) + v8 = "lsave640.pcx"; + } + v6->Load(v8, 0); + } + } viewparams->bRedrawGameUI = 1; viewparams->InitGrayPalette(); pMouse->SetCurrentCursorBitmap(); @@ -10738,28 +10690,14 @@ //----- (0040DBD3) -------------------------------------------------------- void __fastcall Render::SetPixel(Vec2_int_ *pTargetXY, unsigned __int16 uColor) { - Vec2_int_ *pTargetXY_; // esi@1 - unsigned __int16 v3; // di@1 - signed int v4; // ecx@2 - signed int v5; // eax@4 - - pTargetXY_ = pTargetXY; - v3 = uColor; pRenderer->BeginScene(); if ( pRenderer->uNumSceneBegins ) { - v4 = pTargetXY_->x; - if ( pTargetXY_->x >= 0 ) - { - if ( v4 <= 639 ) - { - v5 = pTargetXY_->y; - if ( v5 >= 0 ) - { - if ( v5 <= 479 ) - pRenderer->pTargetSurface[v4 + pRenderer->uTargetSurfacePitch * v5] = v3; - } - } + int xVal = pTargetXY->x; + int yVal = pTargetXY->y; + if ( xVal >= 0 && xVal <= 639 && yVal >= 0 && yVal <= 479) + { + pRenderer->pTargetSurface[xVal + pRenderer->uTargetSurfacePitch * yVal] = uColor; } pRenderer->EndScene(); } @@ -10800,7 +10738,7 @@ { auto i = idx1 + (idx2 - idx1) / 2; - auto res = strcmpi(pName, pSpriteNames[i]); + auto res = _stricmp(pName, pSpriteNames[i]); if (!res) { fseek(pFile, pSpriteOffsets[i], SEEK_SET); @@ -10843,7 +10781,7 @@ else fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); - if ( field_61A94_scale_hwls_to_half ) + if ( field_61A94_scale_hwls_to_half ) //is it even possible to ever get here? field_61A94_scale_hwls_to_half is only set to zero { v11 = pTex->uHeight / 2; v12 = pTex->uWidth / 2; @@ -10900,59 +10838,34 @@ //----- (0045271F) -------------------------------------------------------- bool RenderHWLContainer::Release() { - RenderHWLContainer *v1; // esi@1 - int v2; // ebx@1 - void **v3; // edi@3 __int32 v4; // eax@6 FILE *v5; // ST24_4@6 - size_t *v6; // edi@6 - int v7; // ebx@7 - signed int v9; // [sp+0h] [bp-8h]@6 FILE *File; // [sp+4h] [bp-4h]@6 - v1 = this; - v2 = 0; - if ( this->bDumpDebug ) + if ( this->bDumpDebug) { File = fopen("logd3d.txt", "w"); - v4 = ftell(v1->pFile); - v5 = v1->pFile; - v6 = &v1->uNumItems; - v1->uDataOffset = v4; - fwrite(&v1->uNumItems, 4u, 1u, v5); - v9 = 0; - if ( (signed int)v1->uNumItems > 0 ) - { - v7 = (int)v1->pSpriteNames; - do - { - fwrite(*(const void **)v7, 1u, 0x14u, v1->pFile); - fprintf(File, "D3D texture name: %s\t\toffset: %x\n", *(unsigned int *)v7, *(unsigned int *)(v7 + 200000)); - ++v9; - v7 += 4; - } - while ( v9 < (signed int)*v6 ); - v2 = 0; - } - fwrite(v1->pSpriteOffsets, 4u, *v6, v1->pFile); - fseek(v1->pFile, 4, v2); - fwrite(&v1->uDataOffset, 4u, 1u, v1->pFile); - fclose(v1->pFile); + v4 = ftell(this->pFile); + v5 = this->pFile; + this->uDataOffset = v4; + fwrite(&this->uNumItems, 4u, 1u, v5); + for (int i = 0; i < this->uNumItems; i++) + { + fwrite(this->pSpriteNames[i], 1u, 0x14u, this->pFile); + fprintf(File, "D3D texture name: %s\t\toffset: %x\n", this->pSpriteNames[i], *(unsigned int *)(&(this->pSpriteNames[i]) + 200000/sizeof(char*))); + } + fwrite(this->pSpriteOffsets, 4u, this->uNumItems, this->pFile); + fseek(this->pFile, 4, 0); + fwrite(&this->uDataOffset, 4u, 1u, this->pFile); + fclose(this->pFile); fclose(File); } else { fclose(this->pFile); - if ( (signed int)v1->uNumItems > 0 ) - { - v3 = (void **)v1->pSpriteNames; - do - { - free(*v3); - ++v2; - ++v3; - } - while ( v2 < (signed int)v1->uNumItems ); + for (int i = 0; i < this->uNumItems; i++) + { + free(this->pSpriteNames[i]); } } return true; @@ -10962,15 +10875,12 @@ RenderHWLContainer::RenderHWLContainer(): bDumpDebug(false) { - RenderHWLContainer *v1; // esi@1 - - v1 = this; this->pFile = 0; uSignature = 0; - v1->uDataOffset = 0; - memset(&v1->uNumItems, 0, 0x61A84u); - v1->uNumItems = 0; - v1->field_61A94_scale_hwls_to_half = 0; + this->uDataOffset = 0; + memset(&this->uNumItems, 0, 0x61A84u); + this->uNumItems = 0; + this->field_61A94_scale_hwls_to_half = 0; } //----- (0045237F) --------------------------------------------------------
--- a/SaveLoad.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/SaveLoad.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <io.h> #include <direct.h> #include <assert.h>
--- a/Spells.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Spells.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <stdlib.h> #include "Spells.h"
--- a/Sprites.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Sprites.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <string.h> #include <algorithm>
--- a/StorylineTextTable.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/StorylineTextTable.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <stdlib.h> #include <string.h>
--- a/Texture.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Texture.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <stdlib.h> #include "Texture.h"
--- a/TileTable.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/TileTable.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include <stdio.h> #include <stdlib.h>
--- a/UIBooks.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UIBooks.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "MM7.h" @@ -478,7 +482,7 @@ int v6; // eax@21 int v7; // esi@21 char *v8; // eax@21 - int v9; // eax@22 + char* v9; // eax@22 unsigned int v11; // [sp-8h] [bp-64h]@3 unsigned int v12; // [sp-8h] [bp-64h]@7 Texture *v13; // [sp-4h] [bp-60h]@3
--- a/UICharacter.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UICharacter.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include <algorithm> @@ -87,7 +91,7 @@ int paperdoll_cloak_collar_texture[4][10]; // weak int paperdoll_cloak_texture[4][10]; int paperdoll_helm_texture[2][16]; //511698 -int paperdoll_belt_texture[2][7]; //511718 +int paperdoll_belt_texture[4][7]; //511718 const int paperdoll_Weapon[4][16][2] = {//4E4C30 @@ -934,7 +938,7 @@ item_MainHand4 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum4 - 1]; pX_MainHand4 = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipX; pY_MainHand4 = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipY; - if ( item_MainHand4->uItemID == 64 ) + if ( item_MainHand4->uItemID == 64 ) //blaster v166 = "item64v1"; else v166 = pItemsTable->pItems[item_MainHand4->uItemID].pIconName; @@ -1323,9 +1327,9 @@ pMainHandNum = pPlayers[uPlayerID]->pEquipment.uMainHand; if ( !pMainHandNum || (v70 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[pMainHandNum -1], pItemsTable->pItems[v70].uEquipType != 1) && (pItemsTable->pItems[v70].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) ) - pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], - pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], - pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1])); + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], + pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], + pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1])); pBeltNum = pPlayers[uPlayerID]->pEquipment.uBelt;// if ( pBeltNum ) { @@ -1392,12 +1396,12 @@ pMainHandNum2 = pPlayers[uPlayerID]->pEquipment.uMainHand; if ( pMainHandNum2 ) { - v83 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[pMainHandNum2 - 1]; + v83 = pPlayers[uPlayerID]->pInventoryItems[pMainHandNum2 - 1].uItemID; if ( pItemsTable->pItems[v83].uEquipType == 1 - || pItemsTable->pItems[v83].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield ) + || pItemsTable->pItems[v83].uSkillType == PLAYER_SKILL_SPEAR && !pPlayers[uPlayerID]->pEquipment.uShield ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], - pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], - pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1])); + pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], + pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1])); } pCloakCollarNum = pPlayers[uPlayerID]->pEquipment.uCloak;// if ( pCloakCollarNum ) @@ -1674,8 +1678,12 @@ if ( pMainHandNum5 ) { item_MainHand5 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum5 - 1]; - if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield ) - pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1])); + if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || + pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == PLAYER_SKILL_SPEAR && + !pPlayers[uPlayerID]->pEquipment.uShield ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], + pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], + pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1])); } if ( !bRingsShownInCharScreen )// pRenderer->DrawTextureTransparent(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B)); @@ -1931,25 +1939,20 @@ } else { - v6 = v30; papredoll_dbods[v30] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); papredoll_dlads[v30] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); papredoll_drhs[v30] = pIcons_LOD->LoadTexture(drh_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); - v7 = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); - pPlayer2 = pPlayers[v30 + 1]; - papredoll_dlhus[v30] = v7; - v9 = (char *)&pPlayer2->uCurrentFace; - v10 = *v9; - if ( *v9 == 12 || v10 == 13 ) + papredoll_dlhus[v30] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); + v10 = pPlayers[v30 + 1]->uCurrentFace; + if ( v10 == 12 || v10 == 13 ) { wsprintfA(pContainer, "pc%02dbrd", v10 + 1); - v9 = (char *)&pPlayers[v6 + 1]->uCurrentFace; - papredoll_dbrds[*v9] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + papredoll_dbrds[v10] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); } - wsprintfA(pContainer, "item281pc%02d", *v9 + 1); - papredoll_flying_feet[pPlayers[v6 + 1]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + wsprintfA(pContainer, "item281pc%02d", v10 + 1); + papredoll_flying_feet[pPlayers[v30 + 1]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); IsPlayerWearingWatersuit[v30 + 1] = 0; } ++v30;
--- a/UIHouses.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UIHouses.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "UIHouses.h" #include "Party.h" #include "Player.h"
--- a/UIHouses.h Wed Jun 05 21:00:11 2013 +0600 +++ b/UIHouses.h Wed Jun 05 21:00:45 2013 +0600 @@ -1,6 +1,6 @@ #pragma once -enum HOUSE_DIALOGUE_MENU: unsigned __int32 +enum HOUSE_DIALOGUE_MENU: __int32 { HOUSE_DIALOGUE_NULL = 0, HOUSE_DIALOGUE_MAIN = 1,
--- a/UIMainMenu.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UIMainMenu.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "MM7.h" @@ -276,10 +280,7 @@ unsigned int v10; // ST2C_4@19 MSG Msg; // [sp+84h] [bp-B8h]@10 int v17; // [sp+A0h] [bp-9Ch]@9 - int pX; // [sp+A4h] [bp-98h]@9 - unsigned int pY; // [sp+A8h] [bp-94h]@9 - int v20; // [sp+ACh] [bp-90h]@9 - int a4; // [sp+B0h] [bp-8Ch]@9 + GUIWindow a2; int pColor2; // [sp+F8h] [bp-44h]@9 int pColor1; // [sp+FCh] [bp-40h]@9 int a5; // [sp+128h] [bp-14h]@1 @@ -317,13 +318,15 @@ pFont = pFontCChar; pFont2 = pFontQuick; v1[pSize] = 0; - v20 = 250; - a4 = 440; - pX = 389; - pY = 19; + + a2.uFrameWidth = 250; + a2.uFrameHeight = 440; + a2.uFrameX = 389; + a2.uFrameY = 19; + pTexture2.uWidth = 250; - pHeight = pFont2->GetStringHeight2(pFont, v1, (int)&pX, 0, 1); - pTexture2.uHeight = pHeight + 2 * a4; + pHeight = pFont2->GetStringHeight2(pFont, v1, &a2, 0, 1); + pTexture2.uHeight = pHeight + 2 * a2.uFrameHeight; pTexture2.uNumPixels = (signed __int16)pTexture2.uWidth * (signed __int16)pTexture2.uHeight; v7 = pAllocator->AllocNamedChunk(pTexture2.pPixels, 2 * pTexture2.uNumPixels, "scrollermap"); pNumPixels = pTexture2.uNumPixels; @@ -337,7 +340,7 @@ pString = (char *)operator new(2 * pSize); strncpy(pString, ptr, pSize); pString[pSize]=0; - pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, a4, (signed __int16)pTexture2.uWidth, (signed __int16)pTexture2.uHeight, pColor1, + pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, a2.uFrameHeight, (signed __int16)pTexture2.uWidth, (signed __int16)pTexture2.uHeight, pColor1, pColor2, pString, pTexture2.pPixels, (signed __int16)pTexture2.uWidth); free(pString); pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, (int)ptr); @@ -361,8 +364,8 @@ { pRenderer->BeginScene(); pRenderer->DrawTextureRGB(0, 0, &pTexture); - pRenderer->SetTextureClipRect(pX, pY, pX + v20, pY + a4); - pRenderer->_4A5D33(pX, pY, 0, a5, &pTexture2); + pRenderer->SetTextureClipRect(a2.uFrameX, a2.uFrameY, a2.uFrameX + a2.uFrameWidth, a2.uFrameY + a2.uFrameHeight); + pRenderer->_4A5D33(a2.uFrameX, a2.uFrameY, 0, a5, &pTexture2); pRenderer->ResetTextureClipRect(); pRenderer->EndScene(); ++a5;
--- a/UIPartyCreation.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UIPartyCreation.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "MM7.h" @@ -901,8 +905,8 @@ for (uint k = 0; k < 138; k++) { - if (player->pInventoryItems[k].uItemID) - player->pInventoryItems[k].SetIdentified(); + if (player->pOwnItems[k].uItemID) + player->pOwnItems[k].SetIdentified(); } } }
--- a/UIPopup.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UIPopup.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "MM7.h" @@ -1389,7 +1393,7 @@ } while ( i < 10 ); } - if ( (signed __int64)pParty->pPartyBuffs[3].uExpireTime > 0 ) + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].uExpireTime > 0 ) { sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[650], v121->sCurrentHP); pFontSmallnum->GetLineWidth(pTmpBuf);
--- a/UIRest.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UIRest.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "MM7.h"
--- a/UISaveLoad.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UISaveLoad.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include <io.h> #include "MM7.h"
--- a/UITransition.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UITransition.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include <io.h>
--- a/UiGame.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/UiGame.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "MM7.h" @@ -2243,7 +2247,7 @@ pFace = pTexture_PlayerFaceEradicated; pPortrait = pFace; v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; - if ( pParty->pPartyBuffs[11].uExpireTime ) + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) pRenderer->_4A6E7E(v9, 0x183u, pPortrait); else pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); @@ -2263,7 +2267,7 @@ pFace = pTexture_PlayerFaceDead; pPortrait = pFace; v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; - if ( pParty->pPartyBuffs[11].uExpireTime ) + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) pRenderer->_4A6E7E(v9, 0x183u, pPortrait); else pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); @@ -2297,7 +2301,7 @@ pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID]; pPortrait = pFace; v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; - if ( pParty->pPartyBuffs[11].uExpireTime ) + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) pRenderer->_4A6E7E(v9, 0x183u, pPortrait); else pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait);
--- a/VectorTypes.h Wed Jun 05 21:00:11 2013 +0600 +++ b/VectorTypes.h Wed Jun 05 21:00:45 2013 +0600 @@ -1,5 +1,6 @@ #pragma once + typedef unsigned __int32 uint; #pragma pack(push, 1)
--- a/VideoPlayer.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/VideoPlayer.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "OSAPI.h" #include "Bink_Smacker.h" @@ -115,7 +119,7 @@ v11.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; auto hr = pRenderer->pDirectDraw4->CreateSurface(&v11, &v15, 0); - ErrD3D(hr, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:1476"); + ErrD3D(hr); } v5->uWidth = v11.dwWidth; v5->uHeight = v11.dwHeight; @@ -158,7 +162,7 @@ Dst.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; auto hr = pRenderer->pDirectDraw2->CreateSurface(&Dst, (LPDIRECTDRAWSURFACE *)&a2, 0); - ErrD3D(hr, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:1426"); + ErrD3D(hr); } v5->uWidth = Dst.dwWidth; v5->uHeight = Dst.dwHeight; @@ -868,7 +872,7 @@ unsigned int v9; // [sp-4h] [bp-14h]@10 for (uint i = 0; i < uNumMightVideoHeaders; ++i) - if (!strcmpi(pName, pMightVideoHeaders[i].pVideoName)) + if (!_stricmp(pName, pMightVideoHeaders[i].pVideoName)) { SetFilePointer(hMightVid, pMightVideoHeaders[i].uFileOffset, 0, FILE_BEGIN); @@ -879,7 +883,7 @@ } for (uint i = 0; i < uNumMagicVideoHeaders; ++i) - if (!strcmpi(pName, pMagicVideoHeaders[i].pVideoName)) + if (!_stricmp(pName, pMagicVideoHeaders[i].pVideoName)) { SetFilePointer(hMagicVid, pMagicVideoHeaders[i].uFileOffset, 0, FILE_BEGIN);
--- a/Vis.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/Vis.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -34,7 +34,7 @@ RenderVertexSoft pRay[2]; // [sp+20h] [bp-70h]@17 int v20; // [sp+84h] [bp-Ch]@10 - static Vis_SelectionList SelectedPointersList; + static Vis_SelectionList SelectedPointersList;//stru_F8FE00 SelectedPointersList.uNumPointers = 0; static bool _init_flag = false; @@ -74,7 +74,6 @@ pGame->pIndoorCameraD3D->ViewTransform(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices); pGame->pIndoorCameraD3D->Project(static_DetermineFacetIntersection_array_F8F200, face->uNumVertices, 1); - //v15 = this; SortVectors_x(static_DetermineFacetIntersection_array_F8F200, 0, face->uNumVertices - 1); if (static_DetermineFacetIntersection_array_F8F200[0].vWorldViewPosition.x > pick_depth) return nullptr; @@ -902,6 +901,12 @@ //----- (004C2551) -------------------------------------------------------- Vis_ObjectInfo *Vis_SelectionList::SelectionPointers(int pVisObjectType, int pid) { + //unsigned int v3; // esi@1 + //signed int v4; // edx@1 + //char *v5; // eax@2 + //Vis_ObjectInfo *result; // eax@6 + + //v3 = this->uNumPointers; if ( this->uNumPointers > 0 ) { for ( uint i = 0; i < this->uNumPointers; ++i ) @@ -911,6 +916,22 @@ } } return false; + /*v4 = 0; + if ( this->uNumPointers <= 0 ) + return false; + else + { + //v5 = (char *)&this->object_pool[0].sZValue; + while ( this->object_pool[v4].object_type != a2 || (this->object_pool[v4].sZValue & 0xFFFF) != a3 ) + { + ++v4; + //v5 += 12; + if ( v4 >= this->uNumPointers ) + return false; + } + result = &this->object_pool[v4]; + } + return result;*/ } //----- (004C2591) -------------------------------------------------------- @@ -954,56 +975,54 @@ //----- (004C264A) -------------------------------------------------------- void Vis::sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right) { - //int v4; // edx@1 - //int v5; // ebx@1 + int v4; // edx@1 + int v5; // ebx@1 int v6; // esi@2 signed int i; // ecx@2 - //int v8; // eax@3 - //int v9; // ebx@4 - //int v10; // ebx@6 + int v8; // eax@3 + int v9; // ebx@4 + int v10; // ebx@6 Vis_ObjectInfo *v11; // eax@7 - //Vis *thisa; // [sp+4h] [bp-4h]@1 - //Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2 + Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2 - //v4 = left; - //v5 = right; - //thisa = this; + v4 = left; + v5 = right; if ( right > left ) { do { - v6 = left - 1; - //a3a = pPointers[right]; - for ( i = right; ; pPointers[i] = v11 ) + v6 = v4 - 1; + a3a = pPointers[v5]; + for ( i = v5; ; pPointers[i] = v11 ) { - //v8 = a3a->sZValue; - //LOWORD(v8) = 0; + v8 = a3a->sZValue; + LOWORD(v8) = 0; do { ++v6; - //v9 = pPointers[v6]->sZValue; - //LOWORD(v9) = 0; + v9 = pPointers[v6]->sZValue; + LOWORD(v9) = 0; } - while ( pPointers[v6]->sZValue < pPointers[right]->sZValue ); + while ( v9 < (unsigned int)v8 ); do { if ( i < 1 ) break; --i; - //v10 = pPointers[i]->sZValue; - //LOWORD(v10) = 0; + v10 = pPointers[i]->sZValue; + LOWORD(v10) = 0; } - while ( pPointers[i]->sZValue > pPointers[right]->sZValue ); + while ( v10 > (unsigned int)v8 ); v11 = pPointers[v6]; if ( v6 >= i ) break; pPointers[v6] = pPointers[i]; } - //v5 = right; + v5 = right; pPointers[v6] = pPointers[right]; pPointers[right] = v11; - sort_object_pointers(pPointers, left, v6 - 1); - left = v6 + 1; + sort_object_pointers(pPointers, v4, v6 - 1); + v4 = v6 + 1; } while ( right > v6 + 1 ); }
--- a/mm7_1.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_1.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + /* This file has been generated by the Hex-Rays decompiler. Copyright (c) 2007-2011 Hex-Rays <info@hex-rays.com> @@ -2227,65 +2231,78 @@ //----- (00424829) -------------------------------------------------------- bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID) { + //int v4; // edi@1 + //BspRenderer_stru2 *v5; // ebx@1 int v6; // eax@3 int v7; // esi@5 int v8; // edx@5 + //int v9; // ecx@6 int v10; // eax@12 - int v11; // edi@13 + //int v11; // edi@13 + //int v12; // edx@18 int v13; // eax@22 + //int v14; // edi@28 int v15; // ecx@29 - int v16; // edi@30 + //int v16; // edi@30 + //int v17; // edx@35 int v18; // eax@39 int v19; // eax@44 int v20; // ecx@44 + //int v21; // edi@45 int v22; // edi@46 - __int16 *v23; // ecx@47 + //__int16 *v23; // ecx@47 int v24; // edx@48 - int v25; // eax@50 + //int v25; // eax@50 int v26; // eax@55 signed int v27; // edi@55 + //int v28; // edx@56 int v29; // edx@57 - int v30; // eax@59 + //int v30; // eax@59 int v31; // eax@64 signed int v32; // edi@64 - __int16 *v34; // eax@66 - __int16 v35; // dx@66 + //int v33; // edx@65 + int v34; // eax@66 + int v35; // dx@66 __int16 v36; // dx@67 __int16 v37; // di@67 __int16 v38; // dx@67 - int v40; // edx@69 - int v41; // edi@70 - __int16 *v42; // eax@76 - __int16 *v43; // eax@81 - __int16 *v45; // eax@87 + //BspRenderer_stru2 *v39; // ecx@69 + //int v40; // edx@69 + //int v41; // edi@70 + //__int16 *v42; // eax@76 + //__int16 *v43; // eax@81 + //__int16 *v45; // eax@87 int v46; // edx@87 - __int16 v47; // cx@88 + //__int16 v47; // cx@88 //int v48; // eax@93 int v49; // esi@93 - __int16 *v50; // ecx@94 - int v51; // eax@95 + //__int16 *v50; // ecx@94 + //int v51; // eax@95 + //int v52; // eax@97 int v53; // [sp+Ch] [bp-34h]@44 int v54; // [sp+10h] [bp-30h]@0 int v55; // [sp+14h] [bp-2Ch]@12 - __int16 *v56; // [sp+14h] [bp-2Ch]@47 - __int16 *v57; // [sp+14h] [bp-2Ch]@76 - __int16 *v58; // [sp+14h] [bp-2Ch]@81 - __int16 *v59; // [sp+14h] [bp-2Ch]@87 + //__int16 *v56; // [sp+14h] [bp-2Ch]@47 + //__int16 v57; // [sp+14h] [bp-2Ch]@76 + //__int16 v58; // [sp+14h] [bp-2Ch]@81 + int v59; // [sp+14h] [bp-2Ch]@87 + //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1 int v61; // [sp+1Ch] [bp-24h]@29 int v62; // [sp+20h] [bp-20h]@0 signed int v63; // [sp+24h] [bp-1Ch]@3 signed int v64; // [sp+28h] [bp-18h]@3 int v65; // [sp+2Ch] [bp-14h]@5 - int v66; // [sp+2Ch] [bp-14h]@39 - int v67; // [sp+30h] [bp-10h]@22 + //int v66; // [sp+2Ch] [bp-14h]@39 + //int v67; // [sp+30h] [bp-10h]@22 int v68; // [sp+34h] [bp-Ch]@12 int v69; // [sp+34h] [bp-Ch]@29 int v70; // [sp+34h] [bp-Ch]@46 int v71; // [sp+34h] [bp-Ch]@75 int v72; // [sp+34h] [bp-Ch]@80 - int v73; // [sp+38h] [bp-8h]@11 - int a3a; // [sp+48h] [bp+8h]@76 - int a3b; // [sp+48h] [bp+8h]@87 + //int v73; // [sp+38h] [bp-8h]@11 + //int v74; // [sp+3Ch] [bp-4h]@1 + //int a3a; // [sp+48h] [bp+8h]@76 + //int a3b; // [sp+48h] [bp+8h]@87 //try graphic engine with function returning 1 always, and without //return true; @@ -2319,7 +2336,6 @@ v7 = stru_50B700._screen_space_y[v6]; } } - v73 = v8; if ( v8 == v7 ) return false; v10 = v65; @@ -2328,7 +2344,7 @@ v55 = v65; if ( pNumVertices > 0 ) { - v11 = v65; + //v11 = v65; for ( v68 = 0; v68 < pNumVertices; ++v68 ) { v10 += v64; @@ -2341,29 +2357,25 @@ { v10 -= pNumVertices; } - if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v11] ) + if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] ) { v55 = v10; - v11 = v10; + v65 = v10; } - if ( stru_50B700._screen_space_y[v10] == v73 ) + if ( stru_50B700._screen_space_y[v10] == v8 ) break; } } v13 = v55 + v64; - v67 = v55 + v64; - if ( v55 + v64 < pNumVertices ) + if ( v13 < pNumVertices ) { - if ( v13 >= 0 ) - goto LABEL_27; - v13 += pNumVertices; + if ( v13 < 0 ) + v13 += pNumVertices; } else { v13 -= pNumVertices; } - v67 = v13; -LABEL_27: if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] ) { v62 = stru_50B700._screen_space_x[v55] << 16; @@ -2374,7 +2386,7 @@ v61 = v65; if ( pNumVertices > 0 ) { - v16 = v65; + //v16 = v65; for ( v69 = 0; v69 < pNumVertices; ++v69 ) { v15 += v63; @@ -2387,86 +2399,75 @@ { v15 -= pNumVertices; } - if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v16] ) + if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] ) { v61 = v15; - v16 = v15; + v65 = v15; } - if ( stru_50B700._screen_space_y[v15] == v73 ) + if ( stru_50B700._screen_space_y[v15] == v8 ) break; } } v18 = v63 + v61; - v66 = v63 + v61; - if ( v63 + v61 < pNumVertices ) + if ( v18 < pNumVertices ) { - if ( v18 >= 0 ) - goto LABEL_44; - v18 += pNumVertices; + if ( v18 < 0 ) + v18 += pNumVertices; } else { v18 -= pNumVertices; } - v66 = v18; -LABEL_44: v19 = v18; v20 = v61; if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] ) { v61 = stru_50B700._screen_space_x[v20] << 16; v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20]; - a2->array_3D8[v73] = LOWORD(stru_50B700._screen_space_x[v20]); + a2->array_3D8[v8] = LOWORD(stru_50B700._screen_space_x[v20]); } v22 = v7; - if ( v7 <= v73 ) + if ( v7 <= v8 ) { - v56 = &a2->array_3D8[v7]; - v23 = &a2->array_18[v7]; - for ( v70 = v7; v70 <= v73; ++v70 ) + //v56 = &a2->array_3D8[v7]; + //v23 = &a2->array_18[v7]; + for ( v70 = v7; v70 <= v8; ++v70 ) { - v24 = v67; - if ( v22 < stru_50B700._screen_space_y[v67] || v22 == v73 ) - goto LABEL_57; - v25 = v64 + v67; - v67 = v25; - if ( v25 < pNumVertices ) + v24 = v13; + if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != v8 ) { - if ( v25 >= 0 ) - goto LABEL_55; - v25 += pNumVertices; - } - else - { - v25 -= pNumVertices; + v13 = v64 + v13; + if ( v13 < pNumVertices ) + { + if ( v13 < 0 ) + v13 += pNumVertices; + } + else + { + v13 -= pNumVertices; + } + v26 = v13; + //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; + if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 ) + { + v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; + v62 = stru_50B700._screen_space_x[v24] << 16; + } } - v67 = v25; -LABEL_55: - v26 = v25; - //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; - if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 ) - { - v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; - v62 = stru_50B700._screen_space_x[v24] << 16; - } -LABEL_57: - v29 = v66; - if ( v70 >= stru_50B700._screen_space_y[v66] && v70 != v73 ) + v29 = v18; + if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != v8 ) { - v30 = v63 + v66; - v66 += v63; - if ( v66 >= pNumVertices ) + v18 += v63; + if ( v18 < pNumVertices ) { - v30 -= pNumVertices; - goto LABEL_63; + if ( v18 < 0 ) + v18 += pNumVertices; } - if ( v30 < 0 ) + else { - v30 += pNumVertices; -LABEL_63: - v66 = v30; + v18 -= pNumVertices; } - v31 = v30; + v31 = v18; //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 ) { @@ -2474,95 +2475,98 @@ v61 = stru_50B700._screen_space_x[v29] << 16; } } - *(__int16 *)((char *)v56 + (int)(char *)a2->array_18 - (char *)a2->array_3D8) = HIWORD(v62); - *v56 = HIWORD(v61); - v34 = v23 + 480; - v35 = v23[480]; - if ( *v23 > v35 ) + //v34 = (char *)a2->array_18 - (char *)a2->array_3D8; + //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34); + //v35 = HIWORD(v62); + a2->array_18[v70] = HIWORD(v62); + a2->array_3D8[v70] = HIWORD(v61); + //v34 = &a2->array_3D8[v70]; + //v35 = a2->array_3D8[v70]; + if ( a2->array_18[v70] > a2->array_3D8[v70] ) { - v36 = *v23 ^ v35; - v37 = *v34; - *v23 = v36; + v36 = a2->array_18[v70] ^ a2->array_3D8[v70]; + v37 = a2->array_3D8[v70]; + a2->array_18[v70] = v36; v38 = v37 ^ v36; - *v23 ^= v38; - *v34 = v38; + a2->array_18[v70] ^= v38; + a2->array_3D8[v70] = v38; } - ++v56; + //++v56; v62 += v54; v22 = v70 + 1; v61 += v53; - ++v23; + //++v23; } } - v40 = v73; - if ( v73 < a3->_viewport_space_y || (v41 = a3->_viewport_space_w, v7 > v41) ) + if ( v8 < a3->_viewport_space_y ) + return false; + if ( v7 > a3->_viewport_space_w ) return false; if ( v7 < a3->_viewport_space_y ) v7 = a3->_viewport_space_y; - if ( v73 > v41 ) - { - v40 = a3->_viewport_space_w; - v73 = a3->_viewport_space_w; - } - if ( v7 <= v40 ) + if ( v8 > a3->_viewport_space_w ) + v8 = a3->_viewport_space_w; + if ( v7 <= v8 ) { - a3a = (char *)a2 - (char *)a3; - v57 = &a2->array_18[v7]; - v42 = &a3->array_3D8[v7]; - for ( v71 = v7; v71 <= v40; ++v71 ) + //a3a = (char *)a2 - (char *)a3; + //v42 = &a3->array_3D8[v7]; + //v57 = *(__int16 *)((char *)v42 + a3a); + for ( v71 = v7; v71 <= v8; ++v71 ) { - if ( *(__int16 *)((char *)v42 + a3a) >= *(v42 - 480) && a2->array_18[v71] <= a3->array_3D8[v71] ) + if ( a2->array_18[v71] >= a3->array_18[v71] && a2->array_18[v71] <= a3->array_3D8[v71] ) break; - ++v57; + //++v57; ++v7; - ++v42; + //++v42; } } - if ( v40 < v7 ) + if ( v8 < v7 ) return false; - v58 = &a2->array_18[v40]; - v43 = &a3->array_3D8[v40]; - for ( v72 = v40; v72 >= v7; --v72 ) + //a3a = (char *)a2 - (char *)a3; + //v43 = &a3->array_3D8[v8]; + //v58 = *(__int16 *)((char *)v43 + a3a); + for ( v72 = v8; v72 >= v7; --v72 ) { - if ( *(__int16 *)((char *)v43 + (int)(char *)a2 - (char *)a3) >= *(v43 - 480) && *v58 <= a3->array_3D8[v72] ) + if ( a2->array_3D8[v72] >= a3->array_18[v72] && a2->array_18[v72] <= a3->array_3D8[v72] ) break; - --v58; - --v40; - --v43; - v73 = v40; + //--v58; + --v8; + //--v43; + //v8 = v8; } - if ( v7 >= v40 ) + if ( v7 >= v8 ) return false; - a3b = (char *)a3 - (char *)a2; - v59 = &a3->array_3D8[v7]; - v45 = &a2->array_18[v7]; + //a3b = (char *)a3 - (char *)a2; + v59 = v7; + //v45 = &a2->array_18[v7]; - for ( v46 = v73 - v7 + 1; v46; --v46 ) + for ( v46 = v8 - v7 + 1; v46; --v46 ) { - v47 = *(__int16 *)((char *)v45 + a3b); - if ( *v45 < v47 ) - *v45 = v47; - if ( v45[480] > *v59 ) - v45[480] = *v59; + //v47 = *(__int16 *)((char *)v45 + a3b); + if ( a2->array_18[v59] < a3->array_18[v59] ) + a2->array_18[v59] = a3->array_18[v59]; + if ( a2->array_3D8[v59] > a3->array_3D8[v59] ) + a2->array_3D8[v59] = a3->array_3D8[v59]; ++v59; - ++v45; + //++v45; } a2->_viewport_space_y = v7; - a2->_viewport_space_w = v73; + a2->_viewport_space_w = v8; a2->field_8 = a2->array_18[v7]; - a2->field_C = a2->array_3D8[v7]; + //v48 = a2->array_3D8[v7]; a2->field_10 = v7; a2->field_14 = v7; + a2->field_C = a2->array_3D8[v7]; v49 = v7 + 1; - if ( v49 <= v73 ) + if ( v49 <= v8 ) { - v50 = &a2->array_3D8[v49]; - for ( v49; v49 <= v73; ++v49 ) + //v50 = &a2->array_3D8[v49]; + for ( v49; v49 <= v8; ++v49 ) { - v51 = *(v50 - 480); - if ( v51 < a2->field_8 ) + //v51 = a2->array_18[v49]; + if ( a2->array_18[v49] < a2->field_8 ) { - a2->field_8 = v51; + a2->field_8 = a2->array_18[v49]; a2->field_10 = v49; } if ( a2->array_3D8[v49] > a2->field_C ) @@ -2570,7 +2574,7 @@ a2->field_C = a2->array_3D8[v49]; a2->field_14 = v49; } - ++v50; + //++v50; } } return true;
--- a/mm7_2.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_2.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <io.h> #include <direct.h> #include <assert.h> @@ -145,8 +149,8 @@ return 0; } v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - pParty->pPartyBuffs[18].Apply(pParty->uTimePlayed + 46080, 3u, 0, v20, 0); - pParty->pPartyBuffs[18].uFlags |= 1u; + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 46080, 3u, 0, v20, 0); + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; v31 = 0; v29 = 0; v27 = 0; @@ -176,8 +180,8 @@ else { v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); - pParty->pPartyBuffs[7].Apply(pParty->uTimePlayed + 30720, 3u, 1u, v19, 0); - pParty->pPartyBuffs[7].uFlags |= 1u; + pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 30720, 3u, 1u, v19, 0); + pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; v31 = 0; v29 = 0; v27 = 0; @@ -4257,7 +4261,7 @@ assert(uNumMaps >= 2); for (uint i = 1; i < uNumMaps; ++i) - if (!strcmpi(pInfos[i].pFilename, Str2)) + if (!_stricmp(pInfos[i].pFilename, Str2)) return (MAP_TYPE)i; assert(false && "Map not found!"); @@ -5670,7 +5674,7 @@ struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13 int pXY[2]; // [sp+64h] [bp-8h]@261 int a2; // [sp+7Ch] [bp+10h]@50 - + switch (Msg) { case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam); @@ -7099,7 +7103,7 @@ wchar_t pMagicPath[1024]; - swprintf(pMagicPath, L"%C:\\anims\\magic7.vid", c); + swprintf(pMagicPath, wcslen(L"%C:\\anims\\magic7.vid"), L"%C:\\anims\\magic7.vid", c); if (GetFileAttributesW(pMagicPath) == -1) return false;
--- a/mm7_3.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_3.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> @@ -1206,13 +1210,13 @@ Actor::AI_FaceObject(v75, v38, 0, (AIDirection *)0); break; } - //v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; - //v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; + //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0; + //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0; v0->vVelocity.y = 0; v0->vVelocity.x = 0; - //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) - if ( (signed __int64)pParty->pPartyBuffs[11].uExpireTime < 0) - pParty->pPartyBuffs[11].Reset(); + //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) ) + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = 1; break; case OBJECT_Decoration: @@ -1914,9 +1918,9 @@ auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z; if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { - if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0 - && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) ) - pParty->pPartyBuffs[11].Reset(); + if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0 + && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = 1; goto LABEL_152; } @@ -2275,10 +2279,10 @@ { //LOBYTE(pParty->uFlags) &= 0x7Fu; bWaterWalk = 1; - *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u; + *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u; if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) && pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster-1].sMana <= 0 ) - //*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 ) + //*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 10] <= 0 ) bWaterWalk = 0; } v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk); @@ -2331,8 +2335,8 @@ else pParty->walk_sound_timer = 0; } if (!bUnderwater - && SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0 - && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime) <= 0) ) + && SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0 + && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0) ) pParty->bFlying = false; if (!bJumping) { @@ -2420,8 +2424,8 @@ { pParty->bFlying = 0; if ( bUnderwater - || pParty->pPartyBuffs[7].uFlags & 1 - || pParty->pPlayers[pParty->pPartyBuffs[7].uCaster - 1].sMana > 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[7].uCaster + 10] > 0 ) + || pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 + || pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 10] > 0 ) { pZ -= 30; v113 -= 30; @@ -2667,7 +2671,7 @@ if ( v127 ) pZ = v113; if (pParty->FlyActive()) - stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu; + stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFEu; pParty->uFallStartY = pZ; //goto LABEL_141; } @@ -2680,7 +2684,7 @@ pParty->uFallStartY = v111; v113 = pZ; if (pParty->FlyActive()) - stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u; + stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u; } } @@ -2688,7 +2692,7 @@ { v113 = pZ; if (pParty->FlyActive()) - stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u; + stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u; } //LABEL_141: if (bJumping && !pParty->bFlying) @@ -3207,9 +3211,9 @@ if ( bWaterWalk ) { pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; - //v79 = 20 * pParty->pPartyBuffs[18].uOverlayID + 6180178; - //*(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u; - v79 = (int)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119]; + //v79 = 20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 6180178; + //*(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u; + v79 = (int)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119]; *(short *)v79 |= 1u; if ( !v122 || !v69 ) { @@ -5584,9 +5588,9 @@ 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); + swprintf(xn_filename, wcslen(L"%s_xn.tga"), L"%s_xn.tga", skybox_name); swprintf(xp_filename, wcslen(L"%s_xp.tga"), L"%s_xp.tga", skybox_name); + swprintf(yn_filename, wcslen(L"%s_yn.tga"), L"%s_yn.tga", skybox_name); swprintf(yp_filename, wcslen(L"%s_yp.tga"), L"%s_yp.tga", skybox_name); + swprintf(zn_filename, wcslen(L"%s_zn.tga"), L"%s_zn.tga", skybox_name); swprintf(zp_filename, wcslen(L"%s_zp.tga"), L"%s_zp.tga", skybox_name); int xn_width, xn_height; skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height); @@ -6812,8 +6816,8 @@ if (pWeather->bNight) { v8 = 67108864; - if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 ) - v8 = pParty->pPartyBuffs[16].uPower << 26; + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) + v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; if ( a3 <= v8 ) { if ( a3 > 0 ) @@ -6981,12 +6985,12 @@ } else { - if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime > 0 ) - { - if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime <= 0 ) + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) + { + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime <= 0 ) v11 = 0; else - v11 = pParty->pPartyBuffs[16].uPower; + v11 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; } v12 = v11 << 26; } @@ -13085,7 +13089,7 @@ pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 2u); pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 3u); v39 = (signed __int64)((double)(v42 << 7) * 0.033333335); - v37 = &pParty->pPartyBuffs[2]; + v37 = &pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS]; v36 = pParty->uTimePlayed + v39; v37->Apply(v36, a7b, v43, 0, 0); goto LABEL_139; @@ -13099,7 +13103,7 @@ pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 2u); pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 3u); v39 = (signed __int64)((double)(v42 << 7) * 0.033333335); - v37 = &pParty->pPartyBuffs[2]; + v37 = &pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS]; v36 = pParty->uTimePlayed + v39; v37->Apply(v36, a7b, v43, 0, 0); goto LABEL_139; @@ -13112,7 +13116,7 @@ pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 2u); pGame->pStru6Instance->SetPlayerBuffAnim(0x53u, 3u); v39 = (signed __int64)((double)(v42 << 7) * 0.033333335); - v37 = &pParty->pPartyBuffs[2]; + v37 = &pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS]; v36 = pParty->uTimePlayed + v39; v37->Apply(v36, a7b, v43, 0, 0); goto LABEL_139; @@ -13562,7 +13566,7 @@ v48 = uSkill; v46 = v15; v39 = (signed __int64)((double)(v38 << 7) * 0.033333335); - v37 = &pParty->pPartyBuffs[10]; + v37 = &pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION]; v36 = pParty->uTimePlayed + v39; v37->Apply(v36, v46, v48, v50, v52); goto LABEL_139; @@ -13893,8 +13897,8 @@ } //----- (0044C175) -------------------------------------------------------- -void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds) -{ +void ShowStatusBarString( const char *pString, unsigned int uNumSeconds ) + { unsigned int v2; // esi@1 int i; // eax@1
--- a/mm7_4.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_4.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "VideoPlayer.h" @@ -1921,7 +1925,7 @@ { // colliding with something in the air - fall down v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower; //__debugbreak(); - v6 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[7].uCaster + 2000]; + v6 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 2000]; v7 = *v6 < v5; *v6 -= v5; if ( v7 ) @@ -1942,7 +1946,7 @@ if ( !(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) ) { // taking on water //__debugbreak(); - v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[18].uCaster + 2000]; + v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000]; v7 = *v8 < v4; *v8 -= v4; if ( v7 ) @@ -1986,7 +1990,7 @@ } a1.uObjectDescID = v10; a1.field_60_distance_related_prolly_lod = 0; - v12 = 8 * pParty->pPartyBuffs[10].uCaster; + v12 = 8 * pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uCaster; LOBYTE(v12) = v12 | OBJECT_Player; a1.uAttributes = 0; a1.uSectorID = 0; @@ -2619,7 +2623,7 @@ ++v62; } while ( (signed int)v62 <= (signed int)&pPlayers[4] ); - v46 = (signed __int64)pParty->pPartyBuffs[8].uExpireTime > 0; + v46 = (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0; for (uint i = 0; i < 20; ++i) { @@ -2627,7 +2631,7 @@ viewparams->bRedrawGameUI = 1; } - if ( v46 && (signed __int64)pParty->pPartyBuffs[8].uExpireTime <= 0 ) + if ( v46 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime <= 0 ) { for (uint i = 0; i < 4; ++i) pParty->pPlayers[i].SetCondition(1, 0);
--- a/mm7_5.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_5.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include <assert.h> #include "VideoPlayer.h" @@ -9308,45 +9312,7 @@ ZBuffer_DoFill(pZBuffer, pIcons_LOD->GetTexture(uTextureId), iZValue); } -//----- (0040F845) -------------------------------------------------------- -__int16 __fastcall sub_40F845(int a1, int a2, int a3, int a4, int a5, __int16 a6, int a7) -{ - int v7; // edi@1 - int v8; // esi@1 - int v9; // ecx@2 - int v10; // eax@3 - - v7 = a1; - v8 = a2; - do - { - v9 = a3; - do - { - v10 = *(char *)v8++; - if ( (char)v10 ) - { - if ( (char)v10 == 1 ) - { - LOWORD(v10) = *(short *)(a5 + 2 * v10); - *(short *)v7 = v10; - } - else - { - LOWORD(v10) = a6; - *(short *)v7 = a6; - } - } - v7 += 2; - --v9; - } - while ( v9 ); - v7 = a7 + v7 - a3 - a3; - --a4; - } - while ( a4 ); - return v10; -} + //----- (0040F89C) -------------------------------------------------------- void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue)
--- a/mm7_6.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_6.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "MM7.h" @@ -1607,7 +1611,7 @@ while ( (signed __int64)v6->uExpireTime <= 0 ) { ++v6; - if ( v6 > &pParty->pPartyBuffs[19] ) + if ( v6 > &pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE] ) { v7 = pParty->pPlayers;//[0].pPlayerBuffs; v8 = 0; @@ -2599,7 +2603,7 @@ AwardType *v607; // ecx@1100 __int16 v608; // ax@1102 signed int v609; // eax@1104 - //int v610; // edi@1106 + int v610; // edi@1106 unsigned int v611; // eax@1106 Player *v612; // edi@1106 DDM_DLV_Header *v613; // eax@1108 @@ -6207,8 +6211,7 @@ } v608 = pCastSpell->uPlayerID_2; if ( v608 != 4 && v608 != 5 - //|| (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0) - || (v609 = achieved_awards[v608 + (unsigned __int8)pParty->field_709 - 4], v609 <= 0) + || (v609 = (signed int)*(&pFontCChar + v608 + (unsigned __int8)pParty->field_709), v609 <= 0) || v609 >= 3 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed @@ -6216,7 +6219,7 @@ pCastSpell->spellnum = 0; continue; } - //v610 = 76 * v609; + v610 = 76 * v609; //*((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0; pParty->pHirelings[v609-1].evt_B = 0; v611 = pIconsFrameTable->FindIcon("spell96"); @@ -6480,7 +6483,7 @@ const wchar_t *UIMessage2String(UIMessageType msg) { - #define CASE(xxx) case xxx: _swprintf(b, L"%03X/%s", msg, L#xxx); return b; + #define CASE(xxx) case xxx: swprintf(b, wcslen(L"%03X/%s"), L"%03X/%s", msg, L#xxx); return b; static wchar_t b[256]; // bad for threads switch (msg) { @@ -6571,7 +6574,7 @@ CASE(UIMSG_ToggleColoredLights) CASE(UIMSG_ToggleTint) default: - _swprintf(b, L"UIMSG_%03X", msg); return b; + swprintf(b, wcslen(L"UIMSG_%03X") , L"UIMSG_%03X", msg); return b; }; #undef CASE }
--- a/mm7_data.cpp Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_data.cpp Wed Jun 05 21:00:45 2013 +0600 @@ -1,3 +1,7 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + #include "mm7_data.h" #include "GUIWindow.h" @@ -492,7 +496,7 @@ unsigned int pHealthBarPos[4] = {22, 137, 251, 366}; unsigned int pManaBarPos[4] = {102, 217, 331, 447}; char _4E2B21_buff_spell_tooltip_colors[80]; -char monster_popup_y_offsets[88] = +unsigned char monster_popup_y_offsets[88] = { 236, 20, 0, 216, 0, 0, 0, 0, 0, 0, 206, 20, 0, 246, 246, 236, 10, 246, 0, 0, 0, 236, @@ -1126,7 +1130,7 @@ int dword_591178_teleporty; // weak int dword_59117C_teleportx; // weak char byte_591180[6][100]; // idb -struct NPCData *HouseNPCData[6];//array_5913D8 +struct NPCData *HouseNPCData[60];//array_5913D8 struct Texture *pTexture_591428; struct Texture *pTexture_outside; // idb @@ -1166,7 +1170,7 @@ char pFinalMessage[4096]; // idb char pTmpBuf[2000]; char pTmpBuf2[2000]; -char byte_5C6D50[777]; // weak +char byte_5C6D50[100]; // weak int ui_current_text_color; // weak __int64 qword_5C6DF0; // weak int dword_5C6DF8; // weak
--- a/mm7_data.h Wed Jun 05 21:00:11 2013 +0600 +++ b/mm7_data.h Wed Jun 05 21:00:45 2013 +0600 @@ -88,6 +88,19 @@ // Some convenience macros to make partial accesses nicer // first unsigned macros: +#ifdef HIBYTE +#undef HIBYTE +#endif // HIBYTE +#ifdef HIWORD +#undef HIWORD +#endif // HIWORD +#ifdef LOBYTE +#undef LOBYTE +#endif // LOBYTE +#ifdef LOWORD +#undef LOWORD +#endif // LOWORD + #define LOBYTE(x) (*((_BYTE*)&(x))) // low byte #define LOWORD(x) (*((_WORD*)&(x))) // low word #define LODWORD(x) (*((_DWORD*)&(x))) // low dword @@ -153,7 +166,6 @@ - // Generate a reference to pair of operands template<class T> int16 __PAIR__( int8 high, T low) { return ((( int16)high) << sizeof(high)*8) | uint8(low); } template<class T> int32 __PAIR__( int16 high, T low) { return ((( int32)high) << sizeof(high)*8) | uint16(low); } @@ -433,7 +445,7 @@ extern unsigned int pHealthBarPos[4]; extern unsigned int pManaBarPos[4]; extern char _4E2B21_buff_spell_tooltip_colors[80]; -extern char monster_popup_y_offsets[]; // weak +extern unsigned char monster_popup_y_offsets[]; // weak extern unsigned char hourglass_icon_idx; // weak @@ -761,7 +773,7 @@ extern int dword_591178_teleporty; // weak extern int dword_59117C_teleportx; // weak extern char byte_591180[6][100]; // idb -extern struct NPCData *HouseNPCData[6]; +extern struct NPCData *HouseNPCData[60]; extern struct Texture *pTexture_591428; extern struct Texture *pTexture_outside; // idb @@ -1206,7 +1218,7 @@ int __stdcall retzero_sub_40DFA7(int); // weak int loc_40E4FC(); // weak void __fastcall ZBuffer_Fill(int *pZBuffer, int uTextureId, int iZValue); -__int16 __fastcall sub_40F845(int a1, int a2, int a3, int a4, int a5, __int16 a6, int a7); + void __fastcall ZBuffer_DoFill(int *pZBuffer, Texture *pTex, int uZValue); void __fastcall sub_40F92A(int *pZBuffer, struct Texture *a2, int a3); // idb void __cdecl SetMoonPhaseNames(); @@ -1364,7 +1376,7 @@ __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2); void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb -void __fastcall ShowStatusBarString(const char *pString, unsigned int uNumSeconds); +void ShowStatusBarString(const char *pString, unsigned int uNumSeconds); void __cdecl ShowNothingHereStatus(); signed int __cdecl const_2(); bool __cdecl sub_44C28F_open_nwc_dungeon();