Stronghold Crusader

From LANCommander
Revision as of 01:31, 1 August 2023 by DoctorDalek (talk | contribs) (Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|Firefly Studios}} |Publishers = {{Game.InfoBox.Publisher|Take-Two Interactive}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|July 31, 2002}} |Genres = {{Game.InfoBox.Genre|Simulator}} {{Game.InfoBox.Genre|Real Time Strategy (RTS)}} {{Game.InfoBox.Genre|Strategy}} | PCGamingWiki = Stronghold_Crusader }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play Stronghold...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Firefly Studios
Publishers
Take-Two Interactive
Release Date
Windows: July 31, 2002
Genres
Simulator

Real Time Strategy (RTS) Strategy

View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play Stronghold: Crusader Extreme Stronghold_Crusader_Extreme.exe True
Play Stronghold: Crusader Stronghold Crusader.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)
}

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

New-Item -ItemType Directory -Force -Path "$($env:USERPROFILE)\Documents\Stronghold Crusader"

Copy-Item -Path "$InstallDir\Default.cfg" -Destination "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusader.cfg"
Copy-Item -Path "$InstallDir\Default.cfg" -Destination "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusaderExtreme.cfg"

Patch-Binary -FilePath "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusader.cfg" -Offset 0x23 -Data $rawBytes
Patch-Binary -FilePath "$($env:USERPROFILE)\Documents\Stronghold Crusader\crusaderExtreme.cfg" -Offset 0x23 -Data $rawBytes