Changed tuple use to struct in maps.cpp (LoadV2) (should help in client drops where slow zone boot-ups are a factor)

This commit is contained in:
Uleat 2016-07-14 13:22:36 -04:00
parent 871fcd1fc8
commit 02cedce54e
2 changed files with 29 additions and 10 deletions

View File

@ -1,8 +1,15 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 07/14/2016 ==
Uleat: Changed LoadV2Map usage of std::tuplet<float,float,float> to struct PointEntry (<float,float,float>)
- This appears to help with zone boot times when V2 maps are used on windows systems - unverified on linux systems as of this time
- Current visual studio implementation for tuples is to pass by value whereas structs are passed by reference. The overhead is noticeable when processing VLS data objects (~33 seconds versus ~9 seconds in 'moors' for the affected code with my system)
- This change, in addition to the recent sin/cos change by mackal, should improve zone boot times and help alleviate client dumps on zoning due to time-outs - in some cases
- Please report any issues observed by this or any other change
== 07/09/2016 ==
Uleat: Important fix for mob pathing
- This should fix failed pathing issues (and high cpu usage for zone.exe) for mobs in affect zones
- This should fix failed pathing issues (and high cpu usage for zone.exe) for mobs in affected zones
- Changed variable 'gridno' type from int16 to int32 to reflect actual return value of fetch (values do exceed 32767 aka int16.max)
- Precision loss from int32 to int16 conversion was causing grid id to be changed to quest controlled movement in cases where (gridno & 0x8000 == true)

View File

@ -348,6 +348,18 @@ struct ModelEntry
std::vector<Poly> polys;
};
struct PointEntry
{
PointEntry(float x, float y, float z) { x_val = x; y_val = y; z_val = z; }
void set(float x, float y, float z) { x_val = x; y_val = y; z_val = z; }
bool operator==(const PointEntry& r) const { return (x_val == r.x_val && y_val == r.y_val && z_val == r.z_val); }
bool operator<(const PointEntry& r) const { return (x_val < r.x_val && y_val < r.y_val && z_val < r.z_val); }
float x_val;
float y_val;
float z_val;
};
bool Map::LoadV2(FILE *f) {
uint32 data_size;
if (fread(&data_size, sizeof(data_size), 1, f) != 1) {
@ -792,7 +804,7 @@ bool Map::LoadV2(FILE *f) {
}
int row_number = -1;
std::map<std::tuple<float, float, float>, uint32> cur_verts;
std::map<PointEntry, uint32> cur_verts;
for (uint32 quad = 0; quad < ter_quad_count; ++quad) {
if ((quad % quads_per_tile) == 0) {
++row_number;
@ -818,7 +830,7 @@ bool Map::LoadV2(FILE *f) {
float QuadVertex4Z = floats[quad + row_number + 1];
uint32 i1, i2, i3, i4;
std::tuple<float, float, float> t = std::make_tuple(QuadVertex1X, QuadVertex1Y, QuadVertex1Z);
PointEntry t(QuadVertex1X, QuadVertex1Y, QuadVertex1Z);
auto iter = cur_verts.find(t);
if (iter != cur_verts.end()) {
i1 = iter->second;
@ -826,10 +838,10 @@ bool Map::LoadV2(FILE *f) {
else {
i1 = (uint32)verts.size();
verts.push_back(glm::vec3(QuadVertex1X, QuadVertex1Y, QuadVertex1Z));
cur_verts[std::make_tuple(QuadVertex1X, QuadVertex1Y, QuadVertex1Z)] = i1;
cur_verts[t] = i1;
}
t = std::make_tuple(QuadVertex2X, QuadVertex2Y, QuadVertex2Z);
t.set(QuadVertex2X, QuadVertex2Y, QuadVertex2Z);
iter = cur_verts.find(t);
if (iter != cur_verts.end()) {
i2 = iter->second;
@ -837,10 +849,10 @@ bool Map::LoadV2(FILE *f) {
else {
i2 = (uint32)verts.size();
verts.push_back(glm::vec3(QuadVertex2X, QuadVertex2Y, QuadVertex2Z));
cur_verts[std::make_tuple(QuadVertex2X, QuadVertex2Y, QuadVertex2Z)] = i2;
cur_verts[t] = i2;
}
t = std::make_tuple(QuadVertex3X, QuadVertex3Y, QuadVertex3Z);
t.set(QuadVertex3X, QuadVertex3Y, QuadVertex3Z);
iter = cur_verts.find(t);
if (iter != cur_verts.end()) {
i3 = iter->second;
@ -848,10 +860,10 @@ bool Map::LoadV2(FILE *f) {
else {
i3 = (uint32)verts.size();
verts.push_back(glm::vec3(QuadVertex3X, QuadVertex3Y, QuadVertex3Z));
cur_verts[std::make_tuple(QuadVertex3X, QuadVertex3Y, QuadVertex3Z)] = i3;
cur_verts[t] = i3;
}
t = std::make_tuple(QuadVertex4X, QuadVertex4Y, QuadVertex4Z);
t.set(QuadVertex4X, QuadVertex4Y, QuadVertex4Z);
iter = cur_verts.find(t);
if (iter != cur_verts.end()) {
i4 = iter->second;
@ -859,7 +871,7 @@ bool Map::LoadV2(FILE *f) {
else {
i4 = (uint32)verts.size();
verts.push_back(glm::vec3(QuadVertex4X, QuadVertex4Y, QuadVertex4Z));
cur_verts[std::make_tuple(QuadVertex4X, QuadVertex4Y, QuadVertex4Z)] = i4;
cur_verts[t] = i4;
}
indices.push_back(i4);