Skip to content

Commit

Permalink
Refactor|Hexen: Use HexLex to parse MAPINFO data
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 23, 2014
1 parent 29e810a commit 2457b28
Show file tree
Hide file tree
Showing 8 changed files with 401 additions and 440 deletions.
3 changes: 3 additions & 0 deletions doomsday/plugins/common/src/common.c
Expand Up @@ -23,6 +23,9 @@
#include "common.h"
#include "g_common.h"

dd_bool sc_FileScripts = false;
char const *sc_ScriptsDir = "";

int Common_GetInteger(int id)
{
switch(id)
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/common/src/p_start.cpp
Expand Up @@ -187,7 +187,8 @@ void P_Update()
P_InitInventory();
#endif
#if __JHEXEN__
P_InitMapInfo();
MapInfoParser(sc_FileScripts? Str_Appendf(AutoStr_New(), "%sMAPINFO.txt", sc_ScriptsDir)
: AutoStr_FromText("Lumps:MAPINFO"));
#endif
P_InitSwitchList();
P_InitTerrainTypes();
Expand Down
3 changes: 1 addition & 2 deletions doomsday/plugins/hexen/hexen.pro
Expand Up @@ -88,7 +88,7 @@ SOURCES += \
src/p_enemy.c \
src/p_inter.c \
src/p_lights.c \
src/p_mapinfo.c \
src/p_mapinfo.cpp \
src/p_maputl.c \
src/p_mobj.c \
src/p_pillar.c \
Expand All @@ -98,7 +98,6 @@ SOURCES += \
src/p_telept.c \
src/p_things.c \
src/p_waggle.c \
src/sc_man.c \
src/sn_sonix.c \
src/st_stuff.c \
src/tables.c \
Expand Down
1 change: 0 additions & 1 deletion doomsday/plugins/hexen/include/jhexen.h
Expand Up @@ -57,7 +57,6 @@
#include "../../hexen/include/r_defs.h"
#include "../../hexen/include/r_local.h"
#include "../../hexen/include/s_sequence.h"
#include "../../hexen/include/sc_man.h"
#include "../../hexen/include/st_stuff.h"
#include "../../hexen/include/textdefs.h"
#include "../../hexen/include/version.h"
Expand Down
7 changes: 3 additions & 4 deletions doomsday/plugins/hexen/include/p_mapinfo.h
Expand Up @@ -51,15 +51,14 @@ extern "C" {
#endif

/**
* Initializes the MapInfo database.
* All MAPINFO lumps are then parsed and stored into the database.
* Special early initializer needed to start sound before R_InitRefresh()
*/
void P_InitMapInfo(void);

/**
* Special early initializer needed to start sound before R_InitRefresh()
* Populate the MapInfo database by parsing the MAPINFO lump.
*/
void P_InitMapMusicInfo(void);
void MapInfoParser(Str const *path);

/**
* Returns MAPINFO data for the specified @a map, or the default if not valid.
Expand Down
70 changes: 23 additions & 47 deletions doomsday/plugins/hexen/src/h2_main.c
@@ -1,38 +1,25 @@
/**\file h2_main.c
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file h2_main.c Hexen specifc game initialization.
*
*\author Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006 Jamie Jones <yagisan@dengine.net>
*\author Copyright © 1999 Activision
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2006 Jamie Jones <yagisan@dengine.net>
* @authors Copyright © 1999 Activision
*
* 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.
*
* 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
*/

/**
* Game initialization - Hexen specifc.
* <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>
*/

// HEADER FILES ------------------------------------------------------------

#include <assert.h>
#include <string.h>

#include "jhexen.h"

#include "am_map.h"
Expand All @@ -46,19 +33,8 @@
#include "p_saveg.h"
#include "p_sound.h"

// MACROS ------------------------------------------------------------------

// TYPES -------------------------------------------------------------------

// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------

// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------

// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------

// EXTERNAL DATA DECLARATIONS ----------------------------------------------

// PUBLIC DATA DEFINITIONS -------------------------------------------------
#include <assert.h>
#include <string.h>

int verbose;

Expand Down Expand Up @@ -347,9 +323,9 @@ void X_PreInit(void)
*/
void X_PostInit(void)
{
AutoStr* path;
AutoStr *path;
int p, warpMap;
Uri* uri;
Uri *uri;

// Do this early as other systems need to know.
P_InitPlayerClassInfo();
Expand Down Expand Up @@ -399,7 +375,7 @@ void X_PostInit(void)
sc_ScriptsDir = CommandLine_At(p + 1);
}

P_InitMapMusicInfo(); // Init music fields in mapinfo.
P_InitMapInfo(); // Init music fields in mapinfo.

App_Log(DE2_RES_VERBOSE, "Parsing SNDINFO...");
S_ParseSndInfoLump();
Expand All @@ -411,7 +387,7 @@ void X_PostInit(void)
p = CommandLine_CheckWith("-loadgame", 1);
if(p != 0)
{
const int saveSlot = SV_ParseSlotIdentifier(CommandLine_At(p + 1));
int const saveSlot = SV_ParseSlotIdentifier(CommandLine_At(p + 1));
if(SV_IsUserWritableSlot(saveSlot) && G_LoadGame(saveSlot))
{
// No further initialization is to be done.
Expand Down

0 comments on commit 2457b28

Please sign in to comment.