Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wad Map Converter|Refactor: Relocated some utility routines to new so…
…urce files
- Loading branch information
1 parent
1fec202
commit ea4483c
Showing
5 changed files
with
148 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @file id1map_util.h @ingroup wadmapconverter | ||
* | ||
* @authors Copyright © 2007-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> | ||
*/ | ||
|
||
#ifndef __WADMAPCONVERTER_ID1MAP_UTIL_H__ | ||
#define __WADMAPCONVERTER_ID1MAP_UTIL_H__ | ||
|
||
#include "doomsday.h" | ||
#include "dd_types.h" | ||
#include "maplumpinfo.h" | ||
|
||
/** | ||
* Logical map format identifier (unique). | ||
*/ | ||
typedef enum { | ||
MF_UNKNOWN = -1, | ||
MF_DOOM = 0, | ||
MF_HEXEN, | ||
MF_DOOM64, | ||
NUM_MAPFORMATS | ||
} mapformatid_t; | ||
|
||
/** | ||
* Helper macro for determining whether a value can be interpreted as a logical | ||
* map format identifier (@see mapformatid_t). | ||
*/ | ||
#define VALID_MAPFORMATID(v) ((v) >= MF_DOOM && (v) < NUM_MAPFORMATS) | ||
|
||
/** | ||
* Retrieve the textual name for the identified map format @a id. | ||
* @param id Unique identifier of the map format. | ||
* @return Textual name for this format. Always returns a valid ddstring_t that | ||
* should NOT be free'd. | ||
*/ | ||
const ddstring_t* MapFormatNameForId(mapformatid_t id); | ||
|
||
/** | ||
* Determine type of a named map data lump. | ||
* @param name Name of the data lump. | ||
* @return MapLumpType associated with the named map data lump. | ||
*/ | ||
MapLumpType MapLumpTypeForName(const char* name); | ||
|
||
#endif /* __WADMAPCONVERTER_ID1MAP_UTIL_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* @file id1map_util.cpp @ingroup wadmapconverter | ||
* | ||
* Miscelaneous map conversion utility routines. | ||
* | ||
* @authors Copyright © 2003-2012 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* @authors Copyright © 2006-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 "wadmapconverter.h" | ||
#include "maplumpinfo.h" | ||
|
||
const ddstring_t* MapFormatNameForId(mapformatid_t id) | ||
{ | ||
static const ddstring_t names[1 + NUM_MAPFORMATS] = { | ||
/* MF_UNKNOWN */ { "Unknown" }, | ||
/* MF_DOOM */ { "Doom" }, | ||
/* MF_HEXEN */ { "Hexen" }, | ||
/* MF_DOOM64 */ { "Doom64" } | ||
}; | ||
if(VALID_MAPFORMATID(id)) | ||
{ | ||
return &names[1+id]; | ||
} | ||
return &names[0]; | ||
} | ||
|
||
MapLumpType MapLumpTypeForName(const char* name) | ||
{ | ||
static const struct maplumpinfo_s { | ||
const char* name; | ||
MapLumpType type; | ||
} lumptypeForNameDict[] = | ||
{ | ||
{ "THINGS", ML_THINGS }, | ||
{ "LINEDEFS", ML_LINEDEFS }, | ||
{ "SIDEDEFS", ML_SIDEDEFS }, | ||
{ "VERTEXES", ML_VERTEXES }, | ||
{ "SEGS", ML_SEGS }, | ||
{ "SSECTORS", ML_SSECTORS }, | ||
{ "NODES", ML_NODES }, | ||
{ "SECTORS", ML_SECTORS }, | ||
{ "REJECT", ML_REJECT }, | ||
{ "BLOCKMAP", ML_BLOCKMAP }, | ||
{ "BEHAVIOR", ML_BEHAVIOR }, | ||
{ "SCRIPTS", ML_SCRIPTS }, | ||
{ "LIGHTS", ML_LIGHTS }, | ||
{ "MACROS", ML_MACROS }, | ||
{ "LEAFS", ML_LEAFS }, | ||
{ "GL_VERT", ML_GLVERT }, | ||
{ "GL_SEGS", ML_GLSEGS }, | ||
{ "GL_SSECT", ML_GLSSECT }, | ||
{ "GL_NODES", ML_GLNODES }, | ||
{ "GL_PVS", ML_GLPVS}, | ||
{ NULL } | ||
}; | ||
|
||
DENG_ASSERT(name); | ||
|
||
if(name[0]) | ||
for(int i = 0; lumptypeForNameDict[i].name; ++i) | ||
{ | ||
if(!strnicmp(lumptypeForNameDict[i].name, name, strlen(lumptypeForNameDict[i].name))) | ||
return lumptypeForNameDict[i].type; | ||
} | ||
|
||
return ML_INVALID; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters