- 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)
When Acceptor.accept() returns an error (e.g., "Too many open files"),
the server was continuing to process an invalid socket, causing resource
leaks and potential infinite error loops.
Add continue statement to skip processing when accept() fails, allowing
the server to retry on the next iteration instead of crashing.
Fixes resource exhaustion DoS vulnerability where server would enter
error loop instead of handling gracefully.
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
- 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)
This PR implements a new lua function and packet used for sends dialogs
to the client.
## Example:
https://github.com/user-attachments/assets/97bb5813-ea12-4b1d-a049-2f7ebf6b6da3
Example serverside code:
```lua
--MP.ConfirmationDialog(player_id: number, title: string, body: string, buttons: object, interaction_id: string, warning: boolean = false, reportToServer: boolean = true, reportToExtensions: boolean = true)
function onChatMessage(player_id, player_name, message)
MP.ConfirmationDialog(player_id, "Warning", "Watch your tone buddy!!",
{
{
label = "OK",
key = "dialogOK",
isCancel = true
}
}, "interactionID", true)
end
MP.RegisterEvent("onChatMessage", "onChatMessage")
function dialogOK(player_id, interaction_id)
MP.SendChatMessage(-1, MP.GetPlayerName(player_id) .. " clicked OK")
end
MP.RegisterEvent("dialogOK", "dialogOK")
```
### Details:
Each dialog can have multiple buttons, each button having it's own
callback event (`key`).
Each dialog can also have one button with `isCancel` being true,
settings this property to true causes the button's event to be called
when the users pressed `esc` to exit out of the dialog. If a dialog is
created without any button being the cancel button then the user will
only be able to exit the dialog by restarting the session or pressing
one of the buttons.
`interaction_id` will be sent as the event data with a button press
event, to track from which dialog the button press came. As when
multiple dialogs are opened they will stack and it will become difficult
to track what button on which dialog was pressed without having multiple
event handlers.
Waiting on https://github.com/BeamMP/BeamMP/pull/715 to be merged.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
Converts the vehicle stored client side from a raw string to parsed json
data. This allows us to more easily edit the vehicle state serverside,
which I've started using in this PR for updating the state after a paint
packet.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
# Mod database
This PR adds a local database of mods, which is used to cache mod hashes
and protection status.
## Mod hash caching
Mod hashes will now be cached based on last write date. This will speed
up server startup because only the mods with changes will have to be
hashed.
## Mod protection
You can now protect mods! This will allow you to host a server with
copyrighted content without actually hosting the copyrighted content.
Just run `protectmod <filename with .zip> <true/false>` in the console
to protect a mod. Users that join a server with protected mods will have
to obtain the file themselves and put it in their launcher's resources
folder. The launcher will inform the user about this if the file is
missing.
## Mod reloading
You can now reload client mods while the server is running by using
`reloadmods` in the console. Keep in mind that this is mainly intended
for development, therefore it will **not** force client to rejoin and
neither will is hot-reload mods on the client.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
This PR fixes an issue where players would get personal events during
downloads, which would corrupt the download and block the user from
being able to properly join the server.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
Reverts a PR that has been causing sol to crash.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
Add ENV for missing settings.
Issue: https://github.com/BeamMP/BeamMP-Server/issues/414
Please let me know if there are any issues.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
This PR fixes the segfault caused by rapidjson on the first heartbeat,
and the memory leak that happens during mod hashing.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
Just cleaning up some sentry related code, mentions, etc.
---
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.