1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

Important ModAPI Issues

Discussion in 'Modding' started by rexxar, Oct 10, 2017.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. rexxar

    rexxar Senior Engineer

    Messages:
    1,532
    Hi everyone, I'm currently tasked with finding all issues and broken things in ModAPI and fixing them!

    Here's what I need from you: Report broken things in this thread. DO NOT POST FEATURE REQUESTS HERE! Feature requests will be handled in a different thread.
    PB API issues will be handled in a separate thread as well.

    Please describe how the function currently behaves, how it should behave, and include a mod, world, video, or something which clearly shows the issue. Bonus points are awarded if I can reproduce your issue by loading a world and pressing a button ;)

    If you find something particularly unsafe or exploit-y, please do not report it in this thread. Instead, send an email to support@keenswh.com and it will end up on my desk :)

    Let's Make Modding Great Again!
     
  2. Gwindalmir

    Gwindalmir Senior Engineer

    Messages:
    1,006
    This one is mostly well know, but only occurs in certain circumstances.
    MyAPIGateway isn't always initialized before mod code starts executing (ie. IMyCubeBlock.Init).

    This is mostly an issue on the first session load for that game launch. Once you've loaded a world for the first time, this error is unlikely to occur.
    However for things like the DS, that first load is the only one it sees.

    I don't have a repro case at this moment, but I'll update this post if I get one set up (unless someone else beats me to it).
     
  3. krypt-lynx

    krypt-lynx Apprentice Engineer

    Messages:
    175
  4. Gwindalmir

    Gwindalmir Senior Engineer

    Messages:
    1,006
    Another issue:
    IMyCubeGrid.PositionComp.WorldAABB/LocalAABB does not shrink when you remove blocks from a grid.
    It will grow as you add blocks, but it never shrinks until you reload the world.

    It's an old issue, and was probably done this way for performance, but there's no other way to get an accurate size of the grid without enumerating all blocks on it. At the minimum we need a way to force a rebuild of this value.
     
  5. Digi

    Digi Senior Engineer

    Messages:
    2,393
    • MyAPIGateway.CubeBuilder.FreezeGizmo's setter always sets it to true. Source
    • (just a reminder, you have the fix :p ) MyCubeBuilder.Static.GetBuildBoundingBox() has improper Center when you aim at a grid.

    Stuff I consider broken, but they're technically missing/incomplete stuff:
    • Some definitions are marked as internal and we can't use them, like MyCryoChamberDefinition, MyShipDrillDefinition, and a few others.
    • VRage.Game.ObjectBuilders.Definitions.SessionComponents.* isn't whitelisted, VoxelPlacementSettings and VoxelPlacementMode are used in MyCubeBlockDefinition.
    • MyAPIGateway.Session.Config is missing stuff like UIOpacity, UIBkOpacity, HUDBkOpacity and probably more.
     
    • Like Like x 1
    • Agree Agree x 1
  6. Meridius_IX

    Meridius_IX Trainee Engineer

    Messages:
    45
    Adding to this, it looks like MIdspace's Admin Helper mod uses the same trick to spawn bots. So I recorded a couple vids to show what happens:

    Mars Planet:


    Alien Planet:


    Edit: Accidentally duplicated my post, deleted one and kept this one
     
  7. Vicizlat

    Vicizlat Apprentice Engineer

    Messages:
    174
    I am getting these errors:
    when I am trying to do this:
    Code:
    if (LandingGear.LockMode == SpaceEngineers.Game.ModAPI.Ingame.LandingGearMode.ReadyToLock)
     
  8. rexxar

    rexxar Senior Engineer

    Messages:
    1,532
    Reported.

    Added a half dozen tickets.
    AABB should update every 30 seconds, or on certain events. Check again and let me know if it's still a problem :)
    Reported
    Already fixed internally
    --- Automerge ---
    Thanks guys, keep it coming! :D
     
    • Like Like x 2
  9. Digi

    Digi Senior Engineer

    Messages:
    2,393
    Adding a gamelogic component to a grid only works server side, still an issue from what I understood.
     
  10. rexxar

    rexxar Senior Engineer

    Messages:
    1,532
    Reported internally. My best guess is that grids bypass the component adding stage when being replicated from the server.
     
  11. vorneus

    vorneus Trainee Engineer

    Messages:
    48
    Posted in features thread, but unsure if it's a feature request or a bug. Please remove if it is a feature rexxar.

    Earlier in the year, the constants that restrict MyTransparentGeometry were drastically reduced from 50,000 to 4,000. I've tried to get this reversed (as you know rexx!) but the limits are still in place:

    • MAX_TRANSPARENT_GEOMETRY_COUNT = 4000 (in class MyTransparentGeometry)
    • MAX_NEW_PARTICLES_COUNT = 2799 (in class MyTransparentGeometry)
    • MAX_TRANSPARENT_GEOMETRY_COUNT = 6000 (in class MyTransparentGeometryConstants)

    I'd be so grateful if all constants restricting MyTransparentGeometry to render billboards can be lifted or returned to their previous values.

    Cheers,

    -Ed
     
  12. Digi

    Digi Senior Engineer

    Messages:
    2,393
    • IMyEntity.Synchronized is reversed, it returns IsPreview which basically means do not synchronize.
    • MyAPIGateway.Session.VoxelMaps.CutOutShape() and similar, they require admin rights when called from MP clients, very misleading.
    • MyTransparentGeometry.AddBillboardOriented() with the Reflection arg higher than 0 is not recolorable (this includes changing alpha) anymore and also still makes rifle muzzle flashes white (see SE-5727 for the report on that one).
    • .Render.Visible set to false doesn't hide armor blocks on grids.
    • block.RefreshCustomInfo() doesn't update detail info in real time on most block types (Projector for example), you must re-click the block to see changes.
    • Adding a lot of lines to CustomInfo will freeze the terminal for a noticeable amount of time when clicking on the block. (1000 lines freezes for about 2 seconds).
    • A lot of methods either return lists or use "out" for giving lists (e.g. MyAPIGateway.TerminalControls.GetControls() ), those should be deprecated and given ways to do it without having to create a list every time.
    • Can't add terminal controls to projector (Reported as SE-5882).
     
    Last edited: Nov 4, 2017
  13. midspace

    midspace Senior Engineer

    Messages:
    2,224
    Faction information for the NPC factions is incorrectly returned with the localisation resource name, not the text.

    IMyFaction plFaction = MyAPIGateway.Session.Factions.TryGetPlayerFaction(MyAPIGateway.Session.Player.IdentityId);
    Echo(plFaction.Name);

    this should be "Space Pirates" not "{LOCG:DisplayName_Faction_SpacePirates_Translation}"
     
  14. Digi

    Digi Senior Engineer

    Messages:
    2,393
    • ModAPI.IMyCubeGrid.WorldToGridInteger() is using Vector3 argument instead of Vector3D; Ingame and MyCubeGrid ones are fine.
     
  15. Gwindalmir

    Gwindalmir Senior Engineer

    Messages:
    1,006
    This also affects TryGetFactionByName.
    You have to use the localization resource name in that method, not the faction name.

    TryGetFactionById("SPRT") on the other hand, still works correctly.
     
    Last edited: Nov 13, 2017
  16. midspace

    midspace Senior Engineer

    Messages:
    2,224
    The new GetGroup() for Grid Groups
    https://forum.keenswh.com/threads/7398266/

    It is supposed to have the following connection types.
    Code:
    [LIST]
    [*]Mechanical - Connections by rotor, piston, suspension.
    [*]Logical - Terminal connections. i.e. rotors, pistons, wheels. Includes Mechanical connections.
    [*]Physical - Connections which lock physics. i.e. connectors. Includes Logical and Mechanical connections.
    [*]NoContactDamage - Connections which lock physics, but do not connect terminals. Landing gear only.
    [/LIST]
    
    If I have read it correctly, Logical is rotors, pistons and wheels ONLY.
    However, it appears to be returning grids connected by Connector blocks also. It appears to return the same results as Physical except Physical also has Landing gear attached grids.

    A quick look Sandbox.Game.Entities.Cube.MyShipConnector.WeldInternal() shows that it is calling:
    Code:
    this.OnConstraintAdded(GridLinkTypeEnum.Logical, this.m_other.CubeGrid);
    this.OnConstraintAdded(GridLinkTypeEnum.Physical, this.m_other.CubeGrid);
    Edit:
    Maybe the code is right. Maybe the enum code description just needs a little more detail.

    From testing is should read more like:
    [*]Mechanical - Connections by rotor, piston, suspension.
    [*]Logical - Terminal connections. i.e. Connector block, and Mechanical connections.
    [*]Physical - Connections which lock physics. i.e. Landing gear, Logical and Mechanical connections.
    [*]NoContactDamage - Connections which lock physics, but do not connect terminals. Landing gear only.
     
    Last edited: Nov 28, 2017
  17. midspace

    midspace Senior Engineer

    Messages:
    2,224
    If you create a class that implements ModAPI and somehow cause an exception in the constructor, the error information is too brief and not helpful.

    Log information only shows:
    Code:
    2017-12-01 13:38:29.522 - Thread:  1 ->  Registered modules from: midspace ship scan dev_midspace.shipscan, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    2017-12-01 13:38:29.524 - Thread:  1 ->  Exception during loading of type : MainChatCommandLogic
    2017-12-01 13:38:29.524 - Thread:   1 ->  Registered modules from: midspace admin helper_midspace.adminscripts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    
    The exception handling within Sandbox.Game.World.MyScriptManager.TryAddEntityScripts appears to swallow the exception and not pass any detail whatsoever.
    To would be advantageous for exceptions generated by Mods, to be logged with the exception detail.

    Code:
    catch (Exception)
    {
    	MySandboxGame.Log.WriteLine("Exception during loading of type : " + type.Name);
    }
    
    --- Automerge ---
    The CustomDataChanged event is getting raised twice.
    I make a change in game to a block, and my ModAPI code appears to be getting fired twice.

    Looking at the Sandbox.Game.Entities.Cube.MyTerminalBlock.SetCustomData_Internal looks a little dubious.
    Code:
    	Action<MyTerminalBlock> customDataChanged = this.CustomDataChanged;
    	if (customDataChanged != null)
    	{
    		customDataChanged(this);
    	}
    	if (sync)
    	{
    		this.RaiseCustomDataChanged();
    	}
    My test code...
    Code:
    namespace midspace.mod.hyperdrive
    {
    	using Sandbox.Common.ObjectBuilders;
    	using Sandbox.ModAPI;
    	using VRage.Game.Components;
    	using VRage.ModAPI;
    	using VRage.ObjectBuilders;
    
    	[MyEntityComponentDescriptor(typeof(MyObjectBuilder_MyProgrammableBlock), false)]
    	public class ProgrammableBlockLogic : MyGameLogicComponent
    	{
    		#region fields
    
    		private MyObjectBuilder_EntityBase _objectBuilder;
    		private bool _isInitilized;
    		private IMyProgrammableBlock _programmableBlockEntity;
    
    		#endregion
    
    		public override void Init(MyObjectBuilder_EntityBase objectBuilder)
    		{
    			_objectBuilder = objectBuilder;
    			this.NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
    			this.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
    
    			if (!_isInitilized)
    			{
    				// Use this space to hook up events. NOT TO PROCESS ANYTHING.
    				_isInitilized = true;
    
    				_programmableBlockEntity = (IMyProgrammableBlock)Entity;
    				_programmableBlockEntity.CustomDataChanged += _programmableBlockEntity_CustomDataChanged;
    			}
    		}
    
    		private void _programmableBlockEntity_CustomDataChanged(IMyTerminalBlock obj)
    		{
    			string data = obj.CustomData;
    			VRage.Utils.MyLog.Default.WriteLine($"####### CUSTOM VALUE CHANGED {data}");
    
    			// TODO: do something with data.
    		}
    
    		public override void Close()
    		{
    			if (_isInitilized)
    			{
    				_programmableBlockEntity.CustomDataChanged -= _programmableBlockEntity_CustomDataChanged;
    			}
    		}
    
    		public override MyObjectBuilder_EntityBase GetObjectBuilder(bool copy = false)
    		{
    			return _objectBuilder;
    		}
    	}
    }
    
    --- Automerge ---
    When setting the StorageData on the IMyProgrammableBlock, it changes the ProgramData instead.

    Code:
    // Sandbox.Game.Entities.Blocks.MyProgrammableBlock
    string IMyProgrammableBlock.StorageData
    {
    	get
    	{
    		return this.m_storageData;
    	}
    	set
    	{
    		this.m_programData = value;
    		this.m_editorData = value;
    		if (Sync.IsServer)
    		{
    			this.Recompile(true);
    			return;
    		}
    		this.SendUpdateProgramRequest(this.m_programData, false);
    	}
    }
    
     
  18. midspace

    midspace Senior Engineer

    Messages:
    2,224
    Still not fixed in public.
     
  19. XCython

    XCython Trainee Engineer

    Messages:
    3
    I think the damage of warheads is not going through the DamageSystem anymore, that's why I cannot stop warheads from damaging grids right now. Explosions from missiles and projectiles still seem to be fine though, just the warheads are giving me headache.
     
  20. Anonymous Blackness

    Anonymous Blackness Trainee Engineer

    Messages:
    9
    Is anyone else having issues with MyGameLogicComponent.UpdateAfterSimulation() not being called after this last Update? It has completely broken the Mod I've been working on. Does anyone know if the devs did this intentionally or is it, hopefully, just a new bug?

    MyGameLogicComponent.UpdateAfterSimulation10() and MyGameLogicComponent.UpdateAfterSimulation100() are both still being called but MyGameLogicComponent.UpdateAfterSimulation() just won't fire.
     
  21. Dummy0815

    Dummy0815 Trainee Engineer

    Messages:
    16
    Currently there is no way to create projected blocks with the correct BuildBy Info.
    Internal: MyProjectorBase -> public void Build(MySlimBlock cubeBlock, long owner, long builder, bool requestInstant = true, long builtBy = 0L)
    ModAPI: IMyProjector -> void Build(VRage.Game.ModAPI.IMySlimBlock cubeBlock, long owner, long builder, bool requestInstant)

    further there is no way to check if the block is withing the block limits of the current user
    MyShipWelder -> private bool IsWithinWorldLimits(MyProjectorBase projector, string name).
    It is also not possible to rebuild the function, as access to some of the properties is also not available e.g. MaxBlocksPerPlayer.

    I'm not shure if I should classify this as a bug or feature request. But as this is essential for all moded welders to obtain compatibility (Block counting, Block limits), I would classify it as a bug ;-)
     
    • Agree Agree x 1
  22. Digi

    Digi Senior Engineer

    Messages:
    2,393
    A whitelist issue, IMyEntity.GetIntersectionWithLine() exists but it requires a non-whitelisted struct in order to be usable (MyIntersectionResultLineTriangleEx).
     
Thread Status:
This last post in this thread was made more than 31 days old.