Skip to content

Commit

Permalink
Print chat message from the game module instead of the server
Browse files Browse the repository at this point in the history
  • Loading branch information
smallmodel committed Dec 29, 2024
1 parent 4ec10af commit 2656000
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
26 changes: 26 additions & 0 deletions code/fgame/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10783,10 +10783,29 @@ void Player::EventDMMessage(Event *ev)
return;
}

//
// Added in OPM
//=============
// Print the dm message to console
sToken = "";

for (i = 2; i <= ev->NumArgs(); i++) {
if (i != 2) {
sToken += " ";
}

sToken += ev->GetString(i);
}
//=============

if (iMode == 0) {
//
// everyone
//

// Added in OPM
gi.Printf("%s (%zu) says to everyone: %s\n", client->pers.netname, edict - g_entities, sToken.c_str());

if (!IsSpectator() || g_spectate_allow_full_chat->integer) {
for (i = 0; i < game.maxclients; i++) {
ent = &g_entities[i];
Expand Down Expand Up @@ -10831,6 +10850,10 @@ void Player::EventDMMessage(Event *ev)
//
// team message
//

// Added in OPM
gi.Printf("%s (%zu) says to team: %s\n", client->pers.netname, edict - g_entities, sToken.c_str());

if (IsSpectator()) {
for (i = 0; i < game.maxclients; i++) {
ent = &g_entities[i];
Expand Down Expand Up @@ -10890,6 +10913,9 @@ void Player::EventDMMessage(Event *ev)
return;
}

// Added in OPM
gi.Printf("%s (%zu) says to client #%d: %s\n", client->pers.netname, edict - g_entities, iMode - 1, sToken.c_str());

gi.SendServerCommand(iMode - 1, "%s", szPrintString);

if (ent->entity != this) {
Expand Down
14 changes: 8 additions & 6 deletions code/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1641,12 +1641,14 @@ void SV_ExecuteClientCommand( client_t *cl, const char *s, qboolean clientOK ) {
}
}

// Added in 1.11 MAC server
// Display chat messages
// NOTE: this should be handled by fgame, not server
if (!Q_stricmp(Cmd_Argv(0), "dmmessage")) {
Com_Printf("%s (%zu): %s", cl->name, (size_t)(cl - svs.clients), s);
}
// Removed in OPM
// Message printing is now handled by fgame
//// Added in 1.11 MAC server
//// Display chat messages
//// NOTE: this should be handled by fgame, not server
////if (!Q_stricmp(Cmd_Argv(0), "dmmessage")) {
//// Com_Printf("%s (%zu): %s", cl->name, (size_t)(cl - svs.clients), s);
////}

if (clientOK) {
// pass unknown strings to the game
Expand Down

0 comments on commit 2656000

Please sign in to comment.