mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
[Quest API] Add SendToInstance(instance_type, zone_short_name, instance_version, x, y, z, heading, instance_identifier, duration) to Perl/Lua. (#1417)
* [Quest API] Add SendToInstance(instance_type, zone_short_name, instance_version, x, y, z, heading, instance_identifier, duration) to Perl/Lua. - Add $client->SendToInstance(instance_type, zone_short_name, instance_version, x, y, z, heading, instance_identifier, duration) to Perl. - Add client:SendToInstance(instance_type, zone_short_name, instance_version, x, y, z, heading, instance_identifier, duration) to Lua. * Fix instance naming. * Add current instance type to bucket name, remove unused variables. * Typo.
This commit is contained in:
parent
3f8b67e500
commit
ccfc8b296f
@ -10130,6 +10130,54 @@ void Client::SetAFK(uint8 afk_flag) {
|
|||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Client::SendToInstance(std::string instance_type, std::string zone_short_name, uint32 instance_version, float x, float y, float z, float heading, std::string instance_identifier, uint32 duration) {
|
||||||
|
uint32 zone_id = ZoneID(zone_short_name);
|
||||||
|
std::string current_instance_type = str_tolower(instance_type);
|
||||||
|
std::string instance_type_name = "public";
|
||||||
|
if (current_instance_type.find("solo") != std::string::npos) {
|
||||||
|
instance_type_name = GetCleanName();
|
||||||
|
} else if (current_instance_type.find("group") != std::string::npos) {
|
||||||
|
uint32 group_id = (GetGroup() ? GetGroup()->GetID() : 0);
|
||||||
|
instance_type_name = itoa(group_id);
|
||||||
|
} else if (current_instance_type.find("raid") != std::string::npos) {
|
||||||
|
uint32 raid_id = (GetRaid() ? GetRaid()->GetID() : 0);
|
||||||
|
instance_type_name = itoa(raid_id);
|
||||||
|
} else if (current_instance_type.find("guild") != std::string::npos) {
|
||||||
|
uint32 guild_id = (GuildID() > 0 ? GuildID() : 0);
|
||||||
|
instance_type_name = itoa(guild_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string full_bucket_name = fmt::format(
|
||||||
|
"{}_{}_{}_{}",
|
||||||
|
current_instance_type,
|
||||||
|
instance_type_name,
|
||||||
|
instance_identifier,
|
||||||
|
zone_short_name
|
||||||
|
);
|
||||||
|
std::string current_bucket_value = DataBucket::GetData(full_bucket_name);
|
||||||
|
uint16 instance_id = 0;
|
||||||
|
|
||||||
|
if (current_bucket_value.length() > 0) {
|
||||||
|
instance_id = atoi(current_bucket_value.c_str());
|
||||||
|
} else {
|
||||||
|
if(!database.GetUnusedInstanceID(instance_id)) {
|
||||||
|
Message(Chat::White, "Server was unable to find a free instance id.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!database.CreateInstance(instance_id, zone_id, instance_version, duration)) {
|
||||||
|
Message(Chat::White, "Server was unable to create a new instance.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataBucket::SetData(full_bucket_name, itoa(instance_id), itoa(duration));
|
||||||
|
}
|
||||||
|
|
||||||
|
AssignToInstance(instance_id);
|
||||||
|
MovePC(zone_id, instance_id, x, y, z, heading);
|
||||||
|
}
|
||||||
|
|
||||||
int Client::CountItem(uint32 item_id)
|
int Client::CountItem(uint32 item_id)
|
||||||
{
|
{
|
||||||
int quantity = 0;
|
int quantity = 0;
|
||||||
|
|||||||
@ -662,6 +662,7 @@ public:
|
|||||||
void MoveZoneInstanceGroup(uint16 instance_id);
|
void MoveZoneInstanceGroup(uint16 instance_id);
|
||||||
void MoveZoneInstanceRaid(uint16 instance_id);
|
void MoveZoneInstanceRaid(uint16 instance_id);
|
||||||
void SendToGuildHall();
|
void SendToGuildHall();
|
||||||
|
void SendToInstance(std::string instance_type, std::string zone_short_name, uint32 instance_version, float x, float y, float z, float heading, std::string instance_identifier, uint32 duration);
|
||||||
void AssignToInstance(uint16 instance_id);
|
void AssignToInstance(uint16 instance_id);
|
||||||
void RemoveFromInstance(uint16 instance_id);
|
void RemoveFromInstance(uint16 instance_id);
|
||||||
void WhoAll();
|
void WhoAll();
|
||||||
|
|||||||
@ -2138,6 +2138,11 @@ void Lua_Client::ResetAllDisciplineTimers() {
|
|||||||
self->ResetAllDisciplineTimers();
|
self->ResetAllDisciplineTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lua_Client::SendToInstance(std::string instance_type, std::string zone_short_name, uint32 instance_version, float x, float y, float z, float heading, std::string instance_identifier, uint32 duration) {
|
||||||
|
Lua_Safe_Call_Void();
|
||||||
|
self->SendToInstance(instance_type, zone_short_name, instance_version, x, y, z, heading, instance_identifier, duration);
|
||||||
|
}
|
||||||
|
|
||||||
int Lua_Client::CountItem(uint32 item_id) {
|
int Lua_Client::CountItem(uint32 item_id) {
|
||||||
Lua_Safe_Call_Int();
|
Lua_Safe_Call_Int();
|
||||||
return self->CountItem(item_id);
|
return self->CountItem(item_id);
|
||||||
@ -2517,6 +2522,7 @@ luabind::scope lua_register_client() {
|
|||||||
.def("Popup", (void(Lua_Client::*)(const char*,const char*,uint32,uint32,uint32,uint32,const char*,const char*))& Lua_Client::Popup)
|
.def("Popup", (void(Lua_Client::*)(const char*,const char*,uint32,uint32,uint32,uint32,const char*,const char*))& Lua_Client::Popup)
|
||||||
.def("Popup", (void(Lua_Client::*)(const char*,const char*,uint32,uint32,uint32,uint32,const char*,const char*,uint32))&Lua_Client::Popup)
|
.def("Popup", (void(Lua_Client::*)(const char*,const char*,uint32,uint32,uint32,uint32,const char*,const char*,uint32))&Lua_Client::Popup)
|
||||||
.def("ResetAllDisciplineTimers", (void(Lua_Client::*)(void))&Lua_Client::ResetAllDisciplineTimers)
|
.def("ResetAllDisciplineTimers", (void(Lua_Client::*)(void))&Lua_Client::ResetAllDisciplineTimers)
|
||||||
|
.def("SendToInstance", (void(Lua_Client::*)(std::string,std::string,uint32,float,float,float,float,std::string,uint32))&Lua_Client::SendToInstance)
|
||||||
.def("CountItem", (int(Lua_Client::*)(uint32))&Lua_Client::CountItem)
|
.def("CountItem", (int(Lua_Client::*)(uint32))&Lua_Client::CountItem)
|
||||||
.def("RemoveItem", (void(Lua_Client::*)(uint32))&Lua_Client::RemoveItem)
|
.def("RemoveItem", (void(Lua_Client::*)(uint32))&Lua_Client::RemoveItem)
|
||||||
.def("RemoveItem", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::RemoveItem);
|
.def("RemoveItem", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::RemoveItem);
|
||||||
|
|||||||
@ -41,6 +41,7 @@ public:
|
|||||||
bool IsLD();
|
bool IsLD();
|
||||||
void WorldKick();
|
void WorldKick();
|
||||||
void SendToGuildHall();
|
void SendToGuildHall();
|
||||||
|
void SendToInstance(std::string instance_type, std::string zone_short_name, uint32 instance_version, float x, float y, float z, float heading, std::string instance_identifier, uint32 duration);
|
||||||
int GetAnon();
|
int GetAnon();
|
||||||
void SetAnon(uint8 anon_flag);
|
void SetAnon(uint8 anon_flag);
|
||||||
int GetAFK();
|
int GetAFK();
|
||||||
|
|||||||
@ -5345,6 +5345,28 @@ XS(XS_Client_ResetAllDisciplineTimers) {
|
|||||||
XSRETURN_EMPTY;
|
XSRETURN_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XS(XS_Client_SendToInstance);
|
||||||
|
XS(XS_Client_SendToInstance) {
|
||||||
|
dXSARGS;
|
||||||
|
if (items != 10)
|
||||||
|
Perl_croak(aTHX_ "Usage: Client::SendToInstance(THIS, std::string instance_type, std::string zone_short_name, uint32 instance_version, float x, float y, float z, float heading, std::string instance_identifier, uint32 duration)");
|
||||||
|
{
|
||||||
|
Client* THIS;
|
||||||
|
std::string instance_type = (std::string) SvPV_nolen(ST(1));
|
||||||
|
std::string zone_short_name = (std::string) SvPV_nolen(ST(2));
|
||||||
|
uint32 instance_version = (uint32) SvUV(ST(3));
|
||||||
|
float x = (float) SvNV(ST(4));
|
||||||
|
float y = (float) SvNV(ST(5));
|
||||||
|
float z = (float) SvNV(ST(6));
|
||||||
|
float heading = (float) SvNV(ST(7));
|
||||||
|
std::string instance_identifier = (std::string) SvPV_nolen(ST(8));
|
||||||
|
uint32 duration = (uint32) SvUV(ST(9));
|
||||||
|
VALIDATE_THIS_IS_CLIENT;
|
||||||
|
THIS->SendToInstance(instance_type, zone_short_name, instance_version, x, y, z, heading, instance_identifier, duration);
|
||||||
|
}
|
||||||
|
XSRETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
XS(XS_Client_CountItem);
|
XS(XS_Client_CountItem);
|
||||||
XS(XS_Client_CountItem) {
|
XS(XS_Client_CountItem) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
@ -5616,6 +5638,7 @@ XS(boot_Client) {
|
|||||||
newXSproto(strcpy(buf, "SendSound"), XS_Client_SendSound, file, "$");
|
newXSproto(strcpy(buf, "SendSound"), XS_Client_SendSound, file, "$");
|
||||||
newXSproto(strcpy(buf, "SendSpellAnim"), XS_Client_SendSpellAnim, file, "$$$");
|
newXSproto(strcpy(buf, "SendSpellAnim"), XS_Client_SendSpellAnim, file, "$$$");
|
||||||
newXSproto(strcpy(buf, "SendTargetCommand"), XS_Client_SendTargetCommand, file, "$$");
|
newXSproto(strcpy(buf, "SendTargetCommand"), XS_Client_SendTargetCommand, file, "$$");
|
||||||
|
newXSproto(strcpy(buf, "SendToInstance"), XS_Client_SendToInstance, file, "$$$$$$$$$$");
|
||||||
newXSproto(strcpy(buf, "SendToGuildHall"), XS_Client_SendToGuildHall, file, "$");
|
newXSproto(strcpy(buf, "SendToGuildHall"), XS_Client_SendToGuildHall, file, "$");
|
||||||
newXSproto(strcpy(buf, "SendWebLink"), XS_Client_SendWebLink, file, "$:$");
|
newXSproto(strcpy(buf, "SendWebLink"), XS_Client_SendWebLink, file, "$:$");
|
||||||
newXSproto(strcpy(buf, "SendZoneFlagInfo"), XS_Client_SendZoneFlagInfo, file, "$$");
|
newXSproto(strcpy(buf, "SendZoneFlagInfo"), XS_Client_SendZoneFlagInfo, file, "$$");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user