478 Commits

Author SHA1 Message Date
shijie.chen
d88ddec6f1
Remove unnecessary header files (#8531)
Co-authored-by: shijie.chen <shijie.chen@goland.cn>
2024-03-12 00:07:48 -04:00
Charles Dang
3cbe0dcdcc Make Ubuntu happy 2024-01-29 22:32:05 -05:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Pentarctagon
10997c39a3
Start giving the editor add-on level functionality. (#7719)
The key word of course being "start". This PR changes the editor by default to work at the add-on level instead of in its own separate scenarios and maps directories. The goal is to make the editor more useful generally, but also specifically to make it much easier for players to distribute content they create using the editor:
* When they click the Editor button on the main menu, they will first be prompted to choose an add-on (or mainline), or to create a new add-on.
* When saved, if the scenario cfg is in the format previously generated by the editor, it will be converted to the new format and to use the [multiplayer] tag, the map_file attribute, and have the map data saved to a separate .map file.
* Relatedly, the editor now knows how to handle scenarios with the map_file attribute at all (which yes, does mean that currently wesnoth's editor doesn't know how to load its own mainline scenarios from their cfg).
* When opening the file chooser dialog, it now defaults to their selected add-on's directory.

If they choose to create a new add-on, then the editor creates for them:
* a basic but functional _main.cfg.
* an empty achievements.cfg (at this point mostly just so they might see it at some point and realize achievements exist, but ideally an achievements editor dialog could be created eventually).
* an empty _server.pbl file.
* a proper add-on directory structure containing the standard set of folders (maps/, scenarios/, units/, utils/, images/, etc).

Additionally, as an initial proof of concept for actually using this new add-on level functionality, a new Add-ons dropdown has been added to the editor's top bar, with a pbl editor option. This allows populating the blank _server.pbl file as well as editing an existing _server.pbl. There is also an option to change the add-on's ID, which will update the add-on's folder name and _main.cfg.

Misc other changes:
* The ability to add a recruit list to a side has been added back as a text box on the edit side dialog. While admittedly this doesn't allow players to select units from within the editor itself, it does set the actual side's recruit list (rather than a specific unit's extra_recruits), will show the user what the current recruit list for the side is (which the previously removed implementation didn't show anywhere), and correctly sets the faction as Custom so that the recruit list is used.
* When saving an old-style editor scenario, everything that can be triggered via [event] is either moved to a start event with a specific id attribute. Exceptions to this are [time], [side], and [side][village]. This is done so that the editor can know (for the most part) what things are actually its own to safely replace. As such, aside from the three previously mentioned tags plus the start event, any other WML added to a scenario by a UMC author is preserved rather than being overwritten - the editor no longer replaces the entire contents of the scenario file.
* The editor no longer writes out cfg files missing the top level scenario tag. If it doesn't find one or this is the first save of a new scenario it defaults to [multiplayer], but otherwise it will properly handle finding [test] or [scenario] as well.
* Requires that map files have the .map extension and scenario files have the .cfg extension. Also it assumes that .map files do actually only have map data in them and the .cfg files do actually have valid WML in them. I understand that this is not a limitation it had previously, but I don't think this is an unreasonable thing to require.
* Addresses part of #7667 by just not using regex for figuring out the map_data attribute value.

Additionally, it is not possible to change the currently selected add-on without going back to the main menu, clicking the editor button, and choosing a different add-on. This is intentional - I don't want to deal with having multiple add-ons open at the same time. If someone feels really strongly otherwise, then they can implement that themselves later.
2023-07-19 15:00:14 -05:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
gfgtdf
f8bd32eb15 Deploy and refactor config::optional_child
Previously the config class had an operator bool and
it was a common pattern to use if(const config& = cfg.child(..)).
While this pattern was nice to use. It has severe drawbacks, in
particular it was unclear whether a function that took a config&
parameter allowed "invalid" configs, while most functions
did not, there were some that did. Furtheremore it lead to a few
buggy codes that were unconvered by this change (Not fixed though!),
in particular codes that tested local config objects that were
not references to being invalid, which could never be the case.
This commits replaces those with just `true` in order to not
change behaviour.

Some obvious cases were also removed including for example
things like `assert(config());` There is ony case in the ai code
that i'm not 100% sure of where one implementation of a virtual
function checked for an invalid config and another one that didn't.

With this, all code that check for a config child to be
present now uses config::optional_child which returns an object
that behaves similar to optional<(const) config&>, so it throws
on invalid dereferencing. But it also has operator[string] for
convinience, in particular to make is similary
easy to use the the previous `if (config& = .. child())`.
Also it has a tool DEBUG_CONFIG which tests whether all
optional_config values are checked before they are derefereneced.

Another method manditory_child was
added that throws when the key is not found, which replaces all
occurances of child() that did not check whether the result was
valid. This was neccecary (this= adding a new method instead of
renaming .child) to keep track of converted changes, and be sure
no occurances of child() were accidentally changed to the
throwing version.

We might want to rename one of mandatory_child or optional_child
to just child later. Not sure which one yet. I think it's better
to keep it in the current state (no config::child() ) for a while
though, so that people that currently used child() in their open
prs or other work get an error and not wrongly rely on the previous
behviour of config::child.

The interface of vconfig was not changed in this commit.
2023-04-03 00:39:12 +02:00
Tommy
c2ab49b887 Catch a few more missed logging newlines
Mostly with a space before the trailing newline.
2022-07-20 15:20:57 +12:00
Tommy
ba24612f73 Remove trailing newlines from multiline log messages 2022-07-20 15:20:57 +12:00
Tommy
a02709e0ff Remove \n from log lines with it as suffix on the final string 2022-07-20 15:20:57 +12:00
Tommy
1c25ebdfa2 Remove std::endl from log lines, now that it's added automatically 2022-07-20 15:20:57 +12:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
c4c292fa3b Replace all remaining usages if MAKE_ENUM. 2022-03-03 21:23:02 -06:00
Pentarctagon
f4e4bf6b49 Fix existing code that was relying on implicit string conversion. 2022-03-03 21:23:02 -06:00
Pentarctagon
263e9d7d4f Replace MAKE_ENUM of CONTROLLER with something easier to use.
CONTROLLER is now defined in a single small header that can be easily read without needing to look through a bunch of Boost macros to figure out how it all works. Using the string values of the enum is now also much simpler since they're just constants of the side_controller class.
2022-01-25 16:57:29 -06:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Celtic Minstrel
96b5bf43ef Move shroud/fog ops to wesnoth.sides and change the API somewhat
- place_shroud and remove_shroud no longer accept a shroud data string or the special string "all"
- new functions are added to convert between lists of locations and shroud data strings
- place_fog, remove_fog, is_fogged, and is_shrouded aren't changed, only moved
2021-06-19 11:07:53 -04:00
Charles Dang
0c2134a645 Further boost cleanup
* Removed more unnecessary includes
* Used std::swap instead of boost::swap in fake_unit_ptr. This is since unit_ptr (the type of `unit_` here)
  is now just a shared_ptr instead of a boost::intrusive_ptr.
* Used std::gcd instead of boost::integer::gcd
2021-01-23 23:46:20 +11:00
Pentarctagon
4c2b725ec0 Change all doxygen comments to the same format. 2020-12-31 23:59:28 -06:00
gfgtdf
f4836a699e
fix warning invaldi attribute 'previous_recruits'
fixes #3081
2020-03-20 18:41:32 +01:00
gfgtdf
873752943f fix [modify_side] controller=ai for the current side 2019-10-05 16:27:04 +02:00
josteph
9c7d5986c1 Clarify a po comment for #4366. 2019-09-27 17:01:47 +00:00
josteph
1dccd57b43 Side color tooltip: Use typographical quotes. 2019-09-26 18:37:43 +00:00
josteph
ad0867fa42 Add color names to the Status Table, sidebar and top bar
For colorblind MP players

Fixes #1217
2019-09-26 15:58:02 +00:00
gfgtdf
01581d0218 small team.cpp cleanup 2018-11-13 13:28:29 +01:00
gfgtdf
e4c170f249 fix villages after terrain_mask
(cherry-picked from commit 6cd9de1202d1f4f90d56ba9b7950aecfc1e5f3f4)
2018-10-07 03:24:14 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Charles Dang
19e3afb463 Convert C-style casts to static_cast
(cherry-picked from commit 0dc5656c328cdd02eebb4dbd10dbab3eb4553b57)
2018-10-07 03:21:02 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f6935176b70a035d3e1c03080f79687f94)
2018-10-07 03:17:59 +00:00
Charles Dang
4ba33d464e Cleaned up text rendering-related includes 2018-03-11 21:46:21 +11:00
Charles Dang
a3a9697d14 Cleaned up unnecessary inclusion of formula/string_utils.hpp
These were either not needed, or serialization/string_utils.hpp was desired instead.
2018-03-03 20:22:17 +11:00
Charles Dang
286415a403 Revert "Team: save user_team_name as serialized"
This reverts commit 3496b1a6054a765e4f6b5a88af29649ce718dc42. Damn thing crashed.
2018-02-11 19:10:28 +11:00
Charles Dang
3496b1a605 Team: save user_team_name as serialized
Hopefully this will fix issues in Game Stats where the teamname was displayed as "teamname^South",
for example. I think the reason it appears that way has to do with translatable strings not being
transmitted properly...

This is the same method used in connect_engine.
2018-02-11 15:49:20 +11:00
Charles Dang
1478f21a77 Added ai::manager::has_manager function
Better than the hack we had before.
2018-02-04 01:34:33 +11:00
Charles Dang
d11b62590f Fixup 3dc8617ec9396 (fixes #2398)
See doc comment.
2018-01-26 09:57:29 +11:00
Charles Dang
3dc8617ec9 Fixup c8b0833 (crash when creating scenario in Editor)
There's no AI manager in the editor (a game state is required), nor a need for one, so I simply
disabled the AI initialization if we're not in the editor.
2018-01-24 16:12:57 +11:00
Jyrki Vesterinen
c8b0833b1a Make AI manager a singleton
Fixes #2372.

It turned out that the AI kept dangling references to the old Lua state,
and crashed while destroying AI contexts for destroyed sides.

The best way to avoid it is to ensure that game_state, which already owns
the Lua state, also owns the AI. That way, the AI will be destroyed before
the Lua state and a dangling reference can't stay.
2018-01-24 14:29:01 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
dbf2847a44 Fixup ff5d68f (fixes #2125)
Also contains a minor fixup of db8891fa3c03 (sign type mismatch warning fix).

For some reason, the use of the side-1 fallback in the to_unsigned() calls was making every
side get assigned the color red... Sadly, this means an saved games created in the past 12
hours or so have broken color data. Oh well.
2017-10-26 21:30:12 +11:00
Charles Dang
db8891fa3c Fixup f878433
Issue pointed out by @jyrkive. The new loop would skip any character identical to the first
one instead of only skipping the first one.
2017-10-26 20:35:47 +11:00
Charles Dang
b0f9086524 Removed a debugging aid accidentally committed in ff5d68f
[ci skip]
2017-10-26 10:14:33 +11:00
Charles Dang
ff5d68f9f5 Some refactoring of team color data handling
These changes cover areas from PR #2101, excluding the removal of the numeric ID color ranges.
That can't be done yet (it breaks things).

This also excludes any changes to the connect_engine color handling. That needs to be refactored
separately. Despite the fact that it's done very similar to the new get_side_color_id function,
I need to deal with the fact that every side_engine member in the connect engine keeps a copy of
the default color options.

* Added a general-purpose function to extract color data from a config.
* Refactored the team class's general get-side's-color-data function so it always returns a color
  ID instead of falling back on a number.
* Deployed this change for the leader image coloring in the save_index; said coloring is now always
  done by ID.
* Save color data by ID in team_info instead of using the side number if no color was provided.
* Renamed get_side_color_index to get_side_color_id to better reflect its purpose.
2017-10-26 09:27:50 +11:00
Charles Dang
f878433847 Team: range-for 2017-10-26 04:40:04 +11:00
Charles Dang
d587ad36ec Team: formatting cleanup 2017-10-26 04:40:03 +11:00
Charles Dang
3bca7078ef Team: added faction_lock and leader_lock to list of allowed [side] keys
Dunno why these were excluded...
2017-10-10 12:01:38 +11:00
Charles Dang
2d7857c59b Team: reformatted list of allowed [side] keys
[ci skip]
2017-10-10 12:00:29 +11:00
gfgtdf
821e27c34f add [cancel_action] implements #1427
this adds a new tag [cancel_action], it currently only has an effect in
move actions. It can be used in enter_hex/exit_hex events to abort the
current movement. It can also be used in moveto events where is
cancels possible following attacks (if the user issued a move+attack
action).

This also changes the behaviour of moveto and enter/exit_hex event so
that they now no longer cancel the movement automatically, also
[allow_undo] no longer has an effect on whether the move is cancelled,
it now only allows undoing of the move.
2017-07-25 21:19:05 +02:00
Celtic Minstrel
96ca0b026e Replace config_of with new variadic config constructor 2017-05-21 16:27:46 -04:00
Charles Dang
79ffbbe9b4 Game Events: include manager in pump header to avoid having its include in so many places 2017-05-21 07:52:42 +11:00
Charles Dang
e4f03fe459 Moved all preferences source files into a single folder 2017-05-04 11:04:19 +11:00