This commit removes the utility srt_cast() function and replaces its calls,
along with calls to lexical_cast<std::string>() (and its boost variant),
with std::to_string().
In a few cases where the input type isn't compatible with to_string,
lexical_cast<std::string> is still used.
In other cases where lexical_cast was operating on MAKE_ENUM enums, the
call has been replaced with ENUM::enum_to_string, which is faster.
This fixes an assertion failure at exit which was caused by the event
contexts being cleaned up before the dummy display. There is no need
for the dummy display implementation to ever receive events so the
functionality has been extended for it to not join an event context,
resolving the assertion failure.
And related commits.
This reverts commit 545253ec2b117b413e7ef40e06e65d358ce20f77.
This reverts commit 1215f65eb875cc3070e8d087ce699c0a2ff8d8b0.
This reverts commit 11664f4024cb760de7db5fec54661cd14fc05ac8.
This reverts commit e948df3424657c5843b1fb65a1319449bb6311bc.
This reverts commit 3781e7839f29915292a2452c37b08a1e1fce9841.
This commits were reverted to exclude them from wesnoth 1.13.2 release because:
1) We are still unsure about the best name oftthese attributes
2) This breaks multiple campaigns, including LoW and the tutorial.
Feel free to revert this revert after 1.13.2 when thse issues can be solved..
And also other commits that used that function.
This reverts commit 0d8c008018996c8a147051464a51925a265f7983.
This reverts commit 956e5f932259517fd45efa4fcdffa60542a95d45.
This reverts commit 8f35c4bfcfd3b029ef17d3a3626d5c013a8d0a5d.
This reverts commit dcb265ae701d14fecdc66097d7ee26cd05abb080.
This commit just contained too many bugs, including:
1) string_to_color not parsing any input correctly
2) string_to_color segfaulting on some input strings
3) missing backwards compability in [unstore_unit]
renamed set_scontext_local_choice to leave_synced_context and
set_scontext_leave_for_draw to set_scontext_unsynced.
The old names do not fit anymore because set_scontext_leave_for_draw is
also used for wml menu items.
Also simplified the implementation of set_scontext_leave_for_draw.
floating_label is essentially a primitive GUI1 widget, consisting
just of a text label and non-interacting. It's also used for the
map labels displayed in-game iiuc.
This commit splits some of the functionality of the gamemap object
into a new class, the "terrain_type_data" object. This class is
intended to hold a record of known terrains and the terrain code ->
terrain type map. It handles merging in new terrain definitions,
and it is shared between map objects. It is also cached by the game
config manager, so that we only recalculate this data when we
change configs.
There is in fact a *semantic* change going on here, which is that
when a scenario introduces a new terrain type by merging, this gets
added to the global cache. The alternative is to make a copy of the
global cache, only for the this scenario, as soon as we have to
dirty the cache. However since I didn't see any downside to putting
the merged terrains together and carrying them across scenarios,
I opted not to do that here.
The functionality of tracking observers and displaying chat messages
is moved to a manager class, which the gui owns.
The functionality of displaying notifications is similarly moved out
of the game_display and to a private namespace. (Static singleton
pattern seems okay here since there really won't need to be more
than one of these for a single application, it seems.)
This is consistent with the introduction of the UnitPtr class.
fake_units really aren't different from units, the only difference
is their life time / allocation and ownership. Since we are trying
to use reference counting for all units (to make them safe to use
with animations), the fake units need to be managed by a reference
counted pointer also. This is the easiest way to achieve that.
I also remove some odd code the [move_units_fake] handler --
there was explicit code to remove the fake units from the fake
unit manager, but this is redundant as it is the responsibility
of the destructor.
Code Blocks and VC project files are updated, but
Code::Blocks Scons and Xcode are not.
This avoids the casting to superclass, and it's also a bit faster,
in the refactor of the redraw_unit function we cache all the values
from display that we need locally.
It is not called by any other compilation unit, so it's better to
internalize it and avoid being forced to declare SDL surface in
the header if possible etc.
drawable unit inherits from unit, and implements the draw function,
used only by the display. when the display wants to use the function,
it casts a unit pointer to a drawable_unit, and draws it. this
improves encapsulation.
This commit adds two classes -- fake_unit, and fake_unit_manager,
both split off from code contained in game_display. The display
object is reconfigured to hold a pointer to the manager and
display the units it contains. The rest of the code is configured
to add fake units to the manager, not the display.
This improves encapsulation and helps to reduce the game_display
class.
After this commit e4eb0a3ede83ee338994708ebd48257627b47242 the
replay viewer would segfault during prestart events. However, it
turns out that nothing in the replay viewer, or in that commit,
was directly causing the segault. Instead, the display object
was holding dangling pointers for no reason, when it could have.
been simply computing the correct value (very cheaply). We clean
up the code in the display objects to fix the segfault.
game_display and display versions of set_team were identical, in
header and in implementation, so we simply delete the game_display
one, as a strict refactor.
It uses a shared_ptr, to prevent crashes during play_controller
initialization. But it only holds a weak_ptr, to preserve
previous behavior of skipping whiteboard ops when the ptr is
NULL.
It requires also for us to construct the whiteboard before
constructing the gui, so that we have a valid pointer to pass.
Most likely all of the managers will have to be moved forward,
in this commit we move forward the whiteboard and pathfinding
module, anticipating future commits.
Also refactor editor and game_display to use this.
To achieve this it turns out we also have to add a "dummy display
context" unique to the editor code, which it can use to initalize
editor display, because after refactor NULL doesn't cut it
anymore. This appears in src/editor/editor_display.?pp, might
want to branch into its own file later.