- continued refactoring on sound code.

The game independent part of the code has been mostly isolated.
This commit is contained in:
Christoph Oelckers 2019-12-08 21:22:53 +01:00
commit b9582cc98e
22 changed files with 1524 additions and 1310 deletions

View file

@ -1243,7 +1243,7 @@ FxExpression *FxStringCast::Resolve(FCompileContext &ctx)
if (basex->isConstant())
{
ExpVal constval = static_cast<FxConstant *>(basex)->GetValue();
FxExpression *x = new FxConstant(S_sfx[constval.GetInt()].name, ScriptPosition);
FxExpression *x = new FxConstant(S_GetSoundName(constval.GetInt()), ScriptPosition);
delete this;
return x;
}

View file

@ -1184,7 +1184,7 @@ PSound::PSound()
void PSound::WriteValue(FSerializer &ar, const char *key,const void *addr) const
{
const char *cptr = *(const FSoundID *)addr;
const char *cptr = S_GetSoundName(*(const FSoundID *)addr);
ar.StringPtr(key, cptr);
}

View file

@ -51,7 +51,7 @@ static void CastN2S(FString *a, int b) { FName name = FName(ENamedName(b)); *a =
static int CastS2Co(FString *b) { return V_GetColor(nullptr, *b); }
static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %02x", c.r, c.g, c.b); }
static int CastS2So(FString *b) { return FSoundID(*b); }
static void CastSo2S(FString *a, int b) { *a = S_sfx[b].name; }
static void CastSo2S(FString* a, int b) { *a = S_GetSoundName(b); }
static void CastSID2S(FString *a, unsigned int b) { *a = (b >= sprites.Size()) ? "TNT1" : sprites[b].name; }
static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); }

View file

@ -1837,7 +1837,7 @@ static void DoCast(const VMRegisters &reg, const VMFrame *f, int a, int b, int c
case CAST_So2S:
ASSERTS(a); ASSERTD(b);
reg.s[a] = S_sfx[reg.d[b]].name;
reg.s[a] = S_GetSoundName(reg.d[b]);
break;
case CAST_SID2S: