codecat / godot-tbloader

TrenchBroom Loader for Godot 4. (Alternative to Qodot)
MIT License
240 stars 30 forks source link

Incompatible with Godot 4 alpha 6 #7

Closed hemebond closed 2 years ago

hemebond commented 2 years ago

The latest alpha release (Godot_v4.0-alpha6_linux.64) has broken the extension. I had a go at compiling using the latest version of godot-cpp but got the following error:

g++ -o src/builder.os -c -std=c++17 -fPIC -Wwrite-strings -Og -g -m64 -fPIC -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -I. -Igodot-headers -Iinclude -Igen/include -Igodot-cpp/gen/include -Igodot-cpp/include -Igodot-cpp/godot-headers -Isrc -Isrc/map src/builder.cpp
src/builder.cpp: In member function ‘virtual void Builder::set_node_common(godot::Node3D*, LMEntity&)’:
src/builder.cpp:267:21: error: ‘strstr’ was not declared in this scope
  267 |                 if (strstr(classname, "light") == classname) {
      |                     ^~~~~~
src/builder.cpp:11:1: note: ‘strstr’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
   10 | #include <tb_loader.h>
  +++ |+#include <cstring>
   11 | 
scons: *** [src/builder.os] Error 1
scons: building terminated because of errors.

Small aside, is this line in the SConstruct correct?

env.Append(LINKFLAGS=["/DEBUG"])

Because I got errors from it and found the following in the SCONS docs:

Don't explicitly put include directory arguments in $LINKFLAGS or $SHLINKFLAGS because the result will be non-portable and the directories will not be searched by the dependency scanner.

I've commented it out for now.

hemebond commented 2 years ago

I think I've managed to get it at least installed without obvious errors:

cd godot-cpp/
scons platform=linux bits=64 generate_bindings=yes -j4
cd ..
scons platform=linux bits=64
mv addons/tbloader/bin/libtbloader.linux.64.so addons/tbloader/bin/tbloader.linux.64.so

Then update plugin.gd:

diff --git a/addons/tbloader/src/plugin.gd b/addons/tbloader/src/plugin.gd
index 3aaff1b..e034a9d 100644
--- a/addons/tbloader/src/plugin.gd
+++ b/addons/tbloader/src/plugin.gd
@@ -20,7 +20,7 @@ func _exit_tree():
        map_control = null

 func _handles(object):
-       return object is TBLoader
+       return object as TBLoader

 func _make_visible(visible: bool):
        map_control.set_visible(visible)

Then copy addons over to the project directory.

hemebond commented 2 years ago

Unfortunately it crashes when I try to build the mesh:

ERROR: Condition "_instance_bindings != nullptr" is true.
   at: set_instance_binding (core/object/object.cpp:1778)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.alpha6.official (e4f0fc50f79336cf76beec40e5e8e5164b288714)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x38920) [0x7fe55b0b7920] (??:0)
[2] /lib/x86_64-linux-gnu/libpthread.so.0(pthread_mutex_lock+0) [0x7fe55b3adf00] (??:0)
[3] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3fd59fa] (??:0)
[4] godot::Node* godot::internal::_call_native_mb_ret_obj<godot::Node>(void*, void*) (??:0)
[5] godot::Node::get_owner() const (??:0)
[6] MeshBuilder::build_worldspawn(int, LMEntity&, LMEntityGeometry&) (??:0)
[7] Builder::build_entity(int, LMEntity&, godot::String const&) (??:0)
[8] Builder::build_map() (??:0)
[9] TBLoader::build_meshes() (??:0)
[10] void godot::call_with_variant_args_helper<godot::___UnexistingClass>(godot::___UnexistingClass*, void (godot::___UnexistingClass::*)(), godot::Variant const**, GDNativeCallError&, IndexSequence<>) (??:0)
[11] void godot::call_with_variant_args_dv<godot::___UnexistingClass>(godot::___UnexistingClass*, void (godot::___UnexistingClass::*)(), void* const*, int, GDNativeCallError&, std::vector<godot::Variant, std::allocator<godot::Variant> > const&) (??:0)
[12] godot::MethodBindT<>::call(void*, void* const*, long, GDNativeCallError&) const (??:0)
[13] godot::MethodBind::bind_call(void*, void*, void* const*, long, void*, GDNativeCallError*) (??:0)
[14] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3f38ddf] (??:0)
[15] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3f428db] (??:0)
[16] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3dffdba] (??:0)
[17] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x1726bb2] (??:0)
[18] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x15ceab8] (??:0)
[19] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3f42818] (??:0)
[20] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3dd9fb4] (??:0)
[21] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3f96e56] (??:0)
[22] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x2874046] (??:0)
[23] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x28748dc] (??:0)
[24] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x2874cc7] (??:0)
[25] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x27f2405] (??:0)
[26] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x2816b71] (??:0)
[27] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x2818a5c] (??:0)
[28] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x28673d2] (??:0)
[29] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x2857462] (??:0)
[30] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0xdb06b8] (??:0)
[31] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3d65494] (??:0)
[32] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0x3d66e45] (??:0)
[33] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0xdb0b29] (??:0)
[34] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0xd3c850] (??:0)
[35] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xcd) [0x7fe55b0a27fd] (??:0)
[36] /home/james/.local/bin/Godot_v4.0-alpha6_linux.64() [0xd55fde] (??:0)
-- END OF BACKTRACE --
================================================================
codecat commented 2 years ago

Thanks for letting me know about Alpha 6, I didn't realize it was out. I'll update godot-cpp tomorrow and make any additional necessary adjustments.

I have actually seen that failed assertion quite a lot, I'm just not sure what's really causing it. Either way I'm pretty sure it's a different issue unrelated to Alpha 6.

/DEBUG is not an "include directory" so I'm unsure what you mean with the quote you referenced. The flag itself was necessary in some previous alphas due to a godot-cpp issue, which I believe is solved now.

hemebond commented 2 years ago

/DEBUG is not an "include directory" so I'm unsure what you mean with the quote you referenced. The flag itself was necessary in some previous alphas due to a godot-cpp issue, which I believe is solved now.

This was the error I was getting until I commented out the line:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `godot-cpp/bin/libgodot-cpp.linux.debug.64.a' is up to date.
g++ -o src/builder.os -c -std=c++17 -fPIC -Wwrite-strings -Og -g -m64 -fPIC -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -I. -Igodot-headers -Iinclude -Igen/include -Igodot-cpp/gen/include -Igodot-cpp/include -Igodot-cpp/godot-headers -Isrc -Isrc/map src/builder.cpp
g++ -o addons/tbloader/bin/libtbloader.linux.64.so -Wl,-R,'$ORIGIN' -m64 /DEBUG -shared src/builder.os src/main.os src/tb_loader.os src/builders/csg_builder.os src/builders/mesh_builder.os src/map/entity.os src/map/geo_generator.os src/map/map_data.os src/map/map_parser.os src/map/matrix.os src/map/surface_gatherer.os src/map/vector.os -Lgodot-cpp/bin -lgodot-cpp.linux.debug.64
/usr/bin/ld: cannot find /DEBUG: No such file or directory
collect2: error: ld returned 1 exit status
scons: *** [addons/tbloader/bin/libtbloader.linux.64.so] Error 1
scons: building terminated because of errors.
codecat commented 2 years ago

I've pushed a fix for Alpha 6, as well as made the /DEBUG flag Windows only. Thanks for the report!

Feel free to open another issue for that failed assertion. I'm not sure why that's happening yet. Either way it seems safe to ignore if possible. (On Windows, it just prints an error to the log, but everything works just fine)

Not sure why you changed _handles, because that still seems to expect a bool return value.

hemebond commented 2 years ago

@codecat I forgot to mention that to fix the original issue I made this change:

diff --git a/src/tb_loader.h b/src/tb_loader.h
index 7ec6ced..2e7e33b 100644
--- a/src/tb_loader.h
+++ b/src/tb_loader.h
@@ -9,6 +9,7 @@
 #include <godot_cpp/classes/control.hpp>

 #include <builder.h>
+#include <cstring>

 using namespace godot;

And had to do it again even with the latest code.