Weapon pickup message not displayed in multiplayer

From DoomWiki.org

In multiplayer games, weapons do not disappear when picked up, as they do in a single-player game. There are some exceptions to this rule: in altdeath mode they do disappear, and weapons that are dropped by monsters always disappear. However, if the weapon does not disappear, the usual weapon pickup message also does not appear in the HUD.

Technical details[edit]

The code that handles weapon pickups is located in the file p_inter.c inside the function P_TouchSpecialThing. This function contains a switch/case block that tries to identify the kind of thing that was touched by the player. The following is an example:

      case SPR_SHOT:
	if (!P_GiveWeapon (player, wp_shotgun, special->flags&MF_DROPPED ) )
	player->message = GOTSHOTGUN;
	sound = sfx_wpnup;	

The function P_GiveWeapon is called; this function evaluates whether the player can take the weapon. The function usually returns true if the player can take the weapon (in single player or altdeath). In cooperative or normal deathmatch, the code takes a different path: P_GiveWeapon always returns false. Because of this, P_TouchSpecialThing returns, short-circuiting the code that usually displays the weapon pickup message.

Exiting this function early also skips the code that removes the weapon from the game (intended behavior for cooperative or normal deathmatch). When playing single-player or altdeath, the code continues inside the same function. This sets the correct weapon pickup message, but removes the weapon from the game.