lupoglaz / GodotAIGym

Communicating with godot engine through shared memory
https://lupoglaz.github.io/GodotAIGym/
MIT License
214 stars 27 forks source link

Compiling with the latest Godot #14

Open tlalexander opened 3 years ago

tlalexander commented 3 years ago

Hello!

Very happy to see an OpenAI gym connector! I discovered that this does not compile with the latest Godot, so I have been working on the necessary changes. I've got a commit here with some of the changes necessary, and I wanted to share it.

https://github.com/tlalexander/GodotAIGym/commit/e6a85eaa807347c190fdae984eeef94d8f70e362

My remaining issues as far as I'm able to see right now seem to be related to changes in the Godot String class.

modules/GodotSharedMemory/cSharedMemory.cpp: In member function 'void cSharedMemory::sendIntArray(const String&, const Vector<int>&)':
modules/GodotSharedMemory/cSharedMemory.cpp:100:25: error: 'const class String' has no member named 'c_str'
  100 |  std::wstring ws = name.c_str();
      |                         ^~~~~
modules/GodotSharedMemory/cSharedMemory.cpp: In member function 'void cSharedMemory::sendFloatArray(const String&, const Vector<float>&)':
modules/GodotSharedMemory/cSharedMemory.cpp:116:25: error: 'const class String' has no member named 'c_str'
  116 |  std::wstring ws = name.c_str();

The method c_str has changed to get_data but also returns a different type. So if you just change the affected c_str calls (only those attached to the Godot String class) to get_data, you get a new error:

odules/GodotSharedMemory/cSharedMemory.h:80:46: error: conversion from 'const char32_t*' to non-scalar type 'std::wstring' {aka 'std::__cxx11::basic_string<wchar_t>'} requested
   80 |           std::wstring ws = sem_name.get_data();

Seems pretty solvable but I've got to head to work and take a break on this so I thought I would share my progress! I'm not sure if some of my other changes were appropriate, but I'll keep testing! I know I can run an old version of Godot if I get stuck but I thought it would be nice to contribute. If anyone sees this and has some ideas please let me know. Thanks!

lupoglaz commented 3 years ago

Godot probably changed some String class functions. I'll update for the newest version next week: been extremely busy with work.