Skip to content

Commit 8677da0

Browse files
authored
fix: map boundary checks for projectiles (AscensionGameDev#2237)
1 parent 4574703 commit 8677da0

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Intersect.Server.Core/Entities/Projectile.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,12 @@ public bool MoveFragment(ProjectileSpawn spawn, bool move = true)
374374
var killSpawn = false;
375375
var map = MapController.Get(spawn.MapId);
376376

377-
if (Math.Round(newx) < 0)
377+
if (Math.Floor(newx) < 0)
378378
{
379-
if (MapController.Get(map.Left) != null)
379+
var leftMap = MapController.Get(map.Left);
380+
if (leftMap != null)
380381
{
381-
newMapId = MapController.Get(spawn.MapId).Left;
382+
newMapId = leftMap.Id;
382383
newx = Options.MapWidth - 1;
383384
}
384385
else
@@ -387,11 +388,12 @@ public bool MoveFragment(ProjectileSpawn spawn, bool move = true)
387388
}
388389
}
389390

390-
if (Math.Round(newx) > Options.MapWidth - 1)
391+
if (Math.Ceiling(newx) > Options.MapWidth)
391392
{
392-
if (MapController.Get(map.Right) != null)
393+
var rightMap = MapController.Get(map.Right);
394+
if (rightMap != null)
393395
{
394-
newMapId = MapController.Get(spawn.MapId).Right;
396+
newMapId = rightMap.Id;
395397
newx = 0;
396398
}
397399
else
@@ -400,11 +402,12 @@ public bool MoveFragment(ProjectileSpawn spawn, bool move = true)
400402
}
401403
}
402404

403-
if (Math.Round(newy) < 0)
405+
if (Math.Floor(newy) < 0)
404406
{
405-
if (MapController.Get(map.Up) != null)
407+
var upMap = MapController.Get(map.Up);
408+
if (upMap != null)
406409
{
407-
newMapId = MapController.Get(spawn.MapId).Up;
410+
newMapId = upMap.Id;
408411
newy = Options.MapHeight - 1;
409412
}
410413
else
@@ -413,11 +416,12 @@ public bool MoveFragment(ProjectileSpawn spawn, bool move = true)
413416
}
414417
}
415418

416-
if (Math.Round(newy) > Options.MapHeight - 1)
419+
if (Math.Ceiling(newy) > Options.MapHeight)
417420
{
418-
if (MapController.Get(map.Down) != null)
421+
var downMap = MapController.Get(map.Down);
422+
if (downMap != null)
419423
{
420-
newMapId = MapController.Get(spawn.MapId).Down;
424+
newMapId = downMap.Id;
421425
newy = 0;
422426
}
423427
else

0 commit comments

Comments
 (0)