hopefully version stuff is now run properly on every make...
#include "Engine.hh"
#include "SinglePlayer.hh"
#include "Network/Reactor.hh"
#include "Config.hh"
#include <iostream>
Engine::Engine (const std::string resource_xml_path) :
is_running(true), resources(resource_xml_path)
{
}
void Engine::setupGraphics (PixelCoordinate resolution, bool fullscreen) {
// create the graphics
graphics = new Graphics(*this, game_state, resolution, fullscreen);
}
void Engine::setupNetworkServer (const std::string &listen_port) {
NetworkEndpoint listen_addr(listen_port);
// create the server
net_server = new NetworkServer(game_state, listen_addr);
}
void Engine::setupNetworkClient (const std::string &connect_host, const std::string &connect_port) {
// connect_to
NetworkEndpoint connect_addr(connect_host, connect_port);
// create the client
net_client = new NetworkClient(*this, game_state, connect_addr);
}
void Engine::setupSinglePlayer (void) {
// create player directly
LocalPlayer* lp = new SinglePlayer(game_state);
// add to gamestate
game_state.setLocalPlayer(lp);
}
void Engine::stop (void) {
is_running = false;
}
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();
// 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);
}
}
CL_ResourceManager* Engine::getResourceManager (void) {
return &resources;
}
Logger Engine::log (enum LogLevel level, const char *type) {
return Logger(level <= WARN ? std::cerr : std::cout, level, type);
}