1
1
Fork 0
Browse Source

fix score loading crash

master
alistair 3 years ago
parent
commit
a5dd965777
  1. 2
      src/draw.c
  2. 6
      src/game.c
  3. 7
      src/game.h
  4. 2
      src/logger.c

2
src/draw.c

@ -598,7 +598,7 @@ int draw_end_screen(SDL_Renderer *ren) { @@ -598,7 +598,7 @@ int draw_end_screen(SDL_Renderer *ren) {
int margin = height / 10;
// Vect position = {.x = width - width / 10, .y = height - margin};
long fastest = get_best_time();
long fastest = draw_watch.best_time;
int minutes = level_time / 60000;
float seconds = level_time * 0.001;

6
src/game.c

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
#define FLOOR_THICKNESS 200
#define MAX_ROPE_GRAB_LEN 80000
#define MIN_PHYSICS_STEP 2.0
#define MIN_PHYSICS_STEP 6.0
#define TIMESTEP_LENGTH 5.0
@ -57,6 +57,9 @@ void get_new_physics(Body **phys); @@ -57,6 +57,9 @@ void get_new_physics(Body **phys);
void ratcheted_winch_motor_update(Motor* motor);
void winch_motor_update (struct motorstruct *motor);
/* object that draw.c watches */
struct draw_watcher draw_watch;
// move the collision poly to the position of the player
void default_update_collision_poly(Body *body) {
for (int i=0; i < body->collision_poly_size; i++) {
@ -723,6 +726,7 @@ void next_level() { @@ -723,6 +726,7 @@ void next_level() {
level += 1;;
get_floor_ceiling();
draw_watch.best_time = get_best_time();
load_score_times("saves/times");
v = world.uniques_index[ROOM_W]->room->ceil.items[2]->collision_poly[0];

7
src/game.h

@ -15,6 +15,12 @@ extern int level; @@ -15,6 +15,12 @@ extern int level;
extern bool in_game;
extern int quality;
struct draw_watcher {
long best_time;
};
extern struct draw_watcher draw_watch;
void handle_input_event(SDL_Event event);
// add a motor to the world
@ -38,7 +44,6 @@ struct sg_times_list { @@ -38,7 +44,6 @@ struct sg_times_list {
};
int load_score_times(char *filename);
long get_best_time(void);
/* array of all the things in the world and their kinds */

2
src/logger.c

@ -32,7 +32,7 @@ void logwrite(loggerlevel level, char message[]) { @@ -32,7 +32,7 @@ void logwrite(loggerlevel level, char message[]) {
// delete the \n
time_str[24] = ' ';
char prepend[15];
char prepend[150];
copy_str(prepend, time_str);

Loading…
Cancel
Save