Revert "Set fps limit for main menu and game."

This reverts commit aa178f8fae.
This commit is contained in:
Евгений 2022-05-22 19:20:56 +04:00
parent 725f5283e5
commit 4921424c7d
5 changed files with 7 additions and 55 deletions

View File

@ -226,7 +226,6 @@ add_executable(fallout2-ce WIN32
"src/world_map.h" "src/world_map.h"
"src/xfile.cc" "src/xfile.cc"
"src/xfile.h" "src/xfile.h"
"src/FpsLimiter.cc"
) )
target_compile_definitions(fallout2-ce PUBLIC target_compile_definitions(fallout2-ce PUBLIC

View File

@ -1,18 +0,0 @@
#include "FpsLimiter.h"
FpsLimiter::FpsLimiter(size_t fps):
_Fps(fps),
_Ticks(0)
{
}
void FpsLimiter::Begin()
{
_Ticks = SDL_GetTicks();
}
void FpsLimiter::End()
{
if (1000 / _Fps > SDL_GetTicks() - _Ticks)
SDL_Delay(1000 / _Fps - (SDL_GetTicks() - _Ticks));
}

View File

@ -1,18 +0,0 @@
#ifndef Fallout2_RE_FpsLimiter_h_
#define Fallout2_RE_FpsLimiter_h_
#include <SDL.h>
class FpsLimiter
{
public:
FpsLimiter(size_t fps = 60);
void Begin();
void End();
private:
size_t _Fps;
size_t _Ticks;
};
#endif

View File

@ -130,8 +130,6 @@ int falloutMain(int argc, char** argv)
gameMoviePlay(MOVIE_INTRO, 0); gameMoviePlay(MOVIE_INTRO, 0);
gameMoviePlay(MOVIE_CREDITS, 0); gameMoviePlay(MOVIE_CREDITS, 0);
FpsLimiter fpsLimiter;
if (mainMenuWindowInit() == 0) { if (mainMenuWindowInit() == 0) {
bool done = false; bool done = false;
while (!done) { while (!done) {
@ -140,7 +138,7 @@ int falloutMain(int argc, char** argv)
mainMenuWindowUnhide(1); mainMenuWindowUnhide(1);
mouseShowCursor(); mouseShowCursor();
int mainMenuRc = mainMenuWindowHandleEvents(fpsLimiter); int mainMenuRc = mainMenuWindowHandleEvents();
mouseHideCursor(); mouseHideCursor();
switch (mainMenuRc) { switch (mainMenuRc) {
@ -156,7 +154,7 @@ int falloutMain(int argc, char** argv)
gameMoviePlay(MOVIE_ELDER, GAME_MOVIE_STOP_MUSIC); gameMoviePlay(MOVIE_ELDER, GAME_MOVIE_STOP_MUSIC);
randomSeedPrerandom(-1); randomSeedPrerandom(-1);
_main_load_new(_mainMap); _main_load_new(_mainMap);
mainLoop(fpsLimiter); mainLoop();
paletteFadeTo(gPaletteWhite); paletteFadeTo(gPaletteWhite);
objectHide(gDude, NULL); objectHide(gDude, NULL);
_map_exit(); _map_exit();
@ -191,7 +189,7 @@ int falloutMain(int argc, char** argv)
} else if (loadGameRc != 0) { } else if (loadGameRc != 0) {
windowDestroy(win); windowDestroy(win);
win = -1; win = -1;
mainLoop(fpsLimiter); mainLoop();
} }
paletteFadeTo(gPaletteWhite); paletteFadeTo(gPaletteWhite);
if (win != -1) { if (win != -1) {
@ -300,7 +298,7 @@ int _main_load_new(char* mapFileName)
} }
// 0x480E48 // 0x480E48
void mainLoop(FpsLimiter& fpsLimiter) void mainLoop()
{ {
bool cursorWasHidden = cursorIsHidden(); bool cursorWasHidden = cursorIsHidden();
if (cursorWasHidden) { if (cursorWasHidden) {
@ -312,8 +310,6 @@ void mainLoop(FpsLimiter& fpsLimiter)
scriptsEnable(); scriptsEnable();
while (_game_user_wants_to_quit == 0) { while (_game_user_wants_to_quit == 0) {
fpsLimiter.Begin();
int keyCode = _get_input(); int keyCode = _get_input();
gameHandleKey(keyCode, false); gameHandleKey(keyCode, false);
@ -330,8 +326,6 @@ void mainLoop(FpsLimiter& fpsLimiter)
_main_show_death_scene = 1; _main_show_death_scene = 1;
_game_user_wants_to_quit = 2; _game_user_wants_to_quit = 2;
} }
fpsLimiter.End();
} }
scriptsDisable(); scriptsDisable();
@ -765,7 +759,7 @@ int _main_menu_is_enabled()
} }
// 0x481AEC // 0x481AEC
int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter) int mainMenuWindowHandleEvents()
{ {
_in_main_menu = true; _in_main_menu = true;
@ -778,8 +772,6 @@ int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter)
int rc = -1; int rc = -1;
while (rc == -1) { while (rc == -1) {
fpsLimiter.Begin();
int keyCode = _get_input(); int keyCode = _get_input();
for (int buttonIndex = 0; buttonIndex < MAIN_MENU_BUTTON_COUNT; buttonIndex++) { for (int buttonIndex = 0; buttonIndex < MAIN_MENU_BUTTON_COUNT; buttonIndex++) {
@ -826,8 +818,6 @@ int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter)
rc = MAIN_MENU_TIMEOUT; rc = MAIN_MENU_TIMEOUT;
} }
} }
fpsLimiter.End();
} }
if (oldCursorIsHidden) { if (oldCursorIsHidden) {

View File

@ -2,7 +2,6 @@
#define MAIN_H #define MAIN_H
#include "art.h" #include "art.h"
#include "FpsLimiter.h"
#include <stdbool.h> #include <stdbool.h>
@ -56,7 +55,7 @@ extern CacheEntry* gMainMenuBackgroundFrmHandle;
int falloutMain(int argc, char** argv); int falloutMain(int argc, char** argv);
bool falloutInit(int argc, char** argv); bool falloutInit(int argc, char** argv);
int _main_load_new(char* fname); int _main_load_new(char* fname);
void mainLoop(FpsLimiter& fpsLimiter); void mainLoop();
void _main_selfrun_exit(); void _main_selfrun_exit();
void showDeath(); void showDeath();
void _main_death_voiceover_callback(); void _main_death_voiceover_callback();
@ -67,6 +66,6 @@ void mainMenuWindowFree();
void mainMenuWindowHide(bool animate); void mainMenuWindowHide(bool animate);
void mainMenuWindowUnhide(bool animate); void mainMenuWindowUnhide(bool animate);
int _main_menu_is_enabled(); int _main_menu_is_enabled();
int mainMenuWindowHandleEvents(FpsLimiter& fpsLimiter); int mainMenuWindowHandleEvents();
#endif /* MAIN_H */ #endif /* MAIN_H */