mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-04 00:02:24 +00:00
Position updates with do_pos_update test call
This commit is contained in:
parent
69e90aac0a
commit
da6d7538b0
@ -188,6 +188,7 @@
|
|||||||
|
|
||||||
#define ServerOP_WIServGeneric 0x5001
|
#define ServerOP_WIServGeneric 0x5001
|
||||||
#define ServerOP_WIWorldResponse 0x5002
|
#define ServerOP_WIWorldResponse 0x5002
|
||||||
|
#define ServerOP_WIClientRequest 0x5003
|
||||||
|
|
||||||
enum { QSG_LFGuild = 0 };
|
enum { QSG_LFGuild = 0 };
|
||||||
enum { QSG_LFGuild_PlayerMatches = 0, QSG_LFGuild_UpdatePlayerInfo, QSG_LFGuild_RequestPlayerInfo, QSG_LFGuild_UpdateGuildInfo, QSG_LFGuild_GuildMatches,
|
enum { QSG_LFGuild_PlayerMatches = 0, QSG_LFGuild_UpdatePlayerInfo, QSG_LFGuild_RequestPlayerInfo, QSG_LFGuild_UpdateGuildInfo, QSG_LFGuild_GuildMatches,
|
||||||
@ -1232,6 +1233,17 @@ struct ReloadWorld_Struct{
|
|||||||
uint32 Option;
|
uint32 Option;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct WI_Client_Request_Struct{
|
||||||
|
char Client_UUID[64];
|
||||||
|
char JSON_Data[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WI_Client_Response_Struct{
|
||||||
|
char Client_UUID[64];
|
||||||
|
char JSON_Data[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -29,18 +29,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
std::string FloatToString(float number){
|
|
||||||
std::ostringstream buff;
|
|
||||||
buff << number;
|
|
||||||
return buff.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string IntegerToString(uint32_t number){
|
|
||||||
std::ostringstream buff;
|
|
||||||
buff << number;
|
|
||||||
return buff.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> explode(std::string const & s, char delim)
|
std::vector<std::string> explode(std::string const & s, char delim)
|
||||||
{
|
{
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
|
|||||||
@ -26,11 +26,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
std::string FloatToString(float number);
|
|
||||||
std::string IntegerToString(uint32_t number);
|
|
||||||
std::vector<std::string> explode(std::string const & s, char delim);
|
|
||||||
std::string MakeJSON(std::string json);
|
std::string MakeJSON(std::string json);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "../common/crash.h"
|
#include "../common/crash.h"
|
||||||
#include "../common/EQEmuConfig.h"
|
#include "../common/EQEmuConfig.h"
|
||||||
#include "../common/web_interface_utils.h"
|
#include "../common/web_interface_utils.h"
|
||||||
|
#include "../common/StringUtil.h"
|
||||||
#include "../common/uuid.h"
|
#include "../common/uuid.h"
|
||||||
#include "worldserver.h"
|
#include "worldserver.h"
|
||||||
#include "lib/libwebsockets.h"
|
#include "lib/libwebsockets.h"
|
||||||
@ -62,7 +63,7 @@ int callback_eqemu(libwebsocket_context *context, libwebsocket *wsi, libwebsocke
|
|||||||
session->uuid = CreateUUID();
|
session->uuid = CreateUUID();
|
||||||
session->send_queue = new std::list<std::string>();
|
session->send_queue = new std::list<std::string>();
|
||||||
sessions[session->uuid] = session;
|
sessions[session->uuid] = session;
|
||||||
printf("Create session %s\n", session->uuid.c_str());
|
printf("Created session %s\n", session->uuid.c_str());
|
||||||
break;
|
break;
|
||||||
case LWS_CALLBACK_RECEIVE: {
|
case LWS_CALLBACK_RECEIVE: {
|
||||||
|
|
||||||
@ -76,6 +77,17 @@ int callback_eqemu(libwebsocket_context *context, libwebsocket *wsi, libwebsocke
|
|||||||
if(command.compare("get_version") == 0) {
|
if(command.compare("get_version") == 0) {
|
||||||
session->send_queue->push_back("0.8.0");
|
session->send_queue->push_back("0.8.0");
|
||||||
}
|
}
|
||||||
|
if (command.compare("do_pos_update") == 0){
|
||||||
|
printf("Sending ServerOP_WIClientRequest with session %s Command Str %s \n", session->uuid.c_str(), command.c_str());
|
||||||
|
/* Test Packet */
|
||||||
|
ServerPacket* pack = new ServerPacket(ServerOP_WIClientRequest, sizeof(WI_Client_Request_Struct) + command.length() + 1);
|
||||||
|
WI_Client_Request_Struct* WICR = (WI_Client_Request_Struct*)pack->pBuffer;
|
||||||
|
strn0cpy(WICR->Client_UUID, session->uuid.c_str(), 64);
|
||||||
|
strn0cpy(WICR->JSON_Data, command.c_str(), command.length() + 1);
|
||||||
|
worldserver->SendPacket(pack);
|
||||||
|
safe_delete(pack);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LWS_CALLBACK_SERVER_WRITEABLE: {
|
case LWS_CALLBACK_SERVER_WRITEABLE: {
|
||||||
|
|||||||
@ -23,17 +23,24 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
#include "../common/packet_functions.h"
|
#include "../common/packet_functions.h"
|
||||||
#include "../common/md5.h"
|
#include "../common/md5.h"
|
||||||
#include "../common/packet_dump.h"
|
#include "../common/packet_dump.h"
|
||||||
|
#include "../common/web_interface_utils.h"
|
||||||
#include "worldserver.h"
|
#include "worldserver.h"
|
||||||
|
|
||||||
struct per_session_data_eqemu {
|
struct per_session_data_eqemu {
|
||||||
bool auth;
|
bool auth;
|
||||||
|
std::string uuid;
|
||||||
std::list<std::string> *send_queue;
|
std::list<std::string> *send_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern std::map<std::string, per_session_data_eqemu*> sessions;
|
||||||
|
|
||||||
WorldServer::WorldServer(std::string shared_key)
|
WorldServer::WorldServer(std::string shared_key)
|
||||||
: WorldConnection(EmuTCPConnection::packetModeWebInterface, shared_key.c_str()){
|
: WorldConnection(EmuTCPConnection::packetModeWebInterface, shared_key.c_str()){
|
||||||
pTryReconnect = true;
|
pTryReconnect = true;
|
||||||
@ -59,6 +66,17 @@ void WorldServer::Process(){
|
|||||||
case 0: { break; }
|
case 0: { break; }
|
||||||
case ServerOP_KeepAlive: { break; }
|
case ServerOP_KeepAlive: { break; }
|
||||||
case ServerOP_WIWorldResponse: {
|
case ServerOP_WIWorldResponse: {
|
||||||
|
/* Generic Response routine: web_interface server recieves packet from World -
|
||||||
|
Relays data back to client
|
||||||
|
*/
|
||||||
|
_log(WEB_INTERFACE__ERROR, "WI Recieved packet from world 0x%04x, size %d", pack->opcode, pack->size);
|
||||||
|
WI_Client_Request_Struct* WICR = (WI_Client_Request_Struct*)pack->pBuffer;
|
||||||
|
std::string Data;
|
||||||
|
Data.assign(WICR->JSON_Data, pack->size - 64);
|
||||||
|
/* Check if Session is Valid before sending data back*/
|
||||||
|
if (sessions[WICR->Client_UUID]){
|
||||||
|
sessions[WICR->Client_UUID]->send_queue->push_back(Data.c_str());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,6 +104,15 @@ bool WebInterfaceConnection::Process()
|
|||||||
zoneserver_list.SendPacket(pack); // Send to all zones to test
|
zoneserver_list.SendPacket(pack); // Send to all zones to test
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ServerOP_WIClientRequest:
|
||||||
|
{
|
||||||
|
std::string Data;
|
||||||
|
WI_Client_Request_Struct* WICR = (WI_Client_Request_Struct*)pack->pBuffer;
|
||||||
|
Data.assign(WICR->JSON_Data, pack->size - 64);
|
||||||
|
_log(WEB_INTERFACE__ERROR, "Recieved ServerOPcode from WebInterface 0x%04x \nSize %d\nData '%s' from client:\n%s\n", pack->opcode, pack->size, Data.c_str(), WICR->Client_UUID);
|
||||||
|
zoneserver_list.SendPacket(pack); // Send to all zones to test
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
_log(WEB_INTERFACE__ERROR, "Unknown ServerOPcode from WebInterface 0x%04x, size %d", pack->opcode, pack->size);
|
_log(WEB_INTERFACE__ERROR, "Unknown ServerOPcode from WebInterface 0x%04x, size %d", pack->opcode, pack->size);
|
||||||
|
|||||||
@ -1320,6 +1320,7 @@ bool ZoneServer::Process() {
|
|||||||
}
|
}
|
||||||
case ServerOP_WIWorldResponse:
|
case ServerOP_WIWorldResponse:
|
||||||
{
|
{
|
||||||
|
_log(WEB_INTERFACE__ERROR, "ServerOP_WIWorldResponse for WebInterface 0x%04x, size %d", pack->opcode, pack->size);
|
||||||
WILink.SendPacket(pack);
|
WILink.SendPacket(pack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
15
zone/mob.cpp
15
zone/mob.cpp
@ -32,6 +32,7 @@ extern EntityList entity_list;
|
|||||||
|
|
||||||
extern Zone* zone;
|
extern Zone* zone;
|
||||||
extern WorldServer worldserver;
|
extern WorldServer worldserver;
|
||||||
|
extern std::string WS_Client_Connected;
|
||||||
|
|
||||||
Mob::Mob(const char* in_name,
|
Mob::Mob(const char* in_name,
|
||||||
const char* in_lastname,
|
const char* in_lastname,
|
||||||
@ -1218,14 +1219,16 @@ void Mob::MakeSpawnUpdateNoDelta(PlayerPositionUpdateServer_Struct *spu){
|
|||||||
spu->padding0018 =0x5df27;
|
spu->padding0018 =0x5df27;
|
||||||
|
|
||||||
/* Testing */
|
/* Testing */
|
||||||
if (IsNPC()){
|
if (IsNPC() && WS_Client_Connected.size() != 0){
|
||||||
std::string str = MakeJSON("ResponseType:PositionUpdate,entity:" + IntegerToString(GetID()) + ",x:" + FloatToString(x_pos) + ",y:" + FloatToString(y_pos) + ",z:" + FloatToString(z_pos) + ",h:" + FloatToString(heading));
|
std::string str = MakeJSON("ResponseType:PositionUpdate,entity:" + std::to_string(GetID()) + ",name:" + GetName() + ",x:" + std::to_string(x_pos) + ",y:" + std::to_string(y_pos) + ",z:" + std::to_string(z_pos) + ",h:" + std::to_string(heading));
|
||||||
char * writable = new char[str.size() + 1];
|
char * writable = new char[str.size() + 1];
|
||||||
std::copy(str.begin(), str.end(), writable);
|
std::copy(str.begin(), str.end(), writable);
|
||||||
ServerPacket* wipack = new ServerPacket(ServerOP_WIWorldResponse, str.size() + 1);
|
ServerPacket* pack = new ServerPacket(ServerOP_WIWorldResponse, sizeof(WI_Client_Response_Struct)+str.length() + 1);
|
||||||
wipack->WriteString(writable);
|
WI_Client_Response_Struct* WICR = (WI_Client_Response_Struct*)pack->pBuffer;
|
||||||
if (worldserver.Connected()) { worldserver.SendPacket(wipack); }
|
strn0cpy(WICR->Client_UUID, WS_Client_Connected.c_str(), 64);
|
||||||
safe_delete(wipack);
|
strn0cpy(WICR->JSON_Data, str.c_str(), str.length() + 1);
|
||||||
|
if (worldserver.Connected()) { worldserver.SendPacket(pack); }
|
||||||
|
safe_delete(pack);
|
||||||
delete[] writable;
|
delete[] writable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,6 +100,7 @@ DBAsyncFinishedQueue MTdbafq;
|
|||||||
DBAsync *dbasync = nullptr;
|
DBAsync *dbasync = nullptr;
|
||||||
TaskManager *taskmanager = 0;
|
TaskManager *taskmanager = 0;
|
||||||
QuestParserCollection *parse = 0;
|
QuestParserCollection *parse = 0;
|
||||||
|
std::string WS_Client_Connected;
|
||||||
|
|
||||||
const SPDat_Spell_Struct* spells;
|
const SPDat_Spell_Struct* spells;
|
||||||
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
|
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
|
||||||
|
|||||||
@ -62,6 +62,7 @@ extern NetConnection net;
|
|||||||
extern PetitionList petition_list;
|
extern PetitionList petition_list;
|
||||||
extern uint32 numclients;
|
extern uint32 numclients;
|
||||||
extern volatile bool RunLoops;
|
extern volatile bool RunLoops;
|
||||||
|
extern std::string WS_Client_Connected;
|
||||||
|
|
||||||
WorldServer::WorldServer()
|
WorldServer::WorldServer()
|
||||||
: WorldConnection(EmuTCPConnection::packetModeZone)
|
: WorldConnection(EmuTCPConnection::packetModeZone)
|
||||||
@ -1777,9 +1778,11 @@ void WorldServer::Process() {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_WIServGeneric:
|
case ServerOP_WIClientRequest:
|
||||||
{
|
{
|
||||||
/* Do Nothing for now */
|
WI_Client_Request_Struct* WICR = (WI_Client_Request_Struct*)pack->pBuffer;
|
||||||
|
WS_Client_Connected = WICR->Client_UUID;
|
||||||
|
_log(WEB_INTERFACE__ERROR, "Recieved packet from World, setting Client Connected to %s", WICR->Client_UUID);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_CZSignalClient:
|
case ServerOP_CZSignalClient:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user