SnowRunner tips and tricks

Force game save

When you are at a point in the game you want to save, exit to the Main Menu. This saves the current state of the game, and when you force quit the game in case of an accident (see Accident below), the game will start at least from that location.

Accident

When an accident happens and you know the truck cannot recover, like flipping on its side, quickly press Alt-F4 to immediately exit the game. When you restart the game, you can continue from the last automatic save point.

Trailer delivery in tasks and contracts

When a trailer is requested, usually only a specific trailer satisfies the requirements. It can be on a different map, so in that case you have to tow it across the tunnels.

Find the trailer

The correct trailer is marked with the magnifier icon.

  • On the Global Map navigate to the map which has the trailer. If not stated, check all unlocked maps to find it.
  • On the Objects tab in the Trucks and Trailers section the trailer is marked with a magnifier icon.
  • Select it to show it on the map (ouch!)


You need to have the trailer attached or winched to the truck with both the truck and trailer inside the zone for it to count.

Maintenance Trailer

A Maintenance Trailer cannot be empty to be accepted, it needs to have at least 201 liters fuel in it.

Truck customization in Snowrunner

Eventually there will be many options when you customize your trucks in the garage. These are some recommendations.

Winch

When you get stuck in the mud, the length of the rope is usually more important than the power of the winch motor. Pick the longest rope possible to be able to reach more trees and power poles.

The Extended and Advanced winches have the longest rope. Pick the Advanced if it is available, as it has a stronger motor.

Upgrade the PostgreSQL database cluster

Newer PostgreSQL versions introduce useful functionalities, so it is a great idea to keep our database engines up-to date. In addition if the version of the database engine stays very old, in the future it can be difficult to “catch up” and upgrade the data to the new version.

This is the official documentation of the pg_upgrade process: https://www.postgresql.org/docs/current/pgupgrade.html

To upgrade the PostgreSQL database engine version

Check the version of the PostgreSQL server

  • In pgAdmin4 open a Query Tool window
  • Execute:
    SELECT version();

Create a backup of the old server

  • Open pgAdmin4 and right-click the local database server
  • Click the folder icon to select the backup file location
  • Select the postgres role, and click the Backup button
  • The confirmation appears in the lower right corner
  • Wait until the process completes

Get the PostgreSQL data directory

To get the name of the current PostgreSQL data directory

On macOS

On macOS the location of the server installation is /Library/PostgreSQL/MY_SERVER_VERSION/
The binary (executable) files are in the “bin” directory, the data files are in the “data” directory

Remove deprecated libraries

Some old versions of the PostgreSQL server contain deprecated libraries. As those are not part of the new installation anymore, pg_upgrade will stop with an error message.

Upgrading from version 15

Version 15 of the PostgreSQL server contained the adminpack library which is not part of later versions. Before we shut down the old server we will need to remove the library:

  • In pgAdmin4 right-click the postgres database and select Query Tool
  • Execute the following command
    DROP EXTENSION adminpack CASCADE;

Stop the old PostgreSQL server

  • Find the the PostgreSQL command line utility
    locate pg_ctl
  • If the message appears “WARNING: The locate database (/var/db/locate.database) does not exist.”, execute the following command:
    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
    • There is no indication when the “locate” database build completes, so try to execute the “locate” command after a few minutes to see if the database is available.
  • Switch to the root directory to avoid directory access issues, and execute the found pg_ctl command to shut down the PostgreSQL server.
    The -D option specifies the location of the data directory:
cd /

sudo -u postgres /Library/PostgreSQL/15/bin/pg_ctl -D /Library/PostgreSQL/15/data stop
  • After a few seconds the server stops

Install the new version of the server

  • Download the latest version of the PostgreSQL installer from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
  • Start the installer,
  • Follow the prompts
  • IMPORTANT, use the recommended, version specific installation directory names

  • Create a password for the database superuser called “postgres”
    • If the old version of the PostgresSQL server is running, a new port number will be recommended
    • If no PostgreSQL instance is running, the standard 5432 port number is populated:
  • Keep the Default locale setting
  • The summary page shows the location of the components
  • Click Next to start the installation
  • If you don’t want to install other components, uncheck the Stack Builder launch.

Configure the environment

As the upgrade process will connect to the old and new instance multiple times, save the access credentials in the PostgreSQL password file in the user’s root directory at ~/.pgpass

Create the password file

Official documentation is at https://www.postgresql.org/docs/current/libpq-pgpass.html

  • Open or create the password file from the command line with
    code ~/.pgpass
  • Specify the database admin credentials in the file:
# EXAMPLE: hostname:port:database:username:password
localhost:*:*:postgres:MY_ADMIN_PASSWORD 
  • Set the file access permissions to disallow access by world, otherwise the file will be ignored by the process:
    chmod 0600 ~/.pgpass

If the error message during upgrade is

connection to server on socket “/private/tmp/.s.PGSQL.50432” failed: fe_sendauth: no password supplied
could not connect to source postmaster started with the command:

Enable connection to local servers without a password. Update the config files for the old and new version to trust the local connection.

  • Edit the old server’s config file
    vi /Library/PostgreSQL/15/data/pg_hba.conf
  • In the line of the local connection change the method from “scram-sha-256” to “trust”
local   all             all                                     trust
  • Edit the new server’s config file
    vi /Library/PostgreSQL/17/data/pg_hba.conf
  • In the line of the local connection change the method from “scram-sha-256” to “trust”
local   all             all                                     trust

Stop both PostgreSQL servers

Even though we have stopped the old server, the installation of the new version started the new.

  • Stop the new server with
    sudo -u postgres /Library/PostgreSQL/15/bin/pg_ctl -D /Library/PostgreSQL/15/data stop

Start the upgrade

pg_upgrade needs write access to the current directory, so let’s create a working directory for the process, othrewise we get the error message:

You must have read and write access in the current directory.

Also, as we will run the pg_upgrade comamnd as the user “postgres” we need to start the process in a directory it has access to, otherwise we get the error message:

could not determine current directory

To satisfy both requirements, we need to be in a directory where the postgres user can be and have write access. We will use the temp directory:

cd /tmp
  • To upgrade the PosgreSQL server from version 15 to 17 execute the command as the postgres user:
sudo -su postgres
  • When asked, enter your macOS password to allow the user switching:
  • Switch to the /tmp directory and start the upgrade process
cd /tmp

/Library/PostgreSQL/17/bin/pg_upgrade --old-datadir /Library/PostgreSQL/15/data --new-datadir /Library/PostgreSQL/17/data --old-bindir /Library/PostgreSQL/15/bin --new-bindir /Library/PostgreSQL/17/bin

After successful upgrade

Start the new server

Open the terminal and execute the command below. Use the new server’s version number in the command

sudo -u postgres /Library/PostgreSQL/17/bin/pg_ctl -D /Library/PostgreSQL/17/data start

Check the version of the new PostgreSQL server

  • In pgAdmin4 open a Query Tool window
  • Execute:
    SELECT version();

Rebuild the optimizer statistics

As the optimizer statistics were not transferred to the new server environment, after starting the new server execte the command from the terminal

sudo -su postgres /Library/PostgreSQL/17/bin/vacuumdb --all --analyze-in-stages

To delete the old cluster

Once you have validated the new cluster, you can delete the data files of the old cluster. In the /tmp directory, where we have executed the pg_upgrade comand, the process created a customized script. Execute from the command line

cd /tmp

./delete_old_cluster.sh

Troubleshooting

If the old version of the PostgreSQL server used extra libraries, we need to install those for the new version too:

Checking for presence of required libraries fatal

Your installation references loadable libraries that are missing from the
new installation. You can add these libraries to the new installation,
or remove the functions using them from the old installation. A list of
problem libraries is in the file:
/Library/PostgreSQL/17/data/pg_upgrade_output.d/20241002T161901.823/loadable_libraries.txt

Open the text file and install the referenced libraries. In my case the message was:

could not load library “$libdir/adminpack”: ERROR: could not access file “$libdir/adminpack”: No such file or directory
In database: postgres

If the missing library is the adminpack, see Remove deprecated libraries above.

To install the missing libraries

  • Start the Application Stack Builder utility from the Launchpad
  • Select the new PostgreSQL server version
  • Select the missing library

How to disable image switching by the mouse scroll wheel in IrfanView

IrfanView is a great, free image editing program. One feature can destroy all your work if you keep it enabled.

When you rotate the scroll wheel of your mouse and the vertical scroll bar is not visible, the application loads the next image file from the directory. With this, you lose all changes you made to the image.

To disable image switching by the scroll wheel:

  • In the Options menu select Properties/Settings…
  • On the Properties/Settings page under Load next/previous file on Mouse wheel scroll select Never,
  • Click the Save button.

How to create a free Mapbox access token

Mapbox provides mapping services, and for private individuals many of those services are free. They ask for a credit card number to create a free access token, but they only charge it if the usage is very high, which usually only happens when the token is used for commercial purposes. To avoid credit card charges, keep your Mapbox token safe without publishing it on-line.

To create a free Mapbox access token

Create a Mapbox account

  • Navigate to https://www.mapbox.com/
  • Click the Get started for free button
  • Create an individual account
  • Follow the prompts and provide a credit card information. Mapbox will only charge it if the usage is very high, this usually never happens with private usage.

Create a Mapbox token

  • On the Tokens page click the Create a token button
  • Enter a name for the token, and keep the Public scopes selected
  • Click the Create token button
  • Save the token on your computer, never share it on the internet, as your credit card will be charged if the usage will reach the commercial level.

Migrating from conda to conda-forge for Python package management

Anaconda changed its Term of Use to require payment from companies larger than 200 employees. Many companies are not willing to pay the subscription fees for a software they can substitute.

conda-forge is the free, really open source alternative for the conda Python package manager.

To migrate your development environment from conda to conda-forge

Install conda-forge

To install conda-forge

  1. Navigate to https://conda-forge.org/download/,
  2. Download the installer for you operating system,

On macOS

  1. Open a terminal
  2. Execte the command
    bash ~/Downloads/Miniforge3-MacOSX-x86_64.sh
    • Answer yes when asked to accept the license terms
    • Press ENTER to allow the installation into your user directory

On Windows

  1. Execute the Windows installer

Configuration

Check the version of conda on your workstation, and update Conda, it should be higher than 4.9

conda --version
conda update conda

To not to activate the conda base environment at startup execute the command

conda config --set auto_activate_base false

To install packages from conda-forge, the free for everyone open source package repository

conda config --add channels conda-forge

Activate the strict channel priority to make sure the packages are first searched on the conda-forge channel

conda config --set channel_priority strict

Check the Conda configuration

To list the Conda config locations

conda config --show-sources

The usual Conda config location is ~/.condarc

To check the Conda configuration at the usual location

cat ~/.condarc

channels:
– conda-forge
– defaults
channel_priority: strict

For more information see A brief introduction to conda-forge

Find conda-forge packages

  • Start the Anaconda Navigator by executing in the terminal
    anaconda-navigator
  • On the Environments tab click Channels
  • Click the Add… button,
  • Enter https://conda.anaconda.org/conda-forge/ into the text box,
  • Press the Enter key, and
  • Click the Update channels button

Usage

To activate the conda base environment in the terminal, execute
eval “$(~/miniforge3/bin/conda shell.YOUR_SHELL_NAME hook)”

For iTerm the command is

eval "$(~/miniforge3/bin/conda shell.bash hook)"

To install conda’s shell functions for easier access, first activate the conda base environment as above, then:

conda init

For changes to take effect, close and re-open your current shell.

Type ‘unknown’ is not assignable to type …

TypeScript tries to make sure the variables are always populated with data of the type specified during the variable definition.

Issue

When the TypeScript compiler thinks a function can return another data type, or “unknown”, “undefined”, “null”, Visual Studio Code displays a warning:

type ‘unknown’ is not assignable to type …

Solution

The solution is to explicitly convert the return type to the expected one:

let soObject: SsoObject = <SsoObject> decodeJWT(ssoCookie);

Generating height maps with skydark.pl

To generate the height map of an area of the Earth

  • Navigate to https://heightmap.skydark.pl
  • Enter the name of the city in the search box
  • Set the Map size to 14.336 km
  • To move the selected area on the map, click and drag the central blue square.
  • To move the map closer to the sea level, click the Base level calculator button
  • Select Draw water streams to create the correct river and lake beds on the height map.
  • To display the elevation contour lines on the map image enable the Show height contours button
  • To display the edge of the water on the map image enable the Show water contours button
  • Click the Download PNG height hap button to download the height map.
  • Click the Download map image button to download the map for the overlay image.