diff -r 2a8e780844d2 -r d193dd1d8a7e src/Engine.cc --- a/src/Engine.cc Tue Dec 16 20:30:35 2008 +0000 +++ b/src/Engine.cc Tue Dec 16 23:21:26 2008 +0000 @@ -1,6 +1,8 @@ #include "Engine.hh" #include "SinglePlayer.hh" +#include "Network/Reactor.hh" +#include "Config.hh" #include @@ -41,14 +43,26 @@ } void Engine::run (void) { + // our NetworkReactor + NetworkReactor *reactor = NetworkReactor::current; + + // timeout info + timeval timeout; + while (is_running) { // this does.... magical things CL_System::keep_alive(); - - // if I can't find some better way to do this in ClanLib by next thursday, then it f*%!ing sucks - // 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(10); + + // setup our timeout to ENGINE_TIMEOUT_MS + timeout.tv_sec = 0; + timeout.tv_usec = ENGINE_TIMEOUT_MS * 1000; + + /* + * Thursday came and went, I re-wrote clan-event. + * + * We use the NetworkReactor for sleeping, as it handles it effeciently even if we're not using network. + */ + reactor->poll(&timeout); } }