API Bugs

Discussion in 'Empyrion API' started by Jascha, Mar 14, 2017.

  1. Taelyn

    Taelyn Guest

    Here is the compleet code i used to test it out:

    Code:
    using Eleon.Modding;
    using System.Collections.Generic;
    
    namespace EmpyrionTestProject
    {
        public class EmpyrionTestProject : IMod
        {
            private static IModApi modApi { get; set; }
    
            public void Init(IModApi _modAPI)
            {
                modApi = _modAPI;
    
                modApi.Application.OnPlayfieldLoaded += OnPlayfieldLoaded;
    
                modApi.Log("Mod: init finish");
            }
    
            private void OnPlayfieldLoaded(IPlayfield playfield)
            {
                foreach (KeyValuePair<string, int> testSystem in modApi.Application.GetBlockAndItemMapping())
                {
                    modApi.LogError($"{testSystem.Key}, {testSystem.Value}");
                }
            }
    
            public void Shutdown()
            {
                modApi.Log("Mod: shutdown");
            }
        }
    }
    
    EmpyrionTestProject_Info.yaml:

    Code:
    Name: EmpyrionTestProject
    Description: Empyrion Test Project
    Author: Taelyn
    Version: 0.0.0
    
    # Possible targets: None, Dedi, PfServer, Client (the latter three can be combined)
    # Note: If not set 'Dedi' is the default
    ModTargets: PfServer
     
    #141
  2. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    The function is probably not yet available when loading the mods - even the DemoMod started in the PfServer leads to the error
    -->
     
    #142
  3. Taelyn

    Taelyn Guest

    The function gets active when the first Player Joins the Playfield
     
    #143
  4. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    Sorry, but THAT can only be a bad joke - when the player enters a playfield, the game has better things to do than read in such static information.
     
    #144
  5. Taelyn

    Taelyn Guest

    This data is SaveGame bound. The SaveGame is only generated when a player is ONLINE
     
    #145
  6. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    Ok then I know - thank you - unfortunately the function is unusable for me and I will have to stick to my implementation
     
    #146
  7. Xango2000

    Xango2000 Captain

    Joined:
    Jun 15, 2016
    Messages:
    857
    Likes Received:
    472
    Could yall be dealing with 2 different versions of the server software.

    I use relative pathing for my mods, on most servers my mods tell me their root folder is
    Empyrion - Dedicated Server/DedicatedServer

    There are a few hosts that my mods tell me
    Empyrion - Dedicated Server/
    Is their root folder
     
    #147
  8. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    I improved the performance of the EmpyrionScriptingMod, but when they change the LCDs, the EmpyrionClient !!! abort with these log

    Code:
    30-18:39:38.769 20_39 -ERR- Error in reader ch=0
    30-18:39:38.776 20_39 -EXC- ProtoBuf.ProtoException: Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see https://stackoverflow.com/q/2152978/23354
      at ProtoBuf.ProtoReader.ReadInt32 () [0x000e9] in <4cb0ba2763054c8a8f233bbbce6b7dcc>:0
      at (wrapper dynamic-method) Eleon.Modding.ItemStack.proto_10(object,ProtoBuf.ProtoReader)
      at ProtoBuf.Serializers.CompiledSerializer.ProtoBuf.Serializers.IProtoSerializer.Read (System.Object value, ProtoBuf.ProtoReader source) [0x00000] in <4cb0ba2763054c8a8f233bbbce6b7dcc>:0
      at ProtoBuf.Meta.RuntimeTypeModel.Deserialize (System.Int32 key, System.Object value, ProtoBuf.ProtoReader source) [0x0003c] in <4cb0ba2763054c8a8f233bbbce6b7dcc>:0
      at ProtoBuf.Meta.TypeModel.DeserializeCore (ProtoBuf.ProtoReader reader, System.Type type, System.Object value, System.Boolean noAutoCreate) [0x00015] in <4cb0ba2763054c8a8f233bbbce6b7dcc>:0
      at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type, ProtoBuf.SerializationContext context) [0x00022] in <4cb0ba2763054c8a8f233bbbce6b7dcc>:0
      at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type) [0x00000] in <4cb0ba2763054c8a8f233bbbce6b7dcc>:0
      at ProtoBuf.Serializer.Deserialize[T] (System.IO.Stream source) [0x00005] in <4cb0ba2763054c8a8f233bbbce6b7dcc>:0
      at Assembly-CSharp.TextFileHelper.ChangeResource (System.IO.BinaryReader ) [0x00026] in <dcc8a0e90aec42bd88e6fc3ab88d4a23>:0
      at Assembly-CSharp.ConnectionType.DisableBookmark (System.IO.BinaryReader , Assembly-CSharp.GroupType ) [0x0000b] in <dcc8a0e90aec42bd88e6fc3ab88d4a23>:0
      at Assembly-CSharp.ResourceService.DisableBookmark (Assembly-CSharp.BookmarkInvokerPackageDictionary+PackageLoaderPackageDictionary ) [0x00208] in <dcc8a0e90aec42bd88e6fc3ab88d4a23>:0
    30-18:39:38.806 20_39 -LOG- Disconnected from server [ConnRes]
    If i throttle down the LCD changes the error doesn't occur.
     
    #148
  9. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    Unfortunately, here the ModAPI of Empyrion has some errors in the SinglePlayer :
    - A scenario from the workshop is not delivered at all via ``ModApi.Application?.GetPathFor(AppFolder.ActiveScenario)```.
    - On a playfield change, the structure the player flies and all docked is not in the list of structures ```playfield.Entities``
     
    #149
  10. Taelyn

    Taelyn Guest

    Known
     
    #150
  11. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    @Jascha früher hat dieser Code zum Spawnen von Strukturen funktioniert, was muss ich ändern damit er wieder funktioniert?

    Code:
    public async Task CreateStructure(string aSelectBackupDir, PlayfieldGlobalStructureInfo aStructure)
    {
        var NewID = await Request_NewEntityId();
    
        var SourceDir = Path.Combine(BackupDir,
                        aSelectBackupDir == CurrentSaveGame ? EmpyrionConfiguration.ProgramPath : aSelectBackupDir,
                        @"Saves\Games",
                        Path.GetFileName(EmpyrionConfiguration.SaveGamePath), "Shared", aStructure.structureName);
    
        var sourceExportDat = Path.Combine(SourceDir, "ents.dat");
        var TargetDir       = Path.Combine(EmpyrionConfiguration.SaveGamePath, "Shared", $"{NewID.id}");
    
        var SpawnInfo = new EntitySpawnInfo()
        {
            forceEntityId       = NewID.id,
            playfield           = aStructure.Playfield,
            pos                 = new PVector3(aStructure.Pos.x, aStructure.Pos.y, aStructure.Pos.z),
            rot                 = new PVector3(aStructure.Rot.x, aStructure.Rot.y, aStructure.Rot.z),
            name                = aStructure.Name,
            type                = (byte)Array.IndexOf(EntityTypes, aStructure.Type), // Entity.GetFromEntityType 'Kommentare der Devs: Set this Undef = 0, BA = 2, CV = 3, SV = 4, HV = 5, AstVoxel = 7
            entityTypeName      = "", // 'Kommentare der Devs:  ...or set this to f.e. 'ZiraxMale', 'AlienCivilian1Fat', etc
            prefabName          = NewID.id.ToString(), // $"{aStructure.Type}_Player",
            factionGroup        = 0,
            factionId           = 0, // erstmal auf "public" aStructure.Faction,
            exportedEntityDat   = File.Exists(sourceExportDat) ? sourceExportDat : null
        };
    
        Directory.CreateDirectory(Path.GetDirectoryName(TargetDir));
        CopyAll(new DirectoryInfo(SourceDir), new DirectoryInfo(TargetDir));
    
        try { await Request_Load_Playfield(new PlayfieldLoad(20, aStructure.Playfield, 0)); }
        catch { }  // Playfield already loaded
    
        await Request_Entity_Spawn(SpawnInfo);
        for (int i = 0; i < 10; i++)
        {
            try
            {
                await Request_Structure_Touch(NewID); // Sonst wird die Struktur sofort wieder gelöscht !!!
                break;
            }
            catch
            {
                await Task.Delay(5000);
            }
        }
    }
    
     
    #151
  12. Jascha

    Jascha Administrator

    • Moderator
    Joined:
    Jan 22, 2016
    Messages:
    1,204
    Likes Received:
    671
    Nothing changed in the mod. Must be something in your code. But I can't see anything strange in the code.
     
    #152
    ASTIC likes this.
  13. Bhearus

    Bhearus Ensign

    Joined:
    Feb 18, 2021
    Messages:
    1
    Likes Received:
    0
    Build: 3283
    Mode: Surivial
    Mode: Dedicated

    SERVER NAME: None, just a local test server
    SEED-ID: N/A

    If applicable:
    MODIFIED PLAYFIELDS: None.

    Reproducibility: Always
    Severity: Major

    Type: Factory Resources

    Summary: API Request_Blueprint_Resources Request fails to apply resources properly.

    Description:

    See detailed reproduction steps below.

    Steps to Reproduce:
    Resources to Apply:
    4328:754
    4321:9424.4
    4322:8472.75
    4324:13418.5
    4323:12096
    4320:2670.6
    4360:6804
    4331:12096
    4326:6048
    4327:6048

    Image_1 - After a player connects, and they go to F2/Factory. Select a simple HV stock vehicle. Then the API Request_Blueprint_Resources is utilized to apply resources to that player. Note the application of the resources only shows the resources the HV requires and does not load the rest of the resources.

    Image_2 - Switching to a CV, it shows the resources loaded for the HV, but not the rest of the resources.

    Image_3 - Applying the same API Request_Blueprint_Resources while the CV is in the factory which requires all of the resources above further populates the resources above completely

    Image_4 shows how the factory should look after the first API call.

    Screenshots, Crash Logs, any other Relevant Information or Download links:
     

    Attached Files:

    #153
  14. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    Major BUG:

    IPlayer from IPlayfield only with the values from time of loading the playfield
    e.g. down the Toolbar and the Food

    upload_2021-6-13_12-8-47.png

    in the 1.4 the values are up to date
    upload_2021-6-13_12-14-53.png
    upload_2021-6-13_12-15-15.png
     
    #154
    Last edited: Jun 13, 2021
  15. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    Build: 1.5.0-3375
    Mode: MP&SP
    Mode: Dedicated & Coop & SP

    SERVER NAME: egal
    SEED-ID: egal

    MODIFIED PLAYFIELDS: egal

    Reproducibility: Always
    Severity: Major

    Type: Falsche Daten über den Spieler

    Summary: Kritischer Fehler in der API (war in der 1.4 noch ok)
    Die Schnittstelle IPlayer liefert das Inventar und die Statusdaten nur vom Ladezeitpunkt des Playfields nicht aber die aktuellen Daten :-(

    Dokubilder:
    https://empyriononline.com/threads/api-bugs.10252/page-8#post-437690

    Dokuvideo:
     
    #155
  16. ASTIC

    ASTIC Captain

    Joined:
    Dec 11, 2016
    Messages:
    819
    Likes Received:
    863
    I know what is broken. The capability to add a 'exportedEntityDat' doesn't work anymore :-(
    - with EPB works
    - without DAT works (but looses all custom names and logic)

    Unfortunately, this is the functionality needed to re-spawn a structure with correct device names and logic. And since the A12 creates this 'dat' file itself it is always present. (<A12 I triggered the creation of this file in cyclic in EWA).
    Using the function without this possibility is (actually) almost useless for the players.
     
    #156

Share This Page