mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
converting some remaining abs & fabs to use std::abs, fixing some warnings
This commit is contained in:
parent
55c0cc02a1
commit
add25eb617
@ -124,7 +124,7 @@ namespace EQEmu
|
|||||||
|
|
||||||
class OutBuffer : public std::stringstream {
|
class OutBuffer : public std::stringstream {
|
||||||
public:
|
public:
|
||||||
inline size_t size() { return tellp(); }
|
inline size_t size() { return static_cast<size_t>(tellp()); }
|
||||||
void overwrite(OutBuffer::pos_type position, const char *_Str, std::streamsize _Count);
|
void overwrite(OutBuffer::pos_type position, const char *_Str, std::streamsize _Count);
|
||||||
uchar* detach();
|
uchar* detach();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -73,7 +73,7 @@ uint32 SwapBits21And22(uint32 mask);
|
|||||||
uint32 Catch22(uint32 mask);
|
uint32 Catch22(uint32 mask);
|
||||||
|
|
||||||
// macro to catch fp errors (provided by noudness)
|
// macro to catch fp errors (provided by noudness)
|
||||||
#define FCMP(a,b) (fabs(a-b) < FLT_EPSILON)
|
#define FCMP(a,b) (std::abs(a-b) < FLT_EPSILON)
|
||||||
|
|
||||||
#define _ITOA_BUFLEN 25
|
#define _ITOA_BUFLEN 25
|
||||||
const char *itoa(int num); //not thread safe
|
const char *itoa(int num); //not thread safe
|
||||||
|
|||||||
@ -2795,7 +2795,7 @@ namespace RoF
|
|||||||
|
|
||||||
std::vector<int32> skill;
|
std::vector<int32> skill;
|
||||||
std::vector<int32> points;
|
std::vector<int32> points;
|
||||||
for(auto i = 0; i < emu->total_prereqs; ++i) {
|
for(auto i = 0u; i < emu->total_prereqs; ++i) {
|
||||||
skill.push_back(inapp->ReadUInt32());
|
skill.push_back(inapp->ReadUInt32());
|
||||||
points.push_back(inapp->ReadUInt32());
|
points.push_back(inapp->ReadUInt32());
|
||||||
}
|
}
|
||||||
@ -2849,7 +2849,7 @@ namespace RoF
|
|||||||
outapp->WriteUInt32(emu->total_effects);
|
outapp->WriteUInt32(emu->total_effects);
|
||||||
|
|
||||||
inapp->SetReadPosition(sizeof(AARankInfo_Struct));
|
inapp->SetReadPosition(sizeof(AARankInfo_Struct));
|
||||||
for(auto i = 0; i < emu->total_effects; ++i) {
|
for(auto i = 0u; i < emu->total_effects; ++i) {
|
||||||
outapp->WriteUInt32(inapp->ReadUInt32()); // skill_id
|
outapp->WriteUInt32(inapp->ReadUInt32()); // skill_id
|
||||||
outapp->WriteUInt32(inapp->ReadUInt32()); // base1
|
outapp->WriteUInt32(inapp->ReadUInt32()); // base1
|
||||||
outapp->WriteUInt32(inapp->ReadUInt32()); // base2
|
outapp->WriteUInt32(inapp->ReadUInt32()); // base2
|
||||||
@ -2905,7 +2905,7 @@ namespace RoF
|
|||||||
unsigned char *eq_ptr = __packet->pBuffer;
|
unsigned char *eq_ptr = __packet->pBuffer;
|
||||||
eq_ptr += sizeof(structs::CharacterSelect_Struct);
|
eq_ptr += sizeof(structs::CharacterSelect_Struct);
|
||||||
|
|
||||||
for (int counter = 0; counter < character_count; ++counter) {
|
for (auto counter = 0u; counter < character_count; ++counter) {
|
||||||
emu_cse = (CharacterSelectEntry_Struct *)emu_ptr;
|
emu_cse = (CharacterSelectEntry_Struct *)emu_ptr;
|
||||||
eq_cse = (structs::CharacterSelectEntry_Struct *)eq_ptr; // base address
|
eq_cse = (structs::CharacterSelectEntry_Struct *)eq_ptr; // base address
|
||||||
|
|
||||||
@ -3247,7 +3247,7 @@ namespace RoF
|
|||||||
InBuffer += title_size;
|
InBuffer += title_size;
|
||||||
|
|
||||||
TaskDescriptionData1_Struct *emu_tdd1 = (TaskDescriptionData1_Struct *)InBuffer;
|
TaskDescriptionData1_Struct *emu_tdd1 = (TaskDescriptionData1_Struct *)InBuffer;
|
||||||
emu_tdd1->StartTime = (time(nullptr) - emu_tdd1->StartTime); // RoF has elapsed time here rather than start time
|
emu_tdd1->StartTime = (static_cast<uint32>(time(nullptr)) - emu_tdd1->StartTime); // RoF has elapsed time here rather than start time
|
||||||
|
|
||||||
InBuffer += sizeof(TaskDescriptionData1_Struct);
|
InBuffer += sizeof(TaskDescriptionData1_Struct);
|
||||||
uint32 description_size = strlen(InBuffer) + 1;
|
uint32 description_size = strlen(InBuffer) + 1;
|
||||||
@ -3598,10 +3598,10 @@ namespace RoF
|
|||||||
|
|
||||||
// calculate size of names, note the packet DOES NOT have null termed c-strings
|
// calculate size of names, note the packet DOES NOT have null termed c-strings
|
||||||
std::vector<uint32> name_lengths;
|
std::vector<uint32> name_lengths;
|
||||||
for (int i = 0; i < count; ++i) {
|
for (auto i = 0u; i < count; ++i) {
|
||||||
InternalVeteranReward *ivr = (InternalVeteranReward *)__emu_buffer;
|
InternalVeteranReward *ivr = (InternalVeteranReward *)__emu_buffer;
|
||||||
|
|
||||||
for (int i = 0; i < ivr->claim_count; i++) {
|
for (auto i = 0u; i < ivr->claim_count; i++) {
|
||||||
uint32 length = strnlen(ivr->items[i].item_name, 63);
|
uint32 length = strnlen(ivr->items[i].item_name, 63);
|
||||||
if (length)
|
if (length)
|
||||||
name_lengths.push_back(length);
|
name_lengths.push_back(length);
|
||||||
@ -3621,7 +3621,7 @@ namespace RoF
|
|||||||
|
|
||||||
outapp->WriteUInt32(count);
|
outapp->WriteUInt32(count);
|
||||||
auto name_itr = name_lengths.begin();
|
auto name_itr = name_lengths.begin();
|
||||||
for (int i = 0; i < count; i++) {
|
for (auto i = 0u; i < count; i++) {
|
||||||
InternalVeteranReward *ivr = (InternalVeteranReward *)__emu_buffer;
|
InternalVeteranReward *ivr = (InternalVeteranReward *)__emu_buffer;
|
||||||
|
|
||||||
outapp->WriteUInt32(ivr->claim_id);
|
outapp->WriteUInt32(ivr->claim_id);
|
||||||
@ -3629,7 +3629,7 @@ namespace RoF
|
|||||||
outapp->WriteUInt32(ivr->claim_count);
|
outapp->WriteUInt32(ivr->claim_count);
|
||||||
outapp->WriteUInt8(1); // enabled
|
outapp->WriteUInt8(1); // enabled
|
||||||
|
|
||||||
for (int j = 0; j < ivr->claim_count; j++) {
|
for (auto j = 0u; j < ivr->claim_count; j++) {
|
||||||
assert(name_itr != name_lengths.end()); // the way it's written, it should never happen, so just assert
|
assert(name_itr != name_lengths.end()); // the way it's written, it should never happen, so just assert
|
||||||
outapp->WriteUInt32(*name_itr);
|
outapp->WriteUInt32(*name_itr);
|
||||||
outapp->WriteData(ivr->items[j].item_name, *name_itr);
|
outapp->WriteData(ivr->items[j].item_name, *name_itr);
|
||||||
@ -3857,7 +3857,7 @@ namespace RoF
|
|||||||
VARSTRUCT_ENCODE_STRING(Buffer, emu->name);
|
VARSTRUCT_ENCODE_STRING(Buffer, emu->name);
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, emu->spawnId);
|
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, emu->spawnId);
|
||||||
VARSTRUCT_ENCODE_TYPE(uint8, Buffer, emu->level);
|
VARSTRUCT_ENCODE_TYPE(uint8, Buffer, emu->level);
|
||||||
VARSTRUCT_ENCODE_TYPE(float, Buffer, SpawnSize - 0.7); // Eye Height?
|
VARSTRUCT_ENCODE_TYPE(float, Buffer, SpawnSize - 0.7f); // Eye Height?
|
||||||
VARSTRUCT_ENCODE_TYPE(uint8, Buffer, emu->NPC);
|
VARSTRUCT_ENCODE_TYPE(uint8, Buffer, emu->NPC);
|
||||||
|
|
||||||
structs::Spawn_Struct_Bitfields *Bitfields = (structs::Spawn_Struct_Bitfields*)Buffer;
|
structs::Spawn_Struct_Bitfields *Bitfields = (structs::Spawn_Struct_Bitfields*)Buffer;
|
||||||
|
|||||||
@ -107,16 +107,10 @@ void NPC::DescribeAggro(Client *towho, Mob *mob, bool verbose) {
|
|||||||
float iAggroRange = GetAggroRange();
|
float iAggroRange = GetAggroRange();
|
||||||
|
|
||||||
float t1, t2, t3;
|
float t1, t2, t3;
|
||||||
t1 = mob->GetX() - GetX();
|
t1 = std::abs(mob->GetX() - GetX());
|
||||||
t2 = mob->GetY() - GetY();
|
t2 = std::abs(mob->GetY() - GetY());
|
||||||
t3 = mob->GetZ() - GetZ();
|
t3 = std::abs(mob->GetZ() - GetZ());
|
||||||
//Cheap ABS()
|
|
||||||
if(t1 < 0)
|
|
||||||
t1 = 0 - t1;
|
|
||||||
if(t2 < 0)
|
|
||||||
t2 = 0 - t2;
|
|
||||||
if(t3 < 0)
|
|
||||||
t3 = 0 - t3;
|
|
||||||
if(( t1 > iAggroRange)
|
if(( t1 > iAggroRange)
|
||||||
|| ( t2 > iAggroRange)
|
|| ( t2 > iAggroRange)
|
||||||
|| ( t3 > iAggroRange) ) {
|
|| ( t3 > iAggroRange) ) {
|
||||||
@ -271,16 +265,10 @@ bool Mob::CheckWillAggro(Mob *mob) {
|
|||||||
// Image: I moved this up by itself above faction and distance checks because if one of these return true, theres no reason to go through the other information
|
// Image: I moved this up by itself above faction and distance checks because if one of these return true, theres no reason to go through the other information
|
||||||
|
|
||||||
float t1, t2, t3;
|
float t1, t2, t3;
|
||||||
t1 = mob->GetX() - GetX();
|
t1 = std::abs(mob->GetX() - GetX());
|
||||||
t2 = mob->GetY() - GetY();
|
t2 = std::abs(mob->GetY() - GetY());
|
||||||
t3 = mob->GetZ() - GetZ();
|
t3 = std::abs(mob->GetZ() - GetZ());
|
||||||
//Cheap ABS()
|
|
||||||
if(t1 < 0)
|
|
||||||
t1 = 0 - t1;
|
|
||||||
if(t2 < 0)
|
|
||||||
t2 = 0 - t2;
|
|
||||||
if(t3 < 0)
|
|
||||||
t3 = 0 - t3;
|
|
||||||
if(( t1 > iAggroRange)
|
if(( t1 > iAggroRange)
|
||||||
|| ( t2 > iAggroRange)
|
|| ( t2 > iAggroRange)
|
||||||
|| ( t3 > iAggroRange)
|
|| ( t3 > iAggroRange)
|
||||||
@ -526,7 +514,7 @@ void EntityList::AIYellForHelp(Mob* sender, Mob* attacker) {
|
|||||||
Log(Logs::General, Logs::None, "AIYellForHelp(\"%s\",\"%s\") %s attacking %s Dist %f Z %f",
|
Log(Logs::General, Logs::None, "AIYellForHelp(\"%s\",\"%s\") %s attacking %s Dist %f Z %f",
|
||||||
sender->GetName(), attacker->GetName(), mob->GetName(),
|
sender->GetName(), attacker->GetName(), mob->GetName(),
|
||||||
attacker->GetName(), DistanceSquared(mob->GetPosition(),
|
attacker->GetName(), DistanceSquared(mob->GetPosition(),
|
||||||
sender->GetPosition()), fabs(sender->GetZ()+mob->GetZ()));
|
sender->GetPosition()), std::abs(sender->GetZ()+mob->GetZ()));
|
||||||
#endif
|
#endif
|
||||||
mob->AddToHateList(attacker, 25, 0, false);
|
mob->AddToHateList(attacker, 25, 0, false);
|
||||||
sender->AddAssistCap();
|
sender->AddAssistCap();
|
||||||
|
|||||||
@ -8103,9 +8103,9 @@ void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, ui
|
|||||||
{
|
{
|
||||||
//The ole switcheroo
|
//The ole switcheroo
|
||||||
if (npc_value[i] > 0)
|
if (npc_value[i] > 0)
|
||||||
npc_value[i] = -abs(npc_value[i]);
|
npc_value[i] = -std::abs(npc_value[i]);
|
||||||
else if (npc_value[i] < 0)
|
else if (npc_value[i] < 0)
|
||||||
npc_value[i] = abs(npc_value[i]);
|
npc_value[i] = std::abs(npc_value[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust the amount you can go up or down so the resulting range
|
// Adjust the amount you can go up or down so the resulting range
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user