Fix for tradeskill query [skip ci]

This commit is contained in:
Akkadius 2020-04-04 03:55:53 -05:00
parent 58534dea16
commit bcef171cf9

View File

@ -599,7 +599,7 @@ void Client::CompleteConnect()
if (group) if (group)
group->SendHPManaEndPacketsTo(this); group->SendHPManaEndPacketsTo(this);
} }
//bulk raid send in here eventually //bulk raid send in here eventually
@ -1237,7 +1237,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.ClearOldRecastTimestamps(cid); /* Clear out our old recast timestamps to keep the DB clean */ database.ClearOldRecastTimestamps(cid); /* Clear out our old recast timestamps to keep the DB clean */
// set to full support in case they're a gm with items in disabled expansion slots..but, have their gm flag off... // set to full support in case they're a gm with items in disabled expansion slots..but, have their gm flag off...
// item loss will occur when they use the 'empty' slots, if this is not done // item loss will occur when they use the 'empty' slots, if this is not done
m_inv.SetGMInventory(true); m_inv.SetGMInventory(true);
loaditems = database.GetInventory(cid, &m_inv); /* Load Character Inventory */ loaditems = database.GetInventory(cid, &m_inv); /* Load Character Inventory */
database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */ database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */
database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */ database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */
@ -1341,7 +1341,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
client_max_level = GetCharMaxLevelFromBucket(); client_max_level = GetCharMaxLevelFromBucket();
} }
SetClientMaxLevel(client_max_level); SetClientMaxLevel(client_max_level);
// we know our class now, so we might have to fix our consume timer! // we know our class now, so we might have to fix our consume timer!
if (class_ == MONK) if (class_ == MONK)
consume_food_timer.SetTimer(CONSUMPTION_MNK_TIMER); consume_food_timer.SetTimer(CONSUMPTION_MNK_TIMER);
@ -2840,7 +2840,7 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app)
// rogue simply won't apply at all, no skill check done. // rogue simply won't apply at all, no skill check done.
uint16 poison_skill = GetSkill(EQEmu::skills::SkillApplyPoison); uint16 poison_skill = GetSkill(EQEmu::skills::SkillApplyPoison);
if (ChanceRoll < (.75 + poison_skill / 1000)) { if (ChanceRoll < (.75 + poison_skill / 1000)) {
ApplyPoisonSuccessResult = 1; ApplyPoisonSuccessResult = 1;
AddProcToWeapon(poison->Proc.Effect, false, (GetDEX() / 100) + 103, POISON_PROC); AddProcToWeapon(poison->Proc.Effect, false, (GetDEX() / 100) + 103, POISON_PROC);
@ -3917,7 +3917,7 @@ void Client::Handle_OP_Bug(const EQApplicationPacket *app)
Message(0, "Bug reporting is disabled on this server."); Message(0, "Bug reporting is disabled on this server.");
return; return;
} }
if (app->size != sizeof(BugReport_Struct)) { if (app->size != sizeof(BugReport_Struct)) {
printf("Wrong size of BugReport_Struct got %d expected %zu!\n", app->size, sizeof(BugReport_Struct)); printf("Wrong size of BugReport_Struct got %d expected %zu!\n", app->size, sizeof(BugReport_Struct));
} }
@ -4362,9 +4362,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
sizeof(PlayerPositionUpdateClient_Struct), app->size); sizeof(PlayerPositionUpdateClient_Struct), app->size);
return; return;
} }
PlayerPositionUpdateClient_Struct *ppu = (PlayerPositionUpdateClient_Struct *) app->pBuffer; PlayerPositionUpdateClient_Struct *ppu = (PlayerPositionUpdateClient_Struct *) app->pBuffer;
/* Boat handling */ /* Boat handling */
if (ppu->spawn_id != GetID()) { if (ppu->spawn_id != GetID()) {
/* If player is controlling boat */ /* If player is controlling boat */
@ -4374,16 +4374,16 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
controlling_boat_id = 0; controlling_boat_id = 0;
return; return;
} }
auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading)); auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading));
boat->SetDelta(boat_delta); boat->SetDelta(boat_delta);
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
PlayerPositionUpdateServer_Struct *ppus = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer; PlayerPositionUpdateServer_Struct *ppus = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer;
boat->MakeSpawnUpdate(ppus); boat->MakeSpawnUpdate(ppus);
entity_list.QueueCloseClients(boat, outapp, true, 300, this, false); entity_list.QueueCloseClients(boat, outapp, true, 300, this, false);
safe_delete(outapp); safe_delete(outapp);
/* Update the boat's position on the server, without sending an update */ /* Update the boat's position on the server, without sending an update */
boat->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading), false); boat->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading), false);
return; return;
@ -4398,9 +4398,9 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
if (cmob != nullptr) { if (cmob != nullptr) {
cmob->SetPosition(ppu->x_pos, ppu->y_pos, ppu->z_pos); cmob->SetPosition(ppu->x_pos, ppu->y_pos, ppu->z_pos);
cmob->SetHeading(EQ12toFloat(ppu->heading)); cmob->SetHeading(EQ12toFloat(ppu->heading));
mMovementManager->SendCommandToClients(cmob, 0.0, 0.0, 0.0, mMovementManager->SendCommandToClients(cmob, 0.0, 0.0, 0.0,
0.0, 0, ClientRangeAny, nullptr, this); 0.0, 0, ClientRangeAny, nullptr, this);
cmob->CastToNPC()->SaveGuardSpot(glm::vec4(ppu->x_pos, cmob->CastToNPC()->SaveGuardSpot(glm::vec4(ppu->x_pos,
ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading))); ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading)));
} }
} }
@ -4418,7 +4418,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
// From this point forward, we need to use a new set of variables for client // From this point forward, we need to use a new set of variables for client
// position. If the client is in a boat, we need to add the boat pos and // position. If the client is in a boat, we need to add the boat pos and
// the client offset together. // the client offset together.
float cx = ppu->x_pos; float cx = ppu->x_pos;
float cy = ppu->y_pos; float cy = ppu->y_pos;
float cz = ppu->z_pos; float cz = ppu->z_pos;
@ -4443,45 +4443,45 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
/* Check to see if PPU should trigger an update to the rewind position. */ /* Check to see if PPU should trigger an update to the rewind position. */
float rewind_x_diff = 0; float rewind_x_diff = 0;
float rewind_y_diff = 0; float rewind_y_diff = 0;
rewind_x_diff = cx - m_RewindLocation.x; rewind_x_diff = cx - m_RewindLocation.x;
rewind_x_diff *= rewind_x_diff; rewind_x_diff *= rewind_x_diff;
rewind_y_diff = cy - m_RewindLocation.y; rewind_y_diff = cy - m_RewindLocation.y;
rewind_y_diff *= rewind_y_diff; rewind_y_diff *= rewind_y_diff;
/* /*
We only need to store updated values if the player has moved. We only need to store updated values if the player has moved.
If the player has moved more than units for x or y, then we'll store If the player has moved more than units for x or y, then we'll store
his pre-PPU x and y for /rewind, in case he gets stuck. his pre-PPU x and y for /rewind, in case he gets stuck.
*/ */
if ((rewind_x_diff > 750) || (rewind_y_diff > 750)) if ((rewind_x_diff > 750) || (rewind_y_diff > 750))
m_RewindLocation = glm::vec3(m_Position); m_RewindLocation = glm::vec3(m_Position);
/* /*
If the PPU was a large jump, such as a cross zone gate or Call of Hero, If the PPU was a large jump, such as a cross zone gate or Call of Hero,
just update rewind coordinates to the new ppu coordinates. This will prevent exploitation. just update rewind coordinates to the new ppu coordinates. This will prevent exploitation.
*/ */
if ((rewind_x_diff > 5000) || (rewind_y_diff > 5000)) if ((rewind_x_diff > 5000) || (rewind_y_diff > 5000))
m_RewindLocation = glm::vec3(cx, cy, cz); m_RewindLocation = glm::vec3(cx, cy, cz);
if (proximity_timer.Check()) { if (proximity_timer.Check()) {
entity_list.ProcessMove(this, glm::vec3(cx, cy, cz)); entity_list.ProcessMove(this, glm::vec3(cx, cy, cz));
if (RuleB(TaskSystem, EnableTaskSystem) && RuleB(TaskSystem, EnableTaskProximity)) if (RuleB(TaskSystem, EnableTaskSystem) && RuleB(TaskSystem, EnableTaskProximity))
ProcessTaskProximities(cx, cy, cz); ProcessTaskProximities(cx, cy, cz);
m_Proximity = glm::vec3(cx, cy, cz); m_Proximity = glm::vec3(cx, cy, cz);
} }
/* Update internal state */ /* Update internal state */
m_Delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading)); m_Delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading));
if (IsTracking() && ((m_Position.x != cx) || (m_Position.y != cy))) { if (IsTracking() && ((m_Position.x != cx) || (m_Position.y != cy))) {
if (zone->random.Real(0, 100) < 70)//should be good if (zone->random.Real(0, 100) < 70)//should be good
CheckIncreaseSkill(EQEmu::skills::SkillTracking, nullptr, -20); CheckIncreaseSkill(EQEmu::skills::SkillTracking, nullptr, -20);
} }
/* Break Hide if moving without sneaking and set rewind timer if moved */ /* Break Hide if moving without sneaking and set rewind timer if moved */
if (cy != m_Position.y || cx != m_Position.x) { if (cy != m_Position.y || cx != m_Position.x) {
if ((hidden || improved_hidden) && !sneaking) { if ((hidden || improved_hidden) && !sneaking) {
@ -4500,7 +4500,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
} }
rewind_timer.Start(30000, true); rewind_timer.Start(30000, true);
} }
/* Handle client aggro scanning timers NPCs */ /* Handle client aggro scanning timers NPCs */
is_client_moving = (cy == m_Position.y && cx == m_Position.x) ? false : true; is_client_moving = (cy == m_Position.y && cx == m_Position.x) ? false : true;
@ -4564,55 +4564,55 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
} }
int32 new_animation = ppu->animation; int32 new_animation = ppu->animation;
/* Update internal server position from what the client has sent */ /* Update internal server position from what the client has sent */
m_Position.x = cx; m_Position.x = cx;
m_Position.y = cy; m_Position.y = cy;
m_Position.z = cz; m_Position.z = cz;
/* Visual Debugging */ /* Visual Debugging */
if (RuleB(Character, OPClientUpdateVisualDebug)) { if (RuleB(Character, OPClientUpdateVisualDebug)) {
LogDebug("ClientUpdate: ppu x: [{}] y: [{}] z: [{}] h: [{}]", cx, cy, cz, new_heading); LogDebug("ClientUpdate: ppu x: [{}] y: [{}] z: [{}] h: [{}]", cx, cy, cz, new_heading);
this->SendAppearanceEffect(78, 0, 0, 0, 0); this->SendAppearanceEffect(78, 0, 0, 0, 0);
this->SendAppearanceEffect(41, 0, 0, 0, 0); this->SendAppearanceEffect(41, 0, 0, 0, 0);
} }
/* Only feed real time updates when client is moving */ /* Only feed real time updates when client is moving */
if (is_client_moving || new_heading != m_Position.w || new_animation != animation) { if (is_client_moving || new_heading != m_Position.w || new_animation != animation) {
animation = ppu->animation; animation = ppu->animation;
m_Position.w = new_heading; m_Position.w = new_heading;
/* Broadcast update to other clients */ /* Broadcast update to other clients */
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
PlayerPositionUpdateServer_Struct *position_update = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer; PlayerPositionUpdateServer_Struct *position_update = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer;
MakeSpawnUpdate(position_update); MakeSpawnUpdate(position_update);
if (gm_hide_me) { if (gm_hide_me) {
entity_list.QueueClientsStatus(this, outapp, true, Admin(), 255); entity_list.QueueClientsStatus(this, outapp, true, Admin(), 255);
} else { } else {
entity_list.QueueCloseClients(this, outapp, true, RuleI(Range, ClientPositionUpdates), nullptr, true); entity_list.QueueCloseClients(this, outapp, true, RuleI(Range, ClientPositionUpdates), nullptr, true);
} }
/* Always send position updates to group - send when beyond normal ClientPositionUpdate range */ /* Always send position updates to group - send when beyond normal ClientPositionUpdate range */
Group *group = this->GetGroup(); Group *group = this->GetGroup();
Raid *raid = this->GetRaid(); Raid *raid = this->GetRaid();
if (raid) { if (raid) {
raid->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1)); raid->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
} else if (group) { } else if (group) {
group->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1)); group->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
} }
safe_delete(outapp); safe_delete(outapp);
} }
if (zone->watermap) { if (zone->watermap) {
if (zone->watermap->InLiquid(glm::vec3(m_Position))) { if (zone->watermap->InLiquid(glm::vec3(m_Position))) {
CheckIncreaseSkill(EQEmu::skills::SkillSwimming, nullptr, -17); CheckIncreaseSkill(EQEmu::skills::SkillSwimming, nullptr, -17);
// Dismount horses when entering water // Dismount horses when entering water
if (GetHorseId() && RuleB(Character, DismountWater)) { if (GetHorseId() && RuleB(Character, DismountWater)) {
SetHorseId(0); SetHorseId(0);
@ -5749,23 +5749,23 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
printf("Error in FindPersonRequest_Struct. Expected size of: %zu, but got: %i\n", sizeof(FindPersonRequest_Struct), app->size); printf("Error in FindPersonRequest_Struct. Expected size of: %zu, but got: %i\n", sizeof(FindPersonRequest_Struct), app->size);
else { else {
FindPersonRequest_Struct* t = (FindPersonRequest_Struct*)app->pBuffer; FindPersonRequest_Struct* t = (FindPersonRequest_Struct*)app->pBuffer;
std::vector<FindPerson_Point> points; std::vector<FindPerson_Point> points;
Mob* target = entity_list.GetMob(t->npc_id); Mob* target = entity_list.GetMob(t->npc_id);
if (target == nullptr) { if (target == nullptr) {
//empty length packet == not found. //empty length packet == not found.
EQApplicationPacket outapp(OP_FindPersonReply, 0); EQApplicationPacket outapp(OP_FindPersonReply, 0);
QueuePacket(&outapp); QueuePacket(&outapp);
return; return;
} }
if (!RuleB(Pathing, Find) && RuleB(Bazaar, EnableWarpToTrader) && target->IsClient() && (target->CastToClient()->Trader || if (!RuleB(Pathing, Find) && RuleB(Bazaar, EnableWarpToTrader) && target->IsClient() && (target->CastToClient()->Trader ||
target->CastToClient()->Buyer)) { target->CastToClient()->Buyer)) {
Message(Chat::Yellow, "Moving you to Trader %s", target->GetName()); Message(Chat::Yellow, "Moving you to Trader %s", target->GetName());
MovePC(zone->GetZoneID(), zone->GetInstanceID(), target->GetX(), target->GetY(), target->GetZ(), 0.0f); MovePC(zone->GetZoneID(), zone->GetInstanceID(), target->GetX(), target->GetY(), target->GetZ(), 0.0f);
} }
if (!RuleB(Pathing, Find) || !zone->pathing) if (!RuleB(Pathing, Find) || !zone->pathing)
{ {
//fill in the path array... //fill in the path array...
@ -5788,40 +5788,40 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
{ {
glm::vec3 Start(GetX(), GetY(), GetZ() + (GetSize() < 6.0 ? 6 : GetSize()) * HEAD_POSITION); glm::vec3 Start(GetX(), GetY(), GetZ() + (GetSize() < 6.0 ? 6 : GetSize()) * HEAD_POSITION);
glm::vec3 End(target->GetX(), target->GetY(), target->GetZ() + (target->GetSize() < 6.0 ? 6 : target->GetSize()) * HEAD_POSITION); glm::vec3 End(target->GetX(), target->GetY(), target->GetZ() + (target->GetSize() < 6.0 ? 6 : target->GetSize()) * HEAD_POSITION);
bool partial = false; bool partial = false;
bool stuck = false; bool stuck = false;
auto pathlist = zone->pathing->FindRoute(Start, End, partial, stuck); auto pathlist = zone->pathing->FindRoute(Start, End, partial, stuck);
if (pathlist.empty() || partial) if (pathlist.empty() || partial)
{ {
EQApplicationPacket outapp(OP_FindPersonReply, 0); EQApplicationPacket outapp(OP_FindPersonReply, 0);
QueuePacket(&outapp); QueuePacket(&outapp);
return; return;
} }
// Live appears to send the points in this order: // Live appears to send the points in this order:
// Final destination. // Final destination.
// Current Position. // Current Position.
// rest of the points. // rest of the points.
FindPerson_Point p; FindPerson_Point p;
int PointNumber = 0; int PointNumber = 0;
bool LeadsToTeleporter = false; bool LeadsToTeleporter = false;
auto v = pathlist.back(); auto v = pathlist.back();
p.x = v.pos.x; p.x = v.pos.x;
p.y = v.pos.y; p.y = v.pos.y;
p.z = v.pos.z; p.z = v.pos.z;
points.push_back(p); points.push_back(p);
p.x = GetX(); p.x = GetX();
p.y = GetY(); p.y = GetY();
p.z = GetZ(); p.z = GetZ();
points.push_back(p); points.push_back(p);
for (auto Iterator = pathlist.begin(); Iterator != pathlist.end(); ++Iterator) for (auto Iterator = pathlist.begin(); Iterator != pathlist.end(); ++Iterator)
{ {
if ((*Iterator).teleport) // Teleporter if ((*Iterator).teleport) // Teleporter
@ -5829,7 +5829,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
LeadsToTeleporter = true; LeadsToTeleporter = true;
break; break;
} }
glm::vec3 v = (*Iterator).pos; glm::vec3 v = (*Iterator).pos;
p.x = v.x; p.x = v.x;
p.y = v.y; p.y = v.y;
@ -5837,17 +5837,17 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
points.push_back(p); points.push_back(p);
++PointNumber; ++PointNumber;
} }
if (!LeadsToTeleporter) if (!LeadsToTeleporter)
{ {
p.x = target->GetX(); p.x = target->GetX();
p.y = target->GetY(); p.y = target->GetY();
p.z = target->GetZ(); p.z = target->GetZ();
points.push_back(p); points.push_back(p);
} }
} }
SendPathPacket(points); SendPathPacket(points);
} }
} }
@ -11090,14 +11090,14 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
{ {
case RaidCommandInviteIntoExisting: case RaidCommandInviteIntoExisting:
case RaidCommandInvite: { case RaidCommandInvite: {
Client *player_to_invite = entity_list.GetClientByName(raid_command_packet->player_name); Client *player_to_invite = entity_list.GetClientByName(raid_command_packet->player_name);
if (!player_to_invite) if (!player_to_invite)
break; break;
Group *player_to_invite_group = player_to_invite->GetGroup(); Group *player_to_invite_group = player_to_invite->GetGroup();
if (player_to_invite->HasRaid()) { if (player_to_invite->HasRaid()) {
Message(Chat::Red, "%s is already in a raid.", player_to_invite->GetName()); Message(Chat::Red, "%s is already in a raid.", player_to_invite->GetName());
break; break;
@ -11112,7 +11112,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
Message(Chat::Red, "You can only invite an ungrouped player or group leader to join your raid."); Message(Chat::Red, "You can only invite an ungrouped player or group leader to join your raid.");
break; break;
} }
/* Send out invite to the client */ /* Send out invite to the client */
auto outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct)); auto outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct));
RaidGeneral_Struct *raid_command = (RaidGeneral_Struct*)outapp->pBuffer; RaidGeneral_Struct *raid_command = (RaidGeneral_Struct*)outapp->pBuffer;
@ -11124,7 +11124,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
raid_command->action = 20; raid_command->action = 20;
player_to_invite->QueuePacket(outapp); player_to_invite->QueuePacket(outapp);
safe_delete(outapp); safe_delete(outapp);
break; break;
@ -11220,7 +11220,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
} }
if (player_invited_group->IsLeader(player_invited_group->members[x])) { if (player_invited_group->IsLeader(player_invited_group->members[x])) {
Client *c = nullptr; Client *c = nullptr;
if (player_invited_group->members[x]->IsClient()) if (player_invited_group->members[x]->IsClient())
c = player_invited_group->members[x]->CastToClient(); c = player_invited_group->members[x]->CastToClient();
else else
@ -11230,24 +11230,24 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
raid->SendMakeLeaderPacketTo(raid->leadername, c); raid->SendMakeLeaderPacketTo(raid->leadername, c);
raid->AddMember(c, raid_free_group_id, true, true, true); raid->AddMember(c, raid_free_group_id, true, true, true);
raid->SendBulkRaid(c); raid->SendBulkRaid(c);
if (raid->IsLocked()) { if (raid->IsLocked()) {
raid->SendRaidLockTo(c); raid->SendRaidLockTo(c);
} }
} }
else { else {
Client *c = nullptr; Client *c = nullptr;
if (player_invited_group->members[x]->IsClient()) if (player_invited_group->members[x]->IsClient())
c = player_invited_group->members[x]->CastToClient(); c = player_invited_group->members[x]->CastToClient();
else else
continue; continue;
raid->SendRaidCreate(c); raid->SendRaidCreate(c);
raid->SendMakeLeaderPacketTo(raid->leadername, c); raid->SendMakeLeaderPacketTo(raid->leadername, c);
raid->AddMember(c, raid_free_group_id); raid->AddMember(c, raid_free_group_id);
raid->SendBulkRaid(c); raid->SendBulkRaid(c);
if (raid->IsLocked()) { if (raid->IsLocked()) {
raid->SendRaidLockTo(c); raid->SendRaidLockTo(c);
} }
@ -11281,12 +11281,12 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
c = group->members[x]->CastToClient(); c = group->members[x]->CastToClient();
else else
continue; continue;
raid->SendRaidCreate(c); raid->SendRaidCreate(c);
raid->SendMakeLeaderPacketTo(raid->leadername, c); raid->SendMakeLeaderPacketTo(raid->leadername, c);
raid->AddMember(c, raid_free_group_id, false, true); raid->AddMember(c, raid_free_group_id, false, true);
raid->SendBulkRaid(c); raid->SendBulkRaid(c);
if (raid->IsLocked()) { if (raid->IsLocked()) {
raid->SendRaidLockTo(c); raid->SendRaidLockTo(c);
} }
@ -11294,17 +11294,17 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
else else
{ {
Client *c = nullptr; Client *c = nullptr;
if (group->members[x]->IsClient()) if (group->members[x]->IsClient())
c = group->members[x]->CastToClient(); c = group->members[x]->CastToClient();
else else
continue; continue;
raid->SendRaidCreate(c); raid->SendRaidCreate(c);
raid->SendMakeLeaderPacketTo(raid->leadername, c); raid->SendMakeLeaderPacketTo(raid->leadername, c);
raid->AddMember(c, raid_free_group_id); raid->AddMember(c, raid_free_group_id);
raid->SendBulkRaid(c); raid->SendBulkRaid(c);
if (raid->IsLocked()) { if (raid->IsLocked()) {
raid->SendRaidLockTo(c); raid->SendRaidLockTo(c);
} }
@ -11321,7 +11321,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
if (player_invited_group) { if (player_invited_group) {
raid = new Raid(player_accepting_invite); raid = new Raid(player_accepting_invite);
entity_list.AddRaid(raid); entity_list.AddRaid(raid);
raid->SetRaidDetails(); raid->SetRaidDetails();
Client *addClientig = nullptr; Client *addClientig = nullptr;
@ -11345,7 +11345,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
raid->SendMakeLeaderPacketTo(raid->leadername, c); raid->SendMakeLeaderPacketTo(raid->leadername, c);
raid->AddMember(c, 0, true, true, true); raid->AddMember(c, 0, true, true, true);
raid->SendBulkRaid(c); raid->SendBulkRaid(c);
if (raid->IsLocked()) { if (raid->IsLocked()) {
raid->SendRaidLockTo(c); raid->SendRaidLockTo(c);
} }
@ -11470,7 +11470,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
raid->SetGroupLeader(raid_command_packet->leader_name, false); raid->SetGroupLeader(raid_command_packet->leader_name, false);
/* We were the leader of our old group */ /* We were the leader of our old group */
if (old_group < 12) { if (old_group < 12) {
/* Assign new group leader if we can */ /* Assign new group leader if we can */
for (int x = 0; x < MAX_RAID_MEMBERS; x++) { for (int x = 0; x < MAX_RAID_MEMBERS; x++) {
if (raid->members[x].GroupNumber == old_group) { if (raid->members[x].GroupNumber == old_group) {
@ -11499,7 +11499,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
strn0cpy(raid_command_packet->playername, raid->members[x].membername, 64); strn0cpy(raid_command_packet->playername, raid->members[x].membername, 64);
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
break; break;
@ -11545,7 +11545,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
raid->SetGroupLeader(raid_command_packet->leader_name, false); raid->SetGroupLeader(raid_command_packet->leader_name, false);
for (int x = 0; x < MAX_RAID_MEMBERS; x++) { for (int x = 0; x < MAX_RAID_MEMBERS; x++) {
if (raid->members[x].GroupNumber == oldgrp && strlen(raid->members[x].membername) > 0 && strcmp(raid->members[x].membername, raid_command_packet->leader_name) != 0){ if (raid->members[x].GroupNumber == oldgrp && strlen(raid->members[x].membername) > 0 && strcmp(raid->members[x].membername, raid_command_packet->leader_name) != 0){
raid->SetGroupLeader(raid->members[x].membername); raid->SetGroupLeader(raid->members[x].membername);
raid->UpdateGroupAAs(oldgrp); raid->UpdateGroupAAs(oldgrp);
@ -11568,7 +11568,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
strn0cpy(raid_command->playername, raid->members[x].membername, 64); strn0cpy(raid_command->playername, raid->members[x].membername, 64);
raid_command->zoneid = zone->GetZoneID(); raid_command->zoneid = zone->GetZoneID();
raid_command->instance_id = zone->GetInstanceID(); raid_command->instance_id = zone->GetInstanceID();
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
@ -11583,14 +11583,14 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
else { else {
auto pack = new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); auto pack = new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct));
ServerRaidGeneralAction_Struct* raid_command = (ServerRaidGeneralAction_Struct*)pack->pBuffer; ServerRaidGeneralAction_Struct* raid_command = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
raid_command->rid = raid->GetID(); raid_command->rid = raid->GetID();
raid_command->zoneid = zone->GetZoneID(); raid_command->zoneid = zone->GetZoneID();
raid_command->instance_id = zone->GetInstanceID(); raid_command->instance_id = zone->GetInstanceID();
strn0cpy(raid_command->playername, raid_command_packet->leader_name, 64); strn0cpy(raid_command->playername, raid_command_packet->leader_name, 64);
worldserver.SendPacket(pack); worldserver.SendPacket(pack);
safe_delete(pack); safe_delete(pack);
} }
@ -11778,7 +11778,7 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app)
{ {
if (app->size != sizeof(TradeskillFavorites_Struct)) { if (app->size != sizeof(TradeskillFavorites_Struct)) {
LogError("Invalid size for TradeskillFavorites_Struct: Expected: [{}], Got: [{}]", LogError("Invalid size for TradeskillFavorites_Struct: Expected: [{}], Got: [{}]",
sizeof(TradeskillFavorites_Struct), app->size); sizeof(TradeskillFavorites_Struct), app->size);
return; return;
} }
@ -11828,6 +11828,7 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app)
if (first) //no favorites.... if (first) //no favorites....
return; return;
// TODO: Clean this up
const std::string query = StringFormat( const std::string query = StringFormat(
SQL ( SQL (
SELECT SELECT
@ -11844,11 +11845,11 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app)
AND tr.id IN (%s) AND tr.id IN (%s)
AND tr.must_learn & 0x20 <> 0x20 AND tr.must_learn & 0x20 <> 0x20
AND ( AND (
( (
tr.must_learn & 0x3 <> 0 tr.must_learn & 0x3 <> 0
) )
OR (tr.must_learn & 0x3 = 0) OR (tr.must_learn & 0x3 = 0)
) )
GROUP BY GROUP BY
tr.id tr.id
HAVING HAVING
@ -11924,6 +11925,7 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app)
} }
//arbitrary limit of 200 recipes, makes sense to me. //arbitrary limit of 200 recipes, makes sense to me.
// TODO: Clean this up
std::string query = fmt::format( std::string query = fmt::format(
SQL( SQL(
SELECT SELECT
@ -11931,37 +11933,19 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app)
tr.name, tr.name,
tr.trivial, tr.trivial,
SUM(tre.componentcount), SUM(tre.componentcount),
crl.madecount,
tr.tradeskill tr.tradeskill
FROM FROM
tradeskill_recipe tradeskill_recipe AS tr
AS tr LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id = tre.recipe_id
LEFT
JOIN
tradeskill_recipe_entries
AS
tre
ON
tr.id = tre.recipe_id
LEFT JOIN(
SELECT
recipe_id,
madecount
FROM
char_recipe_list
WHERE
char_id = {}
) AS crl ON tr.id = crl.recipe_id
WHERE WHERE
{} tr.trivial >= {} {} tr.trivial >= {}
AND tr.trivial <= {} AND tr.trivial <= {}
AND tr.enabled <> 0 AND tr.enabled <> 0
AND tr.must_learn & 0x20 <> 0x20 AND tr.must_learn & 0x20 <> 0x20
AND ( AND (
( (
tr.must_learn & 0x3 <> 0 tr.must_learn & 0x3 <> 0
AND crl.madecount IS NOT NULL )
)
OR (tr.must_learn & 0x3 = 0) OR (tr.must_learn & 0x3 = 0)
) )
GROUP BY GROUP BY
@ -11979,7 +11963,6 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app)
LIMIT LIMIT
200 200
), ),
CharacterID(),
search_clause, search_clause,
p_recipes_search_struct->mintrivial, p_recipes_search_struct->mintrivial,
p_recipes_search_struct->maxtrivial, p_recipes_search_struct->maxtrivial,