78482 Commits

Author SHA1 Message Date
Celtic Minstrel
f8f49102fa Add wesnoth.map.get_label 2021-02-28 18:16:31 -05:00
Celtic Minstrel
90e6db0330 Rename two functions for consistency of terminology 2021-02-28 18:16:31 -05:00
Celtic Minstrel
7e1414e249 Rename existing map functions in the map generation kernel 2021-02-28 18:16:31 -05:00
Celtic Minstrel
2d5ea6312e Move various functions into the map module 2021-02-28 18:16:31 -05:00
Celtic Minstrel
e6efc7de6c Refactor the game map to permit exposing it to Lua via wesnoth.current.map
The method of accessing terrain on the map has drastically changed.
- wesnoth.get_terrain and wesnoth.set_terrain are both deprecated
- wesnoth.terrain_mask still works but is moved into the wesnoth.map module and now takes the map object as the first parameter
- The map's terrain is now accessed exclusively via indexing on the map object, ie map[{x,y}]
- You set terrain by assigning a terrain code; the position of ^ in the terrain code now determines the merge mode
- The replace_if_failed option is now manifested as a function that converts any terrain code into a special value that, when assigned to a location on the map, uses the replace if failed logic.

The map object has a few attributes in it:
- width and height are the total size, including borders
- playable_width and playable_height are the values returned from wesnoth.get_map_size, which is now deprecated
- border_size is the third value from wesnoth.get_map_size
- data converts the map to a string
- Special locations are now part of the map object. The length operator is deprecated.
- other than that, wesnoth.map is treated as if it were the metatable of the map object
2021-02-28 18:16:30 -05:00
Celtic Minstrel
51cf2621f7 Add a utility function to extract a location from the front of a variadic parameter pack
The purpose of this is to make it easy for functions implemented in Lua to handle locations
in the same way as functions implemented in C++.

The location_set module has been updated to make use of this functionality in its setter functions.

Usage example:

Imagine a function foo with the following signature:

foo(bar : string, home : location, mode : string, target : location, moo : boolean) -> boolean

With the new read_location function it could be implemented as follows:

function foo(...)
	-- First argument goes in bar
	local bar = ...
	-- Read location starting at the second argument
	local home, n = wesnoth.mP.read_location(select(2, ...))
	-- note: n will be 0 if a location wasn't found at that position
	-- This could be an error, or it could be handled as an optional parameter
	-- Next argument after that goes in mode
	local mode = select(n + 2, ...)
	-- Then read a location into target
	local target, m = wesnoth.map.read_location(select(n + 2, ...))
	-- Finally, read a parameter into moo
	local moo = select(m + n + 2, ...)
	-- Do stuff with all these parameters
	return true
end

With that code, all the following invocations of foo work:

foo('a', 'b', true) -- both optional locations omitted
foo('a', 1, 2, 'q', 5, 6, false) -- locations given as separate integer parameters
foo('a', 'm', {1, 7},  true) -- first location omitted, second given as 2-element array
foo('a', some_unit, 'z', {x = 5, y = 10}, false) -- a unit also functions as a location
foo('a', 7, 12, 'q', my_leader, true) -- mixing different forms also works
2021-02-28 18:16:30 -05:00
Celtic Minstrel
dacd5b323e Add some utility functions to help clarify the merge mode being used when assigning terrains 2021-02-28 18:16:30 -05:00
Celtic Minstrel
b075bbf0c1 Fix some typos 2021-02-28 18:16:29 -05:00
mattsc
287530a43f Goto Micro AI: change how avoid_map is taken into account
There were two issues with the previous method:
- ai_helper.get_avoid_map() never returns nil, but at most an empty location set. Thus, the 'else' clause in that conditional was never reached.
- The presence of an [avoid] tag should not prevent the keys ignoring enemies from taking effect. Instead, [avoid] needs to be taken into account for all possible code paths.
2021-02-28 10:22:11 -08:00
mattsc
94bd2ec993 Goto Micro AI: fix possible error when ignoring enemies
The final determination of the hex to move to must take enemies into account, otherwise the MAI might try to move the unit to a hex it cannot actually reach.
2021-02-28 10:15:07 -08:00
mattsc
fd0c00cfb0 Goto Micro AI: fix checks of avoid_enemies key
Numerical values are sometimes transferred from WML to Lua using the string type. This applies, for example, to very small numbers, such as 0.0000000000001. This needs to be taken into account when checking whether avoid_enemies is a number.
2021-02-28 10:11:49 -08:00
Celtic Minstrel
dff7b7d90d fix a compiler warning 2021-02-28 11:53:56 -05:00
Steve Cotton
37bf7f9333 Update the schema for [terrain_mask] 2021-02-28 15:47:00 +01:00
Celtic Minstrel
9e1677612b Add some unit tests for [terrain_mask] 2021-02-27 21:24:47 -05:00
Celtic Minstrel
f473aabe99 Add another note in [test_condition] for a simple case of using [have_location] to verify that a hex has a particular terrain 2021-02-27 21:24:01 -05:00
Celtic Minstrel
3e31fdb7fb Fix [terrain_mask][rule]layer= 2021-02-27 20:20:48 -05:00
Celtic Minstrel
a97a04e2e9 Update [test_condition] to be a little more verbose and make use of newer features 2021-02-27 19:43:42 -05:00
Celtic Minstrel
ef39108f08 Add an option to the test runner to disable batching of tests 2021-02-27 18:58:28 -05:00
Celtic Minstrel
d74b8c3a52 Fix WML test runner crashing if none of the tests are expected to pass 2021-02-27 16:53:49 -05:00
mattsc
f67a5b269e AI retreat_injured CA: fix retreat_enemy_weight use
Only enemy threats are to be multiplied by this factor, not the ally support.
2021-02-27 08:56:14 -08:00
Nils Kneuper
2191911cc1 updated British English translation 2021-02-27 13:19:36 +01:00
Nils Kneuper
bb035ea19d updated Italian translation 2021-02-27 13:18:26 +01:00
Nils Kneuper
0d59bd832b move map overlay for Hungarian to correct location 2021-02-27 13:15:58 +01:00
nemaara
3d49124c1d Add SoF balance to changelog 2021-02-27 05:26:24 -05:00
nemaara
672628aa07 SoF: rebalance patch 2021-02-27 05:25:40 -05:00
Celtic Minstrel
c645856974
Add a Wesnoth MSVC visualization file for config and t_string (#5571)
* Add a Wesnoth natvis file

The change to t_string is just to make the textdomain map visible to the debugger, since it can't see variables with static linkage.

* Update tstring.hpp

* Update tstring.cpp
2021-02-27 01:08:31 -05:00
mattsc
f799269fa1 AI retreat_injured CA: improve retreat location evaluation
This includes several improvements to the retreat hex evaluation:
- Enemy threats are not the dominant rating contribution any more
- Enemy threats are based mostly on HP balance, rather than simply enemy number
- Enemy threat assessment can be modified with the retreat_enemy_weight aspect
- By default, only healing locations are considered as retreat locations, but this can be overridden with the retreat_enemy_weight aspect
2021-02-26 17:03:06 -08:00
mattsc
663a0ef8ec AI retreat_injured CA: fix bug in finding hexes next to healers
The CA was supposed to mark hexes next to healers as potential healing locations, but because of this bug that did not work.
2021-02-26 16:27:43 -08:00
mattsc
fe316aec3a Add new AI aspect retreat_enemy_weight 2021-02-26 13:57:13 -08:00
Pentarctagon
fa53539f37
Rename query output column 2021-02-26 13:59:30 -06:00
mattsc
903e03d68a AI retreat_injured CA: improve retreat threshold calculation
The main problem was that the previous calculation was based on the 'caution' aspect. While that is not technically wrong, caution is also used for other purposes and there are mainline (and presumably UMC) scenarios that use large values for caution. In those cases, units retreated that were barely injured. This, again, might even be desirable for some use cases, but it needs to be decoupled from the other uses of caution. Thus, the new 'retreat_factor' aspect is used now.

In addition, the calculation is now based on a unit's maximum hitpoints, rather than its level.
2021-02-26 06:49:37 -08:00
mattsc
efe5a4d497 Add new AI aspect retreat_factor 2021-02-25 20:25:16 -08:00
Celtic Minstrel
1ff1ada25c Don't refresh addon cache if running without addons
This allows WML unit tests to be successfully run locally even if you have a local addon that does not have an _info.cfg or _server.pbl.
2021-02-24 20:19:13 -05:00
Steve Cotton
c46a2171f2 Improve the Load dialog's UX when there are no save files or corrupted files
Re-add the popup that appears when "Load" is pressed on the title screen if
there are no files, but now check for files from previous versions too.

Improve handling of switching from a version with files to a version without
files, disabling buttons on the load dialog when there are no files in the
current directory. Versions with no files will still be shown in the drop-down.

This adds a todo about the error path at the start of evaluate_summary_string,
this path is reached by creating empty files in the save dir. The dialog's state
is reasonable, so it seemed a low priority and I don't want to introduce new
bugs by refactoring this path now.

Deleting all files now doesn't automatically close the dialog.
2021-02-24 21:18:48 +01:00
Pentarctagon
6c980d12dc Clear the list of scenario content before getting the next list of content.
Otherwise each scenario keeps appending additional and usually duplicate content being sent to the server.
2021-02-23 22:11:22 -06:00
Pentarctagon
387f4ae448 Don't return a replay URL for private games.
The URL wouldn't work anyway.
2021-02-23 22:11:22 -06:00
Charles Dang
cd2dd8dc7f
Merge pull request #5569 from mattsc/fix_addon_test_scenarios
Add [test] to list of tags with add-on id
2021-02-24 08:46:09 +11:00
mattsc
91115ba84e Add [test] to list of tags with add-on id
As of PR #4963, the engine ignores all global tags defined by add-ons that are not active, that is, that are not used in the current game.  Whether an add-on counts as active is determined based on a list of possible tags with add-on ids.  The [test] tag is not included in this list, resulting in test scenarios in add-ons not working any more.
2021-02-23 13:08:37 -08:00
mattsc
14285994f1 Unit tests: add missing macro undefs 2021-02-23 07:28:34 -08:00
Celtic Minstrel
1dca42ca0e
Fix [modify_side]reset_maps=true
I have no idea how this was missed...
2021-02-22 09:52:56 -05:00
Iris Morelle
9a5e33182f wc: Invest UI cleanup pass 1 2021-02-22 00:31:11 -03:00
Iris Morelle
cb53d30799 gui2/label: Add a normal-sized gold label definition 2021-02-22 00:30:28 -03:00
Iris Morelle
4e5eb49a4a wc: WoCopedia UI cleanup pass #1
Still a lot of work left to do, but this initial commit focuses on
bringing the UI layout on par with mainline standards.

Notable remaining layout issues:

 * Training pages don't have a proper caption.

 * The Items page (previously Artifacts, relabeled Items for consistency
   with the rest of the help text) has individual items grow the list
   horizontally out of the page's bounds, resulting in a horizontal
   scrollbar on the item list right now, or one on the whole window if
   anything is done to prevent the former. There is currently no simple
   way to fix this since labels in listboxes and treeviews grow
   unchecked, rendering `wrap = true` moot.

 * The Factions page seems to be designed to display a list of factions
   but this doesn't seem to be used or working right now?

 * The Settings page has some evidence of this having been user-made
   content. We probably want to do away with some of it in mainline.
   Maybe.

 * The Feedback page screams UMC all over. It is also a bit useless
   without gfgtdf around right now...

 * Lots of questionable English or UI language around still.

 * I don't like tree views.
2021-02-22 00:03:47 -03:00
Wedge009
6f571f3e44 Minor edit for grammar/clarity.
[ci skip]
2021-02-22 14:01:48 +11:00
Charles Dang
56364cc03c Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the same command from 9b7b1751fdda.

Excludes:
* lua/
* spirit_po/
* modules/
2021-02-22 12:15:33 +11:00
Eric Gallager
b2baa10f96
Edit Scepter of Fire difficulty (#5524)
* Edit SoF difficulty

apply patches from https://github.com/cooljeanius/wesnoth_mods/tree/master/campaigns/Sceptre_Of_Fire
2021-02-21 18:15:45 -05:00
Celtic Minstrel
b613e09b2a
Squash unused parameter warning 2021-02-21 16:51:37 -05:00
nemaara
80f6db1f0d Add DM rebalance to changelog 2021-02-21 16:40:16 -05:00
nemaara
ed1ad2470b DM: rebalance pass 2021-02-21 16:39:12 -05:00
Celtic Minstrel
3226147630 Add gives_income key to SLF 2021-02-21 13:22:30 -05:00