1
0
Fork
You've already forked open_gt_server
0
The base server for the main OpenGT version. Feel free to modify the server as you wish!
  • Go 100%
2025年07月07日 23:26:56 +03:00
database Bug Fixing + Persistent Storage 2025年07月07日 16:03:48 +03:00
handlers Some more inventory bug fixes 2025年07月07日 23:26:56 +03:00
managers Some more inventory bug fixes 2025年07月07日 23:26:56 +03:00
models Some more inventory bug fixes 2025年07月07日 23:26:56 +03:00
repositories Some more inventory bug fixes 2025年07月07日 23:26:56 +03:00
tcp Bug Fixing + Persistent Storage 2025年07月07日 16:03:48 +03:00
utils Bug Fixing + Persistent Storage 2025年07月07日 16:03:48 +03:00
.gitignore Forget the gitignore 2025年06月29日 15:52:45 +03:00
go.mod First Commit 2025年06月29日 15:51:35 +03:00
go.sum First Commit 2025年06月29日 15:51:35 +03:00
main.go Bug Fixing + Persistent Storage 2025年07月07日 16:03:48 +03:00
README.md First Commit 2025年06月29日 15:51:35 +03:00

OpenGT server

OpenGT is a FOSS MMO game designed to be easily distributed and modifiable. OpenGT uses the GPL3 license. That way users can create their own version of the MMO and even run the modified server on their own computer.

Server Architecture

The original OpenGT server is written entirely in golang (together with a PostgreSQL) and employs the repository pattern. Clear code structure enables everyone to understand and modify the server as they wish.

The main data structure of the server is the TCP manager. For now, all the packets arriving and leaving the server use the TCP protocol. This is to change in the future (UDP will be employed for movement packets, beyond others).

Events / Actions

Each "Event" arriving to or from the server is characterized by a unique byte. This byte tells the server which handler can read the message and prepare the appropriate response. We call this magic byte the signature of the event

The TCP manager contains a hashmap that corresponds each event's magic byte to a handler. The "handler" interface is defined in handlers/handler.go and describes the basic structure of each handler

Structure of Byte Arrays

The messages (byte arrays) that arrive to the server differ from the ones leaving to the client.

Structure of messages arriving to the client:

Signature Status Value Length Value ...
1 Byte 1 Byte X Bytes X Bytes ...

As you can see, the first two entries are fixed length. This is the header of the message. Status describes whether the server's response was successful or not. In case of an error, it returns the nature of said error. The possible values of "Status" can be found on utils/message.go.

You may have noticed that the server can't just send values by themselves. Before each value, its size must be stated, so the client can know where to stop reading. We need a way to decipher the messy bytes that the server sends.

The structure of a message that the client sends is almost identical:

Structure of messages arriving to the server:

Signature Value Length Value ...
1 Byte X Bytes X Bytes ...