Skip to content

Commit

Permalink
Merge pull request Ash-LikeSnow#48 from BDCarrillo/master
Browse files Browse the repository at this point in the history
Casting a net for errors
  • Loading branch information
BDCarrillo authored May 29, 2024
2 parents c439333 + 48534b0 commit a3e2888
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
38 changes: 31 additions & 7 deletions Data/Scripts/CoreSystems/Ai/AiConstruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,39 @@ public void RegisterSubGrid(MyCubeGrid grid)
grid.Flags |= (EntityFlags)(1 << 31);
grid.OnFatBlockAdded += FatBlockAdded;
grid.OnFatBlockRemoved += FatBlockRemoved;
foreach (var cube in grid.GetFatBlocks().ToArray())

//BDC Temp debugging
var tempBlockArray = grid.GetFatBlocks().ToArray();
try
{
var battery = cube as MyBatteryBlock;
var stator = cube as IMyMotorStator;
var tool = cube as IMyShipToolBase;
var offense = cube as IMyOffensiveCombatBlock;
foreach (var cube in grid.GetFatBlocks())
{
var battery = cube as MyBatteryBlock;
var stator = cube as IMyMotorStator;
var tool = cube as IMyShipToolBase;
var offense = cube as IMyOffensiveCombatBlock;

if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null)
FatBlockAdded(cube);
if (battery != null || cube.HasInventory || stator != null || tool != null || offense != null)
FatBlockAdded(cube);
}
}
catch (Exception ex)
{
var modifiedBlockArray = grid.GetFatBlocks();
var msg = $"Original GetFatBlocks contained {tempBlockArray.Length} items, modified contains {modifiedBlockArray.Count}";
foreach (var original in tempBlockArray)
{
if(!modifiedBlockArray.Contains(original))
msg += $"Block {original.DisplayName} was removed \n";
}
foreach (var modified in modifiedBlockArray)
{
if (!tempBlockArray.Contains(modified))
msg += $"Block {modified.DisplayName} was added \n";
}
Log.Line(msg);
MyLog.Default.WriteLine(msg);
throw ex;
}
SubGridsRegistered[grid] = byte.MaxValue;
}
Expand Down
5 changes: 5 additions & 0 deletions Data/Scripts/CoreSystems/Ai/AiEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using VRage.Collections;
using VRage.Game.Entity;
using VRage.Game.ModAPI;
using VRage.Utils;
using VRageMath;

namespace CoreSystems.Support
Expand Down Expand Up @@ -186,6 +187,10 @@ internal void FatBlockAdded(MyCubeBlock cube)
if (Session.I.IsServer)
{
cube.CubeGrid.RemoveBlock(cube.SlimBlock, true);
//BDC Temp debugging
var msg = $"WeaponCore Removed {cube.BlockDefinition.Id.SubtypeId} block due to placement violations";
Log.Line(msg);
MyLog.Default.WriteLine(msg);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions Data/Scripts/CoreSystems/AudioVisual/AvShot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,9 @@ internal void SetupSounds(double distanceFromCameraSqr)
}
catch (Exception e)
{
MyLog.Default.Error($"Sound error with ammo: {AmmoDef.AmmoRound} from {Weapon.Comp.SubtypeName} soundID {AmmoDef.Const.ShotSoundPair.SoundId} cuename {AmmoDef.Const.ShotSoundPair.GetCueName()}");
throw;
MyLog.Default.Error($"Sound error with ammo: {AmmoDef.AmmoRound} from {Weapon.Comp.TerminalBlock.DisplayName} soundID {AmmoDef.Const.ShotSoundPair.SoundId} cuename {AmmoDef.Const.ShotSoundPair.GetCueName()}" +
$"FireEmitter.Entity null? {FireEmitter?.Entity == null} \n Origin: {Origin}");
throw e;
}
}
}
Expand Down

0 comments on commit a3e2888

Please sign in to comment.