Npcgen2CoordData
A small Windows Forms utility for converting Perfect World npcgen.data spawn coordinates into clean coord_data.txt format.
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.txtinto memory. - Import npcgen.data — select a server maps root folder using
FolderBrowserDialog. The tool scans every immediate subfolder for annpcgen.datafile, parses each one, and merges mobNpcMobListand resourceResourcesListspawn 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:
- Click Load coord_data and pick an existing
coord_data.txt. This is optional, you can start empty. - Click Import npcgen.data and select the maps root folder.
- The tool scans immediate subfolders, for example:
Code:...\maps\world\npcgen.data ...\maps\a78\npcgen.data - Each subfolder is processed in one pass. The subfolder name becomes the map name in
coord_data.txt. - 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:
- Create a
.csfile at the repo root withstatic int Main()inside namespaceNpcgen2CoordData. - Re-declare the four progress delegates:
C#:SetProgressMax SetProgressNext SetProgressValue SetProgressText - Compile with Roslyn
csc.exefrom the Visual Studio or Rider MSBuild folder. - Use:
Code:/langversion:7.3 /target:exe - Include the production source files you want to test, for example:
Code:Npcgen2CoordData\CoordData.cs - Run the produced executable and check
$LASTEXITCODE. - 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.ReadandCoordData.Saveassume the current thread culture uses comma as the decimal separator.
Onen-USmachines this can throwFormatException.
Recommended fix:
C#:CultureInfo.InvariantCulture - Threading
Form1sets:
C#:CheckForIllegalCrossThreadCalls = false;
The app updates UI from worker threads directly. Do not introduceInvokeorasync/awaitwithout auditing the whole flow. - Binary format versioning
NpcGen.ReadNpcgenbranches 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.csreads 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.databinary 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.txtdecimal separator. - Add screenshots of the main form.
- Decide whether to remove the unused
Microsoft.VisualBasicreference.