flag dropping, proper position rounding
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2351 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+15
-5
@@ -331,14 +331,24 @@ void flagdropped(int flag, int action, short x, short y, short z)
|
||||
p.o.y = y;
|
||||
p.o.z = z;
|
||||
p.vel.z = -0.8f;
|
||||
loopi(100)
|
||||
p.aboveeye = p.eyeheight = p.radius = 0.0f;
|
||||
|
||||
bool oldcancollide = false;
|
||||
if(f.actor)
|
||||
{
|
||||
moveplayer(&p, 10, true, 50); // calc drop position
|
||||
oldcancollide = f.actor->cancollide;
|
||||
f.actor->cancollide = false; // avoid collision with owner
|
||||
}
|
||||
loopi(100) // perform physics steps
|
||||
{
|
||||
moveplayer(&p, 10, true, 50);
|
||||
if(p.stuck) break;
|
||||
}
|
||||
f.flag->x = (short)p.o.x;
|
||||
f.flag->y = (short)p.o.y;
|
||||
f.flag->z = (short)p.o.z;
|
||||
if(f.actor) f.actor->cancollide = oldcancollide; // restore settings
|
||||
|
||||
f.flag->x = (short)round(p.o.x);
|
||||
f.flag->y = (short)round(p.o.y);
|
||||
f.flag->z = (short)round(p.o.z);
|
||||
if(f.flag->z < hdr.waterlevel) f.flag->z = (short) hdr.waterlevel;
|
||||
f.flag->spawned = true;
|
||||
f.ack = true;
|
||||
|
||||
@@ -277,4 +277,5 @@ bool isbigendian()
|
||||
return !(*((char *)(&one)));
|
||||
}
|
||||
|
||||
inline float round(float x) { return floor(x + 0.5f); }
|
||||
|
||||
|
||||
@@ -508,6 +508,7 @@ extern bool cmpb(void *b, int n, enet_uint32 c);
|
||||
extern bool cmpf(char *fn, enet_uint32 c);
|
||||
extern void endianswap(void *, int, int);
|
||||
extern bool isbigendian();
|
||||
extern inline float round(float x);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user