From: Tobias Gläßer Date: Sun, 14 Mar 2004 23:45:25 +0000 (+0000) Subject: Quick hack to correct the unprecise CPU clocks a little bit. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=da3753f15dac009a478cfd7cee66b1036d4e00a3;p=supertux.git Quick hack to correct the unprecise CPU clocks a little bit. SVN-Revision: 226 --- diff --git a/src/gameloop.c b/src/gameloop.c index f4727ee36..ec0851933 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -639,6 +639,8 @@ int gameloop(char * subset, int levelnb, int mode) /* Calculate the movement-factor */ frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); + if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ + frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; if(!timer_check(&frame_timer)) { @@ -712,7 +714,7 @@ int gameloop(char * subset, int levelnb, int mode) } if(debug_mode && debug_fps == YES) - SDL_Delay(50); + SDL_Delay(60); /*Draw the current scene to the screen */ /*If the machine running the game is too slow diff --git a/src/high_scores.c b/src/high_scores.c index c209148eb..741dc6227 100644 --- a/src/high_scores.c +++ b/src/high_scores.c @@ -49,7 +49,7 @@ FILE * opendata(char * mode) if (fi == NULL) { - fprintf(stderr, "Warning: I could not open the high score file "); + fprintf(stderr, "Warning: Unable to open the high score file "); if (strcmp(mode, "r") == 0) fprintf(stderr, "for read!!!\n"); @@ -68,7 +68,7 @@ void load_hs(void) FILE * fi; char temp[128]; int c, i, strl; - + hs_score = 100; strcpy(hs_name, "Grandma\0"); c = 0; @@ -102,7 +102,7 @@ void load_hs(void) strl = strlen("name="); for(c = strl, i = 0; c < strlen(temp); ++c, ++i) hs_name[i] = temp[c]; - hs_name[i]= '\0'; + hs_name[i]= '\0'; } } } @@ -120,7 +120,7 @@ void save_hs(int score) SDL_Event event; FILE * fi; - + texture_load(&bkgd, DATA_PREFIX "/images/highscore/highscore.png", IGNORE_ALPHA); hs_score = score; @@ -129,8 +129,8 @@ void save_hs(int score) menu_set_current(&highscore_menu); if(!highscore_menu.item[0].input) - highscore_menu.item[0].input = (char*) malloc(strlen(hs_name) + 1); - + highscore_menu.item[0].input = (char*) malloc(strlen(hs_name) + 1); + strcpy(highscore_menu.item[0].input,hs_name); /* ask for player's name */ diff --git a/src/setup.c b/src/setup.c index 2498f6a75..94651c520 100644 --- a/src/setup.c +++ b/src/setup.c @@ -47,16 +47,16 @@ int faccessible(char *filename) { struct stat filestat; if (stat(filename, &filestat) == -1) - { - return NO; - } - else - { - if(S_ISREG(filestat.st_mode)) - return YES; + { + return NO; + } else - return NO; - } + { + if(S_ISREG(filestat.st_mode)) + return YES; + else + return NO; + } } /* Can we write to this location? */ @@ -259,12 +259,13 @@ void st_directory_setup(void) strlen("/.supertux") + 1)); strcpy(st_dir, home); strcat(st_dir, "/.supertux"); - + /* Remove .supertux config-file from old SuperTux versions */ if(faccessible(st_dir)) - { - remove(st_dir); - } + { + remove + (st_dir); + } st_save_dir = (char *) malloc(sizeof(char) * (strlen(st_dir) + strlen("/save") + 1)); @@ -392,11 +393,11 @@ void process_save_load_game_menu(int save) else { if(game_started == NO) - { - gameloop("default",slot - 1,ST_GL_LOAD_GAME); - show_menu = YES; - menu_set_current(&main_menu); - } + { + gameloop("default",slot - 1,ST_GL_LOAD_GAME); + show_menu = YES; + menu_set_current(&main_menu); + } else loadgame(slot - 1); } @@ -503,7 +504,7 @@ void st_general_free(void) texture_free(&back); texture_free(&arrow_left); texture_free(&arrow_right); - + /* Free menus */ menu_free(&main_menu); @@ -892,7 +893,7 @@ void parseargs(int argc, char * argv[]) use_sound = NO; #else - printf("Warning: Sounds feature is not compiled in \n"); + printf("Warning: Sound capability has not been compiled into this build.\n"); #endif }