Lords of the Realm II

From LANCommander
Revision as of 01:15, 1 August 2023 by DoctorDalek (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Impressions Games
Publishers
Rebellion Developments
Release Date
Windows: October 31, 1996
Genres
Turn-based strategy (TBS)

Real Time Strategy (RTS) Strategy Role-playing (RPG)

View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play Lords2.exe True

Name Change Script

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

$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)
}

$rawBytes = Get-AsciiBytes -InputString $newName -MaxLength 16

Patch-Binary -FilePath "$InstallDir\lords2.inf" -Offset 0 -Data $rawBytes