-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Extract packets and events into their own library #2
Comments
@codehz Hello? Is this an acceptable refactor? I dunno is there any plugin using them and how many of them will this break |
Well, chaiscript limit the type must be registered before registering the function, so if I aggregate them into one library, it may be required to load all mods every time.. |
A quick view through the modloader's code shows that the problem of loading a mod multiple times does not exists,every .so gets loaded only once. PS: It might surprise you but the libraries doesnt seems to work with the rewritten version of mcpelauncher,which launcher pairs with this library? |
@johnbanq I means if you only want to use chai_packets , but it reference a class that registered in chai_events so they all need to be added to the mods/ folder |
oh,then the need of extraction is gone,but can we at least pack event handler functions into namespaces? |
Eg: onPlayerJoined -> event.onPlayerJoined |
@johnbanq TIP: namespace does not support function overloadding. |
but do we need them now? Any instance we have in the current version would require overloading? |
maybe we can get around with this on the C++ side by dispatches? |
TIP2: Namespace does not support nested |
I think using global object as namespace is a better idea( |
TIP3: Namespace cannot be extended in future, you can only define the entries at once |
um... using global objects? well,I guess I will have to give up the idea of organizing functions by namespaces |
does global object supports nesting? |
struct Events {
};
Events e;
chai.add(user_type<Events>(), "Events");
chai.add_global(var(e), "events");
chai.add(fun([](Events e, function<void(Actor)> actor) { ... }), "onActorDied"); produce |
struct PlayerEvents {};
struct Events {PlayerEvents playerEvents;};
Events e;
chai.add(user_type<Events>(), "Events");
chai.add(user_type<PlayerEvents>(), "PlayerEvents");
chai.add_global(var(e), "events");
chai.add(fun(&Events::playerEvents), "player");
chai.add(fun([](PlayerEvents e, function<void(Player)> player) { ... }), "onDied"); events.player.onDied(fun(Player player){}) I think it is the right way to play with chaiscript's type system |
And I will not change the c++ source structure, but may be use the new style( global variable as namespace) |
I guess we cant modify the source strucure without making the entire library monolithic(is it possible to adjust the organization of the codebase after merging?) will go with the global object style,thx! |
We now have like 10 mods in this repo,and stuff like packet sending & handling,player & world events are just basically lying around in modules that uses them,so why not aggregate them into a single library?
like chai_packets & chai_events.
This allows us to add things easier and know where to look for what we need
Pros
Cons
PS: if this got accepted,what about packing modules into namespaces on the chaiscript side?
from onPlayerJoined to events.player.onJoined
from sendTextPacket to packets.sendTextPacket (or just packets.send with a overload)
PSS: This is more like a asking for permission than asking for change,because I thought I should ask before working on changes that breaks the API :)
The text was updated successfully, but these errors were encountered: