summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-12-20 20:18:30 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-12-20 20:18:30 +0100
commit95661918ce5da32cce84055e80fcc15343591638 (patch)
tree0356b59d13cd1b59bdfc42ddc550700a32109372 /src
parent8deb1305726966b3b583865dec1ba7ba1327d8cb (diff)
downloadcolobot-95661918ce5da32cce84055e80fcc15343591638.tar.gz
colobot-95661918ce5da32cce84055e80fcc15343591638.tar.bz2
colobot-95661918ce5da32cce84055e80fcc15343591638.zip
Some further refactoring and test corrections
Diffstat (limited to 'src')
-rw-r--r--src/ui/displayinfo.cpp38
-rw-r--r--src/ui/studio.cpp2
2 files changed, 25 insertions, 15 deletions
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index bd20452..79eb38a 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -23,6 +23,7 @@
#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
+#include "common/stringutils.h"
#include "graphics/core/light.h"
#include "graphics/engine/engine.h"
@@ -971,32 +972,41 @@ void ObjectAdd(ObjectList list[], ObjectType type)
void ObjectWrite(FILE* file, ObjectList list[], int i)
{
- char line[100];
- char* p;
+ std::string line;
if ( list[i].total < 10 )
{
- sprintf(line, "\\c; %dx \\n;\\l;", list[i].total);
+ line = StrUtils::Format("\\c; %dx \\n;\\l;", list[i].total);
}
else
{
- sprintf(line, "\\c;%dx \\n;\\l;", list[i].total);
+ line = StrUtils::Format("\\c;%dx \\n;\\l;", list[i].total);
}
std::string res;
GetResource(RES_OBJECT, list[i].type, res);
- if (res.empty()) return;
- strcat(line, res.c_str());
+ if (res.empty())
+ return;
+
+ line += res;
+
+ line += "\\u ";
- strcat(line, "\\u ");
std::string helpFilename = GetHelpFilename(list[i].type);
- p = const_cast<char*>(helpFilename.c_str());
- if ( p[0] == 0 ) return;
- strcat(line, p+7); // skip "help\?\"
- p = strstr(line, ".txt");
- if ( p != 0 ) *p = 0;
- strcat(line, ";\n");
- fputs(line, file);
+ if (helpFilename.empty())
+ return;
+
+ line += helpFilename.substr(7); // skip "help\?\"
+
+ auto pos = line.find(".txt");
+ if (pos != std::string::npos)
+ {
+ line = line.substr(0, pos);
+ }
+
+ line += ";\n";
+
+ fputs(line.c_str(), file);
}
// Creates the file containing the list of objects.
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index ba28a0a..fb4dd3d 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -1497,7 +1497,7 @@ void CStudio::UpdateDialogPublic()
pl = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1));
if ( pl != 0 )
{
- //? GetResource(RES_TEXT, RT_IO_LIST, name);
+ // GetResource(RES_TEXT, RT_IO_LIST, name); // TODO: unused?
pl->SetName(SearchDirectory(false).c_str(), false);
}
}