Skip to content

Commit

Permalink
Fixed|libheretic: Cheats not working in multiplayer
Browse files Browse the repository at this point in the history
See: b9fdf4f

Todo: The cheats 'gimme', 'iddqd' and 'idkfa' require various new
features and/or functionality. I'll return to these once libhexen
has been updated...
  • Loading branch information
danij-deng committed Jul 25, 2013
1 parent bc0d024 commit f5e4677
Show file tree
Hide file tree
Showing 9 changed files with 801 additions and 798 deletions.
13 changes: 9 additions & 4 deletions doomsday/plugins/common/src/d_netsv.c
Expand Up @@ -1305,7 +1305,7 @@ void NetSv_SendJumpPower(int target, float power)
Net_SendPacket(target, GPT_JUMP_POWER, Writer_Data(writer), Writer_Size(writer));
}

void NetSv_ExecuteCheat(int player, const char* command)
void NetSv_ExecuteCheat(int player, char const *command)
{
// Killing self is always allowed.
/// @todo fixme: really? Even in deathmatch??
Expand All @@ -1322,9 +1322,14 @@ void NetSv_ExecuteCheat(int player, const char* command)
}

/// @todo Can't we use the multipurpose cheat command here?
if(!strnicmp(command, "god", 3) ||
!strnicmp(command, "noclip", 6) ||
!strnicmp(command, "give", 4))
if(!strnicmp(command, "god", 3)
|| !strnicmp(command, "noclip", 6)
|| !strnicmp(command, "give", 4)
#ifdef __JHERETIC__
|| !strnicmp(command, "kill", 4)
|| !strnicmp(command, "chicken", 7)
#endif
)
{
DD_Executef(false, "%s %i", command, player);
}
Expand Down
18 changes: 3 additions & 15 deletions doomsday/plugins/heretic/include/doomdef.h
Expand Up @@ -207,25 +207,13 @@ typedef enum {
AT_NOAMMO // Takes no ammo, used for staff, gauntlets.
} ammotype_t;

#define AMMO_GWND_WIMPY 10
#define AMMO_GWND_HEFTY 50
#define AMMO_CBOW_WIMPY 5
#define AMMO_CBOW_HEFTY 20
#define AMMO_BLSR_WIMPY 10
#define AMMO_BLSR_HEFTY 25
#define AMMO_SKRD_WIMPY 20
#define AMMO_SKRD_HEFTY 100
#define AMMO_PHRD_WIMPY 1
#define AMMO_PHRD_HEFTY 10
#define AMMO_MACE_WIMPY 20
#define AMMO_MACE_HEFTY 100

/**
* Powers, bestowable upon players only.
*/
typedef enum {
PT_NONE,
PT_INVULNERABILITY,
PT_NONE, /// @todo Remove me (index from zero).
PT_FIRST,
PT_INVULNERABILITY = PT_FIRST,
PT_INVISIBILITY,
PT_ALLMAP,
PT_INFRARED,
Expand Down
146 changes: 121 additions & 25 deletions doomsday/plugins/heretic/include/p_inter.h
@@ -1,37 +1,133 @@
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file p_inter.h
*
*\author Copyright © 2009-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2009-2013 Daniel Swanson <danij@dengine.net>
*
* 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 LIBHERETIC_P_INTER_H
#define LIBHERETIC_P_INTER_H

#ifndef __JHERETIC__
# error "Using jHeretic headers without __JHERETIC__"
#endif

#include "doomdef.h"
#include "p_player.h"

DENG_EXTERN_C int maxAmmo[NUM_AMMO_TYPES];
DENG_EXTERN_C int clipAmmo[NUM_AMMO_TYPES];

/**
* @return @c true if power accepted.
*/
boolean P_GivePower(player_t *player, powertype_t powerType);

/**
* @param player Player to relieve of the power.
* @param powerType Power type to take.
*
* 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 taken.
*/
boolean P_TakePower(player_t *player, powertype_t powerType);

/**
* p_inter.h: Handling interactions (i.e., collisions).
* @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 __P_INTER_H__
#define __P_INTER_H__
/**
* 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);

#ifndef __JHERETIC__
# error "Using jHeretic headers without __JHERETIC__"
#endif
/**
* 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 numRounds Number of rounds to give. Use @c -1 to give as many rounds
* 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 numRounds);

boolean P_GiveArmor(player_t* plr, int type, int points);
/**
* @param player Player to receive the health.
* @param amount Amount of health to give. Use @c -1 to fully replenish.
*
* @return @c true iff at least some of the health was given.
*/
boolean P_GiveHealth(player_t *player, int amount);

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

/**
* @return @c true if the weapon or its ammo was accepted.
*/
boolean P_GiveWeapon(player_t *player, weapontype_t weaponType);

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

void P_TouchSpecialMobj(mobj_t *special, mobj_t *toucher);

/**
* @return @c true, if the player is morphed.
*/
boolean P_MorphPlayer(player_t *player);

/**
* Damages both enemies and players.
*
* @param inflictor Mobj that caused the damage creature or missile,
* can be NULL (slime, etc)
* @param source Mobj to target after taking damage. Can be @c NULL
* for barrel explosions and other environmental stuff.
* Source and inflictor are the same for melee attacks.
*
* @return Actual amount of damage done.
*/
int P_DamageMobj2(mobj_t *target, mobj_t *inflictor, mobj_t *source, int damageP, boolean stomping, boolean skipNetworkCheck);
int P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, int damageP, boolean stomping/*, boolean skipNetworkCheck = false*/);

#endif // LIBHERETIC_P_INTER_H
12 changes: 0 additions & 12 deletions doomsday/plugins/heretic/include/p_local.h
Expand Up @@ -99,9 +99,6 @@
DENG_EXTERN_C mobjtype_t puffType;
DENG_EXTERN_C mobj_t* missileMobj;
DENG_EXTERN_C float turboMul;
DENG_EXTERN_C int maxAmmo[NUM_AMMO_TYPES];
DENG_EXTERN_C int clipAmmo[NUM_AMMO_TYPES];
DENG_EXTERN_C int maxAmmo[NUM_AMMO_TYPES];

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -142,15 +139,6 @@ void P_ExplodeMissile(mobj_t* mo);
const char* P_GetMapName(uint episode, uint map);
const char* P_GetShortMapName(uint episode, uint map);

void P_GiveKey(player_t* player, keytype_t key);
void P_TouchSpecialMobj(mobj_t* special, mobj_t* toucher);
int P_DamageMobj(mobj_t* target, mobj_t* inflictor, mobj_t* source, int damage, boolean stomping);
int P_DamageMobj2(mobj_t* target, mobj_t* inflictor, mobj_t* source, int damage, boolean stomping, boolean skipNetworkCheck);
boolean P_GiveAmmo(player_t* player, ammotype_t ammo, int count);
boolean P_GiveBody(player_t* player, int num);
boolean P_GivePower(player_t* player, powertype_t power);
boolean P_MorphPlayer(player_t* player);

void Draw_BeginZoom(float s, float originX, float originY);
void Draw_EndZoom(void);

Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/heretic/src/h_console.c
Expand Up @@ -34,7 +34,7 @@ D_CMD(CheatReveal);
D_CMD(CheatGive);
D_CMD(CheatMassacre);
D_CMD(CheatWhere);
D_CMD(CheatPig);
D_CMD(CheatMorph);
D_CMD(CheatLeaveMap);
D_CMD(CheatSuicide);

Expand Down Expand Up @@ -186,7 +186,7 @@ ccmdtemplate_t gameCCmds[] = {
{"viewmode", NULL, CCmdSetViewMode},

// Heretic specific
{"chicken", "", CCmdCheatPig},
{"chicken", "", CCmdCheatMorph},
{NULL}
};

Expand Down

0 comments on commit f5e4677

Please sign in to comment.