Skip to content

Commit

Permalink
Wad Map Converter|Refactor: Further cleanup refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jul 28, 2012
1 parent cae47e6 commit f76a56a
Show file tree
Hide file tree
Showing 9 changed files with 746 additions and 675 deletions.
87 changes: 87 additions & 0 deletions doomsday/plugins/wadmapconverter/include/id1map.h
@@ -0,0 +1,87 @@
/**
* @file id1map_load.h @ingroup wadmapconverter
*
* @authors Copyright &copy; 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_H__
#define __WADMAPCONVERTER_ID1MAP_H__

#include "doomsday.h"
#include "dd_types.h"
#include "maplumpinfo.h"
#include "id1map_datatypes.h"
#include "id1map_load.h"
#include "id1map_util.h"
#include <vector>
#include <list>

typedef std::vector<mline_t> Lines;
typedef std::vector<mside_t> Sides;
typedef std::vector<msector_t> Sectors;
typedef std::vector<mthing_t> Things;
typedef std::vector<surfacetint_t> SurfaceTints;
typedef std::list<mpolyobj_t> Polyobjs;

class Id1Map
{
public:
uint numVertexes;
coord_t* vertexes; ///< Array of vertex coords [v0:X, vo:Y, v1:X, v1:Y, ..]

Lines lines;
Sides sides;
Sectors sectors;
Things things;
SurfaceTints surfaceTints;
Polyobjs polyobjs;

StringPool* materials; ///< Material dictionary.

Id1Map();
~Id1Map();

int load(MapLumpInfo* lumpInfos[NUM_MAPLUMP_TYPES]);

void analyze(void);

int transfer(void);

MaterialDictId addMaterialToDictionary(const char* name, MaterialDictGroup group);

private:
inline const Str* findMaterialInDictionary(MaterialDictId id)
{
return StringPool_String(materials, id);
}

bool loadVertexes(Reader* reader, uint numElements);
bool loadLineDefs(Reader* reader, uint numElements);
bool loadSideDefs(Reader* reader, uint numElements);
bool loadSectors(Reader* reader, uint numElements);
bool loadThings(Reader* reader, uint numElements);
bool loadSurfaceTints(Reader* reader, uint numElements);

void transferVertexes(void);
void transferSectors(void);
void transferLinesAndSides(void);
void transferSurfaceTints(void);
void transferPolyobjs(void);
void transferThings(void);
};

#endif /* __WADMAPCONVERTER_ID1MAP_H__ */
28 changes: 0 additions & 28 deletions doomsday/plugins/wadmapconverter/include/id1map_datatypes.h
Expand Up @@ -24,8 +24,6 @@
#include "doomsday.h"
#include "dd_types.h"
#include "id1map_util.h"
#include <vector>
#include <list>

/// Sizes of the map data structures in the arrived map formats (in int8_ts).
#define SIZEOF_64VERTEX (4 * 2)
Expand Down Expand Up @@ -155,30 +153,4 @@ typedef struct mlight_s {
int8_t xx[3];
} surfacetint_t;

typedef std::vector<mline_t> Lines;
typedef std::vector<mside_t> Sides;
typedef std::vector<msector_t> Sectors;
typedef std::vector<mthing_t> Things;
typedef std::vector<surfacetint_t> SurfaceTints;
typedef std::list<mpolyobj_t> Polyobjs;

class Id1Map
{
public:
uint numVertexes;
coord_t* vertexes; ///< Array of vertex coords [v0:X, vo:Y, v1:X, v1:Y, ..]

Lines lines;
Sides sides;
Sectors sectors;
Things things;
SurfaceTints surfaceTints;
Polyobjs polyobjs;

StringPool* materials; ///< Material dictionary.

Id1Map();
~Id1Map();
};

#endif /* __WADMAPCONVERTER_ID1MAP_DATATYPES_H__ */
21 changes: 11 additions & 10 deletions doomsday/plugins/wadmapconverter/include/id1map_load.h
Expand Up @@ -22,17 +22,18 @@
#define __WADMAPCONVERTER_ID1MAP_LOAD_H__

#include "doomsday.h"
#include "dd_types.h"
#include "maplumpinfo.h"
#include "id1map_datatypes.h"

extern mapformatid_t DENG_PLUGIN_GLOBAL(mapFormat);
extern Id1Map* DENG_PLUGIN_GLOBAL(map);

int LoadMap(MapLumpInfo* lumpInfos[NUM_MAPLUMP_TYPES]);

void AnalyzeMap(void);

int TransferMap(void);
void MLine_Read(mline_t* l, Reader* reader);
void MLine64_Read(mline_t* l, Reader* reader);
void MLineHx_Read(mline_t* l, Reader* reader);
void MSide_Read(mside_t* s, Reader* reader);
void MSide64_Read(mside_t* s, Reader* reader);
void MSector_Read(msector_t* s, Reader* reader);
void MSector64_Read(msector_t* s, Reader* reader);
void MThing_Read(mthing_t* t, Reader* reader);
void MThing64_Read(mthing_t* t, Reader* reader);
void MThingHx_Read(mthing_t* t, Reader* reader);
void SurfaceTint_Read(surfacetint_t* t, Reader* reader);

#endif /* __WADMAPCONVERTER_ID1MAP_LOAD_H__ */
6 changes: 4 additions & 2 deletions doomsday/plugins/wadmapconverter/include/wadmapconverter.h
Expand Up @@ -29,7 +29,9 @@
#include "doomsday.h"
#include "dd_plugin.h"

#include "id1map_load.h"
#include "id1map_util.h"
#include "id1map.h"

extern mapformatid_t DENG_PLUGIN_GLOBAL(mapFormat);
extern Id1Map* DENG_PLUGIN_GLOBAL(map);

#endif /* end of include guard: __WADMAPCONVERTER_H__ */

0 comments on commit f76a56a

Please sign in to comment.