Remove trailing whitespace

This commit is contained in:
j883376
2013-05-06 13:07:41 -04:00
parent 7a93966158
commit ffcff4aea1
548 changed files with 16397 additions and 16398 deletions
+78 -78
View File
@@ -4,13 +4,13 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -64,15 +64,15 @@ Map* Map::LoadMapfile(const char* in_zonename, const char *directory) {
char zBuf[64];
char cWork[256];
Map* ret = 0;
//have to convert to lower because the short names im getting
//are not all lower anymore, copy since strlwr edits the str.
strn0cpy(zBuf, in_zonename, 64);
if(directory == nullptr)
directory = MAP_DIR;
snprintf(cWork, 250, "%s/%s.map", directory, strlwr(zBuf));
if ((fp = fopen( cWork, "rb" ))) {
ret = new Map();
if(ret != nullptr) {
@@ -96,7 +96,7 @@ Map::Map() {
_maxz = FLT_MIN;
_maxx = FLT_MIN;
_maxy = FLT_MIN;
m_Faces = 0;
m_Nodes = 0;
m_FaceLists = 0;
@@ -122,22 +122,22 @@ bool Map::loadMap(FILE *fp) {
printf("Invalid map version 0x%lx\n", (unsigned long)head.version);
return(false);
}
printf("Map header: %lu faces, %u nodes, %lu facelists\n", (unsigned long)head.face_count, (unsigned int)head.node_count, (unsigned long)head.facelist_count);
m_Faces = head.face_count;
m_Nodes = head.node_count;
m_FaceLists = head.facelist_count;
/* fread(&m_Vertex, 4, 1, fp);
fread(&m_Faces , 4, 1, fp);*/
// mFinalVertex = new VERTEX[m_Vertex];
mFinalFaces = new FACE [m_Faces];
mNodes = new NODE[m_Nodes];
mFaceLists = new uint32[m_FaceLists];
// fread(mFinalVertex, m_Vertex, sizeof(VERTEX), fp);
//this was changed to this loop from the single read because valgrind was
//hanging on this read otherwise... I dont pretend to understand it.
#ifdef SLOW_AND_CRAPPY_MAKES_VALGRIND_HAPPY
@@ -155,7 +155,7 @@ bool Map::loadMap(FILE *fp) {
return(false);
}
#endif
#ifdef SLOW_AND_CRAPPY_MAKES_VALGRIND_HAPPY
for(r = 0; r < m_Nodes; r++) {
if(fread(mNodes+r, sizeof(NODE), 1, fp) != 1) {
@@ -169,7 +169,7 @@ bool Map::loadMap(FILE *fp) {
return(false);
}
#endif
#ifdef SLOW_AND_CRAPPY_MAKES_VALGRIND_HAPPY
for(r = 0; r < m_FaceLists; r++) {
if(fread(mFaceLists+r, sizeof(uint32), 1, fp) != 1) {
@@ -183,8 +183,8 @@ bool Map::loadMap(FILE *fp) {
return(false);
}
#endif
/* mRoot = new NODE();
RecLoadNode(mRoot, fp );*/
@@ -248,7 +248,7 @@ for(m = 0; m < _node->faces.count; m++) {
FACE *c = &mFinalFaces[ *cfl ];
printf(" %lu (%.2f, %.2f, %.2f) (%.2f, %.2f, %.2f) (%.2f, %.2f, %.2f)\n",
*cfl, c->a.x, c->a.y, c->a.z,
c->b.x, c->b.y, c->b.z,
c->b.x, c->b.y, c->b.z,
c->c.x, c->c.y, c->c.z);
cfl++;
}*/
@@ -257,24 +257,24 @@ for(m = 0; m < _node->faces.count; m++) {
}
#ifdef DEBUG_SEEK
printf(" Kids: %u, %u, %u, %u\n", _node->nodes[0], _node->nodes[1], _node->nodes[2], _node->nodes[3]);
printf(" Contained In Box: (%.2f -> %.2f, %.2f -> %.2f)\n", _node->minx, _node->maxx, _node->miny, _node->maxy);
/*printf(" Node found has children.\n");
if(_node->node1 != nullptr) {
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
_node->node1->minx, _node->node1->maxx, _node->node1->miny, _node->node1->maxy);
}
if(_node->node2 != nullptr) {
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
_node->node2->minx, _node->node2->maxx, _node->node2->miny, _node->node2->maxy);
}
if(_node->node3 != nullptr) {
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
_node->node3->minx, _node->node3->maxx, _node->node3->miny, _node->node3->maxy);
}
if(_node->node4 != nullptr) {
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
printf("\tNode: (%.2f -> %.2f, %.2f -> %.2f)\n",
_node->node4->minx, _node->node4->maxx, _node->node4->miny, _node->node4->maxy);
}*/
#endif
@@ -334,8 +334,8 @@ int* Map::SeekFace( NodeRef node_r, float x, float y ) {
if(!(_node->flags & nodeFinal)) {
return(nullptr); //not a final node... could find the proper node...
}
//printf("Seeking face for (%.2f, %.2f) with root 0x%x.\n", x, y, _node);
float dx,dy;
float nx,ny;
@@ -346,19 +346,19 @@ int* Map::SeekFace( NodeRef node_r, float x, float y ) {
const VERTEX &v1 = cf.a;
const VERTEX &v2 = cf.b;
const VERTEX &v3 = cf.c;
dx = v2.x - v1.x; dy = v2.y - v1.y;
nx = x - v1.x; ny = y - v1.y;
if( dx*ny - dy*nx >0.0f ) continue;
dx = v3.x - v2.x; dy = v3.y - v2.y;
nx = x - v2.x; ny = y - v2.y;
if( dx*ny - dy*nx >0.0f ) continue;
dx = v1.x - v3.x; dy = v1.y - v3.y;
nx = x - v3.x; ny = y - v3.y;
if( dx*ny - dy*nx >0.0f ) continue;
*face++ = mFaceLists[_node->faces.offset + i];
}
*face = -1;
@@ -388,7 +388,7 @@ bool Map::LineIntersectsZone(VERTEX start, VERTEX end, float step_mag, VERTEX *r
curz = start.z;
VERTEX cur = start;
stepx = end.x - start.x;
stepy = end.y - start.y;
stepz = end.z - start.z;
@@ -421,7 +421,7 @@ bool Map::LineIntersectsZone(VERTEX start, VERTEX end, float step_mag, VERTEX *r
stepx = (stepx/factor)*step_mag;
stepy = (stepy/factor)*step_mag;
stepz = (stepz/factor)*step_mag;
cnode = SeekNode(GetRoot(), curx, cury);
if(cnode != lnode)
{
@@ -432,7 +432,7 @@ bool Map::LineIntersectsZone(VERTEX start, VERTEX end, float step_mag, VERTEX *r
if(LineIntersectsNode(cnode, start, end, result, on))
return(true);
if(cnode == finalnode)
return false;
}
@@ -472,12 +472,12 @@ bool Map::LineIntersectsNode( NodeRef node_r, VERTEX p1, VERTEX p2, VERTEX *resu
if(!(_node->flags & nodeFinal)) {
return(true); //not a final node... not sure best action
}
unsigned long i;
PFACE cur;
const uint32 *cfl = mFaceLists + _node->faces.offset;
for(i = 0; i < _node->faces.count; i++) {
if(*cfl > m_Faces)
continue; //watch for invalid lists, they seem to happen
@@ -514,14 +514,14 @@ float Map::FindBestZ( NodeRef node_r, VERTEX p1, VERTEX *result, FACE **on) cons
if(!(_node->flags & nodeFinal)) {
return(BEST_Z_INVALID); //not a final node... could find the proper node...
}
VERTEX tmp_result; //dummy placeholder if they do not ask for a result.
if(result == nullptr)
result = &tmp_result;
VERTEX p2(p1);
p2.z = BEST_Z_INVALID;
float best_z = BEST_Z_INVALID;
int zAttempt;
@@ -531,7 +531,7 @@ float Map::FindBestZ( NodeRef node_r, VERTEX p1, VERTEX *result, FACE **on) cons
// If we don't find a bestZ on the first attempt, we try again from a position CurrentZ + 10 higher
// This is in case the pathing between waypoints temporarily sends the NPC below ground level.
//
//
for(zAttempt=1; zAttempt<=2; zAttempt++) {
const uint32 *cfl = mFaceLists + _node->faces.offset;
@@ -549,7 +549,7 @@ printf("Start finding best Z...\n");
#ifdef DEBUG_BEST_Z
printf(" %lu (%.2f, %.2f, %.2f) (%.2f, %.2f, %.2f) (%.2f, %.2f, %.2f)\n",
*cfl, cur->a.x, cur->a.y, cur->a.z,
cur->b.x, cur->b.y, cur->b.z,
cur->b.x, cur->b.y, cur->b.z,
cur->c.x, cur->c.y, cur->c.z);
printf("Found a z: %.2f\n", result->z);
#endif
@@ -579,14 +579,14 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
if( cface == nullptr ) {
return(false); //cant intersect a face we dont have... i guess
}
const VERTEX &pa = cface->a;
const VERTEX &pb = cface->b;
const VERTEX &pc = cface->c;
//quick bounding box checks
float tbb;
tbb = Vmin3(x, pa, pb, pc);
if(p1.x < tbb && p2.x < tbb)
return(false);
@@ -596,7 +596,7 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
tbb = Vmin3(z, pa, pb, pc);
if(p1.z < tbb && p2.z < tbb)
return(false);
tbb = Vmax3(x, pa, pb, pc);
if(p1.x > tbb && p2.x > tbb)
return(false);
@@ -606,16 +606,16 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
tbb = Vmax3(z, pa, pb, pc);
if(p1.z > tbb && p2.z > tbb)
return(false);
//begin attempt 2
//#define RTOD 57.2957795 //radians to degrees constant.
float d;
float denom,mu;
VERTEX n, intersect;
// FACE *thisface = &mFinalFaces[ _node->pfaces[ i ] ];
VERTEX *p = &intersect;
if(result != nullptr)
p = result;
@@ -635,14 +635,14 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
n.z = cface->nz;
d = cface->nd;
#endif
//try inverting the normals...
n.x = -n.x;
n.y = -n.y;
n.z = -n.z;
d = - n.x * pa.x - n.y * pa.y - n.z * pa.z; //recalc
// Calculate the position on the line that intersects the plane
denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z);
if (ABS(denom) < EPS) // Line and plane don't intersect
@@ -676,7 +676,7 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
a1 = pa1.x*pa2.x + pa1.y*pa2.y + pa1.z*pa2.z;
a2 = pa2.x*pa3.x + pa2.y*pa3.y + pa2.z*pa3.z;
a3 = pa3.x*pa1.x + pa3.y*pa1.y + pa3.z*pa1.z;
//holy hell these 3 acos are slow, we need to rewrite this...
// total = (acos(a1) + acos(a2) + acos(a3));
// if (ABS(total - 2*M_PI) > EPS)
@@ -687,7 +687,7 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
return(true);
*/
/*
/*
//yet another failed method, project triangle and point into
//2 space based on largest component of the normal
//and check the triangle there.
@@ -704,7 +704,7 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
tz = -n.z;
else
tz = n.z;
VERTEX pa2, pb2, pc2;
if(tx < ty) {
//keep x
@@ -733,7 +733,7 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
pc2.x = pc.x; pc2.y = pc.y;
}
}
// Determine whether or not the intersection point is bounded by pa,pb,pc
#define Sign(p1, p2, p3) \
((p1->x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1->y - p3.y))
@@ -745,10 +745,10 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
return ((b1 == b2) && (b2 == b3));
*/
/* //not working well, seems to block LOS a lot
//a new check based on barycentric coordinates, stolen from
//a new check based on barycentric coordinates, stolen from
//http://www.flipcode.com/cgi-bin/fcmsg.cgi?thread_show=7766
float xcp, ycp, xab, yab, xac, yac;
float divb;
@@ -802,7 +802,7 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
return(true);
*/
/*
Yet another method adapted from this code:
Vec3 pa1 = pa - p;
@@ -816,7 +816,7 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
if (d < 0) return false;
return true;
*/
//in practice, this seems to actually take longer
//than the arc cosine method above...
n.x = -n.x;
@@ -824,55 +824,55 @@ bool Map::LineIntersectsFace( PFACE cface, VERTEX p1, VERTEX p2, VERTEX *result)
n.z = -n.z;
VERTEX pa1,pa2,pa3, tmp;
float t;
//pa1 = pa - p
pa1.x = pa.x - p->x;
pa1.y = pa.y - p->y;
pa1.z = pa.z - p->z;
//pa2 = pb - p
pa2.x = pb.x - p->x;
pa2.y = pb.y - p->y;
pa2.z = pb.z - p->z;
//tmp = pa1 cross pa2
tmp.x = pa1.y * pa2.z - pa1.z * pa2.y;
tmp.y = pa1.z * pa2.x - pa1.x * pa2.z;
tmp.z = pa1.x * pa2.y - pa1.y * pa2.x;
//t = tmp dot n
t = tmp.x * n.x + tmp.y * n.y + tmp.z * n.z;
if(t < 0)
return(false);
//printf("t = %f\n", t);
//pa3 = pb - p
pa3.x = pc.x - p->x;
pa3.y = pc.y - p->y;
pa3.z = pc.z - p->z;
//tmp = pa2 cross pa3
tmp.x = pa2.y * pa3.z - pa2.z * pa3.y;
tmp.y = pa2.z * pa3.x - pa2.x * pa3.z;
tmp.z = pa2.x * pa3.y - pa2.y * pa3.x;
//t = tmp dot n
t = tmp.x * n.x + tmp.y * n.y + tmp.z * n.z;
if(t < 0)
return(false);
//printf("t = %f\n", t);
//tmp = pa3 cross pa1
tmp.x = pa3.y * pa1.z - pa3.z * pa1.y;
tmp.y = pa3.z * pa1.x - pa3.x * pa1.z;
tmp.z = pa3.x * pa1.y - pa3.y * pa1.x;
//t = tmp dot n
t = tmp.x * n.x + tmp.y * n.y + tmp.z * n.z;
if(t < 0)
return(false);
//printf("t = %f\n", t);
return(true);
}
@@ -890,7 +890,7 @@ bool Map::LineIntersectsZoneNoZLeaps(VERTEX start, VERTEX end, float step_mag, V
cur.x = start.x;
cur.y = start.y;
cur.z = start.z;
step.x = end.x - start.x;
step.y = end.y - start.y;
step.z = end.z - start.z;
@@ -914,7 +914,7 @@ bool Map::LineIntersectsZoneNoZLeaps(VERTEX start, VERTEX end, float step_mag, V
step.y = -0.001f;
if (step.z < 0 && step.z > -0.001f)
step.z = -0.001f;
NodeRef cnode, lnode;
lnode = 0;
//while we are not past end
@@ -926,7 +926,7 @@ bool Map::LineIntersectsZoneNoZLeaps(VERTEX start, VERTEX end, float step_mag, V
if (cnode == NODE_NONE)
{
return(true);
}
}
VERTEX me;
me.x = cur.x;
me.y = cur.y;
@@ -948,7 +948,7 @@ bool Map::LineIntersectsZoneNoZLeaps(VERTEX start, VERTEX end, float step_mag, V
}
lnode = cnode;
}
//move 1 step
if (cur.x != end.x)
cur.x += step.x;
@@ -956,7 +956,7 @@ bool Map::LineIntersectsZoneNoZLeaps(VERTEX start, VERTEX end, float step_mag, V
cur.y += step.y;
if (cur.z != end.z)
cur.z += step.z;
//watch for end conditions
if ( (cur.x > end.x && end.x >= start.x) || (cur.x < end.x && end.x <= start.x) || (step.x == 0) ) {
cur.x = end.x;
@@ -968,7 +968,7 @@ bool Map::LineIntersectsZoneNoZLeaps(VERTEX start, VERTEX end, float step_mag, V
cur.z = end.z;
}
}
//walked entire line and didnt run into anything...
return(false);
}
@@ -980,19 +980,19 @@ float Map::FindClosestZ(VERTEX p ) const
std::list<float> ZSet;
NodeRef NodeR = SeekNode(MAP_ROOT_NODE, p.x, p.y);
if( NodeR == NODE_NONE || NodeR >= m_Nodes)
return 0;
PNODE CurrentNode = &mNodes[NodeR];
if(!(CurrentNode->flags & nodeFinal))
return 0;
return 0;
VERTEX p1(p), p2(p), Result;
p1.z = 999999;
p2.z = BEST_Z_INVALID;
const uint32 *CurrentFaceList = mFaceLists + CurrentNode->faces.offset;
@@ -1006,7 +1006,7 @@ float Map::FindClosestZ(VERTEX p ) const
if(CurrentFace->nz > 0 && LineIntersectsFace(CurrentFace, p1, p2, &Result))
ZSet.push_back(Result.z);
CurrentFaceList++;
}