Commit Graph

106 Commits

Author SHA1 Message Date
Tixx
8a613e0b16 Prevent log spam and simplify code 2026-03-08 17:24:30 +01:00
alex
48d721f602 Harden malformed vehicle packet parsing 2026-03-07 21:23:00 -07:00
Kipstz
31122abe10 Merge branch 'BeamMP:minor' into refactor-string-optimizations 2025-12-28 00:56:24 +01:00
wadyankaw
4a8378427a Add message length validation for chat messages
Right now server only checks if chat message is empty but doesnt check the max length. Client limits to 500 chars but if someone modifies the client they can send huge messages.
I added a check on server side to reject messages longer than 500 characters, same as client limit.
I used translator because I don't know English well
2025-12-28 02:24:08 +03:00
Kipstz
b74f0c7ca8 refactor: optimize string operations and improve code clarity
- Avoid redundant substr() calls in packet parsing hot-path (TServer.cpp)
  The previous code called substr(3) twice per packet, creating
  unnecessary temporary strings. Now stores the result once.

- Replace .size() == 0 with .empty() for idiomatic C++
  (TConsole.cpp, TLuaEngine.cpp)
2025-12-27 23:46:45 +01:00
Tixx
c4c894c1f7 Bump version v3.9.0 2025-10-20 22:41:29 +02:00
Tixx
52a1d9a99e Update vehicle state after paint packet 2025-01-25 22:16:17 +01:00
Tixx
2f577a2358 Store vehicles in parsed json 2025-01-25 22:16:06 +01:00
Tixx
fb2e26bd28 Allow for empty icon param in MP.SendNotification 2024-11-12 12:35:12 +01:00
Tixx
5179ac1fdc Paint packet 2024-10-20 15:38:07 +02:00
Lion Kortlepel
73f494041a fix exception propagation on packet decompression 2024-09-19 16:59:17 +02:00
Lion
63b2a8e4a3 Add post event(s) (#364)
Adds `post*` events which are triggered after the respective `on*` event
has completed and the results have been sent.

They have the same arguments as the `on*` function, with the exception
that another argument is added in the beginning which contains whether
the `on*` variant was cancelled.
2024-09-19 01:37:17 +02:00
Lion Kortlepel
3068a0e5c4 add back car deletion 2024-09-18 16:46:11 +02:00
Lion Kortlepel
f70514a021 add postVehicleEdited
why the fuck is it in past tense
2024-09-18 16:34:56 +02:00
Lion Kortlepel
94768c916d add postChatMessage 2024-09-18 16:30:49 +02:00
Lion Kortlepel
4444be0af9 add postVehicleSpawn event 2024-09-18 16:26:11 +02:00
SaltySnail
0cc73e70c9 fix onVehicleDeleted not being triggered when onVehicleSpawn is triggered 2024-09-15 20:26:20 +02:00
SaltySnail
bfb2086e05 fix all other places where onVehicleDeleted isn't triggered after a delete packet is sent 2024-09-15 20:26:20 +02:00
Lion Kortlepel
e1aaaf5e63 Merge branch 'fix-little-issues' into minor 2024-07-28 10:52:33 +02:00
Lion Kortlepel
28a9690a64 validate Ot packets 2024-06-23 21:58:32 +02:00
Lucca Jiménez Könings
8c15b87628 Refactor all references to settings to use new Settings type
Signed-off-by: Lucca Jiménez Könings <development@jimkoen.com>
2024-05-15 12:52:09 +02:00
Lucca Jiménez Könings
13e641b3a3 Remove interfering legacy code (http,password,etc)
Signed-off-by: Lucca Jiménez Könings <development@jimkoen.com>
2024-05-15 12:45:19 +02:00
Lion Kortlepel
aff537afdf add AGPL-3.0 license header 2024-01-23 21:00:11 +01:00
Lion Kortlepel
023e968302 refactor position packet handling, add regression tests 2024-01-09 15:34:33 +01:00
Lion Kortlepel
a4eb10b6a4 fix MP.GetPositionRaw 2024-01-09 15:34:33 +01:00
Lion Kortlepel
0836fd3af8 fix bug in HandlePosition which caused the vehicle position not to be
saved properly
2024-01-09 15:34:33 +01:00
Lion Kortlepel
a6eb2f7bfe switch to vcpkg+cmake, add debian build to workflows
using lionkor's template (MIT licensed)

This is a combination of 64 commits.
2023-12-05 17:57:19 +01:00
Lion Kortlepel
b10d5d0f4e fix empty events causing issues in the server
an empty event packet, if sent just right, could crash the server
2022-10-31 11:31:15 +01:00
Lion Kortlepel
5581fd1692 fix chat message impersonation issue
instead of using the supplied name, we ignore it entirely and use the
server's internal name for the client
2022-10-31 11:31:15 +01:00
Lion Kortlepel
d36bb7962c ignore empty chat messages
this could happen with a malicious client of some kind, we should simply
ignore them
2022-10-31 11:31:15 +01:00
Lion Kortlepel
4e8bd993d5 remove J packet handler
it wasn't used by anything in the launcher, mod, or during the join
sequence, so i removed it for now.
2022-10-31 11:31:15 +01:00
Lion Kortlepel
abff9bfbdb fix crash when chat message is malformed 2022-10-31 11:31:15 +01:00
Lion Kortlepel
99f41c28cb fix #135 by making onPlayerDisconnect blocking, and calling it before removing the player
before, the handlers were not waited for, so the client was usually
destructed before lua got to the actual event handler call. Now, the
handler is called and waited on, and once all handlers are done, the
client is properly removed from the players internally, thus making
calls to GetPlayerName, GetPlayerIdentifiers, etc. return nil etc.
2022-10-31 11:31:15 +01:00
Lion Kortlepel
87965433c2 change log levels of common warnings and errors to debug
this hides a lot of the "standard" errors we get behind the debug flag.
for example, disconnecting a disconnected player would be such an error
2022-10-15 23:16:16 +02:00
Lion Kortlepel
95ae0f5d03 fix 'Od' and 'Or' packets not being broadcast 2022-10-05 22:17:56 +02:00
Lion Kortlepel
7d2e4d4581 replace tcp networking with boost::asio tcp networking 2022-10-05 18:17:04 +02:00
Lion Kortlepel
5f1d003077 fix various potential crashes in TServer::HandlePosition 2022-10-03 17:06:32 +02:00
Lion Kortlepel
1f14de2e71 revert 9c6127a105 and apply proper fix 2022-10-03 15:11:26 +02:00
Lion Kortlepel
d63c84286e replace logging functions with new fmt versions in ParseVehicle 2022-10-01 22:25:45 +02:00
Lion Kortlepel
9c6127a105 fix bug which may cause a server to crash when a car is spawned
thanks @Anonymous275
2022-10-01 19:10:21 +02:00
Lion Kortlepel
24c98eb2b2 add more compile-time diagnostics, implement fixes for them
Before, a lot of common errors went unnoticed, due to insufficient
compiler diagnostics. This commit fixes this by adding a lot of new
diagnostics, and fixing the issues found by this.
2022-09-26 12:02:05 +02:00
20dka
4b242c26fc optimize function argument passing in GetPidVid, TServer::HandlePosition 2022-09-14 18:53:44 +02:00
20dka
44b94c9e58 add MP.GetPositionRaw(pid, vid)
fix vehicles sometimes not deleting for all players
2022-09-14 01:54:49 +02:00
Lion Kortlepel
d0bb32ec63 cleanup fixme's, todo's 2022-03-24 14:26:02 +01:00
Lion Kortlepel
5180c96e2b TServer::HandleEvent: Fix mistreatment of ':' in event data 2022-03-24 14:06:50 +01:00
Lion Kortlepel
09c9b24cbf Fix Unicycle "infinite spawning" bug 2022-03-10 01:27:16 +01:00
Lion Kortlepel
d969c4a2c2 Use nlohmann/json for IsUnicycle 2022-02-11 10:36:10 +01:00
Lion Kortlepel
f26ca6b40d add nlohmann/json
this will conflict with a change in the http branch, but i dont care
right now
2022-02-11 10:19:10 +01:00
Lion Kortlepel
a1335e8c7d Add statuses, status messages 2021-12-06 13:17:54 +01:00
Lion Kortlepel
eae27633db Add commandline arguments, implement --config, --version, --help 2021-11-26 19:04:21 +01:00