Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
[Quest API] (Performance) Check event EVENT_COMBINE, EVENT_COMBINE_SU…
Browse files Browse the repository at this point in the history
…CCESS, EVENT_COMBINE_FAILURE, or EVENT_COMBINE_VALIDATE exist before export and execute (EQEmu#2896)

* [Quest API] Optionally parse EVENT_COMBINE_SUCCESS and EVENT_COMBINE_FAILURE

- Optionally parse these events instead of always doing so.

* Update tradeskills.cpp

* Update tradeskills.cpp
  • Loading branch information
Kinglykrab authored and catapultam-habeo committed Mar 27, 2023
1 parent 1b3e3c7 commit 2c596b5
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions zone/tradeskills.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,13 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob

DBTradeskillRecipe_Struct spec;

if (parse->EventPlayer(EVENT_COMBINE, user, std::to_string(in_combine->container_slot), 0) == 1) {
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
if (parse->PlayerHasQuestSub(EVENT_COMBINE)) {
if (parse->EventPlayer(EVENT_COMBINE, user, std::to_string(in_combine->container_slot), 0) == 1) {
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
}

if (!content_db.GetTradeRecipe(container, c_type, some_id, user->CharacterID(), &spec)) {
Expand Down Expand Up @@ -446,13 +448,17 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
}

// final check for any additional quest requirements .. "check_zone" in this case - exported as variable [validate_type]
std::string export_string = fmt::format("check_zone {}", zone->GetZoneID());
if (parse->EventPlayer(EVENT_COMBINE_VALIDATE, user, export_string, spec.recipe_id) != 0) {
user->Message(Chat::Emote, "You cannot make this combine because the location requirement has not been met.");
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
if (parse->PlayerHasQuestSub(EVENT_COMBINE_VALIDATE)) {
if (parse->EventPlayer(EVENT_COMBINE_VALIDATE, user, fmt::format("check_zone {}", zone->GetZoneID()), spec.recipe_id) != 0) {
user->Message(
Chat::Emote,
"You cannot make this combine because the location requirement has not been met."
);
auto outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
}

// Send acknowledgement packets to client
Expand Down Expand Up @@ -509,24 +515,29 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
.recipe_id = spec.recipe_id,
.recipe_name = spec.name,
.made_count = spec.madecount,
.tradeskill_id = (uint32)spec.tradeskill
.tradeskill_id = (uint32) spec.tradeskill
};
RecordPlayerEventLogWithClient(user, PlayerEvent::COMBINE_SUCCESS, e);
}

parse->EventPlayer(EVENT_COMBINE_SUCCESS, user, spec.name, spec.recipe_id);
} else {
if (parse->PlayerHasQuestSub(EVENT_COMBINE_SUCCESS)) {
parse->EventPlayer(EVENT_COMBINE_SUCCESS, user, spec.name, spec.recipe_id);
}
}
else {
if (player_event_logs.IsEventEnabled(PlayerEvent::COMBINE_FAILURE)) {
auto e = PlayerEvent::CombineEvent{
.recipe_id = spec.recipe_id,
.recipe_name = spec.name,
.made_count = spec.madecount,
.tradeskill_id = (uint32)spec.tradeskill
.tradeskill_id = (uint32) spec.tradeskill
};
RecordPlayerEventLogWithClient(user, PlayerEvent::COMBINE_FAILURE, e);
}

parse->EventPlayer(EVENT_COMBINE_FAILURE, user, spec.name, spec.recipe_id);
if (parse->PlayerHasQuestSub(EVENT_COMBINE_FAILURE)) {
parse->EventPlayer(EVENT_COMBINE_FAILURE, user, spec.name, spec.recipe_id);
}
}
}

Expand Down Expand Up @@ -701,9 +712,13 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
}

if (success) {
parse->EventPlayer(EVENT_COMBINE_SUCCESS, user, spec.name, spec.recipe_id);
if (parse->PlayerHasQuestSub(EVENT_COMBINE_SUCCESS)) {
parse->EventPlayer(EVENT_COMBINE_SUCCESS, user, spec.name, spec.recipe_id);
}
} else {
parse->EventPlayer(EVENT_COMBINE_FAILURE, user, spec.name, spec.recipe_id);
if (parse->PlayerHasQuestSub(EVENT_COMBINE_FAILURE)) {
parse->EventPlayer(EVENT_COMBINE_FAILURE, user, spec.name, spec.recipe_id);
}
}
}

Expand Down

0 comments on commit 2c596b5

Please sign in to comment.