UDPNetworkUtility is a singleton, disabled InCombat scene

I found incombat to be way too finicky to keep up to date, so I disabled
it for now.
This commit is contained in:
Kayne Ruse
2014-08-13 06:53:43 +10:00
parent 182101b592
commit 74f809a801
15 changed files with 41 additions and 42 deletions
+9 -9
View File
@@ -38,7 +38,7 @@
#include "options_menu.hpp"
#include "lobby_menu.hpp"
#include "in_world.hpp"
#include "in_combat.hpp"
//#include "in_combat.hpp"
#include "clean_up.hpp"
//-------------------------
@@ -66,7 +66,7 @@ void ClientApplication::Init(int argc, char** argv) {
if (SDLNet_Init()) {
throw(std::runtime_error("Failed to initialize SDL_net"));
}
network.Open(0);
UDPNetworkUtility::GetSingleton().Open(0);
std::cout << "Initialized SDL_net" << std::endl;
//-------------------------
@@ -151,7 +151,7 @@ void ClientApplication::Proc() {
void ClientApplication::Quit() {
std::cout << "Shutting down" << std::endl;
network.Close();
UDPNetworkUtility::GetSingleton().Close();
SDLNet_Quit();
SDL_Quit();
std::cout << "Clean exit" << std::endl;
@@ -176,16 +176,16 @@ void ClientApplication::LoadScene(SceneList sceneIndex) {
activeScene = new OptionsMenu();
break;
case SceneList::LOBBYMENU:
activeScene = new LobbyMenu(&network, &clientIndex, &accountIndex);
activeScene = new LobbyMenu(&clientIndex, &accountIndex);
break;
case SceneList::INWORLD:
activeScene = new InWorld(&network, &clientIndex, &accountIndex, &characterIndex, &characterMap);
break;
case SceneList::INCOMBAT:
activeScene = new InCombat(&network, &clientIndex, &accountIndex, &characterIndex, &characterMap);
activeScene = new InWorld(&clientIndex, &accountIndex, &characterIndex, &characterMap);
break;
// case SceneList::INCOMBAT:
// activeScene = new InCombat(&clientIndex, &accountIndex, &characterIndex, &characterMap);
// break;
case SceneList::CLEANUP:
activeScene = new CleanUp(&network, &clientIndex, &accountIndex, &characterIndex, &characterMap);
activeScene = new CleanUp(&clientIndex, &accountIndex, &characterIndex, &characterMap);
break;
default:
throw(std::logic_error("Failed to recognize the scene index"));
-1
View File
@@ -52,7 +52,6 @@ private:
BaseScene* activeScene = nullptr;
//shared parameters
UDPNetworkUtility network;
int clientIndex = -1;
int accountIndex = -1;
int characterIndex = -1;
+7 -2
View File
@@ -23,6 +23,7 @@
//singletons
#include "config_utility.hpp"
#include "udp_network_utility.hpp"
#include <stdexcept>
#include <iostream>
@@ -32,18 +33,22 @@ using namespace std;
int main(int argc, char** argv) {
try {
//create the singletons
ClientApplication::Create();
ConfigUtility::Create();
UDPNetworkUtility::Create();
//call the server's routines
ClientApplication::Create();
ClientApplication& app = ClientApplication::GetSingleton();
app.Init(argc, argv);
app.Proc();
app.Quit();
ClientApplication::Delete();
//delete the singletons
ConfigUtility::Delete();
ClientApplication::Delete();
UDPNetworkUtility::Delete();
}
catch(exception& e) {
cerr << "Fatal exception thrown: " << e.what() << endl;
-2
View File
@@ -31,13 +31,11 @@
//-------------------------
CleanUp::CleanUp(
UDPNetworkUtility* const argNetwork,
int* const argClientIndex,
int* const argAccountIndex,
int* const argCharacterIndex,
CharacterMap* argCharacterMap
):
network(*argNetwork),
clientIndex(*argClientIndex),
accountIndex(*argAccountIndex),
characterIndex(*argCharacterIndex),
+1 -2
View File
@@ -45,7 +45,6 @@ class CleanUp : public BaseScene {
public:
//Public access members
CleanUp(
UDPNetworkUtility* const argNetwork,
int* const argClientIndex,
int* const argAccountIndex,
int* const argCharacterIndex,
@@ -68,7 +67,7 @@ protected:
void KeyUp(SDL_KeyboardEvent const&);
//shared parameters
UDPNetworkUtility& network;
UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton();
int& clientIndex;
int& accountIndex;
int& characterIndex;
-2
View File
@@ -35,13 +35,11 @@
//-------------------------
InWorld::InWorld(
UDPNetworkUtility* const argNetwork,
int* const argClientIndex,
int* const argAccountIndex,
int* const argCharacterIndex,
CharacterMap* argCharacterMap
):
network(*argNetwork),
clientIndex(*argClientIndex),
accountIndex(*argAccountIndex),
characterIndex(*argCharacterIndex),
+1 -2
View File
@@ -49,7 +49,6 @@ class InWorld : public BaseScene {
public:
//Public access members
InWorld(
UDPNetworkUtility* const argNetwork,
int* const argClientIndex,
int* const argAccountIndex,
int* const argCharacterIndex,
@@ -92,7 +91,7 @@ protected:
void UpdateMap();
//shared parameters
UDPNetworkUtility& network;
UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton();
int& clientIndex;
int& accountIndex;
int& characterIndex;
+1 -6
View File
@@ -30,12 +30,7 @@
//Public access members
//-------------------------
LobbyMenu::LobbyMenu(
UDPNetworkUtility* const argNetwork,
int* const argClientIndex,
int* const argAccountIndex
):
network(*argNetwork),
LobbyMenu::LobbyMenu(int* const argClientIndex, int* const argAccountIndex):
clientIndex(*argClientIndex),
accountIndex(*argAccountIndex)
{
+2 -6
View File
@@ -40,11 +40,7 @@
class LobbyMenu : public BaseScene {
public:
//Public access members
LobbyMenu(
UDPNetworkUtility* const argNetwork,
int* const argClientIndex,
int* const argAccountIndex
);
LobbyMenu(int* const argClientIndex, int* const argAccountIndex);
~LobbyMenu();
protected:
@@ -68,7 +64,7 @@ protected:
//shared parameters
ConfigUtility& config = ConfigUtility::GetSingleton();
UDPNetworkUtility& network;
UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton();
int& clientIndex;
int& accountIndex;
+1 -1
View File
@@ -25,7 +25,7 @@
#include <stdexcept>
//NOTE: memset() is used before sending a packet to remove old data; you don't want to send sensitive data over the network
//BUGFIX: memset() is used before sending a packet to remove old data; you don't want to send sensitive data over the network
//NOTE: don't confuse SerialPacket with UDPpacket
void UDPNetworkUtility::Open(int port) {
+11 -6
View File
@@ -22,15 +22,15 @@
#ifndef UDPNETWORKUTILITY_HPP_
#define UDPNETWORKUTILITY_HPP_
//common
#include "serial_packet.hpp"
#include "singleton.hpp"
//APIs
#include "SDL/SDL_net.h"
#include "serial_packet.hpp"
class UDPNetworkUtility {
class UDPNetworkUtility : public Singleton<UDPNetworkUtility> {
public:
UDPNetworkUtility() = default;
~UDPNetworkUtility() = default;
void Open(int port);
void Close();
@@ -65,6 +65,11 @@ public:
return socket;
}
private:
friend Singleton<UDPNetworkUtility>;
UDPNetworkUtility() = default;
~UDPNetworkUtility() = default;
UDPsocket socket = nullptr;
UDPpacket* packet = nullptr;
};
+7 -2
View File
@@ -23,6 +23,7 @@
//singletons
#include "config_utility.hpp"
#include "udp_network_utility.hpp"
#include <stdexcept>
#include <iostream>
@@ -33,17 +34,21 @@ int main(int argc, char** argv) {
try {
//create the singletons
ConfigUtility::Create();
ServerApplication::Create();
UDPNetworkUtility::Create();
//call the server's routines
ServerApplication::Create();
ServerApplication& app = ServerApplication::GetSingleton();
app.Init(argc, argv);
app.Proc();
app.Quit();
ServerApplication::Delete();
//delete the singletons
ConfigUtility::Delete();
ServerApplication::Delete();
UDPNetworkUtility::Delete();
}
catch(exception& e) {
cerr << "Fatal exception thrown: " << e.what() << endl;
+1 -1
View File
@@ -85,7 +85,7 @@ private:
//APIs and utilities
sqlite3* database = nullptr;
lua_State* luaState = nullptr;
UDPNetworkUtility network;
UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton();
ConfigUtility& config = ConfigUtility::GetSingleton();
//simple tables