How Renegades works
Renegades' source code is lost, so everything here was read from the shipped files: each DLL decompiled and
disassembled with Ghidra, the missions run in a stand-in mission host and headless in the real game (OPU 1.3.6, on
which the originals still run), and every finding written up in our own words. Addresses are the game's
(Outpost2.exe 1.2.0.7, which OPU builds on) or the mission DLLs' own, at their base
0x11000000.
Contents: the files · how it took over the game · the menu · the blue look and the R · the music · the mission framework · op2extra.dll · carry-over and "You're cheating!" · Hard mode · the AI · was it made hard to reverse-engineer? · why it crashes · the remake
The files
| File | What it is |
|---|---|
q01.dll-q04.dll | The four missions, as Plymouth campaign missions 1-4. |
ren.vol, ren1.vol, extra.vol | The story, briefings, objectives, chapter titles and credits (as RTF and text); the four maps and tech trees; extra sounds. |
op2mod.dll | The mod's start-up module: adds the .vol files and patches the game (below). |
renshell.dll, renshres.dll | The menu: the game's own shell and its resources, edited. |
ren2res.dll | An edited copy of the game's in-game resources (out2res.dll). |
op2extra.dll | A helper class the missions call for what the mission SDK couldn't do. |
op2ext.dll | The 2006 community extension that loads mods (/loadmod). |
bass.dll, q0N.mo3 | BASS 2.2, a music library, and each mission's music. |
renegmbl.raw | A 156 × 189 picture: the stylised R. |
How it took over the game
The game starts with /loadmod modren. op2ext then runs op2mod.dll, which adds the mod's
.vol files and copies a table of 23 string patches straight into the running game's
data. Among them:
- the menu shell
OP2Shell.dllbecomesRENShell.dll, andout2res.dllbecomesREN2res.dll; - the settings file
outpost2.inibecomesoutpost2.ren, and saved games become.RENfiles; - "Outpost 2" becomes "Renegades" in 13 of the game's texts, and its version reads 1.0.0.0;
- the Plymouth campaign's file name pattern
P%02d.DLLbecomesQ%02d.DLL: one byte, and the game's own campaign now loadsQ01.DLL-Q04.DLL.
Why it only worked on one version. All of this writes to fixed addresses in the game, and the
missions check one of them (next section). OPU 1.4.1's op2ext refuses to load modren at all, so nothing
gets patched: the game loads its own shell and there's no Renegades menu. Under 1.3.6, with Renegades' own op2ext,
it runs.
The blue look and the R
The menu's red controls turn blue because renshres.dll is the game's op2shres.dll with its
art and style strings edited: its button frames (bitmap 236, five 146 × 26 states) are blue where the stock ones
are red; captions and text are green; button labels yellow-green. The main menu's background (bitmap 190) and the
splash logo (bitmap 145) are Renegades' own.
The R in the command pane comes from each mission, not the menu. When a mission DLL loads, its
DllMain reads renegmbl.raw (a 156 × 189 picture) and points an entry of the game's
graphics table (0x4FF814) at it, in place of the Plymouth emblem.
The music
Each mission plays its own q0N.mo3 through BASS 2.2, by replacing five methods of the game's music
manager (around 0x450340-0x450F28). A mission refuses to start unless BASS reports exactly
version 2.2. When a mission is won and unloads, it decodes the next mission's track into music2.wav,
which the menu then plays.
That decoding runs while Windows holds its loader lock, and in our headless runs the game stalled there every time, between a won mission and the next. The music itself came from another game, so the remakes don't use it.
The mission framework
All four missions are built on one framework, compiled into each DLL. InitProc builds the start;
AIProc only runs an event list; everything the mission does after the start happens in its events.
- The menu check. Before anything else, a mission tests whether the byte at
0x4E971Cis aQ:op2mod's one-byte patch. If not, it says "Please run Renegades missions from the Renegades game menu" and stops. - Events. Up to 512, of four kinds: a time (a due tick, and for a repeating one a minimum plus a random part), a unit count, a group's losses (down to three quarters or half), and an area. The runner walks the list newest first; an event made during a pass waits for the next. A one-shot event deletes itself once it fires.
- Errors. Each event runs inside an exception handler; a failure shows "Error executing event" with the event's number and callback address, and the game goes on.
- Saving. The events live in a memory pool (2,048 blocks of 16 bytes) inside the DLL's own
.savesection, which the game saves with the game, so they survive a reload. A save from another build of the DLL gets "Timestamp does not match DLL. This saved game might crash!" - Finding its own save section, the mission opens its own file through
imagehlp, from a path kept in an 80-character buffer.
op2extra.dll
The 1997 mission SDK can't do everything a campaign wants, so Renegades brings its own helper: an
IUnit class with 30 methods, much like the community's later HFL. It works two ways:
- Orders (repair, salvage, dismantle, build, doze and more) are built as the game's own command
packets and handed to the unit owner's packet handler (
0x40E300), as if that player had clicked. - Reads and writes go straight to the game's unit table (
0x54F848, 0x78 bytes a unit): damage, cargo, a factory's bays, whether the lights are on; and flags such as "offensive" and an EMP timer.
Nothing checks that a unit is still alive. The missions use 16 of the 30 methods; Raid alone uses the lights (an attack comes when you first turn them on), the EMP timer (a wrecked Panther) and dozing.
Carry-over and "You're cheating!"
Missions 2-4 start from what you finished the mission before with. When a mission unloads, it writes
Q0N.mis into the game folder: a 32-byte header (the difficulty you played at, your stores and colonists)
and your units, kits and cargo. The next mission builds its start from that file, and won't start without it ("Could
not initialize game").
- Mission 1 writes its file when it was won; mission 3 when it was not won. The test is the other way round in mission 3, so after winning Consequences, Raid has no file to start from, or starts from an older one.
- Raid carries over only your Microwave and Stickyfoam Lynx, spread over eight start slots. With none it can't start at all; with few, the share-out runs past its eight slots onto other tables, and some Lynx start on odd tiles.
- "You're cheating!" The next mission compares the difficulty in the file's header with the one you're playing now. If they differ, it says "You're cheating! Difficulty reset to ..." and plays at the file's difficulty instead. Through the Renegades menu the difficulty can't change between missions, so you'd only see it with a carry-over file from another game.
Hard mode, and what it hides
The missions scale with the difficulty: the colonists you must keep (Relocation fails below 12, 16 or 18), Eden's extra Laser Lynx in Onslaught, how much you must evacuate, how often quakes and meteors come.
Raid is the odd one. It keeps the difficulty twice: as a number, and as three flags (easy, normal, hard). Only the "You're cheating!" branch ever sets the flags. In an honest game all three stay off, so everything gated on them never happens at any difficulty: the Hard flag's second Vehicle Factory, the bigger attack group, a fourth hiding place for the parts and the Panther, the Panther plans in the second factory. The real difficulty still sets Eden's assault size, the escorts and the late reinforcements. The Hard flag's extra start units are checked before the flags can be set, so they never appear at all.
The AI
The computer players are driven entirely by each mission's events, on top of the game's own group AI: building and rebuilding bases piece by piece, mining, raids and attack waves, escorts, scouts, salvage, and a repair AI that sends the closest idle ConVec or repair vehicle to damaged buildings. It's busy: Relocation alone makes about 680,000 calls into the game in 17,000 ticks, mostly looking units up. Consequences sets up 31 groups for its three players.
The remakes copy the framework's event runner, so events fire on the same ticks as the original's, in the same order. Measured side by side in the game, Eden's AI still drifts a little after a while: its factories a cycle early, its trucks a tile apart. Why is still open.
Was it made hard to reverse-engineer?
Not that we found. The four mission DLLs are ordinary C++ builds: no packing, no encryption, no anti-debugging, and
their message texts sit in plain view. (The one packed file is bass.dll, which BASS ships that way.)
What makes Renegades hard to move is how tightly it's tied to one game build:
- patches written into the game at fixed addresses, and a menu check that depends on one of them;
- hooks into the game's music manager, and an exact BASS version;
- a helper DLL that reads and writes the game's unit memory directly;
- carry-over files between missions, and a difficulty check on them;
- and no source.
Why it crashes
- A long install path. The 80-character path buffer: under a long folder name the mission can't find its own file, and crashes at start or on save.
- The mod loader. The
/loadmodstart writes 11 bytes past the end of a memory block. Whether that crashes depends on the machine and the account, which may be why "run it as administrator" sometimes helped. - Winning mission 3 leaves Raid without its carry-over (above), and finishing mission 3 with no Lynx leaves it unable to start.
- Between missions the music decoding can stall the game (above).
- A unit in two groups. The game's
TakeUnitleaves a unit in its old group's list too; removing it from that list later crashes the game. Onslaught does such a removal without checking. - Reused unit ids. A dead unit's id goes to the next unit made, so a mission that keeps the old id gives orders to whatever now holds it. Raid's dozing would order the wrong unit if its dozer died early.
- A saved game holds the mission's code addresses, so it can crash if the DLL loads at another address.
The last two were found when early versions of the remakes crashed the game in long runs; the originals keep their units the same way.
The remake
Each mission is rewritten in OP2Lua (for OPU 1.4.1) from these findings, not from decompiled code, with the same event runner,
numbers and timings, and run against its original in the game, tick by tick. The remakes need none of the old
machinery: no mod loader, no music hooks, no helper DLL. OP2Lua gained the three things the missions took from
op2extra.dll that it lacked (a vehicle's lights, holding fire, and EMP), and a way to play a mission's
own WAV files, for Renegades' voice lines. A new loader stands in for the menu: it draws Renegades' own menu art
and texts from the original renshres.dll and ren.vol, unchanged, starts each mission
through OPU's launcher, and reads the running game to see how the mission ended; then it closes the game and moves
the campaign on.
The in-game look comes back through a small module for OPU's extension loader, in memory only and only for a game
the loader starts: it has the game load Renegades' original ren2res.dll instead of
out2res.dll (the "OP: RENEGADES" title and the blue frames), puts the R in the command pane, and writes
"Renegades" over "Outpost 2" in the game's titles, as op2mod.dll did. It has to rename the file before
the game loads it: OPU starts its modules before the game's own start-up, so swapping the loaded file afterwards gets
overwritten. Renegades' own menu shell doesn't come back: under OPU 1.4.1 the game hung on its way back to it, so the
loader is the menu.