diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 093eff7502..2d414249a9 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -166,6 +166,7 @@ IF (UNIX) ${Vega_Strike_SOURCE_DIR}/src/damage ${Vega_Strike_SOURCE_DIR}/src/resource ${Vega_Strike_SOURCE_DIR}/src/components + ${Vega_Strike_SOURCE_DIR}/src/python/config ${Vega_Strike_BINARY_DIR} ${Vega_Strike_BINARY_DIR}/src /usr/include/harfbuzz/ @@ -177,6 +178,7 @@ ELSE () ${Vega_Strike_SOURCE_DIR}/src/damage ${Vega_Strike_SOURCE_DIR}/src/resource ${Vega_Strike_SOURCE_DIR}/src/components + ${Vega_Strike_SOURCE_DIR}/src/python/config ${Vega_Strike_BINARY_DIR} ${Vega_Strike_BINARY_DIR}/src ) @@ -374,6 +376,7 @@ IF (Python3_FOUND) SET(TST_INCLUDES ${Python3_INCLUDE_DIRS}) SET(TST_LIBS ${Python3_LIBRARIES}) SET(HAVE_PYTHON 1) + add_compile_definitions(Python_SITELIB=${Python3_SITELIB}) ELSE (Python3_FOUND) MESSAGE(FATAL_ERROR "Can't find python") ENDIF (Python3_FOUND) @@ -695,9 +698,9 @@ SET(LIBVS_LOGGING ) SET(LIBCONFIG - src/abstract_config.cpp src/configuration/configuration.cpp src/configuration/game_config.cpp + src/configuration/graphics_config.cpp ) SET(LIBDAMAGE @@ -712,11 +715,14 @@ SET(LIBRESOURCE src/resource/product.cpp src/resource/cargo.cpp src/resource/manifest.cpp - src/resource/python_utils.cpp src/resource/random_utils.cpp src/cmd/json.cpp ) +SET(LIBPYTHON + src/python/config/python_utils.cpp +) + SET(LIBCOMPONENT src/components/component.cpp @@ -1036,7 +1042,6 @@ SET(LIBROOTGENERIC_SOURCES src/atmospheric_fog_mesh.cpp src/configxml.cpp src/easydom.cpp - src/endianness.cpp src/macosx_math.cpp src/faction_generic.cpp src/faction_util_generic.cpp @@ -1044,14 +1049,12 @@ SET(LIBROOTGENERIC_SOURCES src/galaxy_gen.cpp src/galaxy_xml.cpp src/galaxy_utils.cpp - src/hashtable.cpp src/lin_time.cpp src/load_mission.cpp src/pk3.cpp src/posh.cpp src/savegame.cpp src/system_factory.cpp - src/star_system_generic.cpp src/star_system_xml.cpp src/stardate.cpp src/universe_globals.cpp @@ -1132,7 +1135,25 @@ SET(LIBAUDIO_SOURCES ) +ADD_LIBRARY(vegastrike_python SHARED + ${LIBPYTHON} +) + +TARGET_COMPILE_OPTIONS( + vegastrike_python PRIVATE -fPIC +) + +TARGET_LINK_LIBRARIES( + vegastrike_python + ${Boost_LIBRARIES} + ${Python3_LIBRARIES} +) + +# Name must be witout the lib prefix +SET_TARGET_PROPERTIES(vegastrike_python PROPERTIES PREFIX "") + ADD_LIBRARY(vegastrike-engine_com + ${LIBPYTHON} ${LIBVS_LOGGING} ${LIBCONFIG} ${LIBDAMAGE} @@ -1723,13 +1744,14 @@ IF (USE_GTEST) src/resource/tests/resource_test.cpp src/resource/tests/manifest_tests.cpp src/resource/tests/random_tests.cpp - src/resource/tests/python_tests.cpp + src/configuration/tests/python_tests.cpp src/exit_unit_tests.cpp src/components/tests/energy_container_tests.cpp src/components/tests/balancing_tests.cpp ) ADD_LIBRARY(vegastrike-testing + ${LIBPYTHON} ${LIBCONFIG} ${LIBDAMAGE} ${LIBRESOURCE} @@ -1774,8 +1796,8 @@ IF (USE_GTEST) ) FILE( - COPY "src/components/tests/python_tests.py" - DESTINATION ${CMAKE_BINARY_DIR} + COPY "src/configuration/tests/python_tests.py" + DESTINATION ${CMAKE_BINARY_DIR}/test_assets ) INCLUDE(GoogleTest) diff --git a/engine/objconv/CMakeLists.txt b/engine/objconv/CMakeLists.txt index 8170d5bbfc..aba9e8cdd8 100644 --- a/engine/objconv/CMakeLists.txt +++ b/engine/objconv/CMakeLists.txt @@ -88,7 +88,6 @@ SET(MESHER_SOURCES mesher/Modules/XMesh_to_BFXM.cpp mesher/Modules/XMesh_to_Ogre.cpp mesher/Modules/Wavefront_to_BFXM.cpp - ${Vega_Strike_SOURCE_DIR}/src/hashtable.cpp ${Vega_Strike_SOURCE_DIR}/src/xml_support.cpp ) diff --git a/engine/src/abstract_config.cpp b/engine/src/abstract_config.cpp deleted file mode 100644 index 9be9523f8b..0000000000 --- a/engine/src/abstract_config.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "abstract_config.h" - -// This is probably unique enough to ensure no collision -/*string AbstractConfig::DEFAULT_ERROR_VALUE = "AbstractConfig::_GetVariable DEFAULT_ERROR_VALUE"; - -AbstractConfig::AbstractConfig() -{ - -} - -inline std::string AbstractConfig::ValidateVariable(std::string const &result, - std::string const &default_value) { - if(result == DEFAULT_ERROR_VALUE || result.empty()) { - return default_value; - } -}*/ diff --git a/engine/src/abstract_config.h b/engine/src/abstract_config.h deleted file mode 100644 index c5aad68e16..0000000000 --- a/engine/src/abstract_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2001-2023 Daniel Horn, pyramid3d, Stephen G. Tuggy, Benjamen R. Meyer, - * and other Vega Strike contributors. - * - * https://github.com/vegastrike/Vega-Strike-Engine-Source - * - * This file is part of Vega Strike. - * - * Vega Strike is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Vega Strike is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Vega Strike. If not, see . - */ -#ifndef VEGA_STRIKE_ENGINE_ABSTRACT_CONFIG_H -#define VEGA_STRIKE_ENGINE_ABSTRACT_CONFIG_H - -#include - -class AbstractConfig { -private: - static std::string DEFAULT_ERROR_VALUE; - virtual inline std::string _GetStringVariable(std::string const §ion, std::string const &name) = 0; - - //template - //inline T GetVariable(std::string const &result, std::string const &default_value); - -public: - AbstractConfig(); -}; - -#endif //VEGA_STRIKE_ENGINE_ABSTRACT_CONFIG_H diff --git a/engine/src/cmd/missile.cpp b/engine/src/cmd/missile.cpp index 01a2945646..4d708c4638 100644 --- a/engine/src/cmd/missile.cpp +++ b/engine/src/cmd/missile.cpp @@ -32,7 +32,6 @@ #include "configxml.h" #include "images.h" #include "collection.h" -#include "star_system_generic.h" #include "role_bitmask.h" #include "ai/order.h" #include "faction_generic.h" diff --git a/engine/src/cmd/unit_generic.h b/engine/src/cmd/unit_generic.h index fa00897d3c..afd06b9f50 100644 --- a/engine/src/cmd/unit_generic.h +++ b/engine/src/cmd/unit_generic.h @@ -69,7 +69,6 @@ void UncheckUnit( class Unit*un ); #include "collection.h" #include "script/flightgroup.h" #include "faction_generic.h" -#include "star_system_generic.h" #include "gfx/cockpit_generic.h" #include "vsfilesystem.h" #include "collide_map.h" diff --git a/engine/src/configuration/configuration.cpp b/engine/src/configuration/configuration.cpp index 3ec43ae996..29aac0c2ad 100644 --- a/engine/src/configuration/configuration.cpp +++ b/engine/src/configuration/configuration.cpp @@ -30,10 +30,17 @@ #endif #include +#include + using vega_config::GetGameConfig; Configuration::Configuration() { //logging.verbose_debug = GetGameConfig().GetBool("data.verbose_debug", false); + std::ifstream ifs("config.json", std::ifstream::in); + std::stringstream buffer; + buffer << ifs.rdbuf(); + const std::string json_text = buffer.str(); + graphics2_config = Graphics2Config(json_text); } /* Override the default value(provided by constructor) with the value from the user specified configuration file, if any. diff --git a/engine/src/configuration/configuration.h b/engine/src/configuration/configuration.h index 74838af03e..e515387c54 100644 --- a/engine/src/configuration/configuration.h +++ b/engine/src/configuration/configuration.h @@ -30,6 +30,8 @@ #include #include +#include "graphics_config.h" + namespace vega_config { // Config Structs Declaration @@ -449,6 +451,7 @@ class Configuration { Configuration(); void OverrideDefaultsWithUserConfiguration(); vega_config::GeneralConfig general_config; + Graphics2Config graphics2_config; vega_config::DataConfig data_config; vega_config::AIConfig ai; vega_config::AudioConfig audio_config; diff --git a/engine/src/configuration/graphics_config.cpp b/engine/src/configuration/graphics_config.cpp new file mode 100644 index 0000000000..a255b99057 --- /dev/null +++ b/engine/src/configuration/graphics_config.cpp @@ -0,0 +1,50 @@ +#include +#include + +#include "graphics_config.h" +#include "json.h" + +// Exposes the struct to python +// TODO: move this somewhere as the same library should have multiple +// definitions +// Can we spread a boost python module over several files? +/*BOOST_PYTHON_MODULE(vegastrike_python) { + boost::python::class_("GraphicsConfig", boost::python::init<>()) + .def_readwrite("screen", &Graphics2Config::screen) + .def_readwrite("resolution_x", &Graphics2Config::resolution_x) + .def_readwrite("resolution_y", &Graphics2Config::resolution_y); +}*/ + +// a temporary helper function until we move to Boost/JSON +// TODO: remove +static const int GetValue( + const std::string key, + const int default_value, + const json::jobject object) { + if(!object.has_key(key)) { + return default_value; + } + + const std::string attribute = object.get(key); + const int value = std::stoi(attribute); + return value; +} + +Graphics2Config::Graphics2Config(const std::string config) { + json::jobject json_root = json::jobject::parse(config); + + if(!json_root.has_key("graphics")) { + return; + } + + const std::string graphics_json = json_root.get("graphics"); + json::jobject json_graphics = json::jobject::parse(graphics_json); + + screen = GetValue("screen", 0, json_graphics); + resolution_x = GetValue("resolution_x", 2560, json_graphics); + resolution_y = GetValue("resolution_y", 1600, json_graphics); +} + + + + diff --git a/engine/src/resource/python_utils.cpp b/engine/src/configuration/graphics_config.h similarity index 70% rename from engine/src/resource/python_utils.cpp rename to engine/src/configuration/graphics_config.h index 23590f49cb..f0df85d55c 100644 --- a/engine/src/resource/python_utils.cpp +++ b/engine/src/configuration/graphics_config.h @@ -1,5 +1,5 @@ /* - * python_utils.cpp + * graphics_config.h * * Copyright (c) 2001-2002 Daniel Horn * Copyright (c) 2002-2019 pyramid3d and other Vega Strike Contributors @@ -25,21 +25,19 @@ // -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- -#include "python_utils.h" +#ifndef VEGA_STRIKE_ENGINE_PYTHON_CONFIG_GRAPHICS_CONFIG_H +#define VEGA_STRIKE_ENGINE_PYTHON_CONFIG_GRAPHICS_CONFIG_H -#include -#include +// TODO: remove the other GraphicsConfig and rename this +struct Graphics2Config { + int screen{0}; + int resolution_x{1920}; + int resolution_y{1080}; -using namespace boost::python; + Graphics2Config() = default; + Graphics2Config(const std::string config); +}; -const std::string GetPythonPath() { - Py_Initialize(); - wchar_t* w_path_ptr = Py_GetPath(); - Py_Finalize(); - - std::wstring w_path_w( w_path_ptr ); - std::string path( w_path_w.begin(), w_path_w.end() ); - std::cout << "Python path: " << path << std::endl; - return path; -} \ No newline at end of file + +#endif // VEGA_STRIKE_ENGINE_PYTHON_CONFIG_GRAPHICS_CONFIG_H \ No newline at end of file diff --git a/engine/src/resource/tests/python_tests.cpp b/engine/src/configuration/tests/python_tests.cpp similarity index 87% rename from engine/src/resource/tests/python_tests.cpp rename to engine/src/configuration/tests/python_tests.cpp index 4f3d39734a..110a1dcf9d 100644 --- a/engine/src/resource/tests/python_tests.cpp +++ b/engine/src/configuration/tests/python_tests.cpp @@ -30,12 +30,10 @@ #include #include -#include "python_utils.h" +#include "python/config/python_utils.h" using namespace boost::python; -// This code shows how to call a python file from c++ -// It is not portable struct World { @@ -86,15 +84,6 @@ TEST(Python, Call_Function) { Py_Initialize(); - // Use the following code to figure out your original path, as the above Py_SetPath overrides it. - // Note that Py_GetPath must be called after Py_Initialize and Py_SetPath before. - /*wchar_t* w_path_ptr = Py_GetPath(); - std::wstring w_path_w( w_path_ptr ); - std::string path( w_path_w.begin(), w_path_w.end() ); - std::cout << "Path: " << path << std::endl;*/ - - //PyObject* moduleString = PyUnicode_FromString((char*)"python_tests"); - //PyObject* module = PyImport_Import(moduleString); PyObject* module = PyImport_ImportModule("python_tests"); std::cout << "PyImport_ImportModule did not crash\n" << std::flush; if(!module) { @@ -140,4 +129,4 @@ TEST(Python, Call_Function) { // Uncomment to see prints //EXPECT_FALSE(true); -} \ No newline at end of file +} diff --git a/engine/src/components/tests/python_tests.py b/engine/src/configuration/tests/python_tests.py similarity index 100% rename from engine/src/components/tests/python_tests.py rename to engine/src/configuration/tests/python_tests.py diff --git a/engine/src/endianness.cpp b/engine/src/endianness.cpp deleted file mode 100644 index 579766a2ac..0000000000 --- a/engine/src/endianness.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/** -* endianness.cpp -* -* Copyright (c) 2001-2002 Daniel Horn -* Copyright (c) 2002-2019 pyramid3d and other Vega Strike Contributors -* Copyright (c) 2019-2021 Stephen G. Tuggy, and other Vega Strike Contributors -* -* https://github.com/vegastrike/Vega-Strike-Engine-Source -* -* This file is part of Vega Strike. -* -* Vega Strike is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* Vega Strike is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Vega Strike. If not, see . -*/ - -#include "endianness.h" - diff --git a/engine/src/galaxy_utils.cpp b/engine/src/galaxy_utils.cpp index 19ea68f784..94b296b0c1 100644 --- a/engine/src/galaxy_utils.cpp +++ b/engine/src/galaxy_utils.cpp @@ -20,7 +20,6 @@ * along with Vega Strike. If not, see . */ -#include "star_system_generic.h" #include "cmd/script/mission.h" #include "universe.h" #include "galaxy_xml.h" @@ -30,7 +29,6 @@ #include "vs_globals.h" #include "xml_support.h" #include "lin_time.h" -#include "star_system_generic.h" #include "options.h" diff --git a/engine/src/gfx/cockpit_generic.cpp b/engine/src/gfx/cockpit_generic.cpp index b2ed5a66e0..7eed124d2d 100644 --- a/engine/src/gfx/cockpit_generic.cpp +++ b/engine/src/gfx/cockpit_generic.cpp @@ -30,7 +30,6 @@ #include "vs_globals.h" #include "vegastrike.h" #include "cockpit_generic.h" -#include "star_system_generic.h" #include "cmd/unit_generic.h" #include "cmd/unit_util.h" #include "cmd/collection.h" diff --git a/engine/src/gfx/radar/sensor.cpp b/engine/src/gfx/radar/sensor.cpp index dd9c874fe1..972477522a 100644 --- a/engine/src/gfx/radar/sensor.cpp +++ b/engine/src/gfx/radar/sensor.cpp @@ -34,7 +34,7 @@ #include "sensor.h" #include "universe.h" -extern Unit *getTopLevelOwner(); // WTF... located in star_system_generic.cpp +extern Unit *getTopLevelOwner(); // located in star_system.cpp namespace Radar { diff --git a/engine/src/gldrv/winsys.cpp b/engine/src/gldrv/winsys.cpp index 4f5e4ce847..eccbeab702 100644 --- a/engine/src/gldrv/winsys.cpp +++ b/engine/src/gldrv/winsys.cpp @@ -251,10 +251,9 @@ static bool setup_sdl_video_mode(int *argc, char **argv) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); } //#endif - width = g_game.x_resolution; - height = g_game.y_resolution; - - const int screen_number = configuration()->general_config.screen; + width = configuration()->graphics2_config.resolution_x; + height = configuration()->graphics2_config.resolution_y; + const int screen_number = configuration()->graphics2_config.screen; SDL_Window *window = nullptr; if(screen_number == 0) { window = SDL_CreateWindow("Vegastrike", 0, 0, width, height, video_flags); diff --git a/engine/src/hashtable.cpp b/engine/src/hashtable.cpp deleted file mode 100644 index 95aec4f40f..0000000000 --- a/engine/src/hashtable.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/** -* hashtable.cpp -* -* Copyright (c) 2001-2002 Daniel Horn -* Copyright (c) 2002-2019 pyramid3d and other Vega Strike Contributors -* Copyright (c) 2019-2021 Stephen G. Tuggy, and other Vega Strike Contributors -* -* https://github.com/vegastrike/Vega-Strike-Engine-Source -* -* This file is part of Vega Strike. -* -* Vega Strike is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* Vega Strike is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Vega Strike. If not, see . -*/ - -/* removed */ - diff --git a/engine/src/libserver.cpp b/engine/src/libserver.cpp index 88fdd032d8..e2d9f4b7bc 100644 --- a/engine/src/libserver.cpp +++ b/engine/src/libserver.cpp @@ -22,7 +22,6 @@ #include "vs_globals.h" #include "configxml.h" -#include "star_system_generic.h" #include "cmd/unit_generic.h" VegaConfig *createVegaConfig(const char *file) { diff --git a/engine/src/load_mission.cpp b/engine/src/load_mission.cpp index b71826446d..0bdd4230fb 100644 --- a/engine/src/load_mission.cpp +++ b/engine/src/load_mission.cpp @@ -29,7 +29,6 @@ #include "cmd/script/mission.h" #include "cmd/script/pythonmission.h" #include "vs_globals.h" -#include "star_system_generic.h" #include "vsfilesystem.h" #include "vs_logging.h" #include "cmd/unit_generic.h" diff --git a/engine/src/main.cpp b/engine/src/main.cpp index 12b96fd2f3..94d27443d5 100644 --- a/engine/src/main.cpp +++ b/engine/src/main.cpp @@ -247,6 +247,8 @@ int main(int argc, char *argv[]) { const boost::filesystem::path program_name{program_path.filename()}; //canonical_program_path.filename(); const boost::filesystem::path program_directory_path{program_path.parent_path()}; + VSFileSystem::programdir = program_directory_path.string(); + // This will be set later boost::filesystem::path home_subdir_path{}; diff --git a/engine/src/python/config/python_utils.cpp b/engine/src/python/config/python_utils.cpp new file mode 100644 index 0000000000..3f0d43d6d0 --- /dev/null +++ b/engine/src/python/config/python_utils.cpp @@ -0,0 +1,109 @@ +/* + * python_utils.cpp + * + * Copyright (c) 2001-2002 Daniel Horn + * Copyright (c) 2002-2019 pyramid3d and other Vega Strike Contributors + * Copyright (c) 2019-2023 Stephen G. Tuggy, Benjamen R. Meyer, Roy Falk and other Vega Strike Contributors + * + * https://github.com/vegastrike/Vega-Strike-Engine-Source + * + * This file is part of Vega Strike. + * + * Vega Strike is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Vega Strike is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Vega Strike. If not, see . + */ + +// -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- + +#include "python_utils.h" + +#include +#include +#include + +using namespace boost::python; +using namespace boost::filesystem; + +#define Q(x) #x +#define QUOTE(x) Q(x) + +// This is a kludge. It runs python before +// just to get the python paths. +const std::string GetPythonPath() { + Py_Initialize(); + wchar_t* w_path_ptr = Py_GetPath(); + Py_Finalize(); + + std::wstring w_path_w( w_path_ptr ); + std::string path( w_path_w.begin(), w_path_w.end() ); + + return path; +} + + + +// A utility function to call a function and get a PyObject as a result +PyObject* GetClassFromPython( + const std::string build_path, + const std::string path_string, + const std::string module_name, + const std::string function_name) { + boost::filesystem::path full_path = boost::filesystem::path(path_string); + boost::filesystem::current_path(full_path); + + if(!boost::filesystem::exists(module_name + ".py")) { + // TODO: throw exception + return nullptr; + } + + const std::string yaml_path = QUOTE(Python_SITELIB); + const std::string python_path_string = GetPythonPath() + + ":" + path_string + + ":" + yaml_path + ":" + build_path; + const std::wstring python_path_wstring = std::wstring(python_path_string.begin(), + python_path_string.end()); + const wchar_t* python_path = python_path_wstring.c_str(); + Py_SetPath(python_path); + Py_Initialize(); + + + PyObject* module = PyImport_ImportModule(module_name.c_str()); + + if(!module) { + std::cerr << "PyImport_ImportModule is null\n" << std::flush; + PyErr_Print(); + Py_Finalize(); + // TODO: throw exception + return nullptr; + } + + PyObject* function = PyObject_GetAttrString(module,function_name.c_str()); + if(!function) { + std::cerr << "PyObject_GetAttrString is null\n" << std::flush; + PyErr_Print(); + Py_Finalize(); + // TODO: throw exception + return nullptr; + } + + + PyObject* pyResult = PyObject_CallObject(function, nullptr); + Py_Finalize(); + + return pyResult; +} + + + + + diff --git a/engine/src/resource/python_utils.h b/engine/src/python/config/python_utils.h similarity index 78% rename from engine/src/resource/python_utils.h rename to engine/src/python/config/python_utils.h index 083f3f1cbd..9c3da9438b 100644 --- a/engine/src/resource/python_utils.h +++ b/engine/src/python/config/python_utils.h @@ -30,6 +30,18 @@ #include +// See https://stackoverflow.com/q/804894/5276890 +struct _object; +typedef _object PyObject; + const std::string GetPythonPath(); +// A utility function to call a function and get a PyObject as a result +PyObject* GetClassFromPython( + const std::string build_path, + const std::string path_string, + const std::string module_name, + const std::string function_name); + + #endif //VEGA_STRIKE_ENGINE_RESOURCE_PYTHON_UTILS_H \ No newline at end of file diff --git a/engine/src/star_system_generic.cpp b/engine/src/star_system_generic.cpp deleted file mode 100644 index d6f1acaa3f..0000000000 --- a/engine/src/star_system_generic.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/** -* star_system_generic.cpp -* -* Copyright (c) 2001-2002 Daniel Horn -* Copyright (c) 2002-2019 pyramid3d and other Vega Strike Contributors -* Copyright (c) 2019-2021 Stephen G. Tuggy, and other Vega Strike Contributors -* -* https://github.com/vegastrike/Vega-Strike-Engine-Source -* -* This file is part of Vega Strike. -* -* Vega Strike is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* Vega Strike is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Vega Strike. If not, see . -*/ - - - diff --git a/engine/src/star_system_generic.h b/engine/src/star_system_generic.h deleted file mode 100644 index 31705c2fb6..0000000000 --- a/engine/src/star_system_generic.h +++ /dev/null @@ -1,26 +0,0 @@ -/** -* star_system_generic.h -* -* Copyright (c) 2001-2002 Daniel Horn -* Copyright (c) 2002-2019 pyramid3d and other Vega Strike Contributors -* Copyright (c) 2019-2023 Stephen G. Tuggy, Benjamen R. Meyer, and other Vega Strike Contributors -* -* https://github.com/vegastrike/Vega-Strike-Engine-Source -* -* This file is part of Vega Strike. -* -* Vega Strike is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* Vega Strike is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Vega Strike. If not, see . -*/ -// NO HEADER GUARD - diff --git a/engine/src/star_system_xml.cpp b/engine/src/star_system_xml.cpp index db2272a21c..40cda36b5a 100644 --- a/engine/src/star_system_xml.cpp +++ b/engine/src/star_system_xml.cpp @@ -23,7 +23,6 @@ #include #include "xml_support.h" -#include "star_system_generic.h" #include "cmd/planet.h" #include "vs_globals.h" #include "vsfilesystem.h" diff --git a/engine/src/universe_util_generic.cpp b/engine/src/universe_util_generic.cpp index 6f3aa23764..33322d0895 100644 --- a/engine/src/universe_util_generic.cpp +++ b/engine/src/universe_util_generic.cpp @@ -32,7 +32,6 @@ #include "universe_util.h" #include "cmd/unit_generic.h" #include "cmd/collection.h" -#include "star_system_generic.h" #include #include #include "savegame.h" diff --git a/engine/src/universe_util_server.cpp b/engine/src/universe_util_server.cpp index 1aeee8a723..18546cb8a6 100644 --- a/engine/src/universe_util_server.cpp +++ b/engine/src/universe_util_server.cpp @@ -27,7 +27,6 @@ #include "cmd/unit_factory.h" //for UnitFactory::getMasterPartList() #include "cmd/collection.h" #include "networking/netserver.h" -#include "star_system_generic.h" #include #include "lin_time.h" #include "load_mission.h" diff --git a/engine/src/vsfilesystem.cpp b/engine/src/vsfilesystem.cpp index 083930b7e8..00899ce2a2 100644 --- a/engine/src/vsfilesystem.cpp +++ b/engine/src/vsfilesystem.cpp @@ -249,6 +249,7 @@ std::string sharedsprites; std::string savedunitpath; std::string modname; std::string moddir; +std::string programdir; std::string datadir; std::string homedir; diff --git a/engine/src/vsfilesystem.h b/engine/src/vsfilesystem.h index f6624c3059..494dfe3121 100644 --- a/engine/src/vsfilesystem.h +++ b/engine/src/vsfilesystem.h @@ -123,6 +123,7 @@ extern std::string sharedanims; extern std::string sharedsprites; extern std::string savedunitpath; extern std::string moddir; +extern std::string programdir; extern std::string datadir; extern std::string homedir; //User home directory including .vegastrike subdir