This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pacman -Syu --noconfirm base base-devel sudo go git protobuf grpc yaml-cpp pugixml rapidjson boost xorg-server-xvfb zstd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CXXFLAGS += -I../ $(shell pkg-config --cflags pugixml) $(shell pkg-config --cflags libzstd) -I$(PROTO_DIR) -fPIC | |
LDFLAGS += -shared -lz $(shell pkg-config --libs-only-L pugixml) $(shell pkg-config --libs-only-L libzstd) -lpugixml -lyaml-cpp -L../../ -lProtocols -lprotobuf -lENIGMAShared -lpng $(FS_LIBS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool LoadCsvLayerData(const pugi::xml_node &layerNode, const std::string &dataStr, buffers::TreeNode *resNode, | |
const int& tileWidth, const int& tileHeight) { | |
std::vector<unsigned int> globalTileIds; | |
std::istringstream istr(dataStr); | |
std::string line; | |
while(std::getline(istr, line)) { | |
std::stringstream lineStream(line); | |
std::string globalId; | |
while(std::getline(lineStream, globalId, ',')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TMXMapLoader : public pugi::xml_tree_walker { | |
public: | |
// code truncated... | |
bool Load(pugi::xml_document &xmlDoc) { | |
pugi::xml_node mapNode = xmlDoc.child("map"); | |
// first load all tileset(s) in background(s) | |
bool backgroundsOk = LoadTilesets(mapNode, "background"); | |
if(!backgroundsOk) | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// code truncated... | |
class TMXMapLoader : public pugi::xml_tree_walker { | |
// code truncated... | |
private: | |
// code truncated... | |
virtual bool for_each(pugi::xml_node &xmlNode) { | |
// code truncated... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
message Room { | |
optional int32 id = 29 [(gmx) = "GMX_DEPRECATED"]; | |
optional string caption = 1; | |
optional uint32 width = 2 [(yyp) = "roomSettings/Width", (tmx) = "width"]; // tmx width unit is no. of tiles | |
optional uint32 height = 3 [(yyp) = "roomSettings/Height", (tmx) = "height"]; // tmx height unit is no. of tiles | |
optional uint32 hsnap = 4 [(tmx) = "tilewidth"]; // tmx tilewidth unit is probably in pixels | |
optional uint32 vsnap = 5 [(tmx) = "tileheight"]; // tmx tileheight unit is probably in pixels | |
optional bool isometric = 6 [(tmx) = "orientation"]; // TODO: Handle type conversion exclusively. Add support to staggered and hexagonal orientations of tmx | |
optional uint32 speed = 27; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool TSXTilesetLoader::for_each(pugi::xml_node& xmlNode) { | |
// truncated code... | |
pugi::xml_node imgNode = xmlNode.child("image"); | |
if(imgNode.empty()) { | |
pugi::xml_object_range<pugi::xml_named_node_iterator> tileChildrenItr = xmlNode.children("tile"); | |
for(pugi::xml_node tileChild : tileChildrenItr) { | |
buffers::TreeNode *protoNode = backgroundFolderRef->mutable_folder()->add_children(); | |
std::string tileId = tileChild.attribute("id").value(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "tsx.h" | |
// truncated headers and namespaces | |
class TSXTilesetLoader : public pugi::xml_tree_walker { | |
virtual bool for_each(pugi::xml_node& xmlNode) { | |
// truncated code... | |
AddResource(protoNode, resType, xmlNode); | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto2"; | |
package buffers.resources; | |
message Background { | |
optional int32 id = 1 [(gmx) = "GMX_DEPRECATED", (tmx) = "firstgid"]; | |
// truncated code... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
virtual bool for_each(pugi::xml_node& node) { | |
for(pugi::xml_attribute attr : node.attributes()) { | |
if(strcmp(node.name(),"tileset") == 0){ | |
if(strcmp(attr.name(),"tilewidth") == 0) | |
background->set_tile_width(std::stoi(attr.value())); | |
else if(strcmp(attr.name(),"tileheight") == 0) | |
background->set_tile_height(std::stoi(attr.value())); | |
// truncated code ... | |
} | |
// truncated code ... |