mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-19 07:01:09 +00:00
- adapted the breakable stuff interface in Duke to Texture IDs.
This commit is contained in:
parent
f3e652da84
commit
ee8b685fe2
5 changed files with 53 additions and 41 deletions
|
@ -358,29 +358,29 @@ void FMapInfoParser::ParseBreakWall()
|
|||
sc.MustGetStringName("{");
|
||||
while (!sc.CheckString("}"))
|
||||
{
|
||||
int basetile = -1;
|
||||
int breaktile = -1;
|
||||
FTextureID basetile = FNullTextureID();
|
||||
FTextureID breaktile = FNullTextureID();
|
||||
int flags = 0;
|
||||
FSoundID sound = NO_SOUND;
|
||||
VMFunction* handler = nullptr;
|
||||
|
||||
sc.MustGetString();
|
||||
FString basename = sc.String; // save for printing error messages.
|
||||
basetile = tileForName(sc.String);
|
||||
if (basetile < 0)
|
||||
basetile = TexMan.CheckForTexture(sc.String, ETextureType::Any);
|
||||
if (!basetile.isValid())
|
||||
{
|
||||
sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String, basetile);
|
||||
sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String);
|
||||
SkipToNext();
|
||||
}
|
||||
ParseAssign();
|
||||
sc.MustGetString();
|
||||
breaktile = tileForName(sc.String);
|
||||
if (*sc.String && breaktile < 0) sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String, breaktile);
|
||||
breaktile = TexMan.CheckForTexture(sc.String, ETextureType::Any);
|
||||
if (*sc.String && !breaktile.isValid()) sc.ScriptMessage("Unknown texture '%s' in breakwall definition", sc.String);
|
||||
if (sc.CheckString(","))
|
||||
{
|
||||
sc.MustGetString();
|
||||
sound = S_FindSound(sc.String);
|
||||
if (*sc.String && !sound.isvalid()) Printf(TEXTCOLOR_RED "Unknown sound '%s' in definition for breakable wall '5s'\n", basename.GetChars());
|
||||
if (*sc.String && !sound.isvalid()) sc.ScriptMessage("Unknown sound '%s' in definition for breakable wall '5s'\n", basename.GetChars());
|
||||
|
||||
auto saved = sc.SavePos();
|
||||
if (sc.CheckString(","))
|
||||
|
@ -407,7 +407,7 @@ void FMapInfoParser::ParseBreakWall()
|
|||
}
|
||||
}
|
||||
}
|
||||
breakWallMap.Insert(basetile, { breaktile, sound, handler, flags });
|
||||
breakWallMap.Insert(basetile.GetIndex(), {breaktile, sound, handler, flags});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,29 +423,29 @@ void FMapInfoParser::ParseBreakCeiling()
|
|||
sc.MustGetStringName("{");
|
||||
while (!sc.CheckString("}"))
|
||||
{
|
||||
int basetile = -1;
|
||||
int breaktile = -1;
|
||||
FTextureID basetile = FNullTextureID();
|
||||
FTextureID breaktile = FNullTextureID();
|
||||
int flags = 0;
|
||||
FSoundID sound = NO_SOUND;
|
||||
VMFunction* handler = nullptr;
|
||||
|
||||
sc.MustGetString();
|
||||
FString basename = sc.String; // save for printing error messages.
|
||||
basetile = tileForName(sc.String);
|
||||
if (basetile < 0)
|
||||
basetile = TexMan.CheckForTexture(sc.String, ETextureType::Any);
|
||||
if (!basetile.isValid())
|
||||
{
|
||||
sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String, basetile);
|
||||
sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String);
|
||||
SkipToNext();
|
||||
}
|
||||
ParseAssign();
|
||||
sc.MustGetString();
|
||||
breaktile = tileForName(sc.String);
|
||||
if (*sc.String && breaktile < 0) sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String, breaktile);
|
||||
breaktile = TexMan.CheckForTexture(sc.String, ETextureType::Any);
|
||||
if (*sc.String && !breaktile.isValid()) sc.ScriptMessage("Unknown texture '%s' in breakceiling definition", sc.String);
|
||||
if (sc.CheckString(","))
|
||||
{
|
||||
sc.MustGetString();
|
||||
sound = S_FindSound(sc.String);
|
||||
if (*sc.String && !sound.isvalid()) Printf(TEXTCOLOR_RED "Unknown sound '%s' in definition for breakable ceiling '5s'\n", basename.GetChars());
|
||||
if (*sc.String && !sound.isvalid()) sc.ScriptMessage("Unknown sound '%s' in definition for breakable ceiling '5s'\n", basename.GetChars());
|
||||
|
||||
auto saved = sc.SavePos();
|
||||
if (sc.CheckString(","))
|
||||
|
@ -472,7 +472,7 @@ void FMapInfoParser::ParseBreakCeiling()
|
|||
}
|
||||
}
|
||||
}
|
||||
breakCeilingMap.Insert(basetile, { breaktile, sound, handler, flags });
|
||||
breakCeilingMap.Insert(basetile.GetIndex(), {breaktile, sound, handler, flags});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ inline SpawnMap spawnMap;
|
|||
|
||||
struct BreakWallRec
|
||||
{
|
||||
int brokentex;
|
||||
FTextureID brokentex;
|
||||
FSoundID breaksound;
|
||||
VMFunction* handler;
|
||||
int flags;
|
||||
|
|
|
@ -496,9 +496,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, checktexture, sector_checktexture)
|
|||
void sector_settexturename(sectortype* sec, int place, int intname)
|
||||
{
|
||||
if (!sec) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
int tilenum = tileForName(FName(ENamedName(intname)).GetChars());
|
||||
(place == 0 ? sec->ceilingpicnum : sec->floorpicnum) = tilenum;
|
||||
FTextureID texid = TexMan.CheckForTexture(FName(ENamedName(intname)).GetChars(), ETextureType::Any);
|
||||
if (place == 0) sec->setceilingtexture(texid);
|
||||
else sec->setfloortexture(texid);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, settexturename, sector_settexturename)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(sectortype);
|
||||
|
@ -508,12 +510,15 @@ DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, settexturename, sector_settexturename
|
|||
return 0;
|
||||
}
|
||||
|
||||
// This is declared as TextureID but for now receives a tilenum
|
||||
void sector_settexture(sectortype* sec, int place, int tilenum)
|
||||
void sector_settexture(sectortype* sec, int place, int inttexid)
|
||||
{
|
||||
if (!sec) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
(place == 0 ? sec->ceilingpicnum : sec->floorpicnum) = tilenum;
|
||||
|
||||
FSetTextureID texid(inttexid);
|
||||
if (place == 0) sec->setceilingtexture(texid);
|
||||
else sec->setfloortexture(texid);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_sectortype, settexture, sector_settexture)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(sectortype);
|
||||
|
@ -724,9 +729,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, twosided, wall_twosided)
|
|||
void wall_settexturename(walltype* sec, int place, int intname)
|
||||
{
|
||||
if (!sec) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
int tilenum = tileForName(FName(ENamedName(intname)).GetChars());
|
||||
(place ? sec->overpicnum : sec->wallpicnum) = tilenum;
|
||||
FTextureID texid = TexMan.CheckForTexture(FName(ENamedName(intname)).GetChars(), ETextureType::Any);
|
||||
if (place == 0) sec->setwalltexture(texid);
|
||||
else sec->setovertexture(texid);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_walltype, settexturename, wall_settexturename)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(walltype);
|
||||
|
@ -736,11 +743,13 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, settexturename, wall_settexturename)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// This is declared as TextureID but for now receives a tilenum
|
||||
void wall_settexture(walltype* sec, int place, int tilenum)
|
||||
void wall_settexture(walltype* sec, int place, int inttexid)
|
||||
{
|
||||
if (!sec) ThrowAbortException(X_READ_NIL, nullptr);
|
||||
(place ? sec->overpicnum : sec->wallpicnum) = tilenum;
|
||||
|
||||
FSetTextureID texid(inttexid);
|
||||
if (place == 0) sec->setwalltexture(texid);
|
||||
else sec->setovertexture(texid);
|
||||
}
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_walltype, settexture, wall_settexture)
|
||||
{
|
||||
|
|
|
@ -2696,10 +2696,12 @@ void handle_se128(DDukeActor *actor)
|
|||
}
|
||||
// else return;
|
||||
|
||||
wal->overpicnum++;
|
||||
auto data = breakWallMap.CheckKey(wal->overtexture().GetIndex());
|
||||
FTextureID newtex = data? data->brokentex : FNullTextureID();
|
||||
wal->setovertexture(newtex);
|
||||
auto nextwal = wal->nextWall();
|
||||
if (nextwal)
|
||||
nextwal->overpicnum++;
|
||||
nextwal->setovertexture(newtex);
|
||||
|
||||
if (actor->temp_data[0] < actor->temp_data[1]) actor->temp_data[0]++;
|
||||
else
|
||||
|
|
|
@ -1283,34 +1283,35 @@ void checkhitwall(DDukeActor* spr, walltype* wal, const DVector3& pos)
|
|||
return;
|
||||
}
|
||||
|
||||
auto handler = [=](const BreakWallRec* data, int16_t* pic)
|
||||
auto handler = [=](const BreakWallRec* data) ->bool
|
||||
{
|
||||
if (!data->handler)
|
||||
{
|
||||
*pic = data->brokentex;
|
||||
S_PlayActorSound(data->breaksound, spr);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
VMValue args[7] = { wal, data->brokentex, data->breaksound.index(), spr, pos.X, pos.Y, pos.Z };
|
||||
VMValue args[7] = { wal, data->brokentex.GetIndex(), data->breaksound.index(), spr, pos.X, pos.Y, pos.Z};
|
||||
VMCall(data->handler, args, 7, nullptr, 0);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
if (wal->twoSided() && wal->nextSector()->floorz > pos.Z && wal->nextSector()->floorz - wal->nextSector()->ceilingz)
|
||||
{
|
||||
auto data = breakWallMap.CheckKey(wal->overpicnum);
|
||||
auto data = breakWallMap.CheckKey(wal->overtexture().GetIndex());
|
||||
if (data && (data->flags & 1) && (!(data->flags & 2) || wal->cstat & CSTAT_WALL_MASKED))
|
||||
{
|
||||
handler(data, &wal->overpicnum);
|
||||
if (handler(data)) wal->setovertexture(data->brokentex);
|
||||
}
|
||||
}
|
||||
|
||||
auto data = breakWallMap.CheckKey(wal->wallpicnum);
|
||||
auto data = breakWallMap.CheckKey(wal->walltexture().GetIndex());
|
||||
if (data && !(data->flags & 1))
|
||||
{
|
||||
handler(data, &wal->wallpicnum);
|
||||
if (handler(data)) wal->setwalltexture(data->brokentex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1322,17 +1323,17 @@ void checkhitwall(DDukeActor* spr, walltype* wal, const DVector3& pos)
|
|||
|
||||
bool checkhitceiling(sectortype* sectp)
|
||||
{
|
||||
auto data = breakCeilingMap.CheckKey(sectp->ceilingpicnum);
|
||||
auto data = breakCeilingMap.CheckKey(sectp->ceilingtexture().GetIndex());
|
||||
if (data && !(data->flags & 1))
|
||||
{
|
||||
if (!data->handler)
|
||||
{
|
||||
sectp->ceilingpicnum = data->brokentex;
|
||||
sectp->setceilingtexture(data->brokentex);
|
||||
S_PlayActorSound(data->breaksound, ps[screenpeek].GetActor()); // this is nonsense but what the original code did.
|
||||
}
|
||||
else
|
||||
{
|
||||
VMValue args[7] = { sectp, data->brokentex, data->breaksound.index() };
|
||||
VMValue args[7] = { sectp, data->brokentex.GetIndex(), data->breaksound.index()};
|
||||
VMCall(data->handler, args, 3, nullptr, 0);
|
||||
}
|
||||
if (data->flags & 1)
|
||||
|
|
Loading…
Reference in a new issue