1
0
mirror of https://github.com/ScrelliCopter/tmx2gba.git synced 2025-02-21 03:29:25 +11:00

tmxlite: further cleanup

This commit is contained in:
2024-03-28 22:15:57 +11:00
parent 849ff6bcc8
commit a7617f3a3a
24 changed files with 123 additions and 209 deletions

View File

@@ -25,15 +25,14 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/Types.hpp"
#include "tmxlite/detail/Log.hpp"
#ifndef USE_ZLIB
#include "miniz.h"
# include "miniz.h"
#else
#include <zlib.h>
# include <zlib.h>
#endif
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/Types.hpp>
#include <tmxlite/detail/Log.hpp>
#include <cstring>
bool tmx::decompress(const char* source, std::vector<unsigned char>& dest, std::size_t inSize, std::size_t expectedSize)
@@ -59,7 +58,7 @@ bool tmx::decompress(const char* source, std::vector<unsigned char>& dest, std::
stream.next_out = (Bytef*)byteArray.data();
stream.avail_out = static_cast<unsigned int>(expectedSize);
//we'd prefer to use inflateInit2 but it appears
//we'd prefer to use inflateInit2 but it appears
//to be incorrect in miniz. This is fine for zlib
//compressed data, but gzip compressed streams
//will fail to inflate.

View File

@@ -25,10 +25,11 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include "tmxlite/ImageLayer.hpp"
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <tmxlite/ImageLayer.hpp>
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/detail/Log.hpp>
using namespace tmx;

View File

@@ -25,13 +25,14 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include "tmxlite/LayerGroup.hpp"
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/ObjectGroup.hpp"
#include "tmxlite/ImageLayer.hpp"
#include "tmxlite/TileLayer.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <tmxlite/LayerGroup.hpp>
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/ObjectGroup.hpp>
#include <tmxlite/ImageLayer.hpp>
#include <tmxlite/TileLayer.hpp>
#include <tmxlite/detail/Log.hpp>
using namespace tmx;

View File

@@ -25,16 +25,15 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include <pugixml.hpp>
#include <tmxlite/Map.hpp>
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/ObjectGroup.hpp>
#include <tmxlite/ImageLayer.hpp>
#include <tmxlite/TileLayer.hpp>
#include <tmxlite/LayerGroup.hpp>
#include <tmxlite/detail/Log.hpp>
#include <tmxlite/detail/Android.hpp>
#include "tmxlite/Map.hpp"
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/ObjectGroup.hpp"
#include "tmxlite/ImageLayer.hpp"
#include "tmxlite/TileLayer.hpp"
#include "tmxlite/LayerGroup.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <queue>
using namespace tmx;
@@ -136,8 +135,8 @@ bool Map::parseMapNode(const pugi::xml_node& mapNode)
return reset();
}
m_version.upper = STOI(attribString.substr(0, pointPos));
m_version.lower = STOI(attribString.substr(pointPos + 1));
m_version.upper = std::stoi(attribString.substr(0, pointPos));
m_version.lower = std::stoi(attribString.substr(pointPos + 1));
m_class = mapNode.attribute("class").as_string();

View File

@@ -25,13 +25,13 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include <pugixml.hpp>
#include <tmxlite/Object.hpp>
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/Map.hpp>
#include <tmxlite/Tileset.hpp>
#include <tmxlite/detail/Log.hpp>
#include "tmxlite/Object.hpp"
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/Map.hpp"
#include "tmxlite/Tileset.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <sstream>
using namespace tmx;
@@ -65,7 +65,7 @@ void Object::parse(const pugi::xml_node& node, Map* map)
{
m_class = node.attribute("class").as_string();
}
m_position.x = node.attribute("x").as_float();
m_AABB.left = m_position.x;
m_position.y = node.attribute("y").as_float();
@@ -272,7 +272,7 @@ void Object::parseTemplate(const std::string& path, Map* map)
{
m_AABB.height = obj.m_AABB.height;
}
m_tilesetName = obj.m_tilesetName;
if (m_name.empty())
@@ -313,7 +313,7 @@ void Object::parseTemplate(const std::string& path, Map* map)
//compare properties and only copy ones that don't exist
for (const auto& p : obj.m_properties)
{
auto result = std::find_if(m_properties.begin(), m_properties.end(),
auto result = std::find_if(m_properties.begin(), m_properties.end(),
[&p](const Property& a)
{
return a.getName() == p.getName();

View File

@@ -25,10 +25,11 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/ObjectGroup.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/ObjectGroup.hpp>
#include <tmxlite/detail/Log.hpp>
using namespace tmx;

View File

@@ -24,10 +24,11 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/ObjectTypes.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/ObjectTypes.hpp>
#include <tmxlite/detail/Log.hpp>
using namespace tmx;

View File

@@ -25,10 +25,11 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include "tmxlite/Property.hpp"
#include "tmxlite/detail/Log.hpp"
#include "tmxlite/FreeFuncs.hpp"
#include <pugixml.hpp>
#include <tmxlite/Property.hpp>
#include <tmxlite/detail/Log.hpp>
#include <tmxlite/FreeFuncs.hpp>
using namespace tmx;

View File

@@ -25,12 +25,13 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include <pugixml.hpp>
#include <zstd.h>
#include "base64.h"
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/TileLayer.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <zstd.h>
#include <sstream>
using namespace tmx;

View File

@@ -25,11 +25,11 @@ and must not be misrepresented as being the original software.
source distribution.
*********************************************************************/
#include <pugixml.hpp>
#include <tmxlite/Tileset.hpp>
#include <tmxlite/FreeFuncs.hpp>
#include <tmxlite/detail/Log.hpp>
#include "tmxlite/Tileset.hpp"
#include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/detail/Log.hpp"
#include <pugixml.hpp>
#include <ctype.h>
using namespace tmx;
@@ -59,7 +59,7 @@ void Tileset::parse(pugi::xml_node node, Map* map)
Logger::log(attribString + ": not a tileset node! Node will be skipped.", Logger::Type::Warning);
return;
}
m_firstGID = node.attribute("firstgid").as_int();
if (m_firstGID == 0)
{
@@ -237,7 +237,7 @@ const Tileset::Tile* Tileset::getTile(std::uint32_t id) const
{
return nullptr;
}
//corrects the ID. Indices and IDs are different.
id -= m_firstGID;
id = m_tileIndex[id];
@@ -368,12 +368,12 @@ void Tileset::parseTileNode(const pugi::xml_node& node, Map* map)
{
tile.className = node.attribute("class").as_string();
}
//by default we set the tile's values as in an Image tileset
tile.imagePath = m_imagePath;
tile.imageSize = m_tileSize;
if (m_columnCount != 0)
if (m_columnCount != 0)
{
std::uint32_t rowIndex = tile.ID % m_columnCount;
std::uint32_t columnIndex = tile.ID / m_columnCount;