fuzziqersoftware / newserv

Phantasy Star Online game server, proxy, and reverse-engineering tools
MIT License
159 stars 35 forks source link
game-server phantasy-star-online phantasy-star-online-blue-burst phantasystaronline proxy-server psobb psodc psoep3 psogc psopc psox reverse-engineering

newserv

newserv is a game server, proxy, and reverse-engineering tool for Phantasy Star Online (PSO).

This project includes code that was reverse-engineered by the community in ages long past, and has been included in many projects since then. It also includes some game data from Phantasy Star Online itself, which was originally created by Sega.

Feel free to submit GitHub issues if you find bugs or have feature requests. I'd like to make the server as stable and complete as possible, but I can't promise that I'll respond to issues in a timely manner, because this is a personal project undertaken primarily for the fun of reverse-engineering. If you want to contribute to newserv yourself, pull requests are welcome as well.

See TODO.md for a list of known issues and future work I've curated, or go to the GitHub issue tracker for issues and requests submitted by the community.

Table of contents

History

The history of this project essentially mirrors my development as a software engineer from the beginning of my hobby until now. If you don't care about the story, skip to the "Compatibility" or "Setup" sections below.

I originally purchased PSO GC when I heard about PSUL, and wanted to play around with running homebrew on my GameCube. This pathway eventually led to GCARS-CS, but that's another story.

After playing PSO for a while, both offline and online, I wrote a proxy called Khyps sometime in 2003. This was back in the days of the official Sega servers, where vulnerabilities weren't addressed in a timely manner or at all. It was common for malicious players using their own proxies or Action Replay codes (a story for another time) to send invalid commands that the servers would blindly forward, and cause the receiving clients to crash. These crashes were more than simply inconvenient; they could also corrupt your save data, destroying the hours of work you may have put into hunting items and leveling up your character.

For a while it was essentially necessary to use a proxy to go online at all, so the proxy could block these invalid commands. Khyps was designed primarily with this function in mind, though it also implemented some convenient cheats, like the ability to give yourself or other players infinite HP and allow you to teleport to different places without using an in-game teleporter.

After Khyps I took on the larger challenge of writing a server, which resulted in Khyller sometime in 2005. This was the first server of any type I had ever written. This project eventually evolved into a full-featured environment supporting all versions of the game that I had access to - at the time, PC, GC, and BB. (However, I suspect from reading the ancient source files that Khyller's BB support was very buggy.) As Khyller evolved, the code became increasingly cumbersome, littered with debugging filth that I never cleaned up and odd coding patterns I had picked up over the years. My understanding of the C++ language was woefully incomplete as well (as opposed to now, when it is still incomplete but not woefully so), which resulted in Khyller being essentially a C project that had a couple of classes in it.

Sometime in 2006 or 2007, I abandoned Khyller and rebuilt the entire thing from scratch, resulting in Aeon. Aeon was substantially cleaner in code than Khyller but still fairly hard to work with, and it lacked a few of the more arcane features I had originally written (for example, the ability to convert any quest into a download quest). In addition, the code still had some stability problems... it turns out that Aeon's concurrency primitives were simply incorrect. I had derived the concept of a mutex myself, before taking any real computer engineering classes, but had implemented it incorrectly. I made the race window as small as possible, but Aeon would still randomly crash after running seemingly fine for a few days.

At the time of its inception, Aeon was also called newserv, and you may find some beta releases floating around the Internet with filenames like newserv-b3.zip. I had released betas 1, 2, and 3 before I released the entire source of beta 5 and stopped working on the project when I went to college. This was around the time when I switched from writing software primarily on Windows to primarily on macOS and Linux, so Aeon beta 5 was the last server I wrote that specifically targeted Windows. (newserv, which you're looking at now, is a bit tedious to compile on Windows but does work.)

After a long hiatus from PSO and much professional and personal development in my technical abilities, I was reminiscing sometime in October 2018 by reading my old code archives. Somehow inspired when I came across Aeon, I spent a weekend and a couple more evenings rewriting the entire project again, cleaning up ancient patterns I had used eleven years ago, replacing entire modules with simple STL containers, and eliminating even more support files in favor of configuration autodetection. The code is now suitably modern and stable, and I'm not embarrassed by its existence, as I am by Aeon beta 5's source code and my archive of Khyller (which, thankfully, no one else ever saw).

Other server projects

Independently of this project, there are many other PSO servers out there. Those that I know of that are (or were) public are listed here in approximate chronological order:

Using newserv in other projects

There is a fair amount of code in this project that could potentially be useful to other projects. You are free to use code from newserv in your own open-source projects; the only condition is that the contents of the LICENSE file must be included in your project if you use code from newserv. Your project does not also have to use the MIT license; you can use any license you want.

If you want to use parts of newserv in your project, there are two easy ways to do so with proper licensing:

Compatibility

newserv supports all known versions of PSO, including development prototypes. Specifically: Version Lobbies Games Proxy
DC NTE Yes Yes No
DC 11/2000 Yes Yes No
DC 12/2000 Yes Yes Yes
DC 01/2001 Yes Yes Yes
DC V1 Yes Yes Yes
DC 08/2001 Yes Yes Yes
DC V2 Yes Yes Yes
PC NTE Yes (3) Yes No
PC Yes Yes Yes
GC Ep1&2 NTE Yes Yes Yes
GC Ep1&2 Yes Yes Yes
GC Ep1&2 Plus Yes Yes Yes
GC Ep3 NTE Yes Yes (1) Yes
GC Ep3 Yes Yes Yes
Xbox Ep1&2 Beta Yes Yes Yes
Xbox Ep1&2 Yes Yes Yes
BB (vanilla) Yes Yes (2) Yes
BB (Tethealla) Yes Yes (2) Yes

Notes:

  1. Ep3 NTE battles are not well-tested; some things may not work. See notes/ep3-nte-differences.txt for a list of known differences between NTE and the final version. NTE and non-NTE players cannot battle each other.
  2. Some BB-specific features are not well-tested (for example, some quests that use rare commands may not work properly). Please submit a GitHub issue if you find something that doesn't work.
  3. This is the only version of PSO that doesn't have any way to identify the player's account - there is no serial number or username. For this reason, AllowUnregisteredUsers must be enabled in config.json to support PC NTE, and PC NTE players receive a random Guild Card number every time they connect. To prevent abuse, PC NTE support can be disabled in config.json.

Setup

Server setup

Currently newserv works on macOS, Windows, and Ubuntu Linux. It will likely work on other Linux flavors too.

Windows/macOS

  1. Download the latest release-windows-amd64.zip or release-macos-arm64.zip file from the releases page.
  2. Extract the contents of the release folder to a location on your computer.
  3. Edit the config.example.json file in the system folder as needed, then rename it to config.json.
  4. If you plan to play Blue Burst on newserv, set up the patch directory. See client patch directories for more information.
  5. Run the newserv executable.

Linux

There are currently no precompiled releases for Linux. To run newserv on Linux, see the "Building from source" section below.

Building from source

  1. Install the packages newserv depends on.
    • If you're on Windows, install Cygwin. While doing so, install the cmake, gcc-core, gcc-g++, git, libevent2.1_7, make, libiconv-devel, and zlib packages. Do the rest of these steps inside a Cygwin shell (not a Windows cmd shell or PowerShell).
    • If you're on macOS, run brew install cmake libevent libiconv.
    • If you're on Linux, run sudo apt-get install cmake libevent-dev (or use your Linux distribution's package manager).
  2. Build and install phosg.
  3. Optionally, install resource_dasm. This will enable newserv to send memory patches and load DOL files on PSO GC clients. PSO GC clients can play PSO normally on newserv without this.
  4. Run cmake . && make in the newserv directory.

After building newserv, edit system/config.example.json as needed and rename it to system/config.json, set up client patch directories if you're planning to play Blue Burst, then run ./newserv in newserv's directory.

To use newserv in other ways (e.g. for translating data), see the end of this document.

Client patch directories

newserv implements a patch server for PSO PC and PSO BB game data. Any file or directory you put in the system/patch-bb or system/patch-pc directories will be synced to clients when they connect to the patch server.

For Blue Burst set up, the below is mandatory for a smooth experience:

  1. Browse to your chosen client's data directory.
  2. Copy all the map_*.dat files, unitxt_* files and the data.gsl file and place them in system/patch-bb/data.
  3. If you're using game files from the Tethealla client, make a copy of unitxt_j.prs inside system/patch-bb/data and name it unitxt_e.prs. (If unitxt_e.prs already exists, replace it with the copied file.)

If you do not have a BB client, or using a Tethealla client from another source, Tethealla clients that are compatible with newserv can be found here: English / Japanese. These clients connect to 127.0.0.1 (localhost) automatically.

For BB clients, newserv reads some files out of the patch data to implement game logic, so it's important that certain game files are synchronized between the server and the client. newserv contains defaults for these files in the system/maps/bb-v4 directory, but if these don't match the client's copies of the files, odd behavior will occur in games.

To make server startup faster, newserv caches the modification times, sizes, and checksums of the files in the patch directories. If the patch server appears to be misbehaving, try deleting the .metadata-cache.json file in the relevant patch directory to force newserv to recompute all the checksums. Also, in the case when checksums are cached, newserv may not actually load the data for a patch file until it's needed by a client. Therefore, modifying any part of the patch tree while newserv is running can cause clients to see an inconsistent view of it.

Patch directory contents are cached in memory. If you've changed any of these files, you can run reload patch-indexes in the interactive shell to make the changes take effect without restarting the server.

How to connect

PSO DC

Depending on the version of PSO DC that you have, the instructions to connect to a newserv instance will vary.

If you have NTE, USv1, EUv1, or EUv2 and a Broadband Adapter, edit the broadband DNS address to newserv's IP address with newserv's DNS server running. Otherwise, it is necessary to patch the disc or use a codebreaker code to remove the Hunter License server check and/or redirect PSO to the newserv instance. Patching the disc or creating a codebreaker code is beyond the scope of this document.

PSO DC on Flycast

If you're emulating PSO DC, the NTE, USv1, EUv1, and EUv2 versions will connect to newserv by setting the following options in Flycast's emu.cfg file under [network]:

It is also necessary to save any DNS information to the flash memory of the Dreamcast to use the BBA - the easiest way to do this is to use the website option in USv2 and then choose the save to flash option.

If the server is running on the same machine as Flycast, this might not work, even if you point Flycast's DNS queries at your local IP address (instead of 127.0.0.1). In this case, you can modify the loaded executable in memory to make it connect anywhere you want. There is a script included with newserv that can do this on macOS; a similar technique could be done manually using scanmem on Linux or Cheat Engine on Windows. To use the script, do this:

  1. Build and install memwatch.
  2. Start Flycast and run PSO. (You must start PSO before running the script; it won't work if you run the script before loading the game.)
  3. Run sudo patch_flycast_memory.py <original-destination>. Replace <original-destination> with the hostname that PSO wants to connect to (you can find this out by using Wireshark and looking for DNS queries). The script may take up to a minute; you can continue using Flycast while it runs, but don't start an online game until the script is done.
  4. Run newserv and start an online game in PSO.

If you use this method, you'll have to run the script every time you start PSO in Flycast, but you won't have to run it again if you start another online game without restarting emulation.

If using JPv1, JPv2, or USv2, it is also necessary to remove the Hunter Licence server check, either with a disc patch or codebreaker code. Patching the disc or creating a codebreaker code is beyond the scope of this document.

PSO PC

PSO PC has its connection addresses in pso.exe. Hex edit the executable with the connection address you want to connect to. Common server addresses to search for to replace are:

The version of PSO PC I have has the server addresses starting at offset 0x29CB34 in pso.exe. Change those addresses to "localhost" (without quotes) if you just want to connect to a locally-running newserv instance. Alternatively, you can add an entry to the Windows hosts file (C:\Windows\System32\drivers\etc\hosts) to redirect the connection to 127.0.0.1 (localhost) or any other IP address.

PSO GC on a real GameCube

You can make PSO connect to newserv by setting the default gateway and DNS server addresses in the game's network settings to newserv's address. newserv's DNS server must be running on port 53 and must be accessible to the GameCube. If you're not playing PSO Plus or Episode III, this should be all you need to do, assuming you already set LocalAddress in config.json to your PC's private IP address.

If you have PSO Plus or Episode III, it won't want to connect to a server on the same local network as the GameCube itself, as determined by the GameCube's IP address and subnet mask. There are a couple of ways to get around this.

Sodaboy described a fairly easy method, which is to forward the PSO and DNS ports in your router's configuration to your PC's private IP address (the PSO ports are in config.json, and are all TCP; the DNS port is 53 and is UDP). Then, set LocalAddress and ExternalAddress in config.json to your external IP address (from e.g. whatismyip.com). Most routers will let you connect to your public IP address even from within the local network, but the GameCube will think it's connecting to a different network, so it won't reject the connection. If you're concerned about security and don't want your server to be publicly accessible, you can use Windows Firewall or UFW on Linux block incoming connections on the ports you opened, except for connections from the IP addresses you specify.

Another method is to use two network interfaces on the same PC, and tell the GameCube to connect to the one that appears to be on a different network. For example, if your GameCube is on the 10.0.0.x subnet and your PC's address is 10.0.0.5, you can create a fake network adapter on your PC (or use an existing real one) that has an IP address on a different subnet than the GameCube, such as 192.168.0.8. Then, in PSO's network config, set the default gateway and DNS server addresses to 192.168.0.8, and set LocalAddress in config.json to 192.168.0.8, and PSO should connect. This is what I did back in the old days when I primarily developed software on Windows, but I haven't tried it in many years.

PSO GC on a Wii or Wii U

Using a Wii or Wii U to connect to newserv requires the Wii or vWii to be softmodded. How to do this is beyond the scope of this document.

Nintendont includes BBA emulation and is compatible with all PSO GameCube versions except Episodes I&II Trial Edition. To use Nintendont, enable BBA emulation in Nintendont's settings and follow the instructions in the above section (PSO GC on a real GameCube).

Devolution includes modem emulation and is compatible with all PSO GameCube versions including Episodes I&II Trial Edition. newserv can act as a PPP server, which Devolution can directly connect to. To do this:

  1. Enable the PPPRawListen option according to the comments in config.json.
  2. Start newserv.
  3. In the game's network settings, set the username and password to anything (they cannot be blank), and set the phone number to the number that newserv outputs to the console during startup. (It will be near the end of all the startup log messages.) If your Wii is on the same network as newserv, use the local number; otherwise, use the external number.

PSO GC on Dolphin

If you're using the HLE BBA type, set the BBA's DNS server address to newserv's IP address and it should work. (If newserv is on the same machine as Dolphin, you will need to use an action replay code directed at 127.0.0.1 to connect, as PSO rejects DNS queries from the same IP address.) Set PSO's network settings the same as listed below.

If you're using the TAP BBA type, you'll have to set PSO's network settings appropriately for your tap interface. Set the DNS server address in PSO's network settings to newserv's IP address.

If you're using the tapserver BBA or modem type, you can make it connect to a newserv instance running on the same machine via the tapserver interface. To do this:

  1. In the GameCube pane of the Config window, set the SP1 device to Broadband Adapter (tapserver) or Modem Adapter (tapserver).
  2. Set IPStackListen (for BBA) or PPPStackListen (for modem) according to the comments in config.json and start newserv.
  3. In PSO's network settings, enable DHCP ("Automatically obtain an IP address"), set DNS server address to "Automatic", and leave DHCP Hostname as "Not set". Leave the proxy server settings blank.
  4. Start an online game.

PSO BB

The PSO BB client has been modified and distributed in many different forms. newserv supports most, but not all, of the common distributions. Unlike other versions, it's important that the client and server have the same map files, so make sure to set up the patch directory based on the client you'll be using with newserv. (See the "Client patch directories" section for instructions on setting this up.)

The original Japanese and US versions of PSO BB work with newserv (the last Japanese release can be found here). To get them to connect to your server, do one of the following:

Alternatively, you can use the Tethealla client (English or Japanese). If the server is on the same PC as the client and you don't plan to have any external players, these Tethealla clients will automatically connect to the server without any modifications. This version of the client is not packed, and you can find the connection addresses starting at 0x56D724 in psobb.exe. Overwrite these addresses with your server's hostname or IP address, and you should be able to connect.

Connecting external clients

If you want to accept connections from outside your local network, you'll need to set ExternalAddress to your public IP address in the configuration file, and you'll likely need to open some ports in your router's NAT configuration - specifically, all the TCP ports listed in PortConfiguration in config.json.

For GC clients, you'll have to use newserv's built-in DNS server or set up your own DNS server as well. If you want external clients to be able to use your DNS server, you'll have to forward UDP port 53 to your newserv instance. Remote players can then connect to your server by entering your DNS server's IP address in their client's network configuration.

Server feature configuration

User accounts

By default, newserv does not require users to pre-register before playing; the server will instead automatically create an account the first time each player connects. These accounts have no special permissions. You can view, create, edit, and delete user accounts in the server's shell (run help in the shell to see how to do this).

A license is a set of credentials that a player can use to log in. There are six types of licenses:

On BB, character data is scoped to the license, but system and Guild Card data is scoped to the account. That is, an account with multiple BB licenses can have more than 4 characters (up to 4 per license), but they will all share the same team membership and Guild Card lists.

You may want to give your account elevated privileges. To do so, run update-account ACCOUNT-ID flags=root (replacing ACCOUNT-ID with your actual account-id). You can also use update-account to edit other parts of the account; see the help text for more information.

Installing quests

newserv automatically finds quests in the subdirectories of the system/quests/ directory. To install your own quests, or to use quests you've saved using the proxy's Save Files option, just put them in one of the subdirectories there and name them appropriately. The subdirectories and their behaviors (e.g. in which game modes they should appear and for which PSO versions) is defined in the QuestCategories field in config.json.

Within the category directories, quest files should be named like q###-VERSION-LANGUAGE.EXT (although the q is ignored, and can be any letter). The fields in each filename are:

For .dat files, the LANGUAGE token may be omitted. If it's present, then that .dat file will only be used for that language of the quest; if omitted, then that .dat file will be used for all languages of the quest.

Some quests (mostly battle and challenge mode quests) have additional JSON metadata files that describe how the server should handle them. This includes flags that can be used to hide the quest unless a preceding quest has been cleared, or to hide the quest unless purchased as a team reward. These metadata files are generally named similarly to their .bin and .dat counterparts, except the VERSION token may also be omitted if the metadata applies to all languages of the quest on all PSO versions. See system/quests/battle/b88001.json for documentation on the exact format of the JSON file.

Some quests may also include a .pvr file, which contains an image used in the quest. These files are named similarly to their .bin and .dat counterparts.

For example, the GameCube version of Lost HEAT SWORD is in two files named q058-gc-e.bin and q058-gc.dat. newserv knows these files are quests because they're in the system/quests/ directory, it knows they're for PSO GC because the filenames contain -gc, it knows this is the English version of the quest because the .bin filename ends with -e (even though the .dat filename does not), and it puts them in the Retrieval category because the files are within the retrieval/ directory within system/quests/.

The GameCube and Xbox quest formats are very similar, but newserv treats them as different. If you want to use the same quest file for GameCube and Xbox clients, you can make one a symbolic link to the other.

There are multiple PSO quest formats out there; newserv supports all of them. It can also decode any known format to standard .bin/.dat format. Specifically:

Format Extension Supported Decode action
Compressed .bin and .dat Yes None (1)
Compressed Ep3 .bin or .mnm Yes (4) None (1)
Uncompressed .bind and .datd Yes compress-prs (2)
Uncompressed Ep3 .bind or .mnmd Yes (4) compress-prs (2)
Source .bin.txt and .dat Yes None (5)
VMS (DCv1) .bin.vms and .dat.vms Yes decode-vms
VMS (DCv2) .bin.vms and .dat.vms Decode (3) decode-vms (3)
GCI (decrypted) .bin.gci and .dat.gci Yes decode-gci
GCI (with key) .bin.gci and .dat.gci Yes decode-gci
GCI (no key) .bin.gci and .dat.gci Decode (3) decode-gci (3)
GCI (Ep3 NTE) .bin.gci or .mnm.gci Decode (3) decode-gci (3)
GCI (Ep3) .bin.gci or .mnm.gci Yes decode-gci
DLQ .bin.dlq and .dat.dlq Yes decode-dlq
DLQ (Ep3) .bin.dlq or .mnm.dlq Yes decode-dlq
QST (online) .qst Yes decode-qst
QST (download) .qst Yes decode-qst

Notes:

  1. This is the default format. You can convert these to uncompressed format by running newserv decompress-prs FILENAME.bin FILENAME.bind (and similarly for .dat -> .datd)
  2. Similar to (1), to compress an uncompressed quest file: newserv compress-prs FILENAME.bind FILENAME.bin (and likewise for .datd -> .dat)
  3. Use the decode action to convert these quests to .bin/.dat format before putting them into the server's quests directory. If you know the encryption seed (serial number), pass it in as a hex string with the --seed= option. If you don't know the encryption seed, newserv will find it for you, which will likely take a long time.
  4. Episode 3 quests don't go in the system/quests directory. See the Episode 3 section below.
  5. Quest source can be assembled into a .bin or .bind file with newserv assemble-quest-script FILENAME.txt. See system/quests/retrieval/q058-gc-e.bin.txt for an annotated example; this is the English GameCube version of Lost HEAT SWORD.

Episode 3 download quests consist only of a .bin file - there is no corresponding .dat file. Episode 3 download quest files may be named with the .mnm extension instead of .bin, since the format is the same as the standard map files (in system/ep3/). These files can be encoded in any of the formats described above, except .qst.

When newserv indexes the quests during startup, it will warn (but not fail) if any quests are corrupt or in unrecognized formats.

Quest contents are cached in memory, but if you've changed the contents of the quests directory, you can re-index the quests without restarting the server by running reload quest-index in the interactive shell. The new quests will be available immediately, but any games with quests already in progress will continue using the old versions of the quests until those quests end.

Item tables and drop modes

newserv supports server-side item generation on all game versions, except for the earliest DC prototypes (NTE and 11/2000). By default, the game behaves as it did on the original servers - on all versions except BB, item drops are controlled by the leader client in each game, and on BB, item drops are controlled by the server.

There are five different available behaviors for item drops:

In the SERVER_PRIVATE and SERVER_DUPLICATE modes, there is no incentive to pick up items before another player, since other players cannot pick up the items you see dropped from boxes and enemies. However, if you pick up an item and drop it later, it can then be seen and picked up by any player.

The drop mode can be changed at any time during a game with the $dropmode chat command. If the mode is changed after some items have already been dropped, the existing items retain their visibility (that is, items dropped in private mode still can't be picked up by other players since they were dropped before the mode was changed). You can configure which drop modes are used by default, and which modes players are allowed to choose, in config.json. See the comments above the AllowedDropModes and DefaultDropMode keys.

In the server drop modes, the item tables used to generate common items are in the system/item-tables/ItemPT-* files. (The V2 files are used for V1 as well.) The rare item tables are in the rare-table-*.json files. Unlike the original formats, it's possible to make each enemy drop multiple different rare items at different rates, though the default tables never do this.

Cross-version play

All versions of PSO can see and interact with each other in the lobby. newserv also allows some versions to play in-game with each other:

In V1/V2 cross-version play, when any of the server drop modes are used, the server uses the drop table corresponding to the version the game was created with. (For example, if a DC V1 player created the game, rare-table-v1.json will be used, even after V2 players join.)

Server-side saves

newserv has the ability to save character data on the server side. For PSO BB, this is required of course, but this feature can also be used on other PSO versions.

Each account has 4 BB character slots and 16 non-BB character file slots. The non-BB slots are independent of the BB slots, and can be accessed with the $savechar <slot> and $loadchar <slot> commands (slots are numbered 1 through 16). $savechar copies the character you're currently playing as and saves the data on the server, and $loadchar does the reverse, overwriting your current character with the data saved on the server. Note that you can load a character that was saved from a different version of PSO, which allows you to easily transfer characters between games. On v1 and v2, changes done by $loadchar will be undone if you join a game; to permanently save your changes, disconnect from the lobby after using the command.

There is a third command, $bbchar <username> <password> <slot>, which behaves similarly to $savechar but writes the character data to a BB character slot in a different account instead (slots are numbered 1 through 4). This can be used to "upgrade" a character to BB from an earlier version.

Exactly which data is saved and loaded depends on the game version:

Game Inventory Character Options/chats Quest flags Bank Battle/challenge
PSO DC v1 prototypes Yes Yes No No No N/A
PSO DC v1 Yes Yes No No No N/A
PSO DC v2 Yes Yes Yes Yes Yes Yes
PSO PC (v2) Yes Yes No No No Save only
PSO GC NTE Yes Yes Yes Yes Yes Yes
PSO GC (not Plus) Yes Yes Yes Yes Yes Yes
PSO GC Plus (1) Save only Save only No No No Save only
PSO GC Ep3 (1) No Save only No No No Save only
PSO Xbox Yes Yes Yes Yes Yes Yes
PSO BB Yes Yes Yes Yes Yes Yes

Notes:

  1. If EnableSendFunctionCallQuestNumber is enabled in config.json, then $savechar and $loadchar can save and restore all character data on these versions, just like on GC non-Plus. Episode 3 characters exist in a separate namespace; that is, you can't use $savechar and $loadchar to convert an Ep3 character to non-Ep3, or vice versa.

Episode 3 features

newserv supports many features unique to Episode 3:

Battle records

After playing a battle, you can save the record of the battle with the $saverec command. You can then replay the battle later by using the $playrec command in a lobby - this will create a spectator team and play the recording of the battle as if it were happening in realtime. Note that there is a bug in older versions of Dolphin that seems to be frequently triggered when playing battle records, which causes the emulator to crash with the message QObject::~QObject: Timers cannot be stopped from another thread. To avoid this, use the latest version of Dolphin.

Tournaments

Tournaments work differently than they did on Sega's servers. Tournaments can be created with the create-tournament shell command, which enables players to register for them. (Use help to see all the arguments - there are many!) The start-tournament shell command starts the tournament (and prevents further registrations), but this doesn't schedule any matches. Instead, players who are ready to play their next match can all stand at the 4-player battle table near the lobby warp in the same CARD lobby, and the tournament match will start automatically.

These tournament semantics mean that there can be multiple matches in the same tournament in play simultaneously, and not all matches in a round must be complete before the next round can begin - only the matches preceding each individual match must be complete for that match to be playable.

The Meseta rewards for winning tournament matches can be configured in config.json.

Episode 3 files

Episode 3 state and game data is stored in the system/ep3 directory. The files in there are:

There is no public editor for Episode 3 maps and quests, but the format is described fairly thoroughly in src/Episode3/DataIndexes.hh (see the MapDefinition structure). You'll need to use newserv decompress-prs ... to decompress a .bin or .mnm file before editing it, but you don't need to compress it again to use it - just put the .bind or .mnmd file in the maps directory and newserv will make it available.

Like quests, Episode 3 card definitions, maps, and quests are cached in memory. If you've changed any of these files, you can run reload ep3-cards or reload ep3-maps in the interactive shell to make the changes take effect without restarting the server.

Memory patches, client functions, and DOL files

Everything in this section requires resource_dasm to be installed, so newserv can use the assemblers and disassemblers from its libresource_file library. If resource_dasm is not installed, newserv will still build and run, but these features will not be available.

You can put assembly files in the system/client-functions directory with filenames like PatchName.VERS.patch.s and they will appear in the Patches menu for clients that support client functions. Client functions are written in SH-4, PowerPC, or x86 assembly and are compiled when newserv is started. The assembly system's features are documented in the comments in system/client-functions/System/WriteMemory.ppc.s.

The VERS token in client function filenames refers to the specific version of the game that the client function applies to. Some versions do not support receiving client functions at all. The specific versions are:

Game VERS Architecture
PSO DC NTE 1OJ1 Not supported
PSO DC 11/2000 1OJ2 Not supported
PSO DC 12/2000 1OJ3 Not supported
PSO DC 01/2001 1OJ4 Not supported
PSO DC v1 JP 1OJF Not supported
PSO DC v1 US 1OEF Not supported
PSO DC v1 EU 1OPF Not supported
PSO DC 08/2001 2OJ5 SH-4
PSO DC v2 JP 2OJF SH-4
PSO DC v2 US 2OEF SH-4
PSO DC v2 EU 2OPF SH-4
PSO PC (v2) 2OJW Not supported
PSO GC NTE 3OJT PowerPC
PSO GC v1.2 JP 3OJ2 PowerPC
PSO GC v1.3 JP 3OJ3 PowerPC
PSO GC v1.4 JP 3OJ4 PowerPC
PSO GC v1.5 JP 3OJ5 Not supported
PSO GC v1.0 US 3OE0 PowerPC
PSO GC v1.1 US 3OE1 PowerPC
PSO GC v1.2 US 3OE2 Not supported
PSO GC v1.0 EU 3OP0 PowerPC
PSO GC Ep3 NTE 3SJT PowerPC
PSO GC Ep3 JP 3SJ0 PowerPC
PSO GC Ep3 US 3SE0 Not supported
PSO GC Ep3 EU 3SP0 Not supported
PSO Xbox Beta 4OJB x86
PSO Xbox JP Disc 4OJD x86
PSO Xbox JP TU 4OJU x86
PSO Xbox US Disc 4OED x86
PSO Xbox US TU 4OEU x86
PSO Xbox EU Disc 4OPD x86
PSO Xbox EU TU 4OPU x86
PSO BB JP 1.25.13 51OC x86
PSO BB Tethealla 51OC x86

Note: newserv uses the shorter GameCube versioning convention, where discs labeled DOL-XXXX-0-0Y are version 1.Y. The PSO community seems to use the convention 1.0Y in some places instead, but these are the same version. For example, the version that newserv calls v1.4 is the same as v1.04, and is labeled DOL-GPOJ-0-04 on the underside of the disc.

newserv comes with a set of patches for some of the above versions, based on AR codes originally made by Ralf at GC-Forever and Aleron Ives. Many of them were originally posted in this thread.

You can also put DOL files in the system/dol directory, and they will appear in the Programs menu for GC clients. Selecting a DOL file there will load the file into the GameCube's memory and run it, just like the old homebrew loaders (PSUL and PSOload) did. For this to work, ReadMemoryWord.ppc.s, WriteMemory.ppc.s, and RunDOL.ppc.s must be present in the system/client-functions/System directory. This has been tested on Dolphin but not on a real GameCube, so results may vary.

Like other kinds of data, functions and DOL files are cached in memory. If you've changed any of these files, you can run reload functions or reload dol-files in the interactive shell to make the changes take effect without restarting the server.

I mainly built the DOL loading functionality for documentation purposes. By now, there are many better ways to load homebrew code on an unmodified GameCube, but to my knowledge there isn't another open-source implementation of this method in existence.

Using newserv as a proxy

If you want to play online on remote servers rather than running your own server, newserv also includes a PSO proxy. Currently this works with PSO GC and may work with PC and DC; it also works with some BB clients in specific situations.

To use the proxy for PSO DC, PC, or GC, add an entry to the corresponding ProxyDestinations dictionary in config.json, then run newserv and connect to it as normal (see below). You'll see a "Proxy server" option in the main menu, and you can pick which remote server to connect to.

To use the proxy for PSO BB, set the ProxyDestination-BB entry in config.json. If this option is set, it essentially disables the game server for all PSO BB clients - all clients will be proxied to the specified destination instead. Unfortunately, because PSO BB uses a different set of handlers for the data server phase and character selection, there's no in-game way to present the player with a list of options, like there is on PSO PC and PSO GC.

When you're on PSO DC, PC, or GC and are connected to a remote server through newserv's proxy, choosing the Change Ship or Change Block action from the lobby counter will send you back to newserv's main menu instead of the remote server's ship or block select menu. You can go back to the server you were just on by choosing it from the proxy server menu again.

There are many options available when starting a proxy session. All options are off by default unless otherwise noted. The options are:

The remote server will probably try to assign you a Guild Card number that doesn't match the one you have on newserv. On PSO DC, PC and GC, the proxy server rewrites the commands in transit to make it look like the remote server assigned you the same Guild Card number as you have on newserv, but if the remote server has some external integrations (e.g. forum or Discord bots), they will use the Guild Card number that the remote server believes it has assigned to you. The number assigned by the remote server is shown to you when you first connect to the remote server, and you can retrieve it in lobbies or during games with the $li command.

Some chat commands (see below) have the same basic function on the proxy server but have different effects or conditions. In addition, there are some server shell commands that affect clients on the proxy (run help in the shell to see what they are). If there's only one proxy session open, the shell's proxy commands will affect that session. Otherwise, you'll have to specify which session to affect with the on prefix - to send a chat message in LinkedSession:17205AE4, for example, you would run on 17205AE4 chat ....

Chat commands

newserv supports a variety of commands players can use by chatting in-game. Any chat message that begins with $ is treated as a chat command. (If you actually want to send a chat message starting with $, type $$ instead.) On the DC 11/2000 prototype, @ is used instead of $ for all chat commands, since $ does not appear on the English virtual keyboard.

Some commands only work on the game server and not on the proxy server. The chat commands are:

Using $edit

The $edit command modifies your character data. This command doesn't work on V3 (GameCube/Xbox). If you are on V1 or V2 (DC or PC, not BB), your changes will be undone if you join a game - to save your changes, disconnect from the lobby.

Some subcommands are always available. They are:

The remaining subcommands are only available if cheat mode is enabled on the server. They are:

Non-server features

newserv has many CLI options, which can be used to access functionality other than the game and proxy server. Run newserv help to see a full list of the options and how to use each one.

The data formats that newserv can convert to/from are:

Format Encode/compress action Decode/extract action
PRS compression compress-prs decompress-prs
PR2/PRC compression compress-pr2 decompress-pr2
BC0 compression compress-bc0 decompress-bc0
Raw encrypted data encrypt-data decrypt-data
Episode 3 command mask encrypt-trivial-data decrypt-trivial-data
Challenge Mode rank text encrypt-challenge-data decrypt-challenge-data
PSO DC quest file (.vms) None decode-vms
PSO GC quest file (.gci) None decode-gci
Download quest file (.dlq) None decode-dlq
Server quest file (.qst) encode-qst decode-qst
PSO PC save file encrypt-pc-save decrypt-pc-save
PSO GC save file (.gci) encrypt-gci-save decrypt-gci-save
PSO GC snapshot file None decode-gci-snapshot
Quest script (.bin) assemble-quest-script disassemble-quest-script
Quest map (.dat) None disassemble-quest-map
AFS archive None extract-afs
BML archive None extract-bml
GSL archive None extract-gsl
GVM texture encode-gvm None
Text archive encode-text-archive decode-text-archive
Unicode text set encode-unicode-text-set decode-unicode-text-set
Word Select data set None decode-word-select-set
Set data table None disassemble-set-data-table
Rare item table (AFS/GSL/JSON) convert-rare-item-set convert-rare-item-set

There are several actions that don't fit well into the table above, which let you do other things: