X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Flib%2Fwarpzone%2Fserver.qc;h=936d075da8f69e2b3057d965dc35029b57b1cf23;hp=7ddb96cbbf32b6506028705ca23fb08caed0ec6d;hb=820589b53e6802eb4c5ea563bb58d48c4f4aa9e1;hpb=8ba1f6c672361186033b8bebc3be677ac94bd4da diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 7ddb96cbb..936d075da 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -5,9 +5,9 @@ #elif defined(MENUQC) #elif defined(SVQC) #include + #include #include #include - #include #include #include #endif @@ -28,44 +28,31 @@ .float warpzone_teleport_finishtime; .entity warpzone_teleport_zone; -#ifdef SVQC - #define WarpZone_StoreProjectileData(e_) MACRO_BEGIN { \ - entity e = e_; \ - e.warpzone_oldorigin = e.origin; \ - e.warpzone_oldvelocity = e.velocity; \ - e.warpzone_oldangles = e.angles; \ - } MACRO_END -#elif defined(CSQC) - #define WarpZone_StoreProjectileData(e_) MACRO_BEGIN { \ - entity e = e_; \ - e.warpzone_oldorigin = e.move_origin; \ - e.warpzone_oldvelocity = e.move_velocity; \ - e.warpzone_oldangles = e.move_angles; \ - } MACRO_END -#endif +#define WarpZone_StoreProjectileData(e_) MACRO_BEGIN { \ + entity e = e_; \ + e.warpzone_oldorigin = e.origin; \ + e.warpzone_oldvelocity = e.velocity; \ + e.warpzone_oldangles = e.angles; \ + } MACRO_END void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity) { #ifdef SVQC + player.lastteleport_origin = player.origin; + player.lastteleporttime = time; +#endif setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch +#ifdef SVQC player.oldorigin = to; // for DP's unsticking - player.angles = to_angles; player.fixangle = true; - player.velocity = to_velocity; -#elif defined(CSQC) - player.move_origin = to; - player.move_angles = to_angles; - player.move_velocity = to_velocity; #endif + player.angles = to_angles; + player.velocity = to_velocity; BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT); if(IS_PLAYER(player)) -#ifdef SVQC BITCLR_ASSIGN(player.flags, FL_ONGROUND); -#elif defined(CSQC) - BITCLR_ASSIGN(player.move_flags, FL_ONGROUND); -#endif WarpZone_PostTeleportPlayer_Callback(player); } @@ -85,15 +72,9 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1) { vector o0, a0, v0, o1, a1, v1, o10; -#ifdef SVQC o0 = player.origin + player.view_ofs; v0 = player.velocity; a0 = player.angles; -#elif defined(CSQC) - o0 = player.move_origin + player.view_ofs; - v0 = player.move_velocity; - a0 = player.move_angles; -#endif o10 = o1 = WarpZone_TransformOrigin(wz, o0); v1 = WarpZone_TransformVelocity(wz, v0); @@ -137,7 +118,7 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1) } else { - LOG_INFO("would have to put player in solid, won't do that\n"); + LOG_INFO("would have to put player in solid, won't do that"); setorigin(player, o0 - player.view_ofs); return 0; } @@ -189,30 +170,26 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1) return 1; } -void WarpZone_Touch (entity this) +void WarpZone_Touch(entity this, entity toucher) { - if(other.classname == "trigger_warpzone") + if(toucher.classname == "trigger_warpzone") return; - if(time <= other.warpzone_teleport_finishtime) // already teleported this frame + if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame return; // FIXME needs a better check to know what is safe to teleport and what not -#ifdef SVQC - if(other.movetype == MOVETYPE_NONE || other.movetype == MOVETYPE_FOLLOW || other.tag_entity) -#elif defined(CSQC) - if(other.move_movetype == MOVETYPE_NONE || other.move_movetype == MOVETYPE_FOLLOW || other.tag_networkentity) + if((toucher.move_movetype == MOVETYPE_NONE && toucher.move_movetype == MOVETYPE_NONE) || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity +#ifdef CSQC + || tag_networkentity #endif + ) return; - if(WarpZoneLib_ExactTrigger_Touch(this, other)) + if(WarpZoneLib_ExactTrigger_Touch(this, toucher)) return; -#ifdef SVQC - if(WarpZone_PlaneDist(this, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet) -#elif defined(CSQC) - if(WarpZone_PlaneDist(this, other.move_origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet) -#endif + if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet) return; float f; @@ -227,36 +204,32 @@ void WarpZone_Touch (entity this) // 24/(0.25/frametime) // 96*frametime float d; - d = 24 + max(vlen(other.mins), vlen(other.maxs)); - if(IS_NOT_A_CLIENT(other)) - #ifdef SVQC - f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d); - #elif defined(CSQC) - f = -d / bound(frametime * d * 1, frametime * vlen(other.move_velocity), d); - #endif + d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs)); + if(IS_NOT_A_CLIENT(toucher)) + f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d); else f = -1; - if(WarpZone_Teleport(this, other, f, 0)) + if(WarpZone_Teleport(this, toucher, f, 0)) { #ifdef SVQC string save1, save2; save1 = this.target; this.target = string_null; save2 = this.target3; this.target3 = string_null; - SUB_UseTargets(this, other, other); // use other too? + SUB_UseTargets(this, toucher, toucher); // use toucher too? if (!this.target) this.target = save1; if (!this.target3) this.target3 = save2; save1 = this.target; this.target = string_null; save2 = this.target2; this.target2 = string_null; - SUB_UseTargets(this.enemy, other, other); // use other too? + SUB_UseTargets(this.enemy, toucher, toucher); // use toucher too? if (!this.target) this.target = save1; if (!this.target2) this.target2 = save2; #endif } else { - LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))\n"); + LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))"); } } @@ -365,17 +338,8 @@ float WarpZone_CheckProjectileImpact(entity player) { vector o0, v0; - .vector orgvec, velvec; -#ifdef SVQC - orgvec = origin; - velvec = velocity; -#elif defined(CSQC) - orgvec = move_origin; - velvec = move_velocity; -#endif - - o0 = player.orgvec + player.view_ofs; - v0 = player.velvec; + o0 = player.origin + player.view_ofs; + v0 = player.velocity; // if we teleported shortly before, abort if(time <= player.warpzone_teleport_finishtime + 0.1) @@ -388,24 +352,20 @@ float WarpZone_CheckProjectileImpact(entity player) return 0; #ifdef WARPZONELIB_REMOVEHACK - LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n"); + LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now"); #else - LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n"); + LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again"); #endif - LOG_INFO("Entity type: ", player.classname, "\n"); - LOG_INFO("Origin: ", vtos(player.orgvec), "\n"); - LOG_INFO("Velocity: ", vtos(player.velvec), "\n"); + LOG_INFO("Entity type: ", player.classname); + LOG_INFO("Origin: ", vtos(player.origin)); + LOG_INFO("Velocity: ", vtos(player.velocity)); #ifdef WARPZONELIB_REMOVEHACK return 0; #else // retry previous move -#ifdef SVQC setorigin(player, player.warpzone_oldorigin); -#elif defined(CSQC) - player.move_origin = player.warpzone_oldorigin; -#endif - player.velvec = player.warpzone_oldvelocity; + player.velocity = player.warpzone_oldvelocity; if(WarpZone_Teleport(wz, player, 0, 1)) { string save1, save2; @@ -425,7 +385,7 @@ float WarpZone_CheckProjectileImpact(entity player) else { setorigin(player, o0 - player.view_ofs); - player.velvec = v0; + player.velocity = v0; } return +1; @@ -434,9 +394,9 @@ float WarpZone_CheckProjectileImpact(entity player) #endif #endif -float WarpZone_Projectile_Touch(entity this) +float WarpZone_Projectile_Touch(entity this, entity toucher) { - if(other.classname == "trigger_warpzone") + if(toucher.classname == "trigger_warpzone") return true; // no further impacts if we teleported this frame! @@ -496,7 +456,7 @@ float WarpZone_Projectile_Touch(entity this) } #endif - if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, other)) + if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher)) return true; #endif @@ -627,7 +587,7 @@ void WarpZone_InitStep_UpdateTransform(entity this) point = point * (1 / (3 * area)); if(vdist(norm, <, 0.99)) { - LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.\n"); + LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE."); area = 0; // no autofixing in this case } norm = normalize(norm); @@ -644,15 +604,15 @@ void WarpZone_InitStep_UpdateTransform(entity this) makevectors(ang); if(norm * v_forward < 0) { - LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.\n"); + LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE."); norm = -1 * norm; } ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane ang.x = -ang.x; if(norm * v_forward < 0.99) - LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang), "\n"); + LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang)); if(vdist(org - this.aiment.origin, >, 0.5)) - LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").\n"); + LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ")."); } } else if(area > 0) @@ -675,7 +635,6 @@ void WarpZone_InitStep_ClearTarget(entity this) this.enemy = NULL; } -entity warpzone_first; .entity warpzone_next; void WarpZone_InitStep_FindTarget(entity this) { float i; @@ -775,6 +734,8 @@ spawnfunc(trigger_warpzone) BITSET_ASSIGN(this.effects, EF_NODEPTHTEST); this.warpzone_next = warpzone_first; warpzone_first = this; + + IL_PUSH(g_warpzones, this); } spawnfunc(func_camera) { @@ -847,46 +808,51 @@ void WarpZone_StartFrame() WarpZone_PostInitialize_Callback(); } - entity oldother = other; + if(warpzone_warpzones_exist) + { + IL_EACH(g_projectiles, true, + { + WarpZone_StoreProjectileData(it); + }); + } + - FOREACH_ENTITY(!is_pure(it), + FOREACH_CLIENT(true, { if(warpzone_warpzones_exist) - WarpZone_StoreProjectileData(it); + WarpZone_StoreProjectileData(it); // TODO: not actually needed if(IS_OBSERVER(it) || it.solid == SOLID_NOT) if(IS_CLIENT(it)) // we don't care about it being a bot { - other = it; // player - // warpzones if (warpzone_warpzones_exist) { entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs); if (e) - if (!WarpZoneLib_ExactTrigger_Touch(e, other)) + if (!WarpZoneLib_ExactTrigger_Touch(e, it)) if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0) WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this! } // teleporters - if(other.teleportable) + if(it.teleportable) { entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs); if (ent) - if (!WarpZoneLib_ExactTrigger_Touch(ent, other)) - Simple_TeleportPlayer(ent, other); // NOT triggering targets by this! + if (!WarpZoneLib_ExactTrigger_Touch(ent, it)) + Simple_TeleportPlayer(ent, it); // NOT triggering targets by this! } } }); - other = oldother; } .float warpzone_reconnecting; bool visible_to_some_client(entity ent) { - FOREACH_ENTITY(!IS_NOT_A_CLIENT(it), LAMBDA( - if (IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent)) return true; - )); + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent), + { + return true; + }); return false; } void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger) @@ -926,7 +892,7 @@ void WarpZone_PlayerPhysics_FixVAngle(entity this) #ifndef WARPZONE_DONT_FIX_VANGLE if(IS_REAL_CLIENT(this)) if(this.v_angle.z <= 360) // if not already adjusted - if(time - this.ping * 0.001 < this.warpzone_teleport_time) + if(time - CS(this).ping * 0.001 < this.warpzone_teleport_time) { this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle); this.v_angle_z += 720; // mark as adjusted