Skip to content

Commit

Permalink
Added cvar chat-beep; 1= Play a beep sound when a new chat message ar…
Browse files Browse the repository at this point in the history
…rives.
  • Loading branch information
danij committed Jan 9, 2007
1 parent d300e41 commit aac2609
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 33 deletions.
72 changes: 39 additions & 33 deletions doomsday/plugins/common/src/d_net.c
Expand Up @@ -70,6 +70,8 @@ DEFCC(CCmdSetClass);

// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------

static void D_NetMessageEx(char *msg, boolean playSound);

// EXTERNAL DATA DECLARATIONS ----------------------------------------------

extern int netSvAllowSendMsg;
Expand Down Expand Up @@ -108,29 +110,28 @@ cvar_t netCVars[] = {

// CODE ---------------------------------------------------------------------

/*
/**
* Register the console commands and variables of the common netcode.
*/
void D_NetConsoleRegistration(void)
{
int i;
int i;

for(i = 0; netCCmds[i].name; i++)
for(i = 0; netCCmds[i].name; ++i)
Con_AddCommand(netCCmds + i);
for(i = 0; netCVars[i].name; i++)
for(i = 0; netCVars[i].name; ++i)
Con_AddVariable(netCVars + i);
}

/*
/**
* Called when the network server starts.
*
* Duties include:
* updating global state variables
* initializing all players' settings
* Updating global state variables and initializing all players' settings
*/
int D_NetServerStarted(int before)
{
int netMap;
int netMap;

if(before)
return true;
Expand Down Expand Up @@ -177,10 +178,11 @@ int D_NetServerStarted(int before)
return true;
}

/*
/**
* Called when a network server closes.
*
* Duties include: Restoring global state variables
* Duties include:
* Restoring global state variables
*/
int D_NetServerClose(int before)
{
Expand Down Expand Up @@ -300,7 +302,7 @@ long int D_NetPlayerEvent(int plrNumber, int peType, void *data)
int i, num, oldecho = cfg.echoMsg;

// Count the number of players.
for(i = num = 0; i < MAXPLAYERS; i++)
for(i = num = 0; i < MAXPLAYERS; ++i)
if(players[i].plr->ingame)
num++;
// If there are more than two players, include the name of
Expand All @@ -313,19 +315,15 @@ long int D_NetPlayerEvent(int plrNumber, int peType, void *data)

// The chat message is already echoed by the console.
cfg.echoMsg = false;
D_NetMessage(msgBuff);
D_NetMessageEx(msgBuff, (cfg.chatBeep? true : false));
cfg.echoMsg = oldecho;
}
return true;
}

int D_NetWorldEvent(int type, int parm, void *data)
{
//short *ptr;
int i;

//int mtype, flags;
//fixed_t x, y, z, momx, momy, momz;
int i;

switch (type)
{
Expand Down Expand Up @@ -545,7 +543,7 @@ void D_HandlePacket(int fromplayer, int type, void *data, int length)
}
}

/*
/**
* Plays a (local) chat sound.
*/
void D_ChatSound(void)
Expand All @@ -564,34 +562,40 @@ void D_ChatSound(void)
#endif
}

/*
/**
* Show a message on screen, optionally accompanied
* by Chat sound effect.
*
* @param playSound If <code>true</code>, play the chat sound.
*/
void D_NetMessageEx(char *msg, boolean play_sound)
static void D_NetMessageEx(char *msg, boolean playSound)
{
strcpy(msgBuff, msg);
// This is intended to be a local message.
// Let's make sure P_SetMessage doesn't forward it anywhere.
netSvAllowSendMsg = false;
P_SetMessage(players + consoleplayer, msgBuff, false);

if(play_sound)
if(playSound)
D_ChatSound();

netSvAllowSendMsg = true;
}

/*
* Show message on screen, play chat sound.
/**
* Show message on screen and play chat sound.
*
* @param msg Ptr to the message to print.
*/
void D_NetMessage(char *msg)
{
D_NetMessageEx(msg, true);
}

/*
/**
* Show message on screen.
*
* @param msg
*/
void D_NetMessageNoSound(char *msg)
{
Expand All @@ -602,8 +606,9 @@ void D_NetMessageNoSound(char *msg)
* Issues a damage request when a client is trying to damage another player's
* mobj.
*
* @return True, if no further processing of the damage should be done.
* False to process damage as normally.
* @return If <code>true</code> no further processing of the
* damage should be done else, process the damage as
* normally.
*/
boolean D_NetDamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source,
int damage)
Expand All @@ -612,12 +617,12 @@ boolean D_NetDamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source,
{
return false;
}

if(IS_SERVER && source->player - players > 0)
{
// A client is trying to do damage.
#ifdef _DEBUG
Con_Message("P_DamageMobj2: Server ignores client's damage on svside.\n");
Con_Message("P_DamageMobj2: Server ignores client's damage on svside.\n");
#endif
// TODO: Damage requests have not been fully implemented yet.
return false;
Expand All @@ -626,19 +631,19 @@ boolean D_NetDamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source,
else if(IS_CLIENT && source->player - players == consoleplayer)
{
#ifdef _DEBUG
Con_Message("P_DamageMobj2: Client should request damage on mobj %p.\n", target);
Con_Message("P_DamageMobj2: Client should request damage on mobj %p.\n", target);
#endif
return true;
}

#ifdef _DEBUG
Con_Message("P_DamageMobj2: Allowing normal damage in netgame.\n");
Con_Message("P_DamageMobj2: Allowing normal damage in netgame.\n");
#endif
// Process as normal damage.
return false;
}

/*
/**
* Console command to change the players' colors.
*/
DEFCC(CCmdSetColor)
Expand Down Expand Up @@ -693,7 +698,7 @@ DEFCC(CCmdSetColor)
return true;
}

/*
/**
* Console command to change the players' class.
*/
#if __JHEXEN__
Expand All @@ -718,7 +723,8 @@ DEFCC(CCmdSetClass)
return true;
}
#endif
/*

/**
* Console command to change the current map.
*/
DEFCC(CCmdSetMap)
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/common/src/hu_msg.c
Expand Up @@ -244,6 +244,7 @@ cvar_t msgCVars[] = {
{"chat-macro7", 0, CVT_CHARPTR, &cfg.chat_macros[7], 0, 0},
{"chat-macro8", 0, CVT_CHARPTR, &cfg.chat_macros[8], 0, 0},
{"chat-macro9", 0, CVT_CHARPTR, &cfg.chat_macros[9], 0, 0},
{"chat-beep", 0, CVT_BYTE, &cfg.chatBeep, 0, 1},
{NULL}
};

Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/doom64tc/data/conhelp.txt
Expand Up @@ -448,6 +448,9 @@ desc = 1= Player has yellow skullkey.
[player-key-redskull]
desc = 1= Player has red skullkey.

[chat-beep]
desc = 1= Play a beep sound when a new chat message arrives.

[chat-macro0]
desc = Chat macro 1.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/doom64tc/include/d_config.h
Expand Up @@ -167,6 +167,7 @@ typedef struct jdoom_config_s {
float msgColor[3];

char *chat_macros[10];
byte chatBeep;

int corpseTime;
byte killMessages;
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/doom64tc/src/d_main.c
Expand Up @@ -359,6 +359,8 @@ void D_PreInit(void)

cfg.msgColor[0] = cfg.msgColor[1] = cfg.msgColor[2] = 1;

cfg.chatBeep = 1;

cfg.killMessages = true;
cfg.bobWeapon = 1;
cfg.bobView = 1;
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jdoom/data/conhelp.txt
Expand Up @@ -449,6 +449,9 @@ desc = 1= Player has yellow skullkey.
[player-key-redskull]
desc = 1= Player has red skullkey.

[chat-beep]
desc = 1= Play a beep sound when a new chat message arrives.

[chat-macro0]
desc = Chat macro 1.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/include/d_config.h
Expand Up @@ -171,6 +171,7 @@ typedef struct jdoom_config_s {
float msgColor[3];

char *chat_macros[10];
byte chatBeep;

int corpseTime;
byte killMessages;
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/jdoom/src/d_main.c
Expand Up @@ -486,6 +486,8 @@ void D_PreInit(void)
cfg.msgColor[0] = 1;
cfg.msgColor[1] = cfg.msgColor[2] = 0;

cfg.chatBeep = 1;

cfg.killMessages = true;
cfg.bobWeapon = 1;
cfg.bobView = 1;
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jheretic/data/conhelp.txt
Expand Up @@ -482,6 +482,9 @@ desc = Current number of Wings of Wrath artifacts.
[player-artifact-chaosdevice]
desc = Current number of Chaos Devices.

[chat-beep]
desc = 1= Play a beep sound when a new chat message arrives.

[chat-macro0]
desc = Chat macro 1.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jheretic/include/h_config.h
Expand Up @@ -176,6 +176,7 @@ typedef struct jheretic_config_s {
float msgColor[3];

char *chat_macros[10];
byte chatBeep;

int corpseTime;

Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/jheretic/src/h_main.c
Expand Up @@ -383,6 +383,8 @@ void H_PreInit(void)
cfg.msgColor[1] = deffontRGB2[1];
cfg.msgColor[2] = deffontRGB2[2];

cfg.chatBeep = 1;

//cfg.killMessages = true;
cfg.bobView = 1;
cfg.bobWeapon = 1;
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/jhexen/data/conhelp.txt
Expand Up @@ -563,6 +563,9 @@ desc = 1= Player has Clock Gear 3.
[player-artifact-gear4]
desc = 1= Player has Clock Gear 4.

[chat-beep]
desc = 1= Play a beep sound when a new chat message arrives.

[chat-macro0]
desc = Chat macro 1.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/include/x_config.h
Expand Up @@ -155,6 +155,7 @@ typedef struct {

int snd_3D, messageson;
char *chat_macros[10];
byte chatBeep;
float snd_ReverbFactor;
byte reverbDebug;

Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/jhexen/src/h2_main.c
Expand Up @@ -374,6 +374,8 @@ void H2_PreInit(void)
cfg.msgColor[1] = deffontRGB2[1];
cfg.msgColor[2] = deffontRGB2[2];

cfg.chatBeep = 1;

cfg.weaponOrder[0] = WP_FOURTH;
cfg.weaponOrder[1] = WP_THIRD;
cfg.weaponOrder[2] = WP_SECOND;
Expand Down
3 changes: 3 additions & 0 deletions doomsday/plugins/wolftc/data/conhelp.txt
Expand Up @@ -449,6 +449,9 @@ desc = 1= Player has yellow skullkey.
[player-key-redskull]
desc = 1= Player has red skullkey.

[chat-beep]
desc = 1= Play a beep sound when a new chat message arrives.

[chat-macro0]
desc = Chat macro 1.

Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/wolftc/include/d_config.h
Expand Up @@ -168,6 +168,7 @@ typedef struct jdoom_config_s {
float msgColor[3];

char *chat_macros[10];
byte chatBeep;

int corpseTime;
byte killMessages;
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/wolftc/src/d_main.c
Expand Up @@ -484,6 +484,8 @@ void D_PreInit(void)
cfg.msgColor[0] = 1;
cfg.msgColor[1] = cfg.msgColor[2] = 0;

cfg.chatBeep = 1;

cfg.killMessages = true;
cfg.bobWeapon = 1;
cfg.bobView = 1;
Expand Down

0 comments on commit aac2609

Please sign in to comment.