Finished these server tweaks
This commit is contained in:
@@ -29,6 +29,12 @@ void serializeText(void* buffer, TextPacket* packet) {
|
|||||||
//content
|
//content
|
||||||
serialCopy(&buffer, packet->name, PACKET_STRING_SIZE);
|
serialCopy(&buffer, packet->name, PACKET_STRING_SIZE);
|
||||||
serialCopy(&buffer, packet->text, PACKET_STRING_SIZE);
|
serialCopy(&buffer, packet->text, PACKET_STRING_SIZE);
|
||||||
|
|
||||||
|
//location
|
||||||
|
serialCopy(&buffer, &packet->roomIndex, sizeof(int));
|
||||||
|
serialCopy(&buffer, &packet->origin.x, sizeof(double));
|
||||||
|
serialCopy(&buffer, &packet->origin.y, sizeof(double));
|
||||||
|
serialCopy(&buffer, &packet->range, sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
void deserializeText(void* buffer, TextPacket* packet) {
|
void deserializeText(void* buffer, TextPacket* packet) {
|
||||||
@@ -37,4 +43,10 @@ void deserializeText(void* buffer, TextPacket* packet) {
|
|||||||
//content
|
//content
|
||||||
deserialCopy(&buffer, packet->name, PACKET_STRING_SIZE);
|
deserialCopy(&buffer, packet->name, PACKET_STRING_SIZE);
|
||||||
deserialCopy(&buffer, packet->text, PACKET_STRING_SIZE);
|
deserialCopy(&buffer, packet->text, PACKET_STRING_SIZE);
|
||||||
|
|
||||||
|
//location
|
||||||
|
deserialCopy(&buffer, &packet->roomIndex, sizeof(int));
|
||||||
|
deserialCopy(&buffer, &packet->origin.x, sizeof(double));
|
||||||
|
deserialCopy(&buffer, &packet->origin.y, sizeof(double));
|
||||||
|
deserialCopy(&buffer, &packet->range, sizeof(int));
|
||||||
}
|
}
|
||||||
@@ -24,9 +24,14 @@
|
|||||||
|
|
||||||
#include "serial_packet_base.hpp"
|
#include "serial_packet_base.hpp"
|
||||||
|
|
||||||
|
#include "vector2.hpp"
|
||||||
|
|
||||||
struct TextPacket : SerialPacketBase {
|
struct TextPacket : SerialPacketBase {
|
||||||
char name[PACKET_STRING_SIZE];
|
char name[PACKET_STRING_SIZE];
|
||||||
char text[PACKET_STRING_SIZE];
|
char text[PACKET_STRING_SIZE];
|
||||||
|
int roomIndex;
|
||||||
|
Vector2 origin;
|
||||||
|
int range;
|
||||||
};
|
};
|
||||||
|
|
||||||
void serializeText(void* buffer, TextPacket* packet);
|
void serializeText(void* buffer, TextPacket* packet);
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ enum class SerialPacketType {
|
|||||||
|
|
||||||
//general speech
|
//general speech
|
||||||
TEXT_BROADCAST,
|
TEXT_BROADCAST,
|
||||||
|
TEXT_SPEECH,
|
||||||
|
TEXT_WHISPER,
|
||||||
|
|
||||||
//rejection/error messages
|
//rejection/error messages
|
||||||
JOIN_REJECTION,
|
JOIN_REJECTION,
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ void serializePacket(void* buffer, SerialPacketBase* packet) {
|
|||||||
serializeMonster(buffer, static_cast<MonsterPacket*>(packet));
|
serializeMonster(buffer, static_cast<MonsterPacket*>(packet));
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::TEXT_BROADCAST:
|
case SerialPacketType::TEXT_BROADCAST:
|
||||||
|
case SerialPacketType::TEXT_SPEECH:
|
||||||
|
case SerialPacketType::TEXT_WHISPER:
|
||||||
case SerialPacketType::JOIN_REJECTION:
|
case SerialPacketType::JOIN_REJECTION:
|
||||||
case SerialPacketType::LOGIN_REJECTION:
|
case SerialPacketType::LOGIN_REJECTION:
|
||||||
case SerialPacketType::REGION_REJECTION:
|
case SerialPacketType::REGION_REJECTION:
|
||||||
@@ -154,6 +156,8 @@ void deserializePacket(void* buffer, SerialPacketBase* packet) {
|
|||||||
deserializeMonster(buffer, static_cast<MonsterPacket*>(packet));
|
deserializeMonster(buffer, static_cast<MonsterPacket*>(packet));
|
||||||
break;
|
break;
|
||||||
case SerialPacketType::TEXT_BROADCAST:
|
case SerialPacketType::TEXT_BROADCAST:
|
||||||
|
case SerialPacketType::TEXT_SPEECH:
|
||||||
|
case SerialPacketType::TEXT_WHISPER:
|
||||||
case SerialPacketType::JOIN_REJECTION:
|
case SerialPacketType::JOIN_REJECTION:
|
||||||
case SerialPacketType::LOGIN_REJECTION:
|
case SerialPacketType::LOGIN_REJECTION:
|
||||||
case SerialPacketType::REGION_REJECTION:
|
case SerialPacketType::REGION_REJECTION:
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ private:
|
|||||||
|
|
||||||
//chat
|
//chat
|
||||||
void hTextBroadcast(TextPacket* const);
|
void hTextBroadcast(TextPacket* const);
|
||||||
|
void hTextSpeech(TextPacket* const);
|
||||||
|
void hTextWhisper(TextPacket* const);
|
||||||
|
|
||||||
//utility methods
|
//utility methods
|
||||||
void PumpPacket(SerialPacket* const);
|
void PumpPacket(SerialPacket* const);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
//Character Management
|
//Character Management
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
void ServerApplication::HandleCharacterCreate(CharacterPacket* const argPacket) {
|
void ServerApplication::hCharacterCreate(CharacterPacket* const argPacket) {
|
||||||
int characterIndex = characterMgr.Create(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
|
int characterIndex = characterMgr.Create(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
|
||||||
|
|
||||||
if (characterIndex < 0) {
|
if (characterIndex < 0) {
|
||||||
@@ -55,7 +55,7 @@ void ServerApplication::HandleCharacterCreate(CharacterPacket* const argPacket)
|
|||||||
PumpPacket(&newPacket);
|
PumpPacket(&newPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::HandleCharacterDelete(CharacterPacket* const argPacket) {
|
void ServerApplication::hCharacterDelete(CharacterPacket* const argPacket) {
|
||||||
//get the user's data
|
//get the user's data
|
||||||
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
|
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
|
||||||
if (!accountData) {
|
if (!accountData) {
|
||||||
@@ -102,7 +102,7 @@ void ServerApplication::HandleCharacterDelete(CharacterPacket* const argPacket)
|
|||||||
PumpPacket(static_cast<SerialPacket*>(&newPacket));
|
PumpPacket(static_cast<SerialPacket*>(&newPacket));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::HandleCharacterLoad(CharacterPacket* const argPacket) {
|
void ServerApplication::hCharacterLoad(CharacterPacket* const argPacket) {
|
||||||
int characterIndex = characterMgr.Load(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
|
int characterIndex = characterMgr.Load(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
|
||||||
|
|
||||||
if (characterIndex < 0) {
|
if (characterIndex < 0) {
|
||||||
@@ -135,7 +135,7 @@ void ServerApplication::HandleCharacterLoad(CharacterPacket* const argPacket) {
|
|||||||
PumpPacket(&newPacket);
|
PumpPacket(&newPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::HandleCharacterUnload(CharacterPacket* const argPacket) {
|
void ServerApplication::hCharacterUnload(CharacterPacket* const argPacket) {
|
||||||
//get the entries
|
//get the entries
|
||||||
CharacterData* characterData = characterMgr.Get(argPacket->characterIndex);
|
CharacterData* characterData = characterMgr.Get(argPacket->characterIndex);
|
||||||
if (!characterData) {
|
if (!characterData) {
|
||||||
@@ -177,7 +177,7 @@ void ServerApplication::HandleCharacterUnload(CharacterPacket* const argPacket)
|
|||||||
|
|
||||||
//TODO: (9) Could replace this verbosity with a "verify" method, taking a client, account and character ptr as arguments
|
//TODO: (9) Could replace this verbosity with a "verify" method, taking a client, account and character ptr as arguments
|
||||||
|
|
||||||
void ServerApplication::HandleCharacterMovement(CharacterPacket* const argPacket) {
|
void ServerApplication::hCharacterMovement(CharacterPacket* const argPacket) {
|
||||||
//get the specified objects
|
//get the specified objects
|
||||||
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
|
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
|
||||||
CharacterData* characterData = characterMgr.Get(argPacket->characterIndex);
|
CharacterData* characterData = characterMgr.Get(argPacket->characterIndex);
|
||||||
@@ -234,6 +234,10 @@ void ServerApplication::HandleCharacterMovement(CharacterPacket* const argPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::HandleCharacterAttack(CharacterPacket* const) {
|
void ServerApplication::hCharacterAttack(CharacterPacket* const argPacket) {
|
||||||
//TODO: (9) bounce graphical attack data
|
//TODO: (9) bounce graphical attack data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hCharacterDamage(CharacterPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013-2015
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "server_application.hpp"
|
||||||
|
|
||||||
|
void ServerApplication::hTextBroadcast(TextPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hTextSpeech(TextPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hTextWhisper(TextPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
@@ -25,20 +25,10 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//General data management
|
//Queries
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
//NOTE: Queries go here
|
void ServerApplication::hRegionRequest(RegionPacket* const argPacket) {
|
||||||
|
|
||||||
void ServerApplication::SaveServerState() {
|
|
||||||
//SaveServerState
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------
|
|
||||||
//Map management
|
|
||||||
//-------------------------
|
|
||||||
|
|
||||||
void ServerApplication::HandleRegionRequest(RegionPacket* const argPacket) {
|
|
||||||
//get the region object, send a rejection on error
|
//get the region object, send a rejection on error
|
||||||
RoomData* room = roomMgr.Get(argPacket->roomIndex);
|
RoomData* room = roomMgr.Get(argPacket->roomIndex);
|
||||||
if (!room) {
|
if (!room) {
|
||||||
@@ -71,7 +61,7 @@ void ServerApplication::HandleRegionRequest(RegionPacket* const argPacket) {
|
|||||||
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::HandleCharacterExists(CharacterPacket* const argPacket) {
|
void ServerApplication::hQueryCharacterExists(CharacterPacket* const argPacket) {
|
||||||
//respond with all character data
|
//respond with all character data
|
||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
|
|
||||||
@@ -84,3 +74,23 @@ void ServerApplication::HandleCharacterExists(CharacterPacket* const argPacket)
|
|||||||
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hQueryCharacterStats(CharacterPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hQueryCharacterLocation(CharacterPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hQueryMonsterExists(MonsterPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hQueryMonsterStats(MonsterPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerApplication::hQueryMonsterLocation(MonsterPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
@@ -311,6 +311,12 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) {
|
|||||||
case SerialPacketType::TEXT_BROADCAST:
|
case SerialPacketType::TEXT_BROADCAST:
|
||||||
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
case SerialPacketType::TEXT_SPEECH:
|
||||||
|
hTextSpeech(static_cast<TextPacket*>(argPacket));
|
||||||
|
break;
|
||||||
|
case SerialPacketType::TEXT_WHISPER:
|
||||||
|
hTextWhisper(static_cast<TextPacket*>(argPacket));
|
||||||
|
break;
|
||||||
|
|
||||||
//handle errors
|
//handle errors
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ void ServerApplication::hAdminDisconnectForced(ClientPacket* const argPacket) {
|
|||||||
//TODO: (9) boot players
|
//TODO: (9) boot players
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::HandleShutdownRequest(ClientPacket* const argPacket) {
|
void ServerApplication::hAdminShutdownRequest(ClientPacket* const argPacket) {
|
||||||
//get the account and client data
|
//get the account and client data
|
||||||
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
|
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
|
||||||
if (!accountData) {
|
if (!accountData) {
|
||||||
@@ -76,7 +76,7 @@ void ServerApplication::HandleShutdownRequest(ClientPacket* const argPacket) {
|
|||||||
|
|
||||||
//disconnect all clients
|
//disconnect all clients
|
||||||
TextPacket newPacket;
|
TextPacket newPacket;
|
||||||
newPacket.type = SerialPacketType::DISCONNECT_FORCED;
|
newPacket.type = SerialPacketType::ADMIN_DISCONNECT_FORCED;
|
||||||
strncpy(newPacket.text, "Server shutdown", PACKET_STRING_SIZE);
|
strncpy(newPacket.text, "Server shutdown", PACKET_STRING_SIZE);
|
||||||
PumpPacket(&newPacket);
|
PumpPacket(&newPacket);
|
||||||
|
|
||||||
|
|||||||
@@ -21,3 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "server_application.hpp"
|
#include "server_application.hpp"
|
||||||
|
|
||||||
|
void ServerApplication::hMonsterDamage(MonsterPacket* const argPacket) {
|
||||||
|
//TODO: (9) empty
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user