Allow display window to be snoozed

This commit is contained in:
Akkadius 2018-11-05 00:26:52 -06:00
parent 775b5fcaf1
commit d75afd4688
8 changed files with 131 additions and 51 deletions

View File

@ -77,6 +77,11 @@ namespace EQEmu
} // namespace invtype
namespace popupresponse {
const int32 SERVER_INTERNAL_USE_BASE = 2000000000;
const int32 MOB_INFO_DISMISS = 2000000001;
}
namespace invslot {
using namespace RoF2::invslot::enum_;

View File

@ -5468,4 +5468,14 @@ void Mob::SetSpawnedInWater(bool spawned_in_water) {
int32 Mob::GetHPRegen() const
{
return hp_regen;
}
}
bool Client::GetDisplayMobInfoWindow() const
{
return display_mob_info_window;
}
void Client::SetDisplayMobInfoWindow(bool display_mob_info_window)
{
Client::display_mob_info_window = display_mob_info_window;
}

View File

@ -166,6 +166,7 @@ Client::Client(EQStreamInterface* ieqs)
for (int client_filter = 0; client_filter < _FilterCount; client_filter++)
ClientFilters[client_filter] = FilterShow;
display_mob_info_window = true;
character_id = 0;
conn_state = NoPacketsReceived;
client_data_loaded = false;
@ -4031,9 +4032,9 @@ void Client::SetHoTT(uint32 mobid) {
void Client::SendPopupToClient(const char *Title, const char *Text, uint32 PopupID, uint32 Buttons, uint32 Duration)
{
auto outapp = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
OnLevelMessage_Struct *olms = (OnLevelMessage_Struct *)outapp->pBuffer;
OnLevelMessage_Struct *olms = (OnLevelMessage_Struct *) outapp->pBuffer;
if ((strlen(Title) > (sizeof(olms->Title) - 1)) || (strlen(Text) > (sizeof(olms->Text) - 1))) {
safe_delete(outapp);
@ -4045,12 +4046,14 @@ void Client::SendPopupToClient(const char *Title, const char *Text, uint32 Popup
olms->Buttons = Buttons;
if (Duration > 0)
if (Duration > 0) {
olms->Duration = Duration * 1000;
else
}
else {
olms->Duration = 0xffffffff;
}
olms->PopupID = PopupID;
olms->PopupID = PopupID;
olms->NegativeID = 0;
sprintf(olms->ButtonName0, "%s", "Yes");
@ -4059,16 +4062,29 @@ void Client::SendPopupToClient(const char *Title, const char *Text, uint32 Popup
safe_delete(outapp);
}
void Client::SendFullPopup(const char *Title, const char *Text, uint32 PopupID, uint32 NegativeID, uint32 Buttons, uint32 Duration, const char *ButtonName0, const char *ButtonName1, uint32 SoundControls) {
void Client::SendFullPopup(
const char *Title,
const char *Text,
uint32 PopupID,
uint32 NegativeID,
uint32 Buttons,
uint32 Duration,
const char *ButtonName0,
const char *ButtonName1,
uint32 SoundControls
)
{
auto outapp = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
OnLevelMessage_Struct *olms = (OnLevelMessage_Struct *)outapp->pBuffer;
if((strlen(Text) > (sizeof(olms->Text)-1)) || (strlen(Title) > (sizeof(olms->Title) - 1)) ) {
OnLevelMessage_Struct *olms = (OnLevelMessage_Struct *) outapp->pBuffer;
if ((strlen(Text) > (sizeof(olms->Text) - 1)) || (strlen(Title) > (sizeof(olms->Title) - 1))) {
safe_delete(outapp);
return;
}
if (ButtonName0 && ButtonName1 && ( (strlen(ButtonName0) > (sizeof(olms->ButtonName0) - 1)) || (strlen(ButtonName1) > (sizeof(olms->ButtonName1) - 1)) ) ) {
if (ButtonName0 && ButtonName1 && ((strlen(ButtonName0) > (sizeof(olms->ButtonName0) - 1)) ||
(strlen(ButtonName1) > (sizeof(olms->ButtonName1) - 1)))) {
safe_delete(outapp);
return;
}
@ -4077,31 +4093,47 @@ void Client::SendFullPopup(const char *Title, const char *Text, uint32 PopupID,
strcpy(olms->Text, Text);
olms->Buttons = Buttons;
if (ButtonName0 == NULL || ButtonName1 == NULL) {
if (ButtonName0 == nullptr || ButtonName1 == nullptr) {
sprintf(olms->ButtonName0, "%s", "Yes");
sprintf(olms->ButtonName1, "%s", "No");
} else {
}
else {
strcpy(olms->ButtonName0, ButtonName0);
strcpy(olms->ButtonName1, ButtonName1);
}
if(Duration > 0)
if (Duration > 0) {
olms->Duration = Duration * 1000;
else
}
else {
olms->Duration = 0xffffffff;
}
olms->PopupID = PopupID;
olms->NegativeID = NegativeID;
olms->PopupID = PopupID;
olms->NegativeID = NegativeID;
olms->SoundControls = SoundControls;
QueuePacket(outapp);
safe_delete(outapp);
}
void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const char *ButtonName0, const char *ButtonName1, uint32 Duration, int title_type, Client* target, const char *Title, const char *Text, ...) {
void Client::SendWindow(
uint32 PopupID,
uint32 NegativeID,
uint32 Buttons,
const char *ButtonName0,
const char *ButtonName1,
uint32 Duration,
int title_type,
Client *target,
const char *Title,
const char *Text,
...
)
{
va_list argptr;
char buffer[4096];
char buffer[4096];
va_start(argptr, Text);
vsnprintf(buffer, sizeof(buffer), Text, argptr);
@ -4109,23 +4141,23 @@ void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const
size_t len = strlen(buffer);
auto app = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
OnLevelMessage_Struct* olms=(OnLevelMessage_Struct*)app->pBuffer;
auto app = new EQApplicationPacket(OP_OnLevelMessage, sizeof(OnLevelMessage_Struct));
OnLevelMessage_Struct *olms = (OnLevelMessage_Struct *) app->pBuffer;
if(strlen(Text) > (sizeof(olms->Text)-1)) {
if (strlen(Text) > (sizeof(olms->Text) - 1)) {
safe_delete(app);
return;
}
if(!target)
if (!target) {
title_type = 0;
}
switch (title_type)
{
switch (title_type) {
case 1: {
char name[64] = "";
strcpy(name, target->GetName());
if(target->GetLastName()) {
if (target->GetLastName()) {
char last_name[64] = "";
strcpy(last_name, target->GetLastName());
strcat(name, " ");
@ -4135,8 +4167,8 @@ void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const
break;
}
case 2: {
if(target->GuildID()) {
char *guild_name = (char*)guild_mgr.GetGuildName(target->GuildID());
if (target->GuildID()) {
char *guild_name = (char *) guild_mgr.GetGuildName(target->GuildID());
strcpy(olms->Title, guild_name);
}
else {
@ -4150,19 +4182,21 @@ void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const
}
}
memcpy(olms->Text, buffer, len+1);
memcpy(olms->Text, buffer, len + 1);
olms->Buttons = Buttons;
sprintf(olms->ButtonName0, "%s", ButtonName0);
sprintf(olms->ButtonName1, "%s", ButtonName1);
if(Duration > 0)
if (Duration > 0) {
olms->Duration = Duration * 1000;
else
}
else {
olms->Duration = 0xffffffff;
}
olms->PopupID = PopupID;
olms->PopupID = PopupID;
olms->NegativeID = NegativeID;
FastQueuePacket(&app);

View File

@ -246,6 +246,9 @@ public:
std::unordered_map<Mob *, float> close_mobs;
bool is_client_moving;
void SetDisplayMobInfoWindow(bool display_mob_info_window);
bool GetDisplayMobInfoWindow() const;
//abstract virtual function implementations required by base abstract class
virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, EQEmu::skills::SkillType attack_skill);
virtual void Damage(Mob* from, int32 damage, uint16 spell_id, EQEmu::skills::SkillType attack_skill, bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false, eSpecialAttacks special = eSpecialAttacks::None);
@ -1458,6 +1461,8 @@ private:
int Haste; //precalced value
uint32 tmSitting; // time stamp started sitting, used for HP regen bonus added on MAY 5, 2004
bool display_mob_info_window;
int32 max_end;
int32 current_endurance;

View File

@ -10885,33 +10885,46 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app)
{
if (app->size != sizeof(PopupResponse_Struct)) {
Log(Logs::General, Logs::None, "Size mismatch in OP_PopupResponse expected %i got %i",
sizeof(PopupResponse_Struct), app->size);
Log(Logs::General,
Logs::None,
"Size mismatch in OP_PopupResponse expected %i got %i",
sizeof(PopupResponse_Struct),
app->size);
DumpPacket(app);
return;
}
PopupResponse_Struct *prs = (PopupResponse_Struct*)app->pBuffer;
// Handle any EQEmu defined popup Ids first
switch (prs->popupid)
{
case POPUPID_UPDATE_SHOWSTATSWINDOW:
if (GetTarget() && GetTarget()->IsClient())
GetTarget()->CastToClient()->SendStatsWindow(this, true);
else
SendStatsWindow(this, true);
return;
PopupResponse_Struct *popup_response = (PopupResponse_Struct *) app->pBuffer;
default:
break;
/**
* Handle any EQEmu defined popup Ids first
*/
switch (popup_response->popupid) {
case POPUPID_UPDATE_SHOWSTATSWINDOW:
if (GetTarget() && GetTarget()->IsClient()) {
GetTarget()->CastToClient()->SendStatsWindow(this, true);
}
else {
SendStatsWindow(this, true);
}
return;
break;
case EQEmu::popupresponse::MOB_INFO_DISMISS:
this->SetDisplayMobInfoWindow(false);
this->Message(15, "GM Mob display window snoozed in this zone...");
break;
default:
break;
}
char buf[16];
sprintf(buf, "%d\0", prs->popupid);
sprintf(buf, "%d\0", popup_response->popupid);
parse->EventPlayer(EVENT_POPUP_RESPONSE, this, buf, 0);
Mob* Target = GetTarget();
Mob *Target = GetTarget();
if (Target && Target->IsNPC()) {
parse->EventNPC(EVENT_POPUP_RESPONSE, Target->CastToNPC(), this, buf, 0);
}

View File

@ -249,7 +249,7 @@ int command_init(void)
command_add("lastname", "[new lastname] - Set your or your player target's lastname", 50, command_lastname) ||
command_add("level", "[level] - Set your or your target's level", 10, command_level) ||
command_add("listnpcs", "[name/range] - Search NPCs", 20, command_listnpcs) ||
command_add("list", "[npc] [name|all] - Search entities", 20, command_list) ||
command_add("list", "[npcs|players|corpses|doors|objects] [search] - Search entities", 20, command_list) ||
command_add("listpetition", "- List petitions", 50, command_listpetition) ||
command_add("load_shared_memory", "[shared_memory_name] - Reloads shared memory and uses the input as output", 250, command_load_shared_memory) ||
command_add("loc", "- Print out your or your target's current location and heading", 0, command_loc) ||

View File

@ -3489,7 +3489,9 @@ void Mob::SetTarget(Mob *mob)
else if (IsClient()) {
parse->EventPlayer(EVENT_TARGET_CHANGE, CastToClient(), "", 0);
this->DisplayInfo(mob);
if (this->CastToClient()->admin > 200) {
this->DisplayInfo(mob);
}
}
if (IsPet() && GetOwner() && GetOwner()->IsClient()) {

View File

@ -362,6 +362,17 @@ void Mob::DisplayInfo(Mob *mob)
std::cout << "Window Length: " << window_text.length() << std::endl;
// std::cout << "Window " << window_text << std::endl;
client->SendPopupToClient("Entity Info", window_text.c_str());
if (client->GetDisplayMobInfoWindow()) {
client->SendFullPopup(
"GM: Entity Info",
window_text.c_str(),
EQEmu::popupresponse::MOB_INFO_DISMISS,
0,
100,
10,
"Snooze",
"OK"
);
}
}
}