Skip to content

casually-creative/mc2-race-editor-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Midnight Club 2 Race Editor Parser

A PowerShell parser and technical documentation for the .red file format used by Midnight Club 2's in-game Race Editor. Each .red file is a fixed-size 222-byte binary file describing one custom race - including city, time of day, weather, race mode, CPU opponents, checkpoints, time bonuses, and lap count.

Usage

  1. Make a backup of your /userdata folder, just in case.
  2. Place the parser scripts in the root of your Midnight Club 2 directory.
  3. Execute ParseRedToJson.ps1 to parse your /userdata/*.red files to /userjson/*.json files.
  4. Inspect the .json files and make edits where wanted. Be sure to follow the specs for valid values.
  5. Execute ParseJsonToRed.ps1 to parse the /userjson/*.json files back to /userdata/*.red files.

Development

The scripts in src/ are the source of truth. They reference src/race.schema.json at runtime for all enum data and validation. Do not edit the files in dist/ directly — they are generated.

Workflow:

  1. Edit the source scripts in src/ or the schema in src/race.schema.json.
  2. Run the build to produce standalone distributable scripts:
    pwsh .\dev\Build.ps1
    Tip: The Run selected PowerShell script VS Code extension lets you right-click any .ps1 file in the Explorer and run it directly, without needing a terminal.
  3. The built scripts are written to dist/. These have the schema inlined and are minified — share these with end users.

The build step inlines the schema as a here-string and strips all comments and blank lines from the output.

Contents

File Description
src/ParseRedToJson.ps1 Reads all .red files from /userdata and writes one .json per file to /userjson.
src/ParseJsonToRed.ps1 Validates and reads all .json files from /userjson and writes one .red per file to /userdata.
src/race.schema.json JSON Schema (Draft 2020-12) for the race JSON format. Single source of truth for all enum data; the parser reads its lookup tables directly from this file.
dev/Build.ps1 Inlines the schema into each source script and writes standalone output scripts to dist/.
docs/RedFileFormat.md Full technical documentation of the .red binary format: byte map, enumerations, checkpoint layout, parsing rules, serialization rules, and padding sentinels.
docs/PowershellNotes.md Notes and constraints for letting Github Copilot run PowerShell scripts in VS Code.

About

Parser script and technical documentation for Midnight Club 2's race editor races.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors