Skip to content

Commit

Permalink
libcommon|All Games: Common GetInteger routine for all games
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 15, 2012
1 parent c68e935 commit 2b558de
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 39 deletions.
1 change: 1 addition & 0 deletions doomsday/plugins/common/common.pri
Expand Up @@ -65,6 +65,7 @@ HEADERS += \

SOURCES += \
$$common_src/am_map.c \
$$common_src/common.c \
$$common_src/d_net.c \
$$common_src/d_netcl.c \
$$common_src/d_netsv.c \
Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/common/include/common.h
Expand Up @@ -37,4 +37,6 @@
# include "jhexen.h"
#endif

int Common_GetInteger(int id);

#endif /// LIBCOMMON_GAME_INCLUDES
43 changes: 43 additions & 0 deletions doomsday/plugins/common/src/common.c
@@ -0,0 +1,43 @@
/**
* @file common.c
* Top-level libcommon routines.
*
* @authors Copyright &copy; 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright &copy; 2012 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>
*/

#include "common.h"
#include "g_common.h"

int Common_GetInteger(int id)
{
switch(id)
{
case DD_DMU_VERSION:
return DMUAPI_VER;

case DD_GAME_RECOMMENDS_SAVING:
// The engine will use this as a hint whether to remind the user to
// manually save the game before, e.g., upgrading to a new version.
return G_GameState() == GS_MAP;

default:
break;
}
return 0;
}

10 changes: 1 addition & 9 deletions doomsday/plugins/jdoom/src/d_main.c
Expand Up @@ -102,15 +102,7 @@ static boolean autoStart;
*/
int D_GetInteger(int id)
{
switch(id)
{
case DD_DMU_VERSION:
return DMUAPI_VER;

default:
break;
}
return 0;
return Common_GetInteger(id);
}

/**
Expand Down
11 changes: 1 addition & 10 deletions doomsday/plugins/jdoom64/src/d_main.c
Expand Up @@ -104,16 +104,7 @@ static boolean autoStart;
*/
int D_GetInteger(int id)
{
switch(id)
{
case DD_DMU_VERSION:
return DMUAPI_VER;

default:
break;
}
// ID not recognized, return NULL.
return 0;
return Common_GetInteger(id);
}

/**
Expand Down
11 changes: 1 addition & 10 deletions doomsday/plugins/jheretic/src/h_main.c
Expand Up @@ -104,16 +104,7 @@ static boolean autoStart;
*/
int H_GetInteger(int id)
{
switch(id)
{
case DD_DMU_VERSION:
return DMUAPI_VER;

default:
break;
}
// ID not recognized, return NULL.
return 0;
return Common_GetInteger(id);
}

/**
Expand Down
11 changes: 1 addition & 10 deletions doomsday/plugins/jhexen/src/h2_main.c
Expand Up @@ -108,16 +108,7 @@ static skillmode_t startSkill = SM_MEDIUM;
*/
int X_GetInteger(int id)
{
switch(id)
{
case DD_DMU_VERSION:
return DMUAPI_VER;

default:
break;
}
// ID not recognized, return NULL.
return 0;
return Common_GetInteger(id);
}

/**
Expand Down

0 comments on commit 2b558de

Please sign in to comment.