Skip to content

Commit

Permalink
Added light decorations
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jun 10, 2003
1 parent b030748 commit c34db90
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 3 deletions.
38 changes: 37 additions & 1 deletion doomsday/Src/dd_defns.c
Expand Up @@ -261,6 +261,24 @@ ded_mapinfo_t *Def_GetMapInfo(char *map_id)
return 0;
}

ded_decor_t *Def_GetDecoration(int number, boolean is_texture, boolean has_ext)
{
ded_decor_t *def;
int i;

for(i = defs.count.decorations.num - 1, def = defs.decorations + i;
i >= 0; i--, def--)
{
if(!def->is_texture == !is_texture && number == def->surface_index)
{
// Is this suitable?
if(R_IsAllowedDecoration(def, number, has_ext))
return def;
}
}
return 0;
}

int Def_GetFlagValue(char *flag)
{
int i;
Expand Down Expand Up @@ -591,7 +609,6 @@ void Def_Read(void)
Def_CountMsg(count_sounds.num, "sound effects");

// Music.
// DED_NewEntries(&music, &num_music, sizeof(*music), defs.num_music);
for(i = 0; i < defs.count.music.num; i++)
{
ded_music_t *mus = defs.music + i;
Expand Down Expand Up @@ -646,6 +663,14 @@ void Def_Read(void)
// Detail textures. Initialize later...
Def_CountMsg(defs.count.details.num, "detail textures");

// Surface decorations.
for(i = 0; i < defs.count.decorations.num; i++)
{
ded_decor_t *decor = defs.decorations + i;
decor->flags = Def_EvalFlags(decor->flags_str);
}
Def_CountMsg(defs.count.decorations.num, "surface decorations");

// Other data:
Def_CountMsg(defs.count.mapinfo.num, "map infos");
Def_CountMsg(defs.count.finales.num, "finales");
Expand Down Expand Up @@ -685,6 +710,17 @@ void Def_PostInit(void)
(defs.details[i].detail_lump);
details[i].gltex = -1; //~0; // Not loaded.
}

for(i = 0; i < defs.count.decorations.num; i++)
{
ded_decor_t *decor = defs.decorations + i;

decor->surface_index = -1;
if(decor->is_texture)
decor->surface_index = R_CheckTextureNumForName(decor->surface);
else
decor->surface_index = W_CheckNumForName(decor->surface);
}
}

//==========================================================================
Expand Down
25 changes: 25 additions & 0 deletions doomsday/Src/dedfile.c
@@ -1,4 +1,5 @@
// Doomsday Engine Definition File Management.
// (there are more intelligent ways to do all of this...)

#include "dedfile.h"
#include <stdio.h>
Expand Down Expand Up @@ -87,6 +88,7 @@ void DED_Destroy(ded_t *ded)
free(ded->values[i].text);
}
free(ded->values);
free(ded->decorations);
free(ded->sectors);
}

Expand Down Expand Up @@ -338,6 +340,29 @@ void DED_RemoveFinale(ded_t *ded, int index)
sizeof(ded_finale_t));
}

int DED_AddDecoration(ded_t *ded)
{
ded_decor_t *decor = DED_NewEntry( (void**) &ded->decorations,
&ded->count.decorations, sizeof(ded_decor_t));
int i;

// Init some default values.
for(i = 0; i < DED_DECOR_NUM_LIGHTS; i++)
{
// The color (0,0,0) means the light is not active.
decor->lights[i].elevation = 1;
decor->lights[i].radius = 1;
}

return decor - ded->decorations;
}

void DED_RemoveDecoration(ded_t *ded, int index)
{
DED_DelEntry(index, (void**) &ded->decorations, &ded->count.decorations,
sizeof(ded_decor_t));
}

int DED_AddSector(ded_t *ded, int id)
{
ded_sectortype_t *sec = DED_NewEntry( (void**) &ded->sectors,
Expand Down
92 changes: 90 additions & 2 deletions doomsday/Src/dedread.c
Expand Up @@ -7,6 +7,8 @@
//**
//** A GHASTLY MESS!!! This should be rewritten.
//**
//** You have been warned!
//**
//** At the moment the idea is that a lot of macros are used to read
//** a more or less fixed structure of definitions, and if an error
//** occurs then "goto out_of_here;". It leads to a lot more code
Expand Down Expand Up @@ -79,6 +81,8 @@
#define RV_FLT(lab, X) if(ISLABEL(lab)) { READFLT(X); } else
#define RV_VEC(lab, X, N) if(ISLABEL(lab)) { int b; FINDBEGIN; \
for(b=0; b<N; b++) {READFLT(X[b])} ReadToken(); } else
#define RV_IVEC(lab, X, N) if(ISLABEL(lab)) { int b; FINDBEGIN; \
for(b=0; b<N; b++) {READINT(X[b])} ReadToken(); } else
#define RV_NBVEC(lab, X, N) if(ISLABEL(lab)) { READNBYTEVEC(X,N); } else
#define RV_STR(lab, X) if(ISLABEL(lab)) { READSTR(X); } else
#define RV_STR_INT(lab, S, I) if(ISLABEL(lab)) { if(!ReadString(S,sizeof(S))) \
Expand Down Expand Up @@ -384,6 +388,29 @@ void DED_InitReader(char *buffer)
dedend = false;
}

//===========================================================================
// DED_CheckCondition
// Return true if the condition passes. The condition token can be a
// command line option or a game mode.
//===========================================================================
boolean DED_CheckCondition(const char *cond, boolean expected)
{
boolean value = false;

if(cond[0] == '-')
{
// It's a command line option.
value = (ArgCheck(token) != 0);
}
else if(isalnum(cond[0]))
{
// Then it must be a game mode.
value = !stricmp(cond, gx.Get(DD_GAME_MODE));
}

return value == expected;
}

//==========================================================================
// DED_ReadData
// Reads definitions from the given buffer.
Expand All @@ -409,6 +436,7 @@ int DED_ReadData(ded_t *ded, int bDestroyOld, char *buffer,
int prev_dtldef_idx = -1; // For "Copy".
ded_ptcgen_t *gen;
int prev_gendef_idx = -1; // For "Copy".
int prev_decordef_idx = -1; // For "Copy".
ded_finale_t *fin;
ded_linetype_t *l;
ded_sectortype_t *sec;
Expand Down Expand Up @@ -451,7 +479,7 @@ int DED_ReadData(ded_t *ded, int bDestroyOld, char *buffer,
ReadToken();
}
#if !__DEDMAN__
if(sub == (ArgCheck(token) != 0))
if(DED_CheckCondition(token, sub))
{
// Ah, we're done. Get out of here.
goto ded_end_read;
Expand Down Expand Up @@ -481,7 +509,7 @@ int DED_ReadData(ded_t *ded, int bDestroyOld, char *buffer,
ReadToken();
}
#if !__DEDMAN__
if(sub == (ArgCheck(token) != 0))
if(DED_CheckCondition(token, sub))
{
idx = DED_AddInclude(ded, "");
READSTR(tmp);
Expand Down Expand Up @@ -1111,6 +1139,66 @@ int DED_ReadData(ded_t *ded, int bDestroyOld, char *buffer,
CHECKSC;
}
}
if(ISTOKEN("Decoration"))
{
ded_decor_t *decor;

idx = DED_AddDecoration(ded);
decor = ded->decorations + idx;
sub = 0;
if(prev_decordef_idx >= 0 && bCopyNext)
{
// Should we copy the previous definition?
memcpy(decor, ded->decorations + prev_decordef_idx,
sizeof(*decor));
}
FINDBEGIN;
for(;;)
{
READLABEL;
RV_STR("Flags", decor->flags_str)
if(ISLABEL("Texture"))
{
READSTR(decor->surface)
decor->is_texture = true;
}
else if(ISLABEL("Flat"))
{
READSTR(decor->surface)
decor->is_texture = false;
}
else if(ISLABEL("Light"))
{
ded_decorlight_t *dl = decor->lights + sub;
if(sub == DED_DECOR_NUM_LIGHTS)
{
SetError("Too many lights in decoration.");
retval = false;
goto ded_end_read;
}
FINDBEGIN;
for(;;)
{
READLABEL;
RV_VEC("Offset", dl->pos, 2)
RV_FLT("Distance", dl->elevation)
RV_VEC("Color", dl->color, 3)
RV_FLT("Radius", dl->radius)
RV_FLT("Halo radius", dl->halo_radius)
RV_IVEC("Pattern offset", dl->pattern_offset, 2)
RV_IVEC("Pattern skip", dl->pattern_skip, 2)
RV_IVEC("Levels", dl->light_levels, 2)
RV_INT("Flare texture", dl->flare_texture)
RV_END
CHECKSC;
}
sub++;
}
else RV_END
CHECKSC;
}
prev_decordef_idx = idx;
}
if(ISTOKEN("Line")) // Line Type
{
// A new line type.
Expand Down

0 comments on commit c34db90

Please sign in to comment.