From 93ccfeeb9032eec91e0a4e5053f6646a5c73fe2d Mon Sep 17 00:00:00 2001 From: zlago Date: Thu, 26 Dec 2024 00:07:12 +0100 Subject: bugfixes --- src/libplum.c | 1 + src/main.c | 6 ++++-- src/player.c | 3 +++ src/res/pacer.ase | Bin 865 -> 553 bytes src/save.c | 9 ++++++--- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/libplum.c b/src/libplum.c index 5be1668..789aba9 100644 --- a/src/libplum.c +++ b/src/libplum.c @@ -6,6 +6,7 @@ #include #include #include +void *aligned_alloc(size_t, size_t); // hack to make it build on mingw #ifndef PLUM_DEFS diff --git a/src/main.c b/src/main.c index 9c40876..f86ed0b 100644 --- a/src/main.c +++ b/src/main.c @@ -535,8 +535,10 @@ void main_loop(void) { size_t const start = touch.allocated; touch.allocated = i + 1; touch.positions = realloc(touch.positions, sizeof (struct touch_vec) * touch.allocated); - for (size_t index = start; index < i - 1; index++) { - touch.positions[index].active = 0; + if (i) { // hack for 0 - 1 = absurd-high number; all of RAM gets wiped + for (size_t index = start; index < i - 1; index++) { + touch.positions[index].active = 0; + } } } touch.positions[i].active = 1; diff --git a/src/player.c b/src/player.c index e7dfd98..0bf09de 100644 --- a/src/player.c +++ b/src/player.c @@ -169,6 +169,9 @@ static int move(struct entity *self) { self->facing = +1; } self->velocity.y += GRAVITY; + if (self->velocity.y > to_fixed(8)) { + self->hp = 0; // 'fell out of bounds' probably + } // y collision self->y += self->velocity.y; collision_T const cy = collide(self); diff --git a/src/res/pacer.ase b/src/res/pacer.ase index 7d8e666..bd22044 100644 Binary files a/src/res/pacer.ase and b/src/res/pacer.ase differ diff --git a/src/save.c b/src/save.c index 9baf981..faeb8d1 100644 --- a/src/save.c +++ b/src/save.c @@ -19,11 +19,14 @@ int game_save(FILE *file) { return 0; } +static char *level = NULL; // hack to not leak memory + int game_load(FILE *file) { size_t filesize, len; - char *filedata = util_loadFile(file, &filesize); // hack: we leak a tiny bit of memory here + char *filedata = util_loadFile(file, &filesize); fclose(file); - char *level = filedata; + free(level); + level = filedata; len = strnlen(filedata, filesize); if (len == filesize) { fputs("invalid save format\n", stderr); @@ -43,6 +46,6 @@ int game_load(FILE *file) { return 1; } player_property(next_entities.player, "y", filedata); - level = realloc(level, strlen(level) + 1); + level = realloc(level, strlen(level) + 1); // this line looks fucking stupid out of context return game_load_level(level); } -- cgit 1.4.1-2-gfad0