mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-05 18:10:09 +03:00
* Allow overwriting of frame data from the patch data file.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "PatchManager.hpp"
|
||||
#include "AppPlatform.hpp"
|
||||
#include "client/common/Utils.hpp"
|
||||
#include "world/tile/Tile.hpp"
|
||||
#include "world/item/Item.hpp"
|
||||
#include "compat/GL.hpp"
|
||||
|
||||
#define PM_SEPARATOR ('|')
|
||||
@@ -55,6 +57,67 @@ void PatchManager::LoadPatchData(const std::string& patchData)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (command == "frame")
|
||||
{
|
||||
std::string xStr, yStr, itemName;
|
||||
|
||||
if (!std::getline(lineStream, itemName, PM_SEPARATOR)) continue;
|
||||
if (!std::getline(lineStream, xStr, PM_SEPARATOR)) continue;
|
||||
if (!std::getline(lineStream, yStr, PM_SEPARATOR)) continue;
|
||||
|
||||
int itemID = -1, x = 0, y = 0;
|
||||
if (!sscanf(xStr.c_str(), "%d", &x)) continue;
|
||||
if (!sscanf(yStr.c_str(), "%d", &y)) continue;
|
||||
|
||||
// try to parse the item name as an int first
|
||||
if (sscanf(itemName.c_str(), "%d", &itemID))
|
||||
{
|
||||
if (itemID < 0 || itemID >= C_MAX_ITEMS)
|
||||
goto namefailure;
|
||||
|
||||
if (itemID < C_MAX_TILES && !Tile::tiles[itemID])
|
||||
goto namefailure;
|
||||
|
||||
if (itemID >= C_MAX_TILES && !Item::items[itemID])
|
||||
goto namefailure;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string tileDesc = "tile." + itemName;
|
||||
std::string itemDesc = "item." + itemName;
|
||||
// look through the entirety of the Tiles and Items array
|
||||
for (int i = 0; i < C_MAX_TILES && itemID == -1; i++)
|
||||
{
|
||||
if (!Tile::tiles[i])
|
||||
continue;
|
||||
if (Tile::tiles[i]->m_descriptionID != tileDesc)
|
||||
continue;
|
||||
|
||||
itemID = i;
|
||||
}
|
||||
for (int i = 0; i < C_MAX_ITEMS && itemID == -1; i++)
|
||||
{
|
||||
if (!Item::items[i])
|
||||
continue;
|
||||
if (Item::items[i]->m_DescriptionID != itemDesc)
|
||||
continue;
|
||||
|
||||
itemID = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemID == -1)
|
||||
{
|
||||
namefailure:
|
||||
LogMsg("Unknown item/tile with the name %s", itemName.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
m_patchData.push_back(PatchData(TYPE_FRAME, itemID, 16 * y + x));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// features -- TODO un-hardcode this
|
||||
if (command == "vegetation_tint")
|
||||
{
|
||||
@@ -105,6 +168,30 @@ void PatchManager::PatchTextures(AppPlatform* pAppPlatform, ePatchType patchType
|
||||
}
|
||||
}
|
||||
|
||||
void PatchManager::PatchTiles()
|
||||
{
|
||||
for (int i = 0; i < int(m_patchData.size()); i++)
|
||||
{
|
||||
PatchData& pd = m_patchData[i];
|
||||
if (pd.m_type != TYPE_FRAME)
|
||||
continue;
|
||||
|
||||
if (pd.m_destID < C_MAX_TILES && Tile::tiles[pd.m_destID])
|
||||
{
|
||||
Tile::tiles[pd.m_destID]->m_TextureFrame = pd.m_frameNo;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Item::items[pd.m_destID])
|
||||
{
|
||||
Item::items[pd.m_destID]->m_icon = pd.m_frameNo;
|
||||
continue;
|
||||
}
|
||||
|
||||
LogMsg("PatchTiles: unknown item ID %d", pd.m_destID);
|
||||
}
|
||||
}
|
||||
|
||||
bool PatchManager::IsGrassTinted()
|
||||
{
|
||||
return m_bGrassTinted;
|
||||
|
||||
Reference in New Issue
Block a user