mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-11 08:20:50 +00:00
- got rid of setspritez(x) and moved the implementation to SetActor(Z) without referencing the sprite array.
This commit is contained in:
parent
6773fa2189
commit
2654a19cfd
5 changed files with 35 additions and 57 deletions
|
@ -523,12 +523,6 @@ int32_t deletesprite(int16_t spritenum);
|
||||||
|
|
||||||
int32_t changespritesect(int16_t spritenum, int16_t newsectnum);
|
int32_t changespritesect(int16_t spritenum, int16_t newsectnum);
|
||||||
int32_t changespritestat(int16_t spritenum, int16_t newstatnum);
|
int32_t changespritestat(int16_t spritenum, int16_t newstatnum);
|
||||||
int32_t setsprite(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
|
|
||||||
inline int32_t setsprite(int16_t spritenum, int x, int y, int z)
|
|
||||||
{
|
|
||||||
vec3_t v = { x,y,z };
|
|
||||||
return setsprite(spritenum, &v);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
|
int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
|
||||||
|
|
||||||
|
|
|
@ -410,6 +410,11 @@ struct spritetype
|
||||||
backupang();
|
backupang();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setpos(const vec3_t& newpos)
|
||||||
|
{
|
||||||
|
pos = newpos;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t interpolatedx(double const smoothratio, int const scale = 16)
|
int32_t interpolatedx(double const smoothratio, int const scale = 16)
|
||||||
{
|
{
|
||||||
return interpolatedvalue(ox, x, smoothratio, scale);
|
return interpolatedvalue(ox, x, smoothratio, scale);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "gamefuncs.h"
|
#include "gamefuncs.h"
|
||||||
#include "hw_voxels.h"
|
#include "hw_voxels.h"
|
||||||
|
#include "coreactor.h"
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
# include "mdsprite.h"
|
# include "mdsprite.h"
|
||||||
|
@ -764,44 +765,6 @@ int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyo
|
||||||
return zofs;
|
return zofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// setsprite
|
|
||||||
//
|
|
||||||
int32_t setsprite(int16_t spritenum, const vec3_t *newpos)
|
|
||||||
{
|
|
||||||
auto tempsector = sprite[spritenum].sector();
|
|
||||||
|
|
||||||
if (newpos != &sprite[spritenum].pos)
|
|
||||||
sprite[spritenum].pos = *newpos;
|
|
||||||
|
|
||||||
updatesector(newpos->x,newpos->y,&tempsector);
|
|
||||||
|
|
||||||
if (tempsector == nullptr)
|
|
||||||
return -1;
|
|
||||||
if (tempsector != sprite[spritenum].sector())
|
|
||||||
changespritesect(spritenum, sectnum(tempsector));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t setspritez(int16_t spritenum, const vec3_t *newpos)
|
|
||||||
{
|
|
||||||
auto tempsectnum = sprite[spritenum].sector();
|
|
||||||
|
|
||||||
if ((void const *)newpos != (void *)&sprite[spritenum])
|
|
||||||
sprite[spritenum].pos = *newpos;
|
|
||||||
|
|
||||||
updatesectorz(newpos->x,newpos->y,newpos->z,&tempsectnum);
|
|
||||||
|
|
||||||
if (tempsectnum == nullptr)
|
|
||||||
return -1;
|
|
||||||
if (tempsectnum != sprite[spritenum].sector())
|
|
||||||
changespritesect(spritenum, sectnum(tempsectnum));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// nextsectorneighborz
|
// nextsectorneighborz
|
||||||
//
|
//
|
||||||
|
@ -1444,6 +1407,28 @@ int tilehasmodelorvoxel(int const tilenume, int pal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetActor(DCoreActor* actor, const vec3_t* newpos)
|
||||||
|
{
|
||||||
|
auto tempsector = actor->sector();
|
||||||
|
actor->s().setpos(*newpos);
|
||||||
|
updatesector(newpos->x, newpos->y, &tempsector);
|
||||||
|
|
||||||
|
if (tempsector && tempsector != actor->sector())
|
||||||
|
ChangeActorSect(actor, tempsector);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetActorZ(DCoreActor* actor, const vec3_t* newpos)
|
||||||
|
{
|
||||||
|
auto tempsector = actor->sector();
|
||||||
|
actor->s().setpos(*newpos);
|
||||||
|
updatesectorz(newpos->x, newpos->y, newpos->z, &tempsector);
|
||||||
|
|
||||||
|
if (tempsector && tempsector != actor->sector())
|
||||||
|
ChangeActorSect(actor, tempsector);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CCMD(updatesectordebug)
|
CCMD(updatesectordebug)
|
||||||
{
|
{
|
||||||
int sect = 319;
|
int sect = 319;
|
||||||
|
|
|
@ -301,19 +301,13 @@ inline void ChangeActorSect(DCoreActor* actor, sectortype* sect)
|
||||||
changespritesect(actor->GetSpriteIndex(), sector.IndexOf(sect));
|
changespritesect(actor->GetSpriteIndex(), sector.IndexOf(sect));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int SetActorZ(DCoreActor* actor, const vec3_t* newpos)
|
|
||||||
{
|
|
||||||
return setspritez(actor->GetSpriteIndex(), newpos);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int SetActor(DCoreActor* actor, const vec3_t* newpos)
|
void SetActorZ(DCoreActor* actor, const vec3_t* newpos);
|
||||||
{
|
void SetActor(DCoreActor* actor, const vec3_t* newpos);
|
||||||
return setsprite(actor->GetSpriteIndex(), newpos);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int SetActor(DCoreActor* actor, const vec3_t& newpos)
|
inline void SetActor(DCoreActor* actor, const vec3_t& newpos)
|
||||||
{
|
{
|
||||||
return setsprite(actor->GetSpriteIndex(), &newpos);
|
SetActor(actor, &newpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -99,14 +99,14 @@ static int ccmd_spawn(CCmdFuncPtr parm)
|
||||||
if (set & 1) spawned->s->pal = (uint8_t)pal;
|
if (set & 1) spawned->s->pal = (uint8_t)pal;
|
||||||
if (set & 2) spawned->s->cstat = (uint16_t)cstat;
|
if (set & 2) spawned->s->cstat = (uint16_t)cstat;
|
||||||
if (set & 4) spawned->s->ang = ang;
|
if (set & 4) spawned->s->ang = ang;
|
||||||
if (set & 8) {
|
if (set & 8)
|
||||||
if (SetActor(spawned, { x, y, z }) < 0)
|
SetActor(spawned, { x, y, z });
|
||||||
|
if (spawned->sector() == nullptr)
|
||||||
{
|
{
|
||||||
Printf("spawn: Sprite can't be spawned into null space\n");
|
Printf("spawn: Sprite can't be spawned into null space\n");
|
||||||
deletesprite(spawned);
|
deletesprite(spawned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return CCMD_OK;
|
return CCMD_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue