diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2013-12-03 00:11:26 +0100 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2013-12-04 00:15:39 +0100 |
commit | 8deb1305726966b3b583865dec1ba7ba1327d8cb (patch) | |
tree | 291627fbe0123dc35c015b1f398585f204afe8ea /src/script | |
parent | dae8d8738908a65a4ee4ef14d88681e196825126 (diff) | |
download | colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.tar.gz colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.tar.bz2 colobot-8deb1305726966b3b583865dec1ba7ba1327d8cb.zip |
Changed char[] to std::string in restext
Experimental changes
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/script.cpp | 29 | ||||
-rw-r--r-- | src/script/script.h | 2 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/script/script.cpp b/src/script/script.cpp index ca6ce25..5cd21f9 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -22,6 +22,7 @@ #include "common/global.h" #include "common/iman.h" #include "common/restext.h" +#include "common/stringutils.h" #include "graphics/engine/terrain.h" #include "graphics/engine/water.h" @@ -3898,9 +3899,9 @@ bool CScript::Continue(const Event &event) if ( m_error != 0 && m_errMode == ERM_STOP ) { - char s[100]; + std::string s; GetError(s); - m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); + m_main->GetDisplayText()->DisplayText(s.c_str(), m_object, 10.0f, Ui::TT_ERROR); } m_engine->SetPause(true); // gives pause return true; @@ -3931,9 +3932,9 @@ bool CScript::Continue(const Event &event) if ( m_error != 0 && m_errMode == ERM_STOP ) { - char s[100]; + std::string s; GetError(s); - m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); + m_main->GetDisplayText()->DisplayText(s.c_str(), m_object, 10.0f, Ui::TT_ERROR); } return true; } @@ -3973,9 +3974,9 @@ bool CScript::Step(const Event &event) if ( m_error != 0 && m_errMode == ERM_STOP ) { - char s[100]; + std::string s; GetError(s); - m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR); + m_main->GetDisplayText()->DisplayText(s.c_str(), m_object, 10.0f, Ui::TT_ERROR); } return true; } @@ -4347,27 +4348,27 @@ int CScript::GetError() // Returns the text of the error. -void CScript::GetError(char* buffer) +void CScript::GetError(std::string& error) { if ( m_error == 0 ) { - buffer[0] = 0; + error.clear(); } else { if ( m_error == ERR_OBLIGATORYTOKEN ) { - char s[100]; + std::string s; GetResource(RES_ERR, m_error, s); - sprintf(buffer, s, m_token); + error = StrUtils::Format(s.c_str(), m_token); } else if ( m_error < 1000 ) { - GetResource(RES_ERR, m_error, buffer); + GetResource(RES_ERR, m_error, error); } else { - GetResource(RES_CBOT, m_error, buffer); + GetResource(RES_CBOT, m_error, error); } } } @@ -4385,7 +4386,9 @@ void CScript::New(Ui::CEdit* edit, const char* name) char *sf; int cursor1, cursor2, len, i, j; - GetResource(RES_TEXT, RT_SCRIPT_NEW, res); + std::string resStr; + GetResource(RES_TEXT, RT_SCRIPT_NEW, resStr); + strcpy(res, resStr.c_str()); if ( name[0] == 0 ) strcpy(text, res); else strcpy(text, name); diff --git a/src/script/script.h b/src/script/script.h index 7fd5555..3641dd9 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -74,7 +74,7 @@ public: bool IntroduceVirus(); int GetError(); - void GetError(char* buffer); + void GetError(std::string& error); void New(Ui::CEdit* edit, const char* name); bool SendScript(const char* text); |