ilimination of system code, removal of x-watcher and replacement of it by dmon, fixes in audio code, dynamic asset reload

This commit is contained in:
veclavtalica
2025-01-30 04:30:20 +03:00
parent 4b2a22bf3c
commit 74d7190c62
21 changed files with 2164 additions and 1427 deletions

View File

@ -1,4 +1,4 @@
#include "twn_loop.h"
#include "twn_loop_c.h"
#include "twn_engine_context_c.h"
#include "twn_filewatch_c.h"
#include "twn_input_c.h"
@ -6,7 +6,7 @@
#include "twn_util_c.h"
#include "twn_game_object_c.h"
#include "twn_textures_c.h"
#include "system/twn_timer.h"
#include "twn_timer_c.h"
#include <SDL2/SDL.h>
#include <physfs.h>
@ -747,15 +747,20 @@ static void clean_up(void) {
}
static void reset_state(void) {
void reset_state(void) {
ctx.game.initialization_needed = true;
input_reset_state(&ctx.input);
textures_reset_state();
}
static void pack_contents_modified(char const *path, enum FilewatchAction action) {
log_info("Pack contents invalidated: %s, action: %i", path, action);
reset_state();
static uint32_t last_reset_tick;
if (last_reset_tick != (uint32_t)ctx.game.frame_number) {
log_info("Pack contents invalidated: %s, action: %i", path, action);
reset_state();
last_reset_tick = (uint32_t)ctx.game.frame_number;
}
}
@ -868,11 +873,7 @@ int enter_loop(int argc, char **argv) {
profile_end("startup");
while (ctx.is_running) {
if (game_object_try_reloading()) {
ctx.game.initialization_needed = true;
reset_state();
}
/* dispatch all filewatch driven events, such as game object and asset pack reload */
filewatch_poll();
main_loop();
}