diff --git a/client/client_application.cpp b/client/client_application.cpp index 06f0bc6..95f529c 100644 --- a/client/client_application.cpp +++ b/client/client_application.cpp @@ -25,6 +25,7 @@ #include #include +#include //------------------------- //Scene headers @@ -44,24 +45,71 @@ //------------------------- void ClientApplication::Init(int argc, char** argv) { + std::cout << "Beginning " << argv[0] << std::endl; + //load the prerequisites config.Load("rsc\\config.cfg"); + //------------------------- + //Initialize the APIs + //------------------------- + //initialize SDL if (SDL_Init(SDL_INIT_VIDEO)) { throw(std::runtime_error("Failed to initialize SDL")); } - int w = config.Int("client.screen.w"); - int h = config.Int("client.screen.h"); - int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF; - - BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f); + std::cout << "Initialized SDL" << std::endl; //initialize SDL_net if (SDLNet_Init()) { throw(std::runtime_error("Failed to initialize SDL_net")); } network.Open(0); + std::cout << "Initialized SDL_net" << std::endl; + + //------------------------- + //Setup the screen + //------------------------- + + int w = config.Int("client.screen.w"); + int h = config.Int("client.screen.h"); + int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF; + + BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f); + std::cout << "Initialized the screen" << std::endl; + + //------------------------- + //debug output + //------------------------- + + //TODO: enable/disable these with a switch +#define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl; + + std::cout << "Internal sizes:" << std::endl; + + DEBUG_OUTPUT_VAR(sizeof(Region::type_t)); + DEBUG_OUTPUT_VAR(sizeof(Region)); + DEBUG_OUTPUT_VAR(REGION_WIDTH); + DEBUG_OUTPUT_VAR(REGION_HEIGHT); + DEBUG_OUTPUT_VAR(REGION_DEPTH); + DEBUG_OUTPUT_VAR(REGION_SOLID_FOOTPRINT); + DEBUG_OUTPUT_VAR(REGION_FOOTPRINT); + DEBUG_OUTPUT_VAR(PACKET_BUFFER_SIZE); + DEBUG_OUTPUT_VAR(MAX_PACKET_SIZE); + +#undef DEBUG_OUTPUT_VAR + + //------------------------- + //finalize the startup + //------------------------- + + std::cout << "Startup completed successfully" << std::endl; + + //------------------------- + //debugging + //------------------------- + + //... } void ClientApplication::Proc() { @@ -100,9 +148,11 @@ void ClientApplication::Proc() { } void ClientApplication::Quit() { + std::cout << "Shutting down" << std::endl; network.Close(); SDLNet_Quit(); SDL_Quit(); + std::cout << "Clean exit" << std::endl; } //------------------------- diff --git a/client/main.cpp b/client/main.cpp index 9ec652c..156adff 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -27,7 +27,6 @@ using namespace std; int main(int argc, char** argv) { - cout << "Beginning client" << endl; try { ClientApplication app; app.Init(argc, argv); @@ -38,6 +37,5 @@ int main(int argc, char** argv) { cerr << "Fatal exception thrown: " << e.what() << endl; return 1; } - cout << "Clean exit" << endl; return 0; } diff --git a/server/main.cpp b/server/main.cpp index 288e10f..5c01971 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -21,15 +21,12 @@ */ #include "server_application.hpp" -#include "SDL/SDL.h" - #include #include using namespace std; int main(int argc, char** argv) { - cout << "Beginning server" << endl; try { ServerApplication app; app.Init(argc, argv); @@ -37,9 +34,8 @@ int main(int argc, char** argv) { app.Quit(); } catch(exception& e) { - cerr << "Fatal error: " << e.what() << endl; + cerr << "Fatal exception thrown: " << e.what() << endl; return 1; } - cout << "Clean exit" << endl; return 0; } \ No newline at end of file diff --git a/server/server_application.cpp b/server/server_application.cpp index 0a4ebc0..99179c4 100644 --- a/server/server_application.cpp +++ b/server/server_application.cpp @@ -38,9 +38,9 @@ void ServerApplication::Init(int argc, char** argv) { //NOTE: I might need to rearrange the init process so that lua & SQL can interact with the map system as needed. - std::cout << "Beginning startup" << std::endl; + std::cout << "Beginning " << argv[0] << std::endl; - //initial setup + //load the prerequisites config.Load("rsc\\config.cfg"); //------------------------- @@ -114,7 +114,6 @@ void ServerApplication::Init(int argc, char** argv) { //debug output //------------------------- - //TODO: put these outputs into the client too //TODO: enable/disable these with a switch #define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl; @@ -179,7 +178,7 @@ void ServerApplication::Quit() { SDLNet_Quit(); SDL_Quit(); - std::cout << "Shutdown finished" << std::endl; + std::cout << "Clean exit" << std::endl; } //-------------------------