Merge branch 'config' into rebuild

This commit is contained in:
Kayne Ruse
2014-07-03 02:17:44 +10:00
4 changed files with 59 additions and 16 deletions
+55 -5
View File
@@ -25,6 +25,7 @@
#include <stdexcept>
#include <chrono>
#include <iostream>
//-------------------------
//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;
}
//-------------------------
-2
View File
@@ -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;
}
+1 -5
View File
@@ -21,15 +21,12 @@
*/
#include "server_application.hpp"
#include "SDL/SDL.h"
#include <stdexcept>
#include <iostream>
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;
}
+3 -4
View File
@@ -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;
}
//-------------------------