Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: clientgame.cpp
- ===================================================================
- --- clientgame.cpp (revision 6621)
- +++ clientgame.cpp (working copy)
- @@ -1183,7 +1183,7 @@
- conoutf(" The mean height is: %.2f", Mh);
- if (Hhits) conoutf(" Height check is: %d", Hhits);
- if (MA) conoutf(" The max area is: %d (of %d)", MA, Ma);
- - if (m_flags && F2F < 1000) conoutf(" Flag-to-flag distance is: %d", (int)fSqrt(F2F));
- + if (m_flags && F2F < 1000) conoutf(" Flag-to-flag distance is: %d", (int)sqrt((float)F2F));
- if (item_fail) conoutf(" There are one or more items too close to each other in this map");
- }
- COMMAND(showmapstats, ARG_NONE);
- Index: editing.cpp
- ===================================================================
- --- editing.cpp (revision 6621)
- +++ editing.cpp (working copy)
- @@ -527,6 +527,17 @@
- newentity(-1, sel.x, sel.y, (int)camera1->o.z, what, ATOI(a1), ATOI(a2), ATOI(a3), ATOI(a4));
- }
- +void newtclip(char *a1, char *a2, char *a3, char *a4, char *a5)
- +{
- + EDITSEL;
- + int xlen = atoi(a2) & 0x00000F;
- + int ylen = atoi(a3) & 0x00000F;
- + int attr2 = xlen | (ylen << 4);
- + newentity(-1, sel.x, sel.y, (int)camera1->o.z, "tclip", ATOI(a1), attr2, ATOI(a4), ATOI(a5));
- +}
- +
- +COMMAND(newtclip, ARG_5STR);
- +
- void movemap(int xo, int yo, int zo) // move whole map
- {
- EDITMP;
- Index: entities.cpp
- ===================================================================
- --- entities.cpp (revision 6621)
- +++ entities.cpp (working copy)
- @@ -18,18 +18,45 @@
- rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), yaw, 0);
- }
- +void getcliplen(entity &e, int &xlen, int &ylen)
- +{
- + if(e.type == TCLIP)
- + {
- + xlen = e.attr2 & 0x0F;
- + ylen = (e.attr2 & 0xF0) >> 4;
- + }
- + else
- + {
- + xlen = e.attr2;
- + ylen = e.attr3;
- + }
- +}
- +
- void renderclip(entity &e)
- {
- - float xradius = max(float(e.attr2), 0.1f), yradius = max(float(e.attr3), 0.1f);
- + int xlen, ylen;
- + getcliplen(e, xlen, ylen);
- +
- + float xradius = max(float(xlen), 0.1f), yradius = max(float(ylen), 0.1f);
- vec bbmin(e.x - xradius, e.y - yradius, float(S(e.x, e.y)->floor+e.attr1)),
- bbmax(e.x + xradius, e.y + yradius, bbmin.z + max(float(e.attr4), 0.1f));
- + if(e.type==TCLIP)
- + {
- + // draw textured clip
- + // TODO!
- + Texture *t = lookuptexture(e.attr3);
- + }
- +
- + if(!editmode) return;
- +
- glDisable(GL_TEXTURE_2D);
- switch(e.type)
- {
- case CLIP: linestyle(1, 0xFF, 0xFF, 0); break; // yellow
- case MAPMODEL: linestyle(1, 0, 0xFF, 0); break; // green
- case PLCLIP: linestyle(1, 0xFF, 0, 0xFF); break; // magenta
- + case TCLIP: linestyle(1, 0, 0, 0xFF); break;
- }
- glBegin(GL_LINES);
- @@ -208,6 +235,10 @@
- renderent(e);
- }
- }
- + else if(e.type == TCLIP)
- + {
- + renderclip(e);
- + }
- else if(editmode)
- {
- if(e.type==CTF_FLAG)
- Index: entity.h
- ===================================================================
- --- entity.h (revision 6621)
- +++ entity.h (working copy)
- @@ -13,6 +13,7 @@
- SOUND,
- CLIP,
- PLCLIP,
- + TCLIP,
- MAXENTTYPES
- };
- Index: geom.h
- ===================================================================
- --- geom.h (revision 6621)
- +++ geom.h (working copy)
- @@ -3,7 +3,7 @@
- // http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf
- // http://www.mceniry.net/papers/Fast%20Inverse%20Square%20Root.pdf
- // http://en.wikipedia.org/wiki/Fast_inverse_square_root
- -#define UFINVSQRT(x) union { int d; float f; } u; u.f = x; u.d = 0x5f3759df - (u.d >> 1)
- +/*#define UFINVSQRT(x) union { int d; float f; } u; u.f = x; u.d = 0x5f3759df - (u.d >> 1)
- inline float ufInvSqrt (float x) { UFINVSQRT(x); return u.f; } // about 3.5% of error
- inline float fInvSqrt (float x) { UFINVSQRT(x); return 0.5f * u.f * ( 3.00175f - x * u.f * u.f ); } // about 0.1% of error
- inline float fSqrt (float x) { return x * fInvSqrt(x); }
- @@ -24,13 +24,14 @@
- u.f = y * 0.5f * u.f * ( 3.0f - y * u.f * u.f );
- return 1.57079632f * ( r + s * u.f * ( 0.9003163f + y * ( 0.07782684f + y * ( 0.006777598f + y * 0.015079262f ) ) ) );
- }
- -#undef UFINVSQRT
- +#undef UFINVSQRT*/
- template <typename T> inline T pow2(T x) { return x*x; }
- +inline float uSqrt(float x) { return sqrt(fabs(x)); }
- // Fast Cosine
- // inspired after http://www.devmaster.net/forums/showthread.php?t=5784
- -#define FCOS \
- +/*#define FCOS \
- x = fabs(x); \
- int s = 1; \
- if ( x > 1.0f ) \
- @@ -45,7 +46,7 @@
- inline float fSin(float x) { x *= 0.636619772f; x -= 1.0f; FCOS; }
- #undef FCOS
- -inline float ufS2C(float x) { x *= x; return x < 1.0f ? ufSqrt(1.0f - x) : 0.0f; }
- +inline float ufS2C(float x) { x *= x; return x < 1.0f ? ufSqrt(1.0f - x) : 0.0f; }*/
- struct vec
- {
- @@ -86,8 +87,8 @@
- float magnitude() const { return sqrtf(squaredlen()); }
- vec &normalize() { div(magnitude()); return *this; }
- - float fmag() const { return fSqrt(squaredlen()); }
- - float ufmag() const { return ufSqrt(squaredlen()); }
- + //float fmag() const { return fSqrt(squaredlen()); }
- + //float ufmag() const { return ufSqrt(squaredlen()); }
- float dist(const vec &e) const { vec t; return dist(e, t); }
- float dist(const vec &e, vec &t) const { t = *this; t.sub(e); return t.magnitude(); }
- @@ -95,8 +96,8 @@
- float distxy(const vec &e) const { float dx = e.x - x, dy = e.y - y; return sqrtf(dx*dx + dy*dy); }
- float magnitudexy() const { return sqrtf(x*x + y*y); }
- - float fmagxy() const { return fSqrt(x*x + y*y); }
- - float ufmagxy() const { return ufSqrt(x*x + y*y); }
- + //float fmagxy() const { return fSqrt(x*x + y*y); }
- + //float ufmagxy() const { return ufSqrt(x*x + y*y); }
- bool reject(const vec &o, float max) const { return x>o.x+max || x<o.x-max || y>o.y+max || y<o.y-max; }
- Index: physics.cpp
- ===================================================================
- --- physics.cpp (revision 6621)
- +++ physics.cpp (working copy)
- @@ -117,9 +117,11 @@
- {
- entity &e = ents[i];
- // if(e.type==CLIP || (e.type == PLCLIP && d->type == ENT_PLAYER))
- - if (e.type==CLIP || (e.type == PLCLIP && (d->type == ENT_BOT || d->type == ENT_PLAYER))) // don't allow bots to hack themselves into plclips - Bukz 2011/04/14
- + if (e.type==CLIP || e.type == TCLIP || (e.type == PLCLIP && (d->type == ENT_BOT || d->type == ENT_PLAYER))) // don't allow bots to hack themselves into plclips - Bukz 2011/04/14
- {
- - if(fabs(e.x-d->o.x) < e.attr2 + d->radius && fabs(e.y-d->o.y) < e.attr3 + d->radius)
- + int xlen, ylen;
- + getcliplen(e, xlen, ylen);
- + if(fabs(e.x-d->o.x) < xlen + d->radius && fabs(e.y-d->o.y) < ylen + d->radius)
- {
- const float cz = float(S(e.x, e.y)->floor+e.attr1), ch = float(e.attr4);
- const float dz = d->o.z-d->eyeheight;
- @@ -535,7 +537,7 @@
- if(pl->type!=ENT_BOUNCE && hitplayer)
- {
- vec dr(hitplayer->o.x-pl->o.x,hitplayer->o.y-pl->o.y,0);
- - float invdist = ufInvSqrt(dr.sqrxy()),
- + float invdist = 1.0f/dr.magnitudexy(),
- push = (invdist < 10.0f ? dr.dotxy(d)*1.1f*invdist : dr.dotxy(d) * 11.0f);
- pl->o.x -= f*d.x*push;
- @@ -548,7 +550,7 @@
- if (cornersurface)
- {
- float ct2f = (cornersurface == 2 ? -1.0 : 1.0);
- - float diag = f*d.ufmagxy()*2;
- + float diag = f*d.magnitudexy()*2;
- vec vd = vec((d.y*ct2f+d.x >= 0.0f ? diag : -diag), (d.x*ct2f+d.y >= 0.0f ? diag : -diag), 0);
- pl->o.x -= f*d.x;
- pl->o.y -= f*d.y;
- Index: protos.h
- ===================================================================
- --- protos.h (revision 6621)
- +++ protos.h (working copy)
- @@ -702,6 +702,7 @@
- extern void checkitems(playerent *d);
- extern vector<int> changedents;
- extern void syncentchanges(bool force = false);
- +extern void getcliplen(entity &e, int &xlen, int &ylen);
- // rndmap
- extern void perlinarea(block &b, int scale, int seed, int psize);
- Index: server.cpp
- ===================================================================
- --- server.cpp (revision 6621)
- +++ server.cpp (working copy)
- @@ -1628,7 +1628,7 @@
- loopv(clients) if(clients[i]->type!=ST_EMPTY)
- {
- clientstate &cs = clients[i]->state;
- - sum += clients[i]->at3_score = cs.points > 0 ? ufSqrt((float)cs.points) : -ufSqrt((float)-cs.points);
- + sum += clients[i]->at3_score = cs.points > 0 ? uSqrt((float)cs.points) : -uSqrt((float)-cs.points);
- }
- return sum;
- }
- Index: server.h
- ===================================================================
- --- server.h (revision 6621)
- +++ server.h (working copy)
- @@ -446,7 +446,7 @@
- "none?",
- "light", "playerstart", "pistol", "ammobox","grenades",
- "health", "helmet", "armour", "akimbo",
- - "mapmodel", "trigger", "ladder", "ctf-flag", "sound", "clip", "plclip"
- + "mapmodel", "trigger", "ladder", "ctf-flag", "sound", "clip", "plclip", "tclip"
- };
- // see entity.h:61: struct itemstat { int add, start, max, sound; };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement