55 Commits

Author SHA1 Message Date
fusion32
edea08d11c fix small issue with TransferHouses query 2026-02-09 14:25:21 -03:00
fusion32
6052f24524 fix problem with EvictExGuildleaders query 2026-01-17 00:50:58 -03:00
fusion32
8c2a8461db fix problem with connection input + allow login server to query worlds
There was a small problem with how we computed the size of the
packet "header". It was unlikely to manifest tho, because it's at
the beginning of a TCP message and TCP segments aren't that small,
unless the whole message is that small.
  I'm also allowing login servers to query for world information
to allow a basic form of `STATUS` to be implemented.
2025-11-18 15:17:29 -03:00
fusion32
093e1563df turn error codes into enums + check empty credentials before login
Using enums instead of hard coded numbers for error codes should
help with readability, even though they're local to the functions
that use them to avoid flooding the namespace.
  Checking whether credentials are empty before login will prevent
error messages such as "account disabled" from showing up when no
account is specified, which may look weird. It'll also avoid any
database reads although this shouldn't really make a difference
torwards performance or security since it's only an edge case.
2025-10-30 22:15:57 -03:00
fusion32
d36b26307d prevent password brute force (#4)
Prevent blocked IP addresses and accounts from returning anything
other than a blocked error message. Previously, further attempts
would first check the password which enabled brute force attacks
to use the "invalid account/password" message as an oracle.
2025-10-30 01:03:01 -03:00
fusion32
6aa13394a1 adjust character death indexes for common queries 2025-10-27 21:44:13 -03:00
fusion32
27a0df43b3 change how guild data is stored 2025-10-23 04:26:11 -03:00
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