aboutsummaryrefslogtreecommitdiff
path: root/inc/lzy.h
diff options
context:
space:
mode:
Diffstat (limited to 'inc/lzy.h')
-rw-r--r--inc/lzy.h45
1 files changed, 12 insertions, 33 deletions
diff --git a/inc/lzy.h b/inc/lzy.h
index 6e51755..12403e0 100644
--- a/inc/lzy.h
+++ b/inc/lzy.h
@@ -80,8 +80,8 @@ typedef struct LZY_Event {
LZY_EventUnion u;
} LZY_Event;
-int LZY_Init(int argc, const char **argv, const char *title, int target_fps,
- const char *tset_path, const char *font_path);
+int LZY_Init(const char *title, int target_fps, const char *tset_path,
+ const char *font_path);
void LZY_Quit(void);
int LZY_DrawBegin(void);
int LZY_DrawEnd(void);
@@ -210,13 +210,11 @@ static unsigned int tset_width, tset_height;
static unsigned int font_width, font_height;
static int timer_callback(volatile int *);
-int LZY_Init(int argc, const char **argv, const char *title, int target_fps,
- const char *tset_path, const char *font_path) {
+int LZY_Init(const char *title, int target_fps, const char *tset_path,
+ const char *font_path) {
extern bopti_image_t LZY_GINT_TILESET;
extern bopti_image_t LZY_GINT_FONT;
- LZY_UNUSED(argc);
- LZY_UNUSED(argv);
LZY_UNUSED(title);
LZY_UNUSED(tset_path);
LZY_UNUSED(font_path);
@@ -460,7 +458,6 @@ const char *LZY_GetError(void) {
#include LZY_SDL_INCLUDE
#include LZY_SDL_IMAGE_INCLUDE
#include LZY_SDL_MIXER_INCLUDE
-#include <libgen.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -485,24 +482,6 @@ static uint64_t min_dt;
static uint64_t next_time;
static char *datadir;
-static char *str_dup(const char *src) {
- char *copy;
-
- if (src == NULL) {
- error = "src is NULL";
- return NULL;
- }
-
- copy = calloc(strlen(src) + 1, sizeof(char));
- if (copy == NULL) {
- error = "calloc failed";
- return NULL;
- }
-
- strcpy(copy, src);
- return copy;
-}
-
static char *path_relative(const char *path) {
char *buf;
@@ -516,28 +495,28 @@ static char *path_relative(const char *path) {
return NULL;
}
- buf = calloc(strlen(datadir) + strlen(path) + 2, sizeof(char));
+ buf = calloc(strlen(datadir) + strlen(path) + 1, sizeof(char));
if (buf == NULL) {
error = "calloc failed";
return NULL;
}
strcpy(buf, datadir);
- strcat(buf, "/");
strcat(buf, path);
return buf;
}
-int LZY_Init(int argc, const char **argv, const char *title, int target_fps,
- const char *tset_path, const char *font_path) {
+int LZY_Init(const char *title, int target_fps, const char *tset_path,
+ const char *font_path) {
const int img_flags = IMG_INIT_PNG;
char *buf;
- datadir = str_dup((argc < 1) ? ("./rl") : (argv[0]));
- if (datadir == NULL)
+ datadir = SDL_GetBasePath();
+ if (datadir == NULL) {
+ error = SDL_GetError();
return -1;
- dirname(datadir);
+ }
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
error = SDL_GetError();
@@ -625,7 +604,7 @@ int LZY_Init(int argc, const char **argv, const char *title, int target_fps,
void LZY_Quit(void) {
if (datadir != NULL) {
- free(datadir);
+ SDL_free(datadir);
datadir = NULL;
}