Tool SMAPI: Stardew Modding API

Discussion in 'Mods' started by ClxS, Mar 6, 2016.

Thread Status:
Not open for further replies.
  1. forevergent777

    forevergent777 Aquatic Astronaut

    I ended up going back to v.2.0.1 for Animal Husbandry and it works now.
     
    • Title008

      Title008 Big Damn Hero

      My game crashed on the first day. Can you help me?
       

        Attached Files:

      • Pathoschild

        Pathoschild Tiy's Beard

      • Rantar

        Rantar Void-Bound Voyager

        Loaded up and played winter 1-4 just fine then when i went to bed on winter 4 i crashed with this error
         

          Attached Files:

        • Pathoschild

          Pathoschild Tiy's Beard

          @Rantar That looks like a bug with Mail Framework. Does it happen if you remove that mod? If not, I suggest reporting it to that mod's author.
           
          • Digus

            Digus Spaceman Spiff

            I think it's coincidence that the error happen after the MailFrameworkMod loads its assets. Here is what it does:
            Code:
            public bool CanEdit<T>(IAssetInfo asset)
                    {
                        return asset.AssetNameEquals("Data\\mail");
                    }
            
                    public void Edit<T>(IAssetData asset)
                    {
                        var data = asset.AsDictionary<string, string>().Data;
                        data["MailFrameworkPlaceholderId"] = " @, ^your farm has been infected with an unexpected bug. ^Don't panic! ^The bug and this message will auto destroy after read. ^   -Digus";
                    }
            @Rantar do that, try to remove the Animal Husbandry Mod and MailFrameworkMod and sees if the problem still happen.
            It might me some conflict with my mod, but I can't see how MailFrameworkMod would affect "Game1.Update", as it changes nothing in the part of the code.
             
            • Pathoschild

              Pathoschild Tiy's Beard

              @Digus There are a few players with save crashes where removing or downgrading Animal Husbandry and Mail Framework fixed it (see this thread, this earlier comment, and another thread). I was able to reproduce it with one of their saves, so I'll run it through a local build of the game and see where it's failing.
               
              • Pathoschild

                Pathoschild Tiy's Beard

                @Digus When Animal Husbandry adds new gift tastes, it leaves an extra space in the data:
                upload_2018-3-9_22-59-1.png

                That causes a crash when the game parses the data, since it splits by space and tries to parse a blank string as an item ID. Here's a save which reproduces the issue; just go straight to bed to trigger the crash.
                 

                  Attached Files:

                • Digus

                  Digus Spaceman Spiff

                  Thanks for tracing it. I only looked the recent posts and the log really fast(was not free at the time, just checking some emails) and knew it could not have been the mail framework mod, but didn't have time to look into it further.
                  That problem now make sense, I recently changed the method that added the likes and dislikes to avoid compatibility issues. It's probably doing something wrong now.
                   
                  • Digus

                    Digus Spaceman Spiff

                    Well, I don't know why this is happening only with a few people when saving, but I was able to solve it.
                    This was my first code:
                    Code:
                    string valuesToAdd = values
                        .Where(v => !data[key].Contains(v))
                        .Aggregate((workingSentence,next)=> workingSentence + " " + next);
                    if (valuesToAdd.Length > 0)
                    {
                        data[key] += " " + valuesToAdd;
                    }
                    It was causing problems when other mods edited the tastes as well, the 'workingSentense' could be null causing error. So I changed to this:

                    Code:
                    string valuesToAdd = values
                        .Where(v => !data[key].Contains(v))
                        .Aggregate(string.Empty, (workingSentence,next)=> workingSentence + " " + next);
                    if (valuesToAdd.Length > 0)
                    {
                        data[key] += " " + valuesToAdd;
                    }
                    Now the first occurrence would always be joined with an empty string, leaving an extra space when adding to the original data. So I just had to remove the space when adding to the original data, since now it's not needed.

                    Edit: I'm also doing a trim to avoid problem when the original data is empty. It never is in the places I'm adding now, but it could be if I change it in a future version or some other mod mess with it.
                     
                      Last edited: Mar 10, 2018
                    • Rantar

                      Rantar Void-Bound Voyager

                      Everything seem to be working again thanks for the fast fix.
                       
                        Digus likes this.
                      • Pathoschild

                        Pathoschild Tiy's Beard

                        @Digus Here's a way of doing it without Aggregate if you want:
                        Code:
                        int[] newValues = data[key].Split(' ').Select(int.Parse).Union(values).ToArray();
                        data[key] = string.Join(" ", newValues);
                        
                         
                        • Digus

                          Digus Spaceman Spiff

                          Never thought of doing that to work with the items ids.
                          And the weird part is that I'm doing almostthat with the other part of the string, look:
                          Code:
                          string[] tastes = data[npc].Split('/');
                          string currentValues = tastes[(int)taste];
                          string valuesToAdd = values.Where(v => !currentValues.Contains(v)).Aggregate(string.Empty, (workingSentence, next) => workingSentence + " " + next);
                          if (valuesToAdd.Length > 0)
                          {
                              currentValues += valuesToAdd;
                              tastes[(int)taste] = currentValues.Trim();
                              data[npc] = String.Join("/",tastes);
                          }
                          But is there a reason to not use aggregate now that it is working?
                           
                          • Pathoschild

                            Pathoschild Tiy's Beard

                            There's no technical reason to avoid Aggregate, I just find it less readable in most cases. Feel free to use it if you like it. :)
                             
                            • Digus

                              Digus Spaceman Spiff

                              I agree it is. I might change it, I was just checking if there were other reasons.
                              I found my solution at stack overflow. I work as a java developer, so I'm always looking for how to do stuff in C#, especially stream stuff I don't know about. It is much more powerful in C#.
                              Thank you again for the help!
                               
                              • Pathoschild

                                Pathoschild Tiy's Beard

                                SMAPI 2.5.3 beta.3 is now available! (See download and release notes.)

                                Beta 3 fixes an "invalid magic number" error for some Linux players, and includes lots of internal changes to support the upcoming Stardew Valley 1.3 beta.

                                [Edit: download removed; see latest version instead.]
                                 
                                  Last edited: Mar 14, 2018
                                • Pathoschild

                                  Pathoschild Tiy's Beard

                                  SMAPI 2.5.3 is now available!

                                  This has a lot of the internal changes to support the upcoming Stardew Valley 1.3 beta, improved compatibility and update checks, and several fixes. This shouldn't impact any mods; let me know if you notice any issues.
                                   
                                  • corbomite

                                    corbomite Void-Bound Voyager

                                    I just updated to 2.5.3 and now I'm getting this error and most of the stuff I added through Json assets now show up as error items now.

                                    https://log.smapi.io/xm2VR4QM

                                    Edit: it appears that most of the error items are from Mizu's Flowers
                                     
                                      Last edited: Mar 14, 2018
                                    • Pathoschild

                                      Pathoschild Tiy's Beard

                                    • FloraFern

                                      FloraFern Scruffy Nerf-Herder

                                      The most recent download of SMAPI just gave me a Trojan/Virus. I have an old version installed that did not include any malware so I highly doubt that it was a false alert.
                                       
                                      Thread Status:
                                      Not open for further replies.

                                      Share This Page