Skip to content

Commit

Permalink
libcommon: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Feb 3, 2014
1 parent 63f04fd commit 30d105c
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 31 deletions.
1 change: 1 addition & 0 deletions doomsday/plugins/common/common.pri
Expand Up @@ -17,6 +17,7 @@ HEADERS += \
$$common_inc/d_netsv.h \
$$common_inc/dmu_lib.h \
$$common_inc/fi_lib.h \
$$common_inc/gamerules.h \
$$common_inc/g_common.h \
$$common_inc/g_controls.h \
$$common_inc/g_defs.h \
Expand Down
1 change: 1 addition & 0 deletions doomsday/plugins/common/include/common.h
Expand Up @@ -40,6 +40,7 @@
# include "jhexen.h"
#endif

#include "gamerules.h"
#include "pause.h"

DENG_EXTERN_C dd_bool sc_FileScripts;
Expand Down
43 changes: 43 additions & 0 deletions doomsday/plugins/common/include/gamerules.h
@@ -0,0 +1,43 @@
/** @file gamerules.h Game rule set.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <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 LIBCOMMON_GAMERULES_H
#define LIBCOMMON_GAMERULES_H

#include "common.h"

/**
* @ingroup libcommon
*/
typedef struct gamerules_s {
skillmode_t skill;
#if !__JHEXEN__
byte fast;
#endif
byte deathmatch;
byte noMonsters;
#if __JHEXEN__
byte randomClasses;
#else
byte respawnMonsters;
#endif
} gamerules_t;

#endif // LIBCOMMON_GAMERULES_H
14 changes: 0 additions & 14 deletions doomsday/plugins/common/include/saveinfo.h
Expand Up @@ -24,20 +24,6 @@
#include "doomsday.h"
#include "common.h"

typedef struct gamerules_s {
skillmode_t skill;
#if !__JHEXEN__
byte fast;
#endif
byte deathmatch;
byte noMonsters;
#if __JHEXEN__
byte randomClasses;
#else
byte respawnMonsters;
#endif
} gamerules_t;

#ifdef __cplusplus
/**
* Saved game session info.
Expand Down
20 changes: 20 additions & 0 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -2185,6 +2185,26 @@ static void G_InitNewGame(void)
#endif
}

void G_GetGameRules(gamerules_t *rules)
{
DENG_ASSERT(rules != 0);
#if __JHEXEN__
rules->skill = gameSkill;
rules->randomClasses = randomClassParm;
#else
rules->skill = gameSkill;
rules->fast = fastParm;
#endif
rules->deathmatch = deathmatch;
rules->noMonsters = noMonstersParm;

#if __JHEXEN__
rules->randomClasses = randomClassParm;
#else
rules->respawnMonsters = respawnMonsters;
#endif
}

#if __JDOOM__ || __JDOOM64__
static void G_ApplyGameRuleFastMonsters(dd_bool fast)
{
Expand Down
17 changes: 2 additions & 15 deletions doomsday/plugins/common/src/saveinfo.cpp
Expand Up @@ -151,21 +151,8 @@ void SaveInfo::configure()
_episode = gameEpisode+1;
#endif

#if __JHEXEN__
_gameRules.skill = gameSkill;
_gameRules.randomClasses = randomClassParm;
#else
_gameRules.skill = gameSkill;
_gameRules.fast = fastParm;
#endif
_gameRules.deathmatch = deathmatch;
_gameRules.noMonsters = noMonstersParm;

#if __JHEXEN__
_gameRules.randomClasses = randomClassParm;
#else
_gameRules.respawnMonsters = respawnMonsters;
#endif
// Make a copy of the current game rules.
G_GetGameRules(&_gameRules);

#if !__JHEXEN__
_mapTime = ::mapTime;
Expand Down
7 changes: 7 additions & 0 deletions doomsday/plugins/doom/include/g_game.h
Expand Up @@ -37,6 +37,7 @@
#include "doomdef.h"
#include "d_event.h"
#include "d_player.h"
#include "gamerules.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -73,6 +74,12 @@ void G_CommonPreInit(void);
void G_CommonPostInit(void);
void G_CommonShutdown(void);

/**
* Configure the given @a rules structure according to the @em current game rules.
* @todo Refactor away.
*/
void G_GetGameRules(gamerules_t *rules);

void R_InitRefresh(void);

void G_PrintMapList(void);
Expand Down
9 changes: 8 additions & 1 deletion doomsday/plugins/doom64/include/g_game.h
Expand Up @@ -36,6 +36,7 @@

#include "doomdef.h"
#include "d_player.h"
#include "gamerules.h"
#include "wi_stuff.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -72,8 +73,14 @@ void G_Register(void);
void G_CommonPreInit(void);
void G_CommonPostInit(void);
void G_CommonShutdown(void);
void R_InitRefresh(void);

/**
* Configure the given @a rules structure according to the @em current game rules.
* @todo Refactor away.
*/
void G_GetGameRules(gamerules_t *rules);

void R_InitRefresh(void);
void G_DeathMatchSpawnPlayer(int playernum);

void G_PrintMapList(void);
Expand Down
9 changes: 8 additions & 1 deletion doomsday/plugins/heretic/include/g_game.h
Expand Up @@ -35,6 +35,7 @@
#endif

#include "doomdef.h"
#include "gamerules.h"
#include "h_event.h"
#include "h_player.h"

Expand Down Expand Up @@ -71,8 +72,14 @@ void G_Register(void);
void G_CommonPreInit(void);
void G_CommonPostInit(void);
void G_CommonShutdown(void);
void R_InitRefresh(void);

/**
* Configure the given @a rules structure according to the @em current game rules.
* @todo Refactor away.
*/
void G_GetGameRules(gamerules_t *rules);

void R_InitRefresh(void);
void G_DeathMatchSpawnPlayer(int playernum);

void G_PrintMapList(void);
Expand Down
7 changes: 7 additions & 0 deletions doomsday/plugins/hexen/include/g_game.h
Expand Up @@ -32,6 +32,7 @@
# error "Using jHexen headers without __JHEXEN__"
#endif

#include "gamerules.h"
#include "p_mobj.h"
#include "x_player.h"

Expand Down Expand Up @@ -65,6 +66,12 @@ extern int gsvMapMusic;

void G_CommonShutdown(void);

/**
* Configure the given @a rules structure according to the @em current game rules.
* @todo Refactor away.
*/
void G_GetGameRules(gamerules_t *rules);

void R_InitRefresh(void);
void R_GetTranslation(int plrClass, int plrColor, int* tclass, int* tmap);
void Mobj_UpdateTranslationClassAndMap(mobj_t* mo);
Expand Down

0 comments on commit 30d105c

Please sign in to comment.