Skip to content

Commit

Permalink
Refactor|libcommon: Switched common/src/dmu_lib to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Aug 7, 2013
1 parent 4764787 commit 7b15675
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 307 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/common.pri
Expand Up @@ -71,7 +71,7 @@ SOURCES += \
$$common_src/d_net.c \
$$common_src/d_netcl.c \
$$common_src/d_netsv.c \
$$common_src/dmu_lib.c \
$$common_src/dmu_lib.cpp \
$$common_src/fi_lib.c \
$$common_src/g_controls.c \
$$common_src/g_defs.c \
Expand Down
91 changes: 53 additions & 38 deletions doomsday/plugins/common/include/dmu_lib.h
Expand Up @@ -136,22 +136,33 @@
#define DMU_CEILING_NORMAL_Z (DMU_CEILING_OF_SECTOR | DMU_NORMAL_Z)
#define DMU_CEILING_NORMAL_XYZ (DMU_CEILING_OF_SECTOR | DMU_NORMAL_XYZ)

#ifdef __cplusplus
extern "C" {
#endif

void P_BuildLineTagLists(void);

void P_DestroyLineTagLists(void);
iterlist_t* P_GetLineIterListForTag(int tag, boolean createNewList);

iterlist_t *P_GetLineIterListForTag(int tag, boolean createNewList);

void P_BuildSectorTagLists(void);

void P_DestroySectorTagLists(void);
iterlist_t* P_GetSectorIterListForTag(int tag, boolean createNewList);

iterlist_t *P_GetSectorIterListForTag(int tag, boolean createNewList);

void P_BuildAllTagLists(void);

void P_DestroyAllTagLists(void);

Line* P_AllocDummyLine(void);
void P_FreeDummyLine(Line* line);
Line *P_AllocDummyLine(void);

void P_FreeDummyLine(Line *line);

Side* P_AllocDummySide(void);
void P_FreeDummySide(Side* side);
Side *P_AllocDummySide(void);

void P_FreeDummySide(Side *side);

/**
* Get the sector on the other side of the line that is NOT the given sector.
Expand All @@ -161,113 +172,117 @@ void P_FreeDummySide(Side* side);
*
* @return Ptr to the other sector or @c NULL if the specified line is NOT twosided.
*/
Sector* P_GetNextSector(Line* line, Sector* sec);
Sector *P_GetNextSector(Line *line, Sector *sec);

#define FEPHF_MIN 0x1 // Get minium. If not set, get maximum.
#define FEPHF_FLOOR 0x2 // Get floors. If not set, get ceilings.

typedef struct findextremalplaneheightparams_s {
Sector* baseSec;
Sector *baseSec;
byte flags;
coord_t val;
Sector* foundSec;
Sector *foundSec;
} findextremalplaneheightparams_t;

/// Find the sector with the lowest floor height in surrounding sectors.
Sector* P_FindSectorSurroundingLowestFloor(Sector* sector, coord_t max, coord_t* val);
Sector *P_FindSectorSurroundingLowestFloor(Sector *sector, coord_t max, coord_t *val);

/// Find the sector with the highest floor height in surrounding sectors.
Sector* P_FindSectorSurroundingHighestFloor(Sector* sector, coord_t min, coord_t* val);
Sector *P_FindSectorSurroundingHighestFloor(Sector *sector, coord_t min, coord_t *val);

/// Find lowest ceiling in the surrounding sector.
Sector* P_FindSectorSurroundingLowestCeiling(Sector* sector, coord_t max, coord_t* val);
Sector *P_FindSectorSurroundingLowestCeiling(Sector *sector, coord_t max, coord_t *val);

/// Find highest ceiling in the surrounding sectors.
Sector* P_FindSectorSurroundingHighestCeiling(Sector* sector, coord_t min, coord_t* val);
Sector *P_FindSectorSurroundingHighestCeiling(Sector *sector, coord_t min, coord_t *val);

#define FNPHF_FLOOR 0x1 // Get floors, if not set get ceilings.
#define FNPHF_ABOVE 0x2 // Get next above, if not set get next below.

typedef struct findnextplaneheightparams_s {
Sector* baseSec;
Sector *baseSec;
coord_t baseHeight;
byte flags;
coord_t val;
Sector* foundSec;
Sector *foundSec;
} findnextplaneheightparams_t;

/// Find the sector with the next highest floor in surrounding sectors.
Sector* P_FindSectorSurroundingNextHighestFloor(Sector* sector, coord_t baseHeight, coord_t* val);
Sector *P_FindSectorSurroundingNextHighestFloor(Sector *sector, coord_t baseHeight, coord_t *val);

/// Find the sector with the next lowest floor in surrounding sectors.
Sector* P_FindSectorSurroundingNextLowestFloor(Sector* sector, coord_t baseHeight, coord_t* val);
Sector *P_FindSectorSurroundingNextLowestFloor(Sector *sector, coord_t baseHeight, coord_t *val);

/// Find the sector with the next highest ceiling in surrounding sectors.
Sector* P_FindSectorSurroundingNextHighestCeiling(Sector* sector, coord_t baseHeight, coord_t* val);
Sector *P_FindSectorSurroundingNextHighestCeiling(Sector *sector, coord_t baseHeight, coord_t *val);

/// Find the sector with the next lowest ceiling in surrounding sectors.
Sector* P_FindSectorSurroundingNextLowestCeiling(Sector* sector, coord_t baseHeight, coord_t* val);
Sector *P_FindSectorSurroundingNextLowestCeiling(Sector *sector, coord_t baseHeight, coord_t *val);

#define FELLF_MIN 0x1 /// Get minimum. If not set, get maximum.

typedef struct findlightlevelparams_s {
Sector* baseSec;
Sector *baseSec;
byte flags;
float val;
Sector* foundSec;
Sector *foundSec;
} findlightlevelparams_t;

/// Find the sector with the lowest light level in surrounding sectors.
Sector* P_FindSectorSurroundingLowestLight(Sector* sector, float* val);
Sector *P_FindSectorSurroundingLowestLight(Sector *sector, float *val);

/// Find the sector with the highest light level in surrounding sectors.
Sector* P_FindSectorSurroundingHighestLight(Sector* sector, float* val);
Sector *P_FindSectorSurroundingHighestLight(Sector *sector, float *val);

#define FNLLF_ABOVE 0x1 /// Get next above, if not set get next below.

typedef struct findnextlightlevelparams_s {
Sector* baseSec;
Sector *baseSec;
float baseLight;
byte flags;
float val;
Sector* foundSec;
Sector *foundSec;
} findnextlightlevelparams_t;

/// Find the sector with the lowest light level in surrounding sectors.
Sector* P_FindSectorSurroundingNextLowestLight(Sector* sector, float baseLight, float* val);
Sector *P_FindSectorSurroundingNextLowestLight(Sector *sector, float baseLight, float *val);

/// Find the sector with the next highest light level in surrounding sectors.
Sector* P_FindSectorSurroundingNextHighestLight(Sector* sector, float baseLight, float* val);
Sector *P_FindSectorSurroundingNextHighestLight(Sector *sector, float baseLight, float *val);

/**
* Returns the material type of the specified sector, plane.
*
* @param sec The sector to check.
* @param plane The plane id to check.
*/
const terraintype_t* P_PlaneMaterialTerrainType(Sector* sec, int plane);
terraintype_t const *P_PlaneMaterialTerrainType(Sector *sec, int plane);

/**
* Copies all (changeable) properties from one line to another including the
* extended properties.
*/
void P_CopyLine(Line* dest, Line* src);
void P_CopyLine(Line *dest, Line *src);

/**
* Copies all (changeable) properties from one sector to another including
* the extended properties.
*/
void P_CopySector(Sector* dest, Sector* src);
void P_CopySector(Sector *dest, Sector *src);

float P_SectorLight(Sector *sector);
void P_SectorSetLight(Sector *sector, float level);
void P_SectorModifyLight(Sector *sector, float value);
void P_SectorModifyLightx(Sector *sector, fixed_t value);

float P_SectorLight(Sector* sector);
void P_SectorSetLight(Sector* sector, float level);
void P_SectorModifyLight(Sector* sector, float value);
void P_SectorModifyLightx(Sector* sector, fixed_t value);
void P_TranslateSideMaterialOrigin(Side *side, SideSection section, float deltaXY[2]);
void P_TranslateSideMaterialOriginXY(Side *side, SideSection section, float deltaX, float deltaY);

void P_TranslateSideMaterialOrigin(Side* side, SideSection section, float deltaXY[2]);
void P_TranslateSideMaterialOriginXY(Side* side, SideSection section, float deltaX, float deltaY);
void P_TranslatePlaneMaterialOrigin(Plane *plane, float deltaXY[2]);
void P_TranslatePlaneMaterialOriginXY(Plane *plane, float deltaX, float deltaY);

void P_TranslatePlaneMaterialOrigin(Plane* plane, float deltaXY[2]);
void P_TranslatePlaneMaterialOriginXY(Plane* plane, float deltaX, float deltaY);
#ifdef __cplusplus
} // extern "C"
#endif

#endif /* LIBCOMMON_DMU_LIB_H */
35 changes: 21 additions & 14 deletions doomsday/plugins/common/include/p_iterlist.h
@@ -1,7 +1,6 @@
/**
* @file p_iterlist.h
/** @file p_iterlist.h
*
* @author Copyright &copy; 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -35,30 +34,38 @@ typedef enum {
struct iterlist_s;
typedef struct iterlist_s iterlist_t;

iterlist_t* IterList_New(void);
#ifdef __cplusplus
extern "C" {
#endif

iterlist_t *IterList_New(void);

void IterList_Delete(iterlist_t* list);
void IterList_Delete(iterlist_t *list);

/**
* Push a new pointer onto the top of the stack.
* @param data User data pointer to be added.
* @return Index associated to the newly added object.
*/
int IterList_PushBack(iterlist_t* list, void* data);
int IterList_PushBack(iterlist_t *list, void *data);

void* IterList_Pop(iterlist_t* list);
void* IterList_Pop(iterlist_t *list);

void IterList_Clear(iterlist_t* list);
void IterList_Clear(iterlist_t *list);

int IterList_Size(iterlist_t* list);
int IterList_Size(iterlist_t *list);

boolean IterList_Empty(iterlist_t* list);
boolean IterList_Empty(iterlist_t *list);

/// @return Current pointer being pointed at.
void* IterList_MoveIterator(iterlist_t* list);
void* IterList_MoveIterator(iterlist_t *list);

void IterList_RewindIterator(iterlist_t *list);

void IterList_RewindIterator(iterlist_t* list);
void IterList_SetIteratorDirection(iterlist_t *list, iterlist_iterator_direction_t direction);

void IterList_SetIteratorDirection(iterlist_t* list, iterlist_iterator_direction_t direction);
#ifdef __cplusplus
} // extern "C"
#endif

#endif // LIBCOMMON_ITERLIST_H
#endif /* LIBCOMMON_ITERLIST_H */
64 changes: 33 additions & 31 deletions doomsday/plugins/common/include/p_terraintype.h
@@ -1,41 +1,35 @@
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file p_terraintype.h Material terrain type.
*
*\author Copyright © 2009-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2009-2013 Daniel Swanson <danij@dengine.net>
*
* 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
*/

/**
* Material -> TerrainType xlat database.
* <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 LIBCOMMON_TERRAINTYPE_H
#define LIBCOMMON_TERRAINTYPE_H

#define TTF_NONSOLID 0x1 /* Various implications:
1) Bouncing mobjs destroyed on contact.
2) Able mobjs can dive/surface. */
#define TTF_FLOORCLIP 0x2 // Mobjs contacting this terrain will sink into it.
#define TTF_NONSOLID 0x1 /**
* Various implications:
* 1) Bouncing mobjs destroyed on contact.
* 2) Able mobjs can dive/surface.
*/
#define TTF_FLOORCLIP 0x2 ///< Mobjs contacting this terrain will sink into it.
#define TTF_FRICTION_LOW 0x4
#define TTF_FRICTION_HIGH 0x8

// Mobjs contacting this cause various fx to be spawned:
/// Mobjs contacting this cause various fx to be spawned:
#if __JHERETIC__ || __JHEXEN__
#define TTF_SPAWN_SPLASHES 0x10
#define TTF_SPAWN_SMOKE 0x20
Expand All @@ -46,16 +40,24 @@
#define TTF_DAMAGING 0x80
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct terraindef_s {
char* name; // Symbolic name for this terrain.
short flags; // TTF_* terrain type flags.
char *name; ///< Symbolic name for this terrain.
short flags; ///< TTF_* terrain type flags.
} terraintype_t;

void P_InitTerrainTypes(void);
void P_ShutdownTerrainTypes(void);
void P_ClearTerrainTypes(void);

const terraintype_t* P_TerrainTypeForMaterial(Material* mat);
const terraintype_t* P_PlaneMaterialTerrainType(Sector* sec, int plane);
terraintype_t const *P_TerrainTypeForMaterial(Material *mat);
terraintype_t const *P_PlaneMaterialTerrainType(Sector *sec, int plane);

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* LIBCOMMON_TERRAINTYPE_H */

0 comments on commit 7b15675

Please sign in to comment.