mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
Assign expeditions a uuid
This commit is contained in:
parent
f23ca8055f
commit
6a7980ec75
@ -1,5 +1,6 @@
|
||||
CREATE TABLE `expedition_details` (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`uuid` VARCHAR(36) NOT NULL,
|
||||
`instance_id` INT(10) NULL DEFAULT NULL,
|
||||
`expedition_name` VARCHAR(128) NOT NULL,
|
||||
`leader_id` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||
@ -11,7 +12,7 @@ CREATE TABLE `expedition_details` (
|
||||
UNIQUE INDEX `instance_id` (`instance_id`),
|
||||
CONSTRAINT `FK_expedition_details_instance_list` FOREIGN KEY (`instance_id`) REFERENCES `instance_list` (`id`) ON DELETE SET NULL
|
||||
)
|
||||
COLLATE='latin1_swedish_ci'
|
||||
COLLATE='utf8mb4_general_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "worldserver.h"
|
||||
#include "zonedb.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/util/uuid.h"
|
||||
|
||||
extern WorldServer worldserver;
|
||||
extern Zone* zone;
|
||||
@ -46,10 +47,11 @@ const uint32_t Expedition::REPLAY_TIMER_ID = std::numeric_limits<uint32_t>::max(
|
||||
const uint32_t Expedition::EVENT_TIMER_ID = 1;
|
||||
|
||||
Expedition::Expedition(
|
||||
uint32_t id, const DynamicZone& dynamic_zone, std::string expedition_name,
|
||||
uint32_t id, const std::string& uuid, const DynamicZone& dynamic_zone, std::string expedition_name,
|
||||
const ExpeditionMember& leader, uint32_t min_players, uint32_t max_players
|
||||
) :
|
||||
m_id(id),
|
||||
m_uuid(uuid),
|
||||
m_dynamiczone(dynamic_zone),
|
||||
m_expedition_name(expedition_name),
|
||||
m_leader(leader),
|
||||
@ -89,13 +91,14 @@ Expedition* Expedition::TryCreate(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ExpeditionMember leader{ request.GetLeaderID(), request.GetLeaderName() };
|
||||
std::string expedition_uuid = EQ::Util::UUID::Generate().ToString();
|
||||
|
||||
// unique expedition ids are created from database via auto-increment column
|
||||
auto expedition_id = ExpeditionDatabase::InsertExpedition(
|
||||
expedition_uuid,
|
||||
dynamiczone.GetInstanceID(),
|
||||
request.GetExpeditionName(),
|
||||
leader.char_id,
|
||||
request.GetLeaderID(),
|
||||
request.GetMinPlayers(),
|
||||
request.GetMaxPlayers()
|
||||
);
|
||||
@ -104,8 +107,11 @@ Expedition* Expedition::TryCreate(
|
||||
{
|
||||
dynamiczone.SaveToDatabase();
|
||||
|
||||
ExpeditionMember leader{request.GetLeaderID(), request.GetLeaderName()};
|
||||
|
||||
auto expedition = std::unique_ptr<Expedition>(new Expedition(
|
||||
expedition_id,
|
||||
expedition_uuid,
|
||||
dynamiczone,
|
||||
request.GetExpeditionName(),
|
||||
leader,
|
||||
@ -182,6 +188,7 @@ void Expedition::CacheExpeditions(MySQLRequestResult& results)
|
||||
|
||||
std::unique_ptr<Expedition> expedition = std::unique_ptr<Expedition>(new Expedition(
|
||||
expedition_id,
|
||||
row[col::uuid], // expedition uuid
|
||||
DynamicZone{instance_id},
|
||||
row[col::expedition_name], // expedition name
|
||||
ExpeditionMember{leader_id, row[col::leader_name]}, // expedition leader id, name
|
||||
|
||||
@ -67,8 +67,8 @@ class Expedition
|
||||
public:
|
||||
Expedition() = delete;
|
||||
Expedition(
|
||||
uint32_t id, const DynamicZone& dz, std::string expedition_name, const ExpeditionMember& leader,
|
||||
uint32_t min_players, uint32_t max_players);
|
||||
uint32_t id, const std::string& uuid, const DynamicZone& dz, std::string expedition_name,
|
||||
const ExpeditionMember& leader, uint32_t min_players, uint32_t max_players);
|
||||
|
||||
static Expedition* TryCreate(Client* requester, DynamicZone& dynamiczone, ExpeditionRequest& request);
|
||||
|
||||
@ -90,6 +90,7 @@ public:
|
||||
const DynamicZone& GetDynamicZone() const { return m_dynamiczone; }
|
||||
const std::string& GetName() const { return m_expedition_name; }
|
||||
const std::string& GetLeaderName() const { return m_leader.name; }
|
||||
const std::string& GetUUID() const { return m_uuid; }
|
||||
const std::unordered_map<std::string, ExpeditionLockoutTimer>& GetLockouts() const { return m_lockouts; }
|
||||
const std::vector<ExpeditionMember>& GetMembers() const { return m_members; }
|
||||
|
||||
@ -179,6 +180,7 @@ private:
|
||||
uint32_t m_max_players = 0;
|
||||
bool m_is_locked = false;
|
||||
bool m_add_replay_on_join = true;
|
||||
std::string m_uuid;
|
||||
std::string m_expedition_name;
|
||||
DynamicZone m_dynamiczone { DynamicZoneType::Expedition };
|
||||
ExpeditionMember m_leader;
|
||||
|
||||
@ -26,17 +26,19 @@
|
||||
#include <fmt/core.h>
|
||||
|
||||
uint32_t ExpeditionDatabase::InsertExpedition(
|
||||
uint32_t instance_id, const std::string& expedition_name, uint32_t leader_id,
|
||||
uint32_t min_players, uint32_t max_players)
|
||||
const std::string& uuid, uint32_t instance_id, const std::string& expedition_name,
|
||||
uint32_t leader_id, uint32_t min_players, uint32_t max_players)
|
||||
{
|
||||
LogExpeditionsDetail("Inserting new expedition [{}] leader [{}]", expedition_name, leader_id);
|
||||
LogExpeditionsDetail(
|
||||
"Inserting new expedition [{}] leader [{}] uuid [{}]", expedition_name, leader_id, uuid
|
||||
);
|
||||
|
||||
std::string query = fmt::format(SQL(
|
||||
INSERT INTO expedition_details
|
||||
(instance_id, expedition_name, leader_id, min_players, max_players)
|
||||
(uuid, instance_id, expedition_name, leader_id, min_players, max_players)
|
||||
VALUES
|
||||
({}, '{}', {}, {}, {});
|
||||
), instance_id, expedition_name, leader_id, min_players, max_players);
|
||||
('{}', {}, '{}', {}, {}, {});
|
||||
), uuid, instance_id, expedition_name, leader_id, min_players, max_players);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
@ -53,6 +55,7 @@ std::string ExpeditionDatabase::LoadExpeditionsSelectQuery()
|
||||
return std::string(SQL(
|
||||
SELECT
|
||||
expedition_details.id,
|
||||
expedition_details.uuid,
|
||||
expedition_details.instance_id,
|
||||
expedition_details.expedition_name,
|
||||
expedition_details.leader_id,
|
||||
|
||||
@ -36,8 +36,8 @@ class MySQLRequestResult;
|
||||
namespace ExpeditionDatabase
|
||||
{
|
||||
uint32_t InsertExpedition(
|
||||
uint32_t instance_id, const std::string& expedition_name, uint32_t leader_id,
|
||||
uint32_t min_players, uint32_t max_players);
|
||||
const std::string& uuid, uint32_t instance_id, const std::string& expedition_name,
|
||||
uint32_t leader_id, uint32_t min_players, uint32_t max_players);
|
||||
std::string LoadExpeditionsSelectQuery();
|
||||
MySQLRequestResult LoadExpedition(uint32_t expedition_id);
|
||||
MySQLRequestResult LoadAllExpeditions();
|
||||
@ -79,6 +79,7 @@ namespace LoadExpeditionColumns
|
||||
enum eLoadExpeditionColumns
|
||||
{
|
||||
id = 0,
|
||||
uuid,
|
||||
instance_id,
|
||||
expedition_name,
|
||||
leader_id,
|
||||
|
||||
@ -95,6 +95,11 @@ int Lua_Expedition::GetSecondsRemaining() {
|
||||
return self->GetDynamicZone().GetSecondsRemaining();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetUUID() {
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetUUID();
|
||||
}
|
||||
|
||||
int Lua_Expedition::GetZoneID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetZoneID();
|
||||
@ -170,6 +175,7 @@ luabind::scope lua_register_expedition() {
|
||||
.def("GetMembers", &Lua_Expedition::GetMembers)
|
||||
.def("GetName", (std::string(Lua_Expedition::*)(void))&Lua_Expedition::GetName)
|
||||
.def("GetSecondsRemaining", (int(Lua_Expedition::*)(void))&Lua_Expedition::GetSecondsRemaining)
|
||||
.def("GetUUID", (std::string(Lua_Expedition::*)(void))&Lua_Expedition::GetUUID)
|
||||
.def("GetZoneID", (int(Lua_Expedition::*)(void))&Lua_Expedition::GetZoneID)
|
||||
.def("HasLockout", (bool(Lua_Expedition::*)(std::string))&Lua_Expedition::HasLockout)
|
||||
.def("HasReplayLockout", (bool(Lua_Expedition::*)(void))&Lua_Expedition::HasReplayLockout)
|
||||
|
||||
@ -57,21 +57,22 @@ public:
|
||||
uint32_t GetID();
|
||||
int GetInstanceID();
|
||||
std::string GetLeaderName();
|
||||
luabind::object GetLockouts(lua_State* L);
|
||||
uint32_t GetMemberCount();
|
||||
luabind::object GetMembers(lua_State* L);
|
||||
std::string GetName();
|
||||
int GetSecondsRemaining();
|
||||
std::string GetUUID();
|
||||
int GetZoneID();
|
||||
luabind::object GetLockouts(lua_State* L);
|
||||
bool HasLockout(std::string event_name);
|
||||
bool HasReplayLockout();
|
||||
void RemoveCompass();
|
||||
void RemoveLockout(std::string event_name);
|
||||
void SetCompass(uint32 zone_id, float x, float y, float z);
|
||||
void SetCompass(uint32_t zone_id, float x, float y, float z);
|
||||
void SetCompass(std::string zone_name, float x, float y, float z);
|
||||
void SetLocked(bool lock_expedition);
|
||||
void SetReplayLockoutOnMemberJoin(bool enable);
|
||||
void SetSafeReturn(uint32 zone_id, float x, float y, float z, float heading);
|
||||
void SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading);
|
||||
void SetSafeReturn(std::string zone_name, float x, float y, float z, float heading);
|
||||
void SetZoneInLocation(float x, float y, float z, float heading);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user