Navigation Menu

Skip to content

Commit

Permalink
Refactor|libhexen: Switched p_pillar.c and p_waggle.c to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jan 29, 2014
1 parent d9f4cc5 commit a015765
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 262 deletions.
4 changes: 2 additions & 2 deletions doomsday/plugins/hexen/hexen.pro
Expand Up @@ -89,13 +89,13 @@ SOURCES += \
src/p_mapinfo.cpp \
src/p_maputl.c \
src/p_mobj.c \
src/p_pillar.c \
src/p_pillar.cpp \
src/p_pspr.c \
src/p_setup.c \
src/p_spec.c \
src/p_telept.c \
src/p_things.c \
src/p_waggle.c \
src/p_waggle.cpp \
src/sn_sonix.cpp \
src/st_stuff.c \
src/tables.c \
Expand Down
46 changes: 22 additions & 24 deletions doomsday/plugins/hexen/include/p_pillar.h
@@ -1,26 +1,22 @@
/**\file p_pillar.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file p_pillar.h
*
*\author Copyright © 2004-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
*\author Copyright © 1999 Activision
* @authors Copyright © 2004-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 1999 Activision
*
* 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
* <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 LIBHEXEN_P_PILLAR_H
Expand All @@ -32,7 +28,7 @@

typedef struct {
thinker_t thinker;
Sector* sector;
Sector *sector;
float ceilingSpeed;
float floorSpeed;
coord_t floorDest;
Expand All @@ -45,9 +41,11 @@ typedef struct {
extern "C" {
#endif

void T_BuildPillar(pillar_t* pillar);
int EV_BuildPillar(Line* line, byte* args, dd_bool crush);
int EV_OpenPillar(Line* line, byte* args);
void T_BuildPillar(pillar_t *pillar);

int EV_BuildPillar(Line *line, byte *args, dd_bool crush);

int EV_OpenPillar(Line *line, byte *args);

#ifdef __cplusplus
} // extern "C"
Expand Down
40 changes: 18 additions & 22 deletions doomsday/plugins/hexen/include/p_waggle.h
@@ -1,26 +1,22 @@
/**\file p_waggle.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file p_waggle.h
*
*\author Copyright © 2004-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
*\author Copyright © 1999 Activision
* @authors Copyright © 2004-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 1999 Activision
*
* 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
* <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 LIBHEXEN_P_WAGGLE_H
Expand All @@ -38,7 +34,7 @@ typedef enum {

typedef struct {
thinker_t thinker;
Sector* sector;
Sector *sector;
coord_t originalHeight;
coord_t accumulator;
coord_t accDelta;
Expand All @@ -53,7 +49,7 @@ typedef struct {
extern "C" {
#endif

void T_FloorWaggle(waggle_t* waggle);
void T_FloorWaggle(waggle_t *waggle);
dd_bool EV_StartFloorWaggle(int tag, int height, int speed, int offset, int timer);

#ifdef __cplusplus
Expand Down
@@ -1,99 +1,71 @@
/**\file
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file p_pillar.cpp
*
*\author Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*\author Copyright © 1999 Activision
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 1999 Activision
*
* 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
*/

/**
* p_pillar.c:
* <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>
*/

// HEADER FILES ------------------------------------------------------------

#include "jhexen.h"
#include "p_pillar.h"

#include "dmu_lib.h"
#include "p_mapspec.h"
#include "p_iterlist.h"

// MACROS ------------------------------------------------------------------

// TYPES -------------------------------------------------------------------

// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------

// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------

// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------

// EXTERNAL DATA DECLARATIONS ----------------------------------------------

// PUBLIC DATA DEFINITIONS -------------------------------------------------

// PRIVATE DATA DEFINITIONS ------------------------------------------------

// CODE --------------------------------------------------------------------

void T_BuildPillar(pillar_t *pillar)
{
result_e res1;
result_e res2;
DENG_ASSERT(pillar != 0);

// First, raise the floor
res1 = T_MovePlane(pillar->sector, pillar->floorSpeed, pillar->floorDest, pillar->crush, 0, pillar->direction); // floorOrCeiling, direction
result_e res1 = T_MovePlane(pillar->sector, pillar->floorSpeed, pillar->floorDest, pillar->crush, 0, pillar->direction); // floorOrCeiling, direction
// Then, lower the ceiling
res2 = T_MovePlane(pillar->sector, pillar->ceilingSpeed, pillar->ceilingDest, pillar->crush, 1, -pillar->direction);
result_e res2 = T_MovePlane(pillar->sector, pillar->ceilingSpeed, pillar->ceilingDest, pillar->crush, 1, -pillar->direction);
if(res1 == pastdest && res2 == pastdest)
{
P_ToXSector(pillar->sector)->specialData = NULL;
P_ToXSector(pillar->sector)->specialData = 0;
SN_StopSequenceInSec(pillar->sector);
P_ACScriptTagFinished(P_ToXSector(pillar->sector)->tag);
Thinker_Remove(&pillar->thinker);
}
}

int EV_BuildPillar(Line* line, byte* args, dd_bool crush)
int EV_BuildPillar(Line *line, byte *args, dd_bool crush)
{
int rtn = 0;
coord_t newHeight;
Sector* sec = NULL;
pillar_t* pillar;
iterlist_t* list;
iterlist_t *list = P_GetSectorIterListForTag((int) args[0], false);
if(!list) return 0;

list = P_GetSectorIterListForTag((int) args[0], false);
if(!list) return rtn;
int rtn = 0;

IterList_SetIteratorDirection(list, ITERLIST_FORWARD);
IterList_RewindIterator(list);
while((sec = IterList_MoveIterator(list)) != NULL)

Sector *sec;
while((sec = (Sector *)IterList_MoveIterator(list)))
{
// If already moving keep going...
if(P_ToXSector(sec)->specialData)
continue; // Already moving, so keep going.
continue;

if(FEQUAL(P_GetDoublep(sec, DMU_FLOOR_HEIGHT),
P_GetDoublep(sec, DMU_CEILING_HEIGHT)))
continue; // Pillar is already closed.

rtn = 1;
coord_t newHeight = 0;
if(!args[2])
{
newHeight = P_GetDoublep(sec, DMU_FLOOR_HEIGHT) +
Expand All @@ -105,7 +77,7 @@ int EV_BuildPillar(Line* line, byte* args, dd_bool crush)
newHeight = P_GetDoublep(sec, DMU_FLOOR_HEIGHT) + (coord_t) args[2];
}

pillar = Z_Calloc(sizeof(*pillar), PU_MAP, 0);
pillar_t *pillar = (pillar_t *)Z_Calloc(sizeof(*pillar), PU_MAP, 0);
pillar->thinker.function = (thinkfunc_t) T_BuildPillar;
Thinker_Add(&pillar->thinker);

Expand Down Expand Up @@ -137,36 +109,36 @@ int EV_BuildPillar(Line* line, byte* args, dd_bool crush)
pillar->ceilingDest = newHeight;
pillar->direction = 1;
pillar->crush = crush * (int) args[3];
SN_StartSequence(P_GetPtrp(pillar->sector, DMU_EMITTER),
SN_StartSequence((mobj_t *)P_GetPtrp(pillar->sector, DMU_EMITTER),
SEQ_PLATFORM + P_ToXSector(pillar->sector)->seqType);
}
return rtn;
}

int EV_OpenPillar(Line* line, byte* args)
int EV_OpenPillar(Line *line, byte *args)
{
int rtn = 0;
Sector* sec = NULL;
pillar_t* pillar;
iterlist_t* list;
iterlist_t *list = P_GetSectorIterListForTag((int) args[0], false);
if(!list) return 0;

list = P_GetSectorIterListForTag((int) args[0], false);
if(!list) return rtn;
int rtn = 0;

IterList_SetIteratorDirection(list, ITERLIST_FORWARD);
IterList_RewindIterator(list);
while((sec = IterList_MoveIterator(list)) != NULL)

Sector *sec;
while((sec = (Sector *)IterList_MoveIterator(list)))
{
// If already moving keep going...
if(P_ToXSector(sec)->specialData)
continue; // Already moving, so keep going...
continue;

if(!FEQUAL(P_GetDoublep(sec, DMU_FLOOR_HEIGHT),
P_GetDoublep(sec, DMU_CEILING_HEIGHT)))
continue; // Pillar isn't closed.

rtn = 1;

pillar = Z_Calloc(sizeof(*pillar), PU_MAP, 0);
pillar_t *pillar = (pillar_t *)Z_Calloc(sizeof(*pillar), PU_MAP, 0);
pillar->thinker.function = (thinkfunc_t) T_BuildPillar;
Thinker_Add(&pillar->thinker);

Expand Down Expand Up @@ -210,7 +182,7 @@ int EV_OpenPillar(Line* line, byte* args)
}

pillar->direction = -1; // Open the pillar.
SN_StartSequence(P_GetPtrp(pillar->sector, DMU_EMITTER),
SN_StartSequence((mobj_t *)P_GetPtrp(pillar->sector, DMU_EMITTER),
SEQ_PLATFORM + P_ToXSector(pillar->sector)->seqType);
}

Expand Down

0 comments on commit a015765

Please sign in to comment.