ref: f4eb9088523aef3946f02cd45953d14760c598c6
parent: 3ce2a53bc95e3e58383e2b0a982eacba5b396b4a
author: James Haley <[email protected]>
date: Sun Sep 15 16:24:11 EDT 2013
Hopefully complete implementation of player names and Strife player chat features, which work differently than they did in DOOM. If working properly, then this fully completes Chocolate Strife, aside from any presently unknown issues. Subversion-branch: /branches/v2-branch Subversion-revision: 2646
--- a/src/strife/d_englsh.h
+++ b/src/strife/d_englsh.h
@@ -213,10 +213,11 @@
// The following should NOT be changed unless it seems
// just AWFULLY necessary
-#define HUSTR_PLRGREEN "Green: "
-#define HUSTR_PLRINDIGO "Indigo: "
-#define HUSTR_PLRBROWN "Brown: "
-#define HUSTR_PLRRED "Red: "
+// [STRIFE]: Not used, as strings are local to hu_stuff.c
+//#define HUSTR_PLRGREEN "Green: "
+//#define HUSTR_PLRINDIGO "Indigo: "
+//#define HUSTR_PLRBROWN "Brown: "
+//#define HUSTR_PLRRED "Red: "
#define HUSTR_KEYGREEN 'g'
#define HUSTR_KEYINDIGO 'i'
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -160,9 +160,8 @@
static int comport = 0;
// fraggle 06/03/11 [STRIFE]: Multiplayer nickname?
+char *nickname = NULL;
-static char *nickname = NULL;
-
void D_ConnectNetGame(void);
void D_CheckNetGame(void);
@@ -415,10 +414,15 @@
M_BindStrifeControls(); // haleyjd 09/01/10: [STRIFE]
M_BindChatControls(MAXPLAYERS);
- key_multi_msgplayer[0] = HUSTR_KEYGREEN;
- key_multi_msgplayer[1] = HUSTR_KEYINDIGO;
- key_multi_msgplayer[2] = HUSTR_KEYBROWN;
- key_multi_msgplayer[3] = HUSTR_KEYRED;
+ // haleyjd 20130915: Strife chat keys
+ key_multi_msgplayer[0] = '1';
+ key_multi_msgplayer[1] = '2';
+ key_multi_msgplayer[2] = '3';
+ key_multi_msgplayer[3] = '4';
+ key_multi_msgplayer[4] = '5';
+ key_multi_msgplayer[5] = '6';
+ key_multi_msgplayer[6] = '7';
+ key_multi_msgplayer[7] = '8';
#ifdef FEATURE_MULTIPLAYER
NET_BindVariables();
--- a/src/strife/g_game.c
+++ b/src/strife/g_game.c
@@ -983,8 +983,8 @@
&& turbodetected[i])
{
static char turbomessage[80];
- extern char *player_names[4];
- sprintf (turbomessage, "%s is turbo!",player_names[i]);
+ extern char player_names[8][16];
+ sprintf (turbomessage, "%s is turbo!", player_names[i]);
players[consoleplayer].message = turbomessage;
turbodetected[i] = false;
}
--- a/src/strife/hu_stuff.c
+++ b/src/strife/hu_stuff.c
@@ -79,7 +79,7 @@
};
// villsa [STRIFE]
-char pnameprefixes[8][16] =
+char player_names[8][16] =
{
"1: ",
"2: ",
@@ -91,14 +91,6 @@
"8: "
};
-char* player_names[] =
-{
- HUSTR_PLRGREEN,
- HUSTR_PLRINDIGO,
- HUSTR_PLRBROWN,
- HUSTR_PLRRED
-};
-
char chat_char; // remove later.
static player_t* plr;
patch_t* hu_font[HU_FONTSIZE];
@@ -121,8 +113,12 @@
static boolean headsupactive = false;
-static char * nickname; // haleyjd 09/18/10: [STRIFE]
+// haleyjd 20130915 [STRIFE]: need nickname
+extern char *nickname;
+// haleyjd 20130915 [STRIFE]: true if setting nickname
+static boolean hu_setting_name = false;
+
//
// Builtin map names.
// The actual names can be found in DStrings.h.
@@ -276,18 +272,14 @@
headsupactive = true;
// haleyjd 09/18/10: [STRIFE] nickname weirdness.
-
- // STRIFE-TODO: This shit crashes the game.
- /*
- if(nickname != pnameprefixes[consoleplayer])
+ if(nickname != player_names[consoleplayer])
{
if(*nickname)
{
DEH_printf("have one\n");
- nickname = pnameprefixes[consoleplayer];
+ nickname = player_names[consoleplayer];
}
}
- */
}
}
@@ -463,9 +455,7 @@
&& (chat_dest[i] == consoleplayer+1
|| chat_dest[i] == HU_BROADCAST))
{
- // STRIFE-TODO: there is interaction with the player
- // name prefixes array here...
- HU_addMessage(DEH_String(player_names[i]),
+ HU_addMessage(player_names[i],
w_inputbuffer[i].l.l);
message_nottobefuckedwith = true;
@@ -473,6 +463,12 @@
message_counter = HU_MSGTIMEOUT;
S_StartSound(0, sfx_radio);
}
+ else if(chat_dest[i] == HU_CHANGENAME)
+ {
+ // haleyjd 20130915 [STRIFE]: set player name
+ DEH_snprintf(player_names[i], sizeof(player_names[i]),
+ "%.13s: ", w_inputbuffer[i].l.l);
+ }
HUlib_resetIText(&w_inputbuffer[i]);
}
}
@@ -533,7 +529,7 @@
// - The default value of key_message_refresh is changed. That is handled
// elsewhere in Choco, however.
// - There is support for setting the player name through the chat
-// mechanism. This is a STRIFE-TODO.
+// mechanism.
//
boolean HU_Responder(event_t *ev)
{
@@ -572,45 +568,15 @@
message_counter = HU_MSGTIMEOUT;
eatkey = true;
}
- else if (netgame && ev->data2 == key_multi_msg)
+ else if (/*netgame && */ev->data2 == key_multi_msg)
{
eatkey = chat_on = true;
HUlib_resetIText(&w_chat);
HU_queueChatChar(HU_BROADCAST);
}
- else if (netgame && numplayers > 2)
- {
- // STRIFE-TODO: support for setting player names
-
- for (i=0; i<MAXPLAYERS ; i++)
- {
- if (ev->data2 == key_multi_msgplayer[i])
- {
- if (playeringame[i] && i!=consoleplayer)
- {
- eatkey = chat_on = true;
- HUlib_resetIText(&w_chat);
- HU_queueChatChar(i+1);
- break;
- }
- else if (i == consoleplayer)
- {
- num_nobrainers++;
- if (num_nobrainers < 3)
- plr->message = DEH_String(HUSTR_TALKTOSELF1);
- else if (num_nobrainers < 6)
- plr->message = DEH_String(HUSTR_TALKTOSELF2);
- else if (num_nobrainers < 9)
- plr->message = DEH_String(HUSTR_TALKTOSELF3);
- else if (num_nobrainers < 32)
- plr->message = DEH_String(HUSTR_TALKTOSELF4);
- else
- plr->message = DEH_String(HUSTR_TALKTOSELF5);
- }
- }
- }
- }
- }
+ // [STRIFE]: You cannot go straight to chatting with a particular
+ // player from here... you must press 't' first. See below.
+ }
else
{
c = ev->data2;
@@ -639,21 +605,80 @@
}
else
{
- eatkey = HUlib_keyInIText(&w_chat, c);
- if (eatkey)
+ if(w_chat.l.len) // [STRIFE]: past first char of chat?
{
- // static unsigned char buf[20]; // DEBUG
- HU_queueChatChar(c);
-
- // sprintf(buf, "KEY: %d => %d", ev->data1, c);
- // plr->message = buf;
+ eatkey = HUlib_keyInIText(&w_chat, c);
+ if (eatkey)
+ HU_queueChatChar(c);
}
+ else
+ {
+ // [STRIFE]: check for player-specific message;
+ // slightly different than vanilla, to allow keys to be customized
+ for(i = 0; i < MAXPLAYERS; i++)
+ {
+ if(c == key_multi_msgplayer[i])
+ break;
+ }
+ if(i < MAXPLAYERS)
+ {
+ // talking to self?
+ if(i == consoleplayer)
+ {
+ num_nobrainers++;
+ if (num_nobrainers < 3)
+ plr->message = DEH_String(HUSTR_TALKTOSELF1);
+ else if (num_nobrainers < 6)
+ plr->message = DEH_String(HUSTR_TALKTOSELF2);
+ else if (num_nobrainers < 9)
+ plr->message = DEH_String(HUSTR_TALKTOSELF3);
+ else if (num_nobrainers < 32)
+ plr->message = DEH_String(HUSTR_TALKTOSELF4);
+ else
+ plr->message = DEH_String(HUSTR_TALKTOSELF5);
+ }
+ else
+ {
+ eatkey = true;
+ HU_queueChatChar(i+1);
+ DEH_snprintf(lastmessage, sizeof(lastmessage),
+ "Talking to: %c", '1' + i);
+ plr->message = lastmessage;
+ }
+ }
+ else if(c == '$') // [STRIFE]: name changing
+ {
+ eatkey = true;
+ HU_queueChatChar(HU_CHANGENAME);
+ strncpy(lastmessage, DEH_String("Changing Name:"), sizeof(lastmessage));
+ plr->message = lastmessage;
+ hu_setting_name = true;
+ }
+ else
+ {
+ eatkey = HUlib_keyInIText(&w_chat, c);
+ if (eatkey)
+ HU_queueChatChar(c);
+ }
+ }
+
if (c == KEY_ENTER)
{
chat_on = false;
if (w_chat.l.len)
{
- strcpy(lastmessage, w_chat.l.l);
+ // [STRIFE]: name setting
+ if(hu_setting_name)
+ {
+ DEH_snprintf(lastmessage, sizeof(lastmessage),
+ "%s now %.13s", player_names[consoleplayer],
+ w_chat.l.l);
+ hu_setting_name = false;
+ }
+ else
+ {
+ strcpy(lastmessage, w_chat.l.l);
+ }
plr->message = lastmessage;
}
}
--- a/src/strife/hu_stuff.h
+++ b/src/strife/hu_stuff.h
@@ -39,6 +39,7 @@
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
#define HU_BROADCAST 9 // haleyjd [STRIFE] Changed 5 -> 9
+#define HU_CHANGENAME 10 // haleyjd [STRIFE] Special command
#define HU_MSGX 0
#define HU_MSGY (SHORT(hu_font[0]->height) + 1) // [STRIFE]: DOOM bug fix
@@ -63,7 +64,7 @@
void HU_Erase(void);
extern char *chat_macros[10];
-extern char pnameprefixes[8][16]; // villsa [STRIFE]
+extern char player_names[8][16]; // villsa [STRIFE]
// haleyjd [STRIFE] externalized:
extern char *mapnames[];
--- a/src/strife/p_inter.c
+++ b/src/strife/p_inter.c
@@ -790,8 +790,8 @@
// villsa [STRIFE] new messages when fragging players
DEH_snprintf(plrkilledmsg, sizeof(plrkilledmsg),
"%s killed %s",
- pnameprefixes[source->player->mo->miscdata],
- pnameprefixes[target->player->mo->miscdata]);
+ player_names[source->player->mo->miscdata],
+ player_names[target->player->mo->miscdata]);
if(netgame)
players[consoleplayer].message = plrkilledmsg;
--- a/src/strife/st_stuff.c
+++ b/src/strife/st_stuff.c
@@ -1218,7 +1218,7 @@
colpatch = W_CacheLumpName(buffer, PU_CACHE);
V_DrawPatchDirect(28, y, colpatch);
frags = ST_calcFrags(pnum);
- DEH_snprintf(buffer, sizeof(buffer), "%s%d", pnameprefixes[pnum], frags);
+ DEH_snprintf(buffer, sizeof(buffer), "%s%d", player_names[pnum], frags);
HUlib_drawYellowText(38, yt, buffer);
if(!playeringame[pnum])
HUlib_drawYellowText(28, pnum*17 + 65, "X");
@@ -1235,7 +1235,7 @@
colpatch = W_CacheLumpName(buffer, PU_CACHE);
V_DrawPatchDirect(158, y, colpatch);
frags = ST_calcFrags(pnum);
- DEH_snprintf(buffer, sizeof(buffer), "%s%d", pnameprefixes[pnum], frags);
+ DEH_snprintf(buffer, sizeof(buffer), "%s%d", player_names[pnum], frags);
HUlib_drawYellowText(168, yt, buffer);
if(!playeringame[pnum])
HUlib_drawYellowText(158, pnum*17 - 3, "X");