Lords of the Realm II: Difference between revisions

From LANCommander
(Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|Impressions Games}} |Publishers = {{Game.InfoBox.Publisher|Rebellion Developments}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|October 31, 1996}} |Genres = {{Game.InfoBox.Genre|Turn-based strategy (TBS)}} {{Game.InfoBox.Genre|Real Time Strategy (RTS)}} {{Game.InfoBox.Genre|Strategy}} {{Game.InfoBox.Genre|Role-playing (RPG)}} | PCGamingWiki = Lords_of_the_Realm_II }} {{Gam...")
 
No edit summary
 
Line 9: Line 9:
{{Game.InfoBox.ReleaseDate|Windows|October 31, 1996}}
{{Game.InfoBox.ReleaseDate|Windows|October 31, 1996}}
|Genres =
|Genres =
{{Game.InfoBox.Genre|Turn-based strategy (TBS)}}
{{Game.InfoBox.Genre|Turn-based strategy (TBS)}}{{Game.InfoBox.Genre|Real Time Strategy (RTS)}}{{Game.InfoBox.Genre|Strategy}}{{Game.InfoBox.Genre|Role-playing (RPG)}}
{{Game.InfoBox.Genre|Real Time Strategy (RTS)}}
|PCGamingWiki = Lords_of_the_Realm_II}}
{{Game.InfoBox.Genre|Strategy}}
{{Game.InfoBox.Genre|Role-playing (RPG)}}
| PCGamingWiki = Lords_of_the_Realm_II
}}


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


{{Game.Scripts.NameChange
{{Game.Scripts.NameChange
Line 25: Line 22:
|Description = The name is stored as the first 16 bytes of the file lords2.inf in ASCII encoding.
|Description = The name is stored as the first 16 bytes of the file lords2.inf in ASCII encoding.
|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.
 
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -MaxLength 16 -MinLength 16
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)
}
 
$rawBytes = Get-AsciiBytes -InputString $newName -MaxLength 16


Patch-Binary -FilePath "$InstallDir\lords2.inf" -Offset 0 -Data $rawBytes
Edit-PatchBinary -FilePath "$InstallDirectory\lords2.inf" -Offset 0x00 -Data $bytes
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Latest revision as of 03:29, 6 January 2024

Developers
Impressions Games
Publishers
Rebellion Developments
Release Date
Windows: October 31, 1996
Genres
Turn-based strategy (TBS)Real Time Strategy (RTS)StrategyRole-playing (RPG)
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\Lords2.exe True

Name Change Script

The name is stored as the first 16 bytes of the file lords2.inf in ASCII encoding.

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

Edit-PatchBinary -FilePath "$InstallDirectory\lords2.inf" -Offset 0x00 -Data $bytes