MMORPG, seamless world split to zones, cpp
there's intensive inter-zone communication, so the task is to simplify it's implementation as much as possible.
I'm using "proxy" approach where a remote object is represented by its proxy in local zone. this proxy can communicate with its master.
something like async RPC would be helpful, that allows to simply define "remote" methods and to generate as much code as possible, ideally it could look like:
#define REMOVE_METHOD(return_type, method_name, args)
where args are a list of method parameters (type, name, special serialization flag)
this macro could generate:
- declaration of [method_name]. definition will implement game logic that should be provided by a programmer of course
- declaration and definition of forward_[method_name] that for a proxy will pack args to a specific type packet and send to its master
- declaration and definition of do_[method_name] that checks if an object is master or proxy and calls its [method_name] or forward_[method_name] respectively
- declaration and definition of receive_[method_name] that will be automatically called upon receiving specific packet, will unpack data and call [method_name]
results if any can be sent back just like another remote method call
having such system communicating with world objects would be uniform no matter where they are located and it would be extremely simple to add a new "remote" method, only specific serialization of some of its args can require additional effort (once per argument type)
first of all, what do you think about this in general? are there any similar systems that can be used as a reference?
there're two alternative ways to implement such "async RPC":
- by macros: can be tricky even using boost preprocessor library
- by code generation: e.g. by generating C++ code (pre-compile step) based on some simple syntax describing those "remote" methods
what is better (more flexible or less time consuming)? any problems in outlook with code generation?
tnx for your opinion