Forums
May 12, 2021, 06:44 PM

Author Topic: wkTerrainSync v1.1.0a - wkTerrain with automatic data synchronization and extras  (Read 1502 times)

0 Members and 1 Guest are viewing this topic.

wkTerrainSync is an improved version of wkTerrain38 that fixes limitations of the original module. It implements custom network protocol to automatically synchronize terrain data, download missing terrain files from host player and more. With this module players are able to use custom terrains online without limitations and desynchs. On top of that, wkTerrainSync adds extra visual customization features to terrain files to overhaul how the game looks.

Data synchronization features:
   - Custom network protocol integrated with WA's original network code - this module works seamlessly with WormNAT2 and direct hosting
   - Terrains are now referenced by their MD5 hash instead of ID - play online games regardless of your terrain list order and terrain directory names
   - File transfers - missing terrain files are automatically downloaded from the host player
   - Terrain metadata is embedded directly in .wagame replay files - replay files will work even when terrain list changes or files are renamed

Terrain customization features:
   - Terrain files can include additional parallax sprites - back2.spr displayed in far distance behind regular back.spr ; front.spr displayed in front of the map
   - Removed sprite loader limitations when handling back.spr, back2.spr and front.spr - sprites are no longer limited to 640x160px size and can be animated like regular sprites
   - Since v1.0.2: To use extended sprite loader with back.spr rename the file as _back.spr . If _back.spr is not present, the game will load back.spr with the default sprite loader
   - Terrains can override any sprite in the game, including worm animations, weapon projectiles and clouds - place gfx0/spritename.spr (normal palette) and gfx1/spritename.spr (colorblind palette) within terrain.dir to override any sprite
   - Terrains can override water.dir for custom water color and animations - place water.dir next to level.dir in terrain directory. Use https://worms2d.info/Water_color_editor to generate custom water.dir

Installation:
   1) Remove your existing wkTerrain38.dll
   2) Place wkTerrainSync.dll and wkTerrainSync.ini in your WA directory
   3) If you are using CD edition of the game, install wkFileOverride http://worms.thecybershadow.net/wormkit/wkFileOverride.zip

Usage:
   - wkTerrainSync does not require any special configuration or user interaction.
   - If you are joining an online game that uses a new terrain file that you currently don't have installed, you will see an "Invalid map file" in map thumbnail and multiple messages about terrain data download will appear in lobby chat. This means the terrain file is being downloaded from the host and a proper map thumbnail will appear once the terrain is downloaded. This should take few seconds depending on network speed.
   - When generating a random map by clicking on map thumbnail, the game selects a random terrain from all available terrains.
      To limit this selection to only custom terrains, hold CTRL key and click on the thumbnail.
      To limit this selection to only default terrains, hold ALT key and click on the thumbnail.
   - Online play with a mix of wkTerrain38 and wkTerrainSync players is not supported. In such case both wkTerrain38 and wkTerrainSync will refuse to load custom terrain maps and wkTerrainSync will print warning messages in lobby chat
   - Downloaded terrain directories are stored as "Name #MD5checksum" to avoid file conflicts
   - Incomplete file transfers are stored with .part suffix to prevent adding incomplete downloads to the terrain list
   - To troubleshoot the module, enable dev console in .ini file and examine the logged messages
   - To print the version of the module and a list of available terrains, use /terrains command in lobby

Source code is available at: https://github.com/nizikawa-worms/wkTerrainSync
« Last Edit: May 02, 2021, 12:37 PM by nizikawa »

Offline TheMadCharles

you have no idea how much of a godsend you are

Offline oScarDiAnno

This opens a whole new world for terrain customization, and it also removes the hassle of keeping strict same files in order to play with other people, as before I had to keep sending zip updates with the new terrains to my friends and it was a mess when one skipped something.
Again, thanks a lot for your work! ;D

version 1.0.1 fixes game crash when LobbyChat::printLobby() was executed in mid-game lobby

Offline mozzribo

Hi! I'm getting the following error (on Linux):



Code: [Select]
recursive_directory_iterator::recursive_directory_iterator:
File not found.: "data\level\"

I'm sure I'm doing something wrong. Any ideas what that might be? DevConsole shows no output (possibly because I'm in Linux).

I've put the two files in the WA root directory and the terrain folders into DATA/Level... WormKIT is enabled, of course.

The old wkTerrain38 also doesn't seem to work anymore (I get the same error). However, I remember that it did (on the same installation). I haven't been using it in a while, though, due to the desync.

I'm not using a CD version but the GoG one, yet I tried the wkFileOVerride just in case, and of course, it didn't help (unless I used that one improperly as well).

Update: I now (after removing all the terrain files and folders and the wkTerrainSync files) actually encounter a fatal error within the game:



I cannot load customs maps, while generated maps don't load to the game setup screen. When I start the game, it crashes. I can provide the error log if needed.

If I install another instance of the game, I have the same problem. I suppose this has something to do with the registry (not that I have an idea)?
« Last Edit: February 20, 2021, 11:16 PM by mozzribo »

the module has been updated to version 1.0.2
- added a nag message informing players to install wkTerrainSync

fixes:
- host desynchronization with fallback to -Beach terrain
- .BIT levels with custom terrains in online games
- fixed file lock when renaming .part files and infinite request/download/rescan loop
- to fix opaque back sprite in some terrains, back.spr is no longer loaded with extended sprite loader. to use the extended sprite loader, rename back.spr as _back.spr
    - new custom terrains should use _back.spr when using back sprite with custom resolution
    - some existing terrains that utilize custom back.spr loader are added to a predefined exception list by terrain hash
    - the exception list can be overridden by appending the following section to wkTerrainSync.ini file; terrain hashes must be separated by comma symbol:
Code: [Select]
[exceptions]
ExtendedBackSprLoader=e27d433fcd8ac2e696f01437525f34c5,
« Last Edit: February 21, 2021, 06:32 PM by nizikawa »

Hi! I'm getting the following error (on Linux):

i'm not familiar with running worms under wine, but some users confirmed the module works fine on linux. my guess is that your current working directory is not set to WA directory:
launch a new terminal window and enter:
Code: [Select]
cd /home/username/path/to/your/wa/dir/
wine ./WA.exe
this should make dev console output visible in your terminal and might fix the terrain loading issue. i will look into the compatibility of the module with wine

Offline mozzribo

Hi! I'm getting the following error (on Linux):

i'm not familiar with running worms under wine, but some users confirmed the module works fine on linux. my guess is that your current working directory is not set to WA directory:
launch a new terminal window and enter:
Code: [Select]
cd /home/username/path/to/your/wa/dir/
wine ./WA.exe
this should make dev console output visible in your terminal and might fix the terrain loading issue. i will look into the compatibility of the module with wine

Thanks for the help. Ultimately I managed to remove all existing instances of the game and re-install it. Now everything works as expected. We did need to use the most recent version You just posted, though.

Otherwise, me using WA 3.8.1, while the other person using 3.8, both with the previous versions of wkTerrainSync, got the desync error. Here are screenshots, maybe they help even though there isn't much technical information on them:

Me, as a host:



On the joiner's side:




Thanks for the awesome work You're doing!
« Last Edit: February 21, 2021, 02:14 PM by mozzribo »

Offline Magma-1337

I have found a bug where the game crashes when you minimize, then maximize the game while the map editor is open with a custom terrain selected.
If you need, I can send the errorlog.txt so you can figure out what made it crash.
« Last Edit: April 26, 2021, 02:29 AM by Magma-1337 »

Offline MonkeyIsland

Is this bug related to wkTerrainSync?
Due to massive misunderstandings: MonkeyIsland refers to an island not a monkey. I would be a monkey, if my name was IslandMonkey meaning a monkey who is or lives on an island. MonkeyIsland is an island which is related to monkeys. There's been a legend around saying MonkeyIsland is a game. So please, think of me as an island or a game.

I have found a bug where the game crashes when you minimize, then maximize the game while the map editor is open with a custom terrain selected.
If you need, I can send the errorlog.txt so you can figure out what made it crash.
I am aware of the bug and I can replicate it - no need for errorlog. This crash also happens with the original wkTerrain. I will try to fix this bug, but at the moment I can't guarantee anything until I analyze what causes the game to crash.
BTW. I'm currently working on version 1.1 of the module that brings new feature and fixes other bugs.


edit: fixed in v.1.1.0
« Last Edit: May 02, 2021, 09:07 AM by nizikawa »

Version 1.1.0a has been released!

What's new:
Version 1.1.0 introduces support for custom-sized random maps generated with built-in map generator. The maps can be scaled with 0.1x scale increments in both width and height dimensions up to 5.0x scale max.
The module modifies frontend code to add two dropdown menus under map preview with selectable width and height scale. The scale is applicable only to .LEV maps - i.e. the maps that were generated with map generator and not altered since their generation. Drawing anything on the map preview will cause the map to be immediately converted to .BIT format and its scale reset to default.
Online play on custom sized maps is supported, but all players need to have wkTerrainSync v.1.1.0 (or newer) installed.
The generated maps must be converted to PNG format to be played online with people without wkTerrainSync or previous versions of it installed.

Important notes:
The official WA maintainers have stated that this module WILL NOT BE SUPPORTED in upcoming versions (3.9.x and newer) of Worms Armageddon.
Replays created with wkTerrainSync maps WILL NOT BE COMPATIBLE with WA 3.9.x+ out of the box, however it might be possible to convert the replays to a newer format or create a compatibility layer wormkit module.
If you care about future preservation of your replay files, convert your maps into PNG format in map editor before playing on them.

Source code is available at: https://github.com/nizikawa-worms/wkTerrainSync
Binary DLL is attached to the first post and also available at: https://github.com/nizikawa-worms/wkTerrainSync/releases

---edit:
By mistake version 1.1.0 embedded its metadata in every replay, even if custom terrain/scale wasn't used. Although this shouldn't break replays, the metadata in such cases shouldn't be embedded at all.
I've released version 1.1.0a to amend this bug. Those who've installed v.1.1.0 are requested to update to 1.1.0a. Version 1.0.2 is unaffected.
I'm sorry for inconvenience I've caused.
« Last Edit: May 02, 2021, 12:42 PM by nizikawa »

Offline Korydex

Awesome job! It would be appreciated if you could explain every line in the ini file

Awesome job! It would be appreciated if you could explain every line in the ini file

Here are all currently available .ini parameters, with their default values and brief explanation:

[general]
EnableModule = 1                  # enables the module
AllowTerrainDownload = 1          # enables downloading missing terrains from other players
AllowTerrainUpload = 1            # enables sending missing terrain files to other players
IgnoreVersionCheck = 0            # if enabled, the module will attempt to run with non-supported WA versions instead of displaying an error message (for example 3.8.2 if it ever comes out)
EnableLobbyGreentext = 1          # enables module status messages in lobby chat ("downloading terrain ...", "sending file ...")
UseFrontendMessageBox = 1         # enables frontend popup messages on certain errors
UseExperimentalMapTypeCheck = 1   # enables clearing terrain metadata on game start in certain circumstances to prevent polluting .wagame replay files with unnecessary metadata. disable it if you experience desynch on game start and the game loads "-Beach" terrain instead of custom terrain
SendNagMessage = 1                # enables sending warning messages to players without wkTerrainSync installed
ShowInstalledTerrainsInChat = 0   # since v.1.1.0 the module only prints its version/build number after typing "/terrains" in lobby chat. if enabled, the module will also list all installed terrains in chat. you can use "/terrains list" to achieve the same effect
MapThumbnailColor = 191           # specifies the color ID of map thumbnails for custom-sized maps. valid range: 1-255
PrintMapScaleInChat = 1           # enables printing current map scale in lobby chat after the host changes it. requires EnableLobbyGreentext=1

[parallax]
parallaxBackA = 9011200           # specifies parallax parameter of back2.spr
parallaxBackB = 42172416          # specifies parallax parameter of back2.spr
parallaxFrontA = 65536            # specifies parallax parameter of front.spr
parallaxFrontB = 48003809         # specifies parallax parameter of front.spr
HideOnBigMaps = 1                 # back2.spr / front.spr parallax parameters are incorrect for maps with custom vertical scale and are hidden by default. disable this to display them anyway

[debug]
EnableDevConsole = 1              # enables debug console with logs
HexDumpPackets = 0                # prints hex dumps of lobby packets in dev console. slows down frontend during network activity

[fixes]
SuperFrontendFixMapThumbnail = 1  # enables a potentially buggy fix for map thumbnails when the module is used with wkSuperFrontendHD

[exceptions]
ExtendedBackSprLoader = e27d433fcd8ac2e696f01437525f34c5,    # since v.1.0.2 back.spr is no longer loaded with extended sprite loader to fix compatibility with some terrains. to use the extended sprite loader, rename back.spr as _back.spr. this parameter specifies a comma separated list of md5 hashes of terrains that should use extended sprite loader with back.spr