mika-n / RemapIdenticalRBRTextures

Identifies and removes duplicated DDS texture files from RBR textures.rbz map packs. This saves disk space and makes a stage loading faster in RBR.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RemapIdenticalRBRTextures

This tool identifies identical DDS texture files in RICHARD BURNS RALLY textures.rbz archive files, removes duplicates and re-packs the RBZ file.

What are the benefits of doing all this for RBR maps?

  • Smaller map pack size in bytes (the size of track-1234_M/N/E/O_textures.rbz files is reduced when there are no duplicated files).
  • Smaller map pack saves download bandwidth and diskspace in PC.
  • Faster map loading because RBR doesn't re-load a texture if an identical copy is already loaded, plus RBR can read smaller textures.rbz files a bit faster (couple nano seconds faster in SSD systems, 5 nano seconds in historical HDD systems).
  • Wallaby and BlenderRBRExporter doesn't identify identical files yet, so this tool fills the gap and works with all maps created with any tool (even for old maps released years ago).


How this works?

  • Extracts map specific textures.rbz files to a temporary folder
  • Identifies duplicated copies of DDS file, removes duplicated copies and leaves just one copy of the DDS texture file.
  • Creates TextureFilenameMap.ini file with links between a removed DDS file and the one preserved copy of the identical file.
  • RBR (tuned with NGPCarMenu plugin) uses the generated TextureFilenameMap.ini file at stage load time to instruct RBR to use a remapped texture DDS file instead of the deleted duplicated copy. The remap link goes even between textures_O.rbz and texture_M.rbz files to eliminate duplicated DDS files between skybox rbz file.

Note! Identical file here means that the file content is one-on-one identical in a binary level (not a filename match).

Shows usage info:
  RemapIdenticalRBRTextures.exe   

Identifies duplicated textures in track 972 map pack (Maps\Tracks.ini [Map972] map), but does NOT update the map pack. 
This command can be used to "simulate" the process and see the end result in c:\backup\rbr folder without actually modifying anything.
  RemapIdenticalRBRTextures.exe -rbrFolder "c:\games\Richard Burns Rally" -track 972 -backupFolder c:\backup\rbr

Identifies duplicated textures in track 972 map pack, deletes duplicates and modifies the original RBZ map pack (-DeleteDuplicates option)
  RemapIdenticalRBRTextures.exe -rbrFolder "c:\games\Richard Burns Rally" -track 972 -backupFolder c:\backup\rbr -DeleteDuplicates

Example of TextureFilenameMap427.ini (Zaton stage in RSF)

; 20220113_182756 - Zaton - Autogenerated remap file by RallySimFans RemapIdenticalRBRTextures tool
; TAB char is the separator (originalFile remapTargetFile)
; Source texture filename (removed original file)    Target texture filename (preserved single instance of duplicated DDS files)
track-427_n_textures\damp\waters2.dds	 damp\waters.dds
track-427_n_textures\dry\waters2.dds	 dry\waters.dds
track-427_n_textures\dry\cary.dds	 damp\cary.dds
track-427_n_textures\wet\cary.dds	 damp\cary.dds
track-427_o_textures\wet\waters.dds	 track-427_n_textures\wet\waters.dds
track-427_o_textures\wet\waters2.dds	 track-427_n_textures\wet\waters.dds

Recommended map delivery folder structure with RallySimFans RBR mod

  • RallySimFans (RSF) nowadays delivers new classic maps using the following folder logic. Note the stage specific subfolder in RBR Maps folder and stage specific TracksXXX.ini, TrackSettingsXXX.ini and TextureFilenameMapXXX.ini files there. In RSF mod there is no need to merge values at installation time to the common maps\tracks.ini and maps\tracksettings.ini files and map files can be in a map specific subfolder under the common Maps folder. This new logic makes it easier to manage map files and to install new maps.
c:\games\rbr\Maps\
c:\games\rbr\Maps\427-Zaton\
c:\games\rbr\Maps\427-Zaton\Tracks427.ini  (Note! See the next paragraph for more info about TracksXXX.ini)
c:\games\rbr\Maps\427-Zaton\TrackSettings427.ini
c:\games\rbr\Maps\427-Zaton\TextureFilenameMap427.ini
c:\games\rbr\Maps\427-Zaton\427-Zaton splash1.dds    (427- filename prefix required here for the Zaton specific splash screen image. Supports DDS/PNG/JPG)
c:\games\rbr\Maps\427-Zaton\427-Zaton splash2.dds    (alternative splash screen img. RSF randomizes which one to show. Max 100 alternative images)
c:\games\rbr\Maps\427-Zaton\track-427_N_textures.rbz
c:\games\rbr\Maps\427-Zaton\track-427_O_textures.rbz
c:\games\rbr\Maps\427-Zaton\track-427_N.lbs
c:\games\rbr\Maps\427-Zaton\track-427_O.lbs
(plus other map files)

TrackXXX.ini options for custom maps in RallySimFans (RSF) plugin

Each map in RBR needs to have a track definition file listing where are track-XXX_textures.rbz, track-XXX.lbs and other track data files. Traditionally all maps in RBR shared the same Maps\Tracks.ini file. This complicated map installations because people installing custom maps had to manually edit Tracks.ini file and add the new [MapXXX] section in there. In RallySimFans RSF RBR environment this is no longer needed because each map can supply their own copy of TracksXXX.ini file in the map specific subfolder. Installation of a new custom map is now simple as unzipping MyStage.zip file into RBR folder.

Custom stages are shown in RSF in RallySimFans plugin in Practice/Stages/[Test stages] folder at the end of the stage list (ie. RSF in-game Practice racing menu).

When you publish a custom test/development map to RSF RBR installation then please choose any unused map ID for the map. RSF has reserved 490-499 range for custom test maps and none of the official maps use that range, but technically maps can use any map ID. Also, RSF uses 1000-1999 range with BTB online maps, so try to avoid that range even when techically BTB maps work a bit differently. So, a good candidate as a map ID for your custom map is

  • 490-499
  • 3000+

Example of c:\games\rbr\Maps\494-MyStage\Tracks494.ini

[Map494]
TrackName=Maps\494-MyStage\track-494
Particles=Maps\ps_MontBlanc
StageName=My new custom stage
Length=2.3
Tyre=0                  ; Tyre 0 tarmac, 3 gravel, 6 snow
;Surface=0              ; Optional if TYRE option missing: 0 tarmac, 1 gravel, 2 snow
Author=Foobar Team      ; Optional attribute. Shown for custom maps in RSF stage selection list
CountryCode=FI          ; Optional attribute (ISO-2 country code, see www.iban.com/country-codes). A flag shown for custom maps in RSF stage selection list

MinimapDrawn=true       ; Optional attribute to disable the auto-drawn minimap on top of the stage loading splash screen (true by default, but you can set it to false to hide the minimap).

; Following options in TracksXXX.ini file are optional. Map author can use these to instruct RSF Practice and Hotlap
; racing menu to use these as default selections
DefaultWeatherSky = N_hazy_clear
DefaultWeather    = bad
DefaultStageWear  = worn
DefaultWetness    = damp
DefaultTyre       = tarmac intermediate

; Optional stage specific custom StartClock times at the startline HHMM (when a stage shows the start clock object).
; RSF synchronizes the start clock with 3-2-1 countdown and second portion of the time is shown as 50 to 59 and "GO" is at specified time as HH:MM:00 (WRC logic).
; RSFLauncher has an option to customize the start clock to show countdown seconds also (7-6-5-4-3-2-1-GO)
StartClockMorning = 0812
StartClockNoon = 1315
StartClockEvening = 2000
StartClockNight = 2345

; Optional path to the stage specific animation scripts, objects and textures. Here it is possible to define new animations
; or to override default RBR animations (marshals, deers, birds, media people and so on).
; In this example MyCustom would refer to the folder in c:\games\rbr\Maps\494-MyStage\MyCustom\
; and in there the default RBR deer animation and marshalVest texture has been customized. With other animation files 
; RSF fallbacks to use the default RBR files in c:\games\rbr\scripts and c:\games\rbr\sgs folders.
;    c:\games\rbr\Maps\494-MyStage\MyCustom\scripts\load_deer_flat.lua
;    c:\games\rbr\Maps\494-MyStage\MyCustom\sgs\textures\ho_marshalvest.dds
;
AnimationPath=MyCustom

; Optional path to the stage specific fence texture objects.
; In this example MyCustom would refer to the folder in c:\games\rbr\Maps\494-MyStage\MyCustom\
; and in there Textures subfolder can have overridden versions of DDS texture filenames used in the default RBR misc/Fence.dat file.
; If the custom textures folder doesn't have a certain fence texture file then RSF fallbacks to use the default RBR texture file (in Fence.dat).
; Tip. You can extract a DAT file to see how those original RBR fence textures look like by using https://www.kegetys.fi/dattool-v1-01/ DATTOOL app.
; A command line to extract a dat archive file into FENCE subfolder: DATTOOL.EXE -e fence.dat FENCE
;    c:\games\rbr\Maps\494-MyStage\MyCustom\Textures\fence_tile01.dds
;    c:\games\rbr\Maps\494-MyStage\MyCustom\Textures\ar_fence_tile.dds
;
FencePath=MyCustom

; Optional clouds mod to use as per-stage cloud mod. The name of the Clouds option will be used to look for Maps\494-MyStage\Clouds_MyCustom.ini
; or Maps\Clouds_MyCustom.ini files (the first match). Clouds_MyCustom.ini be a copy of the default Maps\Clouds.ini file where all
; us_xxxx texture filenames have been renamed (tip. Do find-and-replace in Notepad) for example as mod_xxxx filenames and 
; Maps\494-MyStage\clouds_textures\ or Maps\clouds_textures\ folder contains mod_xxxx.dds cloud textures in dry/damp/wet folders.
;    Maps\494-MyStage\Clouds_MyCustom.ini or Maps\Clouds_MyCustom.ini file with custom texture filenames
;    Maps\494-MyStage\clouds_textures\ or Maps\clouds_textures\ folder with custom DDS cloud texture files
;    (if the cloud mod is shared by several stages then use Maps folder for the ini and cloud_textures folder)
;
Clouds=Clouds_MyCustom

When a new map is included as an official RSF online map then RSF admins assigns the new public map ID (the next free map ID) for the map. When a new map is close to be released and is in beta testing then RSF admins can reserve the public map ID for the map even before the final release, so a map author can start using that map ID while testing the map. In this case the map author should contact RSF admins in RSF Discord channel.


Copyright (c) 2021-2022 MIKA-N. All rights reserved. This is a free tool for all RBR map authors, but not for commercial use without a permission from the author. Use at your own risk.

RallySimFans - www.rallysimfans.hu

About

Identifies and removes duplicated DDS texture files from RBR textures.rbz map packs. This saves disk space and makes a stage loading faster in RBR.


Languages

Language:C# 100.0%