mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-31 13:00:59 +00:00
- converted FInterBackground into a class so that the scripts can use it.
- fixed some issues with default value matching in savegames.
This commit is contained in:
parent
1e9ef2b1df
commit
b416322032
8 changed files with 507 additions and 438 deletions
|
@ -218,6 +218,7 @@ public:
|
||||||
|
|
||||||
template<class U> friend inline void GC::Mark(TObjPtr<U> &obj);
|
template<class U> friend inline void GC::Mark(TObjPtr<U> &obj);
|
||||||
template<class U> friend FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<U> &value, TObjPtr<U> *);
|
template<class U> friend FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<U> &value, TObjPtr<U> *);
|
||||||
|
template<class U> friend FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<U> &value, U *);
|
||||||
|
|
||||||
friend class DObject;
|
friend class DObject;
|
||||||
};
|
};
|
||||||
|
|
|
@ -301,7 +301,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t
|
||||||
.Terrain("ceilingterrain", p.terrainnum[1], &def->terrainnum[1])
|
.Terrain("ceilingterrain", p.terrainnum[1], &def->terrainnum[1])
|
||||||
("scrolls", scroll, nul)
|
("scrolls", scroll, nul)
|
||||||
// GZDoom exclusive:
|
// GZDoom exclusive:
|
||||||
.Array("reflect", p.reflect, def->reflect, 2)
|
.Array("reflect", p.reflect, def->reflect, 2, true)
|
||||||
.EndObject();
|
.EndObject();
|
||||||
|
|
||||||
if (arc.isReading() && !scroll.isZero())
|
if (arc.isReading() && !scroll.isZero())
|
||||||
|
|
|
@ -4159,9 +4159,14 @@ void P_SetupLevel (const char *lumpname, int position)
|
||||||
MapThingsUserData.Clear();
|
MapThingsUserData.Clear();
|
||||||
|
|
||||||
// Create a backup of the map data so the savegame code can toss out all fields that haven't changed in order to reduce processing time and file size.
|
// Create a backup of the map data so the savegame code can toss out all fields that haven't changed in order to reduce processing time and file size.
|
||||||
level.loadsectors = level.sectors;
|
// Note that we want binary identity here, so assignment is not sufficient because it won't initialize any padding bytes.
|
||||||
level.loadlines = level.lines;
|
// Note that none of these structures may contain non POD fields anyway.
|
||||||
level.loadsides = level.sides;
|
level.loadsectors.Resize(level.sectors.Size());
|
||||||
|
memcpy(&level.loadsectors[0], &level.sectors[0], level.sectors.Size() * sizeof(level.sectors[0]));
|
||||||
|
level.loadlines.Resize(level.lines.Size());
|
||||||
|
memcpy(&level.loadlines[0], &level.lines[0], level.lines.Size() * sizeof(level.lines[0]));
|
||||||
|
level.loadsides.Resize(level.sides.Size());
|
||||||
|
memcpy(&level.loadsides[0], &level.sides[0], level.sides.Size() * sizeof(level.sides[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1130,8 +1130,8 @@ struct side_t
|
||||||
double yOffset;
|
double yOffset;
|
||||||
double xScale;
|
double xScale;
|
||||||
double yScale;
|
double yScale;
|
||||||
FTextureID texture;
|
|
||||||
TObjPtr<DInterpolation*> interpolation;
|
TObjPtr<DInterpolation*> interpolation;
|
||||||
|
FTextureID texture;
|
||||||
//int Light;
|
//int Light;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -939,7 +939,6 @@ FxExpression *FxIntCast::Resolve(FCompileContext &ctx)
|
||||||
{
|
{
|
||||||
CHECKRESOLVED();
|
CHECKRESOLVED();
|
||||||
SAFE_RESOLVE(basex, ctx);
|
SAFE_RESOLVE(basex, ctx);
|
||||||
int c;
|
|
||||||
|
|
||||||
if (basex->ValueType->GetRegType() == REGT_INT)
|
if (basex->ValueType->GetRegType() == REGT_INT)
|
||||||
{
|
{
|
||||||
|
|
|
@ -215,8 +215,15 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<T> &value, TOb
|
||||||
return arc;
|
return arc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
FSerializer &Serialize(FSerializer &arc, const char *key, TObjPtr<T> &value, T *)
|
||||||
|
{
|
||||||
|
Serialize(arc, key, value.o, nullptr);
|
||||||
|
return arc;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class TT>
|
template<class T, class TT>
|
||||||
FSerializer &Serialize(FSerializer &arc, const char *key, TArray<T, TT> &value, TArray<T, TT> *)
|
FSerializer &Serialize(FSerializer &arc, const char *key, TArray<T, TT> &value, TArray<T, TT> *def)
|
||||||
{
|
{
|
||||||
if (arc.isWriting())
|
if (arc.isWriting())
|
||||||
{
|
{
|
||||||
|
@ -234,7 +241,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TArray<T, TT> &value,
|
||||||
}
|
}
|
||||||
for (unsigned i = 0; i < value.Size(); i++)
|
for (unsigned i = 0; i < value.Size(); i++)
|
||||||
{
|
{
|
||||||
Serialize(arc, nullptr, value[i], (T*)nullptr);
|
Serialize(arc, nullptr, value[i], def? &(*def)[i] : nullptr);
|
||||||
}
|
}
|
||||||
arc.EndArray();
|
arc.EndArray();
|
||||||
return arc;
|
return arc;
|
||||||
|
|
229
src/wi_stuff.cpp
229
src/wi_stuff.cpp
|
@ -91,8 +91,10 @@ static const char *WI_Cmd[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FInterBackground
|
class DInterBackground : public DObject
|
||||||
{
|
{
|
||||||
|
DECLARE_ABSTRACT_CLASS(DInterBackground, DObject)
|
||||||
|
|
||||||
// These animation variables, structures, etc. are used for the
|
// These animation variables, structures, etc. are used for the
|
||||||
// DOOM/Ultimate DOOM intermission screen animations. This is
|
// DOOM/Ultimate DOOM intermission screen animations. This is
|
||||||
// totally different from any sprite or texture/flat animations
|
// totally different from any sprite or texture/flat animations
|
||||||
|
@ -161,31 +163,99 @@ private:
|
||||||
FTexture* splat = nullptr; // splat
|
FTexture* splat = nullptr; // splat
|
||||||
FTexture *background = nullptr;
|
FTexture *background = nullptr;
|
||||||
wbstartstruct_t *wbs;
|
wbstartstruct_t *wbs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FInterBackground(wbstartstruct_t *wbst)
|
DInterBackground(wbstartstruct_t *wbst);
|
||||||
{
|
bool LoadBackground(bool isenterpic);
|
||||||
wbs = wbst;
|
void updateAnimatedBack();
|
||||||
|
void drawBackground(int state, bool drawsplat, bool snl_pointeron);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
};
|
|
||||||
//====================================================================
|
|
||||||
//
|
|
||||||
// Loads the background - either from a single texture
|
|
||||||
// or an intermission lump.
|
|
||||||
// Unfortunately the texture manager is incapable of recognizing text
|
|
||||||
// files so if you use a script you have to prefix its name by '$' in
|
|
||||||
// MAPINFO.
|
|
||||||
//
|
|
||||||
//====================================================================
|
|
||||||
bool IsExMy(const char * name)
|
bool IsExMy(const char * name)
|
||||||
{
|
{
|
||||||
// Only check for the first 3 episodes. They are the only ones with default intermission scripts.
|
// Only check for the first 3 episodes. They are the only ones with default intermission scripts.
|
||||||
// Level names can be upper- and lower case so use tolower to check!
|
// Level names can be upper- and lower case so use tolower to check.
|
||||||
return (tolower(name[0]) == 'e' && name[1] >= '1' && name[1] <= '3' && tolower(name[2]) == 'm');
|
return (tolower(name[0]) == 'e' && name[1] >= '1' && name[1] <= '3' && tolower(name[2]) == 'm');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadBackground(bool isenterpic)
|
//====================================================================
|
||||||
|
//
|
||||||
|
// Draws the splats and the 'You are here' arrows
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
int MapToIndex(const char *map)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < lnodes.Size(); i++)
|
||||||
|
{
|
||||||
|
if (!lnodes[i].Level.CompareNoCase(map))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//====================================================================
|
||||||
|
//
|
||||||
|
// Draws the splats and the 'You are here' arrows
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
void drawOnLnode(int n, FTexture * c[], int numc)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i<numc; i++)
|
||||||
|
{
|
||||||
|
int left;
|
||||||
|
int top;
|
||||||
|
int right;
|
||||||
|
int bottom;
|
||||||
|
|
||||||
|
|
||||||
|
right = c[i]->GetScaledWidth();
|
||||||
|
bottom = c[i]->GetScaledHeight();
|
||||||
|
left = lnodes[n].x - c[i]->GetScaledLeftOffset();
|
||||||
|
top = lnodes[n].y - c[i]->GetScaledTopOffset();
|
||||||
|
right += left;
|
||||||
|
bottom += top;
|
||||||
|
|
||||||
|
if (left >= 0 && right < 320 && top >= 0 && bottom < 200)
|
||||||
|
{
|
||||||
|
screen->DrawTexture(c[i], lnodes[n].x, lnodes[n].y, DTA_320x200, true, TAG_DONE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DInterBackground:: DInterBackground(wbstartstruct_t *wbst)
|
||||||
|
{
|
||||||
|
wbs = wbst;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DInterBackground, Create)
|
||||||
|
{
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_POINTER(wbst, wbstartstruct_t);
|
||||||
|
ACTION_RETURN_POINTER(new DInterBackground(wbst));
|
||||||
|
}
|
||||||
|
|
||||||
|
//====================================================================
|
||||||
|
//
|
||||||
|
// Loads the background - either from a single texture
|
||||||
|
// or an intermission lump.
|
||||||
|
// Unfortunately the texture manager is incapable of recognizing text
|
||||||
|
// files so if you use a script you have to prefix its name by '$' in
|
||||||
|
// MAPINFO.
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
bool DInterBackground::LoadBackground(bool isenterpic)
|
||||||
|
{
|
||||||
const char *lumpname = NULL;
|
const char *lumpname = NULL;
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
in_anim_t an;
|
in_anim_t an;
|
||||||
|
@ -450,17 +520,24 @@ public:
|
||||||
}
|
}
|
||||||
background = TexMan[texture];
|
background = TexMan[texture];
|
||||||
return noautostartmap;
|
return noautostartmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================================================================
|
DEFINE_ACTION_FUNCTION(DInterBackground, LoadBackground)
|
||||||
//
|
{
|
||||||
// made this more generic and configurable through a script
|
PARAM_SELF_PROLOGUE(DInterBackground);
|
||||||
// Removed all the ugly special case handling for different game modes
|
PARAM_BOOL(isenterpic);
|
||||||
//
|
ACTION_RETURN_BOOL(self->LoadBackground(isenterpic));
|
||||||
//====================================================================
|
}
|
||||||
|
|
||||||
void updateAnimatedBack()
|
//====================================================================
|
||||||
{
|
//
|
||||||
|
// made this more generic and configurable through a script
|
||||||
|
// Removed all the ugly special case handling for different game modes
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
void DInterBackground::updateAnimatedBack()
|
||||||
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
bcnt++;
|
bcnt++;
|
||||||
|
@ -487,16 +564,23 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================================================================
|
DEFINE_ACTION_FUNCTION(DInterBackground, updateAnimatedBack)
|
||||||
//
|
{
|
||||||
// Draws the background including all animations
|
PARAM_SELF_PROLOGUE(DInterBackground);
|
||||||
//
|
self->updateAnimatedBack();
|
||||||
//====================================================================
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void drawBackground(int state, bool drawsplat, bool snl_pointeron)
|
//====================================================================
|
||||||
{
|
//
|
||||||
|
// Draws the background including all animations
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
|
void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointeron)
|
||||||
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
double animwidth = 320; // For a flat fill or clear background scale animations to 320x200
|
double animwidth = 320; // For a flat fill or clear background scale animations to 320x200
|
||||||
double animheight = 200;
|
double animheight = 200;
|
||||||
|
@ -587,63 +671,26 @@ public:
|
||||||
// Draw only if it points to a valid level on the current screen!
|
// Draw only if it points to a valid level on the current screen!
|
||||||
if (v<lnodes.Size()) drawOnLnode(v, &yah[0], yah.Size());
|
if (v<lnodes.Size()) drawOnLnode(v, &yah[0], yah.Size());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
DEFINE_ACTION_FUNCTION(DInterBackground, drawBackground)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DInterBackground);
|
||||||
|
PARAM_INT(state);
|
||||||
|
PARAM_BOOL(splat);
|
||||||
|
PARAM_BOOL(pointer);
|
||||||
|
self->drawBackground(state, splat, pointer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
IMPLEMENT_CLASS(DInterBackground, true, false)
|
||||||
//====================================================================
|
|
||||||
//
|
|
||||||
// Draws the splats and the 'You are here' arrows
|
|
||||||
//
|
|
||||||
//====================================================================
|
|
||||||
|
|
||||||
int MapToIndex(const char *map)
|
//====================================================================
|
||||||
{
|
//
|
||||||
unsigned int i;
|
//
|
||||||
|
//
|
||||||
|
//====================================================================
|
||||||
|
|
||||||
for (i = 0; i < lnodes.Size(); i++)
|
|
||||||
{
|
|
||||||
if (!lnodes[i].Level.CompareNoCase(map))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//====================================================================
|
|
||||||
//
|
|
||||||
// Draws the splats and the 'You are here' arrows
|
|
||||||
//
|
|
||||||
//====================================================================
|
|
||||||
|
|
||||||
void drawOnLnode(int n, FTexture * c[], int numc)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i<numc; i++)
|
|
||||||
{
|
|
||||||
int left;
|
|
||||||
int top;
|
|
||||||
int right;
|
|
||||||
int bottom;
|
|
||||||
|
|
||||||
|
|
||||||
right = c[i]->GetScaledWidth();
|
|
||||||
bottom = c[i]->GetScaledHeight();
|
|
||||||
left = lnodes[n].x - c[i]->GetScaledLeftOffset();
|
|
||||||
top = lnodes[n].y - c[i]->GetScaledTopOffset();
|
|
||||||
right += left;
|
|
||||||
bottom += top;
|
|
||||||
|
|
||||||
if (left >= 0 && right < 320 && top >= 0 && bottom < 200)
|
|
||||||
{
|
|
||||||
screen->DrawTexture(c[i], lnodes[n].x, lnodes[n].y, DTA_320x200, true, TAG_DONE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FPatchInfo
|
struct FPatchInfo
|
||||||
{
|
{
|
||||||
|
@ -715,7 +762,7 @@ public:
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
FInterBackground *bg;
|
DInterBackground *bg;
|
||||||
int acceleratestage; // used to accelerate or skip a stage
|
int acceleratestage; // used to accelerate or skip a stage
|
||||||
bool playerready[MAXPLAYERS];
|
bool playerready[MAXPLAYERS];
|
||||||
int me; // wbs->pnum
|
int me; // wbs->pnum
|
||||||
|
@ -2039,14 +2086,15 @@ public:
|
||||||
if (li) lnametexts[1] = li->LookupLevelName();
|
if (li) lnametexts[1] = li->LookupLevelName();
|
||||||
else lnametexts[1] = "";
|
else lnametexts[1] = "";
|
||||||
|
|
||||||
bg = new FInterBackground(wbs);
|
bg = new DInterBackground(wbs);
|
||||||
|
GC::AddSoftRoot(bg);
|
||||||
noautostartmap = bg->LoadBackground(false);
|
noautostartmap = bg->LoadBackground(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WI_unloadData ()
|
void WI_unloadData ()
|
||||||
{
|
{
|
||||||
// [RH] The texture data gets unloaded at pre-map time, so there's nothing to do here
|
GC::DelSoftRoot(bg);
|
||||||
if (bg != nullptr) delete bg;
|
bg->Destroy();
|
||||||
bg = nullptr;
|
bg = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2149,6 +2197,7 @@ DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, totaltime);
|
||||||
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, pnum);
|
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, pnum);
|
||||||
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, plyr);
|
DEFINE_FIELD_X(WBStartStruct, wbstartstruct_t, plyr);
|
||||||
|
|
||||||
|
DEFINE_FIELD(FIntermissionScreen, bg);
|
||||||
DEFINE_FIELD(FIntermissionScreen, acceleratestage);
|
DEFINE_FIELD(FIntermissionScreen, acceleratestage);
|
||||||
DEFINE_FIELD(FIntermissionScreen, playerready);
|
DEFINE_FIELD(FIntermissionScreen, playerready);
|
||||||
DEFINE_FIELD(FIntermissionScreen, me);
|
DEFINE_FIELD(FIntermissionScreen, me);
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
|
|
||||||
|
class InterBackground native
|
||||||
|
{
|
||||||
|
native InterBackground Create(wbstartstruct wbst);
|
||||||
|
native bool LoadBackground(bool isenterpic);
|
||||||
|
native void updateAnimatedBack();
|
||||||
|
native void drawBackground(int state, bool drawsplat, bool snl_pointeron);
|
||||||
|
}
|
||||||
|
|
||||||
struct PatchInfo
|
struct PatchInfo
|
||||||
{
|
{
|
||||||
Font mFont;
|
Font mFont;
|
||||||
|
@ -60,7 +68,7 @@ struct IntermissionScreen native
|
||||||
|
|
||||||
const SHOWNEXTLOCDELAY = 4; // in seconds
|
const SHOWNEXTLOCDELAY = 4; // in seconds
|
||||||
|
|
||||||
//FInterBackground *bg;
|
InterBackground bg;
|
||||||
native int acceleratestage; // used to accelerate or skip a stage
|
native int acceleratestage; // used to accelerate or skip a stage
|
||||||
native bool playerready[MAXPLAYERS];
|
native bool playerready[MAXPLAYERS];
|
||||||
native int me; // wbs.pnum
|
native int me; // wbs.pnum
|
||||||
|
|
Loading…
Reference in a new issue