mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r2748) Remove unused cruft from the main loop
This commit is contained in:
parent
1a5de9ff9b
commit
f359d1a394
7
hal.h
7
hal.h
|
@ -12,16 +12,11 @@ typedef struct {
|
||||||
const char *(*start)(const char * const *parm);
|
const char *(*start)(const char * const *parm);
|
||||||
void (*stop)(void);
|
void (*stop)(void);
|
||||||
void (*make_dirty)(int left, int top, int width, int height);
|
void (*make_dirty)(int left, int top, int width, int height);
|
||||||
int (*main_loop)(void);
|
void (*main_loop)(void);
|
||||||
bool (*change_resolution)(int w, int h);
|
bool (*change_resolution)(int w, int h);
|
||||||
void (*toggle_fullscreen)(bool fullscreen);
|
void (*toggle_fullscreen)(bool fullscreen);
|
||||||
} HalVideoDriver;
|
} HalVideoDriver;
|
||||||
|
|
||||||
enum {
|
|
||||||
ML_QUIT = 0,
|
|
||||||
ML_SWITCHDRIVER = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *(*start)(const char * const *parm);
|
const char *(*start)(const char * const *parm);
|
||||||
void (*stop)(void);
|
void (*stop)(void);
|
||||||
|
|
|
@ -521,7 +521,7 @@ int ttd_main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
while (_video_driver->main_loop() == ML_SWITCHDRIVER) {}
|
_video_driver->main_loop();
|
||||||
|
|
||||||
JoinOTTDThread();
|
JoinOTTDThread();
|
||||||
IConsoleFree();
|
IConsoleFree();
|
||||||
|
|
|
@ -215,7 +215,7 @@ static void DedicatedHandleKeyInput(void)
|
||||||
IConsoleCmdExec(input_line); // execute command
|
IConsoleCmdExec(input_line); // execute command
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DedicatedVideoMainLoop(void)
|
static void DedicatedVideoMainLoop(void)
|
||||||
{
|
{
|
||||||
uint32 next_tick;
|
uint32 next_tick;
|
||||||
uint32 cur_ticks;
|
uint32 cur_ticks;
|
||||||
|
@ -257,14 +257,12 @@ static int DedicatedVideoMainLoop(void)
|
||||||
|
|
||||||
if (!_networking) {
|
if (!_networking) {
|
||||||
DEBUG(net, 1)("Dedicated server could not be launched. Aborting.");
|
DEBUG(net, 1)("Dedicated server could not be launched. Aborting.");
|
||||||
return ML_QUIT;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (!_exit_game) {
|
||||||
InteractiveRandom(); // randomness
|
InteractiveRandom(); // randomness
|
||||||
|
|
||||||
if (_exit_game) return ML_QUIT;
|
|
||||||
|
|
||||||
if (!_dedicated_forks)
|
if (!_dedicated_forks)
|
||||||
DedicatedHandleKeyInput();
|
DedicatedHandleKeyInput();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ static void NullVideoStop(void) { free(_null_video_mem); }
|
||||||
|
|
||||||
static void NullVideoMakeDirty(int left, int top, int width, int height) {}
|
static void NullVideoMakeDirty(int left, int top, int width, int height) {}
|
||||||
|
|
||||||
static int NullVideoMainLoop(void)
|
static void NullVideoMainLoop(void)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ static int NullVideoMainLoop(void)
|
||||||
_screen.dst_ptr = _null_video_mem;
|
_screen.dst_ptr = _null_video_mem;
|
||||||
UpdateWindows();
|
UpdateWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ML_QUIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool NullVideoChangeRes(int w, int h) { return false; }
|
static bool NullVideoChangeRes(int w, int h) { return false; }
|
||||||
|
|
|
@ -350,11 +350,11 @@ static int PollEvent(void)
|
||||||
if (_game_mode != GM_MENU) {
|
if (_game_mode != GM_MENU) {
|
||||||
if(_patches.autosave_on_exit) {
|
if(_patches.autosave_on_exit) {
|
||||||
DoExitSave();
|
DoExitSave();
|
||||||
return ML_QUIT;
|
return 0;
|
||||||
} else
|
} else
|
||||||
AskExitGame();
|
AskExitGame();
|
||||||
} else
|
} else
|
||||||
return ML_QUIT;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN: /* Toggle full-screen on ALT + ENTER/F */
|
case SDL_KEYDOWN: /* Toggle full-screen on ALT + ENTER/F */
|
||||||
|
@ -400,7 +400,7 @@ static void SdlVideoStop(void)
|
||||||
SdlClose(SDL_INIT_VIDEO);
|
SdlClose(SDL_INIT_VIDEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SdlVideoMainLoop(void)
|
static void SdlVideoMainLoop(void)
|
||||||
{
|
{
|
||||||
uint32 next_tick = SDL_CALL SDL_GetTicks() + 30;
|
uint32 next_tick = SDL_CALL SDL_GetTicks() + 30;
|
||||||
uint32 cur_ticks;
|
uint32 cur_ticks;
|
||||||
|
@ -414,9 +414,9 @@ static int SdlVideoMainLoop(void)
|
||||||
InteractiveRandom(); // randomness
|
InteractiveRandom(); // randomness
|
||||||
|
|
||||||
while ((i = PollEvent()) == -1) {}
|
while ((i = PollEvent()) == -1) {}
|
||||||
if (i >= 0) return i;
|
if (i >= 0) return;
|
||||||
|
|
||||||
if (_exit_game) return ML_QUIT;
|
if (_exit_game) return;
|
||||||
|
|
||||||
mod = SDL_CALL SDL_GetModState();
|
mod = SDL_CALL SDL_GetModState();
|
||||||
keys = SDL_CALL SDL_GetKeyState(&numkeys);
|
keys = SDL_CALL SDL_GetKeyState(&numkeys);
|
||||||
|
|
|
@ -21,7 +21,6 @@ static struct {
|
||||||
HPALETTE gdi_palette;
|
HPALETTE gdi_palette;
|
||||||
int width,height;
|
int width,height;
|
||||||
int width_org, height_org;
|
int width_org, height_org;
|
||||||
bool switch_driver;
|
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool double_size;
|
bool double_size;
|
||||||
bool has_focus;
|
bool has_focus;
|
||||||
|
@ -698,7 +697,7 @@ static void CheckPaletteAnim(void)
|
||||||
InvalidateRect(_wnd.main_wnd, NULL, FALSE);
|
InvalidateRect(_wnd.main_wnd, NULL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Win32GdiMainLoop(void)
|
static void Win32GdiMainLoop(void)
|
||||||
{
|
{
|
||||||
MSG mesg;
|
MSG mesg;
|
||||||
uint32 next_tick = GetTickCount() + 30, cur_ticks;
|
uint32 next_tick = GetTickCount() + 30, cur_ticks;
|
||||||
|
@ -711,8 +710,7 @@ static int Win32GdiMainLoop(void)
|
||||||
TranslateMessage(&mesg);
|
TranslateMessage(&mesg);
|
||||||
DispatchMessage(&mesg);
|
DispatchMessage(&mesg);
|
||||||
}
|
}
|
||||||
if (_exit_game) return ML_QUIT;
|
if (_exit_game) return;
|
||||||
if (_wnd.switch_driver) return ML_SWITCHDRIVER;
|
|
||||||
|
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
if (_wnd.has_focus && GetAsyncKeyState(VK_SHIFT) < 0) {
|
if (_wnd.has_focus && GetAsyncKeyState(VK_SHIFT) < 0) {
|
||||||
|
|
Loading…
Reference in New Issue