Hi,

during my refactoring i changed a _lot_ of things, especially for
playlevel.cpp and playturn.cpp. I will set up a wiki page explaining what i
did and how things are supposed to fit together. That might take a while,
though. This mail is for those, who need some quick information covering the
most important changes.

playlevel.cpp is - gone!
Well, not gone completely of course but the file is no longer there. What
was in it can now be found within 3 classes: play_controller,
playsingle_controller and playmp_controller. play_controller provides the
basic architecture of play_level. I splitted a lot of things to make that
one huge method a little more handy. You will for example find methods like
play_turn, play_side, init_side, init_gui, finish_turn etc. The beginning of
the old play_level function was all about initialization, this mostly went
into the constructors of play_controller and its internal objects. However,
play_controller is just the basis for "real classes", it is not meant to be
instantiated. It provides a lot of virtual functions that can be overriden
in classes that inherit from it. Those classes are at the moment:
replay_controller, playsingle_controller and playmp_controller (which does
not inherit from play_controller directly but from playsingle_controller
instead). replay_controller adds some statements specific for replays,
playsingle_controller handles the human gameplay interaction and
playmp_controller adds all the network communication stuff.

playturn.cpp is - well, not gone but almost.
The only thing that is left there is some network functions like send_data
and process_network_data etc. I would like to move them to playmp_controller
but that needs some preparation first because they are tied together with
other code like in ai.cpp so this is far from being a no-brainer. The rest
that was in playturn.cpp moved to various places:
- The event-handling stuff (can_execute_command, handle_event ...) is to be
found in the controller classes, mostly in play_controller and
playsingle_controller.
- The menu commands (and those commands that are initiated by hotkeys) are
mostly within menu_events.cpp. A corresponding object is built whenever
play_controller is instantiated (see its constructor).
- The mouse actions (mouse_press, left_click and the like) is within
mouse_events.cpp together with some functions that are exclusively called
from them. A corresponding object is built at instantiating play_controller
as well (see the constructor of play_controller again).
- All the floating_textbox stuff moved into its own class. Just the handling
of the gui elements, not executing the commands of it.

Two more things:
- If you add functionality to the controllers, please consider where to put
it best. If it can be used everywhere, put it in play_controller. If it
needs human gameplay interaction but no networking, put it in
playsingle_controller etc. Feel free to make methods of play_controller
virtual if needed. I have only done that for the ones that are necessary at
the moment.
- I am not satisfied with mouse_events.cpp and menu_events.cpp yet. They
need too much communication between them and i wanted to keep them separate
completely. There is also some methods in mouse_events (like attack_enemy)
that i think don't belong there. But i can't do everything at once.
Enhancing this will have to be delayed to future work.

Hope that makes you have a smooth dive into the code.

Greetings

Yogi


_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev

Reply via email to