Sign in to follow this  
joedobo

Disabled mods and leftover items in the wurmitems.db

Recommended Posts

Recently I've been trying to add ways to make it so mods can be disabled without any lasting negative effects. One problem is a crash; I've run into it when you add a new item to the game and

then add it to a bulk bin.  Once the mod is disabled the client will crash when a player opens the bin containing the new item.

Normally when an item doesn't have an ItemTemplate entry the server just doesn't render it. I'm not exactly sure what happens but the client doesn't crash. I'm also thinking that it

would be a good idea to deal with this predictably. That's better than hoping Wurm continues to do it in a non-crashing way.

 

One idea I have is to use the types in modsupport.db and add default dummy types to Wurm if one or more of those types aren't listed in Wurm after the ItemTemplatesCreatedListener finishes.

 

Any thoughts? Thank you.

 

 

Error log that only prints up if the toon happens to have a itemTemplate-missing item in inventory when a bulk bin is opened. If the item are just in the bulk bin the client just crashes.

Quote

[06:44:49 PM] INFO com.wurmonline.server.LoginHandler: /127.0.0.1,Tedd successfully logged on, id: 402690730752.
[06:44:49 PM] WARNING com.wurmonline.server.Items: Problem getting Template for item with Wurm ID 47482679388930  for creature 402690730752 - No item template with id 22759
com.wurmonline.server.items.NoSuchTemplateException: No item template with id 22759
    at com.wurmonline.server.items.ItemTemplateFactory.getTemplate(ItemTemplateFactory.java:81)
    at com.wurmonline.server.Items.loadAllItemsForCreatureAndItemtype(Items.java:2082)
    at com.wurmonline.server.Items.loadAllItemsForCreature(Items.java:1839)
    at com.wurmonline.server.LoginHandler.handleLogin(LoginHandler.java:1684)
    at com.wurmonline.server.LoginHandler.login(LoginHandler.java:439)
    at com.wurmonline.server.LoginHandler.reallyHandle(LoginHandler.java:306)
    at com.wurmonline.communication.SocketConnection.tick(SocketConnection.java:615)
    at com.wurmonline.communication.SocketServer.tick(SocketServer.java:172)
    at com.wurmonline.server.Server.run(Server.java:2422)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)

 

Database copy for modsupport.db

Quote

"1"    "22767"    "ITEMTEMPLATE"    "jase2z.Aspic"
"2"    "22766"    "ITEMTEMPLATE"    "jdbTowel"
"3"    "22765"    "ITEMTEMPLATE"    "jdbCottonBed"
"4"    "22764"    "ITEMTEMPLATE"    "jdbMadder"
"5"    "22763"    "ITEMTEMPLATE"    "jdbCheeseDrill"
"6"    "22762"    "ITEMTEMPLATE"    "jdbCottonToolBelt"
"7"    "22761"    "ITEMTEMPLATE"    "jdbWaxGourd"
"8"    "22760"    "ITEMTEMPLATE"    "jdbNettleTea"
"9"    "22759"    "ITEMTEMPLATE"    "jdbGourdCanteen"

 

Here's the error part of the code. I removed some of the code. It's in com.wurmonline.server.Items.

public static void loadAllItemsForCreatureAndItemtype(final long creatureId, final DbStrings dbstrings, final Set<Item> creatureItems) {
	Connection dbcon = null;
	PreparedStatement ps = null;
	ResultSet rs = null;
	try {
		dbcon = DbConnector.getItemDbCon();
		ps = dbcon.prepareStatement(dbstrings.getCreatureItems());
		ps.setLong(1, creatureId);
		rs = ps.executeQuery();
		long iid = -10L;
		while (rs.next()) {
			iid = rs.getLong("WURMID");
			try {
				final ItemTemplate temp = ItemTemplateFactory.getInstance().getTemplate(rs.getInt("TEMPLATEID"));
				....
			}
			catch (NoSuchTemplateException nst) {
				Items.logger.log(Level.WARNING, "Problem getting Template for item with Wurm ID " + iid + "  for creature " + creatureId + " - " + nst.getMessage(), (Throwable)nst);
			}
		}
	}
	catch (SQLException sqx) {
		Items.logger.log(Level.WARNING, "Failed to load items for creature " + creatureId + ": " + sqx.getMessage(), sqx);
		return;
	}
}

 

Share this post


Link to post
Share on other sites

When you remove a mod that adds things, you normally have to remove the 'things' manually. As I can see it, if you disable the mod, what is going to tell the server to remove the items from the database? There's no code to do that(?).

Could probably have a second mod that is run once to remove them(?), OR if it was me include with the mod a remove.bat that would be dropped into the SQLite folder of the map and ran once to sends a query to the database to flush out all the no longer wanted items?

Share this post


Link to post
Share on other sites

Modloader.db has the types in a database assuming you use the ItemTemplateFactory tools. yes, it should be possible to use these a construct a search query of WU's item database and remove entries.

 

I was actually thinking about a more temporary solution. When I mod I often want to disable a mod temporarily for testing. Also when client updates a server owner might want to disable a mod while waiting for the mod to get updated. If that mod causes server crashing bugs that is hard to do.

 

I made a little test program to see if the idea might work: test program. It caused an issue with item volumes. I'd need to fetch an existent item from WU's database and use it to reverse calculate specifics. The issue is if you make an item's default metrics bigger or small it causes a item count change for any of those items in bulk containers.

Share this post


Link to post
Share on other sites

Adding a dummy template seems like a nice idea.

But this would probably leave "?" bags all over the place. Hiding the items from the bulk storage containers would create "holes" in them the player could fill and push the container over its limit once the mod is reenabled. Similar for a dummy item that's larger than the actual item.

Maybe a dummy item with a moderate volume but a huge weight could work in a way. People can't take it out since it'd be to heavy to move. On the other hand it would not be possible to empty the bin anymore.

Share this post


Link to post
Share on other sites

I might have caused some confusing calling it a dummy type.

 

It would be a generalized item template that would be applied to whatever template id is missing...

ItemTemplateFactory.getInstance().createItemTemplate(xxMissingIDxx, 3, "Missing item", "Missing item", "excellent", "good", "ok", "poor",
	"No item template matches this item", new short[]{}, (short) 340, (short) 1,
	0, Long.MAX_VALUE, 1, 1, 1, -10, MiscConstants.EMPTY_BYTE_PRIMITIVE_ARRAY,
	"model.writ.deed.", 200.0f, 1, (byte) 0, 0, false, -1);

 

I suspect it will cause problems if the x,y,z and weight don't match. Volume isn't in the database. That metric is calculated using the product of x,y,z and placed in a java instanced field for the item type.

 

I prefer to show the items even if they are question mark bags. That way players can garbaged them in-game.

 

@ago, if someone is using the ItemTemplateFactory tools they have to supply x,y,z and weight in order to build. It seems like it would be easier to look values up in the modloader database instead of trying to fetch things from WU item database and then reverse calculate the values.

 

I leading towards a mod that does

1. nothing, well it's disabled.

2. replaces all missing item templates with dummies. x,y,z and weight would need to match up for it to work smoothly.

3. an automated tool to remove all occurrence of the item type from the database. It would be a quick delete. Here we would select from columns TEMPLATEID and REALTEMPLATE where the value equals the missing templateID. Finally, delete them. We need real Template column because that is how to identify a bulk item.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this