From bffad13e0e7c99a5b167bc1d2f4a66afb1bdcc5d Mon Sep 17 00:00:00 2001 From: yukani Date: Sat, 5 Oct 2024 20:17:16 +0300 Subject: [PATCH 1/3] fix --- source/game_sa/Scripts/Commands/Text.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/game_sa/Scripts/Commands/Text.cpp b/source/game_sa/Scripts/Commands/Text.cpp index 06a7fe8dc5..ff18ba1c39 100644 --- a/source/game_sa/Scripts/Commands/Text.cpp +++ b/source/game_sa/Scripts/Commands/Text.cpp @@ -61,7 +61,10 @@ void DisplayText(CVector2D pos, const char* gxtKey) { assert(CTheScripts::UseTextCommands != CTheScripts::eUseTextCommandState::DISABLED); auto* const line = &CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame++]; - strcpy_s(line->m_szGxtEntry, gxtKey); + line->m_Pos = pos; + line->param1 = -1; + line->param2 = -1; + strncpy(line->m_szGxtEntry, gxtKey, 8); } void notsa::script::commands::text::RegisterHandlers() { From fd30879b01e7327a0e485cfddc8ef5c17febe336 Mon Sep 17 00:00:00 2001 From: yukani Date: Sat, 5 Oct 2024 21:28:25 +0300 Subject: [PATCH 2/3] use sizeof instead of magic --- source/game_sa/Scripts/Commands/Text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/game_sa/Scripts/Commands/Text.cpp b/source/game_sa/Scripts/Commands/Text.cpp index ff18ba1c39..51235ff05b 100644 --- a/source/game_sa/Scripts/Commands/Text.cpp +++ b/source/game_sa/Scripts/Commands/Text.cpp @@ -64,7 +64,7 @@ void DisplayText(CVector2D pos, const char* gxtKey) { line->m_Pos = pos; line->param1 = -1; line->param2 = -1; - strncpy(line->m_szGxtEntry, gxtKey, 8); + strncpy(line->m_szGxtEntry, gxtKey, sizeof(line->m_szGxtEntry)); } void notsa::script::commands::text::RegisterHandlers() { From 8eca97b1fd3be061d7c992fee4858ce9f50d1bf8 Mon Sep 17 00:00:00 2001 From: yukani Date: Sat, 5 Oct 2024 21:43:16 +0300 Subject: [PATCH 3/3] revert to strcpy_s --- source/game_sa/Scripts/Commands/Text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/game_sa/Scripts/Commands/Text.cpp b/source/game_sa/Scripts/Commands/Text.cpp index 51235ff05b..78c4386c6b 100644 --- a/source/game_sa/Scripts/Commands/Text.cpp +++ b/source/game_sa/Scripts/Commands/Text.cpp @@ -64,7 +64,7 @@ void DisplayText(CVector2D pos, const char* gxtKey) { line->m_Pos = pos; line->param1 = -1; line->param2 = -1; - strncpy(line->m_szGxtEntry, gxtKey, sizeof(line->m_szGxtEntry)); + strcpy_s(line->m_szGxtEntry, gxtKey); } void notsa::script::commands::text::RegisterHandlers() {