From 0730b6b588ebe64ad88af9064d181fcf55ccd0ce Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Thu, 26 Jan 2023 20:40:58 -0600 Subject: [PATCH] [Crash] Fix crash issue with log formatting during character creation (#2798) --- world/client.cpp | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/world/client.cpp b/world/client.cpp index 672a68012..3d142b2ef 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -1778,12 +1778,39 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) pp.binds[0].heading = pp.heading; } - LogInfo("Current location [{}] [{}] [{}] [{}] [{}] [{}]", - ZoneName(pp.zone_id), pp.zone_id, pp.x, pp.y, pp.z, pp.heading); - LogInfo("Bind location [{}] [{}] [{}] [{}] [{}]", - ZoneName(pp.binds[0].zone_id), pp.binds[0].zone_id, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z); - LogInfo("Home location [{}] [{}] [{}] [{}] [{}]", - ZoneName(pp.binds[4].zone_id), pp.binds[4].zone_id, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z); + if (GetZone(pp.zone_id)) { + LogInfo( + "Current location [{}] [{}] [{:.2f}] [{:.2f}] [{:.2f}] [{:.2f}]", + ZoneName(pp.zone_id), + pp.zone_id, + pp.x, + pp.y, + pp.z, + pp.heading + ); + } + + if (GetZone(pp.binds[0].zone_id)) { + LogInfo( + "Bind location [{}] [{}] [{:.2f}] [{:.2f}] [{:.2f}]", + ZoneName(pp.binds[0].zone_id), + pp.binds[0].zone_id, + pp.binds[0].x, + pp.binds[0].y, + pp.binds[0].z + ); + } + + if (GetZone(pp.binds[4].zone_id)) { + LogInfo( + "Home location [{}] [{}] [{:.2f}] [{:.2f}] [{:.2f}]", + ZoneName(pp.binds[4].zone_id), + pp.binds[4].zone_id, + pp.binds[4].x, + pp.binds[4].y, + pp.binds[4].z + ); + } /* Starting Items inventory */ content_db.SetStartingItems(&pp, &inv, pp.race, pp.class_, pp.deity, pp.zone_id, pp.name, GetAdmin());