From d62a47a5e60a54d5cdc0a27e6393abef44ceb3b4 Mon Sep 17 00:00:00 2001 From: captainurist <73941350+captainurist@users.noreply.github.com> Date: Mon, 16 Oct 2023 10:52:39 +0100 Subject: [PATCH 1/2] Dropped all FromFileTxt functions --- src/Engine/Graphics/Overlays.cpp | 53 ---- src/Engine/Graphics/Overlays.h | 1 - src/Engine/Objects/Monsters.cpp | 101 -------- src/Engine/Objects/Monsters.h | 1 - src/Engine/Tables/CharacterFrameTable.cpp | 111 --------- src/Engine/Tables/CharacterFrameTable.h | 1 - src/Engine/Tables/IconFrameTable.cpp | 133 ---------- src/Engine/Tables/IconFrameTable.h | 2 - src/Engine/Tables/TileTable.cpp | 280 ---------------------- src/Engine/Tables/TileTable.h | 1 - 10 files changed, 684 deletions(-) diff --git a/src/Engine/Graphics/Overlays.cpp b/src/Engine/Graphics/Overlays.cpp index f4bc6403bf6c..775797273c76 100644 --- a/src/Engine/Graphics/Overlays.cpp +++ b/src/Engine/Graphics/Overlays.cpp @@ -94,59 +94,6 @@ void OverlayList::InitializeSprites() { pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID); } -//----- (00458E4F) -------------------------------------------------------- -bool OverlayList::FromFileTxt(const char *Args) { - FILE *v4; // eax@1 - unsigned int v5; // esi@3 - void *v7; // eax@9 - // FILE *v8; // ST0C_4@11 - char *i; // eax@11 - char Buf[490]; // [sp+10h] [bp-2F0h]@3 - FrameTableTxtLine v18; // [sp+204h] [bp-FCh]@4 - FrameTableTxtLine v19; // [sp+280h] [bp-80h]@4 - FILE *File; // [sp+2FCh] [bp-4h]@1 - unsigned int Argsa; // [sp+308h] [bp+8h]@3 - - pOverlays.clear(); - v4 = fopen(Args, "r"); - File = v4; - if (!v4) Error("ObjectDescriptionList::load - Unable to open file: %s."); - - v5 = 0; - Argsa = 0; - if (fgets(Buf, sizeof(Buf), v4)) { - do { - *strchr(Buf, 10) = 0; - memcpy(&v19, txt_file_frametable_parser(Buf, &v18), sizeof(v19)); - if (v19.uPropCount && *v19.pProperties[0] != 47) ++Argsa; - } while (fgets(Buf, sizeof(Buf), File)); - v5 = Argsa; - } - pOverlays.reserve(v5); - - fseek(File, 0, 0); - for (i = fgets(Buf, sizeof(Buf), File); i; i = fgets(Buf, sizeof(Buf), File)) { - *strchr(Buf, 10) = 0; - memcpy(&v19, txt_file_frametable_parser(Buf, &v18), sizeof(v19)); - if (v19.uPropCount && *v19.pProperties[0] != 47) { - OverlayDesc &overlay = pOverlays.emplace_back(); - - overlay.uOverlayID = atoi(v19.pProperties[0]); - if (!iequals(v19.pProperties[1], "center")) { - if (iequals(v19.pProperties[1], "transparent")) - overlay.uOverlayType = 2; - else - overlay.uOverlayType = 1; - } else { - overlay.uOverlayType = 0; - } - overlay.uSpriteFramesetID = pSpriteFrameTable->FastFindSprite(v19.pProperties[2]); - } - } - fclose(File); - return 1; -} - //----- (0045855F) -------------------------------------------------------- void ActiveOverlay::Reset() { this->indexToOverlayList = 0; diff --git a/src/Engine/Graphics/Overlays.h b/src/Engine/Graphics/Overlays.h index 7fcd80cd28c9..1730e39da383 100644 --- a/src/Engine/Graphics/Overlays.h +++ b/src/Engine/Graphics/Overlays.h @@ -40,7 +40,6 @@ struct OverlayDesc { }; struct OverlayList { - bool FromFileTxt(const char *Args); void InitializeSprites(); std::vector pOverlays; diff --git a/src/Engine/Objects/Monsters.cpp b/src/Engine/Objects/Monsters.cpp index 420cd2db0eee..a26cfdb8eace 100644 --- a/src/Engine/Objects/Monsters.cpp +++ b/src/Engine/Objects/Monsters.cpp @@ -291,107 +291,6 @@ int ParseSpecialAttack(char *spec_att_str) { return 0; } -//----- (004598FC) -------------------------------------------------------- -bool MonsterList::FromFileTxt(const char *Args) { - FILE *v3; // eax@1 - unsigned int v4; // esi@3 - void *v5; // eax@9 - FILE *v6; // ST14_4@11 - char *i; // eax@11 - signed int v8; // esi@12 - uint16_t v9; // ax@16 - const char *v10; // ST18_4@16 - uint16_t v11; // ax@16 - const char *v12; // ST14_4@16 - uint16_t v13; // ax@16 - const char *v14; // ST10_4@16 - int16_t v15; // ax@16 - const char *v16; // ST0C_4@16 - int v17; // esi@16 - uint8_t v18; // al@16 - signed int v19; // esi@16 - uint16_t v20; // ax@17 - int v21; // ecx@17 - char Buf[490]; // [sp+4h] [bp-304h]@3 - FrameTableTxtLine v24; // [sp+1F8h] [bp-110h]@4 - FrameTableTxtLine v25; // [sp+274h] [bp-94h]@4 - int v26; // [sp+2F0h] [bp-18h]@16 - FILE *File; // [sp+304h] [bp-4h]@1 - unsigned int Argsa; // [sp+310h] [bp+8h]@3 - int Argsb; // [sp+310h] [bp+8h]@16 - - v3 = fopen(Args, "r"); - File = v3; - if (!v3) Error("MonsterRaceListStruct::load - Unable to open file: %s."); - - v4 = 0; - Argsa = 0; - if (fgets(Buf, sizeof(Buf), v3)) { - do { - *strchr(Buf, 10) = 0; - memcpy(&v25, frame_table_txt_parser(Buf, &v24), sizeof(v25)); - if (v25.uPropCount && *v25.pProperties[0] != 47) ++Argsa; - } while (fgets(Buf, sizeof(Buf), File)); - v4 = Argsa; - } - - v6 = File; - fseek(v6, 0, 0); - MonsterId monsterId = MONSTER_INVALID; - for (i = fgets(Buf, sizeof(Buf), File); i; i = fgets(Buf, sizeof(Buf), File)) { - *strchr(Buf, 10) = 0; - memcpy(&v25, frame_table_txt_parser(Buf, &v24), sizeof(v25)); - v8 = 0; - if (v25.uPropCount && *v25.pProperties[0] != 47) { - monsterId = static_cast(std::to_underlying(monsterId) + 1); - MonsterDesc &monster = this->pMonsters[monsterId]; - - monster.pMonsterName = v25.pProperties[0]; - - constexpr std::array, 8> mapping = {{ - {ANIM_Standing, 1}, - {ANIM_Walking, 2}, - {ANIM_Bored, 3}, - {ANIM_AtkMelee, 4}, - {ANIM_AtkRanged, 4}, - {ANIM_GotHit, 5}, - {ANIM_Dying, 6}, - {ANIM_Dead, 7}, - }}; - - do { - monster.pSpriteNames[mapping[v8].first] = v25.pProperties[mapping[v8].second]; - ++v8; - } while (v8 < 8); - v9 = atoi(v25.pProperties[8]); - v10 = v25.pProperties[9]; - monster.uMonsterHeight = v9; - v11 = atoi(v10); - v12 = v25.pProperties[10]; - monster.uMovementSpeed = v11; - v13 = atoi(v12); - v14 = v25.pProperties[11]; - monster.uMonsterRadius = v13; - v15 = atoi(v14); - v16 = v25.pProperties[12]; - monster.uToHitRadius = v15; - v17 = (uint8_t)atoi(v16); - Argsb = atoi(v25.pProperties[13]) & 0xFF; - v26 = atoi(v25.pProperties[14]) & 0xFF; - v18 = atoi(v25.pProperties[15]); - monster.sTintColor = Color(v18, v26, Argsb, v17); - v19 = 0; - do { - v20 = atoi(v25.pProperties[v19 + 16]); - v21 = v19++; - monster.pSoundSampleIDs[v21] = v20; - } while (v19 < 4); - } - } - fclose(File); - return 1; -} - //----- (004563FF) -------------------------------------------------------- MonsterId MonsterStats::FindMonsterByTextureName(const std::string &monster_textr_name) { for (MonsterId i : pInfos.indices()) { diff --git a/src/Engine/Objects/Monsters.h b/src/Engine/Objects/Monsters.h index 8cd6f1b20f7a..fa33b94be6f4 100644 --- a/src/Engine/Objects/Monsters.h +++ b/src/Engine/Objects/Monsters.h @@ -101,7 +101,6 @@ struct MonsterDesc { struct MonsterList { MonsterId GetMonsterIDByName(const std::string &pMonsterName); - bool FromFileTxt(const char *Args); IndexedArray pMonsters; }; diff --git a/src/Engine/Tables/CharacterFrameTable.cpp b/src/Engine/Tables/CharacterFrameTable.cpp index b2aef5548919..df34cd4854d1 100644 --- a/src/Engine/Tables/CharacterFrameTable.cpp +++ b/src/Engine/Tables/CharacterFrameTable.cpp @@ -52,114 +52,3 @@ PlayerFrame *PlayerFrameTable::GetFrameBy_y(int *pFramesetID, int *pAnimTime, } return &this->pFrames[*pFramesetID]; } - -//----- (00494C5A) -------------------------------------------------------- -// int PlayerFrameTable::FromFileTxt(const char *Args) { -// // PlayerFrameTable *v2; // ebx@1 -// FILE *v3; // eax@1 -// int v4; // esi@3 -// void *v5; // eax@10 -// FILE *v6; // ST0C_4@12 -// char *i; // eax@12 -// // int16_t v8; // ax@15 -// // const char *v9; // ST10_4@15 -// // uint16_t v10; // ax@15 -// // const char *v11; // ST0C_4@15 -// int j; // esi@15 -// // int v13; // eax@17 -// int v14; // edx@22 -// int v15; // ecx@23 -// int v16; // eax@24 -// signed int k; // eax@27 -// // PlayerFrame *v18; // edx@28 -// int v19; // esi@28 -// int l; // ecx@29 -// char Buf; // [sp+Ch] [bp-2F8h]@3 -// FrameTableTxtLine v23; // [sp+200h] [bp-104h]@4 -// FrameTableTxtLine v24; // [sp+27Ch] [bp-88h]@4 -// int v25; // [sp+2F8h] [bp-Ch]@3 -// int v26; // [sp+2FCh] [bp-8h]@3 -// FILE *File; // [sp+300h] [bp-4h]@1 -// int Argsa; // [sp+30Ch] [bp+8h]@28 -// -// __debugbreak(); // Ritor1; -// // TileTable::dtor((TileTable *)this); -// v3 = fcaseopen(Args, "r"); -// File = v3; -// if (!v3) Error("PlayerFrameTable::load - Unable to open file: %s.", Args); -// v4 = 0; -// v25 = 0; -// v26 = 1; -// if (fgets(&Buf, 490, v3)) { -// do { -// *strchr(&Buf, 10) = 0; -// memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); -// if (v24.uPropCount && *v24.pProperties[0] != 47) { -// if (v24.uPropCount < 3) -// Error( -// "PlayerFrameTable::load, too few arguments, %s line " -// "%i.", -// Args, v26); -// ++v25; -// } -// ++v26; -// } while (fgets(&Buf, 490, File)); -// v4 = v25; -// } -// this->uNumFrames = v4; -// v5 = malloc(sizeof(PlayerFrame) * v4); -// this->pFrames = (PlayerFrame *)v5; -// if (!v5) Error("PlayerFrameTable::load - Out of Memory!"); -// v6 = File; -// this->uNumFrames = 0; -// fseek(v6, 0, 0); -// for (i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File)) { -// *strchr(&Buf, 10) = 0; -// memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); -// if (v24.uPropCount && *v24.pProperties[0] != 47) { -// // v8 = atoi(v24.pProperties[0]); -// // v9 = v24.pProperties[1]; -// this->pFrames[this->uNumFrames].expression = -// (CharacterExpressionID)atoi(v24.pProperties[0]); -// // v10 = atoi(v9); -// // v11 = v24.pProperties[2]; -// this->pFrames[this->uNumFrames].uTextureID = -// atoi(v24.pProperties[1]); -// this->pFrames[this->uNumFrames].uAnimTime = -// atoi(v24.pProperties[2]); -// this->pFrames[this->uNumFrames].uAnimLength = 0; -// this->pFrames[this->uNumFrames].uFlags = 0; -// for (j = 3; j < v24.uPropCount; ++j) { -// if (iequals(v24.pProperties[j], "New")) -// this->pFrames[this->uNumFrames].uFlags |= 4; -// } -// ++this->uNumFrames; -// } -// } -// fclose(File); -// -// if ((signed int)(this->uNumFrames - 1) > 0) { -// v15 = 0; -// for (v14 = 0; v14 < this->uNumFrames - 1; ++v14) { -// v16 = (int)&this->pFrames[v15]; -// if (!(*(char *)(v16 + 18) & 4)) this->pFrames[v14].uFlags |= 1; -// ++v15; -// } -// } -// for (k = 0; k < (signed int)this->uNumFrames; *(short *)(Argsa + 6) = v19) { -// // v18 = this->pFrames; -// Argsa = (int)&this->pFrames[k]; -// v19 = *(short *)(Argsa + 4); -// if (this->pFrames[k].uFlags & 1) { -// ++k; -// for (l = (int)&this->pFrames[k]; this->pFrames[k].uFlags & 1; -// l += 10) { -// v19 += *(short *)(l + 4); -// ++k; -// } -// HEXRAYS_LOWORD(v19) = this->pFrames[k].uAnimTime + v19; -// } -// ++k; -// } -// return 1; -// } diff --git a/src/Engine/Tables/CharacterFrameTable.h b/src/Engine/Tables/CharacterFrameTable.h index ae357bbcce33..8b1e40480c11 100644 --- a/src/Engine/Tables/CharacterFrameTable.h +++ b/src/Engine/Tables/CharacterFrameTable.h @@ -19,7 +19,6 @@ struct PlayerFrameTable { int GetDurationByExpression(CharacterExpressionID expression); PlayerFrame *GetFrameBy_x(int uFramesetID, int gameTime); PlayerFrame *GetFrameBy_y(int *a2, int *a3, int a4); - int FromFileTxt(const char *Args); std::vector pFrames; }; diff --git a/src/Engine/Tables/IconFrameTable.cpp b/src/Engine/Tables/IconFrameTable.cpp index 2e9effd35ce9..456566c2131d 100644 --- a/src/Engine/Tables/IconFrameTable.cpp +++ b/src/Engine/Tables/IconFrameTable.cpp @@ -64,136 +64,3 @@ void IconFrameTable::InitializeAnimation(unsigned int uIconID) { } } } - -/* -//----- (0049509D) -------------------------------------------------------- -int IconFrameTable::FromFileTxt(const char *Args) -{ - //IconFrameTable *v2; // ebx@1 - FILE *v3; // eax@1 - int v4; // esi@3 - void *v5; // eax@10 - FILE *v6; // ST0C_4@12 - char *i; // eax@12 - const char *v8; // ST00_4@15 - int v9; // eax@16 - int v10; // edx@20 - int v11; // ecx@21 - int v12; // eax@22 - signed int j; // edx@25 - IconFrame_MM7 *v14; // ecx@26 - int v15; // esi@26 - int k; // eax@27 - signed int result; // eax@11 - char Buf; // [sp+Ch] [bp-2F8h]@3 - FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4 - FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4 - int v21; // [sp+2F8h] [bp-Ch]@3 - int v22; // [sp+2FCh] [bp-8h]@3 - FILE *File; // [sp+300h] [bp-4h]@1 - int Argsa; // [sp+30Ch] [bp+8h]@26 - - //v2 = this; - //TileTable::dtor((TileTable *)this); - __debugbreak();//Ritor1: this function not used - v3 = fopen(Args, "r"); - File = v3; - if ( !v3 ) - Error("IconFrameTable::load - Unable to open file: %s.", Args); - v4 = 0; - v21 = 0; - v22 = 1; - if ( fgets(&Buf, 490, v3) ) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); - if ( v20.uPropCount && *v20.pProperties[0] != 47 ) - { - if ( v20.uPropCount < 3 ) - Error("IconFrameTable::loadText, too few arguments, %s line %i.", -Args, v22); - ++v21; - } - ++v22; - } - while ( fgets(&Buf, 490, File) ); - v4 = v21; - } - this->uNumIcons = v4; - v5 = malloc(32 * v4);//, "I Frames"); - this->pIcons = (IconFrame_MM7 *)v5; - if ( v5 ) - { - v6 = File; - this->uNumIcons = 0; - fseek(v6, 0, 0); - for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); - if ( v20.uPropCount && *v20.pProperties[0] != 47 ) - { - strcpy(this->pIcons[this->uNumIcons].pAnimationName, -v20.pProperties[0]); strcpy(this->pIcons[this->uNumIcons].pTextureName, -v20.pProperties[1]); v8 = v20.pProperties[2]; - this->pIcons[this->uNumIcons].uFlags = 0; - if ( iequals(v8, "new") ) - { - v9 = (int)&this->pIcons[this->uNumIcons].uFlags; - *(char *)v9 |= 4u; - } - this->pIcons[this->uNumIcons].uAnimTime = atoi(v20.pProperties[3]); - this->pIcons[this->uNumIcons].uAnimLength = 0; - this->pIcons[this->uNumIcons++].uTextureID = 0; - } - } - fclose(File); - v10 = 0; - if ( (signed int)(this->uNumIcons - 1) > 0 ) - { - v11 = 0; - do - { - v12 = (int)&this->pIcons[v11]; - if ( !(*(char *)(v12 + 60) & 4) ) - *(char *)(v12 + 28) |= 1u; - ++v10; - ++v11; - } - while ( v10 < (signed int)(this->uNumIcons - 1) ); - } - for ( j = 0; j < (signed int)this->uNumIcons; *(short *)(Argsa + 26) = v15 ) - { - v14 = this->pIcons; - Argsa = (int)&v14[j]; - v15 = *(short *)(Argsa + 24); - if ( *(char *)(Argsa + 28) & 1 ) - { - ++j; - for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 ) - { - v15 += *(short *)(k + 24); - ++j; - } - LOWORD(v15) = v14[j].uAnimTime + v15; - } - ++j; - } - result = 1; - } - else - { - fclose(File); - result = 0; - } - return result; -}*/ - -/* -//----- (0042EB78) -------------------------------------------------------- -int IconFrameTable::GetIconAnimLength(unsigned int uIconID) -{ - return 8 * this->pIcons[uIconID].uAnimLength; -}*/ diff --git a/src/Engine/Tables/IconFrameTable.h b/src/Engine/Tables/IconFrameTable.h index 194bf5c09fe4..42b3a21f62ea 100644 --- a/src/Engine/Tables/IconFrameTable.h +++ b/src/Engine/Tables/IconFrameTable.h @@ -48,8 +48,6 @@ struct IconFrameTable { unsigned int FindIcon(const std::string &pIconName); Icon *GetFrame(unsigned int uIconID, unsigned int frame_time); void InitializeAnimation(unsigned int uIconID); - int FromFileTxt(const char *Args); - // int GetIconAnimLength(unsigned int uIconID); std::vector pIcons; }; diff --git a/src/Engine/Tables/TileTable.cpp b/src/Engine/Tables/TileTable.cpp index def194e22372..259b10a201d6 100644 --- a/src/Engine/Tables/TileTable.cpp +++ b/src/Engine/Tables/TileTable.cpp @@ -70,283 +70,3 @@ unsigned int TileTable::GetTileId(Tileset uTerrainType, TILE_SECT uSection) { } return 0; } - -//----- (00488047) -------------------------------------------------------- -int TileTable::FromFileTxt(const char *pFilename) { - TileTable *v2; // ebp@1 - FILE *v3; // eax@1 - unsigned int v4; // ebx@3 - void *v5; // eax@9 - uint16_t v6; // ax@14 - const char *v7; // ST14_4@14 - uint16_t v8; // ax@14 - const char *v9; // esi@14 - const char *v35; // esi@67 - int j; // edi@152 - const char *v72; // esi@153 - FILE *i; // [sp-10h] [bp-304h]@3 - FILE *File; // [sp+4h] [bp-2F0h]@1 - FrameTableTxtLine v84; // [sp+8h] [bp-2ECh]@4 - FrameTableTxtLine v85; // [sp+84h] [bp-270h]@4 - char Buf[490]; // [sp+100h] [bp-1F4h]@4 - - v2 = this; - v3 = fopen(pFilename, "r"); - File = v3; - if (!v3) Error("TileTable::load - Unable to open file: %s."); - v4 = 0; - for (i = v3; fgets(Buf, sizeof(Buf), i); i = File) { - *strchr(Buf, 10) = 0; - memcpy(&v84, txt_file_frametable_parser(Buf, &v85), sizeof(v84)); - if (v84.uPropCount && *v84.pProperties[0] != 47) ++v4; - } - v2->tiles.reserve(v4); - v2->tiles.resize(0); - fseek(File, 0, 0); - - while (fgets(Buf, sizeof(Buf), File)) { - *strchr(Buf, 10) = 0; - memcpy(&v84, txt_file_frametable_parser(Buf, &v85), sizeof(v84)); - if (v84.uPropCount) { - if (*v84.pProperties[0] != 47) { - TileDesc &tile = v2->tiles.emplace_back(); - - // strcpy(tile.pTileName, v84.pProperties[0]); - v6 = atoi(v84.pProperties[1]); - v7 = v84.pProperties[2]; - tile.uTileID = v6; - v8 = atoi(v7); - v9 = v84.pProperties[3]; - // tile.uBitmapID = v8; - - if (iequals(v9, "TTtype_NULL")) { - tile.tileset = Tileset_NULL; - } else if (iequals(v9, "TTtype_Start")) { - tile.tileset = Tileset_Start; - } else if (iequals(v9, "TTtype_Grass")) { - tile.tileset = Tileset_Grass; - } else if (iequals(v9, "TTtype_Snow")) { - tile.tileset = Tileset_Snow; - } else if (iequals(v9, "TTtype_Sand")) { - tile.tileset = Tileset_Desert; - } else if (iequals(v9, "TTtype_Volcano")) { - tile.tileset = Tileset_CooledLava; - } else if (iequals(v9, "TTtype_Dirt")) { - tile.tileset = Tileset_Dirt; - } else if (iequals(v9, "TTtype_Water")) { - tile.tileset = Tileset_Water; - } else if (iequals(v9, "TTtype_Cracked")) { - tile.tileset = Tileset_Badlands; - } else if (iequals(v9, "TTtype_Swamp")) { - tile.tileset = Tileset_Swamp; - } else if (iequals(v9, "TTtype_Tropical")) { - tile.tileset = Tileset_Tropical; - } else if (iequals(v9, "TTtype_City")) { - tile.tileset = Tileset_City; - } else if (iequals(v9, "TTtype_RoadGrassCobble")) { - tile.tileset = Tileset_RoadGrassCobble; - } else if (iequals(v9, "TTtype_RoadGrassDirt")) { - tile.tileset = Tileset_RoadGrassDirt; - } else if (iequals(v9, "TTtype_RoadSnowCobble")) { - tile.tileset = Tileset_RoadSnowCobble; - } else if (iequals(v9, "TTtype_RoadSnowDirt")) { - tile.tileset = Tileset_RoadSnowDirt; - } else if (iequals(v9, "TTtype_RoadSandCobble")) { - tile.tileset = Tileset_RoadSandCobble; - } else if (iequals(v9, "TTtype_RoadSandDirt")) { - tile.tileset = Tileset_RoadSandDirt; - } else if (iequals(v9, "TTtype_RoadVolcanoCobble")) { - tile.tileset = Tileset_RoadVolcanoCobble; - } else if (iequals(v9, "TTtype_RoadVolcanoDirt")) { - tile.tileset = Tileset_RoadVolcanoDirt; - } else if (iequals(v9, "TTtype_RoadCrackedCobble")) { - tile.tileset = Tileset_RoadCrackedCobble; - } else if (iequals(v9, "TTtype_RoadCrackedDirt")) { - tile.tileset = Tileset_RoadCrackedDirt; - } else if (iequals(v9, "TTtype_RoadSwampCobble")) { - tile.tileset = Tileset_RoadSwampCobble; - } else if (iequals(v9, "TTtype_RoadSwampDirt")) { - tile.tileset = Tileset_RoadSwampDir; - } else if (iequals(v9, "TTtype_RoadTropicalCobble")) { - tile.tileset = Tileset_RoadTropicalCobble; - } else if (iequals(v9, "TTtype_RoadTropicalDirt")) { - tile.tileset = Tileset_RoadTropicalDirt; - } else if (iequals(v9, "TTtype_RoadCityStone")) { - tile.tileset = Tileset_RoadCityStone; - } else { - logger->warning("Unknown tile type {}", v9); - } - - v35 = v84.pProperties[4]; - - // Default - tile.uSection = TILE_SECT_Base1; - tile.uAttributes = 0; - - if (iequals(v35, "TTsect_NULL")) { - tile.uSection = TILE_SECT_NULL; - } else if (iequals(v35, "TTsect_Start")) { - tile.uSection = TILE_SECT_Start; - } else if (iequals(v35, "TTsect_Base1")) { - tile.uSection = TILE_SECT_Base1; - } else if (iequals(v35, "TTsect_Base2")) { - tile.uSection = TILE_SECT_Base2_NS; - } else if (iequals(v35, "TTsect_Base3")) { - tile.uSection = TILE_SECT_Base3_EW; - } else if (iequals(v35, "TTsect_Base4")) { - tile.uSection = TILE_SECT_Base4_N_E; - } else if (iequals(v35, "TTsect_Special1")) { - tile.uSection = TILE_SECT_Special1_N_W; - } else if (iequals(v35, "TTsect_Special2")) { - tile.uSection = TILE_SECT_Special2_S_E; - } else if (iequals(v35, "TTsect_Special3")) { - tile.uSection = TILE_SECT_Special3_S_W; - } else if (iequals(v35, "TTsect_Special4")) { - tile.uSection = TILE_SECT_Special4_NS_E; - } else if (iequals(v35, "TTsect_Special5")) { - tile.uSection = TILE_SECT_Special5_NS_W; - } else if (iequals(v35, "TTsect_Special6")) { - tile.uSection = TILE_SECT_Special6_EW_N; - } else if (iequals(v35, "TTsect_Special7")) { - tile.uSection = TILE_SECT_Special7_EW_S; - } else if (iequals(v35, "TTsect_Special8")) { - tile.uSection = TILE_SECT_Special8_NCAP; - } else if (iequals(v35, "TTsect_NE1")) { - tile.uSection = TILE_SECT_NE1_SE1_ECAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_NW1")) { - tile.uSection = TILE_SECT_NW1_SW1_WCAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_SE1")) { - tile.uSection = TILE_SECT_NE1_SE1_ECAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_SW1")) { - tile.uSection = TILE_SECT_NW1_SW1_WCAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_E1")) { - tile.uSection = TILE_SECT_E1_DS; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_W1")) { - tile.uSection = TILE_SECT_W1_DW; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_N1")) { - tile.uSection = TILE_SECT_N1_DE; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_S1")) { - tile.uSection = TILE_SECT_S1_DSW; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_XNE1")) { - tile.uSection = TILE_SECT_XNE1_XSE1_DNE; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_XNW1")) { - tile.uSection = TILE_SECT_XNW1_XSW1_DNW; - tile.uAttributes = TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_XSE1")) { - tile.uSection = TILE_SECT_XNE1_XSE1_DNE; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_XSW1")) { - tile.uSection = TILE_SECT_XNW1_XSW1_DNW; - tile.uAttributes = TILE_DESC_TRANSITION; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_CROS")) { - tile.uSection = TILE_SECT_Base1; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_NS")) { - tile.uSection = TILE_SECT_Base2_NS; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_EW")) { - tile.uSection = TILE_SECT_Base3_EW; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_N_E")) { - tile.uSection = TILE_SECT_Base4_N_E; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_N_W")) { - tile.uSection = TILE_SECT_Special1_N_W; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_S_E")) { - tile.uSection = TILE_SECT_Special2_S_E; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_S_W")) { - tile.uSection = TILE_SECT_Special3_S_W; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_NS_E")) { - tile.uSection = TILE_SECT_Special4_NS_E; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_NS_W")) { - tile.uSection = TILE_SECT_Special5_NS_W; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_EW_N")) { - tile.uSection = TILE_SECT_Special6_EW_N; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_EW_S")) { - tile.uSection = TILE_SECT_Special7_EW_S; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_NCAP")) { - tile.uSection = TILE_SECT_Special8_NCAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_ECAP")) { - tile.uSection = TILE_SECT_NE1_SE1_ECAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_SCAP")) { - tile.uSection = TILE_SECT_SCAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_WCAP")) { - tile.uSection = TILE_SECT_NW1_SW1_WCAP; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DN")) { - tile.uSection = TILE_SECT_DN; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DS")) { - tile.uSection = TILE_SECT_E1_DS; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DW")) { - tile.uSection = TILE_SECT_W1_DW; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DE")) { - tile.uSection = TILE_SECT_N1_DE; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DSW")) { - tile.uSection = TILE_SECT_S1_DSW; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DNE")) { - tile.uSection = TILE_SECT_XNE1_XSE1_DNE; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DSE")) { - tile.uSection = TILE_SECT_DSE; - tile.uAttributes |= TILE_DESC_TRANSITION; - } else if (iequals(v35, "TTsect_DNW")) { - tile.uSection = TILE_SECT_XNW1_XSW1_DNW; - tile.uAttributes |= TILE_DESC_TRANSITION; - } - - for (j = 5; j < v84.uPropCount; ++j) { - v72 = v84.pProperties[j]; - if (iequals(v84.pProperties[j], "TTattr_Burn")) { - tile.uAttributes |= TILE_DESC_BURN; - } else if (iequals(v72, "TTattr_Water")) { - tile.uAttributes |= TILE_DESC_WATER; - } else if (iequals(v72, "TTattr_Water2")) { - tile.uAttributes |= TILE_DESC_WATER_2; - } else if (iequals(v72, "TTattr_Block")) { - tile.uAttributes |= TILE_DESC_BLOCK; - } else if (iequals(v72, "TTattr_Repulse")) { - tile.uAttributes |= TILE_DESC_REPULSE; - } else if (iequals(v72, "TTattr_Flat")) { - tile.uAttributes |= TILE_DESC_FLAT; - } else if (iequals(v72, "TTattr_Wave")) { - tile.uAttributes |= TILE_DESC_WAVY; - } else if (iequals(v72, "TTattr_NoDraw")) { - tile.uAttributes |= TILE_DESC_DONT_DRAW; - } else if (iequals(v72, "TTattr_Transition")) { - tile.uAttributes |= TILE_DESC_TRANSITION; - } else { - logger->warning("Unknown tile attribute {}", v72); - } - } - } - } - } - - fclose(File); - return 1; -} diff --git a/src/Engine/Tables/TileTable.h b/src/Engine/Tables/TileTable.h index 35a83b4c87dc..2b93aa84b394 100644 --- a/src/Engine/Tables/TileTable.h +++ b/src/Engine/Tables/TileTable.h @@ -38,7 +38,6 @@ struct TileTable { void InitializeTileset(Tileset tileset); int GetTileForTerrainType(Tileset a1, bool a2); unsigned int GetTileId(Tileset uTerrainType, TILE_SECT uSection); - int FromFileTxt(const char *pFilename); std::vector tiles; }; From 5e71e122019804a13e7f3838cc6b746b2ba97d47 Mon Sep 17 00:00:00 2001 From: captainurist <73941350+captainurist@users.noreply.github.com> Date: Mon, 16 Oct 2023 10:55:06 +0100 Subject: [PATCH 2/2] Dropped HWLContainer --- src/Engine/Graphics/CMakeLists.txt | 2 - src/Engine/Graphics/HWLContainer.cpp | 134 --------------------------- src/Engine/Graphics/HWLContainer.h | 39 -------- 3 files changed, 175 deletions(-) delete mode 100644 src/Engine/Graphics/HWLContainer.cpp delete mode 100644 src/Engine/Graphics/HWLContainer.h diff --git a/src/Engine/Graphics/CMakeLists.txt b/src/Engine/Graphics/CMakeLists.txt index 57fffacf30be..ccb034806d26 100644 --- a/src/Engine/Graphics/CMakeLists.txt +++ b/src/Engine/Graphics/CMakeLists.txt @@ -9,7 +9,6 @@ set(ENGINE_GRAPHICS_SOURCES DecalBuilder.cpp DecorationList.cpp FrameLimiter.cpp - HWLContainer.cpp IRenderFactory.cpp Image.cpp ImageLoader.cpp @@ -48,7 +47,6 @@ set(ENGINE_GRAPHICS_HEADERS DecorationList.h FaceEnums.h FrameLimiter.h - HWLContainer.h IRender.h IRenderFactory.h Image.h diff --git a/src/Engine/Graphics/HWLContainer.cpp b/src/Engine/Graphics/HWLContainer.cpp deleted file mode 100644 index d5a9469c4715..000000000000 --- a/src/Engine/Graphics/HWLContainer.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "Engine/Graphics/HWLContainer.h" - -#include -#include -#include - -#include "Engine/EngineIocContainer.h" -#include "Library/Compression/Compression.h" -#include "Library/Logger/Logger.h" -#include "Utility/String.h" - -#pragma pack(push, 1) -struct HWLHeader { - uint32_t uSignature; - uint32_t uDataOffset; -}; -#pragma pack(pop) - -HWLContainer::HWLContainer() { - log = EngineIocContainer::ResolveLogger(); -} - -HWLContainer::~HWLContainer() { - if (pFile != nullptr) { - fclose(this->pFile); - } -} - -bool HWLContainer::Open(const std::string &pFilename) { - assert(!pFile); - - pFile = fopen(pFilename.c_str(), "rb"); - if (!pFile) { - log->warning("Failed to open file: {}", pFilename); - return false; - } - - HWLHeader header; - if (fread(&header, sizeof(HWLHeader), 1, pFile) != 1) - return false; - - if (memcmp(&header.uSignature, "D3DT", 4) != 0) { - log->warning("Invalid format: {}", pFilename); - return false; - } - fseek(pFile, header.uDataOffset, SEEK_SET); - - typedef struct HWLNode { - std::string sName; - size_t uOffset = 0; - } HWLNode; - std::vector vNodes; - - uint32_t uNumItems = 0; - if (fread(&uNumItems, 4, 1, pFile) != 1) - return false; - - char tmpName[21]; - for (unsigned int i = 0; i < uNumItems; ++i) { - if (fread(tmpName, 20, 1, pFile) != 1) - return false; - tmpName[20] = 0; - HWLNode node; - node.sName = toLower(std::string(tmpName)); - node.uOffset = 0; - vNodes.push_back(node); - } - - for (unsigned int i = 0; i < uNumItems; ++i) { - uint32_t uOffset = 0; - if (fread(&uOffset, 4, 1, pFile) != 1) - return false; - vNodes[i].uOffset = uOffset; - } - - for (HWLNode &node : vNodes) { - mNodes[node.sName] = node.uOffset; - } - - return true; -} - -#pragma pack(push, 1) -struct HWLTextureHeader { - uint32_t uCompressedSize; - uint32_t uBufferWidth; - uint32_t uBufferHeight; - uint32_t uAreaWidth; - uint32_t uAreaHeigth; - uint32_t uWidth; - uint32_t uHeight; - uint32_t uAreaX; - uint32_t uAreaY; -}; -#pragma pack(pop) - -HWLTexture *HWLContainer::LoadTexture(const std::string &pName) { - if (mNodes.size() == 0) { - return nullptr; - } - - std::map::iterator it = mNodes.find(toLower(pName)); - if (it == mNodes.end()) { - return nullptr; - } - size_t uOffset = it->second; - - fseek(pFile, uOffset, SEEK_SET); - - HWLTextureHeader textureHeader; - if (fread(&textureHeader, sizeof(HWLTextureHeader), 1, pFile) != 1) - return nullptr; - - HWLTexture *pTex = new HWLTexture; - pTex->uBufferWidth = textureHeader.uBufferWidth; - pTex->uBufferHeight = textureHeader.uBufferHeight; - pTex->uAreaWidth = textureHeader.uAreaWidth; - pTex->uAreaHeigth = textureHeader.uAreaHeigth; - pTex->uWidth = textureHeader.uWidth; - pTex->uHeight = textureHeader.uHeight; - pTex->uAreaX = textureHeader.uAreaX; - pTex->uAreaY = textureHeader.uAreaY; - - pTex->pPixels = new uint16_t[pTex->uWidth * pTex->uHeight]; - if (textureHeader.uCompressedSize) { - Blob buffer = zlib::uncompress(Blob::read(pFile, textureHeader.uCompressedSize)); - memcpy(pTex->pPixels, buffer.data(), buffer.size()); // TODO: gotta check size here. - } else { - if (fread(pTex->pPixels, 2 * pTex->uWidth * pTex->uHeight, 1, pFile) != 1) - return nullptr; - } - - return pTex; -} diff --git a/src/Engine/Graphics/HWLContainer.h b/src/Engine/Graphics/HWLContainer.h deleted file mode 100644 index 031f7d4beee5..000000000000 --- a/src/Engine/Graphics/HWLContainer.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -class HWLTexture { - public: - inline HWLTexture() {} - - int uBufferWidth = 0; - int uBufferHeight = 0; - int uAreaWidth = 0; - int uAreaHeigth = 0; - unsigned int uWidth = 0; - unsigned int uHeight = 0; - int uAreaX = 0; - int uAreaY = 0; - uint16_t *pPixels = nullptr; -}; - -class Logger; - -// TODO(captainurist): currently unused, can drop. -class HWLContainer { - public: - HWLContainer(); - virtual ~HWLContainer(); - - bool Open(const std::string &pFilename); - - HWLTexture *LoadTexture(const std::string &pName); - - protected: - FILE *pFile = nullptr; - Logger *log = nullptr; - std::map mNodes; -};