implement !msg and !help chat commands

* Added the !msg and !help command

* Started fixing issues

* Rewrote !msg processing in chat system

* cleanup

---------

Co-authored-by: p2r3 <p2r3@p2r3.com>
This commit is contained in:
M6a5x98
2025-09-19 00:20:50 +02:00
committed by GitHub
parent ba86dfd927
commit b23e19ecd4
3 changed files with 98 additions and 15 deletions

View File

@@ -125,6 +125,22 @@ int getPlayerData (int client_fd, PlayerData **output) {
return 1;
}
// Returns the player with the given name, or NULL if not found
PlayerData *getPlayerByName (int start_offset, int end_offset, uint8_t *buffer) {
for (int i = 0; i < MAX_PLAYERS; i ++) {
if (player_data[i].client_fd == -1) continue;
int j;
for (j = start_offset; j < end_offset && j < 256 && buffer[j] != ' '; j++) {
if (player_data[i].name[j - start_offset] != buffer[j]) break;
}
if ((j == end_offset || buffer[j] == ' ') && j < 256) {
return &player_data[i];
}
}
return NULL;
}
// Marks a client as disconnected and cleans up player data
void handlePlayerDisconnect (int client_fd) {
// Search for a corresponding player in the player data array