Pax Imperia: Eminent Domain

From LANCommander
Revision as of 01:20, 1 August 2023 by DoctorDalek (talk | contribs) (Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|Heliotrope Studios}} |Publishers = {{Game.InfoBox.Publisher|Heliotrope Studios}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|September 1, 1997}} |Genres = {{Game.InfoBox.Genre|Real Time Strategy (RTS)}} {{Game.InfoBox.Genre|Strategy}} | PCGamingWiki = Pax_Imperia:_Eminent_Domain }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play|Path = Pax Imperia.exe|Argumen...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Heliotrope Studios
Publishers
Heliotrope Studios
Release Date
Windows: September 1, 1997
Genres
Real Time Strategy (RTS)

Strategy

View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play Pax Imperia.exe True

Name Change Script

$NewName = $args[0]
$InstallDir = $PSScriptRoot

function Get-AsciiBytes([string]$InputString, [int]$MaxLength)
{
    if ($InputString.Length -gt $MaxLength)
    {
        $InputString = $InputString.Substring(0, $MaxLength)
    }

    $bytes = [System.Text.Encoding]::ASCII.GetBytes($InputString)
    $array = @()
    $count = 0

    $extraPadding = $MaxLength - $bytes.Length

    foreach ($byte in $bytes)
    {
        if ($count -lt $MaxLength)
        {
            $array += $byte
            $count++
        }
    }

    for ($i = $count; $i -lt $MaxLength; $i++)
    {
        $array += 0x00
    }

    return $array
}

function Patch-Binary([byte[]]$Data, [int]$Offset, [string]$FilePath)
{
    $bytes = [System.IO.File]::ReadAllBytes($FilePath)

    for ($i = 0; $i -lt $Data.Length; $i++)
    {
        $bytes[$Offset + $i] = $Data[$i]
    }

    [System.IO.File]::WriteAllBytes($FilePath, $bytes)
}

$hostNameBytes = Get-AsciiBytes -InputString $newName -MaxLength 31
$nameBytes = Get-AsciiBytes -InputString $newName -MaxLength 16

Patch-Binary -FilePath "$InstallDir\Data\PrefData" -Offset 0x16b -Data $hostNameBytes
Patch-Binary -FilePath "$InstallDir\Data\PrefData" -Offset 0x19e -Data $nameBytes