This Week In Veloren 127

5 minute read05 July 2021

Authored by AngelOnFira

This week, we see some changes coming to the economic system, as well as food. We hear about some network fixes, and what issues caused them.

- AngelOnFira, TWiV Editor

Contributor Work

Thanks to this week's contributors, @a1phyr, @xMAC94x, @aweinstock, @juliancoffee, @Sam, @UMR1352, @zoli111, @AldanTanneo, @XVar, @Yusdacra, @swrup, @steanne, @eckso, @imbris, @tygyh, @zesterer, @DaforLynx, @Slipped.

This month's Rust Gamedev newsletter is out! You can also read this week's meeting minutes here.

@Snowram added death SFX and VFX, and made dungeon entrances spawn depend on biomes (MR yet to be reviewed). @LunarEclipse I've been working on a few small improvements to Torvus such as adding /version and /help commands. @juliancoffee adjusted the yeti difficulty for beginner dungeon.

@Christof just started a redesign of the economic simulation to support new items and game mechanics introduced in the past six months. With housing, gliders, lanterns, ores, coal, and gems added, the new schema feels more adequate but is still a work in progress. Making the conversion between items and economic wares more reasonable is the major goal here.

Food rework by @juliancoffee

I've been working on a food rework after consuming animations got merged, now most of the food heals you in 5-10 seconds and starts when you sit down. We also got a new food item which gives you two effects at the same time - Mushroom Curry 🍛. It requires you to patiently eat it, but then gives you quick saturation buff which restores 50 HP as well as a long-lasting regeneration buff, which slowly heals you for more than a minute!

As for small fixes, merchants now can sell and buy most of the items at reasonable prices (when Mushroom Curry costs more than its ingredients). They can even buy mind flayer spell bags though quite frequently they don't have coins that you would want for it.

Network improvements by @aweinstock

Disabling Nagle's algorithm

In order to debug some networking performance issues, I added some instrumentation of network requests to the client using the tracy tracing profiler. This revealed that messages on the in-game stream (which is meant to handle low-latency data like entity position updates and client inputs) were being delivered in batches.

Graph showing nearly a full second of latency, after which 6 messages were delivered at once:

This turned out to be a result of not disabling Nagle's algorithm/enabling TCP_NODELAY. Nagle's algorithm maintains a buffer of small messages, only sending a TCP packet when it's full. This trades away latency to improve throughput, which is the opposite of what's desired for the in-game stream. As a result of disabling Nagle's algorithm, input handling and entity movement should be smoother.

Attempts to improve lossy terrain compression

I also tried to improve terrain compression by using 256-color palettes per block kind. This should allow for sending terrain that's a third of the size (since it's 1 byte per voxel for color data instead of 3 bytes for RGB triples), while still being fairly high quality (since Grass has 256 shades of green, Wood has 256 shades of brown, and so on).

The slow part of using a palette on terrain is finding the closest color to the original color, which can be sped up relative to linear search by treating the colors as vectors and using spatial data structures like kd-trees and R*-trees to find nearest neighbors of a color by Euclidean distance.

While this was a success compression ratio wise (a full resolution chunk can be stored at 6% of an in-memory chonk with quantized colors, compared to the 17% or so of deflate or full resolution unquantized PNG), it was an order of magnitude slower than either deflate or quarter resolution PNG (the previous best lossy compression format, at 3% ratio, with noticeable artifacts), rendering it unsuitable for real-time compression of terrain chunks.

Graph showing average compression time vs chunk height for a set of chunks near a dungeon:


I gave a few more materials non-zero prices, which resulted in most metal and hide armor being valued by NPC merchants. Cloth isn't being given a price yet since cloth is considered too easy to acquire via chunk reloading, this is intended to be addressed by modeling plant growth.

I also fixed a longstanding bug with underwater campfires, they now no longer emit smoke or light when they get put out by being submerged underwater: