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