A tool for making map images from OpenTTD save games

Overview

OpenTTD Surveyor

A tool for making map images from OpenTTD save games. This is not part of the main OpenTTD codebase, nor is it ever intended to be part of it. This project was written in python to parse save game files to make maps. At the time of writing, it only supports save files up to version 34.

Installation

Install pycairo https://pycairo.readthedocs.io/en/latest/getting_started.html

On a mac you can do:

> brew install cairo pkg-config

Create a virtualenv and install the requirements:

> python3 -m venv venv
> source venv/bin/activate
> pip install --upgrade pip
> pip install -r requirements.txt

Then clone the repo and change dir:

> git clone [email protected]:aidansean/OpenTTD_surveyor.git
> cd OpenTTD_surveyor

Use

Then you should be able to use the tool to make some maps!

Make a png map of the tutorial map:

> python src/run.py -m png -v -i example_saves/Tutorial.sav

Make an svg map of the tutorial map in dark mode:

> python src/run.py -m svg -v -d -i example_saves/Tutorial.sav

Docker

You can also use docker to run the tool to avoid installing dependencies on your host PC (instead you need to "only" install docker).

Follow the relevant instructions to install docker on your system: https://docs.docker.com/engine/install/

Clone the repo and change dir as mentioned above.

Build the docker image:

docker build . -t openttd_surveyor

And run the tool:

docker run --rm -v "${PWD}/example_saves":/save -v "${PWD}/example_images":/image openttd_surveyor -m png -v -o /image -i "/save/tiny.sav"

Change ${PWD}/example_saves to the location of your savegames and ${PWD}/example_images to the location you want to output the images.

Questions

It takes ages to generate a map for a very large save game.

Yes, it will do. You can use the -p option to show progress bars and -v option to give verbose output, and find out where it's taking a long time.

Can I use this on Windows?

I don't have a Windows machine, so I can't help with that, I'm afraid. Anywhere you can use python and can install cairo should work.

Will it work with this really cool extension I'm using?

Yes. No. Maybe. I don't know. Can you repeat the question? Try it and find out!

I'm colour blind. Can you make it more colour blind friendly?

Maybe... Pretty much all the colours are specified in the config files, so you should be able to change the colours there to something more friendly.

This repo is poorly coded and the maps are buggy!

Probably. Help out by forking it and opening a PR :)

Screenshots

Here's the sort of thing it can do:

Normal mode example

Normal mode example

Dark mode example

Comments
  • JGRPP version support or some other error?

    JGRPP version support or some other error?

    Hello, is the JGRPP version of OpenTTD supported? I'm getting some error I think it cannot find the owner of some bridge with my savegame but I'm not 100% if it's JGRPP that's responsible for that or not.

    Here's the full exception along with some context:

    INFO:Surveyor:[2021-05-31 13:28:31.757651]  All done!
    INFO:Surveyor:[2021-05-31 13:28:31.812244]  Min, max map height: 0, 255
    INFO:Surveyor:[2021-05-31 13:28:31.890413]  Dimensions of tile size, image before resizing: 50, 25550 x 25550
    INFO:Surveyor:[2021-05-31 13:28:31.890888]  Dimensions of tile size, image after resizing : 50, 25550 x 25550
    INFO:Surveyor:[2021-05-31 13:28:32.190478]  Drawing tile backgrounds.
    INFO:Surveyor:[2021-05-31 13:28:39.897068]  Drawing road tiles.
    INFO:Surveyor:[2021-05-31 13:28:40.242632]  Drawing rail tiles.
    INFO:Surveyor:[2021-05-31 13:28:45.233072]  Drawing station tiles.
    INFO:Surveyor:[2021-05-31 13:28:47.840059]  Drawing tunnel mouth and bridge ramp tiles.
    INFO:Surveyor:[2021-05-31 13:28:47.899509]  Drawing building tiles.
    INFO:Surveyor:[2021-05-31 13:28:50.830704]  Drawing industry tiles.
    INFO:Surveyor:[2021-05-31 13:28:52.405351]  Drawing water tiles.
    INFO:Surveyor:[2021-05-31 13:28:57.646366]  Drawing road tiles.
    INFO:Surveyor:[2021-05-31 13:28:57.756247]  Drawing tram tiles.
    INFO:Surveyor:[2021-05-31 13:28:57.796677]  Drawing rail tiles.
    INFO:Surveyor:[2021-05-31 13:29:01.166532]  Drawing rail signals.
    INFO:Surveyor:[2021-05-31 13:29:01.260801]  Drawing bridges over tiles.
    Traceback (most recent call last):
      File "/app/src/run.py", line 113, in <module>
    Working with the following settings:
       save_file_path: /data/fureito.sav
     output_file_path: /data/fureito.png
     config_file_path: config/main.json
           image_mode: PNG
            tile_size: None
              verbose: True
    show_progress_bar: False
            dark_mode: False
        main()
      File "/app/src/run.py", line 109, in main
        surveyor.save_image(output_file_path, image_mode)
      File "/app/src/surveyor.py", line 178, in save_image
        self.painter.save_image(image_file_path, filetype=filetype)
      File "/app/src/cairo_painter.py", line 2050, in save_image
        self.draw_bridges_over(all_tiles)
      File "/app/src/cairo_painter.py", line 1829, in draw_bridges_over
        self.draw_unknown_bridge_over(tiles, tile, tile.bridge - 1)
      File "/app/src/cairo_painter.py", line 1305, in draw_unknown_bridge_over
        self.draw_rail_bridge_over(tile, rotation, track_type, source_tile_owner)
      File "/app/src/cairo_painter.py", line 849, in draw_rail_bridge_over
        self.draw_bridge_over(tile, rotation, "rail", track_type, None, source_tile_owner)
      File "/app/src/cairo_painter.py", line 782, in draw_bridge_over
        self.draw_rail_line(
      File "/app/src/cairo_painter.py", line 452, in draw_rail_line
        inner_rgb = self.player_colors[owner]
    TypeError: list indices must be integers or slices, not NoneType
    

    Also attaching the savegame: fureito.sav.zip

    Edit: added more context to the log

    opened by eirc 3
  • Industry replacement grfs can fail

    Industry replacement grfs can fail

    Looks Like Industry set replacements fail:

    INFO:Surveyor:[2021-05-31 14:50:23.292846]  Parsing tile bits...
    Traceback (most recent call last):
      File ".\src\run.py", line 113, in <module>
    	main()
      File ".\src\run.py", line 107, in main
    	surveyor.ingest_data()
      File ".\OpenTTD_surveyor\src\surveyor.py", line 145, in ingest_data
    	self.set_map_bytes()
      File ".\OpenTTD_surveyor\src\surveyor.py", line 127, in set_map_bytes
    	tile.parse_all()
      File ".\OpenTTD_surveyor\src\tile.py", line 138, in parse_all
    	self.occupant.parse_all()
      File ".\OpenTTD_surveyor\src\tile_occupant.py", line 244, in parse_all
    	self.industry_type = INDUSTRY_TYPES[self.parse_map_bits(b'MAP5', 0, 8)]
    IndexError: list index out of range
    

    Specifically a FIRS 4.0.1 grf only. Maybe just use the index number if out of range?

    opened by purplemonkeymad 2
  • Support runnning with docker.

    Support runnning with docker.

    Since the project is not developed with docker in mind, the "run" command looks a bit awkward in order to mount all relevant directories and to make sure the current dir is correct.

    If this gets used enough it can be simplified further in the future by, for example, outputting the image by default to the same folder as the savegame and similar minor tweaks. I didn't want to make any such changes now though to keep this as frictionless as possible.

    opened by eirc 0
  • Added eras and types of signals.

    Added eras and types of signals.

    This PR adds signals with eras and types:

    Era:

    • 0: Semaphore, rectangle
    • 1: Electric, circle

    Type:

    • 0: Block, white
    • 1: Pre-signal, yellow
    • 2: Exit signal, grey
    • 3: Combo signal, yellow with grey vertical stripe
    • 4: Path signal: Red
    • 5: One way path signal: White with red horizontal stripe

    It also adds the option to not show roads.

    opened by aidansean 0
  • Fixed progress bars. Protected against IndexError

    Fixed progress bars. Protected against IndexError

    This PR fixes three things:

    • Protects against None values when searched for bridge owners (this happens with incompatible save files, but allows the process to complete, helping to debug the problem.)
    • If finding the industry type results in an IndexError, set the industry_type to OTHER_INDUSTRY.
    • Fixes progress bars. There must be a cleaner way to do this with decorators or something. A problem to solve properly at a later date.
    opened by aidansean 0
Owner
Aidan Randle-Conde
Former high energy physicist who codes to solve problems for fun
Aidan Randle-Conde
An image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testingAn image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testing

SVM Données Une base d’images contient 490 images pour l’apprentissage (400 voitures et 90 bateaux), et encore 21 images pour fait des tests. Prétrait

Achraf Rahouti 3 Nov 30, 2021
Predicting Semantic Map Representations from Images with Pyramid Occupancy Networks

This is the code associated with the paper Predicting Semantic Map Representations from Images with Pyramid Occupancy Networks, published at CVPR 2020.

Thomas Roddick 219 Dec 20, 2022
A large dataset of 100k Google Satellite and matching Map images, resembling pix2pix's Google Maps dataset.

Larger Google Sat2Map dataset This dataset extends the aerial ⟷ Maps dataset used in pix2pix (Isola et al., CVPR17). The provide script download_sat2m

null 34 Dec 28, 2022
Honours project, on creating a depth estimation map from two stereo images of featureless regions

image-processing This module generates depth maps for shape-blocked-out images Install If working with anaconda, then from the root directory: conda e

null 2 Oct 17, 2022
Fang Zhonghao 13 Nov 19, 2022
BitPack is a practical tool to efficiently save ultra-low precision/mixed-precision quantized models.

BitPack is a practical tool that can efficiently save quantized neural network models with mixed bitwidth.

Zhen Dong 36 Dec 2, 2022
naked is a Python tool which allows you to strip a model and only keep what matters for making predictions.

naked is a Python tool which allows you to strip a model and only keep what matters for making predictions. The result is a pure Python function with no third-party dependencies that you can simply copy/paste wherever you wish.

Max Halford 24 Dec 20, 2022
Using this codebase as a tool for my own research. Making some modifications to the original repo for my own purposes.

For SwapNet Create a list.txt file containing all the images to process. This can be done with the GNU find command: find path/to/input/folder -name '

Andrew Jong 2 Nov 10, 2021
A little software to generate and save Julia or Mandelbrot's Fractals.

Julia-Mandelbrot-s-Fractals A little software to generate and save Julia or Mandelbrot's Fractals. Dependencies : Python 3.7 or more. (Also possible t

Olivier 0 Jul 9, 2022
Drone-based Joint Density Map Estimation, Localization and Tracking with Space-Time Multi-Scale Attention Network

DroneCrowd Paper Detection, Tracking, and Counting Meets Drones in Crowds: A Benchmark. Introduction This paper proposes a space-time multi-scale atte

VisDrone 98 Nov 16, 2022
An Artificial Intelligence trying to drive a car by itself on a user created map

An Artificial Intelligence trying to drive a car by itself on a user created map

Akhil Sahukaru 17 Jan 13, 2022
This is code to fit per-pixel environment map with spherical Gaussian lobes, using LBFGS optimization

Spherical Gaussian Optimization This is code to fit per-pixel environment map with spherical Gaussian lobes, using LBFGS optimization. This code has b

null 41 Dec 14, 2022
A neuroanatomy-based augmented reality experience powered by computer vision. Features 3D visuals of the Atlas Brain Map slices.

Brain Augmented Reality (AR) A neuroanatomy-based augmented reality experience powered by computer vision that features 3D visuals of the Atlas Brain

Yasmeen Brain 10 Oct 6, 2022
Codes for TS-CAM: Token Semantic Coupled Attention Map for Weakly Supervised Object Localization.

TS-CAM: Token Semantic Coupled Attention Map for Weakly SupervisedObject Localization This is the official implementaion of paper TS-CAM: Token Semant

vasgaowei 112 Jan 2, 2023
Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or columns of a 2d feature map, as a standalone package for Pytorch

Triangle Multiplicative Module - Pytorch Implementation of the Triangle Multiplicative module, used in Alphafold2 as an efficient way to mix rows or c

Phil Wang 22 Oct 28, 2022
Official implementation of "StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation" (SIGGRAPH 2021)

StyleCariGAN in PyTorch Official implementation of StyleCariGAN:Caricature Generation via StyleGAN Feature Map Modulation in PyTorch Requirements PyTo

PeterZhouSZ 49 Oct 31, 2022
Many Class Activation Map methods implemented in Pytorch for CNNs and Vision Transformers. Including Grad-CAM, Grad-CAM++, Score-CAM, Ablation-CAM and XGrad-CAM

Class Activation Map methods implemented in Pytorch pip install grad-cam ⭐ Tested on many Common CNN Networks and Vision Transformers. ⭐ Includes smoo

Jacob Gildenblat 6.6k Jan 6, 2023
GBIM(Gesture-Based Interaction map)

手势交互地图 GBIM(Gesture-Based Interaction map),基于视觉深度神经网络的交互地图,通过电脑摄像头观察使用者的手势变化,进而控制地图进行简单的交互。网络使用PaddleX提供的轻量级模型PPYOLO Tiny以及MobileNet V3 small,使得整个模型大小约10MB左右,即使在CPU下也能快速定位和识别手势。

null 8 Feb 10, 2022
Official implementation of "StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation" (SIGGRAPH 2021)

StyleCariGAN: Caricature Generation via StyleGAN Feature Map Modulation This repository contains the official PyTorch implementation of the following

Wonjong Jang 270 Dec 30, 2022