summaryrefslogtreecommitdiffhomepage
path: root/StarsEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-04 22:28:16 +0200
committerAki <please@ignore.pl>2022-04-04 22:28:16 +0200
commit1bc6242caac5261dfd74be55027aa033f7a297a4 (patch)
treea4439aa20f59eb12fe8fdfd093014bd019892934 /StarsEx
parent4cc312f90d27ea7abb010bd317188d9d08a9fd3e (diff)
downloadstarshatter-1bc6242caac5261dfd74be55027aa033f7a297a4.zip
starshatter-1bc6242caac5261dfd74be55027aa033f7a297a4.tar.gz
starshatter-1bc6242caac5261dfd74be55027aa033f7a297a4.tar.bz2
Streamlined game loops
Diffstat (limited to 'StarsEx')
-rw-r--r--StarsEx/Game.cpp33
-rw-r--r--StarsEx/Game.h2
-rw-r--r--StarsEx/GameWinDX9.cpp3
-rw-r--r--StarsEx/StarServer.cpp22
-rw-r--r--StarsEx/StarServer.h1
-rw-r--r--StarsEx/Starshatter.cpp37
-rw-r--r--StarsEx/Starshatter.h1
7 files changed, 10 insertions, 89 deletions
diff --git a/StarsEx/Game.cpp b/StarsEx/Game.cpp
index 4fda01e..41375f9 100644
--- a/StarsEx/Game.cpp
+++ b/StarsEx/Game.cpp
@@ -136,37 +136,20 @@ Game::Pause(bool f)
// +--------------------------------------------------------------------+
-bool
+void
Game::GameLoop()
{
- bool wait_for_windows_events = true;
-
- if (active && !paused) {
- if (!server) {
- // Route Events to EventTargets
- EventDispatch* ed = EventDispatch::GetInstance();
- if (ed)
- ed->Dispatch();
- }
-
- UpdateWorld();
- GameState();
-
- if (!server) {
- UpdateScreen();
- }
-
- wait_for_windows_events = false;
+ if (active) {
+ auto dispatch = EventDispatch::GetInstance();
+ if (dispatch)
+ dispatch->Dispatch();
}
- else if (active && paused) {
- if (GetKey()=='P')
- Pause(false);
- }
-
+ UpdateWorld();
+ GameState();
+ UpdateScreen();
Clock::GetInstance()->Step();
frame_number++;
Mouse::w = 0;
- return wait_for_windows_events;
}
// +--------------------------------------------------------------------+
diff --git a/StarsEx/Game.h b/StarsEx/Game.h
index cf62744..6f5936e 100644
--- a/StarsEx/Game.h
+++ b/StarsEx/Game.h
@@ -70,7 +70,7 @@ public:
bool Server() { return server; }
bool ShowMouse() { return show_mouse; }
- virtual bool GameLoop();
+ virtual void GameLoop();
virtual void UpdateWorld();
virtual void GameState();
virtual void UpdateScreen();
diff --git a/StarsEx/GameWinDX9.cpp b/StarsEx/GameWinDX9.cpp
index 2e1aabc..6e779c7 100644
--- a/StarsEx/GameWinDX9.cpp
+++ b/StarsEx/GameWinDX9.cpp
@@ -583,8 +583,7 @@ GameWinDX9::Run()
DispatchMessage(&msg);
}
else {
- if (GameLoop())
- WaitMessage();
+ GameLoop();
}
}
return exit_code ? exit_code : msg.wParam;
diff --git a/StarsEx/StarServer.cpp b/StarsEx/StarServer.cpp
index 2d24bde..fa0743d 100644
--- a/StarsEx/StarServer.cpp
+++ b/StarsEx/StarServer.cpp
@@ -291,28 +291,6 @@ StarServer::InstantiateMission()
// +--------------------------------------------------------------------+
-bool
-StarServer::GameLoop()
-{
- if (active && paused) {
- UpdateWorld();
- GameState();
- }
-
- else if (!active) {
- UpdateWorld();
- GameState();
- Sleep(10);
- }
-
- Game::GameLoop();
- return false; // must return false to keep processing
- // true tells the outer loop to sleep until a
- // windows event is available
-}
-
-// +--------------------------------------------------------------------+
-
void
StarServer::UpdateWorld()
{
diff --git a/StarsEx/StarServer.h b/StarsEx/StarServer.h
index 3e8a722..fa4828d 100644
--- a/StarsEx/StarServer.h
+++ b/StarsEx/StarServer.h
@@ -51,7 +51,6 @@ public:
protected:
- virtual bool GameLoop();
virtual void UpdateWorld();
virtual void InstantiateMission();
diff --git a/StarsEx/Starshatter.cpp b/StarsEx/Starshatter.cpp
index 415a04b..cc36461 100644
--- a/StarsEx/Starshatter.cpp
+++ b/StarsEx/Starshatter.cpp
@@ -789,43 +789,6 @@ Starshatter::KeyDown(int action) const
// +--------------------------------------------------------------------+
-bool
-Starshatter::GameLoop()
-{
- cam_dir = CameraDirector::GetInstance();
-
- if (active && paused) {
- // Route Events to EventTargets
- EventDispatch* ed = EventDispatch::GetInstance();
- if (ed)
- ed->Dispatch();
-
- UpdateWorld();
- GameState();
- UpdateScreen();
-
- /***
- static DWORD vmf_time = 0;
-
- if (real_time() - vmf_time > 5000) {
- vmf_time = real_time();
- DWORD vmf = video->VidMemFree() / (1024 * 1024);
- ::Print("\n###### %02d:%02d - Video Memory Free: %d MB\n\n",
- vmf_time / 60000,
- vmf_time / 1000,
- vmf);
- }
- ***/
- }
-
- Game::GameLoop();
- return false; // must return false to keep processing
- // true tells the outer loop to sleep until a
- // windows event is available
-}
-
-// +--------------------------------------------------------------------+
-
void
Starshatter::UpdateWorld()
{
diff --git a/StarsEx/Starshatter.h b/StarsEx/Starshatter.h
index ed800fc..75f5d0d 100644
--- a/StarsEx/Starshatter.h
+++ b/StarsEx/Starshatter.h
@@ -128,7 +128,6 @@ protected:
virtual void DoChatMode();
virtual void DoGameKeys();
- virtual bool GameLoop();
virtual void UpdateWorld();
virtual void InstantiateMission();
virtual bool ResizeVideo();