Sign in to follow this  
Budda

CaveResourceFix - Fix your cave maps that have resource counts set to ~50 for non-vein tiles

Recommended Posts

With the latest update adding Sandstone a few of us have found that old maps generated have the sandstone spawning in with only ~50 hits. I had a look through the code and found that it expects all cave tiles to have a random resource count, with rock and rocksalt tiles ignoring this resource count and using their own counter for when to break the wall.

 

I've quickly thrown together this jar to fix this resource count on anything, but it isn't perfect. It will set any cave tile that has a resource count within a range to a random amount. This means it will also re-roll any vein tiles that have a count within the range, so keep that in mind before running it.

 

NOTE: BACKUP MAP FILES BEFORE RUNNING THIS, JUST IN CASE.

 

IF YOU HAVE AN ISSUE WITH MINE ENTRANCES OR MINE DOORS DISAPPEARING OR BECOMING BUGGED, RESTORE ALL FILES EXCEPT resources.map FROM YOUR BACKUP.

 

Full Info:

** CaveResourceFix to randomise the cave resource count on all cave tiles within a range.
** Will update all cave tile types that fall within the range, not just cave walls.

 

USAGE:
java -jar CaveResourceFix.jar [directory] [maxRand] [minRange] [maxRange]

 

[directory] : OPTIONAL - The path to the directory with the map files to be updated. Defaults to the current directory.
[maxRand] : OPTIONAL (directory must be specified if used) - The maximum resource count possible. Must be below 65535 - minRange. Defaults to 10000.
[minRange] : OPTIONAL (directory and maxRand must be specified if used) - The low point of the resource count range to check. Defaults to 40.
[maxRange] : OPTIONAL (directory, maxRand and minRange must be specified if used) - The high point of the resource count range to check. Defaults to 60.

 

EXAMPLES:
java -jar CaveResourceFix.jar
Will load map files from the current directory and set any cave tiles with a resource count between 40 and 60 to a random number between 40 and 10040.

 

java -jar CaveResourceFix.jar . 35000
Will load map files from the current directory and set any cave tiles with a resource count between 40 and 60 to a random number between 40 and 35040.

 

java -jar CaveResourceFix.jar ./world5 15000 20 80
Will load map files from the "world5" directory and set any cave tiles with a resource count between 20 and 80 to a random number between 20 and 15020.

 

Download Link:

https://drive.google.com/file/d/0BzAde1avZPjKM1g1LVVibHYyWWc/view?usp=sharing

  • Like 4

Share this post


Link to post
Share on other sites

Can we get the source code on GitHub? 

  • Like 1

Share this post


Link to post
Share on other sites

Single file and I don't plan on keeping it updated or making it more useful, full source below:

 

package net.buddat.wgenerator.caveresourcefix;

import java.io.IOException;
import java.util.Random;

import com.wurmonline.wurmapi.api.WurmAPI;

public class CaveResourceFix {

	public static void main(String[] args) {
		String directory = ".";
		short randSize = 10000;
		int minRange = 40;
		int maxRange = 60;
		if (args.length > 0)
			directory = args[0];
		if (args.length > 1)
			randSize = Short.parseShort(args[1]);
		if (args.length > 2)
			minRange = Integer.parseInt(args[2]);
		if (args.length > 3)
			maxRange = Integer.parseInt(args[3]);
		
		try {
			Random rand = new Random(System.currentTimeMillis());
			WurmAPI api = WurmAPI.open(directory);
			System.out.println("Map Size: W:" + api.getMapData().getWidth() + ", H:" + api.getMapData().getHeight());
			
			int count = 0;
			for (int i = 0; i < api.getMapData().getWidth(); i++)
				for (int j = 0; j < api.getMapData().getHeight(); j++) {
					if (api.getMapData().getCaveResourceCount(i, j) > minRange && api.getMapData().getCaveResourceCount(i, j) < maxRange) {
						api.getMapData().setCaveResourceCount(i, j, (short) (rand.nextInt(randSize) + minRange));
						count++;
					}
				}
			api.getMapData().saveChanges();
			
			System.out.println(count + " cave tiles successfully updated.");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

 

Share this post


Link to post
Share on other sites

It acted like it patched fine.  Didn't throw any errors.  I used the no arguments command line "java -jar CaveResourceFix.jar"

 

Upon bringing the server back up, all mine entrances were closed.  Attempts to tunnel in resulted in the "brittle" error message as the tile I was trying to mine into was an empty open space (not describing this well).  It's as if the closed mine entrance was a mine door, but it was not.  I only know the tile where the rock surface was empty due to the fact that when I logged my GM out, I was in the mine to begin with and it appeared to be a rock mine door visually.

 

I was able to open a mine back up by converting the rock to a mine door and then destroying the mine door, but that would be a painful and labor intensive solution to apply across the server.

 

I reverted to a backup and may temporarily hand out transmute rods till I can figure out how to fix this.

 

Thanks

 

Ike

 

 

Share this post


Link to post
Share on other sites

I just double checked mine entrances on the map I ran this on while testing, and they were all fine - no collapsed entrances or bugged out mine doors that I could find. Did you use the default values for the range, or lower the minRange to ~0?

 

As always for everyone else, I suggest backing up files before you make any changes to them with any programs - including this one.

Share this post


Link to post
Share on other sites

I just ran it with no parameters at all.

 

Weird.

 

It was apparently every mine entrance too.

 

 

Share this post


Link to post
Share on other sites

Just had the same thing happen to me when updating my live map. Restored from backup then ran it again and only copied over the new resources.map file and that has fixed it.

Share this post


Link to post
Share on other sites
2 hours ago, Sklo:D said:

Yup you are right, this method will close all holes, mine doors etc and turn them into rock.

This is why I am always requesting source code for such scripts.

 

The method is in WurmAPI, which we do have the source to...

Share this post


Link to post
Share on other sites

Used the method you described this evening.  Got it all sorted out.

 

Thank you for the assistance, is much appreciated.

Share this post


Link to post
Share on other sites

Hiya.

 

Just wondering if there will be a proper fix implemented at some point or is this .jar "the" fix and we wont be getting a proper dowloadable hotfix ?

 

thanks.

 

Valiance and Kaylie.

 

Share this post


Link to post
Share on other sites

I had the same issue with all the mine entrances covered with Rock but unable to re-tunnel.  I restored the map files and copied over the new resource file as someone else above suggested.  This fixed the entrances but I seem to have holes in my mine.

Not sure how to fix these as I can't target the tile to use repair tool on it.

 

Appears these holes are in fact sandstone tiles.  But my client is rendering them as holes in the world.

Edited by Jayren

Share this post


Link to post
Share on other sites

Are you sure you are on the new client version? If you are on 1.3.1.3 they will look as holes.

Share this post


Link to post
Share on other sites
On 12.5.2017 at 2:54 PM, bdew said:

 

The method is in WurmAPI, which we do have the source to...

 

But we would not know that it uses the Wurm Api without the source code of the tool itself.

Share this post


Link to post
Share on other sites

Problems here too.

All mine entries are replaced by "cave" (not the tile below, just the layer). It cannot be tunneled through.

There are some tiles in the mines that are super-deep mined out tiles, I'm guessing these are messed up standstone etc.

Share this post


Link to post
Share on other sites

BUMP still broken, guess I have to fix that myself once again. #thatgreatsupport

Share this post


Link to post
Share on other sites

Why is the sandstone veins still broken?  #thatgreatsupport

Share this post


Link to post
Share on other sites

Use the workaround posted above, make a copy of your map files, run the tool on that copy, then copy only the cave layer resources map back to your game folder.

Edited by bdew

Share this post


Link to post
Share on other sites

While I want to fix Sandstone this also means that Salt, Glim and Ada will also get bumped from 50ish to potentially 10,000. While that doesn't bother me in regards to Salt not sure I'm excited about that for Glim and Ada. Not really excited about having to have people open tickets every time they discover Sandstone so we can manually change it either so I'm seriously torn about how to proceed.

 

EDIT: Also will this effect rock tiles as well?

Edited by LifesaverM
Adt'l Info

Share this post


Link to post
Share on other sites

I have also found that glimmer/addy veins now have the ability to spawn with more than 50 actions(up to the max you set or the default 10k). I have a vein in my mine with over 8k actions. Any fix for this?

On 5/22/2017 at 10:36 AM, LifesaverM said:

EDIT: Also will this effect rock tiles as well?

 

 It does not effect rock tiles

Edited by Governor

Share this post


Link to post
Share on other sites
On 19.5.2017 at 4:04 PM, bdew said:

Use the workaround posted above, make a copy of your map files, run the tool on that copy, then copy only the cave layer map back to your game folder.

 

cave layer map will not help you the tool doesn't change anything in it.

Share this post


Link to post
Share on other sites
6 minutes ago, Sklo:D said:

 

cave layer map will not help you the tool doesn't change anything in it.

 

Sorry brain fart!

 

I meant resource layer. resources.map

 

 

  • Like 1

Share this post


Link to post
Share on other sites
4 minutes ago, bdew said:

 

Sorry brain fart!

 

I meant resource layer. resources.map

 

 

 

Yup correct.

 

But anyways, I am sick of things in this game which don't get fixed for weeks. Just because WU is not a "priority". Two options, if they sell this game they have to provide support, if they are not able to test a 35 line script properly they shouldn't sell this game because obviously they can't provide good support.

Edited by Sklo:D

Share this post


Link to post
Share on other sites

Well to be fair the problem doesn't exist (AFAIK) on the maps that came with WU.

 

It's only in maps made by (some) custom map generators that put some weird values in resource layer instead of -1. I don't think it's reasonable for us to demand support from CC for player-made content.

  • 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