Pax Imperia: Eminent Domain: Difference between revisions

From LANCommander
(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...")
 
No edit summary
 
Line 9: Line 9:
{{Game.InfoBox.ReleaseDate|Windows|September 1, 1997}}
{{Game.InfoBox.ReleaseDate|Windows|September 1, 1997}}
|Genres =
|Genres =
{{Game.InfoBox.Genre|Real Time Strategy (RTS)}}
{{Game.InfoBox.Genre|Real Time Strategy (RTS)}}{{Game.InfoBox.Genre|Strategy}}
{{Game.InfoBox.Genre|Strategy}}
|PCGamingWiki = Pax_Imperia:_Eminent_Domain}}
| PCGamingWiki = Pax_Imperia:_Eminent_Domain
}}


{{Game.ActionBox
{{Game.ActionBox
|Actions =  
|Actions =  
{{Game.ActionBox.Row|Name = Play|Path = Pax Imperia.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Play|Path = {InstallDir}\Pax Imperia.exe|Arguments = |WorkingDirectory = |Primary = True}}
}}
}}


{{Game.Scripts.NameChange
{{Game.Scripts.NameChange
Line 23: Line 22:
|Description =  
|Description =  
|RequiresAdmin = False
|RequiresAdmin = False
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
$NewName = $args[0]
<syntaxhighlight lang="powershell" line>
$InstallDir = $PSScriptRoot
# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases.
 
$hostNameBytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 31 -MinLength 31
function Get-AsciiBytes([string]$InputString, [int]$MaxLength)
$nameBytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 16 -MinLength 16
{
    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
Edit-PatchBinary -FilePath "$InstallDirectory\Data\PrefData" -Offset 0x16b -Data $hostNameBytes
Patch-Binary -FilePath "$InstallDir\Data\PrefData" -Offset 0x19e -Data $nameBytes
Edit-PatchBinary -FilePath "$InstallDirectory\Data\PrefData" -Offset 0x19e -Data $nameBytes
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Latest revision as of 03:29, 6 January 2024

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 {InstallDir}\Pax Imperia.exe True

Name Change Script

# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases.
$hostNameBytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 31 -MinLength 31
$nameBytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 16 -MinLength 16

Edit-PatchBinary -FilePath "$InstallDirectory\Data\PrefData" -Offset 0x16b -Data $hostNameBytes
Edit-PatchBinary -FilePath "$InstallDirectory\Data\PrefData" -Offset 0x19e -Data $nameBytes