Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor: Split up p_dmu.h; produced DmuArgs from setargs_t
  • Loading branch information
danij-deng committed Jun 7, 2013
1 parent 679f9bb commit b9f73d2
Show file tree
Hide file tree
Showing 28 changed files with 885 additions and 966 deletions.
16 changes: 15 additions & 1 deletion doomsday/api/api_map.h
Expand Up @@ -373,7 +373,20 @@ DENG_API_TYPEDEF(Map)
*/
void (*SetTraceOpening)(Line* line);

// Map Updates (DMU)
/*
* Map Updates (DMU):
*
* The Map Update API is used for accessing and making changes to map data
* during gameplay. From here, the relevant engine's subsystems will be
* notified of changes in the map data they use, thus allowing them to
* update their status whenever needed.
*/

/**
* Translate a DMU element/property constant to a string. Primarily intended
* for error/debug messages.
*/
char const* (*Str)(uint prop);

/**
* Determines the type of the map data object.
Expand Down Expand Up @@ -612,6 +625,7 @@ DENG_API_T(Map);
#define P_TraceOpening _api_Map.traceOpening
#define P_SetTraceOpening _api_Map.SetTraceOpening

#define DMU_Str _api_Map.Str
#define DMU_GetType _api_Map.GetType
#define P_ToIndex _api_Map.ToIndex
#define P_ToPtr _api_Map.ToPtr
Expand Down
5 changes: 3 additions & 2 deletions doomsday/client/client.pro
Expand Up @@ -366,14 +366,14 @@ DENG_HEADERS += \
include/world/bspleaf.h \
include/world/bspnode.h \
include/world/dam_file.h \
include/world/dmuargs.h \
include/world/entitydatabase.h \
include/world/generators.h \
include/world/line.h \
include/world/lineowner.h \
include/world/linesighttest.h \
include/world/map.h \
include/world/mapelement.h \
include/world/p_dmu.h \
include/world/p_intercept.h \
include/world/p_mapdata.h \
include/world/p_maptypes.h \
Expand Down Expand Up @@ -647,6 +647,7 @@ SOURCES += \
src/updater/updatersettingsdialog.cpp \
src/uri.cpp \
src/ui/signalaction.cpp \
src/world/api_map.cpp \
src/world/blockmap.cpp \
src/world/blockmapvisual.cpp \
src/world/bsp/convexsubspace.cpp \
Expand All @@ -658,14 +659,14 @@ SOURCES += \
src/world/bspleaf.cpp \
src/world/bspnode.cpp \
src/world/dam_file.cpp \
src/world/dmuargs.cpp \
src/world/entitydatabase.cpp \
src/world/generators.cpp \
src/world/line.cpp \
src/world/linesighttest.cpp \
src/world/map.cpp \
src/world/mapelement.cpp \
src/world/p_data.cpp \
src/world/p_dmu.cpp \
src/world/p_intercept.cpp \
src/world/p_maputil.cpp \
src/world/p_mobj.cpp \
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/de_play.h
Expand Up @@ -34,7 +34,7 @@
#include "BspNode"
#include "Sector"
#include "Polyobj"
#include "world/p_dmu.h"
#include "world/dmuargs.h"
#include "world/p_object.h"
#include "world/p_intercept.h"
#include "world/p_maputil.h"
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/include/resource/material.h
Expand Up @@ -24,7 +24,7 @@
#include "MapElement"
#include "def_data.h"
#include "audio/s_environ.h"
#include "world/p_dmu.h" // setargs_t
#include "world/dmuargs.h"
#ifdef __CLIENT__
# include "MaterialContext"
#endif
Expand Down Expand Up @@ -983,7 +983,7 @@ class Material : public de::MapElement,
// Observes Texture Deletion.
void textureBeingDeleted(de::Texture const &texture);

int property(setargs_t &args) const;
int property(DmuArgs &args) const;

private:
DENG2_PRIVATE(d)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/world/bspleaf.h
Expand Up @@ -290,7 +290,7 @@ class BspLeaf : public de::MapElement
#endif // __CLIENT__

protected:
int property(setargs_t &args) const;
int property(DmuArgs &args) const;

private:
DENG2_PRIVATE(d)
Expand Down
64 changes: 64 additions & 0 deletions doomsday/client/include/world/dmuargs.h
@@ -0,0 +1,64 @@
/** @file world/dmuargs.h Doomsday Map Update (API) Arguments.
*
* @author Copyright © 2006-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright © 2006-2013 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 DENG_WORLD_DMUARGS_H
#define DENG_WORLD_DMUARGS_H

#include "api_mapedit.h" // valuetype_t

/**
* Encapsulates the arguments used when routing DMU API calls to map elements.
*
* @ingroup world
*/
class DmuArgs
{
public: /// @todo make private
int type;
uint prop;
int modifiers; /// Property modifiers (e.g., line of sector)
valuetype_t valueType;
boolean *booleanValues;
byte *byteValues;
int *intValues;
fixed_t *fixedValues;
float *floatValues;
double *doubleValues;
angle_t *angleValues;
void **ptrValues;

DmuArgs(int type, uint prop);

/**
* Read the value of an argument. Does some basic type checking so that
* incompatible types are not assigned. Simple conversions are also done,
* e.g., float to fixed.
*/
void value(valuetype_t valueType, void *dst, uint index) const;

/**
* Change the value of an argument. Does some basic type checking so that
* incompatible types are not assigned. Simple conversions are also done,
* e.g., float to fixed.
*/
void setValue(valuetype_t valueType, void const *src, uint index);
};

#endif // DENG_WORLD_DMUARGS_H
8 changes: 4 additions & 4 deletions doomsday/client/include/world/line.h
Expand Up @@ -388,8 +388,8 @@ class Line : public de::MapElement
*/
void setShadowVisCount(int newCount);

int property(setargs_t &args) const;
int setProperty(setargs_t const &args);
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);

private:
DENG2_PRIVATE(d)
Expand Down Expand Up @@ -771,8 +771,8 @@ class Line : public de::MapElement
inline void replaceTo(Vertex &newVertex) { replaceVertex(To, newVertex); }

protected:
int property(setargs_t &args) const;
int setProperty(setargs_t const &args);
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);

public:
/**
Expand Down
6 changes: 6 additions & 0 deletions doomsday/client/include/world/map.h
Expand Up @@ -650,6 +650,12 @@ class Map

public: /// @todo Make private:

/**
* Initializes the dummy element arrays used with the DMU API, with a
* fixed number of dummies.
*/
static void initDummies();

void finishMapElements();

/**
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/include/world/mapelement.h
Expand Up @@ -23,7 +23,7 @@
#include <de/Error>

#include "dd_share.h"
#include "world/p_dmu.h"
#include "world/dmuargs.h"

namespace de {

Expand Down Expand Up @@ -121,7 +121,7 @@ class MapElement
* @param args Property arguments.
* @return Always @c 0 (can be used as an iterator).
*/
virtual int property(setargs_t &args) const;
virtual int property(DmuArgs &args) const;

/**
* Update a property value, selected by DMU_* name.
Expand All @@ -135,7 +135,7 @@ class MapElement
* @param args Property arguments.
* @return Always @c 0 (can be used as an iterator).
*/
virtual int setProperty(setargs_t const &args);
virtual int setProperty(DmuArgs const &args);

private:
int _type;
Expand Down
77 changes: 0 additions & 77 deletions doomsday/client/include/world/p_dmu.h

This file was deleted.

4 changes: 2 additions & 2 deletions doomsday/client/include/world/plane.h
Expand Up @@ -198,8 +198,8 @@ class Plane : public de::MapElement
Type type() const;

protected:
int property(setargs_t &args) const;
int setProperty(setargs_t const &args);
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);

private:
DENG2_PRIVATE(d)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/include/world/sector.h
Expand Up @@ -466,8 +466,8 @@ class Sector : public de::MapElement,
void setValidCount(int newValidCount);

protected:
int property(setargs_t &args) const;
int setProperty(setargs_t const &args);
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);

// Observes Plane HeightChange.
void planeHeightChanged(Plane &plane, coord_t oldHeight);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/world/segment.h
Expand Up @@ -257,7 +257,7 @@ class Segment : public de::MapElement
#endif // __CLIENT__

protected:
int property(setargs_t &args) const;
int property(DmuArgs &args) const;

private:
DENG2_PRIVATE(d)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/include/world/surface.h
Expand Up @@ -32,7 +32,7 @@
#ifdef __CLIENT__
# include "MaterialSnapshot"
#endif
#include "world/p_dmu.h"
#include "world/dmuargs.h"

class BspLeaf;

Expand Down Expand Up @@ -437,8 +437,8 @@ class Surface : public de::MapElement
/// @deprecated Unnecessary; refactor away.
bool isAttachedToMap() const;

int property(setargs_t &args) const;
int setProperty(setargs_t const &args);
int property(DmuArgs &args) const;
int setProperty(DmuArgs const &args);

private:
DENG2_PRIVATE(d)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/world/vertex.h
Expand Up @@ -125,7 +125,7 @@ class Vertex : public de::MapElement
inline void setY(coord_t newPosition) { setOriginComponent(1, newPosition); }

protected:
int property(setargs_t &args) const;
int property(DmuArgs &args) const;

public:
/**
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_main.cpp
Expand Up @@ -889,7 +889,7 @@ static int DD_BeginGameChangeWorker(void* parameters)
ddgamechange_paramaters_t* p = (ddgamechange_paramaters_t*)parameters;
DENG_ASSERT(p);

P_InitMapUpdate();
Map::initDummies();
P_InitMapEntityDefs();

if(p->initiatedBusyMode)
Expand Down

0 comments on commit b9f73d2

Please sign in to comment.