NFSU.cc / RE Atlas / Traffic Simulation

Traffic limits: how many cars, which models, colours, lights (Speed.exe PC)

Traffic Simulation 45 verified Speed.exe addresses Speed.exe (2003, x86)

Read only, nothing was run. Tools: Ghidra live on the named project (G), capstone tools/recomp/asm.py (C), tools/re/carinfo.py on GLOBALB.BUN (F), file listing of game/Cars (D). V = read in code, I = inferred, U = open. Names: census/names_trafficpool.tsv. Earlier notes (docs/re/traffic.md, re_racer_cap_probe) were leads.

Answers first

  1. Count. The first hard cap is 30 entrants (0x4322a0, cmp [race+0x12c], 0x1e). With 1 player + 6 rivals that leaves

23 traffic cars with no patch (V, G+C). The 26 in tools/recomp/caves/traffic.s is the cave's own clamp, not the game's. The next real wall is the collision body id table: 0xde = 222 ids, bitmap of only 216 bits, no bound check (V, C+G). It is code, not data. Soft limits (pools grow, neighbour list 16) do not stop cars. Not run: nothing here proves 23 cars survive the id table.

  1. Variety. 35 rows, 15 with usage 2. In the real game district 0 (every shipped track id >= 1000) gives weight 1.0 to only six

models, so only six traffic models can ever appear. The cave 0x63b270 gives all 12 normal traffic rows weight 1.0 and lets 8 racer cars in. Repeats come from the type count (6, then 12) and from the 100 re-picks that only try to avoid a type already in the entrant list. Paint is a per-model list of 1..8 ids. The teleporter keeps the model and re-rolls the paint on every move.

  1. Lights. 0x429100(ecx=car, A, B, C, lights, horn, gap) is the one call. Shown in section 3.

1. COUNT, in the order it bites

#LimitAddressValueOn overflowData or code
1Entrants0x4322a0 (G, C)30 (0x1e), stride 0x750, count [race+0x12c] = 0x78a41cthe entrant is dropped without any message; later code uses a smaller listcode: the immediate 0x1e. The array is a static pool 0x77c790..0x78a2f0 (30 x 0x750 = 0xdb60 bytes, ends at RaceStatus), cleared by 0x431df0 on return to the front end (sets [0x78a418] = 0x77c790, count 0); the cap 30 is structural, so raising 0x1e alone overruns into RaceStatus (V)
2Collision body ids0x466970 (C), id taken at 0x469b00 (C)0xde = 222 ids; table 0x736050 = 0xde dwords; bitmap 0x736070 = 0x1b bytes = 216 bitsno check: id 216..222 writes past the bitmap, id 222 past the table (heap corruption)code (two malloc sizes and 0xde)
3Track polygon bodies0x466970, 0x469810 (G)pool n = 0xa0 (160), stops adding when fullcars late in the update get no road polygons (I: may fall through)code; they also take ids from 2 (U how long they live)
4Car body pool0x466970: CarCollisionBodySlotPool n=0x1e, slot 0x19030, flags 0xbgrows by n/4+1 = 8 slots (V, G 0x567160)none needed
5World object pool0x466970 n=0x20 (props, not cars)32growsnone
6AI slot pools0x455530 (re_racer_cap_probe, not re-read)26/27/27/640grow (I)optional
7Neighbour list0x57a910, mov [esp+0x4c], 0x10 at 0x57abad (C)16 cars per AI carfarther cars are invisible to that AI (soft)code, not needed
8World car array0x41fe50 (G)array at L+0x28 where L = [0x7361f8], layout room 150 until L+0x280; +0x18 total, +0x24 index of first traffic carnone up to 150none
9LoadedCar pool0x58c3b0 (G), pool [0x734500]40 (docs, I)evicts unused entries, then growsnone
10Model memorynot foundUUU

Not a cap but what really limits the world: placement. Measured 19 placed of 21 asked in WORLD (docs/traffic_placement.md, 31 m spacing +0xd4 and 520 nodes). That is data in the TrackInfo row (host can write it). Per-car sound/skid/shadow pools and model memory were not traced in the time given (U).

Largest count with no patch: 23 traffic (30 - 1 - 6), if placement and the id table allow it. Fewest patches for more: the immediate 0x1e plus (V) a larger array (the static pool ends at RaceStatus 0x78a2f0); the id table then needs 0xde and the two mallocs raised together.

2. VARIETY

Rows (F: carinfo.py, D: game/Cars). Columns: index name usage; skins +0xd9 and ids at +0xc80; weights +0xc60..+0xc70 (districts 0..4). Enable +0x40 is not a flag: it is the first byte of the geometry path ("CARS\NAME\GEOMETRY.BIN", 'C' = 67 in all 35), so 0x57cfa0 accepts every row. Skin test: +0xd9 > 0 (0x57cfa0 skips the Lancer: 0 skins). All 35 have geometry; usage 0 files are 4.7 to 6.2 MB (full tuner models), usage 2 files are 60 to 90 KB (low detail). TEXTURES.BIN of usage 2 cars is 4616 bytes (U where their body texture comes from).

inameuseskinsweights d0..d4traffic now (stock / cave)
0-12, 14-19GOLF FOCUS MIATA NEON CIVIC PEUGOT CELICA ECLIPSE RX7 SUPRA S2000 RSX IMPREZA INTEGRA TIBURON 350Z SENTRA 240SX SKYLINE01 each (id 1)1.0 allstock no; cave: GOLF FOCUS NEON CIVIC PEUGOT CELICA INTEGRA SENTRA at 0.375 each
13LANCER001.0 allnever (no skins)
20TAXI210 0 1 0 1stock no; cave yes
214DR_SEDAN0228 (1-8)1 1 0 1 0yes / yes
22AMBULANCE21all 0never
23TAXI02211 0 0 0 1yes / yes
24PANELVAN26 (1-6)1 1 0 0 0yes / yes
25COUPE280 0 0 1 1stock no; cave yes
26FIRETRUCK21all 0never
27PARCELVAN221 1 0 0 1yes / yes
28PICKUP281 1 0 1 0yes / yes
294DR_SEDAN280 0 1 0 0stock no; cave yes
30BUS23all 0never
31SUV281 1 0 1 0yes / yes
32MINIVAN280 1 0 1 0stock no; cave yes
33HATCHBACK250 0 1 0 1stock no; cave yes
34HATCHBACK02280 0 1 0 1stock no; cave yes

Stock: 6 models (21, 23, 24, 27, 28, 31). Cave: 12 traffic rows + 8 racer rows = 20 models. BUS, AMBULANCE, FIRETRUCK stay 0. The cave's weights were checked against the cave source only, not run.

Pick (V, G): 0x4b3ac0 calls 0x57d000, which sums the weights of the rows 0x57cfa0 returns and walks with a random number. After the pick it scans the entrant list for an entrant kind 0 with the same type; if found it picks again, at most 100 times (local < 100), then accepts the repeat. With 12 cars and only 6 stock types, repeats are certain (more cars than types). With 20 types the re-pick works and repeats fall. Tracks load all models up front: 0x448f70 asks 0x58c3b0 once per entrant (U: whether equal types share one LoadedCar entry). No per-track model list was found; the repeat the OWNER sees is the type table.

Paint (V, G+C): 0x4b3ac0: paint id = byte [row+0xc80 + rand mod [row+0xd9]], Ride_Init(id), 0x57d340 fills the parts, 0x57e9a0 sets ride+0x4c4 to the first part of kind 0x1e. Usage 1 rows use id 1 or 2. Skins per model: 1, 8, 6, 2, 8, 8 for the six stock models (up to 8 for the others). At run time: call 0x569c30(ecx=car, id) (sets [[car+0x10]+7], then 0x56c310). 0x59a7c0 (the teleporter move) ends with 0x59b5d0, which calls 0x59b590 (random id of the same type) and 0x569c30 when it differs: so a recycled car keeps its model, and its colour changes with each move. A different model needs a new car (U). The +0x17 entrant byte is overwritten at placement by 0x5992f0 with 0x59b590 too (G).

3. LIGHTS

Fields (V, G+C): 0x429100 stores them, 0x429190 (every frame, not for human drivers) uses them. Time unit: 0x73ad34 runs at 4000 per second, 0.00025 converts to seconds.

until A + B + C counted from the start (I from the compare order in 0x429190).

when a flash phase and +0x83f, +0x4c (off) otherwise, +0x50 asks if it plays.

(V, scalar scan). +0x855 is also set by the lights key, case 0x9a in 0x431960, for human cars. The draw test 0x5693b0 returns 1 for every traffic car (kind 3), else +0x855 (I: traffic lights may be always on at the draw; U whether a flash is visible).

Call in the game (V, 0x44c2e0 at 0x44c539): ecx = car; stack, last pushed first: gap (+0x840), horn (+0x83f), lights (+0x83e), C, B, A. The game rolls: horn flag is rolled first (probability 1.0 / 0.75 / 0.05 / 0.075 by who the other car is and its relative lane speed); only if the horn flag is set is the lights flag rolled (0.5, or 0.9 when the closing value [slot+4] > 50). A = 0.1..0.5 s (rand * 0.4 + 0.1), B = 0.05..0.25 s, C = 0.1..0.5 s, +0.6 when closing > 50. Trigger: the other car is a human, not traffic and not usage 1 (0x57a6b0), and it is in the traffic car's slot list. The older "within 50 m" is not what the code compares: 50 is tested against slot +4 (a closing speed, per re_traffic_rivals).

To flash and honk from the host: 0x429100 with ecx = traffic car, A = 0.3, B = 0.15, C = 0.3, lights = 1, horn = 1, gap = 1 (chosen values, not game values). It is silently ignored if the last arm is too recent.

Flash visible: one byte (not applied, tools/recomp/patches.py is the orchestrator's)

0x5693b0 (C): cmp [ecx+4],3 / jne +3 / mov al,1 / ret / mov al,[eax+0x855]: a traffic car's head flare is always on (caller 0x56da42 in 0x56d8d0), so 0x429100's lights flag cannot show. Byte 0x5693b7 75 -> eb makes every car read +0x855. host/rivals.c traffic_tick already keeps the base +0x854 at 1 for traffic and at 0 for 48 frames during a flash, so the lights blink. Without the byte nothing changes on screen; the horn works either way.