MCPcopy Create free account
hub / github.com/demoth/jake2 / SV_Push

Method SV_Push

game/src/main/java/jake2/game/SV.java:297–450  ·  view source on GitHub ↗

Objects need to be moved back on a failed push, otherwise riders would continue to slide.

(SubgameEntity pusher, float[] move, float[] amove, GameExportsImpl gameExports)

Source from the content-addressed store, hash-verified

295 * continue to slide.
296 */
297 private static boolean SV_Push(SubgameEntity pusher, float[] move, float[] amove, GameExportsImpl gameExports) {
298 int i;
299 float[] mins = { 0, 0, 0 };
300 float[] maxs = { 0, 0, 0 };
301 float[] org = { 0, 0, 0 };
302 float[] org2 = { 0, 0, 0 };
303 float[] move2 = { 0, 0, 0 };
304 float[] forward = { 0, 0, 0 };
305 float[] right = { 0, 0, 0 };
306 float[] up = { 0, 0, 0 };
307
308 // clamp the move to 1/8 units, so the position will
309 // be accurate for client side prediction
310 for (i = 0; i < 3; i++) {
311 float temp;
312 temp = move[i] * 8.0f;
313 if (temp > 0.0)
314 temp += 0.5;
315 else
316 temp -= 0.5;
317 move[i] = 0.125f * (int) temp;
318 }
319
320 // find the bounding box
321 for (i = 0; i < 3; i++) {
322 mins[i] = pusher.absmin[i] + move[i];
323 maxs[i] = pusher.absmax[i] + move[i];
324 }
325
326 // we need this for pushing things later
327 Math3D.VectorSubtract(Globals.vec3_origin, amove, org);
328 Math3D.AngleVectors(org, forward, right, up);
329
330 // save the pusher's original position
331 gameExports.pushed[gameExports.pushed_p].ent = pusher;
332 Math3D.VectorCopy(pusher.s.origin,
333 gameExports.pushed[gameExports.pushed_p].origin);
334 Math3D.VectorCopy(pusher.s.angles,
335 gameExports.pushed[gameExports.pushed_p].angles);
336
337 if (pusher.getClient() != null)
338 gameExports.pushed[gameExports.pushed_p].deltayaw = pusher.getClient().getPlayerState().pmove.delta_angles[Defines.YAW];
339
340 gameExports.pushed_p++;
341
342 // move the pusher to it's final position
343 Math3D.VectorAdd(pusher.s.origin, move, pusher.s.origin);
344 Math3D.VectorAdd(pusher.s.angles, amove, pusher.s.angles);
345 gameExports.gameImports.linkentity(pusher);
346
347 // see if any solid entities are inside the final position
348
349 //check= g_edicts + 1;
350 for (int e = 1; e < gameExports.num_edicts; e++) {
351 SubgameEntity check = gameExports.g_edicts[e];
352 if (!check.inuse)
353 continue;
354 if (check.movetype == GameDefines.MOVETYPE_PUSH

Callers 1

SV_Physics_PusherMethod · 0.95

Calls 10

VectorSubtractMethod · 0.95
AngleVectorsMethod · 0.95
VectorCopyMethod · 0.95
getClientMethod · 0.95
VectorAddMethod · 0.95
SV_TestEntityPositionMethod · 0.95
DotProductMethod · 0.95
G_TouchTriggersMethod · 0.95
getPlayerStateMethod · 0.65
linkentityMethod · 0.65

Tested by

no test coverage detected