Skip to content

Commit

Permalink
DMU API: Added property DMU_ARCHIVE_INDEX
Browse files Browse the repository at this point in the history
The archive index is the position of the relevant data and/or
definition for the map element in the "archived" map. The archive
in this context is original source of the map element (e.g., from
an id Tech 1 format map).

For example, in the case of a DMU_SIDE element that is produced
from an id tech 1 format map, the archive index will be the index
of the definition in the SIDEDEFS data lump.

Todo: This info should be used when translating legacy indexes,
such as those used in the Doom ver 1.9 save game reader.
  • Loading branch information
danij-deng committed Apr 22, 2013
1 parent 78f93b8 commit 0ddfbe5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doomsday/api/api_map.h
Expand Up @@ -30,6 +30,8 @@
#include <de/aabox.h>
#include <de/mathutil.h>

#define DMT_ARCHIVE_INDEX DDVT_INT

#define DMT_VERTEX_ORIGIN DDVT_DOUBLE

#define DMT_HEDGE_SIDE DDVT_PTR
Expand Down
11 changes: 11 additions & 0 deletions doomsday/api/dd_share.h
Expand Up @@ -328,6 +328,9 @@ enum {

DMU_NONE = 0,

/*
* Element types:
*/
DMU_FIRST_ELEMENT_TYPE_ID = 1,
DMU_VERTEX = DMU_FIRST_ELEMENT_TYPE_ID,
DMU_HEDGE,
Expand All @@ -341,12 +344,20 @@ enum {
DMU_MATERIAL,
DMU_LAST_ELEMENT_TYPE_ID = DMU_MATERIAL,

/*
* Selection methods:
*/
DMU_LINE_BY_TAG,
DMU_SECTOR_BY_TAG,

DMU_LINE_BY_ACT_TAG,
DMU_SECTOR_BY_ACT_TAG,

/*
* Element properties:
*/
DMU_ARCHIVE_INDEX, ///< Relevant data/definition position in the "archived" map.

DMU_X,
DMU_Y,
DMU_XY,
Expand Down
16 changes: 13 additions & 3 deletions doomsday/client/src/map/mapelement.cpp
Expand Up @@ -56,9 +56,19 @@ MapElement &MapElement::operator = (MapElement const &other)

int MapElement::property(setargs_t &args) const
{
/// @throw UnknownPropertyError The requested property is not readable.
throw UnknownPropertyError(QString("%1::property").arg(DMU_Str(_type)),
QString("Property '%1' is unknown/not readable").arg(DMU_Str(args.prop)));
switch(args.prop)
{
case DMU_ARCHIVE_INDEX:
DMU_GetValue(DMT_ARCHIVE_INDEX, &_indexInArchive, &args, 0);
break;

default:
/// @throw UnknownPropertyError The requested property is not readable.
throw UnknownPropertyError(QString("%1::property").arg(DMU_Str(_type)),
QString("Property '%1' is unknown/not readable").arg(DMU_Str(args.prop)));
}

return false; // Continue iteration.
}

int MapElement::setProperty(setargs_t const &args)
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/src/map/p_dmu.cpp
Expand Up @@ -90,6 +90,7 @@ char const *DMU_Str(uint prop)
{ DMU_SECTOR_BY_TAG, "DMU_SECTOR_BY_TAG" },
{ DMU_LINE_BY_ACT_TAG, "DMU_LINE_BY_ACT_TAG" },
{ DMU_SECTOR_BY_ACT_TAG, "DMU_SECTOR_BY_ACT_TAG" },
{ DMU_ARCHIVE_INDEX, "DMU_ARCHIVE_INDEX" },
{ DMU_X, "DMU_X" },
{ DMU_Y, "DMU_Y" },
{ DMU_XY, "DMU_XY" },
Expand Down

0 comments on commit 0ddfbe5

Please sign in to comment.