Need for Speed II

From LANCommander
Revision as of 01:18, 1 August 2023 by DoctorDalek (talk | contribs) (Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|EA Canada}} |Publishers = {{Game.InfoBox.Publisher|Electronic Arts}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|March 31, 1997}} |Genres = {{Game.InfoBox.Genre|Simulator}} {{Game.InfoBox.Genre|Racing}} | PCGamingWiki = Need_for_Speed_II }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play|Path = nfs2se-gl2.exe|Arguments = |WorkingDirectory = |Primary = True}}...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
EA Canada
Publishers
Electronic Arts
Release Date
Windows: March 31, 1997
Genres
Simulator

Racing

View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play nfs2se-gl2.exe True

Name Change Script

This script patches the config.dat file found in the user's AppData\Roaming\.nfs2se\config folder that is created by the NFSIISE port created by zaps166. The config file has no checksum so modifying the player names is as simple as patching two locations in the binary.

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

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 8

Patch-Binary -FilePath "$($env:APPDATA)\.nfs2se\config.dat" -Offset 228 -Data $rawBytes
Patch-Binary -FilePath "$($env:APPDATA)\.nfs2se\config.dat" -Offset 428 -Data $rawBytes