From 5c58e11feaafb000a60d948da16ca23f70d88635 Mon Sep 17 00:00:00 2001 From: mibi88 <76903855+mibi88@users.noreply.github.com> Date: Sat, 27 Jul 2024 15:26:31 +0200 Subject: [PATCH] Revert "Fixes" This reverts commit 47cd6dc351d8fa1de7a79ad00a0209b92c2db252. --- CMakeLists.txt | 1 - src/dialogs.c | 1 - src/events.c | 123 ------------------------------------------------- src/game.c | 1 + src/game.h | 3 +- 5 files changed, 2 insertions(+), 127 deletions(-) delete mode 100644 src/events.c diff --git a/CMakeLists.txt b/CMakeLists.txt index eaca920..aa873c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ set(SOURCES src/game.c src/dialogs.c src/npc.c - src/events.c # ... ) # Shared assets, fx-9860G-only assets and fx-CG-50-only assets diff --git a/src/dialogs.c b/src/dialogs.c index ce26a57..23a7890 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -8,7 +8,6 @@ #include "config.h" #include "game.h" #include "npc.h" -#include "events.h" #define BOX_HEIGHT (F_HEIGHT/PXSIZE+8) diff --git a/src/events.c b/src/events.c deleted file mode 100644 index aee4472..0000000 --- a/src/events.c +++ /dev/null @@ -1,123 +0,0 @@ -#include -#include -#include "events.h" - -void events_init_handler(EventHandler *handler) { - handler->vars = 0; -} - -int events_bind_variable(EventHandler *handler, int *var, char *name) { - if(handler->vars < MAX_VARIABLES){ - handler->variables[handler->vars] = var; - handler->var_names[handler->vars++] = name; - }else{ - return 1; - } - return 0; -} - -char op_chars[OP_AMOUNT+1] = " =+-/*%"; - -int _op_null(int a, int b) { - return 0; -} - -int _op_set(int a, int b) { - return b; -} - -int _op_add(int a, int b) { - return a+b; -} - -int _op_sub(int a, int b) { - return a-b; -} - -int _op_div(int a, int b) { - if(b == 0) return 0; - return a/b; -} - -int _op_mul(int a, int b) { - return a*b; -} - -int _op_mod(int a, int b) { - if(b == 0) return 0; - return a%b; -} - -int (*_operations[OP_AMOUNT])(int, int) = { - _op_null, - _op_set, - _op_add, - _op_sub, - _op_div, - _op_mul, - _op_mod -}; - -#define MIN(a, b) a < b ? a : b - -char _message_buffer[MESSAGE_BUFFER_SZ]; -char *events_parse_string(EventHandler *handler, char *message) { - size_t message_pos = 0; - char in_token = 0; - char var_name[TOKEN_MAX_SZ]; - size_t name_pos = 0; - Operation var_op = OP_NULL; - char num[TOKEN_MAX_SZ]; - size_t num_pos = 0; - Token tok_type = T_NULL; - char c; - size_t i, n; - int *var; - for(i=0;ivars;n++){ - if(!strcmp(var_name, handler->var_names[n])){ - var = handler->variables[n]; - if(var_op){ - *var = _operations[var_op](*var, atoi(num)); - } - break; - } - } - } - /* Reset everything */ - tok_type = T_NULL; - name_pos = 0; - var_op = OP_NULL; - num_pos = 0; - } - }else if(!in_token){ - if(message_pos < TOKEN_MAX_SZ) _message_buffer[message_pos++] = c; - } - if(in_token && c != ' '){ - if(tok_type == T_VAR_EDIT){ - if(var_op != OP_NULL){ - if(num_pos < TOKEN_MAX_SZ) num[num_pos++] = c; - } - if(strchr(op_chars, c)){ - var_op = (Operation)(strchr(op_chars, c)-op_chars); - } - if(var_op == OP_NULL){ - if(name_pos < TOKEN_MAX_SZ) var_name[name_pos++] = c; - } - } - if(c == '$'){ - tok_type = T_VAR_EDIT; - } - } - } - _message_buffer[MIN(message_pos, MESSAGE_BUFFER_SZ)] = '\0'; - return _message_buffer; -} diff --git a/src/game.c b/src/game.c index 9a9b0d6..32b4104 100644 --- a/src/game.c +++ b/src/game.c @@ -94,6 +94,7 @@ void game_draw(Game *game) { map_render_by_layer(game, FOREGROUND); game_render_indicator(game); dprint(8, 8, C_BLACK, "Lifes: %d", game->player.life); + dprint(8, 16, C_BLACK, "Mana: %d", game->mana); } /* Key management */ diff --git a/src/game.h b/src/game.h index 940ae61..8b0eb3a 100644 --- a/src/game.h +++ b/src/game.h @@ -5,7 +5,7 @@ #include #include -#include "events.h" + /* The direction where the player is going to. */ typedef enum { @@ -132,7 +132,6 @@ typedef struct { typedef struct { Map *map_level; /* The level that the player is currently playing */ Player player; /* The player data (see player.h). */ - EventHandler handler; /* Some global variables */ /* Set to true when asked for exit */ bool exittoOS;