1
0
Fork 0

Codechange: [Network] Use std::string instead of char[] for the name of the file that is downloading

pull/9369/head
rubidium42 2021-06-14 16:16:10 +02:00 committed by rubidium42
parent 981cd0197a
commit 05005dcdfa
2 changed files with 4 additions and 4 deletions

View File

@ -131,7 +131,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widge
StringID str; StringID str;
if (this->downloaded_bytes == this->total_bytes) { if (this->downloaded_bytes == this->total_bytes) {
str = STR_CONTENT_DOWNLOAD_COMPLETE; str = STR_CONTENT_DOWNLOAD_COMPLETE;
} else if (!StrEmpty(this->name)) { } else if (!this->name.empty()) {
SetDParamStr(0, this->name); SetDParamStr(0, this->name);
SetDParam(1, this->downloaded_files); SetDParam(1, this->downloaded_files);
SetDParam(2, this->total_files); SetDParam(2, this->total_files);
@ -147,7 +147,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widge
void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes) void BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(const ContentInfo *ci, int bytes)
{ {
if (ci->id != this->cur_id) { if (ci->id != this->cur_id) {
strecpy(this->name, ci->filename.c_str(), lastof(this->name)); this->name = ci->filename;
this->cur_id = ci->id; this->cur_id = ci->id;
this->downloaded_files++; this->downloaded_files++;
} }

View File

@ -22,8 +22,8 @@ protected:
uint total_files; ///< Number of files to download uint total_files; ///< Number of files to download
uint downloaded_files; ///< Number of files downloaded uint downloaded_files; ///< Number of files downloaded
uint32 cur_id; ///< The current ID of the downloaded file uint32 cur_id; ///< The current ID of the downloaded file
char name[48]; ///< The current name of the downloaded file std::string name; ///< The current name of the downloaded file
public: public:
/** /**