- refactored coordinate display to have a single unified printing function.

The games will now only return the data, this has also been added for Exhumed.
Printing will now be in actual map units, not build's internal mixed format.
This commit is contained in:
Christoph Oelckers 2022-08-22 00:08:52 +02:00
parent b32c4444c4
commit aa0080039f
10 changed files with 30 additions and 31 deletions

View file

@ -232,7 +232,16 @@ ADD_STAT(fps)
ADD_STAT(coord)
{
return gi->GetCoordString();
auto coord = gi->GetCoordinates();
FString out;
if (coord.first.X < DBL_MAX)
{
out.AppendFormat("X: %d ", int(coord.first.X));
out.AppendFormat("Y: %d ", int(coord.first.Y));
out.AppendFormat("Z: %d ", int(coord.first.Z));
out.AppendFormat("Angle: %d\n", int(coord.second.Degrees()));
}
return out;
}
CUSTOM_CVARD(Int, r_showfps, 0, 0, "show the frame rate counter")

View file

@ -91,7 +91,7 @@ struct GameInterface
virtual void SerializeGameState(FSerializer& arc) {}
virtual void DrawPlayerSprite(const DVector2& origin, bool onteam) {}
virtual void SetAmbience(bool on) {}
virtual FString GetCoordString() { return "'stat coord' not implemented"; }
virtual std::pair<DVector3, DAngle> GetCoordinates() { return {}; }
virtual void ExitFromMenu() { throw CExitEvent(0); }
virtual ReservedSpace GetReservedScreenSpace(int viewsize) { return { 0, 0 }; }
virtual void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) {}

View file

@ -121,7 +121,7 @@ struct GameInterface : public ::GameInterface
void MenuOpened() override;
void MenuClosed() override;
bool CanSave() override;
FString GetCoordString() override;
std::pair<DVector3, DAngle> GetCoordinates() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override;
void UpdateSounds() override;
void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) override;

View file

@ -847,14 +847,10 @@ bool GameInterface::GenerateSavePic()
return true;
}
FString GameInterface::GetCoordString()
std::pair<DVector3, DAngle> GameInterface::GetCoordinates()
{
FString out;
out.Format("pos= %d, %d, %d - angle = %2.3f",
gMe->actor->int_pos().X, gMe->actor->int_pos().Y, gMe->actor->int_pos().Z, gMe->actor->spr.int_ang() * BAngToDegree);
return out;
if (!gMe || !gMe->actor) return std::make_pair(DVector3(DBL_MAX, 0, 0), nullAngle);
return std::make_pair(gMe->actor->spr.pos, gMe->actor->spr.angle);
}

View file

@ -35,7 +35,7 @@ struct GameInterface : public ::GameInterface
FSavegameInfo GetSaveSig() override;
double SmallFontScale() override { return isRR() ? 0.5 : 1.; }
void SerializeGameState(FSerializer& arc) override;
FString GetCoordString() override;
std::pair<DVector3, DAngle> GetCoordinates() override;
void ExitFromMenu() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override;
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;

View file

@ -55,19 +55,11 @@ BEGIN_DUKE_NS
//
//---------------------------------------------------------------------------
FString GameInterface::GetCoordString()
std::pair<DVector3, DAngle> GameInterface::GetCoordinates()
{
int snum = screenpeek;
FString out;
out.Format("pos= %2.3f, %2.3f, %2.3f - angle = %2.3f - sector = %d, lotag = %d, hitag = %d",
ps[snum].pos.X, ps[snum].pos.Y, ps[snum].pos.Z, ps[snum].angle.ang.Degrees(), sectnum(ps[snum].cursector),
ps[snum].cursector->lotag, ps[snum].cursector->hitag);
return out;
return std::make_pair(ps[screenpeek].pos, ps[screenpeek].angle.ang);
}
GameStats GameInterface::getStats()
{
player_struct* p = &ps[myconnectindex];

View file

@ -600,6 +600,14 @@ bool GameInterface::CanSave()
return new GameInterface;
}
std::pair<DVector3, DAngle> GameInterface::GetCoordinates()
{
auto pPlayerActor = PlayerList[nLocalPlayer].pActor;
if (!pPlayerActor) return std::make_pair(DVector3(DBL_MAX, 0, 0), nullAngle);
return std::make_pair(pPlayerActor->spr.pos, pPlayerActor->spr.angle);
}
void DExhumedActor::Serialize(FSerializer& arc)
{
Super::Serialize(arc);

View file

@ -239,6 +239,7 @@ struct GameInterface : public ::GameInterface
vec3_t chaseCamPos(DAngle ang, fixedhoriz horiz) { return vec3_t(int(-ang.Cos() * 1536.), int(-ang.Sin() * 1536.), (horiz.asq16() * 3) >> 10); }
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override;
int GetCurrentSkill() override;
std::pair<DVector3, DAngle> GetCoordinates() override;
::GameStats getStats() override;
};

View file

@ -1017,19 +1017,12 @@ void CircleCamera(int *nx, int *ny, int *nz, sectortype** vsect, DAngle *nang, f
*nang = ang;
}
FString GameInterface::GetCoordString()
std::pair<DVector3, DAngle> GameInterface::GetCoordinates()
{
PLAYER* pp = Player + myconnectindex;
FString out;
out.AppendFormat("POSX:%d ", pp->int_ppos().X);
out.AppendFormat("POSY:%d ", pp->int_ppos().Y);
out.AppendFormat("POSZ:%d ", pp->int_ppos().Z);
out.AppendFormat("ANG:%d\n", pp->angle.ang.Buildang());
return out;
return std::make_pair(pp->pos, pp->angle.ang);
}
void PrintSpriteInfo(PLAYER* pp)
{
const int Y_STEP = 7;

View file

@ -1953,7 +1953,7 @@ struct GameInterface : public ::GameInterface
FSavegameInfo GetSaveSig() override;
void SerializeGameState(FSerializer& arc);
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
FString GetCoordString() override;
std::pair<DVector3, DAngle> GetCoordinates() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override;
void UpdateSounds() override;
void ErrorCleanup() override;