mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
Codechange: replace buffer+strecpy with std::string
This commit is contained in:
parent
3f18a8863a
commit
0ea3e338ab
@ -699,19 +699,19 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
|
|||||||
check_not_null(p);
|
check_not_null(p);
|
||||||
p++; // Start after the '/'
|
p++; // Start after the '/'
|
||||||
|
|
||||||
char tmp[MAX_PATH];
|
std::string filename = p;
|
||||||
if (strecpy(tmp, p, lastof(tmp)) == lastof(tmp)) {
|
/* Remove the extension from the string. */
|
||||||
|
for (uint i = 0; i < 2; i++) {
|
||||||
|
auto pos = filename.find_last_of('.');
|
||||||
|
if (pos == std::string::npos) {
|
||||||
this->OnFailure();
|
this->OnFailure();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Remove the extension from the string. */
|
filename.erase(pos);
|
||||||
for (uint i = 0; i < 2; i++) {
|
|
||||||
p = strrchr(tmp, '.');
|
|
||||||
check_and_terminate(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the string, without extension, to the filename. */
|
/* Copy the string, without extension, to the filename. */
|
||||||
this->curInfo->filename = tmp;
|
this->curInfo->filename = std::move(filename);
|
||||||
|
|
||||||
/* Request the next file. */
|
/* Request the next file. */
|
||||||
if (!this->BeforeDownload()) {
|
if (!this->BeforeDownload()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user