src/proto2/Engine.cc
changeset 25 af75a1894a32
parent 24 b81cb670e6b2
child 28 3da59a3bc92e
--- a/src/proto2/Engine.cc	Sun Nov 09 20:40:46 2008 +0000
+++ b/src/proto2/Engine.cc	Sun Nov 09 21:51:13 2008 +0000
@@ -1,6 +1,5 @@
 
 #include "Engine.hh"
-#include "GameState.hh"
 #include "NetworkServer.hh"
 #include "NetworkClient.hh"
 
@@ -10,53 +9,29 @@
 
 }
 
-void Engine::runNetworkServer (const std::string &listen_port) {
-    // the engine
-    Engine engine;
-    
-    // setup network
-    CL_SetupNetwork setup_network;
-
-    try {
-        // create the server
-        engine.net_server = new NetworkServer(engine.game_state, listen_port);
-
-        // run the main loop
-        engine.main_loop();
-    
-    } catch (CL_Error &e) {
-        std::cerr << "NetworkServer::main: CL_Error:" << e.message << std::endl;
-
-        throw;
-    }
+void Engine::setupGraphics (void) {
+    // create the graphics
+    graphics = new Graphics(*this, game_state);
 }
 
-void Engine::runNetworkClient (const std::string &connect_host, const std::string &connect_port) {
-    // the engine
-    Engine engine;
-    
-    // setup network
-    CL_SetupNetwork setup_network;
+void Engine::setupNetworkServer (const std::string &listen_port) {
+    // create the server
+    net_server = new NetworkServer(game_state, listen_port);
+}
 
+void Engine::setupNetworkClient (const std::string &connect_host, const std::string &connect_port) {
     // connect_to
     CL_IPAddress connect_addr(connect_host, connect_port);
 
-    try {
-        // create the server
-        engine.net_client = new NetworkClient(engine.game_state, connect_addr);
-
-        // run the main loop
-        engine.main_loop();
-    
-    } catch (CL_Error &e) {
-        std::cerr << "NetworkServer::main: CL_Error:" << e.message << std::endl;
-
-        throw;
-    }
-
+    // create the client
+    net_client = new NetworkClient(game_state, connect_addr);
 }
 
-void Engine::main_loop (void) {
+void Engine::stop (void) {
+    is_running = false;
+}
+
+void Engine::run (void) {
     while (is_running) {
         // this does.... magical things
         CL_System::keep_alive();
@@ -65,7 +40,6 @@
         // ideally, we should be able to have a main loop that does timed waits on I/O, fufilling some set of timers
         // but as far as I can tell, ClanLib doesn't have anything like that
         CL_System::sleep(100);
-
     }
 }