Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wzapi: getDroidPath that return droid path #3793

Merged
merged 7 commits into from
May 4, 2024

Conversation

1269339743
Copy link
Contributor

this API returns path of a droid,
an Array of object {x:Number, y:Number}, in world coordinate.
its implement is quick and can simplify AI scripting

@past-due
Copy link
Member

past-due commented May 3, 2024

One conundrum: script APIs always deal with map coordinates (not world coordinates).

See:

warzone2100/src/wzapi.h

Lines 80 to 81 in 981df67

// NOTES:
// - All position value types (scr_position, scr_area, etc) passed to/from scripts expect map coordinates

Assuming map coordinates are sufficient for your use-case (and I hope they would be?) we can simply use map_coord() to convert the values before adding them to the vector for JS

src/wzapi.cpp Outdated Show resolved Hide resolved
src/wzapi.cpp Outdated Show resolved Hide resolved
src/wzapi.h Outdated Show resolved Hide resolved
1269339743 and others added 4 commits May 4, 2024 01:21
Co-authored-by: Pavel Solodovnikov <[email protected]>
FAILED: src/CMakeFiles/warzone2100.dir/wzapi.cpp.o
/usr/bin/c++ -DCURL_GNUTLS_DOES_NOT_REQUIRE_LOCKS_INIT -DENABLE_DISCORD -DJSON_USE_IMPLICIT_CONVERSIONS=0 -DNLOHMANN_JSON_NAMESPACE=nlohmann -DNLOHMANN_JSON_NAMESPACE_BEGIN="namespace nlohmann {" -DNLOHMANN_JSON_NAMESPACE_END=} -DSQLITE_ENABLE_COLUMN_METADATA -DWZ_DEBUG_GFX_API_LEAKS -DYY_NO_UNISTD_H -I/home/user/Documents/src/warzone2100/build -I/home/user/Documents/src/warzone2100/. -I/home/user/Documents/src/warzone2100/3rdparty -I/home/user/Documents/src/warzone2100/lib/wzmaplib/include -I/home/user/Documents/src/warzone2100/3rdparty/optional-lite/include -I/home/user/Documents/src/warzone2100/3rdparty/glad/include -I/home/user/Documents/src/warzone2100/3rdparty/launchinfo/include -I/home/user/Documents/src/warzone2100/3rdparty/EmbeddedJSONSignature/include -I/home/user/Documents/src/warzone2100/3rdparty/quickjs-wz -I/home/user/Documents/src/warzone2100/3rdparty/re2 -I/home/user/Documents/src/warzone2100/3rdparty/SQLiteCpp/include -isystem /home/user/Documents/src/warzone2100/3rdparty/glm -isystem /home/user/Documents/src/warzone2100/3rdparty/date/include -isystem /home/user/Documents/src/warzone2100/3rdparty/json/include -isystem /home/user/Documents/src/warzone2100/3rdparty/fmt/include -fstack-protector-strong -fstack-clash-protection -O2 -g -DNDEBUG -std=c++14 -fPIE -Wpedantic -Wall -Wextra -fno-common -fno-math-errno -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Winit-self -Woverloaded-virtual -Wstrict-null-sentinel -Wwrite-strings -Wpointer-arith -Wmissing-noreturn -Wnon-virtual-dtor -Wnull-dereference -Wduplicated-cond -Walloc-zero -Walloca-larger-than=1024 -Wrestrict -Wfloat-conversion -Wformat-security -Wstringop-truncation -Wlogical-op -Wuninitialized -Werror -Wno-float-conversion -Wno-unused-but-set-variable -Wno-sign-compare -Wno-unused-parameter -Wno-format-truncation -Wno-array-bounds -MD -MT src/CMakeFiles/warzone2100.dir/wzapi.cpp.o -MF src/CMakeFiles/warzone2100.dir/wzapi.cpp.o.d -o src/CMakeFiles/warzone2100.dir/wzapi.cpp.o -c /home/user/Documents/src/warzone2100/src/wzapi.cpp
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/c++allocator.h:33,
                 from /usr/include/c++/11/bits/allocator.h:46,
                 from /usr/include/c++/11/string:41,
                 from /home/user/Documents/src/warzone2100/./lib/framework/debug.h:299,
                 from /home/user/Documents/src/warzone2100/./lib/framework/string_ext.h:25,
                 from /home/user/Documents/src/warzone2100/./lib/framework/frame.h:40,
                 from /home/user/Documents/src/warzone2100/./lib/framework/wzapp.h:24,
                 from /home/user/Documents/src/warzone2100/src/wzapi.cpp:25:
/usr/include/c++/11/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = scr_position; _Args = {int, int}; _Tp = scr_position]’:
/usr/include/c++/11/bits/alloc_traits.h:516:17:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = scr_position; _Args = {int, int}; _Tp = scr_position; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<scr_position>]’
/usr/include/c++/11/bits/vector.tcc:115:30:   required from ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, int}; _Tp = scr_position; _Alloc = std::allocator<scr_position>]’
/home/user/Documents/src/warzone2100/src/wzapi.cpp:2105:22:   required from here
/usr/include/c++/11/ext/new_allocator.h:162:11: error: new initializer expression list treated as compound expression [-fpermissive]
  162 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/ext/new_allocator.h:162:11: error: no matching function for call to ‘scr_position::scr_position(int)’
In file included from /home/user/Documents/src/warzone2100/src/qtscript.h:26,
                 from /home/user/Documents/src/warzone2100/src/wzapi.cpp:33:
/home/user/Documents/src/warzone2100/src/wzapi.h:98:8: note: candidate: ‘scr_position::scr_position()’
   98 | struct scr_position
      |        ^~~~~~~~~~~~
/home/user/Documents/src/warzone2100/src/wzapi.h:98:8: note:   candidate expects 0 arguments, 1 provided
/home/user/Documents/src/warzone2100/src/wzapi.h:98:8: note: candidate: ‘constexpr scr_position::scr_position(const scr_position&)’
/home/user/Documents/src/warzone2100/src/wzapi.h:98:8: note:   no known conversion for argument 1 from ‘int’ to ‘const scr_position&’
/home/user/Documents/src/warzone2100/src/wzapi.h:98:8: note: candidate: ‘constexpr scr_position::scr_position(scr_position&&)’
/home/user/Documents/src/warzone2100/src/wzapi.h:98:8: note:   no known conversion for argument 1 from ‘int’ to ‘scr_position&&’
[146/148] Building CXX object src/CMakeFiles/warzone2100.dir/multiint.cpp.o
ninja: build stopped: subcommand failed.
@past-due past-due merged commit e025ff0 into Warzone2100:master May 4, 2024
37 checks passed
1269339743 pushed a commit to 1269339743/warzone2100 that referenced this pull request May 5, 2024
@past-due past-due added the wzapi label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants