lishid Posted February 21, 2015 Share Posted February 21, 2015 Bug Submission: Category: General Issue Title: Mod-Recipe priority/sortkey issue Issue Description: Since recipes are ordered by "sortkey", and mods register new Recipes based on the order of their priority, mod recipes stops working if two mods have the same priority (for example, if both mods don't set their priority, assumed to be 0) with a factor of chance. Depending on the sort order of the mods, if both the server and client sort it the same way, then recipes work as expected. However, if the client has other (client-only) mods with the same priority, then the sorting algorithm could potentially scramble the same-priority mods, resulting in inconsistent server-client recipe sortkeys. A simple fix would be sorting mods by priority, then by name. This would ensure Recipe introducing mods to have absolute sort order and thus sortkey. Steps to Reproduce: Server: install 2 mods that introduces new Recipes. Client: install 1 client-only mod. Ensure all 3 mods has the same priority (e.g. 0). Login and try to craft a mod-introduced recipe. Link to comment Share on other sites More sharing options...
lishid Posted February 21, 2015 Author Share Posted February 21, 2015 A temporary workaround for mod creators is to give a unique priority to their mod. This ensures the mod to have an absolute sortkey for their Recipes, which would be the same for both server and clients. Link to comment Share on other sites More sharing options...
afetogbo Posted February 21, 2015 Share Posted February 21, 2015 How does one give a unique priority to a mod? I am trying to set up a dedicated server and would like to do this for the many mods I have to add structures to my server. Link to comment Share on other sites More sharing options...
Maris Posted February 21, 2015 Share Posted February 21, 2015 In modinfo.lua add string:priority = 0.00381745920Where "381745920" is your mod id in steam. This is solution only for mod creators. Link to comment Share on other sites More sharing options...
lishid Posted February 21, 2015 Author Share Posted February 21, 2015 Yeah, as a server owner, there's no way but to make a copy of the mod and upload it to steam (prepared to get criticized for copying other's work!). Hopefully this gets fixed early enough. I'd like to add that if a bad mod decides to load recipes inconsistently (for example, one on server side, two on client side), then all mods loaded after this one will be subject to the Recipe sortkey issue. The solution I have in mind against this is to use prefab name instead of sortkey as RPC message. The recipes are already prefab-unique anyway. Link to comment Share on other sites More sharing options...
Developer PeterA Posted February 23, 2015 Developer Share Posted February 23, 2015 Thanks for reporting the issue. Getting this fixed is high on my priority list. Link to comment Share on other sites More sharing options...
Developer PeterA Posted March 19, 2015 Developer Share Posted March 19, 2015 Hey @lishid,@afetogbo, and @Maris, I've added a new modapi function that mods will be able to use to add recipes. Mod recipes now should go through AddRecipe called from modmain. As a consequence of this change recipe's sort_key can be modified now without affecting RPC calls. This change is currently live in the RoG test branch, but will go live for everyone once RoG goes live fully. Let me know if you have any questions, and thanks for your input! Link to comment Share on other sites More sharing options...
afetogbo Posted March 19, 2015 Share Posted March 19, 2015 sweet. can you give us an example of a recipe with this new code? p.s. the death of afetopia recipes is at hand. ^cause i am a code noob Link to comment Share on other sites More sharing options...
Developer PeterA Posted March 19, 2015 Developer Share Posted March 19, 2015 @afetogbo, yeah, here's how it will function once it's live. This is what I've updated my soulmates mod to have in modmain.AddRecipe("bindingring", {GLOBAL.Ingredient("goldnugget", 10), GLOBAL.Ingredient("moonrocknugget", 1)}, GLOBAL.RECIPETABS.MAGIC, GLOBAL.TECH.NONE)GLOBAL.AllRecipes["bindingring"].atlas = GLOBAL.resolvefilepath("images/inventoryimages/bindingring.xml") Just to be clear, this isn't available yet in the default branch, and will be coming with the RoG changes. Link to comment Share on other sites More sharing options...
rezecib Posted March 19, 2015 Share Posted March 19, 2015 @PeterA, because atlas and imagename are very likely custom for mod-added recipes, maybe AddRecipe could have those as arguments at the end? Link to comment Share on other sites More sharing options...
Developer PeterA Posted March 20, 2015 Developer Share Posted March 20, 2015 @rezecib, sounds reasonable to me. I'll include a spot for the atlas (which we'll resolve for you), and the texture name. Link to comment Share on other sites More sharing options...
Developer PeterA Posted March 20, 2015 Developer Share Posted March 20, 2015 Quick update, this is what adding a new recipe will look like from your modmain now. You don't need to specify "bindingring.tex" though, that's optional, since we assume the image will be name .. ".tex"AddRecipe("bindingring", {GLOBAL.Ingredient("goldnugget", 10), GLOBAL.Ingredient("moonrocknugget", 1)}, GLOBAL.RECIPETABS.MAGIC, GLOBAL.TECH.NONE, nil, nil, nil, nil, nil, "images/inventoryimages/bindingring.xml", "bindingring.tex" ) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.