Began adding basic authentication

This commit is contained in:
Kayne Ruse
2014-05-06 21:35:07 +10:00
parent 8358d72a98
commit 1beb7cbd5d
8 changed files with 24 additions and 10 deletions
+2 -2
View File
@@ -119,10 +119,10 @@ void ClientApplication::LoadScene(SceneList sceneIndex) {
activeScene = new OptionsMenu(&config); activeScene = new OptionsMenu(&config);
break; break;
case SceneList::LOBBYMENU: case SceneList::LOBBYMENU:
activeScene = new LobbyMenu(&config, &network, &clientIndex, &characterIndex); activeScene = new LobbyMenu(&config, &network, &clientIndex, &accountIndex, &characterIndex);
break; break;
case SceneList::INWORLD: case SceneList::INWORLD:
activeScene = new InWorld(&config, &network, &clientIndex, &characterIndex); activeScene = new InWorld(&config, &network, &clientIndex, &accountIndex, &characterIndex);
break; break;
case SceneList::INCOMBAT: case SceneList::INCOMBAT:
activeScene = new InCombat(); activeScene = new InCombat();
+1
View File
@@ -48,6 +48,7 @@ private:
ConfigUtility config; ConfigUtility config;
UDPNetworkUtility network; UDPNetworkUtility network;
int clientIndex = -1; int clientIndex = -1;
int accountIndex = -1;
int characterIndex = -1; int characterIndex = -1;
}; };
+7 -3
View File
@@ -31,10 +31,11 @@
//Public access members //Public access members
//------------------------- //-------------------------
InWorld::InWorld(ConfigUtility* const argConfig, UDPNetworkUtility* const argNetwork, int* const argClientIndex, int* const argCharacterIndex): InWorld::InWorld(ConfigUtility* const argConfig, UDPNetworkUtility* const argNetwork, int* const argClientIndex, int* const argAccountIndex, int* const argCharacterIndex):
config(*argConfig), config(*argConfig),
network(*argNetwork), network(*argNetwork),
clientIndex(*argClientIndex), clientIndex(*argClientIndex),
accountIndex(*argAccountIndex),
characterIndex(*argCharacterIndex) characterIndex(*argCharacterIndex)
{ {
//setup the utility objects //setup the utility objects
@@ -67,6 +68,7 @@ InWorld::InWorld(ConfigUtility* const argConfig, UDPNetworkUtility* const argNet
char buffer[PACKET_STRING_SIZE]; char buffer[PACKET_STRING_SIZE];
packet.meta.type = SerialPacket::Type::SYNCHRONIZE; packet.meta.type = SerialPacket::Type::SYNCHRONIZE;
packet.clientInfo.clientIndex = clientIndex; packet.clientInfo.clientIndex = clientIndex;
packet.clientInfo.accountIndex = accountIndex;
packet.clientInfo.characterIndex = characterIndex; packet.clientInfo.characterIndex = characterIndex;
serialize(&packet, buffer); serialize(&packet, buffer);
network.Send(Channels::SERVER, buffer, PACKET_BUFFER_SIZE); network.Send(Channels::SERVER, buffer, PACKET_BUFFER_SIZE);
@@ -271,6 +273,7 @@ void InWorld::HandlePacket(SerialPacket packet) {
void InWorld::HandleDisconnect(SerialPacket packet) { void InWorld::HandleDisconnect(SerialPacket packet) {
network.Unbind(Channels::SERVER); network.Unbind(Channels::SERVER);
clientIndex = -1; clientIndex = -1;
accountIndex = -1;
characterIndex = -1; characterIndex = -1;
SetNextScene(SceneList::MAINMENU); SetNextScene(SceneList::MAINMENU);
} }
@@ -347,6 +350,7 @@ void InWorld::SendPlayerUpdate() {
//pack the packet //pack the packet
packet.meta.type = SerialPacket::Type::CHARACTER_UPDATE; packet.meta.type = SerialPacket::Type::CHARACTER_UPDATE;
packet.characterInfo.clientIndex = clientIndex; packet.characterInfo.clientIndex = clientIndex;
packet.characterInfo.accountIndex = accountIndex;
packet.characterInfo.characterIndex = characterIndex; packet.characterInfo.characterIndex = characterIndex;
packet.characterInfo.position = localCharacter->GetPosition(); packet.characterInfo.position = localCharacter->GetPosition();
packet.characterInfo.motion = localCharacter->GetMotion(); packet.characterInfo.motion = localCharacter->GetMotion();
@@ -361,7 +365,7 @@ void InWorld::RequestDisconnect() {
//send a disconnect request //send a disconnect request
packet.meta.type = SerialPacket::Type::DISCONNECT; packet.meta.type = SerialPacket::Type::DISCONNECT;
packet.clientInfo.clientIndex = clientIndex; packet.clientInfo.accountIndex = accountIndex;
serialize(&packet, buffer); serialize(&packet, buffer);
network.Send(Channels::SERVER, buffer, PACKET_BUFFER_SIZE); network.Send(Channels::SERVER, buffer, PACKET_BUFFER_SIZE);
} }
@@ -372,7 +376,7 @@ void InWorld::RequestShutDown() {
//send a shutdown request //send a shutdown request
packet.meta.type = SerialPacket::Type::SHUTDOWN; packet.meta.type = SerialPacket::Type::SHUTDOWN;
packet.clientInfo.clientIndex = clientIndex; packet.clientInfo.accountIndex = accountIndex;
serialize(&packet, buffer); serialize(&packet, buffer);
network.Send(Channels::SERVER, buffer, PACKET_BUFFER_SIZE); network.Send(Channels::SERVER, buffer, PACKET_BUFFER_SIZE);
} }
+2 -1
View File
@@ -52,7 +52,7 @@
class InWorld : public BaseScene { class InWorld : public BaseScene {
public: public:
//Public access members //Public access members
InWorld(ConfigUtility* const, UDPNetworkUtility* const, int* const, int* const); InWorld(ConfigUtility* const, UDPNetworkUtility* const, int* const, int* const, int* const);
~InWorld(); ~InWorld();
protected: protected:
@@ -92,6 +92,7 @@ protected:
ConfigUtility& config; ConfigUtility& config;
UDPNetworkUtility& network; UDPNetworkUtility& network;
int& clientIndex; int& clientIndex;
int& accountIndex;
int& characterIndex; int& characterIndex;
//graphics //graphics
+3 -1
View File
@@ -30,10 +30,11 @@
//Public access members //Public access members
//------------------------- //-------------------------
LobbyMenu::LobbyMenu(ConfigUtility* const argConfig, UDPNetworkUtility* const argNetwork, int* const argClientIndex, int* const argCharacterIndex): LobbyMenu::LobbyMenu(ConfigUtility* const argConfig, UDPNetworkUtility* const argNetwork, int* const argClientIndex, int* const argAccountIndex, int* const argCharacterIndex):
config(*argConfig), config(*argConfig),
network(*argNetwork), network(*argNetwork),
clientIndex(*argClientIndex), clientIndex(*argClientIndex),
accountIndex(*argAccountIndex),
characterIndex(*argCharacterIndex) characterIndex(*argCharacterIndex)
{ {
//setup the utility objects //setup the utility objects
@@ -221,6 +222,7 @@ void LobbyMenu::HandlePacket(SerialPacket packet) {
break; break;
case SerialPacket::Type::JOIN_RESPONSE: case SerialPacket::Type::JOIN_RESPONSE:
clientIndex = packet.clientInfo.clientIndex; clientIndex = packet.clientInfo.clientIndex;
accountIndex = packet.clientInfo.accountIndex;
characterIndex = packet.clientInfo.characterIndex; characterIndex = packet.clientInfo.characterIndex;
network.Bind(&packet.meta.srcAddress, Channels::SERVER); network.Bind(&packet.meta.srcAddress, Channels::SERVER);
SetNextScene(SceneList::INWORLD); SetNextScene(SceneList::INWORLD);
+2 -1
View File
@@ -42,7 +42,7 @@
class LobbyMenu : public BaseScene { class LobbyMenu : public BaseScene {
public: public:
//Public access members //Public access members
LobbyMenu(ConfigUtility* const, UDPNetworkUtility* const, int* const, int* const); LobbyMenu(ConfigUtility* const, UDPNetworkUtility* const, int* const, int* const, int* const);
~LobbyMenu(); ~LobbyMenu();
protected: protected:
@@ -65,6 +65,7 @@ protected:
ConfigUtility& config; ConfigUtility& config;
UDPNetworkUtility& network; UDPNetworkUtility& network;
int& clientIndex; int& clientIndex;
int& accountIndex;
int& characterIndex; int& characterIndex;
//members //members
+4
View File
@@ -54,6 +54,7 @@ void serializeClient(SerialPacket* packet, char* buffer) {
//indexes //indexes
SERIALIZE(buffer, &packet->clientInfo.clientIndex, sizeof(int)); SERIALIZE(buffer, &packet->clientInfo.clientIndex, sizeof(int));
SERIALIZE(buffer, &packet->clientInfo.accountIndex, sizeof(int));
SERIALIZE(buffer, &packet->clientInfo.characterIndex, sizeof(int)); SERIALIZE(buffer, &packet->clientInfo.characterIndex, sizeof(int));
//texts //texts
@@ -95,6 +96,7 @@ void serializeCharacter(SerialPacket* packet, char* buffer) {
//indexes //indexes
SERIALIZE(buffer, &packet->characterInfo.clientIndex, sizeof(int)); SERIALIZE(buffer, &packet->characterInfo.clientIndex, sizeof(int));
SERIALIZE(buffer, &packet->characterInfo.accountIndex, sizeof(int));
SERIALIZE(buffer, &packet->characterInfo.characterIndex, sizeof(int)); SERIALIZE(buffer, &packet->characterInfo.characterIndex, sizeof(int));
//texts //texts
@@ -130,6 +132,7 @@ void deserializeClient(SerialPacket* packet, char* buffer) {
//indexes //indexes
DESERIALIZE(buffer, &packet->clientInfo.clientIndex, sizeof(int)); DESERIALIZE(buffer, &packet->clientInfo.clientIndex, sizeof(int));
DESERIALIZE(buffer, &packet->clientInfo.accountIndex, sizeof(int));
DESERIALIZE(buffer, &packet->clientInfo.characterIndex, sizeof(int)); DESERIALIZE(buffer, &packet->clientInfo.characterIndex, sizeof(int));
//texts //texts
@@ -178,6 +181,7 @@ void deserializeCharacter(SerialPacket* packet, char* buffer) {
//indexes //indexes
DESERIALIZE(buffer, &packet->characterInfo.clientIndex, sizeof(int)); DESERIALIZE(buffer, &packet->characterInfo.clientIndex, sizeof(int));
DESERIALIZE(buffer, &packet->characterInfo.accountIndex, sizeof(int));
DESERIALIZE(buffer, &packet->characterInfo.characterIndex, sizeof(int)); DESERIALIZE(buffer, &packet->characterInfo.characterIndex, sizeof(int));
//texts //texts
+3 -2
View File
@@ -27,7 +27,7 @@
#include "SDL/SDL_net.h" #include "SDL/SDL_net.h"
#define NETWORK_VERSION 20140428 #define NETWORK_VERSION 20140506
#define PACKET_STRING_SIZE 100 #define PACKET_STRING_SIZE 100
#pragma pack(push, 0) #pragma pack(push, 0)
@@ -88,8 +88,8 @@ union SerialPacket {
//information about the client //information about the client
struct ClientInformation { struct ClientInformation {
Metadata meta; Metadata meta;
//TODO: change clientIndex to accountIndex for player ID
int clientIndex; int clientIndex;
int accountIndex;
int characterIndex; int characterIndex;
char username[PACKET_STRING_SIZE]; char username[PACKET_STRING_SIZE];
char handle[PACKET_STRING_SIZE]; char handle[PACKET_STRING_SIZE];
@@ -108,6 +108,7 @@ union SerialPacket {
struct CharacterInformation { struct CharacterInformation {
Metadata meta; Metadata meta;
int clientIndex; int clientIndex;
int accountIndex;
int characterIndex; int characterIndex;
char handle[PACKET_STRING_SIZE]; char handle[PACKET_STRING_SIZE];
char avatar[PACKET_STRING_SIZE]; char avatar[PACKET_STRING_SIZE];