[General] - Mod-Recipe priority/sortkey issue


lishid

Recommended Posts

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

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

  • Developer

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

  • Developer

@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

  • Developer

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

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.