Sign in to follow this  

BUG in com.wurmonline.server.items.Materials

Recommended Posts

Not critical, but maybe easy to fix bug, that make logging of server activity a bit..hard :

i put level of logging to FINE and 


 FINE com.wurmonline.server.items.Materials: Returning Birch for unexpected material type:

server.log  filled with this


id , 0, 11, 15 ,17 ,19 , 22,27, 53

and in com.wurmonline.server.items.Materials


   public static TreeData.TreeType getTreeTypeForWood(final byte wood) {
        switch (wood) {
            case 14: {
                return TreeData.TreeType.BIRCH;
            case 37: {
                return TreeData.TreeType.PINE;
            case 38: {
                return TreeData.TreeType.OAK;
            case 39: {
                return TreeData.TreeType.CEDAR;
            case 40: {
                return TreeData.TreeType.WILLOW;
            case 41: {
                return TreeData.TreeType.MAPLE;
            case 42: {
                return TreeData.TreeType.APPLE;
            case 43: {
                return TreeData.TreeType.LEMON;
            case 44: {
                return TreeData.TreeType.OLIVE;
            case 45: {
                return TreeData.TreeType.CHERRY;
            case 63: {
                return TreeData.TreeType.CHESTNUT;
            case 64: {
                return TreeData.TreeType.WALNUT;
            case 65: {
                return TreeData.TreeType.FIR;
            case 66: {
                return TreeData.TreeType.LINDEN;
            default: {
                if (Materials.logger.isLoggable(Level.FINER)) {
                    Materials.logger.fine("Returning Birch for unexpected material type: " + wood);
                return null;

as you see different types identifiers expected so problem in this method or in definition of items.

upd : it not connected to gm actions as i even not logged in . It not connected to character creation. it happen every  other moment

UPD2 : this method have only 3 uses :
chop from  com.wurmonline.server.behaviours.MethodsItems
plantSprout from  com.wurmonline.server.behaviours.Terraforming
getSizeMod from  com.wurmonline.server.items.Item
for what and when getSizeMod used i dont know.

Edited by masaykh

Share this post

Link to post
Share on other sites

Can you track exactly when this is happening? Is this something a player is doing?


I ask because if this is triggering when you create an item as a GM, and don't select a material, instead select default material, it would seem like it is functioning as intended.


Also another possibility is it could be triggering on character creation, you know those odd tools made out of birchwood instead of Iron, so you can't imp them. I would say this was somewhat intended as well.


I am just brainstorming with you here, not confirming or denying anything.

Edited by Xyp

Share this post

Link to post
Share on other sites

I think getSizeMod() is used to send item graphic scaling information to the client. For example, a combined bunch of wood scrap's graphic is bigger then a single wood scrap.
It might also be something that grows item measurements (x,y,z) for combined things but I don't thinks so as the second part is solely about scaling up non-fruit trees.

I believe getSizeMod is getting called for every item that is on the ground.

now from 
"id , 0, 11, 15 ,17 ,19 , 22,27, 53"

The material (byte) value for a item template looks up a value in getTemplateIdForMaterial() for Materials.class. The value is another itemTemplate which could be called the most basic construction material...logs, iron lumps, rock shards, string of cloth....
11 is 46 or iron lumps
15 is 146 or rock shards
17 is 214 or string of cloth
19 is 130 or clay
22 is -10 or WU's way of having a null-like value for Java's primitive data types.
27 is 204 or charcoal
53 is 318 or wemp fibre

As a test trying making a pile of tar on the ground and see if 58 gets added to that list. Note that material 58 isn't in getTemplateIdForMaterial() but it is assign to tar. You could try peat also which is similar to tar but has type 59.

Given the material identifiers are all the basics used by most WU items this all makes sense to me so far.

What are some solution?
1. Try to use Javassists ExprEditor and "public void edit(Handler h) throws CannotCompileException". It might be possible to remove that logging message. I don't see how its important. You could also use Javassist and setbody() to overwrite getTreeTypeForWood() and remove that logging message.

2. Figure out a way to change getSizeMod so that in the second half of the method, calls to Materials.getTreeTypeForWood() are only called if its item instance object is something that is compatible with that static getter. I'm not sure how you'll do this as something here confuses me. There is no "tree" item. The item list does have felled tree, stump, christmas tree. But those aren't trees. I don't get how an item instance was created for a "tree" object if there is no template. It could simply be that I'm wrong about this method scaling up tree models.


That's it for now, hope it help.

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