Skip to content

Commit

Permalink
Fixed the handling of the sky mask material.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij committed Mar 7, 2008
1 parent 082dce0 commit 7a33085
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/dd_share.h
Expand Up @@ -277,7 +277,7 @@ extern "C" {

// Non-integer/special values for Set/Get
DD_SKYMASKMATERIAL_NAME = 0x4000,
DD_SKYFLATNUM,
DD_SKYMASKMATERIAL_NUM,
DD_TRANSLATIONTABLES_ADDRESS,
DD_TRACE_ADDRESS, // divline 'trace' used by PathTraverse.
DD_SPRITE_REPLACEMENT, // Sprite <-> model replacement.
Expand Down
35 changes: 25 additions & 10 deletions doomsday/engine/portable/src/dd_main.c
Expand Up @@ -111,6 +111,8 @@ extern int monochrome;
extern int gamedataformat;
extern int gamedrawhud;

extern material_t *skyMaskMaterial;

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

directory_t ddRuntimeDir, ddBinDir;
Expand Down Expand Up @@ -940,8 +942,6 @@ ddvalue_t ddValues[DD_LAST_VALUE - DD_FIRST_VALUE - 1] = {
};
/* *INDENT-ON* */

int skyFlatNum;

/**
* Get a 32-bit signed integer value.
*/
Expand Down Expand Up @@ -970,8 +970,10 @@ int DD_GetInteger(int ddvalue)
case DD_WINDOW_HEIGHT:
return theWindow->height;

case DD_SKYFLATNUM:
return skyFlatNum;
case DD_SKYMASKMATERIAL_NUM:
if(skyMaskMaterial)
return skyMaskMaterial->ofTypeID;
return 0;

default:
break;
Expand All @@ -998,10 +1000,6 @@ void DD_SetInteger(int ddvalue, int parm)
{
DD_CheckQuery(ddvalue, parm);
// How about some special values?
if(ddvalue == DD_SKYFLATNUM)
{
skyFlatNum = parm;
}
return;
}
if(ddValues[ddvalue].writePtr)
Expand All @@ -1019,6 +1017,11 @@ void* DD_GetVariable(int ddvalue)
// How about some specials?
switch(ddvalue)
{
case DD_SKYMASKMATERIAL_NUM:
if(skyMaskMaterial)
return &skyMaskMaterial->ofTypeID;
return 0;

case DD_VIEWX:
return &viewX;

Expand Down Expand Up @@ -1214,8 +1217,20 @@ void DD_SetVariable(int ddvalue, void *parm)
return;

case DD_SKYMASKMATERIAL_NAME:
memset(skyFlatName, 0, 9);
strncpy(skyFlatName, parm, 9);
{
int mat;
char name[9];
size_t len;

len = strlen(parm);
if(len > 8)
len = 8;
strncpy(name, parm, len);
name[len] = '\0';

if((mat = R_MaterialNumForName(name, MAT_FLAT)) != -1)
skyMaskMaterial = R_GetMaterial(mat, MAT_FLAT);
}
return;

case DD_PSPRITE_OFFSET_X:
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -112,8 +112,6 @@ extern int ratioLimit;
extern boolean palettedTextureExtAvailable;
extern boolean s3tcAvailable;

extern material_t skyMaskMaterial;

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

// The current texture.
Expand Down
7 changes: 1 addition & 6 deletions doomsday/engine/portable/src/r_main.c
Expand Up @@ -90,7 +90,6 @@ fixed_t *fineCosine = &finesine[FINEANGLES / 4];
int extraLight; // bumped light from gun blasts

material_t *skyMaskMaterial = NULL;
char skyFlatName[9] = "F_SKY";

float frameTimePos; // 0...1: fractional part for sharp game tics

Expand Down Expand Up @@ -131,13 +130,9 @@ void R_Register(void)
// C_VAR_INT("rend-vsync", &useVSync, 0, 0, 1);
}

/**
* The skyflat is the special flat used for surfaces that should show
* a view of the sky.
*/
void R_InitSkyMap(void)
{
skyMaskMaterial = R_GetMaterial(R_MaterialNumForName(skyFlatName, MAT_FLAT), MAT_FLAT);
// Nothing to do.
}

/**
Expand Down
3 changes: 1 addition & 2 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -447,8 +447,6 @@ void G_CommonPreInit(void)
R_SetDataPath( DATAPATH );

R_SetBorderGfx(borderLumps);

DD_SetVariable(DD_SKYMASKMATERIAL_NAME, SKYFLATNAME);
Con_SetString("map-name", NOTAMAPNAME, 1);

G_RegisterBindClasses();
Expand Down Expand Up @@ -489,6 +487,7 @@ void G_CommonPostInit(void)
XG_Register(); // Register XG classnames.
#endif

DD_SetVariable(DD_SKYMASKMATERIAL_NAME, SKYFLATNAME);
R_SetViewSize(cfg.screenBlocks, 0);

Con_Message("P_Init: Init Playloop state.\n");
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/p_map.c
Expand Up @@ -2163,7 +2163,7 @@ static boolean P_ThingHeightClip(mobj_t *thing)
#if __JHEXEN__
thing->floorPic = tmFloorPic;
#else
// killough $dropoff_fix: remember dropoffs.
// $dropoff_fix: remember dropoffs.
thing->dropOffZ = tmDropoffZ;
#endif

Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/include/doomdef.h
Expand Up @@ -257,7 +257,7 @@ enum { VX, VY, VZ }; // Vertex indices.

#define GAMETIC (Get(DD_GAMETIC))

#define SKYMASKMATERIAL (Get(DD_SKYFLATNUM))
#define SKYMASKMATERIAL (Get(DD_SKYMASKMATERIAL_NUM))
#define SKYFLATNAME ("F_SKY1")

#endif
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom64/include/doomdef.h
Expand Up @@ -254,7 +254,7 @@ enum { VX, VY, VZ }; // Vertex indices.

#define GAMETIC (Get(DD_GAMETIC))

#define SKYMASKMATERIAL (Get(DD_SKYFLATNUM))
#define SKYMASKMATERIAL (Get(DD_SKYMASKMATERIAL_NUM))
#define SKYFLATNAME ("F_SKY1")

#define SFXVOLUME (Get(DD_SFX_VOLUME) / 17)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/include/h_stat.h
Expand Up @@ -60,7 +60,7 @@

#define GAMETIC Get(DD_GAMETIC)

#define SKYMASKMATERIAL Get(DD_SKYFLATNUM)
#define SKYMASKMATERIAL Get(DD_SKYMASKMATERIAL_NUM)
#define SKYFLATNAME "F_SKY1"

#define maketic Get(DD_MAKETIC)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jhexen/include/x_state.h
Expand Up @@ -108,7 +108,7 @@ extern int bodyqueslot;

// Needed to store the number of the dummy sky flat.
// Used for rendering, as well as tracking projectiles etc.
#define SKYMASKMATERIAL Get(DD_SKYFLATNUM)
#define SKYFLATNAME "F_SKY"
#define SKYMASKMATERIAL Get(DD_SKYMASKMATERIAL_NUM)
#define SKYFLATNAME "F_SKY"

#endif
2 changes: 1 addition & 1 deletion doomsday/plugins/wolftc/include/doomstat.h
Expand Up @@ -187,7 +187,7 @@ extern int bodyqueslot;

// Needed to store the number of the dummy sky flat.
// Used for rendering, as well as tracking projectiles etc.
#define skyMaskMaterial Get(DD_SKYFLATNUM)
#define SKYMASKMATERIAL Get(DD_SKYMASKMATERIAL_NUM)
#define SKYFLATNAME "F_SKY1"

extern int rndindex;
Expand Down

0 comments on commit 7a33085

Please sign in to comment.