mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
Rework say links
We now consume 1 item ID for say links, this means you will be able to create more items! We used ID 0xFFFFF for this, which is the max ID an item can be in the item links. You have the rest to play with! Normal say links pass the ID in the first aug slot and silent say links in the second aug slot. This means we can have MANY more say links as well!
This commit is contained in:
parent
04b7ba7a1d
commit
d86307c720
@ -273,6 +273,9 @@ enum {
|
|||||||
#define NPC_DEFAULT_LOGGING_ENABLED false
|
#define NPC_DEFAULT_LOGGING_ENABLED false
|
||||||
|
|
||||||
|
|
||||||
|
// This is the item ID we use for say links, we use the max that fits in 5 ASCII chars
|
||||||
|
#define SAYLINK_ITEM_ID 0xFFFFF
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|||||||
@ -13774,11 +13774,10 @@ std::string Bot::CreateSayLink(Client* c, const char* message, const char* name)
|
|||||||
}
|
}
|
||||||
safe_delete_array(escaped_string);
|
safe_delete_array(escaped_string);
|
||||||
|
|
||||||
sayid += 500000;
|
|
||||||
|
|
||||||
Client::TextLink linker;
|
Client::TextLink linker;
|
||||||
linker.SetLinkType(linker.linkItemData);
|
linker.SetLinkType(linker.linkItemData);
|
||||||
linker.SetProxyItemID(sayid);
|
linker.SetProxyItemID(SAYLINK_ITEM_ID);
|
||||||
|
linker.SetProxyAugment1ID(sayid);
|
||||||
linker.SetProxyText(name);
|
linker.SetProxyText(name);
|
||||||
|
|
||||||
auto say_link = linker.GenerateLink();
|
auto say_link = linker.GenerateLink();
|
||||||
|
|||||||
@ -8090,34 +8090,32 @@ void Client::Handle_OP_InstillDoubt(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app)
|
void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app)
|
||||||
{
|
{
|
||||||
if (app->size != sizeof(ItemViewRequest_Struct)){
|
if (app->size != sizeof(ItemViewRequest_Struct)) {
|
||||||
Log.Out(Logs::General, Logs::Error, "Wrong size on OP_ItemLinkClick. Got: %i, Expected: %i", app->size, sizeof(ItemViewRequest_Struct));
|
Log.Out(Logs::General, Logs::Error, "Wrong size on OP_ItemLinkClick. Got: %i, Expected: %i", app->size,
|
||||||
|
sizeof(ItemViewRequest_Struct));
|
||||||
DumpPacket(app);
|
DumpPacket(app);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DumpPacket(app);
|
DumpPacket(app);
|
||||||
ItemViewRequest_Struct* ivrs = (ItemViewRequest_Struct*)app->pBuffer;
|
ItemViewRequest_Struct *ivrs = (ItemViewRequest_Struct *)app->pBuffer;
|
||||||
|
|
||||||
//todo: verify ivrs->link_hash based on a rule, in case we don't care about people being able to sniff data from the item DB
|
// todo: verify ivrs->link_hash based on a rule, in case we don't care about people being able to sniff data
|
||||||
|
// from the item DB
|
||||||
|
|
||||||
const Item_Struct* item = database.GetItem(ivrs->item_id);
|
const Item_Struct *item = database.GetItem(ivrs->item_id);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
if (ivrs->item_id > 500000)
|
if (ivrs->item_id != SAYLINK_ITEM_ID) {
|
||||||
{
|
Message(13, "Error: The item for the link you have clicked on does not exist!");
|
||||||
std::string response = "";
|
return;
|
||||||
int sayid = ivrs->item_id - 500000;
|
|
||||||
bool silentsaylink = false;
|
|
||||||
|
|
||||||
if (sayid > 250000) //Silent Saylink
|
|
||||||
{
|
|
||||||
sayid = sayid - 250000;
|
|
||||||
silentsaylink = true;
|
|
||||||
}
|
}
|
||||||
|
// This new scheme will shuttle the ID in the first augment for non-silent links
|
||||||
|
// and the second augment for silent.
|
||||||
|
std::string response = "";
|
||||||
|
bool silentsaylink = ivrs->augments[1] > 0 ? true : false;
|
||||||
|
int sayid = silentsaylink ? ivrs->augments[1] : ivrs->augments[0];
|
||||||
|
|
||||||
if (sayid > 0)
|
if (sayid > 0) {
|
||||||
{
|
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid);
|
std::string query = StringFormat("SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid);
|
||||||
auto results = database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
@ -8132,55 +8130,40 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
response = row[0];
|
response = row[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((response).size() > 0)
|
if ((response).size() > 0) {
|
||||||
{
|
if (!mod_saylink(response, silentsaylink)) {
|
||||||
if (!mod_saylink(response, silentsaylink)) { return; }
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (GetTarget() && GetTarget()->IsNPC())
|
if (GetTarget() && GetTarget()->IsNPC()) {
|
||||||
{
|
if (silentsaylink) {
|
||||||
if (silentsaylink)
|
|
||||||
{
|
|
||||||
parse->EventNPC(EVENT_SAY, GetTarget()->CastToNPC(), this, response.c_str(), 0);
|
parse->EventNPC(EVENT_SAY, GetTarget()->CastToNPC(), this, response.c_str(), 0);
|
||||||
parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0);
|
parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Message(7, "You say, '%s'", response.c_str());
|
Message(7, "You say, '%s'", response.c_str());
|
||||||
ChannelMessageReceived(8, 0, 100, response.c_str());
|
ChannelMessageReceived(8, 0, 100, response.c_str());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
if (silentsaylink) {
|
||||||
{
|
|
||||||
if (silentsaylink)
|
|
||||||
{
|
|
||||||
parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0);
|
parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Message(7, "You say, '%s'", response.c_str());
|
Message(7, "You say, '%s'", response.c_str());
|
||||||
ChannelMessageReceived(8, 0, 100, response.c_str());
|
ChannelMessageReceived(8, 0, 100, response.c_str());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Message(13, "Error: Say Link not found or is too long.");
|
Message(13, "Error: Say Link not found or is too long.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Message(13, "Error: The item for the link you have clicked on does not exist!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
ItemInst *inst =
|
||||||
|
database.CreateItem(item, item->MaxCharges, ivrs->augments[0], ivrs->augments[1], ivrs->augments[2],
|
||||||
ItemInst* inst = database.CreateItem(item, item->MaxCharges, ivrs->augments[0], ivrs->augments[1], ivrs->augments[2], ivrs->augments[3], ivrs->augments[4], ivrs->augments[5]);
|
ivrs->augments[3], ivrs->augments[4], ivrs->augments[5]);
|
||||||
if (inst) {
|
if (inst) {
|
||||||
SendItemPacket(0, inst, ItemPacketViewLink);
|
SendItemPacket(0, inst, ItemPacketViewLink);
|
||||||
safe_delete(inst);
|
safe_delete(inst);
|
||||||
|
|||||||
@ -2766,14 +2766,13 @@ const char* QuestManager::saylink(char* Phrase, bool silent, const char* LinkNam
|
|||||||
}
|
}
|
||||||
safe_delete_array(escaped_string);
|
safe_delete_array(escaped_string);
|
||||||
|
|
||||||
if (silent)
|
|
||||||
sayid = sayid + 750000;
|
|
||||||
else
|
|
||||||
sayid = sayid + 500000;
|
|
||||||
|
|
||||||
//Create the say link as an item link hash
|
//Create the say link as an item link hash
|
||||||
Client::TextLink linker;
|
Client::TextLink linker;
|
||||||
linker.SetProxyItemID(sayid);
|
linker.SetProxyItemID(SAYLINK_ITEM_ID);
|
||||||
|
if (silent)
|
||||||
|
linker.SetProxyAugment2ID(sayid);
|
||||||
|
else
|
||||||
|
linker.SetProxyAugment1ID(sayid);
|
||||||
linker.SetProxyText(LinkName);
|
linker.SetProxyText(LinkName);
|
||||||
|
|
||||||
auto say_link = linker.GenerateLink();
|
auto say_link = linker.GenerateLink();
|
||||||
|
|||||||
@ -292,7 +292,7 @@ bool Zone::LoadGroundSpawns() {
|
|||||||
char* name=0;
|
char* name=0;
|
||||||
uint32 gsnumber=0;
|
uint32 gsnumber=0;
|
||||||
for(gsindex=0;gsindex<50;gsindex++){
|
for(gsindex=0;gsindex<50;gsindex++){
|
||||||
if(groundspawn.spawn[gsindex].item>0 && groundspawn.spawn[gsindex].item<500000){
|
if(groundspawn.spawn[gsindex].item>0 && groundspawn.spawn[gsindex].item<SAYLINK_ITEM_ID){
|
||||||
ItemInst* inst = nullptr;
|
ItemInst* inst = nullptr;
|
||||||
inst = database.CreateItem(groundspawn.spawn[gsindex].item);
|
inst = database.CreateItem(groundspawn.spawn[gsindex].item);
|
||||||
gsnumber=groundspawn.spawn[gsindex].max_allowed;
|
gsnumber=groundspawn.spawn[gsindex].max_allowed;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user