Skip to content

Commit

Permalink
Fixed|libdoom: Cheats not working in multiplayer
Browse files Browse the repository at this point in the history
There were numerous logic issues in the cheat code handling which
interpreted cheats entered via the console differently to those
entered using keyboard input event sequences.

All cheats are now actioned by console commands which the original
games' keyboard input event sequences are mapped to. It no longer
matters how a cheat is entered.

All P_Give* functions have been reworked and cleaned up so as to
standardize on the internal APIs.

Todo: Do the same for libheretic and libhexen...
  • Loading branch information
danij-deng committed Jul 24, 2013
1 parent dfb1f74 commit b9fdf4f
Show file tree
Hide file tree
Showing 5 changed files with 592 additions and 631 deletions.
6 changes: 3 additions & 3 deletions doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -1572,9 +1572,9 @@ void NetSv_LoadGame(unsigned int game_id)
Net_SendPacket(DDSP_ALL_PLAYERS, GPT_LOAD, Writer_Data(writer), Writer_Size(writer));
}

void NetSv_SendMessageEx(int plrNum, const char *msg, boolean yellow)
void NetSv_SendMessageEx(int plrNum, char const *msg, boolean yellow)
{
Writer* writer;
Writer *writer;

if(IS_CLIENT || !netSvAllowSendMsg)
return;
Expand All @@ -1584,7 +1584,7 @@ void NetSv_SendMessageEx(int plrNum, const char *msg, boolean yellow)
return;

#ifdef _DEBUG
Con_Message("NetSv_SendMessageEx: Message '%s'", msg);
Con_Message("NetSv_SendMessageEx: '%s'", msg);
#endif

if(plrNum == DDSP_ALL_PLAYERS)
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/doom/include/doomdef.h
Expand Up @@ -211,7 +211,8 @@ typedef enum {

// Power ups.
typedef enum {
PT_INVULNERABILITY,
PT_FIRST,
PT_INVULNERABILITY = PT_FIRST,
PT_STRENGTH,
PT_INVISIBILITY,
PT_IRONFEET,
Expand Down
132 changes: 99 additions & 33 deletions doomsday/plugins/doom/include/p_inter.h
@@ -1,45 +1,111 @@
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file p_inter.h
*
*\author Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
*\author Copyright © 1993-1996 by id Software, Inc.
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 1993-1996 by id Software, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef LIBDOOM_P_INTER_H
#define LIBDOOM_P_INTER_H

#ifndef __JDOOM__
# error "Using jDoom headers without __JDOOM__"
#endif

/**
* @param player Player to receive the power.
* @param powerType Power type to give.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
* @return @c true iff the power was given.
*/
boolean P_GivePower(player_t *player, powertype_t powerType);

/**
* p_inter.h:
* @param player Player to relieve of the power.
* @param powerType Power type to take.
*
* @return @c true iff the power was taken.
*/
boolean P_TakePower(player_t *player, powertype_t powerType);

#ifndef __P_INTER_H__
#define __P_INTER_H__
/**
* @param player Player to toggle a power for.
* @param powerType Power type to toggle.
*
* @return @c true iff the power was toggled.
*/
boolean P_TogglePower(player_t *player, powertype_t powerType);

#ifndef __JDOOM__
# error "Using jDoom headers without __JDOOM__"
#endif
/**
* Give key(s) to the specified player. If a key is successfully given a short
* "bonus flash" screen tint animation is played and a HUE_ON_PICKUP_KEY event
* is generated (which optionally reveals the HUD if hidden). If the specified
* key(s) are already owned then nothing will happen (and false is returned).
*
* @param player Player to receive the key(s).
* @param keyType Key type to give. Use @c NUM_KEY_TYPES to give ALL keys.
*
* @return @c true iff at least one new key was given (not already owned).
*/
boolean P_GiveKey(player_t *player, keytype_t keyType);

boolean P_GivePower(player_t *plr, int);
boolean P_TakePower(player_t *plr, int power);
void P_GiveKey(player_t *plr, keytype_t keyType);
boolean P_GiveBody(player_t *plr, int num);
void P_GiveBackpack(player_t *plr);
boolean P_GiveWeapon(player_t *plr, weapontype_t weapon, boolean dropped, const char* pickupMessage, int pickupSound);
boolean P_GiveArmorType(player_t* plr, int type, int points);
/**
* Give ammo(s) to the specified player. If a ammo is successfully given the
* player 'brain' may decide to change weapon (depends on the user's config)
* and a HUE_ON_PICKUP_AMMO event is generated (which optionally reveals the
* HUD if hidden). If the specified ammo(s) are already owned then nothing will
* happen (and false is returned).
*
* @note The final number of rounds the player will receive depends on both the
* ammount given and how many the player can carry. Use @ref P_GiveBackpack()
* to equip the player with a backpack, thereby increasing this capacity.
*
* @param player Player to receive the ammo(s).
* @param ammoType Ammo type to give. Use @c NUM_AMMO_TYPES to give ALL ammos.
* Giving the special 'unlimited ammo' type @c AT_NOAMMO will
* always succeed, however no sideeffects will occur.
* @param numClips Number of clip loads (@em not rounds!). Use @c 0 to give
* only half of one clip. Use @c -1 to give as many clips as
* necessary to fully replenish stock.
*
* @return @c true iff at least one new round was given (not already owned).
*/
boolean P_GiveAmmo(player_t *player, ammotype_t ammoType, int numClips);

#endif
/**
* @param player Player to receive the health.
*
* @return @c true iff at least some of the health was given.
*/
boolean P_GiveHealth(player_t *player, int amount);

/**
* @param player Player to receive the backpack.
*/
void P_GiveBackpack(player_t *player);

/**
* The weapon name may have a MF_DROPPED flag ored in.
*/
boolean P_GiveWeapon(player_t *player, weapontype_t weapon, boolean dropped);

/**
* @return @c true iff the armor was given.
*/
boolean P_GiveArmor(player_t *player, int type, int points);

#endif // LIBDOOM_P_INTER_H

0 comments on commit b9fdf4f

Please sign in to comment.