From 2b558dedbcbca5cf6776efaf46a43fbb151998c8 Mon Sep 17 00:00:00 2001 From: skyjake Date: Sat, 15 Sep 2012 14:31:18 +0300 Subject: [PATCH] libcommon|All Games: Common GetInteger routine for all games --- doomsday/plugins/common/common.pri | 1 + doomsday/plugins/common/include/common.h | 2 ++ doomsday/plugins/common/src/common.c | 43 ++++++++++++++++++++++++ doomsday/plugins/jdoom/src/d_main.c | 10 +----- doomsday/plugins/jdoom64/src/d_main.c | 11 +----- doomsday/plugins/jheretic/src/h_main.c | 11 +----- doomsday/plugins/jhexen/src/h2_main.c | 11 +----- 7 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 doomsday/plugins/common/src/common.c diff --git a/doomsday/plugins/common/common.pri b/doomsday/plugins/common/common.pri index b9f5c3953b..8192f0c8e5 100644 --- a/doomsday/plugins/common/common.pri +++ b/doomsday/plugins/common/common.pri @@ -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 \ diff --git a/doomsday/plugins/common/include/common.h b/doomsday/plugins/common/include/common.h index 7175528f2b..087dc1421e 100644 --- a/doomsday/plugins/common/include/common.h +++ b/doomsday/plugins/common/include/common.h @@ -37,4 +37,6 @@ # include "jhexen.h" #endif +int Common_GetInteger(int id); + #endif /// LIBCOMMON_GAME_INCLUDES diff --git a/doomsday/plugins/common/src/common.c b/doomsday/plugins/common/src/common.c new file mode 100644 index 0000000000..9404908dc5 --- /dev/null +++ b/doomsday/plugins/common/src/common.c @@ -0,0 +1,43 @@ +/** + * @file common.c + * Top-level libcommon routines. + * + * @authors Copyright © 2012 Jaakko Keränen + * @authors Copyright © 2012 Daniel Swanson + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html + * + * 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 + */ + +#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; +} + diff --git a/doomsday/plugins/jdoom/src/d_main.c b/doomsday/plugins/jdoom/src/d_main.c index f632e3ef41..5e64f62d13 100644 --- a/doomsday/plugins/jdoom/src/d_main.c +++ b/doomsday/plugins/jdoom/src/d_main.c @@ -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); } /** diff --git a/doomsday/plugins/jdoom64/src/d_main.c b/doomsday/plugins/jdoom64/src/d_main.c index 6784a7684f..850742e743 100644 --- a/doomsday/plugins/jdoom64/src/d_main.c +++ b/doomsday/plugins/jdoom64/src/d_main.c @@ -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); } /** diff --git a/doomsday/plugins/jheretic/src/h_main.c b/doomsday/plugins/jheretic/src/h_main.c index 2c035c36e6..72798313c9 100644 --- a/doomsday/plugins/jheretic/src/h_main.c +++ b/doomsday/plugins/jheretic/src/h_main.c @@ -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); } /** diff --git a/doomsday/plugins/jhexen/src/h2_main.c b/doomsday/plugins/jhexen/src/h2_main.c index 8cd1d5b63e..4a868027a3 100644 --- a/doomsday/plugins/jhexen/src/h2_main.c +++ b/doomsday/plugins/jhexen/src/h2_main.c @@ -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); } /**