X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fwarpzonelib%2Fserver.qc;h=3d4a750455a3e5947b073e3c62e698a9d347ea74;hb=fd1994ad0d18eb285f70ac44afd8ab5b246a4e61;hp=94209205ba6b6e15d0000181d5115c61818051ae;hpb=d28bb718bfd02ac65b80e6160d829a2b5f2edc4d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/warpzonelib/server.qc b/qcsrc/warpzonelib/server.qc index 94209205b..3d4a75045 100644 --- a/qcsrc/warpzonelib/server.qc +++ b/qcsrc/warpzonelib/server.qc @@ -1,3 +1,5 @@ +#define REMOVEHACK + // for think function .vector warpzone_save_origin; .vector warpzone_save_angles; @@ -19,7 +21,7 @@ void WarpZone_StoreProjectileData(entity e) void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity) { - setorigin (player, to); + setorigin (player, to); // NOTE: this also aborts the move, when this is called by touch player.oldorigin = to; // for DP's unsticking player.angles = to_angles; player.fixangle = TRUE; @@ -42,35 +44,6 @@ float WarpZone_Teleported_Send(entity to, float sf) return TRUE; } -#define WARPZONE_TELEPORT_FIXSOLID(ret) \ - do \ - { \ - setorigin(player, o1 - player.view_ofs); \ - if(WarpZoneLib_MoveOutOfSolid(player)) \ - { \ - o1 = player.origin + player.view_ofs; \ - setorigin(player, o0 - player.view_ofs); \ - } \ - else \ - { \ - print("would have to put player in solid, won't do that\n"); \ - setorigin(player, o0 - player.view_ofs); \ - return (ret); \ - } \ - } \ - while(0) -#define WARPZONE_TELEPORT_DOTELEPORT() \ - do \ - { \ - WarpZone_RefSys_Add(player, wz); \ - WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1); \ - WarpZone_StoreProjectileData(player); \ - player.warpzone_teleport_time = time; \ - player.warpzone_teleport_finishtime = time; \ - player.warpzone_teleport_zone = wz; \ - } \ - while(0) - float WarpZone_Teleport(entity wz, entity player, float f0, float f1) { vector o0, a0, v0, o1, a1, v1, o10; @@ -109,12 +82,31 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1) o1 = o1 - v1 * (d / dv); } - // put him inside solid + // put him out of solid tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player); if(trace_startsolid) - WARPZONE_TELEPORT_FIXSOLID(0); + { + setorigin(player, o1 - player.view_ofs); + if(WarpZoneLib_MoveOutOfSolid(player)) + { + o1 = player.origin + player.view_ofs; + setorigin(player, o0 - player.view_ofs); + } + else + { + print("would have to put player in solid, won't do that\n"); + setorigin(player, o0 - player.view_ofs); + return 0; + } + } - WARPZONE_TELEPORT_DOTELEPORT(); + // do the teleport + WarpZone_RefSys_Add(player, wz); + WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1); + WarpZone_StoreProjectileData(player); + player.warpzone_teleport_time = time; + player.warpzone_teleport_finishtime = time; + player.warpzone_teleport_zone = wz; // prevent further teleports back float dt = (o1 - o10) * v1 * (1 / (v1 * v1)); @@ -166,8 +158,20 @@ void WarpZone_Touch (void) return; float f; - if(clienttype(self) == CLIENTTYPE_NOTACLIENT) - f = min(-1, -64 / vlen(self.velocity)); + // number of frames we need to go back: + // dist = 16*sqrt(2) qu + // dist ~ 24 qu + // 24 qu = v*t + // 24 qu = v*frametime*n + // n = 24 qu/(v*frametime) + // for clients go only one frame though, may be too irritating otherwise + // but max 0.25 sec = 0.25/frametime frames + // 24/(0.25/frametime) + // 96*frametime + float d; + d = 24 + max(vlen(other.mins), vlen(other.maxs)); + if(clienttype(other) == CLIENTTYPE_NOTACLIENT) + f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d); else f = -1; if(WarpZone_Teleport(self, other, f, 0)) @@ -313,8 +317,18 @@ float WarpZone_CheckProjectileImpact(entity player) if(!wz) return 0; +#ifdef REMOVEHACK + print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n"); +#else print("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n"); +#endif + print("Entity type: ", player.classname, "\n"); + print("Origin: ", vtos(player.origin), "\n"); + print("Velocity: ", vtos(player.velocity), "\n"); +#ifdef REMOVEHACK + return 0; +#else // retry previous move setorigin(player, player.warpzone_oldorigin); player.velocity = player.warpzone_oldvelocity; @@ -349,6 +363,7 @@ float WarpZone_CheckProjectileImpact(entity player) } return +1; +#endif } float WarpZone_Projectile_Touch() { @@ -770,43 +785,50 @@ void WarpZone_StartFrame() WarpZone_InitStep_UpdateTransform(); self = e; WarpZones_Reconnect(); + WarpZone_PostInitialize_Callback(); } - if(warpzone_warpzones_exist) + entity oldself, oldother; + oldself = self; + oldother = other; + for(e = world; (e = nextent(e)); ) { - entity oldself, oldother; - oldself = self; - oldother = other; - for(e = world; (e = nextent(e)); ) + if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); } + + float f = clienttype(e); + if(f == CLIENTTYPE_REAL) { - WarpZone_StoreProjectileData(e); - float f; - f = clienttype(e); - if(f == CLIENTTYPE_REAL) + if(e.solid == SOLID_NOT) // not spectating? + if(e.movetype == MOVETYPE_NOCLIP || e.movetype == MOVETYPE_FLY || e.movetype == MOVETYPE_FLY_WORLDONLY) // not spectating? (this is to catch observers) { - if(e.solid != SOLID_NOT) // not spectating? - continue; - if(e.movetype != MOVETYPE_NOCLIP && e.movetype != MOVETYPE_FLY) // not spectating? (this is to catch observers) - continue; - self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs); - if(!self) - continue; - other = e; - if(WarpZoneLib_ExactTrigger_Touch()) - continue; - if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0) - WarpZone_Teleport(self, e, -1, 0); // NOT triggering targets by this! + other = e; // player + + // warpzones + if(warpzone_warpzones_exist) { + self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs); + if(self) + if(!WarpZoneLib_ExactTrigger_Touch()) + if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0) + WarpZone_Teleport(self, e, -1, 0); } // NOT triggering targets by this! + + // teleporters + self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs); + if(self) + if(!WarpZoneLib_ExactTrigger_Touch()) + Simple_TeleportPlayer(self, other); // NOT triggering targets by this! } - if(f == CLIENTTYPE_NOTACLIENT) - { + } + + if(f == CLIENTTYPE_NOTACLIENT) + { + if(warpzone_warpzones_exist) for(; (e = nextent(e)); ) WarpZone_StoreProjectileData(e); - break; - } + break; } - self = oldself; - other = oldother; } + self = oldself; + other = oldother; } .float warpzone_reconnecting;