- added mapangle function for converting angles from map data.

This is just a wrapper around DAngle::fromBuild, its purpose is to clearly highlight data that cannot be refactored and needs to be converted
This commit is contained in:
Christoph Oelckers 2022-09-11 13:47:47 +02:00
parent fdeb060ccd
commit 0e1a566d62
11 changed files with 23 additions and 17 deletions

View file

@ -314,7 +314,7 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)
secno = fr.ReadInt16();
spr.statnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.angle = mapangle(spr.intangle);
spr.intowner = fr.ReadInt16();
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
@ -341,7 +341,7 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno)
spr.yoffset = fr.ReadInt8();
spr.picnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.angle = mapangle(spr.intangle);
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
spr.inittype = fr.ReadInt16();
@ -369,7 +369,7 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno)
spr.yrepeat = fr.ReadUInt8();
spr.picnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.angle = mapangle(spr.intangle);
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
spr.inittype = fr.ReadInt16();

View file

@ -745,3 +745,9 @@ TArray<walltype> loadMapWalls(const char* filename);
void loadMapBackup(const char* filename);
void loadMapHack(const char* filename, const uint8_t*, SpawnSpriteDef& sprites);
void validateStartSector(const char* filename, const DVector3& pos, int* cursectnum, unsigned numsectors, bool noabort = false);
// should only be used to read angles from map-loaded data (for proper documentation)
inline DAngle mapangle(int mapang)
{
return DAngle::fromBuild(mapang);
}

View file

@ -139,7 +139,7 @@ static void batThinkGoto(DBloodActor* actor)
auto nAngle = VecToAngle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < DAngle::fromBuild(pDudeInfo->periphery))
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < mapangle(pDudeInfo->periphery))
aiNewState(actor, &batSearch);
batThinkTarget(actor);
}

View file

@ -178,7 +178,7 @@ static void beastThinkGoto(DBloodActor* actor)
auto nAngle = VecToAngle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < DAngle::fromBuild(pDudeInfo->periphery))
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < mapangle(pDudeInfo->periphery))
{
if (pXSector && pXSector->Underwater)
aiNewState(actor, &beastSwimSearch);
@ -328,7 +328,7 @@ static void beastThinkSwimGoto(DBloodActor* actor)
auto nAngle = VecToAngle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < DAngle::fromBuild(pDudeInfo->periphery))
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < mapangle(pDudeInfo->periphery))
aiNewState(actor, &beastSwimSearch);
aiThinkTarget(actor);
}

View file

@ -152,7 +152,7 @@ static void eelThinkGoto(DBloodActor* actor)
auto nAngle = VecToAngle(dvec);
int nDist = approxDist(dvec);
aiChooseDirection(actor, nAngle);
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < DAngle::fromBuild(pDudeInfo->periphery))
if (nDist < 512 && absangle(actor->spr.angle, nAngle) < mapangle(pDudeInfo->periphery))
aiNewState(actor, &eelSearch);
eelThinkTarget(actor);
}

View file

@ -475,7 +475,7 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, int* cursectnum,
pSprite->picnum = LittleShort(load.picnum);
int secno = LittleShort(load.sectnum);
pSprite->statnum = LittleShort(load.statnum);
pSprite->angle = DAngle::fromBuild(LittleShort(load.ang));
pSprite->angle = mapangle(LittleShort(load.ang));
pSprite->intowner = LittleShort(load.owner);
pSprite->xint = LittleShort(load.index);
pSprite->yint = LittleShort(load.yvel);
@ -549,7 +549,7 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, int* cursectnum,
pXSprite->data1 = bitReader.readSigned(16);
pXSprite->data2 = bitReader.readSigned(16);
pXSprite->data3 = bitReader.readSigned(16);
pXSprite->goalAng = DAngle::fromBuild(bitReader.readUnsigned(11));
pXSprite->goalAng = mapangle(bitReader.readUnsigned(11));
pXSprite->dodgeDir = bitReader.readSigned(2);
pXSprite->locked = bitReader.readUnsigned(1);
pXSprite->medium = bitReader.readUnsigned(2);

View file

@ -417,7 +417,7 @@ QAV* getQAV(int res_id)
qavdata->frames[i].tiles[j].stat = fr.ReadInt32();
qavdata->frames[i].tiles[j].shade = fr.ReadInt8();
qavdata->frames[i].tiles[j].palnum = fr.ReadUInt8();
qavdata->frames[i].tiles[j].angle = DAngle::fromBuild(fr.ReadUInt16());
qavdata->frames[i].tiles[j].angle = mapangle(fr.ReadUInt16());
}
}

View file

@ -155,7 +155,7 @@ void AISoul::Tick(RunListEvent* ev)
pActor->spr.extra += (pActor->nPhase & 0x0F) + 5;
pActor->spr.extra &= kAngleMask;
double nVel = DAngle::fromBuild(pActor->spr.extra).Cos();
double nVel = mapangle(pActor->spr.extra).Cos();
auto vect = pActor->spr.angle.ToVector() * nVel * 8;
auto coll = movesprite(pActor,vect, pActor->vel.Z, 0, CLIPMASK0);

View file

@ -1176,7 +1176,7 @@ void SetupSectorObject(sectortype* sectp, short tag)
break;
case SO_LIMIT_TURN:
sop->limit_ang_center = actor->spr.angle;
sop->limit_ang_delta = DAngle::fromBuild(actor->spr.lotag);
sop->limit_ang_delta = mapangle(actor->spr.lotag);
KillActor(actor);
break;
case SO_MATCH_EVENT:
@ -1191,7 +1191,7 @@ void SetupSectorObject(sectortype* sectp, short tag)
case SO_SPIN:
if (sop->spin_speed != nullAngle)
break;
sop->spin_speed = DAngle::fromBuild(actor->spr.lotag);
sop->spin_speed = mapangle(actor->spr.lotag);
sop->last_ang = sop->ang;
KillActor(actor);
break;
@ -1203,7 +1203,7 @@ void SetupSectorObject(sectortype* sectp, short tag)
break;
case SO_SPIN_REVERSE:
sop->spin_speed = DAngle::fromBuild(actor->spr.lotag);
sop->spin_speed = mapangle(actor->spr.lotag);
sop->last_ang = sop->ang;
if (sop->spin_speed >= nullAngle)
@ -2195,7 +2195,7 @@ DVector2 DoTrack(SECTOR_OBJECT* sop, short locktics)
if (sop->spin_speed != nullAngle)
break;
sop->spin_speed = DAngle::fromBuild(tpoint->tag_high);
sop->spin_speed = mapangle(tpoint->tag_high);
sop->last_ang = sop->ang;
break;

View file

@ -93,7 +93,7 @@ int DoWallMove(DSWActor* actor)
bool SOsprite = false;
double dist = SP_TAG13(actor) * maptoworld;
DAngle ang = DAngle::fromBuild(SP_TAG4(actor));
DAngle ang = mapangle(SP_TAG4(actor));
picnum1 = SP_TAG5(actor);
picnum2 = SP_TAG6(actor);
shade1 = SP_TAG7(actor);

View file

@ -11740,7 +11740,7 @@ int DoSerpRing(DSWActor* actor)
}
// rotate the ring
actor->user.slide_ang += DAngle::fromBuild(actor->spr.yint);
actor->user.slide_ang += mapangle(actor->spr.yint);
// rotate the heads
if (actor->user.Flags & (SPR_BOUNCE))