FakeFishGames / Barotrauma

A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
http://www.barotraumagame.com/
1.76k stars 406 forks source link

Auto Operate on Turrets not attached to Submarines will crash the game. #14728

Open Regalis11 opened 1 month ago

Regalis11 commented 1 month ago

Discussed in https://github.com/FakeFishGames/Barotrauma/discussions/14725

Originally posted by **tribalknight** September 25, 2024 ### Disclaimers - [X] I have searched the issue tracker to check if the issue has already been reported. - [X] My issue happened while using mods. ### What happened? I was creating a spotlight item that tracks players using XML from the searchlight and adding the parameters to activate Auto-operate as well as ensuring the Spotlight only targets characters (humans and monsters included). Upon spawning the item outside of the submarine using cheats, the spotlight would point towards nearby characters as intended. Unfortunately, if everyone nearby is distant from the Spotlight, it will immediately crash the game (as well as crash the server in Multiplayer sessions). ### Reproduction steps 1. Create a mod using the searchlight XML and modify it to require no power and no minimum voltage. 2. For the parameters in the Turret, enable Auto-operate and disable Target Submarines and Target Items. 3. Once the mod is ready, load Barotrauma and either go into the Sub Editor or Host a Server with the mod. 4. Using the console, spawn the modded item during a round, and keep some distance from it. 5. If the round doesn't end and there are no nearby characters, the modded item will crash the game (or server if hosted in Multiplayer). ### Bug prevalence Just once ### Single player or multiplayer? Happens in both single player and multiplayer ### - _No response_ ### Version v1.5.9.2 (Summer Update Hotfix 2) ### - _No response_ ### Which operating system did you encounter this bug on? Windows ### Relevant error messages and crash reports ```shell Exception handler failed: One or more errors occurred. (Object reference not set to an instance of an object.) at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Barotrauma.SubmarineInfo.get_MD5Hash() in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaShared\SharedSource\Map\SubmarineInfo.cs:line 152 at Barotrauma.Program.CrashDump(GameMain game, String filePath, Exception exception) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaClient\ClientSource\Program.cs:line 182 at Barotrauma.Program.CrashHandler(Object sender, UnhandledExceptionEventArgs args) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaClient\ClientSource\Program.cs:line 76 Initial exception: Object reference not set to an instance of an object. at Barotrauma.Items.Components.Turret.CanShoot(Body targetBody, Character user, Identifier friendlyTag, Boolean targetSubmarines, Boolean allowShootingIfNothingInWay) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaShared\SharedSource\Items\Components\Turret.cs:line 1745 at Barotrauma.Items.Components.Turret.UpdateAutoOperate(Single deltaTime, Boolean ignorePower, Identifier friendlyTag) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaShared\SharedSource\Items\Components\Turret.cs:line 1140 at Barotrauma.Items.Components.Turret.Update(Single deltaTime, Camera cam) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaShared\SharedSource\Items\Components\Turret.cs:line 428 at Barotrauma.Item.Update(Single deltaTime, Camera cam) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaShared\SharedSource\Items\Item.cs:line 2348 at Barotrauma.MapEntity.UpdateAll(Single deltaTime, Camera cam) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaShared\SharedSource\Map\MapEntity.cs:line 689 at Barotrauma.GameScreen.Update(Double deltaTime) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaShared\SharedSource\Screens\GameScreen.cs:line 246 at Barotrauma.GameMain.Update(GameTime gameTime) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaClient\ClientSource\GameMain.cs:line 950 at Microsoft.Xna.Framework.Game.DoUpdate(GameTime gameTime) in E:\Barotrauma-development\Libraries\MonoGame.Framework\Src\MonoGame.Framework\Game.cs:line 656 at Microsoft.Xna.Framework.Game.Tick() in E:\Barotrauma-development\Libraries\MonoGame.Framework\Src\MonoGame.Framework\Game.cs:line 500 at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop() in E:\Barotrauma-development\Libraries\MonoGame.Framework\Src\MonoGame.Framework\SDL\SDLGamePlatform.cs:line 93 at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) in E:\Barotrauma-development\Libraries\MonoGame.Framework\Src\MonoGame.Framework\Game.cs:line 397 at Microsoft.Xna.Framework.Game.Run() in E:\Barotrauma-development\Libraries\MonoGame.Framework\Src\MonoGame.Framework\Game.cs:line 367 at Barotrauma.Program.Main(String[] args) in B:\programming\c#\Barotrauma\Barotrauma\BarotraumaClient\ClientSource\Program.cs:line 61 ```
Regalis11 commented 1 month ago

Fixed in https://github.com/FakeFishGames/Barotrauma-development/commit/84520964e4a924d1956ab7db6079c65fa84bd343