37147 Commits

Author SHA1 Message Date
Charles Dang
255b1ad055 GUI2: init more members directly from builders when possible 2024-12-09 02:59:32 -05:00
Charles Dang
e208a4e776 GUI2/Grid: minor private impl cleanup 2024-12-09 02:19:44 -05:00
Charles Dang
3a74825e8d Initial work to handle chat timestamps as time_points 2024-12-09 02:18:52 -05:00
Charles Dang
6d4058d670 GUI2/Unit Recall: properly handle saving last sort order
Small regression from 530cd2b02b1587c26012d07ee2ba0fbea9f0170e
2024-12-09 02:00:49 -05:00
Charles Dang
dd1eb9e964 GUI2/Listbox: make sorter widgets mandatory
Better to have a widget-not-found error than silently doing nothing here.
2024-12-09 01:59:52 -05:00
Charles Dang
f7a271dab9 GUI2/Listbox: adjustments for 7d92a8cb4a6cc195113f42ecaa158a0c3e741906 2024-12-09 01:55:13 -05:00
Charles Dang
7d92a8cb4a GUI2: take find_widget and find ID args as string_view 2024-12-09 01:20:09 -05:00
Charles Dang
530cd2b02b GUI2/Listbox: improve sort option handling
* Re-added the ability to set a single sorter, this time by ID.
* Multi-sorter setting now uses the magic sort_N IDs.
* Cleaned up internal handling to remove reliance on header grid columns.
  Sorters will still be looked for in the header, but rely on the specified ID.
  This did (I'm pretty sure) work before, but now it's explicit.
* The order_pair typedef has been removed
* set_active_sorting_option has been removed set_active_sorter and now takes its arguments separately instead of as a pair.
* set_active_sorter will use the bound sorter header on-modified handler
  instead of calling order_by_column directly
* set_sorting_options has been renamed to set_sorters
* get_active_sorting_option has been renamed get_sorter
2024-12-08 23:04:43 -05:00
Charles Dang
10b640c0f2 GUI2/Listbox: refactor initialization process
Used work by @babaissarkar in #9630 as a base. We're finally using [instance] for something!
2024-12-08 23:04:43 -05:00
Charles Dang
bed8047ee4 GUI2/Tree View: get indentation step size from builder 2024-12-08 23:04:43 -05:00
Charles Dang
2d9cc9c89d GUI2: add a scrollbar_container builder
This unifies handling of the scrollbar modes without having to manually set them in the builders. At one point, this wasn't too common, but it's become common enough that having a separate builder is cleaner
2024-12-08 23:04:43 -05:00
gfgtdf
5801b5bcdb
use to/from_chars in attribute_value and lexical_cast (#8790)
This makes attribute_value and lexical_cast use the "new" to/from_chars api.

Its main advantages are:
- It's guaranteed to be locale independent, hopefully fixing all cases of #3945 and similar
- It fixes some cases config serialization, in particular the test
```
	cfg["x"] = "9.87654321";
	BOOST_CHECK_EQUAL(cfg["x"], 9.87654321);
```
- Previously the lexical_cast implementation used exception
  handling for invalid formats (catching std::invalid_argument)
  which made noise during debugging (and is also slower if it
  is not optimized out).
- It's faster

So far afaik the only compiler which has a complete and proper to/from_chars implementation is msvc, gccs implementation of from_chars sometimes uses strtod under the hood and clang simply hasn't implemented from_chars for floating point numbers yet at all (actually the upcomig clang 20 will have it). Luckily for us, there is now also boost::charconv that can be used. So this raises to minimum build requirement to have at least one of:

- msvc 2019 update 5
- gcc 11
- clang 14 (i have added a fallback implementation of from_chars for this case, that doesn't support all of its features, and is probably certainly not as fast as the boost version, but supports the features that we use from it)
- boost 1.85
 
Since in particular the gcc implementation isn't that good (at least it on gcc11), boost charconv is the preferred implementation that is used if available.

This also removes a strange overload for
pointers to integers in lexical_cast while changing lexical_cast to use the new api.
2024-12-08 22:28:10 +01:00
Tóth Kornél
ad563d99e9
Map editor segmentation fault fix (#9564)
Fixed map editor crashing when creating or opening scenario after played local scenario before opening map editor. Resolves #9563. The cause of the bug was that the ai manager singleton pointer was not set to nullptr after it was destructed. Fixed this by making ai manager destructor set singleton to nullptr. Before this the ai_map_ map member has to be cleared in destructor because it might try to access the singleton when destructed.

---------

Co-authored-by: SomeName42 <>
2024-12-06 14:39:47 -06:00
JJ Marr
2e520d03a5 Remove incorrect moves
These were added by clang-tidy's autofix, which both tried to convert
the parameters to const references and std::move them. The correct
behaviour is to convert only to a const reference.
2024-12-06 02:15:13 -05:00
Charles Dang
e0bda68b80 Revert "listbox: simplify builder"
This reverts commit c38b856a826b9c16926ab0be92f007021d1544a1.
2024-12-06 00:43:39 -05:00
Subhraman Sarkar
c38b856a82 listbox: simplify builder 2024-12-06 11:09:47 +05:30
Subhraman Sarkar
20242ffc84 styled widget: use std::move 2024-12-06 10:31:50 +05:30
Charles Dang
5175beb1e7
GUI2/Listbox: allow setting all sorters at once (#9629) 2024-12-05 22:45:52 -05:00
Charles Dang
c4f7523e00 GUI2/Listbox: unify registration of sorting options
Instead of two functions for translatable and non-translatable options, comparison will be determined by the return value of the sorter. Existing translatable sorting options have been adjusted to return t_string rather than string.
2024-12-04 21:46:39 -05:00
Yoruma
5a10721637
Add a red line to the bottom of lobby chat to help distinguish old messages 2024-12-03 16:10:25 +01:00
Subhraman Sarkar
482c2817f9 fix clang-tidy warnings 2024-12-03 20:35:25 +05:30
JJ Marr
92e91e4c0e Match modal_dialog::register_integer to header
For whatever reason, callback_save_value had type
std::function<void(int)> in the .cpp file but
std::function<void(const int)> in the header file. This reconciles them
to both take in an integer as a parameter.
2024-12-01 23:19:53 -05:00
JJ Marr
ecd273914c NOLINT exception to const reference rules
Specifically, this function is intended to cause a runtime error when a
pointer to an incorrect type is passed in.
2024-12-01 23:19:53 -05:00
JJ Marr
6999b294d5 Use std::move wherever possible 2024-12-01 23:19:53 -05:00
JJ Marr
fe5296aefd Make every possible param a const reference
This is important for performance. If a parameter doesn't have to be
modified, it should be a constant reference to the original.
2024-12-01 23:19:53 -05:00
Charles Dang
0ed106c4e2 wesnothd: format logged-in time directly
This was the last use of lg::format_timespan, which was only ever used in server code anyway. The server probably shouldn't be formatting this anyway, but as long as it is, we don't need a dedicated function or fancy formatting.
2024-12-01 21:42:04 -05:00
Charles Dang
a25d28e637 Game Events: removed an unnecessary getter
Bad design to return mutable reference to static object. This method has the possibility of creating a new default entry in the by_name map, but the remove call will be a no-op in that case (as it was before), so no harm done.
2024-12-01 17:23:27 -05:00
Charles Dang
20e61d67ff server_base: remove orphaned function declarations
Left over from  e7a4869c4a5cfe870de79880cb29b68b29994b2c
2024-12-01 13:21:57 -05:00
gfgtdf
ba5c1c1ac1 Fix #7478 game crash after reloading a mp game in debug mode (#8907)
previously the game would return to titlescreen here if mp_info_
but was null but
`game_config::debug && state_.classification().is_multiplayer()`
returned true which happend when a multiplayer game was reloaded
via the sp loadgame dialog.

This fixes the issue by simply removing the "always show mp staging
between scenarios in debug mode" feature, which imo never was that
useful anyways.
2024-11-30 22:49:32 +01:00
gfgtdf
c08152a0e7 Don't store duplicate current side num in savefiles
This not only removes duplicate information which can always cause bugs if it's out of sync,
this can also be used an an easy way to detect the old undo stack format
2024-11-30 22:45:32 +01:00
gfgtdf
8a91549fe8 fix possible crash in undo events 2024-11-30 22:45:32 +01:00
gfgtdf
73c14e0d2b fix possible crash in capture events
its not safe to keep a reference to the owner_side variable
since the event might remove it, which could lead to a crash
when atempting to set it
2024-11-30 22:45:32 +01:00
gfgtdf
a5dae832c8 small cleanup
thereis no need for if(s_c::undo_blocked()) { s_c::block_undo(); } since it automaticially happens at the end of every action already
2024-11-30 22:45:32 +01:00
gfgtdf
7c41d550a9 split undoing of moves into small steps
this way even when enter/exit_hex events with [on_undo] are involved, undoing happens
in reverse order of the gamestate changes during the original action
2024-11-30 22:45:32 +01:00
gfgtdf
4dc69c5267 split villagecapture into seperate undo action
this wayits possibel to undo the action exactly in the reverse order
as they are a happening on the original code, even with wml events involved
2024-11-30 22:45:32 +01:00
gfgtdf
8350f48c88 Refactor undo stack
This commit splits undo actions into multiple smaller steps. The main advantages:
- Its allows us always undo the parts of an action in the reverse order of which
  they originally happen, preventing bugs that could be caused if the parts
  interact with each other in a way where the order matters (like for example
  an [on_undo] resetting a units moves, when the event happend in a move action
  which would then also reset the units moves on undoing).
- It's easier to add (c++) undo steps for specific steps even if they are used
  from wml, like spending gold.
- [do_command] no longer confused the undo stack (in fact it's by default now undoable).
- All actions are put onto the undo stack in the same way, previously it was
  often unclear whether the undo stack is empty during a specific step  during
  the execution of an action, in particular when people tried to use
  `undo_stack->empty()` to check whether an action could still be undone.
2024-11-30 22:45:32 +01:00
gfgtdf
d8086942df small cleanup 2024-11-30 22:45:32 +01:00
JJ Marr
3b8ceb00f0 Replace NULL with nullptr in the codebase 2024-11-30 13:24:45 +01:00
JJ Marr
d8d92b5d28 Add clang-tidy support to cmake
Also, enables it in CI.
2024-11-30 13:24:45 +01:00
JJ Marr
1cf3fed50f Refactor module compilation into separate library
This allows us to disable clang-tidy for this folder.
2024-11-30 13:24:45 +01:00
Charles Dang
653333a8bf Restore space after log timestamps 2024-11-28 22:14:06 -05:00
Charles Dang
4ccfca6b1d Game Display: check for teams before refreshing reports (fixes #9609)
Regression from 7fa4fe483c755da3aea731da9667cb03f7598fb9
2024-11-28 22:13:43 -05:00
Charles Dang
2c216eec72
Refactor utils::format_timespan to use chrono types (#9610)
This also adjusts the periods for years and months. Previously, we were using values of 30 days for a month and 12 months for year. Now, we use the chrono values of a month as 1/12 of a year and a year as 365.2425 days.
2024-11-28 22:07:52 -05:00
Subhraman Sarkar
2477618306 rich label: support specifying text color, font and style in resolution
This allows the rich_label definitions in rich_label_default to work.
2024-11-28 23:04:05 +05:30
Subhraman Sarkar
2e0f8c453e lua_widget_attributes: use existing functions in gui/widgets/helper.cpp 2024-11-28 11:57:21 +05:30
Charles Dang
98f0d3721c wesnothd: convert stray member to seconds 2024-11-27 18:58:28 -05:00
pentarctagon
7183553e23 1.19.6+dev 2024-11-26 12:17:36 -06:00
pentarctagon
99469ba31d 1.19.6 2024-11-26 12:16:03 -06:00
Charles Dang
0f8d9a9940
wesnothd: handle server IP bans more generically (#9602)
Instead of simply returning a string, `is_ip_banned` now returns a struct with an error code, ban reason, and ban time remaining. This avoids doing time duration formatting on the server and allows the error message to be localized on the client. It also makes the ban handling interface more generic in server_base, which should hopefully allow forum bans to be handled this way as well.
2024-11-26 09:13:57 -05:00
Subhraman Sarkar
c475b0c684 add a command line option to preprocess a string 2024-11-24 16:51:12 +01:00