Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Dear Guest, You are a regular member, and you cannot download files here. To be able to download all files here, you must become a “Lovely Member.” How to become a Lovely Member? Click this link: 💖 How to Become a “Lovely Member” on Our Forum Alternatively, you can upgrade your account to VIP using this link: Upgrade
🔧 Tools for editing, scripting, and customizing Perfect World servers—forge your own MMORPG realm!
7e96378d-0a37-4b8d-ae87-924733a26e35.webp


Npcgen2CoordData

A small Windows Forms utility for converting Perfect World npcgen.data spawn coordinates into clean coord_data.txt format.​



Overview

Npcgen2CoordData is a small Windows Forms utility that imports mob and resource spawn coordinates from a Perfect World style npcgen.data binary file and merges them into a tab-separated coord_data.txt file used by related server tooling.

The tool provides three main actions through a single form:

  • Load coord_data — read an existing coord_data.txt into memory.
  • Import npcgen.data — select a server maps root folder using FolderBrowserDialog. The tool scans every immediate subfolder for an npcgen.data file, parses each one, and merges mob NpcMobList and resource ResourcesList spawn positions into the loaded coord data, keyed by entity ID.
  • Save coord_data — write the merged result back out as coord_data.txt.

The map or location name is taken from the subfolder name, for example:

Code:
world
a78
a64

Empty files, truncated files, and parse errors are skipped and listed in the final status text.

Long-running file I/O runs on background threads, while progress is reported through the form progress bar and status label.



Stack

  • Language: C# 7.3
  • Framework: .NET Framework 3.5, WinForms
  • Output type: WinExe, AnyCPU
  • Project format: Legacy non-SDK MSBuild .csproj, ToolsVersion="15.0"
  • UI: Windows Forms Classic
  • Package manager: None, only GAC / framework references
  • Solution: Npcgen2CoordData.sln



Requirements

  • Windows with .NET Framework 3.5 SP1 targeting pack installed.
  • Windows feature required: .NET Framework 3.5 includes .NET 2.0 and 3.0.
  • MSBuild shipped with Visual Studio 2017+ or JetBrains Rider.

[WARNING]
Do not build with the legacy compiler:

Code:
C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe

It only supports C# 3.0 and will fail on string interpolation or null-conditional syntax used in the codebase.
[/WARNING]

[NOTE]
Microsoft.VisualBasic is still listed in the project file but is currently unused. It was kept to avoid unnecessary changes to the legacy project file.
[/NOTE]



Build

From the repository root in PowerShell:

Code:
& "C:\Program Files\Microsoft Visual Studio\<edition>\MSBuild\Current\Bin\MSBuild.exe" `
    Npcgen2CoordData\Npcgen2CoordData.csproj /v:m /nologo

Replace <edition> with your installed Visual Studio edition, for example:

Code:
2022\Community

Rider users can open:

Code:
Npcgen2CoordData.sln

Then build directly from the IDE.

Build output:

Code:
Npcgen2CoordData\bin\Debug\Npcgen2CoordData.exe
Npcgen2CoordData\bin\Release\Npcgen2CoordData.exe



Run

Launch the built executable directly:

Code:
.\Npcgen2CoordData\bin\Debug\Npcgen2CoordData.exe

Typical workflow:

  1. Click Load coord_data and pick an existing coord_data.txt. This is optional, you can start empty.
  2. Click Import npcgen.data and select the maps root folder.
  3. The tool scans immediate subfolders, for example:
    Code:
    ...\maps\world\npcgen.data
    ...\maps\a78\npcgen.data
  4. Each subfolder is processed in one pass. The subfolder name becomes the map name in coord_data.txt.
  5. Click Save coord_data to write the merged output.



Entry Point

Code:
Npcgen2CoordData/Program.cs
└── Program.Main
    └── Application.Run(new Form1())

Main UI files:

Code:
Npcgen2CoordData/Form1.cs
Npcgen2CoordData/Form1.Designer.cs
Npcgen2CoordData/Form1.resx



Scripts

This repository ships with:

  • No build scripts
  • No run scripts
  • No package.json
  • No CI configuration

The PowerShell command shown in the Build section is the canonical way to compile from the command line.



Environment Variables

None are read by the application.



Tests

There is currently:

  • No test project
  • No test framework reference
  • No CI

Ad-hoc tests are written as standalone console programs that compile against the production .cs files directly.

High-level test steps:

  1. Create a .cs file at the repo root with static int Main() inside namespace Npcgen2CoordData.
  2. Re-declare the four progress delegates:
    C#:
    SetProgressMax
    SetProgressNext
    SetProgressValue
    SetProgressText
  3. Compile with Roslyn csc.exe from the Visual Studio or Rider MSBuild folder.
  4. Use:
    Code:
    /langversion:7.3
    /target:exe
  5. Include the production source files you want to test, for example:
    Code:
    Npcgen2CoordData\CoordData.cs
  6. Run the produced executable and check $LASTEXITCODE.
  7. Delete the test source and binary afterwards.

[WARNING]
At least ProgressMax and, for CoordData.Read, ProgressText are invoked unconditionally without ?..

Tests must subscribe to those events or they will throw NullReferenceException.
[/WARNING]



Project Structure

Code:
Npcgen2CoordData.sln                  Visual Studio solution
LICENSE                               GNU GPL v3
README.md                             Main documentation
.junie/AGENTS.md                      Contributor notes
Npcgen2CoordData/
├── Npcgen2CoordData.csproj           Legacy-format csproj, net35, WinExe
├── Program.cs                        Application entry point
├── Form1.cs                          Main form + progress delegate types
├── Form1.Designer.cs                 Generated designer code
├── Form1.resx                        Form resources
├── CoordData.cs                      coord_data.txt reader/writer
├── npcgen.cs                         npcgen.data binary reader
├── icon.ico                          App icon
└── Properties/
    ├── AssemblyInfo.cs
    ├── Resources.resx / .Designer.cs
    └── Settings.settings / .Designer.cs



Known Gotchas

  • Culture-sensitive parsing

    CoordData.Read and CoordData.Save assume the current thread culture uses comma as the decimal separator.

    On en-US machines this can throw FormatException.

    Recommended fix:

    C#:
    CultureInfo.InvariantCulture
  • Threading

    Form1 sets:

    C#:
    CheckForIllegalCrossThreadCalls = false;

    The app updates UI from worker threads directly. Do not introduce Invoke or async/await without auditing the whole flow.
  • Binary format versioning

    NpcGen.ReadNpcgen branches on:

    Code:
    Version > 6
    Version > 9
    Version >= 11

    Any additions must also be mirrored in the corresponding write paths, or saved files may become unreadable.
  • Public fields in data-carrier classes

    npcgen.cs reads and writes fields in declaration order. Do not auto-refactor to properties or reorder fields.



License

GNU General Public License v3.0.

See:

Code:
LICENSE



TODO

  • Document the exact npcgen.data binary layout per version.
  • Clarify expected text encoding for fixed-length name fields in npcgen.cs.
  • Add a real automated test project.
  • Confirm minimum supported Windows version.
  • Confirm localization assumptions for coord_data.txt decimal separator.
  • Add screenshots of the main form.
  • Decide whether to remove the unused Microsoft.VisualBasic reference.
Author
hrace009
Downloads
5
Views
742
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from hrace009

Latest updates

  1. 1.1.0 - 2026-05-04

    Inferred SemVer bump: minor — new user-facing features (dynamic objecthandling and batch map...
Back
Top