This commit is contained in:
Arthur Ice
2014-12-05 20:16:13 -08:00
124 changed files with 63220 additions and 2537 deletions
+63 -82
View File
@@ -16,14 +16,11 @@
*/
#include "../common/debug.h"
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <set>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
@@ -38,39 +35,28 @@
#include <unistd.h>
#endif
#include "../common/packet_functions.h"
#include "../common/packet_dump.h"
#include "worldserver.h"
#include "../common/rdtsc.h"
#include "../common/packet_dump_file.h"
#include "../common/string_util.h"
#include "../common/breakdowns.h"
#include "../common/guilds.h"
#include "../common/rulesys.h"
#include "../common/spdat.h"
#include "../common/data_verification.h"
#include "petitions.h"
#include "npc_ai.h"
#include "../common/skills.h"
#include "forage.h"
#include "zone.h"
#include "event_codes.h"
#include "../common/faction.h"
#include "../common/crc32.h"
#include "../common/data_verification.h"
#include "../common/faction.h"
#include "../common/guilds.h"
#include "../common/rdtsc.h"
#include "../common/rulesys.h"
#include "../common/skills.h"
#include "../common/spdat.h"
#include "../common/string_util.h"
#include "../common/zone_numbers.h"
#include "event_codes.h"
#include "guild_mgr.h"
#include "merc.h"
#include "petitions.h"
#include "pets.h"
#include "queryserv.h"
#include "quest_parser_collection.h"
#include "string_ids.h"
#include "titles.h"
#include "water_map.h"
#include "worldserver.h"
#include "zone.h"
#include "zone_config.h"
#include "guild_mgr.h"
#include "pathing.h"
#include "water_map.h"
#include "merc.h"
#include "pets.h"
#include "../common/zone_numbers.h"
#include "quest_parser_collection.h"
#include "queryserv.h"
extern QueryServ* QServ;
extern Zone* zone;
@@ -474,10 +460,10 @@ int Client::HandlePacket(const EQApplicationPacket *app)
mlog(CLIENT__NET_ERR, "Unhandled incoming opcode: %s", buffer);
if(app->size < 1000)
DumpPacket(app->pBuffer, app->size);
DumpPacket(app, app->size);
else{
std::cout << "Dump limited to 1000 characters:\n";
DumpPacket(app->pBuffer, 1000);
DumpPacket(app, 1000);
}
#endif
break;
@@ -2968,7 +2954,7 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app)
if ((PrimaryWeapon && PrimaryWeapon->GetItem()->ItemType == ItemType1HPiercing) ||
(SecondaryWeapon && SecondaryWeapon->GetItem()->ItemType == ItemType1HPiercing)) {
float SuccessChance = (GetSkill(SkillApplyPoison) + GetLevel()) / 400.0f;
double ChanceRoll = MakeRandomFloat(0, 1);
double ChanceRoll = zone->random.Real(0, 1);
CheckIncreaseSkill(SkillApplyPoison, nullptr, 10);
@@ -3642,14 +3628,14 @@ void Client::Handle_OP_Begging(const EQApplicationPacket *app)
return;
}
int RandomChance = MakeRandomInt(0, 100);
int RandomChance = zone->random.Int(0, 100);
int ChanceToAttack = 0;
if (GetLevel() > GetTarget()->GetLevel())
ChanceToAttack = MakeRandomInt(0, 15);
ChanceToAttack = zone->random.Int(0, 15);
else
ChanceToAttack = MakeRandomInt(((this->GetTarget()->GetLevel() - this->GetLevel()) * 10) - 5, ((this->GetTarget()->GetLevel() - this->GetLevel()) * 10));
ChanceToAttack = zone->random.Int(((this->GetTarget()->GetLevel() - this->GetLevel()) * 10) - 5, ((this->GetTarget()->GetLevel() - this->GetLevel()) * 10));
if (ChanceToAttack < 0)
ChanceToAttack = -ChanceToAttack;
@@ -3668,7 +3654,7 @@ void Client::Handle_OP_Begging(const EQApplicationPacket *app)
if (RandomChance < ChanceToBeg)
{
brs->Amount = MakeRandomInt(1, 10);
brs->Amount = zone->random.Int(1, 10);
// This needs some work to determine how much money they can beg, based on skill level etc.
if (CurrentSkill < 50)
{
@@ -4537,7 +4523,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
m_Delta = xyz_heading(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading);
if(IsTracking() && ((m_Position.m_X!=ppu->x_pos) || (m_Position.m_Y!=ppu->y_pos))){
if(MakeRandomFloat(0, 100) < 70)//should be good
if(zone->random.Real(0, 100) < 70)//should be good
CheckIncreaseSkill(SkillTracking, nullptr, -20);
}
@@ -5235,16 +5221,16 @@ void Client::Handle_OP_DisarmTraps(const EQApplicationPacket *app)
if (trap && trap->detected)
{
int uskill = GetSkill(SkillDisarmTraps);
if ((MakeRandomInt(0, 49) + uskill) >= (MakeRandomInt(0, 49) + trap->skill))
if ((zone->random.Int(0, 49) + uskill) >= (zone->random.Int(0, 49) + trap->skill))
{
Message(MT_Skills, "You disarm a trap.");
trap->disarmed = true;
trap->chkarea_timer.Disable();
trap->respawn_timer.Start((trap->respawn_time + MakeRandomInt(0, trap->respawn_var)) * 1000);
trap->respawn_timer.Start((trap->respawn_time + zone->random.Int(0, trap->respawn_var)) * 1000);
}
else
{
if (MakeRandomInt(0, 99) < 25){
if (zone->random.Int(0, 99) < 25){
Message(MT_Skills, "You set off the trap while trying to disarm it!");
trap->Trigger(this);
}
@@ -5605,7 +5591,7 @@ void Client::Handle_OP_FeignDeath(const EQApplicationPacket *app)
secfeign = 0;
uint16 totalfeign = primfeign + secfeign;
if (MakeRandomFloat(0, 160) > totalfeign) {
if (zone->random.Real(0, 160) > totalfeign) {
SetFeigned(false);
entity_list.MessageClose_StringID(this, false, 200, 10, STRING_FEIGNFAILED, GetName());
}
@@ -7869,7 +7855,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app)
p_timers.Start(pTimerHide, reuse - 1);
float hidechance = ((GetSkill(SkillHide) / 250.0f) + .25) * 100;
float random = MakeRandomFloat(0, 100);
float random = zone->random.Real(0, 100);
CheckIncreaseSkill(SkillHide, nullptr, 5);
if (random < hidechance) {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_SpawnAppearance, sizeof(SpawnAppearance_Struct));
@@ -7893,7 +7879,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app)
Mob *evadetar = GetTarget();
if (!auto_attack && (evadetar && evadetar->CheckAggro(this)
&& evadetar->IsNPC())) {
if (MakeRandomInt(0, 260) < (int)GetSkill(SkillHide)) {
if (zone->random.Int(0, 260) < (int)GetSkill(SkillHide)) {
msg->string_id = EVADE_SUCCESS;
RogueEvade(evadetar);
}
@@ -8000,6 +7986,10 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app)
strcpy(insr->itemnames[L], item->Name);
insr->itemicons[L] = aug_weap->Icon;
}
else if (inst->GetOrnamentationIcon() && inst->GetOrnamentationIDFile()) {
strcpy(insr->itemnames[L], item->Name);
insr->itemicons[L] = inst->GetOrnamentationIcon();
}
else {
strcpy(insr->itemnames[L], item->Name);
insr->itemicons[L] = item->Icon;
@@ -9272,11 +9262,11 @@ void Client::Handle_OP_Mend(const EQApplicationPacket *app)
int mendhp = GetMaxHP() / 4;
int currenthp = GetHP();
if (MakeRandomInt(0, 199) < (int)GetSkill(SkillMend)) {
if (zone->random.Int(0, 199) < (int)GetSkill(SkillMend)) {
int criticalchance = spellbonuses.CriticalMend + itembonuses.CriticalMend + aabonuses.CriticalMend;
if (MakeRandomInt(0, 99) < criticalchance){
if (zone->random.Int(0, 99) < criticalchance){
mendhp *= 2;
Message_StringID(4, MEND_CRITICAL);
}
@@ -9291,7 +9281,7 @@ void Client::Handle_OP_Mend(const EQApplicationPacket *app)
0 skill - 25% chance to worsen
20 skill - 23% chance to worsen
50 skill - 16% chance to worsen */
if ((GetSkill(SkillMend) <= 75) && (MakeRandomInt(GetSkill(SkillMend), 100) < 75) && (MakeRandomInt(1, 3) == 1))
if ((GetSkill(SkillMend) <= 75) && (zone->random.Int(GetSkill(SkillMend), 100) < 75) && (zone->random.Int(1, 3) == 1))
{
SetHP(currenthp > mendhp ? (GetHP() - mendhp) : 1);
SendHPUpdate();
@@ -9598,7 +9588,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app)
TakeMoneyFromPP(cost, true);
}
// 0 is approved hire request
// approved hire request
SendMercMerchantResponsePacket(0);
}
else
@@ -10596,37 +10586,28 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
case RaidCommandInviteIntoExisting:
case RaidCommandInvite: {
Client *i = entity_list.GetClientByName(ri->player_name);
if (i){
Group *g = i->GetGroup();
if (g){
if (g->IsLeader(i) == false)
Message(13, "You can only invite an ungrouped player or group leader to join your raid.");
else{
//This sends an "invite" to the client in question.
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct));
RaidGeneral_Struct *rg = (RaidGeneral_Struct*)outapp->pBuffer;
strn0cpy(rg->leader_name, ri->leader_name, 64);
strn0cpy(rg->player_name, ri->player_name, 64);
rg->parameter = 0;
rg->action = 20;
i->QueuePacket(outapp);
safe_delete(outapp);
}
}
else{
//This sends an "invite" to the client in question.
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct));
RaidGeneral_Struct *rg = (RaidGeneral_Struct*)outapp->pBuffer;
strn0cpy(rg->leader_name, ri->leader_name, 64);
strn0cpy(rg->player_name, ri->player_name, 64);
rg->parameter = 0;
rg->action = 20;
i->QueuePacket(outapp);
safe_delete(outapp);
}
if (!i)
break;
Group *g = i->GetGroup();
// These two messages should be generated by the client I think, just do this for now
if (i->HasRaid()) {
Message(13, "%s is already in a raid.", i->GetName());
break;
}
if (g && !g->IsLeader(i)) {
Message(13, "You can only invite an ungrouped player or group leader to join your raid.");
break;
}
//This sends an "invite" to the client in question.
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidGeneral_Struct));
RaidGeneral_Struct *rg = (RaidGeneral_Struct*)outapp->pBuffer;
strn0cpy(rg->leader_name, ri->leader_name, 64);
strn0cpy(rg->player_name, ri->player_name, 64);
rg->parameter = 0;
rg->action = 20;
i->QueuePacket(outapp);
safe_delete(outapp);
break;
}
case RaidCommandAcceptInvite: {
@@ -11192,7 +11173,7 @@ void Client::Handle_OP_RandomReq(const EQApplicationPacket *app)
randLow = 0;
randHigh = 100;
}
randResult = MakeRandomInt(randLow, randHigh);
randResult = zone->random.Int(randLow, randHigh);
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RandomReply, sizeof(RandomReply_Struct));
RandomReply_Struct* rr = (RandomReply_Struct*)outapp->pBuffer;
@@ -11682,7 +11663,7 @@ void Client::Handle_OP_SenseTraps(const EQApplicationPacket *app)
if (trap && trap->skill > 0) {
int uskill = GetSkill(SkillSenseTraps);
if ((MakeRandomInt(0, 99) + uskill) >= (MakeRandomInt(0, 99) + trap->skill*0.75))
if ((zone->random.Int(0, 99) + uskill) >= (zone->random.Int(0, 99) + trap->skill*0.75))
{
auto diff = trap->m_Position - GetPosition();
@@ -12425,7 +12406,7 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app)
// 1199 I don't have time for that now. etc
if (!tmp->CastToNPC()->IsMerchantOpen()) {
tmp->Say_StringID(MakeRandomInt(1199, 1202));
tmp->Say_StringID(zone->random.Int(1199, 1202));
action = 0;
}
@@ -12480,7 +12461,7 @@ void Client::Handle_OP_Sneak(const EQApplicationPacket *app)
CheckIncreaseSkill(SkillSneak, nullptr, 5);
}
float hidechance = ((GetSkill(SkillSneak) / 300.0f) + .25) * 100;
float random = MakeRandomFloat(0, 99);
float random = zone->random.Real(0, 99);
if (!was && random < hidechance) {
sneaking = true;
}