Skip to content

PangyaAPI

Luiz Filho edited this page May 7, 2026 · 1 revision

PangyaAPI — Shared Libraries

← Home | Servers


The PangyaAPI folder contains four libraries reused by all five servers.


PangyaAPI.Network

Networking layer shared by all servers.

Component File Responsibility
Server (abstract) PangyaServer/Server.cs Base class for all TCP servers
Session PangyaSession/Session.cs Represents an active connection
SessionManager PangyaSession/SessionManager.cs Manages all active sessions
Client PangyaSession/Client.cs Connected client abstraction
Cipher Cryptor/Cipher.cs Packet encryption/decryption
CryptoOracle Cryptor/CryptoOracle.cs Public/private key tables
MiniLzo Cryptor/MiniLzo.cs LZO packet compression
Packet PangyaPacket/Packet.cs Binary packet structure
PacketBuffer PangyaPacket/PacketBuffer.cs Packet read/write buffer
ConfigDDos PangyaUtil/ConfigDDos.cs Anti-DDoS configuration and filter
IpDdosFilter PangyaUtil/ConfigDDos.cs IP filter with rate limiting
unit PangyaUnit/unit.cs Asynchronous processing unit
thread PangyaThread/thread.cs Thread management

Packet Encryption

Pangya packets use XOR encryption with public and private key tables (CryptoOracle).

Encrypted packet format:
[salt(1)] [len_low(1)] [len_high(1)] [pad(1)] [public_key(1)] [encrypted_data...]

The server-to-client encryption adds 5 header bytes and applies XOR to the remaining bytes.


PangyaAPI.SQL

Database abstraction layer with support for multiple engines via DbFactory.

Component File Responsibility
Pangya_DB (abstract) Manager/Pangya_DB.cs Base class for all DB commands
DbFactory Manager/DbFactory.cs Creates the correct DB instance
mssql Manager/mssql.cs SQL Server driver via ODBC
mysql Manager/mysql.cs MySQL/MariaDB driver
postgresql Manager/postgresql.cs PostgreSQL (in development)
ctx_db Manager/ctx_db.cs Connection context
Response TYPE/Response.cs Query result object
Result_Set TYPE/Result_Set.cs Set of returned rows
exec_query Manager/exec_query.cs Parameterized query executor

Supported Engines

Engine INI Key Status
SQL Server MSSQL or SQLSERVER ✅ Active
MySQL / MariaDB MYSQL ✅ Active
PostgreSQL POSTGRESQL 🔧 In development

Repository Command Pattern

// Each DB command is a class inheriting Pangya_DB
// Implement prepareConsulta() — builds and executes the stored procedure
// Implement lineResult()      — processes each returned row

var cmd = new CmdPlayerInfo(uid);
cmd.exec();
// result available via cmd properties

The call_db_cmd.log file tracks which commands have been executed to avoid redundant console output.


PangyaAPI.Utilities

General utilities shared by all servers.

Component File Responsibility
IniHandle IniLib.cs .ini config file parser
message_pool Log/message_pool.cs Async log message pool
message Log/message.cs Log message structure
PangyaBinaryReader Models/PangyaBinaryReader.cs Binary packet reader
PangyaBinaryWriter Models/PangyaBinaryWriter.cs Binary packet writer
PangyaSyncTimer PangyaSyncTimer.cs Synchronized event timer
Singleton Singleton.cs Generic singleton pattern
TcpClientEx TcpClientEx.cs TcpClient extension
Tools Tools.cs General utility methods
Translation Translation.cs Server message localization
UtilTime UtilTime.cs Date/time formatting
exception exception.cs Custom PangyaSharp exception

PangyaAPI.IFF.JP

Library for reading Pangya JP's proprietary IFF binary data format. Contains models for all game items.

Model File Description
Character Models/Data/Character.cs Playable characters
ClubSet Models/Data/ClubSet.cs Club sets
Ball Models/Data/Ball.cs Golf balls
Caddie Models/Data/Caddie.cs Caddies (assistants)
Mascot Models/Data/Mascot.cs Mascots
Card Models/Data/Card.cs Special cards
Course Models/Data/Course.cs Golf courses
Item Models/Data/Item.cs General shop items
Part Models/Data/Part.cs Character parts (clothing)
GrandPrixData Models/Data/GrandPrixData.cs Grand Prix data
Achievement Models/Data/Achievement.cs Achievements
Furniture Models/Data/Furniture.cs MyRoom furniture

PangyaAPI.Discord (optional)

Discord webhook integration for server event notifications to a Discord channel.


Next: Database & ODBC Setup

new_logo_v5

Clone this wiki locally