summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp
index f56e129..1fc8d17 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -28,9 +28,32 @@
#include <BulletCollision/NarrowPhaseCollision/btRaycastCallback.h>
#include <GLFW/glfw3.h>
#include <cstring>
+#include <filesystem>
#include <fstream>
#include <thread>
+void game_get_executable_path();
+
+#ifdef _WIN32
+#include <windows.h>
+void game_get_executable_path() {
+ char buf[512];
+ size_t result = GetModuleFileNameA(NULL, buf, 512);
+ // TODO leaky
+ char *val = (char*)malloc(strlen(buf)+1);
+ strcpy(val, buf);
+ pkeSettings.executable_path = val;
+}
+#else
+void game_get_executable_path() {
+ auto path = std::filesystem::canonical("/proc/self/exe");
+ // TODO leaky
+ char *val = (char*)malloc(strlen(path.c_str())+1);
+ strcpy(val, path.c_str());
+ pkeSettings.executable_path = val;
+}
+#endif
+
void Game_Init();
void Game_Tick(double delta);
void Game_Teardown();
@@ -100,11 +123,11 @@ void Game_Tick(double delta) {
window_tick_late(delta);
}
-void pke_game_main_init(PKEWindowProperties windowProps, const char *executablePath, PKEPluginInterface *plugins, unsigned int n_plugins) {
+void pke_game_main_init(PKEWindowProperties windowProps, PKEPluginInterface *plugins, unsigned int n_plugins) {
fprintf(stdout, "[%s] pke_game_main_init Entering.\n", __FILE__);
unsigned int u;
- pkeSettings.executablePath = executablePath;
+ game_get_executable_path();
Game_Init();
pk_ev_init(pkeSettings.mem_bkt.game);
@@ -333,9 +356,9 @@ void pke_game_main_teardown() {
fprintf(stdout, "[%s] pke_game_main_teardown Exiting.\n", __FILE__);
}
-void Game_Main(PKEWindowProperties windowProps, const char *executablePath) {
+void Game_Main(PKEWindowProperties windowProps) {
- pke_game_main_init(windowProps, executablePath, nullptr, 0);
+ pke_game_main_init(windowProps);
pke_game_main_load();