implements getprefpath in null platform driver

This commit is contained in:
Dethrace Labs 2025-06-28 08:05:26 +12:00
parent dc9d0922af
commit 653b7dc139
5 changed files with 11 additions and 5 deletions

View File

@ -224,7 +224,7 @@ void Harness_DetectAndSetWorkingDirectory(char* argv0) {
if (access("DATA/GENERAL.TXT", F_OK) == 0) {
// good, found
} else {
gHarness_platform.GetPrefPath("dethrace", pref_path);
gHarness_platform.GetPrefPath(pref_path, "dethrace");
path = pref_path;
}
}
@ -481,7 +481,7 @@ static int Harness_Ini_Callback(void* user, const char* section, const char* nam
int Harness_ProcessIniFile(void) {
int i;
char path[1024];
gHarness_platform.GetPrefPath("dethrace", path);
gHarness_platform.GetPrefPath(path, "dethrace");
strcat(path, "dethrace.ini");

View File

@ -47,7 +47,7 @@ typedef struct tHarness_platform {
void* (*GL_GetProcAddress)(const char* name);
void (*GetViewport)(int* x, int* y, float* width_multiplier, float* height_multiplier);
void (*GetPrefPath)(char* app_name, char* path);
void (*GetPrefPath)(char* path, char* app_name);
} tHarness_platform;

View File

@ -1,4 +1,5 @@
#include "null.h"
#include <string.h>
static uint32_t null_time;
@ -53,6 +54,10 @@ static uint32_t null_getticks(void) {
return null_time;
}
static void null_get_pref_path(char* path, char* app_name) {
strcpy(path, ".");
}
void Null_Platform_Init(tHarness_platform* platform) {
null_time = 0;
platform->ProcessWindowMessages = null_get_and_handle_message;
@ -68,4 +73,5 @@ void Null_Platform_Init(tHarness_platform* platform) {
platform->ShowErrorMessage = null_show_error_message;
platform->Renderer_SetPalette = null_set_palette;
platform->GetPrefPath = null_get_pref_path;
}

View File

@ -286,7 +286,7 @@ static void SDL1_Harness_GetViewport(int* x, int* y, float* width_multipler, flo
*height_multiplier = viewport.scale_y;
}
static void SDL1_Harness_GetPrefPath(char* app_name, char* path) {
static void SDL1_Harness_GetPrefPath(char* path, char* app_name) {
// SDL_GetPrefPath not in SDL1. We could implement it if we really needed to.
// for now, just return the current path
strcpy(path, ".");

View File

@ -367,7 +367,7 @@ static void SDL2_Harness_GetViewport(int* x, int* y, float* width_multipler, flo
*height_multiplier = viewport.scale_y;
}
static void SDL2_Harness_GetPrefPath(char* app_name, char* path) {
static void SDL2_Harness_GetPrefPath(char* path, char* app_name) {
char* sdl_path = SDL2_GetPrefPath(NULL, app_name);
strcpy(path, sdl_path);
SDL2_free(sdl_path);