Skip to content
Open

Gta #2691

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
51de469
refactor: update
drazisil May 12, 2025
d8f0465
📝 Add docstrings to `gta` (#2679)
coderabbitai[bot] May 12, 2025
ebd2129
refactor: imports and logging in transactions, login, trackingPing, …
drazisil May 12, 2025
be7a076
fix: improve error handling in deserialize method of BytableByte class
drazisil May 12, 2025
23f6599
feat: add unit tests for BytableBase class and enhance documentation
drazisil May 12, 2025
4939e69
fix: cast query results to UserRecordMini type for improved type safety
drazisil May 12, 2025
3f8173a
refactor: autofix issues in 19 files
deepsource-autofix[bot] May 13, 2025
993ef5a
Merge branch 'dev' into gta
drazisil May 13, 2025
092f0da
fix: remove TypeScript error suppression in SubThread initialization
drazisil May 14, 2025
b28a385
feat: enhance socket data processing and error handling in npsPortRouter
drazisil May 14, 2025
3fd7ba3
Merge branch 'gta' of https://github.com/rustymotors/server into gta
drazisil May 14, 2025
d59ca0a
fix: add missing comma in VSCode settings for proper JSON formatting
drazisil May 14, 2025
93691ed
feat: add unit tests for BinaryMember and BytableCString classes
drazisil May 14, 2025
c2c3d8f
Merge branch 'dev' into gta
drazisil May 14, 2025
1d80c04
chore: update swc and rebuild lockfile
drazisil May 14, 2025
1d5a202
feat: add unit tests for BytableByte class
drazisil May 14, 2025
07ee2f5
Merge branch 'dev' into gta
drazisil May 14, 2025
55b4ea8
feat: implement MockField and MockCStringField with serialization tes…
drazisil May 15, 2025
e2392b1
chore: remove biomejs.biome from VSCode extensions recommendations
drazisil May 15, 2025
441d8fc
chore: update @sentry/profiling-node to version 9.19.0
drazisil May 15, 2025
4668651
refactor: remove unused binary.ts file and its associated functions
drazisil May 15, 2025
c957a1c
test: add unit tests for BytableServerHeader with serialization and d…
drazisil May 15, 2025
1dacf0a
fix: correct formatting and alignment in README.md
drazisil May 15, 2025
f50f23b
fix: ensure node_modules is removed in clean target
drazisil May 15, 2025
effb0e6
refactor: replace NPSHeader with BytableHeader in NPSMessage and rela…
drazisil May 15, 2025
2c23129
test: add unit tests for BytableStructure serialization and deseriali…
drazisil May 15, 2025
155a60e
refactor: update BytableServerHeader methods and add BytableServerMes…
drazisil May 15, 2025
81654ea
Revert "refactor: update BytableServerHeader methods and add BytableS…
drazisil May 15, 2025
207772b
refactor: update project name in CHANGELOG from rusty-motors-shared t…
drazisil May 15, 2025
5906323
fix: correct export type syntax in logger index file
drazisil May 15, 2025
b7d512e
fix: improve alignment function to handle non-positive alignment values
drazisil May 15, 2025
371cc81
refactor: streamline BinaryMember set method to handle padding and si…
drazisil May 15, 2025
7e7a97d
test: update BinaryMember test to handle empty Uint8Array and verify …
drazisil May 15, 2025
54f1967
test: add Uint16_t tests for initialization, value setting, and error…
drazisil May 15, 2025
2dade10
refactor: remove unused CString class and its associated methods from…
drazisil May 15, 2025
382bc39
refactor: clear fields before deserializing and setting body in Bytab…
drazisil May 15, 2025
0413f50
Merge branch 'dev' into gta
drazisil May 15, 2025
13a7a73
chore: add @biomejs/biome to onlyBuiltDependencies in package.json
drazisil May 15, 2025
72dd86e
refactor: improve serialization logic in PersonaRecord class
drazisil May 16, 2025
4680a03
refactor: streamline mcotsPortRouter and enhance data handling with d…
drazisil May 16, 2025
b296a68
refactor: enhance mcotsPortRouter tests with improved logging and soc…
drazisil May 16, 2025
45e98c7
refactor: update import paths to use .js extensions for consistency
drazisil May 16, 2025
c9347e5
refactor: add licensing information and update import paths to use .j…
drazisil May 16, 2025
b23071d
refactor: enhance documentation for BytableServerHeader class with de…
drazisil May 16, 2025
6d8af70
refactor: standardize import statements and enhance utility functions…
drazisil May 16, 2025
69120a0
refactor: add licensing information and standardize comments across m…
drazisil May 16, 2025
fb7f00c
refactor: streamline test setup by introducing utility functions for …
drazisil May 16, 2025
addb69e
refactor: move user lookup to database module
drazisil May 16, 2025
9d469b6
refactor: implement configuration management using config and dotenv …
drazisil May 16, 2025
2931f23
refactor: update VSCode extensions recommendations for improved devel…
drazisil May 17, 2025
28b0a86
refactor: update Node.js version matrix in GitHub Actions workflow
drazisil May 17, 2025
829bf42
refactor: code structure for improved readability and maintainability
drazisil May 17, 2025
6300647
refactor: implement code changes to enhance functionality and improve…
drazisil May 17, 2025
5ac53dc
refactor: simplify test cases for splitPackets function
drazisil May 17, 2025
1a3eb72
refactor: add deprecation notice for Q library in pnpm-lock.yaml
drazisil May 17, 2025
e1bdd3f
test: add unit tests for BytableContainer and BytableShortContainer c…
drazisil May 17, 2025
453e827
refactor: consolidate BytableContainer and BytableShortContainer classes
drazisil May 17, 2025
c6c0938
refactor: enhance BinaryMember tests and add new utility function tests
drazisil May 17, 2025
bbf9937
refactor: migrate byte order utility functions to Endian object and f…
drazisil May 17, 2025
f5d0044
refactor: add mock implementations for deserialize and setMessageLeng…
drazisil May 17, 2025
4cce491
refactor: remove BinaryMember and related utility functions
drazisil May 17, 2025
c070ef9
refactor: replace databaseManager with databaseService and clean up u…
drazisil May 18, 2025
cec54eb
refactor: remove DatabaseManager and its associated functions
drazisil May 18, 2025
0f213e0
refactor: update databaseService methods to async and adjust related …
drazisil May 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ PRIVATE_KEY_FILE=
PUBLIC_KEY_FILE=
SENTRY_DSN=
MCO_LOG_LEVEL=
MCO_LOGGING_GROUPS=
3 changes: 1 addition & 2 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ on:
pull_request:
workflow_dispatch:
merge_group:


jobs:
build-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x, 23.x]
node-version: [22.x, 23.x, 24.x]

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
Expand Down
9 changes: 5 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"recommendations": [
"ms-azuretools.vscode-docker",
"ms-vscode.makefile-tools",
"usernamehw.errorlens",
"biomejs.biome",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"ms-azuretools.vscode-containers",
"kisstkondoros.vscode-codemetrics",
"mhutchie.git-graph",
"vitest.explorer",
"biomejs.biome"
]
}
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Typescript",
"type": "node",
"runtimeExecutable": "pnpx",
"runtimeVersion": "23.5.0",
"request": "launch",
"args": ["src/server.ts"],
"runtimeArgs": [
"tsx",
"--import",
"./instrument.mjs",
"--openssl-legacy-provider"
],
"cwd": "${workspaceRoot}",
"envFile": "${workspaceFolder}/.env",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Stop Prod",
"request": "launch",
Expand Down
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"git.enableCommitSigning": true,
"typescript.tsdk": "node_modules/typescript/lib",
"js/ts.implicitProjectConfig.checkJs": true
"git.enableCommitSigning": true,
"typescript.tsdk": "node_modules/typescript/lib",
"js/ts.implicitProjectConfig.checkJs": true,
"vitest.rootConfig": "vite.config.ts"
}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ docker-init: ## Start the project in docker

.PHONY: clean
clean: ## Clean the project
@rm -rf node_modules -v
@rm -rf */**/node_modules -v
@rm -rf dist -v

Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# mcos

[![Node.js CI](https://github.com/drazisil/mcos/actions/workflows/node.yml/badge.svg?branch=dev)](https://github.com/drazisil/mcos/actions/workflows/node.yml) [![CodeQL](https://github.com/drazisil/mcos/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/drazisil/mcos/actions/workflows/codeql-analysis.yml?branch=dev) [![codecov](https://codecov.io/gh/rustymotors/server/graph/badge.svg?token=XiwYgbHCeN)](https://codecov.io/gh/rustymotors/server) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Node.js CI](https://github.com/drazisil/mcos/actions/workflows/node.yml/badge.svg?branch=dev)](https://github.com/drazisil/mcos/actions/workflows/node.yml) [![CodeQL](https://github.com/drazisil/mcos/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/drazisil/mcos/actions/workflows/codeql-analysis.yml?branch=dev) [![codecov](https://codecov.io/gh/rustymotors/server/graph/badge.svg?token=XiwYgbHCeN)](https://codecov.io/gh/rustymotors/server) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) ![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/rustymotors/server?utm_source=oss&utm_medium=github&utm_campaign=rustymotors%2Fserver&labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews)

## About

Expand All @@ -18,20 +18,21 @@ There's a brief explanation of the thought process here [link](https://github.co

## Server Setup

- See [server docs](./docs/server.md)
- See [server docs](./docs/server.md)
- See [configuration docs](./config/README.md)

## Client Setup

- See [client docs](./docs/client.md)
- See [client docs](./docs/client.md)

## Timeline

- March 6, 2016 - Started
- March 6, 2016 - Started

- October 12, 2023 - Connected to lobby
- October 12, 2023 - Connected to lobby

![img The first non-hacked image of the MCO lobby since it was shutdown](images/2012-10-12_lobby.png)

## Current Status

- [TODO Issues](https://github.com/drazisil/mcos/labels/todo%20%3Aspiral_notepad%3A)
- [TODO Issues](https://github.com/drazisil/mcos/labels/todo%20%3Aspiral_notepad%3A)
82 changes: 82 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Configuration System for Rusty Motors Server

This project uses the [`config`](https://www.npmjs.com/package/config) and [`dotenv`](https://www.npmjs.com/package/dotenv) packages for secure, flexible, and environment-based configuration management.

## How It Works

- **Config Directory:** All configuration files are located in the root-level `config/` directory.
- **Default Values:** The main configuration is in `config/default.json`.
- **Environment Variables:** You can override any config value using environment variables, as mapped in `config/custom-environment-variables.json`.
- **.env Support:** You can also use a `.env` file in the project root to set environment variables for local development.
- **Environment-Specific Config:** You can add files like `config/production.json` or `config/development.json` for environment-specific overrides.

## How to Use

1. **Edit `config/default.json`** to set project-wide defaults (see example below).
2. **Override with environment variables** (e.g., in your shell, CI/CD, or `.env` file):
- Example: `export CERTIFICATE_FILE=/path/to/cert.pem`
3. **(Optional) Add a `.env` file** in the project root for local development:
```env
CERTIFICATE_FILE=./data/mcouniverse.crt
PRIVATE_KEY_FILE=./data/private_key.pem
PUBLIC_KEY_FILE=./data/pub.key
EXTERNAL_HOST=localhost
MCO_LOG_LEVEL=debug
```
4. **(Optional) Add `production.json`, `test.json`, etc.** for environment-specific config.

## Example: `config/default.json`

```json
{
"host": "localhost",
"logLevel": "debug",
"certificateFile": "./data/mcouniverse.crt",
"privateKeyFile": "./data/private_key.pem",
"publicKeyFile": "./data/pub.key"
}
```

## Example: `config/custom-environment-variables.json`

```json
{
"host": "EXTERNAL_HOST",
"logLevel": "MCO_LOG_LEVEL",
"certificateFile": "CERTIFICATE_FILE",
"privateKeyFile": "PRIVATE_KEY_FILE",
"publicKeyFile": "PUBLIC_KEY_FILE"
}
```

## How the Code Loads Config

The code uses the `config` package to load settings. For example:

```typescript
import config from 'config';
const host = config.get<string>('host');
```

Or, using the provided helper:

```typescript
import { getServerConfiguration } from 'rusty-motors-shared';
const config = getServerConfiguration();
console.log(config.host);
```

## Best Practices

- **Never commit secrets** (like private keys) directly to config files. Use environment variables or a secure secrets manager.
- **Document any required config values** for new developers.
- **Check the config/ directory** for all available options and mappings.

## Further Reading

- [node-config documentation](https://github.com/node-config/node-config/wiki/Configuration-Files)
- [dotenv documentation](https://github.com/motdotla/dotenv)

---

For questions, see the project README or ask in the project chat.
7 changes: 7 additions & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"host": "EXTERNAL_HOST",
"logLevel": "MCO_LOG_LEVEL",
"certificateFile": "CERTIFICATE_FILE",
"privateKeyFile": "PRIVATE_KEY_FILE",
"publicKeyFile": "PUBLIC_KEY_FILE"
}
7 changes: 7 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"host": "localhost",
"logLevel": "debug",
"certificateFile": "./data/mcouniverse.crt",
"privateKeyFile": "./data/private_key.pem",
"publicKeyFile": "./data/pub.key"
}
22 changes: 10 additions & 12 deletions instrument.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import * as Sentry from '@sentry/node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';

Sentry.init({
dsn: process.env['SENTRY_DSN'],
integrations: [
// Add our Profiling integration
nodeProfilingIntegration(),
],

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
profilesSampleRate: 1.0, // Profiling sample rate is relative to tracesSampleRate
dsn: process.env['SENTRY_DSN'],
integrations: [
// Add our Profiling integration
nodeProfilingIntegration(),
],

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
profilesSampleRate: 1.0, // Profiling sample rate is relative to tracesSampleRate
});


26 changes: 21 additions & 5 deletions libs/@rustymotors/binary/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
export * from "./lib/Bytable";
export * from "./lib/BytableContainer";
export * from "./lib/BytableDword";
export * from "./lib/BytableHeader";
export * from "./lib/BytableMessage";
// mcos is a game server, written from scratch, for an old game
// Copyright (C) <2017> <Drazi Crendraven>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

export * from './lib/Bytable.js';
export * from './lib/BytableContainer.js';
export * from './lib/BytableDword.js';
export * from './lib/BytableHeader.js';
export * from './lib/BytableMessage.js';
Loading
Loading