From 8817914744fce8f0c6f18d03378b900368293a9f Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 4 Aug 2020 21:56:32 +1000 Subject: [PATCH] - add printcoords as an `ADD_STAT()` define and move string code into static function for shared use between CCMD and ADD_STAT. --- source/build/src/engine.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 22b9b1afc..624fe2b26 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -108,13 +108,32 @@ int32_t circlewall=-1; int16_t editstatus = 0; static fix16_t global100horiz; // (-100..300)-scale horiz (the one passed to drawrooms) +static FString printcoords(void) +{ + FString str; + + str.Format( + "pos.x: %d\n" + "pos.y: %d\n" + "pos.z: %d\n" + "ang : %d\n" + "horiz: %d\n", + globalposx, globalposy, + globalposz, globalang, + fix16_to_int(global100horiz) + ); + + return str; +} + CCMD(printcoords) { - Printf("pos.x: %d\n", globalposx); - Printf("pos.y: %d\n", globalposy); - Printf("pos.z: %d\n", globalposz); - Printf("ang: %d\n" , globalang); - Printf("horiz: %d\n", fix16_to_int(global100horiz)); + Printf("%s", printcoords().GetChars()); +} + +ADD_STAT(printcoords) +{ + return printcoords(); } int32_t(*getpalookup_replace)(int32_t davis, int32_t dashade) = NULL;