Skip to content
Permalink
Browse files

Remove Obsolete Proto2ES (#1533)

Well, this is it, the dawn of a new ENIGMA and the final stage of the transition to Google Protocol Buffers. When Josh created the GameData structure (basically converts EnigmaStruct into a proto) in #1448, he made Proto2ES obsolete and no longer necessary. This pull request completes the transition by finally adding a new method to the `compileEGMf` DLL that accepts a protocol buffer and deleting Proto2ES from emake's sources. With this change, emake, RGM, and any new frontend tools should reach peak compiling performance as they are passing a proto directly to the compiler with no intermediate translation to other formats. Other tools, like LGM, will continue to use the outdated EnigmaStruct, subject to binary compatibility-breaking changes, for the foreseeable future until someone decides to migrate such tools to protos too.

### Summary of Changes
* Changed the `EnigmaPlugin::BuildGame` overload that accepts a proto game to no longer call `Proto2ES` and instead call the newly loaded `plugin_CompileProto` function. It's worth mentioning that, for some reason, we had this set up to take `Game` instead of `Project` so I didn't have a need to change the signature yet. I also wasn't sure the distinction fundies was making between `Game` and `Project` when he made the latter contain the former. For now, I just made a temporary `Project` and set the passed `Game` on it.
* Deleted the `Proto2ES` header and source file from emake's sources.
* Changed the CompilerSource makefile to link to zlib and lodepng since it now needs both in order to compile a proto game.
* Changed the `GameData` structure to define all of the proto-based copy constructors and flatten the tree. Some resources had specific requirements, such as objects and timelines which needed their drag and drop actions converted to code. The actions to code conversion will probably later be moved into libEGM because RGM is not going to support the old drag and drop actions format. Sounds, Sprites, and Backgrounds also needed the code from Proto2ES in order to load their binary data in for the compiler.
* Changed `CompilerSource/compiler/compile.cpp` to export a new `compileProto` DLL function for frontend tools that would like to use ENIGMA's new Protocol Buffers interface. The Protocol Buffers interface, as should be obvious, has several advantages including the ability to serialize and communicate the buffers to a remote client or to make changes without breaking binary compatibility.
* Changed the object parsing and linking logic to deal with events that have a subname instead of a subid (collision events in GMX have the other object as a string). From the comments, it appears that Josh was confused and thought that name was the composite name of the main id and subid, when in reality it's just the name of the "other" object for collision events at the moment. Later I'd like to see this changed around to support what I call "templated" events where you could hypothetically have an event for any kind of resource (perhaps an event for when a selected sprite loads). Regardless, this specifically addresses being able to build AI Tutorial project from emake.
* Addressed the `"<undefined>"` resource name edge case in the GMX reader using the new resource reference option provided by #1547 to know which string fields to compare.
* Tweaked the top-level makefile to have `liblodepng` as a dependency of the default target (which is the compiler). This has to be done because `GameData`, which is part of the compiler backend, now requires lodepng in order to load the binary data for Sprites and Backgrounds.
* Changed the emake makefile to no longer link to zlib and lodepng since it no longer has a direct dependency on them. Also removed the dependency in the main makefile too.
  • Loading branch information...
RobertBColton committed Feb 13, 2019
1 parent ce15a46 commit ff783971ec92ca908533fdf1c9c6d9820e60c055
@@ -1,6 +1,5 @@
#include "EnigmaPlugin.hpp"
#include "Main.hpp"
#include "Proto2ES.h"

#include "OS_Switchboard.h"

@@ -65,6 +64,7 @@ int EnigmaPlugin::Load()

plugin_Init = reinterpret_cast<const char*(*)(EnigmaCallbacks*)>(BindFunc(_handle, "libInit"));
plugin_CompileEGM = reinterpret_cast<int (*)(EnigmaStruct *es, const char* exe_filename, int mode)>(BindFunc(_handle, "compileEGMf"));
plugin_CompileProto = reinterpret_cast<int (*)(const buffers::Project *proj, const char* exe_filename, int mode)>(BindFunc(_handle, "compileProto"));
plugin_NextResource = reinterpret_cast<const char* (*)()>(BindFunc(_handle, "next_available_resource"));
plugin_FirstResource = reinterpret_cast<const char* (*)()>(BindFunc(_handle, "first_available_resource"));
plugin_ResourceIsFunction = reinterpret_cast<bool (*)()>(BindFunc(_handle, "resource_isFunction"));
@@ -121,9 +121,9 @@ int EnigmaPlugin::BuildGame(EnigmaStruct* data, GameMode mode, const char* fpath

int EnigmaPlugin::BuildGame(buffers::Game* data, GameMode mode, const char* fpath)
{
EnigmaStruct *es = Proto2ES(data);
es->filename = fpath;
return plugin_CompileEGM(es, fpath, mode);
buffers::Project proj;
proj.set_allocated_game(data);
return plugin_CompileProto(&proj, fpath, mode);
}

const char* EnigmaPlugin::NextResource() {
@@ -4,6 +4,7 @@
#include "EnigmaCallbacks.hpp"
#include "backend/EnigmaStruct.h"
#include "frontend.h"
#include "project.pb.h"
#include "game.pb.h"

#include <functional>
@@ -53,7 +54,7 @@ class EnigmaPlugin
private:
std::function<const char*(EnigmaCallbacks*)> plugin_Init = nullptr;
std::function<int(EnigmaStruct*, const char*, int)> plugin_CompileEGM = nullptr;
std::function<int(buffers::Game *project, const char*, int)> plugin_CompileBuffer = nullptr;
std::function<int(const buffers::Project *proj, const char*, int)> plugin_CompileProto = nullptr;
std::function<const char*()> plugin_NextResource = nullptr;
std::function<const char*()> plugin_FirstResource = nullptr;
std::function<bool()> plugin_ResourceIsFunction = nullptr;
@@ -15,8 +15,6 @@
#include "yyp.h"
#endif

#include "Proto2ES.h"

#include <boost/filesystem.hpp>

#include <fstream>
@@ -17,8 +17,8 @@ else
endif

PROTO_DIR := $(SHARED_SRC_DIR)/protos
CXXFLAGS := -I$(SRC_DIR) -I../../CompilerSource -I$(SHARED_SRC_DIR) -I$(SHARED_SRC_DIR)/lodepng -I$(PROTO_DIR) -I$(PROTO_DIR)/codegen -std=c++11 -Wall -Wextra -Wpedantic -g
LDFLAGS := $(OS_LIBS) -L../../ -lz -L$(SHARED_SRC_DIR)/lodepng -llodepng -lProtocols -lprotobuf
CXXFLAGS := -I$(SRC_DIR) -I../../CompilerSource -I$(SHARED_SRC_DIR) -I$(PROTO_DIR) -I$(PROTO_DIR)/codegen -std=c++11 -Wall -Wextra -Wpedantic -g
LDFLAGS := $(OS_LIBS) -L../../ -lProtocols -lprotobuf

rwildcard=$(wildcard $1/$2) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2))
SOURCES := $(call rwildcard,$(SRC_DIR),*.cpp)
Oops, something went wrong.

0 comments on commit ff78397

Please sign in to comment.
You can’t perform that action at this time.