Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-05 00:10:02 +0000
committerStijn Buys <ingar@osirion.org>2008-02-05 00:10:02 +0000
commit95ca0e469ef856c0182bb0da411e4417391e3780 (patch)
treea07db9b9d726d175d8305dc3cc5520b8a70f7a73 /src/client/client.cc
parentcf61370df80de6dc659dbd9b803c973b300c1b4c (diff)
renamed client and server application objects
cleaned up namespaces
Diffstat (limited to 'src/client/client.cc')
-rw-r--r--src/client/client.cc125
1 files changed, 119 insertions, 6 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index 1d29c23..556e2a7 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -4,22 +4,135 @@
the terms and conditions of the GNU General Public License version 2
*/
-#include "client/application.h"
+// project headers
+#include "client/client.h"
+#include "client/video.h"
#include "client/camera.h"
#include "client/console.h"
#include "client/input.h"
-#include "client/video.h"
#include "client/view.h"
-
+#include "core/core.h"
#include "game/game.h"
+// SDL headers
+#include <SDL/SDL.h>
+
+// C++ headers
+#include <iostream>
+#include <cmath>
+
namespace client
{
-// public instances
-Application application;
-Console console;
+//--- private definition ------------------------------------------
+/// client application implementation
+class Client : public core::ApplicationInterface
+{
+public:
+ /// initialize the client Client
+ virtual void init();
+
+ /// run the client Client
+ virtual void run();
+
+ /// shutdown the client Client
+ virtual void shutdown();
+
+ /// quit the client Client
+ virtual void quit(int status);
+};
+
+Client app;
+
+//--- public ------------------------------------------------------
game::Game game;
+void main(int count, char **arguments)
+{
+ std::cout << "The Osirion Project " << VERSION << std::endl;
+ for (int i =0; i < count; i++)
+ std::cout << arguments[i] << " ";
+ std::cout << std::endl;
+
+ app.init();
+ app.run();
+ app.shutdown();
+}
+
+//--- private -----------------------------------------------------
+
+void Client::quit(int status)
+{
+ SDL_Quit();
+ core::ApplicationInterface::quit(status);
+}
+
+void Client::init()
+{
+ con_print << "Initializing client..." << std::endl;
+ // initialize core
+ core::ApplicationInterface::init();
+
+ // Initialize the video subsystem
+ if (!client::video::init())
+ quit(1);
+
+ // initialize console
+ console::init();
+
+ // initialize input
+ input::init();
+}
+
+void Client::run()
+{
+ con_print << "Running client..." << std::endl;
+
+ Uint32 chrono = SDL_GetTicks();
+
+ while (true) {
+ Uint32 current = SDL_GetTicks();
+
+ // overflow protection ~49 days
+ if (current < chrono) {
+ chrono = current;
+ }
+
+ // run a core frame
+ float seconds = ((float)(current - chrono)) / 1000.0f;
+ core::ApplicationInterface::frame(seconds);
+
+ // run a video frame
+ video::frame(seconds);
+
+ // process input
+ input::frame(seconds);
+
+ // update the main loop chronometer
+ chrono = current;
+ }
+
+}
+
+void Client::shutdown()
+{
+ con_print << "Shutting down client..." << std::endl;
+ console::flush();
+
+ console::shutdown();
+ console::flush();
+
+ input::shutdown();
+ console::flush();
+
+ video::shutdown();
+ console::flush();
+
+ core::ApplicationInterface::shutdown();
+ console::flush();
+
+ quit(0);
+}
+
} // namespace client