48 Commits

Author SHA1 Message Date
fusion32
0ff6217227 add include path for PostgreSQL + overall cleanup
Some distributions place libpq headers under /usr/include/postgresql
which is why it's added to the include path. And even though we don't
support it yet, the same happens with MariaDB, with headers being
placed under /usr/include/mariadb.
2025-10-19 19:17:37 -03:00
fusion32
eba55f8361 update documentation + wrap the few SQLite scripts 2025-10-18 18:21:31 -03:00
fusion32
ebf536a791 properly handle NULL values with postgres result helpers 2025-10-18 03:40:40 -03:00
fusion32
601ce32ee8 modify how automatic SQLite patches/upgrades works + overall cleanup 2025-10-18 02:35:24 -03:00
fusion32
d92f642810 world startup/shutdown timestamps + adjust a few column names 2025-10-17 16:12:31 -03:00
fusion32
63705942a3 properly handle text encoding differences with QueryManager clients 2025-10-16 23:04:00 -03:00
fusion32
01a6e8dbe4 move ResolveHostName outside of GetCharacterEndpoints 2025-10-16 04:23:52 -03:00
fusion32
9825f08f2b prevent a few SQLite queries to fail when they affected no rows
This was done with the old design in mind, but with the query
thread offloading, returning false is meant to signal a failure
in completing it. A connection lost with PostgreSQL or BUSY error
with SQLite, for example.
2025-10-16 02:00:22 -03:00
fusion32
0a82003d87 allow all database config options to be loaded, even when not used 2025-10-16 01:53:03 -03:00
fusion32
95022ca95b lower monotonic uptime resolution from MILLISECONDS to SECONDS
The monotonic uptime was used exclusively with caches and having
a resolution of SECONDS allows it to be stored as an int without
risk of wrapping (~68 years). Using MILLISECONDS meant that it
would wrap after ~25 days which is totally possible and EXPECTED.

  Just as an example, the small test server I ran for about 1 month
had ZERO downtime on the QueryManager except for when I manually
restarted it. It was probably very close to wrapping when I took
it down.
2025-10-16 01:46:10 -03:00
fusion32
b49d7de51c gracefully handle no rows on "COUNT(*)" queries 2025-10-16 01:04:48 -03:00
fusion32
85b75f7737 make config.cfg a distribution template 2025-10-16 00:47:01 -03:00
fusion32
c3b333af90 fix a few postgres queries 2025-10-15 21:41:03 -03:00
fusion32
e89144eb2d implement all postgres queries 2025-10-15 20:27:29 -03:00
fusion32
7a2358c859 postgres interval helpers + a few more queries 2025-10-15 04:13:13 -03:00
fusion32
a4b5623497 make query output parameter names more specific
This also avoids conflicts with database RESULT objects that we lacked
with SQLite but show up with PostgreSQL and MySQL.
2025-10-14 23:24:42 -03:00
fusion32
00d91512b4 GET_WORLD_CONFIG robustness + tidying up a few variable names 2025-10-14 19:15:28 -03:00
fusion32
e1c2920ca2 the remainder of postgres helpers (probably)
This should give us everything we need to implement all the
supported queries.
2025-10-14 18:38:30 -03:00
fusion32
a0f918bf65 more postgres helpers and a couple of queries 2025-10-14 04:19:02 -03:00
fusion32
b1631a7952 most of the postgres primitives/helpers 2025-10-13 19:47:12 -03:00
fusion32
f188d54236 beginning of postgres driver + overall tweaks 2025-10-13 14:56:50 -03:00
fusion32
46c6532933 organize database configs and schema files + compilation guards 2025-10-10 15:22:27 -03:00
fusion32
cc4873e338 switch to blocking poll + fix config, signals, time, non-game login 2025-10-10 02:17:19 -03:00
fusion32
ddcba8ef56 update query functions 2025-10-09 21:36:58 -03:00
fusion32
3faece41a8 small indentation adjustment 2025-10-09 03:59:32 -03:00
fusion32
9f151fa130 update sqlite driver + impl INTERNAL_RESOLVE_WORLD
With this change the game server is able to login again but we
still need to re-implement/re-fit the other queries for it to
properly startup.
2025-10-09 03:45:58 -03:00
fusion32
708bd2e3cf worker initialization robustness + query processing 2025-10-07 23:37:24 -03:00
fusion32
aa31732158 make connections properly handle async queries
This moves queries from `src/connections.cc` to `src/query.cc` and
adds a few missing details. The only thing left is to review query
processing and tie database operations to the `TDatabase` struct.
2025-10-07 18:50:02 -03:00
fusion32
f3c2d53f18 sketch out new query queue/worker for async queries 2025-10-06 19:41:32 -03:00
fusion32
fa22d10a9d fix problem with finishing or excluding from auctions 2025-10-04 12:45:13 -03:00
fusion32
875b584b09 fix RIGHT check with notations and ip banishments 2025-09-13 10:30:50 -03:00
fusion32
748f676ea6 remove ParseOptionalIPAddress
I had just added it in the last commit but it made its use case
non-obvious. Checking whether the string is empty before trying to
parse an IP address is clearer than calling some function that has
its own concept of what an empty address is.
2025-09-13 02:20:28 -03:00
fusion32
5e980ee99a fix queries where the IP address is optional 2025-09-12 23:48:00 -03:00
fusion32
6694516890 add check to make sure the database is open with write permissions
Using `sqlite_open` with `SQLITE_OPEN_READWRITE` doesn't guarantee
the database will be open with read-write permissions.
	- See: https://www.sqlite.org/c3ref/open.html
2025-08-30 22:41:00 -03:00
fusion32
9c29c27aa8 fix player index loading + small service config change 2025-08-18 03:03:47 -03:00
fusion32
7ca3cfca6e wrapping up for a public release 2025-08-15 14:53:56 -03:00
fusion32
20ca1cf661 store world hostname and resolve at runtime 2025-08-08 12:11:36 -03:00
fusion32
634554a0df fix problem with concurrent writes + implement website queries
There was a problem with concurrent writes not being visible
until after restart, due to how cached prepared statements work
with SQLite (see comment in `database.cc`).
2025-08-01 19:23:13 -03:00
fusion32
82b82dca7d improvements and bug fixes
- Add support for SIGINT and SIGTERM signals for graceful termination.
- Properly check premium account status with `EVICT_FREE_ACCOUNTS`
  query.
- Properly check if character is already online before failing game
  login with "too many characters" error.
- Overall cleanup.
2025-07-22 22:22:01 -03:00
fusion32
29f6d814a2 impl LOGIN_ACCOUNT to be used with the login server 2025-07-17 01:02:33 -03:00
fusion32
5463c34177 finish game queries 2025-07-15 23:37:52 -03:00
fusion32
8bc672f711 impl banishment, deaths, and buddies queries 2025-07-14 19:46:36 -03:00
fusion32
c0f9ee43af impl BANISH_ACCOUNT 2025-07-13 13:16:38 -03:00
fusion32
f827fcc848 reorganize query functions and impl SET_NOTATION 2025-07-13 10:04:53 -03:00
fusion32
1cad8468cb house related queries 2025-07-12 20:44:10 -03:00
fusion32
ac41dc912d add TransactionScope 2025-07-11 12:30:22 -03:00
fusion32
3ab6d1d312 implement more queries + overall improvements 2025-07-11 11:55:03 -03:00
fusion32
8dbd1d39e3 bare bones query manager
This is a bare bones query manager that will respond just enough
queries to get the server running. The overall structure of the
tables should be almost set but we'd need to handle all queries to
get the server running properly.
  It uses the SQLite3 3.50.2 amalgamation for a database backend so
we can completely avoid having to spin up yet another service for a
separate database system, effectively turning the query manager into
the database itself. This also means that other services such as the
login server and website must go through it to access the data but
it shouldn't be too difficult to replicate the querying mechanism
from the server.
  This design choice was made with a single game server in mind. The
networking protocol is NOT encrypted at all and won't accept remote
connections. For a fully multi-world distributed infrastructure, a
distributed database system like PostgreSQL and MySQL should be
considered.
2025-07-10 16:57:09 -03:00