Daily Web Map Download and XOR Compare

Guides on how to mod, model, program, or other content of value for learning Wurm modding. But also any guides that can help in game.
Post Reply
axeblade346
Trollslayer
Trollslayer
Posts: 17
Joined: Mon Aug 31, 2020 7:42 am

Daily Web Map Download and XOR Compare

Post by axeblade346 »

This guide is more to show another servers players & owner how it’s done but other might find it useful.

Guide goal
To download a daily backup of the web maps images and use Xor compare to check what changed. Use full to check tree spreading/dying and changes to a deed over time.


WTF is Xor Compare??
Xor takes 2 layers / images and shows your just the color changes between the 2 images.
Let say one pixel on layer 1 is 255 , 255 , 140 and the other layer is 140 , 155 , 145 the result Xor color will be 115 ,100 , 5
overlaying a semi-transparent version of this over the map gives you a very good idea of what changed and where.


End goal example
Image


What you need
A PC with Windows (Working on a Linux version but it ain’t there yet)
Note your “ADMIN” username and login password. If you don`t have a login password GO SET ONE as its safer and needed for a step. (“ADMIN” user can install stuff, limited users need the admin username and password to do so)

A Webrowser (I use chome but its just to get a link)

A web map that saves to a single image (Kenabil’s one works for this, Old Wyvern does NOT)
https://github.com/awakening-wurm/MapViewer/releases

A text editor (notepad or notepad++)
https://notepad-plus-plus.org/downloads/

A scheduler to automate the downloads (I use a backup program for this)
https://www.cobiansoft.com/cobianbackup.html - Get the Reflector version as its newer

An image editor with Layers and xor Compare.
https://www.getpaint.net/download.html - get the free version


How to get the maplink
Open the web map and check the bottom left (Kenabil’s)
Image
Note where the link takes you
Should be something like https://kangawu.com.au/map_kw/map-terrain.png
We can get the Isometric (3D) & Topographic map from this link
…/map-terrain.png
…/map-isometric.png
…/map-topographic.png

Get this link for each server map you want to download and note it down.

Make the downloader
For this I will use {change this} for stuff you need to fill in, fell free to discord PM me (Axeblade#0875 / Axeblade on modding discord) if you need help with this as its OLD Dos style coding and I had to ask my dad for help at the start. There is a full example at the bottom

1st create a folder you want the maps to download to and note down the FULL link to that folder
The way I made it each date saves in its own subfolder.
Make a text file in that folder and in the file add the following.

Code: Select all

@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "folderstamp=%DD% %MM% %YYYY%"
set "datestamp=%DD%%MM%%YYYY%"
@echo on
This will use the PCs date to create the folders.
Now add the following

Code: Select all

md “{full link using \ not / }\%folderstamp%”
cd “{full link using \ not / }\%folderstamp%”
This will make a folder using the date
And then add the following

Code: Select all

curl “{map link 1 for terrain}” --output %datestamp%{mapname}FLAT.png --ssl-no-revoke
curl “{map link 1 for topographic}” --output %datestamp%{mapname}TOPO.png --ssl-no-revoke
curl “[map link 1 for isometric}” --output %datestamp%{mapname}ISO.png --ssl-no-revoke
And repeat this for each server’s map.
This will copy the url (curl) and rename the files with a datestamp infront it.
so the result will be a folder/date/<date>map.png
the --ssl-no-revoke is not always needed but it doesn`t hurt to add it even when not needed
And then to make it look need add.

Code: Select all

cd..
pause
Resave the file to something like Mapdownloader.bat (make 100% sure to add the .bat and delete the .txt)
Run the file and check what it downloads. Its normal for it to pop up a very old looking dos style window.
If it works edit the bat and remove the pause as the last line (that was just to make sure you read the errors if it gives any)


Full example
Spoiler

Code: Select all

@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "folderstamp=%DD% %MM% %YYYY%"
set "datestamp=%DD%%MM%%YYYY%"
@echo on

md "C:\Users\Axeblade346\Pictures\WURM\Wurm Maps\%folderstamp%"
cd "C:\Users\Axeblade346\Pictures\WURM\Wurm Maps\%folderstamp%"

curl https://kangawu.com.au/map_kw/map-terrain.png --output %datestamp%KWFLAT.png --ssl-no-revoke
curl https://kangawu.com.au/map_kw/map-topographic.png --output %datestamp%KWTOPO.png --ssl-no-revoke
curl https://kangawu.com.au/map_kw/map-isometric.png --output %datestamp%KWISO.png --ssl-no-revoke
curl https://kangawu.com.au/map_tw/map-terrain.png --output %datestamp%TWFLAT.png --ssl-no-revoke
curl https://kangawu.com.au/map_tw/map-topographic.png --output %datestamp%TWTOPO.png --ssl-no-revoke
curl https://kangawu.com.au/map_tw/map-isometric.png --output %datestamp%TWISO.png --ssl-no-revoke

cd..

Setup a schedule
Install Cobain reflector.
It will ask you for your username and password. This is so it can access some folders to download to /backup that it can`t normally.
Open the Gui (Icon looks like a DVD next to pc date and time)

In its menu click on tools , Service and application Control.
Click yes if Windows UAC asks and then click on the Services Tab
Click on install or logon (which ever one is not greyed out)v in the control the main service part.
Change the option to Regular account and type in your "ADMIN" username and password.
And yes to start the service.
The click on the AutoStart tab and make sure the user interface is set to auto start for all users.
Close the Service and application Control.

In Cobain click the big + (5th icon)
Give the task a name and select Dummy tasks.
In schedule choose daily and a time. (Make sure your PC and internet is on at this time)
Then in Events , in the pre-backup events click Add -> execute.
In the explorer change the file type to all and go find the .bat file we made.
If done correctly it should list the folder and file in the pre-backup events.
Click Ok
Click the >> (1st button) to run all tasks to test it.
It should open the exact same “dos” window as the downloader step)
… Cobain can also be used to make a backup to an eternal hard drive / nas / google drive folder ext.

And with this you will get a daily backup of the maps.

XOR compare time.
Install paint,net if you haven’t.
Open a map file image in paint.net and then drop and drag another date version of it over to paint.net
Choose ADD LAYER not open.
In the Layers options (F7 to open it if it doesn’t show) Click on the topmost layer to mark it
Click the wrench icon and set the blend mode to Xor and play around with the opacity till you can see the other layer thru the Xor layer (~140 to 180 for me).

Click ok
Then click the merge layer icon.
Then click file > SAVE AS… and give it a name. (Ctrl+SHIFT+S)

And that’s it. Open the new image in what ever image viewer you prefer.
Note that tree killing trees like Oaks sometimes have a bright green dot and dark green dots around it when it kills trees.
Over time you will learn what each color means in the Xor part


I crop in with piant.net and upload it with sharex to imgur for sharing it on the web.

Post Reply