# HG changeset patch # User Nomad # Date 1364272804 -7200 # Node ID d37b03507b3be73d3581286d5940e580601061db # Parent 9d2b911ef52649ae6f585dae67ab3cf6be226267# Parent d6e84d15805264b111337f183b2c09a84e202a5b Merge diff -r 9d2b911ef526 -r d37b03507b3b Events.cpp --- a/Events.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/Events.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -338,12 +338,10 @@ memcpy(pSomeEVT_Events, pLevelEVT_Index, sizeof(EventIndex)*4400); } - v4 = 0; v124 = 0; //for (uint i = 0; i < uSomeEVT_NumEvents; ++i) // { - //v6 = v123; //v7 = ""; while ( 1 ) @@ -1040,8 +1038,7 @@ sub_4451A8_press_any_key(uEventID, v105, v121); LABEL_301: if ( v133 == 1 ) -LABEL_302: - OnMapLeave(); + OnMapLeave(); return; } v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); @@ -1071,12 +1068,16 @@ case EVENT_ReceiveDamage: v85 = EVT_DWORD(_evt->v7 ); v86 = _evt->v5; - if ( (unsigned __int8)v86 <= 3u ) + if ( (unsigned __int8)v86 <= 3 ) { v119 = _evt->v6; v115 = EVT_DWORD(_evt->v7 ); v89 = (unsigned __int8)v86; - goto LABEL_233; + v88 = &pParty->pPlayers[v89]; + v88->ReceiveDamage(v115, v119); + ++curr_seq_num; + v4 = v124; + break; } if ( v86 == 4 ) { @@ -1092,16 +1093,17 @@ v119 = _evt->v6; v88 = pPlayers[uActiveCharacter]; v115 = EVT_DWORD(_evt->v7 ); - goto LABEL_234; + v88->ReceiveDamage(v115, v119); + ++curr_seq_num; + v4 = v124; + break; } if ( v86 != 5 ) { v119 = _evt->v6; v115 = EVT_DWORD(_evt->v7 ); v89 = rand() % 4; -LABEL_233: v88 = &pParty->pPlayers[v89]; -LABEL_234: v88->ReceiveDamage(v115, v119); ++curr_seq_num; v4 = v124; @@ -1372,7 +1374,8 @@ pDialogueWindow = 0; pIcons_LOD->_40F9C5(); } - goto LABEL_302; + OnMapLeave(); + return; } } ++curr_seq_num; diff -r 9d2b911ef526 -r d37b03507b3b Game.cpp --- a/Game.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/Game.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -334,7 +334,6 @@ if ( pArcomageGame->bGameInProgress ) { ArcomageGame::Loop(); -//LABEL_89: pRenderer->Present(); continue; } diff -r 9d2b911ef526 -r d37b03507b3b Indoor.cpp --- a/Indoor.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/Indoor.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -536,11 +536,14 @@ if (pFace->Fluid() && pFace->uBitmapID == pRenderer->hd_water_tile_id ) { - __debugbreak(); v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - goto LABEL_42; + v27 = pBitmaps_LOD->pHardwareTextures[v23]; + if (pFace->uAttributes & FACE_DO_NOT_LIGHT) + _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); + else + pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); + return; } - if (pFace->Fluid()) { //auto v24 = GetTickCount() / 4; @@ -552,14 +555,17 @@ for (uint i = 0; i < uNumVerticesa; ++i) //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle); - v23 = pFace->uBitmapID; - goto LABEL_42; + v27 = pBitmaps_LOD->pHardwareTextures[v23]; + if (pFace->uAttributes & FACE_DO_NOT_LIGHT) + _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); + else + pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); + return; } else if (pFace->uAttributes & 0x4000) { v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_); -LABEL_42: v27 = pBitmaps_LOD->pHardwareTextures[v23]; if (pFace->uAttributes & FACE_DO_NOT_LIGHT) _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); @@ -569,7 +575,12 @@ } v17 = 0xFFFFFFFF; v23 = pFace->uBitmapID; - goto LABEL_42; + v27 = pBitmaps_LOD->pHardwareTextures[v23]; + if (pFace->uAttributes & FACE_DO_NOT_LIGHT) + _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); + else + pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | OBJECT_BModel, v17, 0); + return;; } } } diff -r 9d2b911ef526 -r d37b03507b3b Indoor.h --- a/Indoor.h Tue Mar 26 06:34:44 2013 +0200 +++ b/Indoor.h Tue Mar 26 06:40:04 2013 +0200 @@ -1,7 +1,7 @@ #pragma once #include "VectorTypes.h" #include "IndoorCameraD3D.h" - +#include "Weather.h" @@ -402,13 +402,7 @@ -#pragma pack(push, 1) -struct IndoorLocation_stru1 -{ - unsigned __int64 uLastVisitDay; - char field_2F4[48]; -}; -#pragma pack(pop) + @@ -475,7 +469,7 @@ unsigned int uNumSpawnPoints; struct SpawnPointMM7 *pSpawnPoints; struct DDM_DLV_Header dlv; - IndoorLocation_stru1 stru1; + LocationTime_stru1 stru1; char _visible_outlines[876]; }; #pragma pack(pop) diff -r 9d2b911ef526 -r d37b03507b3b LOD.h --- a/LOD.h Tue Mar 26 06:34:44 2013 +0200 +++ b/LOD.h Tue Mar 26 06:40:04 2013 +0200 @@ -14,9 +14,6 @@ TEXTURE_16BIT_PALETTE = 0x2, }; - - - namespace LOD { #pragma pack(push, 1) diff -r 9d2b911ef526 -r d37b03507b3b Outdoor.cpp --- a/Outdoor.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/Outdoor.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -316,9 +316,9 @@ MessageBoxA(0, "Error!", "Couldn't Load Map!", 0); CreateDebugLocation(); } - ::day_attrib = v5->day_attrib; - ::day_fogrange_1 = v5->day_fogrange_1; - ::day_fogrange_2 = v5->day_fogrange_2; + ::day_attrib = v5->loc_time.day_attrib; + ::day_fogrange_1 = v5->loc_time.day_fogrange_1; + ::day_fogrange_2 = v5->loc_time.day_fogrange_2; if ( Is_out15odm_underwater() ) SetUnderwaterFog(); _6BE134_odm_main_tile_group = v5->pTileTypes[0].tileset; @@ -679,9 +679,9 @@ if ( Is_out15odm_underwater() ) SetUnderwaterFog(); - pOutdoor->day_fogrange_1 = ::day_fogrange_1; - pOutdoor->day_fogrange_2 = ::day_fogrange_2; - pOutdoor->day_attrib = ::day_attrib; + pOutdoor->loc_time.day_fogrange_1 = ::day_fogrange_1; + pOutdoor->loc_time.day_fogrange_2 = ::day_fogrange_2; + pOutdoor->loc_time.day_attrib = ::day_attrib; } //----- (00482170) -------------------------------------------------------- @@ -2324,7 +2324,7 @@ pSrc += 0xC8; pGameLoadingUI_ProgressBar->Progress(); - memcpy(&uLastVisitDay, pSrc, 0x38u); + memcpy(&loc_time, pSrc, 0x38u); free(pSrcMem); @@ -2353,23 +2353,23 @@ //v100 = HIDWORD(uLastVisitDay); //LODWORD(v142) = LODWORD(uLastVisitDay); //HIDWORD(v142) = v100; - if (uLastVisitDay) + if (loc_time.uLastVisitDay) { - if ( (signed int)((signed int)(signed __int64)((double)uLastVisitDay * 0.234375) / 60 / 60 / 24) % 28 != pParty->uDaysPlayed ) + if ( (signed int)((signed int)(signed __int64)((double)loc_time.uLastVisitDay * 0.234375) / 60 / 60 / 24) % 28 != pParty->uDaysPlayed ) { if ( rand() % 100 >= 20 ) v108 = dword_4EC268[rand() % dword_4EC2A8]; else v108 = dword_4EC28C[rand() % dword_4EC2AC]; - sprintf(sky_texture_name, "plansky%d", v108); + sprintf(loc_time.sky_texture_name, "plansky%d", v108); } } else { - strcpy(sky_texture_name, "plansky3"); + strcpy(loc_time.sky_texture_name, "plansky3"); } //v101 = pBitmaps_LOD->LoadTexture(field_4F8); - uSky_TextureID = pBitmaps_LOD->LoadTexture(sky_texture_name); + uSky_TextureID = pBitmaps_LOD->LoadTexture(loc_time.sky_texture_name); if (uSky_TextureID != -1) pBitmaps_LOD->pTextures[uSky_TextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uSky_TextureID].palette_id1); diff -r 9d2b911ef526 -r d37b03507b3b Outdoor.h --- a/Outdoor.h Tue Mar 26 06:34:44 2013 +0200 +++ b/Outdoor.h Tue Mar 26 06:40:04 2013 +0200 @@ -4,7 +4,7 @@ #include "Indoor.h" #include "TileFrameTable.h" #include "MapInfo.h" - +#include "Weather.h" #define DAY_ATTRIB_FOG 1 @@ -210,12 +210,13 @@ unsigned int uNumSpawnPoints; struct SpawnPointMM7 *pSpawnPoints; struct DDM_DLV_Header ddm; - unsigned __int64 uLastVisitDay; - char sky_texture_name[12]; - int day_attrib; - int day_fogrange_1; - int day_fogrange_2; - char field_510[24]; + LocationTime_stru1 loc_time; + //unsigned __int64 uLastVisitDay; + //char sky_texture_name[12]; + //int day_attrib; + //int day_fogrange_1; + //int day_fogrange_2; + // char field_510[24]; unsigned char uUndiscoveredArea[88][11];//968 unsigned char uDicovered_area[88][11];//[968] int field_CB8; diff -r 9d2b911ef526 -r d37b03507b3b Player.cpp --- a/Player.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/Player.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -1489,7 +1489,7 @@ } else { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[67], this->pName); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[67], this->pName); ShowStatusBarString(pTmpBuf, 2u); result = 0; } @@ -3597,7 +3597,7 @@ v25 = pGlobalTXT_LocalizationStrings[377]; } v23 = pTmpBuf2; - sprintf(pTmpBuf2, v25, v26); + sprintfex(pTmpBuf2, v25, v26); goto LABEL_43; } return 0; @@ -7293,10 +7293,10 @@ case 0x10Fu: v3->sAgeModifier = 0; goto LABEL_112; + case 0xDDu: + goto LABEL_172; default: goto LABEL_167; - case 0xDDu: - goto LABEL_172; } goto LABEL_172; } @@ -7544,7 +7544,7 @@ v68 = aCharacterConditionNames[v3->GetMajorConditionIdx()]; v58 = pGlobalTXT_LocalizationStrings[382]; LABEL_90: - sprintf(pTmpBuf, v58, v68); + sprintfex(pTmpBuf, v58, v68); v23 = pTmpBuf; LABEL_91: ShowStatusBarString(v23, 2u); @@ -7600,7 +7600,7 @@ if ( v75 > v21 || !*v17 ) { v22 = pParty->pPickedItem.GetDisplayName(); - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[381], v22); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[381], v22); ShowStatusBarString(pTmpBuf, 2u); v65 = 0; v56 = 20; diff -r 9d2b911ef526 -r d37b03507b3b Render.cpp --- a/Render.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/Render.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -5204,13 +5204,13 @@ // 4EFA84: using guessed type int dword_4EFA84; //----- (0049F5A2) -------------------------------------------------------- -int Render::_49F5A2(int a2, int a3, int a4, void *Dst, int a6, int a7) -{ +void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) + { Render *v7; // ebx@1 void *v8; // esi@3 void *v9; // esi@3 int v10; // ecx@4 - int v11; // eax@4 + unsigned short* v11; // eax@4 int v12; // eax@6 int v13; // eax@8 int v14; // ecx@8 @@ -5220,158 +5220,141 @@ char v18[58]; // [sp+Ch] [bp-ACh]@3 // __int16 v19; // [sp+44h] [bp-74h]@3 char v20[48]; // [sp+48h] [bp-70h]@3 - char *v21; // [sp+78h] [bp-40h]@7 - char *v22; // [sp+7Ch] [bp-3Ch]@7 + char *lineG; // [sp+78h] [bp-40h]@7 + char *lineB; // [sp+7Ch] [bp-3Ch]@7 int v23; // [sp+80h] [bp-38h]@4 int v24; // [sp+84h] [bp-34h]@4 int v25; // [sp+88h] [bp-30h]@4 int v26; // [sp+8Ch] [bp-2Ch]@4 - char Src; // [sp+90h] [bp-28h]@3 - char v28; // [sp+91h] [bp-27h]@3 - char v29; // [sp+92h] [bp-26h]@3 - char v30; // [sp+93h] [bp-25h]@3 - __int16 v31; // [sp+94h] [bp-24h]@3 - __int16 v32; // [sp+96h] [bp-22h]@3 - __int16 v33; // [sp+98h] [bp-20h]@3 - __int16 v34; // [sp+9Ah] [bp-1Eh]@3 - __int16 v35; // [sp+9Ch] [bp-1Ch]@3 - __int16 v36; // [sp+9Eh] [bp-1Ah]@3 - char v37; // [sp+A0h] [bp-18h]@3 - char v38; // [sp+A1h] [bp-17h]@3 - __int16 v39; // [sp+A2h] [bp-16h]@3 - __int16 v40; // [sp+A4h] [bp-14h]@3 - void *ptr; // [sp+A8h] [bp-10h]@3 - int v42; // [sp+ACh] [bp-Ch]@1 + PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 + PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 + char *lineRGB; // [sp+A8h] [bp-10h]@3 + int pitch; // [sp+ACh] [bp-Ch]@1 char v43; // [sp+B3h] [bp-5h]@18 int i; // [sp+B4h] [bp-4h]@6 + unsigned short* line_pictute_data; + byte test_byte; + unsigned char pict_byte; v7 = this; - v42 = a3; - if ( a3 & 1 ) - v42 = a3 + 1; - v31 = 0; - v32 = 0; - v33 = a3 - 1; - v34 = a4 - 1; - v39 = v42; + pitch = wight; + if ( wight & 1 ) + pitch = wight + 1; + Src.left = 0; + Src.up = 0; + Src.right = wight - 1; + Src.bottom = heidth - 1; + v27.pitch = pitch; memset(&v20, 0, 0x30u); memset(&v18, 0, 0x38u); - v8 = Dst; - v37 = 0; + v8 = data_buff; + v27.reserved = 0; *(_WORD *)&v18[56] = 0; - Src = 10; - v28 = 5; - v29 = 1; - v30 = 8; - v35 = 75; - v36 = 75; - v38 = 3; - v40 = 1; - memcpy(Dst, &Src, 1u); + Src.manufacturer = 10; + Src.version = 5; + Src.encoding = 1; + Src.bpp = 8; + Src.hdpi = 75; + Src.vdpi = 75; + v27.planes = 3; + v27.palette_info = 1; + memcpy(data_buff, &Src, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v28, 1u); + memcpy(v8, &Src.version, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v29, 1u); + memcpy(v8, &Src.encoding, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v30, 1u); + memcpy(v8, &Src.bpp, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v31, 2u); + memcpy(v8, &Src.left, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v32, 2u); + memcpy(v8, &Src.up, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v33, 2u); + memcpy(v8, &Src.right, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v34, 2u); + memcpy(v8, &Src.bottom, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v35, 2u); + memcpy(v8, &Src.hdpi, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v36, 2u); + memcpy(v8, &Src.vdpi, 2u); v8 = (char *)v8 + 2; memcpy(v8, &v20, 0x30u); v8 = (char *)v8 + 48; - memcpy(v8, &v37, 1u); + memcpy(v8, &v27, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v38, 1u); + memcpy(v8, &v27.planes, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v39, 2u); + memcpy(v8, &v27.pitch, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v40, 2u); + memcpy(v8, &v27.palette_info, 2u); v8 = (char *)v8 + 2; memcpy(v8, &v18, 0x3Au); v9 = (char *)v8 + 58; - ptr = pAllocator->AllocNamedChunk(0, 3 * a3 + 6, 0); - if ( a4 > 0 ) - { - v10 = v42; - v25 = a4; - v26 = 3 * v42; - v23 = 2 * a3; - v11 = a2; - v24 = a2; + + lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); + if ( heidth > 0 ) + { + v10 = pitch; + v25 = heidth; + v26 = 3 * pitch; + v23 = 2 * wight; + v11 = picture_data; + v24 = (int)picture_data; while ( 1 ) { - a4 = v11; + line_pictute_data = v11; v12 = 0; i = 0; - if ( a3 > 0 ) - { - v21 = (char *)ptr + v10; - v22 = (char *)ptr + 2 * v42; + if ( wight > 0 ) + { + lineG = (char *)lineRGB + pitch; + lineB = (char *)lineRGB + 2 * pitch; do { - *((char *)ptr + v12) = (signed int)(v7->uTargetRMask & *(short *)a4) >> (LOBYTE(v7->uTargetGBits) - + LOBYTE(v7->uTargetBBits) - + v7->uTargetRBits - - 8); - v13 = i; - v21[i] = (signed int)(v7->uTargetGMask & *(short *)a4) >> (LOBYTE(v7->uTargetBBits) - + LOBYTE(v7->uTargetGBits) - - 8); - v14 = a4; - a4 += 2; - v22[v13] = (v7->uTargetBMask & *(char *)v14) << (8 - LOBYTE(v7->uTargetBBits)); - v12 = v13 + 1; - i = v12; - } - while ( v12 < a3 ); + lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); + lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); + lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); + + v12++; + } + while ( v12 < wight ); } for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) { - BYTE3(a4) = 1; - BYTE3(a2) = *((char *)ptr + i); + test_byte = 1; + pict_byte = lineRGB [i]; do { - v15 = i + BYTE3(a4); - if ( *((char *)ptr + v15) != BYTE3(a2) ) + v15 = i + test_byte; + if ( *((char *)lineRGB + v15) != pict_byte ) break; - if ( !(v15 % v42) ) + if ( !(v15 % pitch) ) break; - ++BYTE3(a4); - } - while ( BYTE3(a4) < 0x3Fu ); - if ( i + BYTE3(a4) > v26 ) - BYTE3(a4) = 3 * v42 - i; - if ( BYTE3(a4) > 1u || BYTE3(a2) >= 0xC0u ) - { - v43 = BYTE3(a4) | 0xC0; + ++test_byte; + } + while ( test_byte < 0x3Fu ); + if ( i + test_byte > v26 ) + test_byte = 3 * pitch - i; + if ( test_byte > 1u || pict_byte >= 0xC0u ) + { + v43 = test_byte | 0xC0; memcpy(v9, &v43, 1u); v9 = (char *)v9 + 1; } - memcpy(v9, (char *)&a2 + 3, 1u); - i += BYTE3(a4); - } - v11 = v23 + v24; + memcpy(v9, &pict_byte, 1u); + i += test_byte; + } + v11 +=wight ; v16 = v25-- == 1; - v24 += v23; + if ( v16 ) break; - v10 = v42; - } - } - pAllocator->FreeChunk(ptr); - result = a7; - *(int *)a7 = (char *)v9 - Dst; - return result; + v10 = pitch; + } + } + pAllocator->FreeChunk(lineRGB); + *(int *)packed_size = (char *)v9 - data_buff; + } //----- (0049F8B5) -------------------------------------------------------- diff -r 9d2b911ef526 -r d37b03507b3b Render.h --- a/Render.h Tue Mar 26 06:34:44 2013 +0200 +++ b/Render.h Tue Mar 26 06:40:04 2013 +0200 @@ -279,7 +279,7 @@ void PresentBlackScreen(); void SavePCXScreenshot(); void _49F1BC(const char *a1); - int _49F5A2(int a2, int a3, int a4, void *Dst, int a6, int a7); + void PackPCXpicture(unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size); FILE *SavePCXImage(const char *Filename, char *a3, int a4, int a5); void ClearTarget(unsigned int uColor); void Release2(); diff -r 9d2b911ef526 -r d37b03507b3b SaveLoad.cpp --- a/SaveLoad.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/SaveLoad.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -24,6 +24,15 @@ +struct SaveDataHeader + { + int Signature; + char txt_ver[4]; + int compressed_size; + int uncompressed_size; + }; + + struct SavegameList *pSavegameList = new SavegameList; @@ -228,16 +237,16 @@ //----- (0045F469) -------------------------------------------------------- -int __fastcall SaveGame(int a1, __int16 *a2) -{ +void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) + { int result; // eax@1 - void *pScreenshot; // edi@5 - int v4; // eax@6 + unsigned short *pScreenshot; // edi@5 + int text_pos; // eax@6 int v5; // eax@6 int v6; // eax@6 const char *v7; // edi@8 FILE *v8; // edi@24 - int v9; // edi@30 + char* compressed_buf; // edi@30 void *v10; // esi@31 void *v11; // esi@31 void *v12; // esi@37 @@ -249,7 +258,7 @@ unsigned int v18; // ecx@38 unsigned int v19; // esi@39 BSPModel *v20; // edx@39 - void *v21; // esi@41 + char *data_write_pos; // esi@41 void *v22; // esi@41 BSPModel *v23; // eax@42 signed int v24; // edi@42 @@ -283,7 +292,7 @@ int pPositionX; // [sp+20Ch] [bp-64h]@2 int v53; // [sp+210h] [bp-60h]@2 int v54; // [sp+214h] [bp-5Ch]@2 - int Src; // [sp+218h] [bp-58h]@30 + SaveDataHeader Src; // [sp+218h] [bp-58h]@30 char v56; // [sp+21Ch] [bp-54h]@30 char v57; // [sp+21Dh] [bp-53h]@30 char v58; // [sp+21Eh] [bp-52h]@30 @@ -291,12 +300,12 @@ int v60; // [sp+220h] [bp-50h]@30 int v61; // [sp+224h] [bp-4Ch]@30 int v62; // [sp+228h] [bp-48h]@2 - LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2 + LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 size_t Size; // [sp+250h] [bp-20h]@26 __int16 *v66; // [sp+254h] [bp-1Ch]@1 - void *DstBuf; // [sp+258h] [bp-18h]@2 + char *uncompressed_buff; // [sp+258h] [bp-18h]@2 __int16 *v68; // [sp+25Ch] [bp-14h]@32 - unsigned int v69; // [sp+260h] [bp-10h]@23 + unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 int v70; // [sp+264h] [bp-Ch]@22 std::string *v71; // [sp+268h] [bp-8h]@8 int a3; // [sp+26Fh] [bp-1h]@8 @@ -304,10 +313,10 @@ //v66 = a2; strcpy(byte_6BE3B0, pCurrentMapName); if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena - return false; + return; - DstBuf = malloc(0xF4240); - pDir.Reset(); + uncompressed_buff = (char*)malloc(1000000); + pLodDirectory.Reset(); pPositionX = pParty->vPosition.x; v51 = pParty->vPosition.y; v62 = pParty->vPosition.z; @@ -322,25 +331,25 @@ if (uCurrentlyLoadedLevelType == LEVEL_Indoor) pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; else - pOutdoor->uLastVisitDay = pParty->uTimePlayed; + pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; pScreenshot = MakeScreenshot(150, 112); - strcpy(pDir.pFilename, "image.pcx"); - pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize); + strcpy(pLodDirectory.pFilename, "image.pcx"); + pRenderer->PackPCXpicture(pScreenshot, 150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize); free(pScreenshot); if (pCurrentScreen == SCREEN_SAVEGAME) { pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); - v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]); - pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение - v5 = pFontSmallnum->AlignText_Center(0xBA, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); - v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]); - pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите + text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение + text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); + text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите pRenderer->Present(); } - if (pNew_LOD->Write(&pDir, DstBuf, 0)) + if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); @@ -352,45 +361,45 @@ memset(header.field_30, 0, 52); strcpy(header.pLocationName, pCurrentMapName); header.uWordTime = pParty->uTimePlayed; - strcpy(pDir.pFilename, "header.bin"); - pDir.uDataSize = sizeof(SavegameHeader); - if (pNew_LOD->Write(&pDir, &header, 0)) + strcpy(pLodDirectory.pFilename, "header.bin"); + pLodDirectory.uDataSize = sizeof(SavegameHeader); + if (pNew_LOD->Write(&pLodDirectory, &header, 0)) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); } - strcpy(pDir.pFilename, "party.bin"); - pDir.uDataSize = 90680; - if ( pNew_LOD->Write(&pDir, pParty, 0) ) + strcpy(pLodDirectory.pFilename, "party.bin"); + pLodDirectory.uDataSize = sizeof(Party); //90680; + if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); } - strcpy(pDir.pFilename, "clock.bin"); - pDir.uDataSize = 40; - if ( pNew_LOD->Write(&pDir, pEventTimer, 0) ) + strcpy(pLodDirectory.pFilename, "clock.bin"); + pLodDirectory.uDataSize =sizeof(Timer);// 40; + if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); } - strcpy(pDir.pFilename, "overlay.bin"); - pDir.uDataSize = 1008; - if ( pNew_LOD->Write(&pDir, pOtherOverlayList, 0) ) + strcpy(pLodDirectory.pFilename, "overlay.bin"); + pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; + if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); } - strcpy(pDir.pFilename, "npcdata.bin"); - pDir.uDataSize = 501 * sizeof(NPCData); - assert(pDir.uDataSize == 38076); - if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) ) + strcpy(pLodDirectory.pFilename, "npcdata.bin"); + pLodDirectory.uDataSize = 501 * sizeof(NPCData); + assert(pLodDirectory.uDataSize == 38076); + if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); } - strcpy(pDir.pFilename, "npcgroup.bin"); - pDir.uDataSize = 102; - if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) ) + strcpy(pLodDirectory.pFilename, "npcgroup.bin"); + pLodDirectory.uDataSize = 102; + if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); @@ -406,13 +415,13 @@ __debugbreak(); sprintf(Str, "lloyd%d%d.pcx", i, j); fseek(v8, 0, 2); - pDir.uDataSize = ftell(v8); + pLodDirectory.uDataSize = ftell(v8); rewind(v8); - fread(DstBuf, pDir.uDataSize, 1, v8); - strcpy((char *)&pDir, Str); + fread(uncompressed_buff, pLodDirectory.uDataSize, 1, v8); + strcpy((char *)&pLodDirectory, Str); fclose(v8); remove(Str); - if ( pNew_LOD->Write(&pDir, DstBuf, 0) ) + if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); @@ -421,114 +430,100 @@ } } } - if ( !a2 ) + if ( !NotSaveWorld ) { //__debugbreak(); - sub_42FA22_mess_with_laying_item_list(); - v9 = (int)malloc(0xF4240); - v71 = (std::string *)v9; - Src = 91969; - v56 = 109; - v57 = 118; - v58 = 105; - v59 = 105; - v60 = 0; - v61 = 0; - memcpy((void *)v9, &Src, 0x10); + CompactLayingItemsList(); + compressed_buf = (char*)malloc(1000000); + // v71 = (std::string *)compressed_buf; + Src.Signature = 91969; + Src.txt_ver[0] = 'm'; + Src.txt_ver[1] = 'v'; + Src.txt_ver[2] = 'i'; + Src.txt_ver[3] = 'i'; + Src.compressed_size = 0; + Src.uncompressed_size = 0; + data_write_pos = uncompressed_buff; + memcpy((void *)compressed_buf, &Src, 0x10); if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; pIndoor->dlv.uNumBModels = 0; pIndoor->dlv.uNumDecorations = uNumLevelDecorations; - memcpy(DstBuf, &pIndoor->dlv, 0x28); - v10 = (char *)DstBuf + 40; - memcpy(v10, pIndoor->_visible_outlines, 0x36B); - v11 = (char *)v10 + 875; - if ( (signed int)pIndoor->uNumFaces > 0 ) - { - v68 = 0; - for (int i = 0; i <= (signed int)pIndoor->uNumFaces; ++i) + memcpy(data_write_pos, &pIndoor->dlv, 0x28); + data_write_pos += 40; + memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); + data_write_pos += 875; + + for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) { - v38 = &pIndoor->pFaces[i].uAttributes;//(char *)v68 + (unsigned int)pIndoor->pFaces + 44; - memcpy(v11, v38, 4); - v68 += 48; - v11 = (char *)v11 + 4; + memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); + data_write_pos += 4; } - } - if ( (signed int)uNumLevelDecorations > 0 ) - { - v68 = &pLevelDecorations[0].field_2; - for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) + + for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) { - memcpy(v11, v68, 2); - v68 += 16; - v11 = (char *)v11 + 2; + memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2); + + data_write_pos+= 2; } - } - memcpy(v11, &uNumActors, 4); - v12 = (char *)v11 + 4; - memcpy(v12, pActors, 836 * uNumActors); - v13 = (char *)v12 + 836 * uNumActors; - memcpy(v13, &uNumSpriteObjects, 4); - v13 = (char *)v13 + 4; - memcpy(v13, pSpriteObjects, 112 * uNumSpriteObjects); - v14 = (char *)v13 + 112 * uNumSpriteObjects; - memcpy(v14, &uNumChests, 4); - v14 = (char *)v14 + 4; - memcpy(v14, pChests, 5324 * uNumChests); - v15 = (char *)v14 + 5324 * uNumChests; - memcpy(v15, pIndoor->pDoors, 0x3E80); - v15 = (char *)v15 + 16000; - memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); - v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size; - memcpy(v16, &stru_5E4C90, 0xC8); - v17 = (int)((char *)v16 + 200); - memcpy((void *)v17, &pIndoor->stru1, 0x38); + memcpy(data_write_pos, &uNumActors, 4); + data_write_pos += 4; + memcpy(data_write_pos, pActors, 836 * uNumActors); + data_write_pos += 836 * uNumActors; + memcpy(data_write_pos, &uNumSpriteObjects, 4); + data_write_pos += 4; + memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); + data_write_pos += 112 * uNumSpriteObjects; + memcpy(data_write_pos, &uNumChests, 4); + data_write_pos += 4; + memcpy(data_write_pos, pChests, 5324 * uNumChests); + data_write_pos += 5324 * uNumChests; + memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); + data_write_pos += 16000; + memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); + data_write_pos += pIndoor->blv.uDoors_ddata_Size; + memcpy(data_write_pos, &stru_5E4C90, 0xC8); + data_write_pos += 200; + memcpy(data_write_pos, &pIndoor->stru1, 0x38); + data_write_pos += 56; + } else { v18 = 0; pOutdoor->ddm.uNumFacesInBModels = 0; - if ( (signed int)pOutdoor->uNumBModels > 0 ) - { - v19 = pOutdoor->uNumBModels; - v20 = &pOutdoor->pBModels[0]; - do - { - v18 += v20->uNumFaces; - ++v20; - --v19; - pOutdoor->ddm.uNumFacesInBModels = v18; - } - while ( v19 ); - } - v21 = DstBuf; + for (int i=0; iuNumBModels;++i) + { + v18 +=pOutdoor->pBModels[i].uNumFaces; + } + pOutdoor->ddm.uNumFacesInBModels = v18; pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; - memcpy(DstBuf, &pOutdoor->ddm, 0x28); - v21 = (char *)v21 + 40; - memcpy(v21, pOutdoor->uUndiscoveredArea, 0x3C8); - v21 = (char *)v21 + 968; - memcpy(v21, pOutdoor->uDicovered_area, 0x3C8); - v22 = (char *)v21 + 968; + memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 + data_write_pos += sizeof(DDM_DLV_Header); + memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8); + data_write_pos += 968; + memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8); + data_write_pos += 968; if ( (signed int)pOutdoor->uNumBModels > 0 ) { v23 = pOutdoor->pBModels; v24 = 76; for (int i = 0; i < (signed int)pOutdoor->uNumBModels ; ++i) { - v25 = v23[i].uNumFaces == 0;//*(int *)&v23->pModelName[v24] == 0; - v26 = v23[i].uNumFaces < 0;//*(int *)&v23->pModelName[v24] < 0; - if ( !(v26 | v25) ) + //v25 = v23[i].uNumFaces == 0;//*(int *)&v23->pModelName[v24] == 0; + // v26 = v23[i].uNumFaces < 0;//*(int *)&v23->pModelName[v24] < 0; + if ( pOutdoor->pBModels[i].uNumFaces>0) { v68 = 0; for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) { v38 = &(v23[i].pFaces[j].uAttributes); //(char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28; - memcpy(v22, v38, 4); + memcpy(data_write_pos, v38, 4); v23 = pOutdoor->pBModels; v68 += 154; - v22 = (char *)v22 + 4; + data_write_pos += 4; } } v24 += 188; @@ -539,55 +534,56 @@ v66 = &pLevelDecorations[0].field_2; for (int i = 0; i <= (signed int)uNumLevelDecorations; ++i) { - memcpy(v22, v66, 2); + memcpy(data_write_pos, v66, 2); v66 += 16; - v22 = (char *)v22 + 2; + data_write_pos += 2; } } - memcpy(v22, &uNumActors, 4); - v28 = (char *)v22 + 4; - memcpy(v28, pActors, 836 * uNumActors); - v29 = (char *)v28 + 836 * uNumActors; - memcpy(v29, &uNumSpriteObjects, 4); - v29 = (char *)v29 + 4; - memcpy(v29, pSpriteObjects, 112 * uNumSpriteObjects); - v30 = (char *)v29 + 112 * uNumSpriteObjects; - memcpy(v30, &uNumChests, 4); - v30 = (char *)v30 + 4; - memcpy(v30, pChests, 5324 * uNumChests); - v31 = (char *)v30 + 5324 * uNumChests; - memcpy(v31, &stru_5E4C90, 0xC8); - v17 = (int)((char *)v31 + 200); - memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38); - v9 = (int)v71; + memcpy(data_write_pos, &uNumActors, 4); + data_write_pos += 4; + memcpy(data_write_pos, pActors, 836 * uNumActors); + data_write_pos += 836 * uNumActors; + memcpy(data_write_pos, &uNumSpriteObjects, 4); + data_write_pos += 4; + memcpy(data_write_pos, pSpriteObjects, 112 * uNumSpriteObjects); + data_write_pos += 112 * uNumSpriteObjects; + memcpy(data_write_pos, &uNumChests, 4); + data_write_pos += 4; + memcpy(data_write_pos, pChests, 5324 * uNumChests); + data_write_pos += 5324 * uNumChests; + memcpy(data_write_pos, &stru_5E4C90, 0xC8); + data_write_pos += 200; + memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); + data_write_pos += 56; + + //compressed_buf = (int)v71; } - v32 = v17 + 56; strcpy(Source, pCurrentMapName); _splitpath(Source, Drive, Dir, Filename, Ext); v48 = 100; - Size = v32 - (int)DstBuf; - v69 = 999984; - LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf); - if ( v33 || (signed int)v69 > (signed int)Size ) + Size = (int)data_write_pos - (int)uncompressed_buff; + compressed_block_size = 999984; + LOBYTE(v33) = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); + if ( v33 || (signed int)compressed_block_size > (signed int)Size ) { - memcpy((void *)(v9 + 16), DstBuf, Size); - v69 = Size; + memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); + compressed_block_size = Size; } - v69 += 16; - memcpy((void *)(v9 + 8), &v69, 4); - memcpy((void *)(v9 + 12), &Size, 4); + compressed_block_size += 16; + memcpy(&((SaveDataHeader *)compressed_buf)->compressed_size, &compressed_block_size, 4); + memcpy(&((SaveDataHeader *)compressed_buf)->uncompressed_size, &Size, 4); sprintf(Source, "%s%s", &Filename, &Ext); - strcpy((char *)&pDir, Source); - pDir.uDataSize = v69; - if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) ) + strcpy((char *)&pLodDirectory, Source); + pLodDirectory.uDataSize = compressed_block_size; + if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) { sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208); MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); } - free((void *)v9); + free((void *)compressed_buf); } - free(DstBuf); - if ( a1 ) + free(uncompressed_buff); + if ( IsAutoSAve ) { if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) { @@ -602,9 +598,7 @@ pParty->vPosition.z = v62; pParty->uFallStartY = v62; pParty->sRotationY = v53; - result = v54; pParty->sRotationX = v54; - return result; } diff -r 9d2b911ef526 -r d37b03507b3b SpriteObject.cpp --- a/SpriteObject.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/SpriteObject.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -17,7 +17,7 @@ #include "mm7_data.h" size_t uNumSpriteObjects; -SpriteObject pSpriteObjects[1000]; +SpriteObject pSpriteObjects[MAX_SPRITE_OBJECTS]; //----- (00404828) -------------------------------------------------------- SpriteObject::SpriteObject() @@ -83,7 +83,7 @@ v21 = v6; } while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );*/ - for (uint i = 0; i < 1000; ++i) + for (uint i = 0; i < MAX_SPRITE_OBJECTS; ++i) if (!pSpriteObjects[i].uObjectDescID) { v6 = i; @@ -1100,3 +1100,17 @@ } } } + + +//----- (0042FA22) -------------------------------------------------------- +void CompactLayingItemsList() + { + int new_obj_pos=0; + + for (int i=0; iDrawTextureIndexed(8, 8, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); sprintf(pTmpBuf, "\f%05d", v3); - sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]);//^Pi[%s] %s + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]);//^Pi[%s] %s strcat(pTmpBuf, pTmpBuf2); if ( pPlayer->uSkillPoints ) v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0); diff -r 9d2b911ef526 -r d37b03507b3b UIPopup.cpp --- a/UIPopup.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/UIPopup.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -1767,7 +1767,7 @@ if ( v15 > v14->uLevel ) sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[147], v15); v16 = sub_4B46F8(v15) - LODWORD(v14->uExperience); - sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[538], v16, v15 + 1); + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[538], v16, v15 + 1); strcat(pTmpBuf, "\n"); strcat(pTmpBuf, pTmpBuf2); LOBYTE(_y) = sprintf(pTmpBuf2, "%s\n \n%s", pPlayerExperienceAttributeDescription, pTmpBuf); diff -r 9d2b911ef526 -r d37b03507b3b UiGame.cpp --- a/UiGame.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/UiGame.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -626,7 +626,7 @@ } v31 = pSpriteObjects[v30].stru_24.GetDisplayName(); v28 = pTmpBuf; - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s" + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[470], v31);// "Get %s" } else { diff -r 9d2b911ef526 -r d37b03507b3b Weather.h --- a/Weather.h Tue Mar 26 06:34:44 2013 +0200 +++ b/Weather.h Tue Mar 26 06:40:04 2013 +0200 @@ -1,7 +1,17 @@ #pragma once - +#pragma pack(push, 1) +struct LocationTime_stru1 + { + unsigned __int64 uLastVisitDay; + char sky_texture_name[12]; + int day_attrib; + int day_fogrange_1; + int day_fogrange_2; + char field_2F4[24]; + }; +#pragma pack(pop) diff -r 9d2b911ef526 -r d37b03507b3b mm7_2.cpp --- a/mm7_2.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/mm7_2.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -6256,8 +6256,8 @@ } //----- (0045E03A) -------------------------------------------------------- -unsigned __int16 *__fastcall MakeScreenshot(signed int width, signed int height) -{ +unsigned short * MakeScreenshot( signed int width, signed int height ) + { signed int v2; // edi@1 unsigned __int16 *v3; // ebx@1 int v4; // edx@7 @@ -6293,7 +6293,8 @@ v23 = 452.0 / (double)width; v25 = 336.0 / (double)height; pPixels = (unsigned __int16 *)malloc(2 * height * width); - v3 = pPixels; + memset(pPixels,0,2 * height * width); + /*v3 = pPixels; if ( pRenderer->pRenderD3D ) { pRenderer->BeginSceneD3D(); @@ -6421,7 +6422,7 @@ } } pRenderer->EndScene(); - } + }*/ return pPixels; } diff -r 9d2b911ef526 -r d37b03507b3b mm7_3.cpp --- a/mm7_3.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/mm7_3.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -1729,113 +1729,74 @@ v82 = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16; -LABEL_87: +//LABEL_87: while ( pPartyActionQueue->uNumActions ) { switch ( pPartyActionQueue->Next() ) { case PARTY_TurnLeft: - v12 = uTurnSpeed; if ( uTurnSpeed ) - goto LABEL_58; - v13 = (double)v82 * fTurnSpeedMultiplier; - v14 = angle + (unsigned __int64)(signed __int64)v13; + { + v14 = angle + uTurnSpeed; + angle = stru_5C6E00->uDoublePiMask & v14; + break; + } + v14 = angle + (unsigned __int64)(signed __int64)(double)v82 * fTurnSpeedMultiplier; angle = stru_5C6E00->uDoublePiMask & v14; - goto LABEL_87; + break; case PARTY_TurnRight: - LODWORD(v15) = uTurnSpeed; if ( uTurnSpeed ) { - angle = stru_5C6E00->uDoublePiMask & (angle - v15); - goto LABEL_87; + angle = stru_5C6E00->uDoublePiMask & (angle - uTurnSpeed); + break; } v16 = (double)v82 * fTurnSpeedMultiplier; - //{ - v15 = (signed __int64)v16; - angle = stru_5C6E00->uDoublePiMask & (angle - v15); - goto LABEL_87; - //} + angle = stru_5C6E00->uDoublePiMask & (angle - (signed __int64)v16); + break; case PARTY_FastTurnLeft: - v12 = uTurnSpeed; if ( uTurnSpeed ) { -LABEL_58: - v14 = angle + v12; + v14 = angle + uTurnSpeed; } else { - v13 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82; - v14 = angle + (unsigned __int64)(signed __int64)v13; + v14 = angle + (unsigned __int64)(signed __int64)(fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82; } angle = stru_5C6E00->uDoublePiMask & v14; - goto LABEL_87; + break; case PARTY_FastTurnRight: LODWORD(v15) = uTurnSpeed; if ( !uTurnSpeed ) { - v16 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82; - v15 = (signed __int64)v16; + v15 = (signed __int64)(fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)v82; } angle = stru_5C6E00->uDoublePiMask & (angle - v15); - goto LABEL_87; - case PARTY_StrafeLeft://Ctrl + <- - __debugbreak(); - v17 = stru_5C6E00->Sin(angle); - v18 = (double)v81; - //v88 = v18; - v78 = (unsigned __int64)(v17 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16; - v2 -= v78; - v19 = stru_5C6E00->Cos(angle); - v78 = (unsigned __int64)(v19 * (signed __int64)((signed int)(signed __int64)(v18 * fWalkSpeedMultiplier) >> 1)) >> 16; - v1 += v78; + break; + case PARTY_StrafeLeft: + v2 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; + v1 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; v78 = 1; - goto LABEL_87; + break; case PARTY_StrafeRight: - __debugbreak(); - v20 = stru_5C6E00->Sin(angle); - v21 = (double)v81; - //v88 = v21; - v78 = (unsigned __int64)(v20 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16; - v2 += v78; - v22 = stru_5C6E00->Cos(angle); - v78 = (unsigned __int64)(v22 * (signed __int64)((signed int)(signed __int64)(v21 * fWalkSpeedMultiplier) >> 1)) >> 16; - //goto LABEL_68; - v1 -= v78; + v2 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; + v1 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)((signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier) >> 1)) >> 16; v78 = 1; - goto LABEL_87; + break; case PARTY_WalkForward: - __debugbreak(); - v23 = stru_5C6E00->Cos(angle); - v24 = (double)v81; - //v88 = v24; - v78 = (unsigned __int64)(v23 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16; - v2 += v78; - v25 = stru_5C6E00->Sin(angle); - v78 = (unsigned __int64)(v25 * (signed __int64)(signed int)(signed __int64)(v24 * fWalkSpeedMultiplier)) >> 16; - v1 += v78; + v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier)) >> 16; + v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fWalkSpeedMultiplier)) >> 16; v78 = 1; - goto LABEL_87; + break; case PARTY_WalkBackward: - __debugbreak(); - v26 = stru_5C6E00->Cos(angle); - v27 = (double)v81; - //v88 = v27; - v78 = (unsigned __int64)(v26 * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16; - v2 -= v78; - v28 = stru_5C6E00->Sin(angle); - v78 = (unsigned __int64)(v28 * (signed __int64)(signed int)(signed __int64)(v27 * fBackwardWalkSpeedMultiplier)) >> 16; - v1 -= v78; + v2 -= (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; + v1 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; v78 = 1; - goto LABEL_87; + break; case PARTY_RunForward: - //v29 = stru_5C6E00->Cos(angle); - //v30 = (double)v81; - //v88 = (double)v81; v2 += (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16; - //v31 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); v1 += (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)v81 * fWalkSpeedMultiplier))) >> 16; v72 = 1; - goto LABEL_87; + break; case PARTY_RunBackward: //v32 = stru_5C6E00->SinCos(angle); //v33 = (double)v81; @@ -1844,15 +1805,14 @@ //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); v1 -= (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)(signed int)(signed __int64)((double)v81 * fBackwardWalkSpeedMultiplier)) >> 16; v72 = 1; - goto LABEL_87; + break; case PARTY_LookUp: _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); if ( _view_angle > 128 ) _view_angle = 128; v35 = uActiveCharacter; - if ( !uActiveCharacter ) - goto LABEL_87; - pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_63, 0); + if ( uActiveCharacter ) + pPlayers[v35]->PlaySound((PlayerSpeech)SPEECH_63, 0); break; case PARTY_LookDown: _view_angle += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); @@ -1873,7 +1833,7 @@ } break; default: - goto LABEL_87; + break; } } v36 = 0; @@ -11968,7 +11928,7 @@ else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_OnLongTimer) { v3 = &array_5B5928_timers[dword_5B65C8_timers_count]; - v20 = pOutdoor->uLastVisitDay; + v20 = pOutdoor->loc_time.uLastVisitDay; if (uCurrentlyLoadedLevelType == LEVEL_Indoor) v20 = pIndoor->stru1.uLastVisitDay; @@ -12329,7 +12289,7 @@ } else if ( v10 ) { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?" + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?" v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf, &v8, 0, 0)) / 2 + 101; v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf, 3); } @@ -12374,7 +12334,7 @@ pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)]; v1 = pMapStats->GetMapInfo(pCurrentMapName); if ( v1 ) - sprintf(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" + sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" else strcpy(sHouseName, pGlobalTXT_LocalizationStrings[79]);// "Exit" pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, (int)sHouseName); @@ -12443,9 +12403,9 @@ v6 = v3; v5 = pGlobalTXT_LocalizationStrings[128]; // "It will take %d days to travel to %s." } - sprintf(pTmpBuf, v5, v6, v1->pName); + sprintfex(pTmpBuf, v5, v6, v1->pName); strcat(pTmpBuf, "\n \n"); - sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName); + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName); strcat(pTmpBuf, pTmpBuf2); v4 = pFontCreate->CalcTextHeight(pTmpBuf, &v7, 0, 0); v7.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf, 3u); diff -r 9d2b911ef526 -r d37b03507b3b mm7_4.cpp --- a/mm7_4.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/mm7_4.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -7154,7 +7154,7 @@ v24 = pSkillNames[v17]; v21 = pGlobalTXT_LocalizationStrings[225]; LABEL_90: - sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[534], v21, v24, v27); + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[534], v21, v24, v27); } return pTmpBuf2; } @@ -7879,7 +7879,7 @@ { pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); - sprintf(sHouseName, pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName); + sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName); pBtn_ExitCancel = pDialogueWindow->CreateButton( 566, 445, 75, 33, 1, 0, 0x71u, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[34],// "Cancel" (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),0); diff -r 9d2b911ef526 -r d37b03507b3b mm7_5.cpp --- a/mm7_5.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/mm7_5.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -2726,7 +2726,7 @@ v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName; v157 = pGlobalTXT_LocalizationStrings[483]; _sprintex_2args_draw_status_and_continue: - sprintf(pTmpBuf, v157, v173); + sprintfex(pTmpBuf, v157, v173); } else { @@ -2756,7 +2756,7 @@ v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName; v161 = pGlobalTXT_LocalizationStrings[486]; } - sprintf(pTmpBuf, v161, v178); + sprintfex(pTmpBuf, v161, v178); sub_41C0B8_set_status_string(pTmpBuf); //goto LABEL_91; v0 = 1; @@ -5108,7 +5108,7 @@ v50 = (int)pMonster; pMonsterName = (char *)uDamageAmount; pPlayerName = player->pName; // "%s inflicts %lu points killing %s" - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); + sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); ShowStatusBarString(pTmpBuf, 2u); } } diff -r 9d2b911ef526 -r d37b03507b3b mm7_6.cpp --- a/mm7_6.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/mm7_6.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -8290,39 +8290,7 @@ } } -//----- (0042FA22) -------------------------------------------------------- -SpriteObject *__cdecl sub_42FA22_mess_with_laying_item_list() -{ - size_t v0; // edx@1 - int v1; // ebp@1 - SpriteObject *result; // eax@1 - SpriteObject *v3; // ebx@1 - - v0 = 0; - v1 = 0; - //result = (char *)&pSpriteObjects[0].uObjectDescID; - result = pSpriteObjects; - v3 = pSpriteObjects; - do - { - if ( result->uObjectDescID ) - { - if ( v1 != v0 ) - { - memcpy(v3, result, 0x70u); - result->uObjectDescID = 0; - } - ++v0; - ++v3;// = (char *)v3 + 112; - } - ++result;// += 112; - ++v1; - } - //while ( (signed int)result < (signed int)((char *)&pObjectList->uNumObjects + 2) ); - while( result <= &pSpriteObjects[999] ); - uNumSpriteObjects = v0; - return result; -} + //----- (0042FA66) -------------------------------------------------------- int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6) diff -r 9d2b911ef526 -r d37b03507b3b mm7_data.h --- a/mm7_data.h Tue Mar 26 06:34:44 2013 +0200 +++ b/mm7_data.h Tue Mar 26 06:40:04 2013 +0200 @@ -1737,7 +1737,7 @@ signed int __cdecl sub_42F4DA(); bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9); void __fastcall sub_42F960_create_object(int x, int y, int z); // idb -SpriteObject *__cdecl sub_42FA22_mess_with_laying_item_list(); +void CompactLayingItemsList(); signed int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6); bool __fastcall sub_42FB5C(signed int a1); // int __cdecl crt_sub_42FBB7(); @@ -1872,12 +1872,12 @@ unsigned int __fastcall SkillToMastery(unsigned __int16 a1); unsigned int __fastcall GetSpellColor(signed int a1); void *__thiscall unknown_vdtor_6(void *_this, bool a2); -unsigned __int16 *__fastcall MakeScreenshot(signed int width, signed int height); +unsigned short * MakeScreenshot(signed int width, signed int height); void __thiscall SaveScreenshot(const char *pFilename); void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType); // idb void __cdecl GameUI_DrawSaveMenu(); void __fastcall LoadGame(unsigned int uSlot); // idb -int __fastcall SaveGame(int a1, __int16 *a2); +void SaveGame(bool IsAutoSAve, bool NotSaveWorld); void __fastcall DoSavegame(unsigned int uSlot); // idb void GameUI_MainMenu_DoDrawLoad(int a1); void GameUI_MainMenu_DrawLoad(); diff -r 9d2b911ef526 -r d37b03507b3b mm7text_ru.cpp --- a/mm7text_ru.cpp Tue Mar 26 06:34:44 2013 +0200 +++ b/mm7text_ru.cpp Tue Mar 26 06:40:04 2013 +0200 @@ -1328,16 +1328,16 @@ switch (src[2]) { case 'I': case 'i': + case 'V': case 'v': + case 'R': case 'r': + case 'D': case 'd': + case 'T': case 't': { strncpy(dst, name_begin, name_len); dst += name_len; } break; - case 'R': case 'r': - case 'D': case 'd': - case 'V': case 'v': - case 'T': case 't': case 'P': case 'p': { auto token_begin = src;