Commit graph

108 commits

Author SHA1 Message Date
Celtic Minstrel
c143dfdfeb Fix shallow_literal/shallow_parsed not returning named tuples for the WML tags 2024-02-04 16:23:25 -05:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Celtic Minstrel
c44bd5a3a4 luaW_toconfig should clear its output argument
Every place it's called already passes a default-constructed config, so this won't affect any existing code.

The removed assert is pointless when it'll be cleared by the call, and the two places that called that function also passed a default-constructed config already, so it was doing nothing.
2022-07-26 00:01:14 -04: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
1fe87c4e24 Remove "<< '\n';" from log lines 2022-07-20 15:20:57 +12:00
Tommy
6ace55e063 Remove << "\n"; from log lines 2022-07-20 15:20:57 +12:00
Celtic Minstrel
de080ad368 Misc dir() support
- Named tuples
- Version
- vconfig
2022-06-20 20:54:28 -04:00
Pentarctagon
1a3498cbf3 Rename nowarn/ to lua/
Also cleanup the includes.
2022-03-09 15:01:37 -06:00
Pentarctagon
dd947db289 Avoid lua build warning without altering source code. 2022-03-09 15:01:37 -06:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -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
Pentarctagon
8e2996661f
Prevents logging of duplicate deprecation messages and messages missing timestamps.
Fixes #5942
2021-07-24 18:51:42 -05:00
Celtic Minstrel
1e42f80c13 Lua API: Use the named tuple idiom for WML tags
Instead of this:

for i,t in ipairs(cfg) do
  if t[1] == 'foo' then
    do_something(t[2])
  end
end

You can now write this:

for i,t in ipairs(cfg) do
  if t.tag == 'foo' then
    do_something(t.value)
  end
end
2021-07-07 01:32:05 -04:00
Celtic Minstrel
d04bd2bf5d Lua API: Add a named tuple idiom, used mainly for locations
This should fix the issue introduced in 5a9c24c4e7

I also spotted a couple more cases missed in the prior commit.
2021-07-02 14:04:54 -04:00
Celtic Minstrel
e555e0681d Fix a bunch of compiler warnings
- Some implicit conversions
- Loop variable is always copied
- Missing prototypes
- Unused lambda captures
- Comma operators
2021-07-01 01:33:28 -04:00
Celtic Minstrel
5a9c24c4e7 Updated a few places that didn't handle locations in the unified way 2021-07-01 01:33:28 -04:00
Celtic Minstrel
21a54e4bd0 Fix shroud parsing functions
Addresses #5885
2021-06-23 09:49:27 -04:00
Celtic Minstrel
a03d59d7eb Lua: Add a new schedule module
The primary components of this are:
- wesnoth.current.schedule
- wesnoth.map.get_time_area()
- wesnoth.schedule module
2021-06-19 11:07:53 -04:00
Celtic Minstrel
b613e09b2a
Squash unused parameter warning 2021-02-21 16:51:37 -05:00
Celtic Minstrel
8beb7b08fb Add optional uservalues count to custom Lua new operator 2021-02-21 13:15:37 -05:00
Charles Dang
561cc33dc4
Upgrade to Lua 5.4.2 (#5535)
The change to static_cast for the definition of  LUAL_BUFFERSIZE replaces the fix previously used (d0100758f8) for Lua 5.3. 5.4 removes the static alternative for LUAL_BUFFERSIZE. A better solution would probably be to disable the old-style-cast warning for luaconf.h, but I can't figure out how to do that so using static_cast is the easiest solution. Do note that change will have to be applied each Lua update like the aforementioned commit.
2021-02-14 02:07:12 +11:00
Charles Dang
5df29bf9e6 Used [[fallthrough]] directly 2021-01-23 18:26:48 +11:00
Charles Dang
c5b1fa9dfd Converted uses of utils::string_view to std::string_view 2021-01-22 11:51:53 +11:00
Charles Dang
e31b327a90 Converted config_attribute_value to use utils::variant
All visitors that are used with apply_visitor have had their boost::static_visitor inheritance
made conditional as well.
2021-01-20 14:23:46 +11:00
Charles Dang
6b89bf86a7 Removed trailing tabs and whitespaces from C++ source
[ci skip]

I ran the same command from 9b7b1751fd.

Excludes:
* lua/
* spirit_po/
2020-10-09 14:14:38 +11:00
Celtic Minstrel
30240aa7cd For consistency, rename tstr:format -> tstr:vformat, and add tstr:format as an alias to string.format
In order for the latter to work, string.format was overridden as follows (but implemented in the C API):

local old_format = string.format
function string.format(str, ...)
	if type(str) == 'userdata' and getmetatable(str) == 'translatable string' then str = tostring(str) end
	return old_format(str, ...)
end
2019-12-04 22:28:14 -05:00
Celtic Minstrel
7ee7d6d47c Lua: More stuff for the stringx module
- Move format_conjunct_list and format_disjunct_list
- Move wesnoth.format (renamed to vformat so as not to conflict with string.format); it's also available as tstr:format()
- Add stringx.trim
- The convenience wrappers of stringx.split now set the remove_empty and strip_space flags
2019-12-04 00:45:36 -05:00
Celtic Minstrel
aa5ac6af29 Add stringx module that exposes Wesnoth's split/join functions to Lua
The built-in string module is set as the metatable index for the stringx module, and the stringx module is set as the metatable index for strings, meaning all string and stringx methods are available through (''):method_name.

This also enables direct indexing of strings to get individual characters (ie ('str')[1] and the like), which package.lua already assumed even though it didn't work. Negative indices are supported to, and index from the end of the srring.

New functions:
- stringx.split
- stringx.parenthetical_split
- stringx.map_split
- stringx.escaped_split
- stringx.quoted_split
- stringx.anim_split
- stringx.join
- stringx.join_map
2019-12-01 20:25:13 -05:00
Celtic Minstrel
86f66a5825 Lua: Add a few more useful functions to the WML module and make WML table conversion a little more robust
- New functions: wml.find_child, wml.attribute_count, wml.equal, wml.valid
- When converting a Lua table to WML, the engine will no longer accept invalid attributes
- Use of wml.tovconfig in plugin or map generation scripts is deprecated (it already doesn't quite work properly in those contexts but still could've been used as a way to test a table's validity as WML)
2019-12-01 20:25:13 -05:00
Celtic Minstrel
61d0da9c84 Add __tostring metamethods to textdomains, races, unit types, weapons, and sides 2019-11-17 14:23:59 -05:00
Jyrki Vesterinen
81d0d2214a Lua API: Allow WML tags with leading underscore (#3877)
@gfgtdf said that it's more consistent to allow them across the board,
which IMHO is a strong enough argument for the API change in master.
2019-01-19 15:02:10 +02:00
Jyrki Vesterinen
cb2a236dbf Allow WML tags with leading underscore (#3877)
@gfgtdf pointed out that the WML parser can deal with such tags after all.
I had missed that when I implemented the check that the game state is
valid WML before saving it (commit 3bc36efa58).

Such tags are still disallowed in the Lua API because allowing them would
be an API change.
2019-01-18 22:15:20 +02:00
gfgtdf
7d93ce1604 add luaW_table_get_def 2018-10-21 03:06:08 +02:00
gfgtdf
3d1e3b36df add lua terrainmap object 2018-10-20 13:29:16 +02:00
josteph
e77bb3451d Fix "unknown pragma" warnings on gcc. 2018-10-14 19:19:57 +00:00
gfgtdf
9d6613a8cc fix 3541 : crash in lua tstring comparision
(cherry-picked from commit 69cdbe8da7)
2018-10-07 03:25:01 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
Charles Dang
399b589e60 Use std::time() instead of plain C time()
(cherry-picked from commit d26824901d)
2018-10-07 03:21:01 +00:00
Jyrki Vesterinen
ca150a9129 Visual Studio: increased warning level to /W4 even for release builds
In particular, this enables C4100, the warning for unreferenced function
parameters.

I also fixed some /W4 warnings.

(cherry-picked from commit d4c9db9e35)
2018-10-07 03:18:09 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f693)
2018-10-07 03:17:59 +00:00
Celtic Minstrel
dabf09fce1 Fix deprecation spam
This removes the Lua deprecation_message function in favour of exposing the C++ variant to Lua instead.
It also moves all deprecation messages to a separate logdomain, making them easily enabled en masse.
2018-03-04 21:21:33 -05:00
Celtic Minstrel
d9d65e61b4 Utility function that I didn't end up using but which could be useful elsewhere 2018-02-12 00:09:48 -05:00
Matthias Krüger
a2168d2e24 codespell fixes to /src 2018-02-08 21:54:09 +11:00
Charles Dang
786233d5c9 Replace resources::screen with game_display singleton
This is consistent with the use of display::get_singleton() (in fact, it's the same
pointer). It also makes the code more readable, and means we get to further clean up
the resources set.
2018-01-26 12:36:45 +11:00
Charles Dang
f23305f7e2 Formatting cleanup: T const& -> const T& 2018-01-23 01:26:23 +11:00
Jyrki Vesterinen
fbb0e0229c Improve consistency of WML name validation functions
* moved the new function next to valid_id()
* renamed to valid_tag(), and renamed valid_id() to valid_attribute()
* removed unnecessary parentheses I forgot in
* changed the name of valid_id()'s parameter from "id" to "name"
* changed WML parser to use valid_tag() when it validates tag names

Thanks to @CelticMinstrel who told me about config::valid_id().
2018-01-19 20:27:53 +02:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Jyrki Vesterinen
52e3772c86 Lua API: reject invalid WML tag names (#2375)
Tags that the WML parser rejects shouldn't be possible to create with Lua,
either. This ensures that a UMC author can't accidentally, or deliberately,
inject such tags into the game state and make saving the game impossible.

Fixes #2375.
2018-01-17 23:52:34 +02:00