Skip to content
Kelvin edited this page Oct 22, 2023 · 6 revisions

Welcome to the Maple2 wiki!

Dependency Diagram

Maple2_dependency

Development Setup

Prerequisites:

Environment Variables:

- If running via CLI, export `ENV` variables, you can add these to your `.bashrc` or equivalent for future use.
- If running via IDE, these can be set in your Run configurations.
export MS2_ROOT="C:/Nexon/Library/maplestory2/"
export DATA_DB_CONNECTION="Server=localhost;Database=maple-data;User=root;Password=maplestory;oldguids=true"
export DATA_DB_CONNECTION="Server=localhost;Database=maple-data;User=root;Password=maplestory;oldguids=true"
export GAME_DB_CONNECTION="Server=localhost;Database=game-server;User=root;Password=maplestory;oldguids=true"

# Only needed if hosting for external access
export GAME_IP=<GAME_SERVER_IP>
export LOGIN_IP=<LOGIN_SERVER_IP>
export DATA_DB_CONNECTION="Server=localhost;Database=maple-data;User=root;Password=maplestory;oldguids=true"
export GAME_DB_CONNECTION="Server=localhost;Database=game-server;User=root;Password=maplestory;oldguids=true"

# Only needed if hosting for external access
export LOGIN_IP=<LOGIN_SERVER_IP>
export DATA_DB_CONNECTION="Server=localhost;Database=maple-data;User=root;Password=maplestory;oldguids=true"
export GAME_DB_CONNECTION="Server=localhost;Database=game-server;User=root;Password=maplestory;oldguids=true"

# Only needed if hosting for external access
export GAME_IP=<GAME_SERVER_IP>
export GAME_CHANNEL=<GAME_CHANNEL>
export GAME_PORT=<GAME_SERVER_PORT>
export GRPC_CHANNEL_PORT=<GAME_GRPC_CHANNEL_PORT>

Metadata Ingestion (maple-data):

  1. Environment variables should be set as documented above.
  2. dotnet run --project Maple2.File.Ingest or equivalent

If a new table is added, you will need to drop the database and run the ingest tool again.

Game Database Management (game-server):

Before running any dotnet ef commands, you will need to be in the Maple2.Server.World directory and setup your environment variables:

$env:GAME_DB_CONNECTION="Server=localhost;Database=game-server;User=root;Password=maplestory;oldguids=true"
$env:DATA_DB_CONNECTION="Server=localhost;Database=maple-data;User=root;Password=maplestory;oldguids=true"

Initializing the Database:

Using EF Core CLI (running in powershell):

dotnet ef database update

Seeding the Database (game-server):

Run SQL queries in Maple2.Database/sql

Creating a Migration:

When making changes to the schema (Maple2.Database.Model), you will need to generate a migration to apply the changes to existing tables. This can be done by running:

dotnet ef migrations add $NAME

If you need to regenerate the migration, first remove it:

dotnet ef database update $OLD_VERSION
dotnet ef migrations remove

Note: Ensure that Maple2.Server.World/Migrations/Ms2ContextModelSnapshot.cs is also reverted properly. (The tool always seems to mess it up, so you might have to manually revert it through git)

Applying a Migration:

To apply the latest migration, you can again just run:

dotnet ef database update

You can also specify and optional migration name to switch between older versions:

dotnet ef database update $NAME

Running the Server:

Servers should be started in the following order:

  1. Maple2.Server.World
  2. Maple2.Server.Game
  3. Maple2.Server.Login

During development, you will generally just restart the Game server, and occasionally the World server. Doing so should be a safe operation, and all users will be kicked to the login screen.

You can also run the server using docker compose up, but that is not useful during development due to the need for constant restarting.