mirror of
https://github.com/ZDoom/Raze.git
synced 2025-06-01 17:52:13 +00:00
- Remove a lot of reference values on primitive data types from Blood's QAV interpolation system. Also use move assignments on the ignoredata
TMap when we're adding it to the game-side after processing it.
This commit is contained in:
parent
78e0719eca
commit
974ca7bd1d
5 changed files with 20 additions and 20 deletions
|
@ -2016,7 +2016,7 @@ void parseModel(FScanner& sc, FScriptPosition& pos)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
static bool parseDefineQAVInterpolateIgnoreBlock(FScanner& sc, const int& res_id, TMap<int, TArray<int>>& ignoredata, const int& numframes)
|
static bool parseDefineQAVInterpolateIgnoreBlock(FScanner& sc, const int res_id, TMap<int, TArray<int>>& ignoredata, const int numframes)
|
||||||
{
|
{
|
||||||
FScanner::SavedPos blockend;
|
FScanner::SavedPos blockend;
|
||||||
FScriptPosition pos = sc;
|
FScriptPosition pos = sc;
|
||||||
|
@ -2043,7 +2043,7 @@ static bool parseDefineQAVInterpolateIgnoreBlock(FScanner& sc, const int& res_id
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto arraybuilder = [&](const FString& input, TArray<int>& output, const int& maxvalue) -> bool
|
auto arraybuilder = [&](const FString& input, TArray<int>& output, const int maxvalue) -> bool
|
||||||
{
|
{
|
||||||
if (input.CompareNoCase("all") == 0)
|
if (input.CompareNoCase("all") == 0)
|
||||||
{
|
{
|
||||||
|
@ -2091,7 +2091,7 @@ static bool parseDefineQAVInterpolateIgnoreBlock(FScanner& sc, const int& res_id
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parseDefineQAVInterpolateBlock(FScanner& sc, const int& res_id, const int& numframes)
|
static bool parseDefineQAVInterpolateBlock(FScanner& sc, const int res_id, const int numframes)
|
||||||
{
|
{
|
||||||
FScanner::SavedPos blockend;
|
FScanner::SavedPos blockend;
|
||||||
FScriptPosition pos = sc;
|
FScriptPosition pos = sc;
|
||||||
|
@ -2127,11 +2127,11 @@ static bool parseDefineQAVInterpolateBlock(FScanner& sc, const int& res_id, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add interpolation properties to game for processing while drawing.
|
// Add interpolation properties to game for processing while drawing.
|
||||||
gi->AddQAVInterpProps(res_id, interptype, loopable, ignoredata);
|
gi->AddQAVInterpProps(res_id, interptype, loopable, std::move(ignoredata));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseDefineQAV(FScanner& sc, FScriptPosition& pos)
|
static void parseDefineQAV(FScanner& sc, FScriptPosition& pos)
|
||||||
{
|
{
|
||||||
FScanner::SavedPos blockend;
|
FScanner::SavedPos blockend;
|
||||||
FString fn;
|
FString fn;
|
||||||
|
|
|
@ -123,8 +123,8 @@ struct GameInterface
|
||||||
virtual void AddExcludedEpisode(FString episode) {}
|
virtual void AddExcludedEpisode(FString episode) {}
|
||||||
virtual int GetCurrentSkill() { return -1; }
|
virtual int GetCurrentSkill() { return -1; }
|
||||||
virtual bool IsQAVInterpTypeValid(const FString& type) { return false; }
|
virtual bool IsQAVInterpTypeValid(const FString& type) { return false; }
|
||||||
virtual void AddQAVInterpProps(const int& res_id, const FString& interptype, const bool& loopable, const TMap<int, TArray<int>>& ignoredata) { }
|
virtual void AddQAVInterpProps(const int res_id, const FString& interptype, const bool loopable, const TMap<int, TArray<int>>&& ignoredata) { }
|
||||||
virtual void RemoveQAVInterpProps(const int& res_id) { }
|
virtual void RemoveQAVInterpProps(const int res_id) { }
|
||||||
|
|
||||||
virtual FString statFPS()
|
virtual FString statFPS()
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,8 +151,8 @@ struct GameInterface : public ::GameInterface
|
||||||
void LoadGameTextures() override;
|
void LoadGameTextures() override;
|
||||||
int GetCurrentSkill() override;
|
int GetCurrentSkill() override;
|
||||||
bool IsQAVInterpTypeValid(const FString& type) override;
|
bool IsQAVInterpTypeValid(const FString& type) override;
|
||||||
void AddQAVInterpProps(const int& res_id, const FString& interptype, const bool& loopable, const TMap<int, TArray<int>>& ignoredata) override;
|
void AddQAVInterpProps(const int res_id, const FString& interptype, const bool loopable, const TMap<int, TArray<int>>&& ignoredata) override;
|
||||||
void RemoveQAVInterpProps(const int& res_id) override;
|
void RemoveQAVInterpProps(const int res_id) override;
|
||||||
|
|
||||||
GameStats getStats() override;
|
GameStats getStats() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,7 +40,7 @@ extern void (*qavClientCallback[])(int, void *);
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
using QAVPrevTileFinder = TILE_FRAME* (*)(FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int& i);
|
using QAVPrevTileFinder = TILE_FRAME* (*)(FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i);
|
||||||
|
|
||||||
struct QAVInterpProps
|
struct QAVInterpProps
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ struct QAVInterpProps
|
||||||
bool loopable;
|
bool loopable;
|
||||||
TMap<int, TArray<int>> IgnoreData;
|
TMap<int, TArray<int>> IgnoreData;
|
||||||
|
|
||||||
bool CanInterpFrameTile(const int& nFrame, const int& i)
|
bool CanInterpFrameTile(const int nFrame, const int i)
|
||||||
{
|
{
|
||||||
// Check whether the current frame's tile is skippable.
|
// Check whether the current frame's tile is skippable.
|
||||||
auto thisFrame = IgnoreData.CheckKey(nFrame);
|
auto thisFrame = IgnoreData.CheckKey(nFrame);
|
||||||
|
@ -62,17 +62,17 @@ static TMap<int, QAVInterpProps> qavInterpProps;
|
||||||
static void qavInitTileFinderMap()
|
static void qavInitTileFinderMap()
|
||||||
{
|
{
|
||||||
// Interpolate between frames if the picnums match. This is safest but could miss interpolations between suitable picnums.
|
// Interpolate between frames if the picnums match. This is safest but could miss interpolations between suitable picnums.
|
||||||
qavPrevTileFinders.Insert("picnum", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int& i) -> TILE_FRAME* {
|
qavPrevTileFinders.Insert("picnum", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* {
|
||||||
return prevFrame->tiles[i].picnum == thisFrame->tiles[i].picnum ? &prevFrame->tiles[i] : nullptr;
|
return prevFrame->tiles[i].picnum == thisFrame->tiles[i].picnum ? &prevFrame->tiles[i] : nullptr;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Interpolate between frames if the picnum is valid. This can be problematic if tile indices change between frames.
|
// Interpolate between frames if the picnum is valid. This can be problematic if tile indices change between frames.
|
||||||
qavPrevTileFinders.Insert("index", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int& i) -> TILE_FRAME* {
|
qavPrevTileFinders.Insert("index", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* {
|
||||||
return prevFrame->tiles[i].picnum > 0 ? &prevFrame->tiles[i] : nullptr;
|
return prevFrame->tiles[i].picnum > 0 ? &prevFrame->tiles[i] : nullptr;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find previous frame by iterating all previous frame's tiles and return on first matched x coordinate.
|
// Find previous frame by iterating all previous frame's tiles and return on first matched x coordinate.
|
||||||
qavPrevTileFinders.Insert("x", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int& i) -> TILE_FRAME* {
|
qavPrevTileFinders.Insert("x", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* {
|
||||||
for (int j = 0; j < 8; j++) if (thisFrame->tiles[i].x == prevFrame->tiles[j].x)
|
for (int j = 0; j < 8; j++) if (thisFrame->tiles[i].x == prevFrame->tiles[j].x)
|
||||||
{
|
{
|
||||||
return &prevFrame->tiles[j];
|
return &prevFrame->tiles[j];
|
||||||
|
@ -81,7 +81,7 @@ static void qavInitTileFinderMap()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find previous frame by iterating all previous frame's tiles and return on first matched y coordinate.
|
// Find previous frame by iterating all previous frame's tiles and return on first matched y coordinate.
|
||||||
qavPrevTileFinders.Insert("y", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int& i) -> TILE_FRAME* {
|
qavPrevTileFinders.Insert("y", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* {
|
||||||
for (int j = 0; j < 8; j++) if (thisFrame->tiles[i].y == prevFrame->tiles[j].y)
|
for (int j = 0; j < 8; j++) if (thisFrame->tiles[i].y == prevFrame->tiles[j].y)
|
||||||
{
|
{
|
||||||
return &prevFrame->tiles[j];
|
return &prevFrame->tiles[j];
|
||||||
|
@ -101,12 +101,12 @@ bool GameInterface::IsQAVInterpTypeValid(const FString& type)
|
||||||
return qavGetInterpType(type) != nullptr;
|
return qavGetInterpType(type) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameInterface::AddQAVInterpProps(const int& res_id, const FString& interptype, const bool& loopable, const TMap<int, TArray<int>>& ignoredata)
|
void GameInterface::AddQAVInterpProps(const int res_id, const FString& interptype, const bool loopable, const TMap<int, TArray<int>>&& ignoredata)
|
||||||
{
|
{
|
||||||
qavInterpProps.Insert(res_id, { qavGetInterpType(interptype), loopable, ignoredata });
|
qavInterpProps.Insert(res_id, { qavGetInterpType(interptype), loopable, std::move(ignoredata) });
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameInterface::RemoveQAVInterpProps(const int& res_id)
|
void GameInterface::RemoveQAVInterpProps(const int res_id)
|
||||||
{
|
{
|
||||||
qavInterpProps.Remove(res_id);
|
qavInterpProps.Remove(res_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,13 +239,13 @@ QAV* getQAV(int res_id);
|
||||||
void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick);
|
void qavProcessTicker(QAV* const pQAV, int* duration, int* lastTick);
|
||||||
void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, double* smoothratio, bool const fixedduration = false, bool const ignoreWeaponTimer = false);
|
void qavProcessTimer(PLAYER* const pPlayer, QAV* const pQAV, int* duration, double* smoothratio, bool const fixedduration = false, bool const ignoreWeaponTimer = false);
|
||||||
|
|
||||||
inline bool qavIsOriginal(const int& res_id)
|
inline bool qavIsOriginal(const int res_id)
|
||||||
{
|
{
|
||||||
auto const lump = fileSystem.FindResource(res_id, "QAV");
|
auto const lump = fileSystem.FindResource(res_id, "QAV");
|
||||||
return lump >= 0 && fileSystem.GetFileContainer(lump) < fileSystem.GetMaxIwadNum();
|
return lump >= 0 && fileSystem.GetFileContainer(lump) < fileSystem.GetMaxIwadNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int qavGetCorrectID(const int& res_id)
|
inline int qavGetCorrectID(const int res_id)
|
||||||
{
|
{
|
||||||
return cl_bloodweapinterp && qavIsOriginal(res_id) && fileSystem.FindResource(res_id + 10000, "QAV") != -1 ? res_id + 10000 : res_id;
|
return cl_bloodweapinterp && qavIsOriginal(res_id) && fileSystem.FindResource(res_id + 10000, "QAV") != -1 ? res_id + 10000 : res_id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue