Skip to content

Commit

Permalink
Refactor|libhexen: Switched hrefresh.c to C++
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jul 2, 2014
1 parent ab641d8 commit a09e1dd
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 109 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/hexen/hexen.pro
Expand Up @@ -79,7 +79,7 @@ SOURCES += \
src/acscript.cpp \
src/h2_main.cpp \
src/hconsole.c \
src/hrefresh.c \
src/hrefresh.cpp \
src/in_lude.cpp \
src/m_cheat.cpp \
src/m_random.c \
Expand Down
@@ -1,28 +1,24 @@
/**\file hrefresh.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
/** @file hrefresh.cpp Hexen specific refresh functions/utilities.
*
*\author Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2003-2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2014 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
* <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>
*/

#include <string.h>
#include <cstring>

#include "jhexen.h"

Expand Down Expand Up @@ -85,15 +81,17 @@ dd_bool R_ViewFilterColor(float rgba[4], int filter)
return true;
}
else if(filter >= STARTHOLYPAL)
{ // White.
{
// White.
rgba[CR] = 1;
rgba[CG] = 1;
rgba[CB] = 1;
rgba[CA] = cfg.filterStrength * (STARTHOLYPAL + 3 - filter) / 6.f;
return true;
}
else if(filter == STARTICEPAL)
{ // Light blue.
{
// Light blue.
rgba[CR] = .5f;
rgba[CG] = .5f;
rgba[CB] = 1;
Expand All @@ -112,8 +110,7 @@ dd_bool R_ViewFilterColor(float rgba[4], int filter)
*/
void R_UpdateViewFilter(int player)
{
player_t* plr = players + player;
int palette = 0;
player_t *plr = players + player;

if(IS_DEDICATED && !player) return;

Expand All @@ -123,6 +120,7 @@ void R_UpdateViewFilter(int player)
// Not currently present?
if(!plr->plr->inGame) return;

int palette = 0;
if(G_GameState() == GS_MAP)
{
if(plr->overridePalette)
Expand Down Expand Up @@ -179,10 +177,7 @@ void R_UpdateViewFilter(int player)

void G_RendPlayerView(int player)
{
player_t* plr = &players[player];
dd_bool special200 = false;
float pspriteOffsetY;

player_t *plr = &players[player];
if(!plr->plr->mo)
{
App_Log(DE2_DEV_GL_ERROR, "Rendering view of player %i, who has no mobj!", player);
Expand All @@ -197,21 +192,22 @@ void G_RendPlayerView(int player)

// Check for the sector special 200: use sky2.
// I wonder where this is used?
dd_bool special200 = false;
if(P_ToXSector(Mobj_Sector(plr->plr->mo))->special == 200)
{
special200 = true;
R_SkyParams(0, DD_DISABLE, NULL);
R_SkyParams(1, DD_ENABLE, NULL);
}

pspriteOffsetY = HU_PSpriteYOffset(plr);
float pspriteOffsetY = HU_PSpriteYOffset(plr);
DD_SetVariable(DD_PSPRITE_OFFSET_Y, &pspriteOffsetY);

// $democam
GL_SetFilter((plr->plr->flags & DDPF_USE_VIEW_FILTER)? true : false);
if(plr->plr->flags & DDPF_USE_VIEW_FILTER)
{
const float* color = plr->plr->filterColor;
float const *color = plr->plr->filterColor;
GL_SetFilterColor(color[CR], color[CG], color[CB], color[CA]);
}

Expand All @@ -226,7 +222,7 @@ void G_RendPlayerView(int player)
}

#if 0
static void rendHUD(int player, const RectRaw* portGeometry)
static void rendHUD(int player, RectRaw const *portGeometry)
{
if(player < 0 || player >= MAXPLAYERS) return;
if(G_GameState() != GS_MAP) return;
Expand All @@ -238,8 +234,8 @@ static void rendHUD(int player, const RectRaw* portGeometry)
Hu_MapTitleDrawer(portGeometry);
}

void X_DrawViewPort(int port, const RectRaw* portGeometry,
const RectRaw* windowGeometry, int player, int layer)
void X_DrawViewPort(int port, RectRaw const *portGeometry,
RectRaw const *windowGeometry, int player, int layer)
{
if(layer != 0)
{
Expand All @@ -250,7 +246,7 @@ void X_DrawViewPort(int port, const RectRaw* portGeometry,
switch(G_GameState())
{
case GS_MAP: {
player_t* plr = players + player;
player_t *plr = players + player;

if(!ST_AutomapObscures2(player, windowGeometry))
{
Expand All @@ -262,8 +258,8 @@ void X_DrawViewPort(int port, const RectRaw* portGeometry,
if(!(P_MobjIsCamera(plr->plr->mo) && Get(DD_PLAYBACK))) // $democam
X_Drawer(player);
}
break;
}
break; }

case GS_STARTUP:
DGL_DrawRectf2Color(0, 0, portGeometry->size.width, portGeometry->size.height, 0, 0, 0, 1);
break;
Expand All @@ -273,7 +269,7 @@ void X_DrawViewPort(int port, const RectRaw* portGeometry,
}
#endif

void X_DrawWindow(const Size2Raw* windowSize)
void X_DrawWindow(Size2Raw const *windowSize)
{
if(G_GameState() == GS_INTERMISSION)
{
Expand All @@ -289,17 +285,15 @@ void X_DrawWindow(const Size2Raw* windowSize)
}
}

void X_EndFrame(void)
void X_EndFrame()
{
int i;

SN_UpdateActiveSequences();

if(G_GameState() != GS_MAP) return;

for(i = 0; i < MAXPLAYERS; ++i)
for(int i = 0; i < MAXPLAYERS; ++i)
{
player_t* plr = players + i;
player_t *plr = players + i;

if(!plr->plr->inGame || !plr->plr->mo) continue;

Expand All @@ -316,80 +310,76 @@ void X_EndFrame(void)
* object properties (solid, local, low/nograv, etc.), color translation
* and other interesting little details.
*/
void R_SetAllDoomsdayFlags(void)
void R_SetAllDoomsdayFlags()
{
int i;
mobj_t *mo;

if(G_GameState() != GS_MAP)
return;
if(G_GameState() != GS_MAP) return;

// Only visible things are in the sector thinglists, so this is good.
for(i = 0; i < numsectors; ++i)
for(mo = P_GetPtr(DMU_SECTOR, i, DMT_MOBJS); mo; mo = mo->sNext)
for(int i = 0; i < numsectors; ++i)
for(mobj_t *mo = (mobj_t *)P_GetPtr(DMU_SECTOR, i, DMT_MOBJS); mo; mo = mo->sNext)
{
if(IS_CLIENT && mo->ddFlags & DDMF_REMOTE)
{
if(IS_CLIENT && mo->ddFlags & DDMF_REMOTE)
{
Mobj_UpdateTranslationClassAndMap(mo);
continue;
}
Mobj_UpdateTranslationClassAndMap(mo);
continue;
}

// Reset the flags for a new frame.
mo->ddFlags &= DDMF_CLEAR_MASK;

if(mo->flags & MF_LOCAL)
mo->ddFlags |= DDMF_LOCAL;
if(mo->flags & MF_SOLID)
mo->ddFlags |= DDMF_SOLID;
if(mo->flags & MF_MISSILE)
mo->ddFlags |= DDMF_MISSILE;
if(mo->flags2 & MF2_FLY)
mo->ddFlags |= DDMF_FLY | DDMF_NOGRAVITY;
if(mo->flags2 & MF2_FLOATBOB)
mo->ddFlags |= DDMF_BOB | DDMF_NOGRAVITY;
if(mo->flags2 & MF2_LOGRAV)
mo->ddFlags |= DDMF_LOWGRAVITY;
if(mo->flags & MF_NOGRAVITY /* || mo->flags2 & MF2_FLY */ )
mo->ddFlags |= DDMF_NOGRAVITY;

// $democam: cameramen are invisible.
if(P_MobjIsCamera(mo))
mo->ddFlags |= DDMF_DONTDRAW;

// Choose which ddflags to set.
if(mo->flags2 & MF2_DONTDRAW)
{
mo->ddFlags |= DDMF_DONTDRAW;
continue; // No point in checking the other flags.
}
// Reset the flags for a new frame.
mo->ddFlags &= DDMF_CLEAR_MASK;

if(mo->flags & MF_LOCAL)
mo->ddFlags |= DDMF_LOCAL;
if(mo->flags & MF_SOLID)
mo->ddFlags |= DDMF_SOLID;
if(mo->flags & MF_MISSILE)
mo->ddFlags |= DDMF_MISSILE;
if(mo->flags2 & MF2_FLY)
mo->ddFlags |= DDMF_FLY | DDMF_NOGRAVITY;
if(mo->flags2 & MF2_FLOATBOB)
mo->ddFlags |= DDMF_BOB | DDMF_NOGRAVITY;
if(mo->flags2 & MF2_LOGRAV)
mo->ddFlags |= DDMF_LOWGRAVITY;
if(mo->flags & MF_NOGRAVITY /* || mo->flags2 & MF2_FLY */ )
mo->ddFlags |= DDMF_NOGRAVITY;

// $democam: cameramen are invisible.
if(P_MobjIsCamera(mo))
mo->ddFlags |= DDMF_DONTDRAW;

// Choose which ddflags to set.
if(mo->flags2 & MF2_DONTDRAW)
{
mo->ddFlags |= DDMF_DONTDRAW;
continue; // No point in checking the other flags.
}

if((mo->flags & MF_BRIGHTSHADOW) == MF_BRIGHTSHADOW)
mo->ddFlags |= DDMF_BRIGHTSHADOW;
else
{
if(mo->flags & MF_SHADOW)
mo->ddFlags |= DDMF_SHADOW;
if(mo->flags & MF_ALTSHADOW ||
(cfg.translucentIceCorpse && mo->flags & MF_ICECORPSE))
mo->ddFlags |= DDMF_ALTSHADOW;
}
if((mo->flags & MF_BRIGHTSHADOW) == MF_BRIGHTSHADOW)
mo->ddFlags |= DDMF_BRIGHTSHADOW;
else
{
if(mo->flags & MF_SHADOW)
mo->ddFlags |= DDMF_SHADOW;
if(mo->flags & MF_ALTSHADOW ||
(cfg.translucentIceCorpse && mo->flags & MF_ICECORPSE))
mo->ddFlags |= DDMF_ALTSHADOW;
}

if((mo->flags & MF_VIEWALIGN && !(mo->flags & MF_MISSILE)) ||
mo->flags & MF_FLOAT || (mo->flags & MF_MISSILE &&
!(mo->flags & MF_VIEWALIGN)))
mo->ddFlags |= DDMF_VIEWALIGN;
if((mo->flags & MF_VIEWALIGN && !(mo->flags & MF_MISSILE)) ||
mo->flags & MF_FLOAT || (mo->flags & MF_MISSILE &&
!(mo->flags & MF_VIEWALIGN)))
mo->ddFlags |= DDMF_VIEWALIGN;

Mobj_UpdateTranslationClassAndMap(mo);
Mobj_UpdateTranslationClassAndMap(mo);

// An offset for the light emitted by this object.
/* Class = MobjLightOffsets[mo->type];
if(Class < 0) Class = 8-Class;
// Class must now be in range 0-15.
mo->ddFlags |= Class << DDMF_LIGHTOFFSETSHIFT; */
// An offset for the light emitted by this object.
/* Class = MobjLightOffsets[mo->type];
if(Class < 0) Class = 8-Class;
// Class must now be in range 0-15.
mo->ddFlags |= Class << DDMF_LIGHTOFFSETSHIFT; */

// The Mage's ice shards need to be a bit smaller.
// This'll make them half the normal size.
/*if(mo->type == MT_SHARDFX1)
mo->ddFlags |= 2 << DDMF_LIGHTSCALESHIFT;*/
}
// The Mage's ice shards need to be a bit smaller.
// This'll make them half the normal size.
/*if(mo->type == MT_SHARDFX1)
mo->ddFlags |= 2 << DDMF_LIGHTSCALESHIFT;*/
}
}

0 comments on commit a09e1dd

Please sign in to comment.