mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed collision bug with player <-> player
This commit is contained in:
parent
f63bcc8673
commit
805a74c1e4
|
@ -164,12 +164,6 @@ extern "C" void modc_predict()
|
||||||
if(!world.players[c])
|
if(!world.players[c])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
// TODO: this should be moved into the g_game
|
|
||||||
// but not done to preserve the nethash
|
|
||||||
if(length(world.players[c]->vel) > 150.0f)
|
|
||||||
world.players[c]->vel = normalize(world.players[c]->vel) * 150.0f;
|
|
||||||
|
|
||||||
world.players[c]->move();
|
world.players[c]->move();
|
||||||
world.players[c]->quantize();
|
world.players[c]->quantize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,13 +318,14 @@ void player_core::tick()
|
||||||
vec2 dir = normalize(pos - p->pos);
|
vec2 dir = normalize(pos - p->pos);
|
||||||
if(d < phys_size*1.25f && d > 1.0f)
|
if(d < phys_size*1.25f && d > 1.0f)
|
||||||
{
|
{
|
||||||
float a = phys_size*1.25f - d;
|
float a = (phys_size*1.45f - d);
|
||||||
|
|
||||||
// make sure that we don't add excess force by checking the
|
// make sure that we don't add excess force by checking the
|
||||||
// direction against the current velocity
|
// direction against the current velocity
|
||||||
vec2 veldir = normalize(vel);
|
vec2 veldir = normalize(vel);
|
||||||
float v = 1-(dot(veldir, dir)+1)/2;
|
float v = 1-(dot(veldir, dir)+1)/2;
|
||||||
vel = vel + dir*a*v;
|
vel = vel + dir*a*(v*0.75f);
|
||||||
|
vel = vel * 0.85f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle hook influence
|
// handle hook influence
|
||||||
|
@ -345,6 +346,10 @@ void player_core::tick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clamp the velocity to something sane
|
||||||
|
if(length(vel) > 100.0f)
|
||||||
|
vel = normalize(vel) * 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void player_core::move()
|
void player_core::move()
|
||||||
|
|
|
@ -1312,14 +1312,6 @@ void player::tick_defered()
|
||||||
vec2 start_vel = core.vel;
|
vec2 start_vel = core.vel;
|
||||||
bool stuck_before = test_box(core.pos, vec2(28.0f, 28.0f));
|
bool stuck_before = test_box(core.pos, vec2(28.0f, 28.0f));
|
||||||
|
|
||||||
// TODO: this should be moved into the g_game
|
|
||||||
// but not done to preserve the nethash
|
|
||||||
if(length(core.vel) > 150.0f)
|
|
||||||
{
|
|
||||||
dbg_msg("server", "insane move! clamping (%f,%f) %f", core.vel.x, core.vel.y, length(core.vel));
|
|
||||||
core.vel = normalize(core.vel) * 150.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.move();
|
core.move();
|
||||||
bool stuck_after_move = test_box(core.pos, vec2(28.0f, 28.0f));
|
bool stuck_after_move = test_box(core.pos, vec2(28.0f, 28.0f));
|
||||||
core.quantize();
|
core.quantize();
|
||||||
|
|
Loading…
Reference in a new issue