void LFGuildManager::SendPlayerStatus(uint32 FromZoneID, uint32 FromInstanceID, char *From) { std::list<PlayerLookingForGuild>::iterator it; for(it = Players.begin(); it != Players.end(); ++it) { if(!strcasecmp((*it).Name.c_str(), From)) { ServerPacket *pack = new ServerPacket(ServerOP_QueryServGeneric, strlen(From) + (*it).Comments.length() + 30); pack->WriteUInt32(FromZoneID); pack->WriteUInt32(FromInstanceID); pack->WriteString(From); pack->WriteUInt32(QSG_LFGuild); pack->WriteUInt32(QSG_LFGuild_RequestPlayerInfo); pack->WriteString((*it).Comments.c_str()); pack->WriteUInt32((*it).TimeZone); pack->WriteUInt32((*it).TimePosted); pack->WriteUInt32(1); worldserver->SendPacket(pack); safe_delete(pack); break; } } }
void LFGuildManager::SendGuildStatus(uint32 FromZoneID, uint32 FromInstanceID, char *From, char *GuildName) { std::list<GuildLookingForPlayers>::iterator it; for(it = Guilds.begin(); it != Guilds.end(); ++it) { if(!strcasecmp((*it).Name.c_str(), GuildName)) { ServerPacket *pack = new ServerPacket(ServerOP_QueryServGeneric, strlen(From) + (*it).Comments.length() + 42); pack->WriteUInt32(FromZoneID); pack->WriteUInt32(FromInstanceID); pack->WriteString(From); pack->WriteUInt32(QSG_LFGuild); pack->WriteUInt32(QSG_LFGuild_RequestGuildInfo); pack->WriteString((*it).Comments.c_str()); pack->WriteUInt32((*it).FromLevel); pack->WriteUInt32((*it).ToLevel); pack->WriteUInt32((*it).Classes); pack->WriteUInt32((*it).AACount); pack->WriteUInt32((*it).TimeZone); pack->WriteUInt32((*it).TimePosted); worldserver->SendPacket(pack); safe_delete(pack); break; } } }
void RemoteCallResponse(const std::string &connection_id, const std::string &request_id, const std::map<std::string, std::string> &res, const std::string &error) { uint32 sz = (uint32)(connection_id.size() + request_id.size() + error.size() + 3 + 16); auto iter = res.begin(); while(iter != res.end()) { sz += (uint32)iter->first.size() + (uint32)iter->second.size() + 10; ++iter; } ServerPacket *pack = new ServerPacket(ServerOP_WIRemoteCallResponse, sz); pack->WriteUInt32((uint32)request_id.size()); pack->WriteString(request_id.c_str()); pack->WriteUInt32((uint32)connection_id.size()); pack->WriteString(connection_id.c_str()); pack->WriteUInt32((uint32)error.size()); pack->WriteString(error.c_str()); pack->WriteUInt32((uint32)res.size()); iter = res.begin(); while(iter != res.end()) { pack->WriteUInt32((uint32)iter->first.size()); pack->WriteString(iter->first.c_str()); pack->WriteUInt32((uint32)iter->second.size()); pack->WriteString(iter->second.c_str()); ++iter; } WILink.SendPacket(pack); safe_delete(pack); }
void handle_rc_relay(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms) { std::string error; std::map<std::string, std::string> res; uint32 zone_id = 0; uint32 instance_id = 0; ZoneServer *zs = nullptr; if(params.size() < 2) { error = "Missing zone relay params"; RemoteCallResponse(connection_id, request_id, res, error); return; } zone_id = (uint32)atoi(params[0].c_str()); instance_id = (uint32)atoi(params[1].c_str()); if(!zone_id && !instance_id) { error = "Zone not booted"; RemoteCallResponse(connection_id, request_id, res, error); return; } if(instance_id) { zs = zoneserver_list.FindByInstanceID(instance_id); } else { zs = zoneserver_list.FindByZoneID(zone_id); } if(!zs) { error = "Zone server not found"; RemoteCallResponse(connection_id, request_id, res, error); return; } uint32 sz = (uint32)(request_id.size() + connection_id.size() + method.size() + 3 + 16); uint32 p_sz = (uint32)params.size() - 2; for(uint32 i = 0; i < p_sz; ++i) { auto ¶m = params[i + 2]; sz += (uint32)param.size(); sz += 5; } ServerPacket *pack = new ServerPacket(ServerOP_WIRemoteCall, sz); pack->WriteUInt32((uint32)request_id.size()); pack->WriteString(request_id.c_str()); pack->WriteUInt32((uint32)connection_id.size()); pack->WriteString(connection_id.c_str()); pack->WriteUInt32((uint32)method.size()); pack->WriteString(method.c_str()); pack->WriteUInt32(p_sz); for(uint32 i = 0; i < p_sz; ++i) { auto ¶m = params[i + 2]; pack->WriteUInt32((uint32)param.size()); pack->WriteString(param.c_str()); } zs->SendPacket(pack); safe_delete(pack); }
void LFGuildManager::TogglePlayer(uint32 FromZoneID, uint32 FromInstanceID, char *From, uint32 Class, uint32 Level, uint32 AAPoints, char *Comments, uint32 Toggle, uint32 TimeZone) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; std::list<PlayerLookingForGuild>::iterator it; for(it = Players.begin(); it != Players.end(); ++it) { if(!strcasecmp((*it).Name.c_str(), From)) { Players.erase(it); break; } } if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM `lfguild` WHERE `type` = 0 AND `name` = '%s'", From), errbuf, 0, 0)) _log(QUERYSERV__ERROR, "Error removing player from LFGuild table, query was %s, %s", query, errbuf); safe_delete_array(query); uint32 Now = time(NULL); if(Toggle == 1) { PlayerLookingForGuild p(From, Comments, Level, Class, AAPoints, TimeZone, Now); Players.push_back(p); if(!database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `lfguild` (`type`, `name`, `comment`, `fromlevel`, `tolevel`, `classes`, `aacount`, `timezone`, `timeposted`) VALUES(0, '%s', '%s', %u, 0, %u, %u, %u, %u)", From, Comments, Level, Class, AAPoints, TimeZone, Now), errbuf, 0, 0)) _log(QUERYSERV__ERROR, "Error inserting player into LFGuild table, query was %s, %s", query, errbuf); safe_delete_array(query); } ServerPacket *pack = new ServerPacket(ServerOP_QueryServGeneric, strlen(From) + strlen(Comments) + 30); pack->WriteUInt32(FromZoneID); pack->WriteUInt32(FromInstanceID); pack->WriteString(From); pack->WriteUInt32(QSG_LFGuild); pack->WriteUInt32(QSG_LFGuild_RequestPlayerInfo); pack->WriteString(Comments); pack->WriteUInt32(TimeZone); pack->WriteUInt32(Now); pack->WriteUInt32(Toggle); worldserver->SendPacket(pack); safe_delete(pack); }
void LFGuildManager::ToggleGuild(uint32 FromZoneID, uint32 FromInstanceID, char *From, char* GuildName, char *Comments, uint32 FromLevel, uint32 ToLevel, uint32 Classes, uint32 AACount, uint32 Toggle, uint32 TimeZone) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; std::list<GuildLookingForPlayers>::iterator it; for(it = Guilds.begin(); it != Guilds.end(); ++it) { if(!strcasecmp((*it).Name.c_str(), GuildName)) { Guilds.erase(it); break; } } if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM `lfguild` WHERE `type` = 1 AND `name` = '%s'", GuildName), errbuf, 0, 0)) _log(QUERYSERV__ERROR, "Error removing guild from LFGuild table, query was %s, %s", query, errbuf); safe_delete_array(query); uint32 Now = time(NULL); if(Toggle == 1) { GuildLookingForPlayers g(GuildName, Comments, FromLevel, ToLevel, Classes, AACount, TimeZone, Now); Guilds.push_back(g); if(!database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO `lfguild` (`type`, `name`, `comment`, `fromlevel`, `tolevel`, `classes`, `aacount`, `timezone`, `timeposted`) VALUES(1, '%s', '%s', %u, %u, %u, %u, %u, %u)", GuildName, Comments, FromLevel, ToLevel, Classes, AACount, TimeZone, Now), errbuf, 0, 0)) _log(QUERYSERV__ERROR, "Error inserting guild into LFGuild table, query was %s, %s", query, errbuf); safe_delete_array(query); } ServerPacket *pack = new ServerPacket(ServerOP_LFGuildUpdate, strlen(GuildName) + strlen(Comments) + 30); pack->WriteString(GuildName); pack->WriteString(Comments); pack->WriteUInt32(FromLevel); pack->WriteUInt32(ToLevel); pack->WriteUInt32(Classes); pack->WriteUInt32(AACount); pack->WriteUInt32(TimeZone); pack->WriteUInt32(Now); pack->WriteUInt32(Toggle); worldserver->SendPacket(pack); safe_delete(pack); }
void RemoteCallSubscriptionHandler::Process() { //create a check for all these connection ids packet uint32 sz = 12; auto iter = connection_ids.begin(); while(iter != connection_ids.end()) { sz += (uint32)iter->first.size(); sz += 5; ++iter; } if (!zone) return; ServerPacket *pack = new ServerPacket(ServerOP_WIClientSession, sz); pack->WriteUInt32((uint32)zone->GetZoneID()); pack->WriteUInt32((uint32)zone->GetInstanceID()); pack->WriteUInt32((uint32)connection_ids.size()); iter = connection_ids.begin(); while(iter != connection_ids.end()) { pack->WriteUInt32((uint32)iter->first.size()); pack->WriteString(iter->first.c_str()); ++iter; } worldserver.SendPacket(pack); safe_delete(pack); }
void QueryServ::SendQuery(std::string Query) { ServerPacket* pack = new ServerPacket(ServerOP_QSSendQuery, Query.length() + 5); pack->WriteUInt32(Query.length()); /* Pack Query String Size so it can be dynamically broken out at queryserv */ pack->WriteString(Query.c_str()); /* Query */ worldserver.SendPacket(pack); safe_delete(pack); }
void LFGuildManager::SendPlayerMatches(uint32 FromZoneID, uint32 FromInstanceID, char *From, uint32 FromLevel, uint32 ToLevel, uint32 MinAA, uint32 TimeZone, uint32 Classes) { std::list<PlayerLookingForGuild>::iterator it; std::list<PlayerLookingForGuild> Matches; uint32 PacketSize = strlen(From) + 21, NumberOfMatches = 0; for(it = Players.begin(); it != Players.end(); ++it) { uint32 bitmask = 1 << (*it).Class ; if(((*it).Level >= FromLevel) && ((*it).Level <= ToLevel) && ((*it).AACount >= MinAA) && (bitmask & Classes) && ((TimeZone == 0xFFFFFFFF) || (TimeZone == (*it).TimeZone))) { ++NumberOfMatches; Matches.push_back(*it); PacketSize += (*it).Name.length() + (*it).Comments.length() + 18; } } ServerPacket *pack = new ServerPacket(ServerOP_QueryServGeneric, PacketSize); pack->WriteUInt32(FromZoneID); pack->WriteUInt32(FromInstanceID); pack->WriteString(From); pack->WriteUInt32(QSG_LFGuild); pack->WriteUInt32(QSG_LFGuild_PlayerMatches); pack->WriteUInt32(NumberOfMatches); for(it = Matches.begin(); it != Matches.end(); ++it) { pack->WriteString((*it).Name.c_str()); pack->WriteString((*it).Comments.c_str()); pack->WriteUInt32((*it).Level); pack->WriteUInt32((*it).Class); pack->WriteUInt32((*it).AACount); pack->WriteUInt32((*it).TimeZone); } worldserver->SendPacket(pack); safe_delete(pack); }
void handle_method_world_to_client(per_session_data_eqemu *session, rapidjson::Document &document, std::string &method) { CheckParams(5, "[zone_id, instance_id, opcode, size, data]"); VerifyID(); CalculateSize(); ServerPacket *pack = new ServerPacket(ServerOP_WIRemoteOpcodeFromClient, sz); pack->WriteUInt32((uint32)id.size()); \ pack->WriteString(id.c_str()); \ pack->WriteUInt32((uint32)session->uuid.size()); \ pack->WriteString(session->uuid.c_str()); \ pack->WriteUInt32((uint32)method.size()); \ pack->WriteString(method.c_str()); \ auto ¶ms = document["params"]; \ auto params_sz = params.Size(); \ pack->WriteUInt32(params_sz); \ for(rapidjson::SizeType i = 0; i < params_sz; ++i) { \ auto ¶m = params[(rapidjson::SizeType)i]; \ pack->WriteUInt32((uint32)strlen(param.GetString())); \ pack->WriteString(param.GetString()); \ } \ worldserver->SendPacket(pack); \ safe_delete(pack); \ }