615 changes: 204 additions & 411 deletions src/console.cpp

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,25 @@ enum CONSOLE_TEXT_JUSTIFICATION

extern char ConsoleString[MAX_CONSOLE_TMP_STRING_LENGTH];

bool addConsoleMessage(const char *Text, CONSOLE_TEXT_JUSTIFICATION jusType, SDWORD player);
bool addConsoleMessage(const char *Text, CONSOLE_TEXT_JUSTIFICATION jusType, SDWORD player, bool team = false);
void updateConsoleMessages(void);
void initConsoleMessages(void);
void removeTopConsoleMessage(void);
void displayConsoleMessages(void);
void displayOldMessages(void);
void flushConsoleMessages(void);
void setConsoleBackdropStatus(bool state);
void enableConsoleDisplay(bool state);
bool getConsoleDisplayStatus(void);
void setConsoleSizePos(UDWORD x, UDWORD y, UDWORD width);
void setConsolePermanence(bool state, bool bClearOld);
bool mouseOverConsoleBox(void);
UDWORD getNumberConsoleMessages(void);
int getNumberConsoleMessages(void);
void setConsoleLineInfo(UDWORD vis);
UDWORD getConsoleLineInfo(void);
void permitNewConsoleMessages(bool allow);
void toggleConsoleDrop(void);
void setHistoryMode(bool mode);

#if defined(DEBUG)
# define debug_console(...) \
Expand Down
10 changes: 3 additions & 7 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ void processInput(void)
ignoreRMBC = false;

/* Process all of our key mappings */
mouseOverConsole = mouseOverConsoleBox();
if (mousePressed(MOUSE_WUP) && !isMouseOverRadar())
{
/* Ctrl+Alt+WheelUp makes game speed up */
Expand All @@ -467,7 +468,7 @@ void processInput(void)
{
kf_BuildPrevPage();
}
else
else if (!mouseOverConsole)
{
kf_ZoomInStep();
}
Expand All @@ -484,7 +485,7 @@ void processInput(void)
{
kf_BuildNextPage();
}
else
else if (!mouseOverConsole)
{
kf_ZoomOutStep();
}
Expand All @@ -500,11 +501,6 @@ void processInput(void)
/* Run all standard mappings */
keyProcessMappings(false);
}
else
{
kf_SendTextMessage(); // process multiplayer chat message.
}

/* Allow the user to clear the console if need be */
mouseOverConsole = mouseOverConsoleBox();
if (mouseOverConsole && mousePressed(MOUSE_LMB))
Expand Down
26 changes: 0 additions & 26 deletions src/display3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,28 +456,6 @@ static PIELIGHT structureBrightness(STRUCTURE *psStructure)
return buildingBrightness;
}

/// Display the multiplayer chat box
static void displayMultiChat(void)
{
iV_SetFont(font_regular);

UDWORD pixelLength;
UDWORD pixelHeight;

pixelLength = iV_GetTextWidth(sTextToSend);
pixelHeight = iV_GetTextLineSize();

if ((realTime % 500) < 250)
{
// implement blinking cursor in multiplayer chat
pie_BoxFill(RET_X + pixelLength + 3, 474 + E_H - (pixelHeight / 4), RET_X + pixelLength + 10, 473 + E_H, WZCOL_CURSOR);
}

/* FIXME: GET RID OF THE MAGIC NUMBERS BELOW */
iV_TransBoxFill(RET_X + 1, 474 + E_H - pixelHeight, RET_X + 1 + pixelLength + 2, 473 + E_H);

iV_DrawText(sTextToSend, RET_X + 3, 469 + E_H);
}

/// Show all droid movement parts by displaying an explosion at every step
static void showDroidPaths(void)
Expand Down Expand Up @@ -766,10 +744,6 @@ void draw3DScene(void)
iV_SetTextColour(WZCOL_TEXT_BRIGHT);

/* Dont remove this folks!!!! */
if (!bAllowOtherKeyPresses)
{
displayMultiChat();
}
if (errorWaiting)
{
// print the error message if none have been printed for one minute
Expand Down
5 changes: 3 additions & 2 deletions src/displaydef.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
#include "lib/ivis_opengl/imd.h"
#include "lib/ivis_opengl/pieclip.h"

#define BOUNDARY_X (22)
#define BOUNDARY_Y (22)
// for mouse scrolling. (how many pixels from the edge before pointer scrolls the screen in a direction)
#define BOUNDARY_X (2)
#define BOUNDARY_Y (2)

struct SCREEN_DISP_DATA
{
Expand Down
89 changes: 89 additions & 0 deletions src/hci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include "lib/widget/label.h"
#include "lib/widget/bar.h"
#include "lib/widget/button.h"
#include "lib/widget/editbox.h"
#include "cheat.h"
#include "console.h"
#include "design.h"
#include "display.h"
Expand Down Expand Up @@ -82,13 +84,16 @@
#include "wrappers.h"
#include "keybind.h"
#include "qtscript.h"
#include "frend.h"

// Is a button widget highlighted, either because the cursor is over it or it is flashing.
//
#define buttonIsHilite(p) ((p->getState() & WBUT_HIGHLIGHT) != 0)

// Empty edit window
static bool SecondaryWindowUp = false;
// Chat dialog
static bool ChatDialogUp = false;

#define RETXOFFSET (0)// Reticule button offset
#define RETYOFFSET (0)
Expand Down Expand Up @@ -1350,6 +1355,30 @@ INT_RETVAL intRunWidgets(void)
quitting = true;
break;

// process our chatbox
case CHAT_EDITBOX:
{
const char *msg2 = widgGetString(psWScreen, CHAT_EDITBOX);
int mode = (int) widgGetUserData2(psWScreen, CHAT_EDITBOX);
if (strlen(msg2))
{
attemptCheatCode(msg2); // parse the message
if (mode == CHAT_TEAM)
{
sendTeamMessage(msg2);
}
else
{
sendTextMessage(msg2, false);
}
}
inputLoseFocus();
bAllowOtherKeyPresses = true;
widgDelete(psWScreen, CHAT_CONSOLEBOX);
ChatDialogUp = false;
break;
}

/* Default case passes remaining IDs to appropriate function */
default:
switch (intMode)
Expand Down Expand Up @@ -5175,3 +5204,63 @@ bool CoordInBuild(int x, int y)

return true;
}

// Our chat dialog for global & team communication
// \mode sets if global or team communication is wanted
void chatDialog(int mode)
{
static WIDGET *parent = psWScreen->psForm;
static IntFormAnimated *consoleBox = NULL;
static W_EDITBOX *chatBox = NULL;
static W_CONTEXT sContext;

if (!ChatDialogUp)
{
consoleBox = new IntFormAnimated(parent);
consoleBox->id = CHAT_CONSOLEBOX;
consoleBox->setGeometry(CHAT_CONSOLEBOXX, CHAT_CONSOLEBOXY, 300, CHAT_CONSOLEBOXH);

chatBox = new W_EDITBOX(consoleBox);
chatBox->id = CHAT_EDITBOX;
chatBox->setGeometry(10, 28, 280, 20);
if (mode == CHAT_GLOB)
{
chatBox->setBoxColours(WZCOL_MENU_BORDER, WZCOL_MENU_BORDER, WZCOL_MENU_BACKGROUND);
widgSetUserData2(psWScreen, CHAT_EDITBOX, CHAT_GLOB);
}
else
{
chatBox->setBoxColours(WZCOL_YELLOW, WZCOL_YELLOW, WZCOL_MENU_BACKGROUND);
widgSetUserData2(psWScreen, CHAT_EDITBOX, CHAT_TEAM);
}
sContext.xOffset = sContext.yOffset = 0;
sContext.mx = sContext.my = 0;

W_LABEL *label = new W_LABEL(consoleBox);
label->setGeometry(12, 10, 100, 12);
if (mode == CHAT_GLOB)
{
label->setFontColour(WZCOL_TEXT_BRIGHT);
label->setString(_("Chat: Global"));
}
else
{
label->setFontColour(WZCOL_YELLOW);
label->setString(_("Chat: Team"));
}
label->setTextAlignment(WLAB_ALIGNTOPLEFT);
ChatDialogUp = true;
}
else
{
debug(LOG_ERROR, "Tried to throw up chat dialog when we already had one up!");
}
// Auto-click it
widgGetFromID(psWScreen, CHAT_EDITBOX)->clicked(&sContext);
}

// Helper call to see if we have builder/research/... window up or not.
bool GetSecondaryWindowUp(void)
{
return SecondaryWindowUp;
}
27 changes: 20 additions & 7 deletions src/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


#define BASE_COORDS_X (640)
#define BASE_COORDS_Y (480)
#define BASE_COORDS_Y (460)
#define E_W (pie_GetVideoBufferWidth() - BASE_COORDS_X)
#define E_H (pie_GetVideoBufferHeight() - BASE_COORDS_Y)
#define D_W ((pie_GetVideoBufferWidth() - BASE_COORDS_X)/2)
Expand Down Expand Up @@ -102,15 +102,25 @@
#define IDSTAT_ALLYEND 5100

// Reticule position.
#define RET_X 24
#define RET_X 6
#define RET_Y (324+E_H)
#define RET_FORMWIDTH 132
#define RET_FORMHEIGHT 132

// chat stuff
#define CHAT_CONSOLEBOX 0x4A001
#define CHAT_EDITBOX 0x4A004
#define CHAT_TEAM 0x1
#define CHAT_GLOB 0x2
#define CHAT_CONSOLEBOXX RET_X + RET_FORMWIDTH + D_W
#define CHAT_CONSOLEBOXY (RET_Y)
#define CHAT_CONSOLEBOXW 160
#define CHAT_CONSOLEBOXH 54

/* Option positions */
#define OPT_GAP 5

// Object screen position.
// Object screen position. (aka where the factories, research builds show up) [right of command retile]
#define BASE_GAP 6
#define OBJ_BACKX (RET_X + RET_FORMWIDTH + BASE_GAP + D_W) // X coord of object screen back form.
#define OBJ_BACKY RET_Y // Y coord of object screen back form.
Expand Down Expand Up @@ -144,11 +154,11 @@
#define CLOSE_HEIGHT 15
#define CLOSE_SIZE 15

// Stat screen position.
#define STAT_X 23
#define STAT_Y (45 + E_H)
// Stat screen position. [aka, the 'dialog' of items you research/create]
#define STAT_X 6
#define STAT_Y (E_H)
#define STAT_WIDTH RET_FORMWIDTH // Width of the tab form.
#define STAT_HEIGHT 273 // Height of the tab form.
#define STAT_HEIGHT 322 // Height of the tab form.
#define STAT_TABWIDTH 15
#define STAT_TABFORMX 0 // Offset of the tab form within the main form.
#define STAT_TABFORMY 18 // Offset of the tab form within the main form.
Expand Down Expand Up @@ -375,4 +385,7 @@ extern void intDemolishCancel(void);

StateButton *makeObsoleteButton(WIDGET *parent); ///< Makes a button to toggle showing obsolete items.

extern void chatDialog(int mode);
extern bool GetSecondaryWindowUp(void);

#endif // __INCLUDED_SRC_HCI_H__
118 changes: 33 additions & 85 deletions src/keybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,16 @@ void kf_ToggleConsoleDrop(void)
{
if (!bInTutorial)
{
setHistoryMode(false);
toggleConsoleDrop();
}
}

void kf_ToggleTeamChat(void)
{
if (!bInTutorial)
{
setHistoryMode(true);
toggleConsoleDrop();
}
}
Expand Down Expand Up @@ -2001,87 +2011,38 @@ void kf_ShowGridInfo(void)
}
}
#endif

// --------------------------------------------------------------------------
// Chat message. NOTE THIS FUNCTION CAN DISABLE ALL OTHER KEYPRESSES
void kf_SendTextMessage(void)
void kf_SendTeamMessage(void)
{
UDWORD ch;
utf_32_char unicode;

if (bAllowOtherKeyPresses) // just starting.
if (bAllowOtherKeyPresses) // just starting.
{
bAllowOtherKeyPresses = false;
sstrcpy(sTextToSend, "");
sstrcpy(sCurrentConsoleText, ""); //for beacons
sstrcpy(sCurrentConsoleText, ""); //for beacons
inputClearBuffer();
StartTextInput();
chatDialog(CHAT_TEAM); // throw up the dialog
}

ch = inputGetKey(&unicode);
while (ch != 0) // in progress
else
{
// FIXME: Why are we using duplicate defines? INPBUF_CR == KEY_RETURN == SDLK_RETURN

// Kill if they hit return or keypad enter or it maxes out console or it's more than one line long
// NOTE: here is where we would start SDL_StartTextInput() if we were to use SDL's UTF input
// (also, perhaps make the chat key configurable?)
if ((ch == INPBUF_CR) || (ch == KEY_KPENTER) || (strlen(sTextToSend) >= MAX_CONSOLE_STRING_LENGTH - 16) // Prefixes with ERROR: and terminates with '?'
|| iV_GetTextWidth(sTextToSend) > (pie_GetVideoBufferWidth() - 64)) // sendit
{
bAllowOtherKeyPresses = true;
// flushConsoleMessages();

sstrcpy(sCurrentConsoleText, ""); //reset beacon msg, since console is empty now

// don't send empty lines to other players
if (!strcmp(sTextToSend, ""))
{
return;
}

//console callback message
//--------------------------
ConsolePlayer = selectedPlayer;
sstrcpy(ConsoleMsg, sTextToSend);
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_CONSOLE);

sendTextMessage(sTextToSend, false);
attemptCheatCode(sTextToSend);
StopTextInput();
return;
}
else if (ch == INPBUF_BKSPACE) // delete
{
if (sTextToSend[0] != '\0') // cant delete nothing!
{
size_t newlen = strlen(sTextToSend) - 1;
while (newlen > 0 && (sTextToSend[newlen] & 0xC0) == 0x80)
{
--newlen; // Don't delete half a unicode character.
}
sTextToSend[newlen] = '\0';
sstrcpy(sCurrentConsoleText, sTextToSend); //beacons
}
}
else if (ch == INPBUF_ESC) //abort.
{
bAllowOtherKeyPresses = true;
sstrcpy(sCurrentConsoleText, "");
StopTextInput();
// flushConsoleMessages();
return;
}
else // display
{
const utf_32_char input_char[2] = { unicode, '\0' };
char *utf = UTF32toUTF8(input_char, NULL);
sstrcat(sTextToSend, utf);
free(utf);
sstrcpy(sCurrentConsoleText, sTextToSend);
}
bAllowOtherKeyPresses = true;
}
}

ch = inputGetKey(&unicode);
// Chat message. NOTE THIS FUNCTION CAN DISABLE ALL OTHER KEYPRESSES
void kf_SendGlobalMessage(void)
{
if (bAllowOtherKeyPresses) // just starting.
{
bAllowOtherKeyPresses = false;
sstrcpy(sTextToSend, "");
sstrcpy(sCurrentConsoleText, ""); //for beacons
inputClearBuffer();
chatDialog(CHAT_GLOB); // throw up the dialog
}
else
{
bAllowOtherKeyPresses = true;
}

// macro store stuff
Expand All @@ -2094,8 +2055,6 @@ void kf_SendTextMessage(void)
else
{
sstrcpy(sTextToSend, ingame.phrases[0]);
bAllowOtherKeyPresses = true;
// flushConsoleMessages();
sendTextMessage(sTextToSend, false);
return;
}
Expand All @@ -2109,8 +2068,6 @@ void kf_SendTextMessage(void)
else
{
sstrcpy(sTextToSend, ingame.phrases[1]);
bAllowOtherKeyPresses = true;
// flushConsoleMessages();
sendTextMessage(sTextToSend, false);
return;
}
Expand All @@ -2124,8 +2081,6 @@ void kf_SendTextMessage(void)
else
{
sstrcpy(sTextToSend, ingame.phrases[2]);
bAllowOtherKeyPresses = true;
// flushConsoleMessages();
sendTextMessage(sTextToSend, false);
return;
}
Expand All @@ -2139,8 +2094,6 @@ void kf_SendTextMessage(void)
else
{
sstrcpy(sTextToSend, ingame.phrases[3]);
bAllowOtherKeyPresses = true;
// flushConsoleMessages();
sendTextMessage(sTextToSend, false);
return;
}
Expand All @@ -2154,17 +2107,12 @@ void kf_SendTextMessage(void)
else
{
sstrcpy(sTextToSend, ingame.phrases[4]);
bAllowOtherKeyPresses = true;
// flushConsoleMessages();
sendTextMessage(sTextToSend, false);
return;
}
}

// flushConsoleMessages(); //clear
// addConsoleMessage(sTextToSend,DEFAULT_JUSTIFY, SYSTEM_MESSAGE); //display
// iV_DrawText(sTextToSend,16+D_W,RADTLY+D_H-16);
}

// --------------------------------------------------------------------------
void kf_ToggleConsole(void)
{
Expand Down
4 changes: 3 additions & 1 deletion src/keybind.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@ extern void kf_ChooseCancel(void);
extern void kf_ToggleWeather(void);
extern void kf_KillSelected(void);
extern void kf_ShowGridInfo(void);
extern void kf_SendTextMessage(void);
extern void kf_SendGlobalMessage(void);
extern void kf_SendTeamMessage(void);
extern void kf_SelectPlayer(void);
extern void kf_ToggleDrivingMode(void);
extern void kf_ToggleConsole(void);
extern void kf_ToggleTeamChat(void);
extern void kf_SelectAllOnScreenUnits(void);
extern void kf_SelectAllUnits(void);
extern void kf_SelectAllVTOLs(void);
Expand Down
15 changes: 8 additions & 7 deletions src/keymap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ _keymapsave keyMapSaveTable[] =
kf_ToggleRadar,
kf_ToggleConsole,
kf_ToggleEnergyBars,
kf_NOOP,
kf_ToggleTeamChat,
kf_ScreenDump ,
kf_MoveToLastMessagePos,
kf_AssignGrouping_1,
Expand Down Expand Up @@ -166,8 +166,8 @@ _keymapsave keyMapSaveTable[] =
kf_SetDroidMovePatrol ,
kf_SetDroidGoForRepair ,
kf_SetDroidOrderHold,
kf_SendTextMessage,
kf_NOOP,
kf_SendGlobalMessage,
kf_SendTeamMessage,
kf_ScatterDroids,
kf_SetDroidRetreatMedium,
kf_SetDroidRetreatHeavy,
Expand Down Expand Up @@ -392,7 +392,8 @@ void keyInitMappings(bool bForceDefaults)
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, (KEY_CODE)KEY_MAXSCAN, KEYMAP_PRESSED, kf_JumpToSensorUnits, N_("View next Sensor Unit"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, (KEY_CODE)KEY_MAXSCAN, KEYMAP_PRESSED, kf_JumpToCommandUnits, N_("View next Commander"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_TAB, KEYMAP_PRESSED, kf_ToggleOverlays, N_("Toggle Overlays"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_BACKQUOTE, KEYMAP_PRESSED, kf_ToggleConsoleDrop, N_("Console On/Off"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_BACKQUOTE, KEYMAP_PRESSED, kf_ToggleConsoleDrop, N_("Toggle Console History "));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_BACKQUOTE, KEYMAP_PRESSED, kf_ToggleTeamChat, N_("Toggle Team Chat History"));
// **********************************
// IN GAME MAPPINGS - Single key presses - ALL __DEBUG keymappings will be removed for master
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_B, KEYMAP_PRESSED, kf_CentreOnBase, N_("Center View on HQ"));
Expand All @@ -406,9 +407,9 @@ void keyInitMappings(bool bForceDefaults)
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_R, KEYMAP_PRESSED, kf_SetDroidGoForRepair, N_("Return For Repair"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_S, KEYMAP_PRESSED, kf_SetDroidOrderStop, N_("Stop Droid"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_T, KEYMAP_PRESSED, kf_SetDroidGoToTransport, N_("Go to Transport"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_RETURN, KEYMAP_PRESSED, kf_SendTextMessage, N_("Send Text Message"));

keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LALT, KEY_H, KEYMAP_PRESSED, kf_AddHelpBlip, N_("Drop a beacon"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_IGNORE, KEY_RETURN, KEYMAP_PRESSED, kf_SendGlobalMessage, N_("Send Global Text Message"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LCTRL, KEY_RETURN, KEYMAP_PRESSED, kf_SendTeamMessage, N_("Send Team Text Message"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LALT, KEY_H, KEYMAP_PRESSED, kf_AddHelpBlip, N_("Drop a beacon"));

keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LALT, KEY_S, KEYMAP_PRESSED, kf_ToggleShadows, N_("Toggles shadows"));
keyAddMapping(KEYMAP_ASSIGNABLE, KEY_LALT, KEY_T, KEYMAP_PRESSED, kf_toggleTrapCursor, N_("Trap cursor"));
Expand Down
61 changes: 53 additions & 8 deletions src/multiplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,23 +1165,65 @@ bool recvResearchStatus(NETQUEUE queue)
return true;
}

static void printchatmsg(const char *text, int from)
static void printchatmsg(const char *text, int from, bool team = false)
{
char msg[MAX_CONSOLE_STRING_LENGTH];

sstrcpy(msg, NetPlay.players[from].name); // name
sstrcat(msg, ": "); // seperator
sstrcat(msg, text); // add message
addConsoleMessage(msg, DEFAULT_JUSTIFY, from); // display
addConsoleMessage(msg, DEFAULT_JUSTIFY, from, team); // display
}

// ////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
// Text Messaging between team.
void sendTeamMessage(const char *pStr, uint32_t from)
{
char display[MAX_CONSOLE_STRING_LENGTH];
bool team = true;

sstrcpy(display, pStr);
// This is for local display
if (from == selectedPlayer)
{
printchatmsg(display, from, team);
}

for (int i = 0; i < game.maxPlayers; i++)
{
if (i != from && aiCheckAlliances(from, i))
{
if (i == selectedPlayer)
{
printchatmsg(display, from); // also display it
}
if (isHumanPlayer(i))
{
NETbeginEncode(NETnetQueue(i), NET_TEXTMSG);
NETuint32_t(&from); // who this msg is from
NETbool(&team);
NETstring(display, MAX_CONSOLE_STRING_LENGTH); // the message to send
NETend();
}
else if (myResponsibility(i))
{
msgStackPush(CALL_AI_MSG, from, i, display, -1, -1, NULL);
triggerEventChat(from, i, display);
}
else //also send to AIs now (non-humans), needed for AI
{
sendAIMessage(display, from, i);
}
}
}
}

// Text Messaging between players. proceed string with players to send to.
// eg "123hi there" sends "hi there" to players 1,2 and 3.
bool sendTextMessage(const char *pStr, bool all, uint32_t from)
{
bool normal = true;
bool normal = true, team = false;
bool sendto[MAX_PLAYERS];
int posTable[MAX_PLAYERS];
UDWORD i;
Expand Down Expand Up @@ -1265,6 +1307,7 @@ bool sendTextMessage(const char *pStr, bool all, uint32_t from)
{
NETbeginEncode(NETbroadcastQueue(), NET_TEXTMSG);
NETuint32_t(&from); // who this msg is from
NETbool(&team); // team specific?
NETstring(msg, MAX_CONSOLE_STRING_LENGTH); // the message to send
NETend();
for (i = 0; i < MAX_PLAYERS; i++)
Expand Down Expand Up @@ -1298,6 +1341,7 @@ bool sendTextMessage(const char *pStr, bool all, uint32_t from)
{
NETbeginEncode(NETnetQueue(i), NET_TEXTMSG);
NETuint32_t(&from); // who this msg is from
NETbool(&team); // team specific?
NETstring(msg, MAX_CONSOLE_STRING_LENGTH); // the message to send
NETend();
}
Expand Down Expand Up @@ -1327,6 +1371,7 @@ bool sendTextMessage(const char *pStr, bool all, uint32_t from)
{
NETbeginEncode(NETnetQueue(i), NET_TEXTMSG);
NETuint32_t(&from); // who this msg is from
NETbool(&team); // team specific?
NETstring(display, MAX_CONSOLE_STRING_LENGTH); // the message to send
NETend();
}
Expand Down Expand Up @@ -1434,15 +1479,15 @@ bool recvTextMessage(NETQUEUE queue)
UDWORD playerIndex;
char msg[MAX_CONSOLE_STRING_LENGTH];
char newmsg[MAX_CONSOLE_STRING_LENGTH];
bool team;

memset(msg, 0x0, sizeof(msg));
memset(newmsg, 0x0, sizeof(newmsg));

NETbeginDecode(queue, NET_TEXTMSG);
// Who this msg is from
NETuint32_t(&playerIndex);
// The message to receive
NETstring(newmsg, MAX_CONSOLE_STRING_LENGTH);
NETuint32_t(&playerIndex); // Who this msg is from
NETbool(&team); // team specific?
NETstring(newmsg, MAX_CONSOLE_STRING_LENGTH); // The message to receive
NETend();

if (whosResponsible(playerIndex) != queue.index)
Expand All @@ -1461,7 +1506,7 @@ bool recvTextMessage(NETQUEUE queue)
// Add message
sstrcat(msg, newmsg);

addConsoleMessage(msg, DEFAULT_JUSTIFY, playerIndex);
addConsoleMessage(msg, DEFAULT_JUSTIFY, playerIndex, team);

// Multiplayer message callback
// Received a console message from a player, save
Expand Down
1 change: 1 addition & 0 deletions src/multiplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ extern bool SendDestroyTemplate(DROID_TEMPLATE *t, uint8_t player);
extern bool SendResearch(uint8_t player, uint32_t index, bool trigger);
extern bool SendDestroyFeature(FEATURE *pF); // send a destruct feature message.
extern bool sendTextMessage(const char *pStr, bool cast, uint32_t from = selectedPlayer); // send a text message
extern void sendTeamMessage(const char *pStr, uint32_t from = selectedPlayer); // send a team chat message
void printConsoleNameChange(const char *oldName, const char *newName); ///< Print message to console saying a name changed.

extern void turnOffMultiMsg(bool bDoit);
Expand Down