Skip to content

Commit 01847e0

Browse files
committed
Merge remote-tracking branch 'upstream/master' into next
2 parents 8679e22 + 0ac6c27 commit 01847e0

File tree

2 files changed

+55
-26
lines changed

2 files changed

+55
-26
lines changed

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Multi Theft Auto: San Andreas
22

3-
[![Build Status](https://github.com/multitheftauto/mtasa-blue/workflows/Build/badge.svg?event=push&branch=master)](https://github.com/multitheftauto/mtasa-blue/actions?query=branch%3Amaster+event%3Apush) [![Unique servers online](https://img.shields.io/endpoint?url=https%3A%2F%2Fmtasa.com%2Fapi%2Fservers-shields.io.json)](https://community.multitheftauto.com/index.php?p=servers) [![Unique players online](https://img.shields.io/endpoint?url=https%3A%2F%2Fmtasa.com%2Fapi%2Fplayers-shields.io.json)](https://multitheftauto.com) [![Unique players last 24 hours](https://img.shields.io/endpoint?url=https%3A%2F%2Fmtasa.com%2Fapi%2Funique-players-shields.io.json)](https://multitheftauto.com) [![Discord](https://img.shields.io/discord/278474088903606273?label=discord&logo=discord)](https://discord.com/invite/mtasa) [![Crowdin](https://badges.crowdin.net/e/f5dba7b9aa6594139af737c85d81d3aa/localized.svg)](https://multitheftauto.crowdin.com/multitheftauto)
3+
[![Build Status](https://github.com/multitheftauto/mtasa-blue/workflows/Build/badge.svg?event=push&branch=master)](https://github.com/multitheftauto/mtasa-blue/actions?query=branch%3Amaster+event%3Apush) [![Unique servers online](https://img.shields.io/endpoint?url=https%3A%2F%2Fmultitheftauto.com%2Fapi%2Fservers-shields.io.json)](https://community.multitheftauto.com/index.php?p=servers) [![Unique players online](https://img.shields.io/endpoint?url=https%3A%2F%2Fmultitheftauto.com%2Fapi%2Fplayers-shields.io.json)](https://multitheftauto.com) [![Unique players last 24 hours](https://img.shields.io/endpoint?url=https%3A%2F%2Fmultitheftauto.com%2Fapi%2Funique-players-shields.io.json)](https://multitheftauto.com) [![Discord](https://img.shields.io/discord/278474088903606273?label=discord&logo=discord)](https://discord.com/invite/mtasa) [![Crowdin](https://badges.crowdin.net/e/f5dba7b9aa6594139af737c85d81d3aa/localized.svg)](https://multitheftauto.crowdin.com/multitheftauto)
44

55
[Multi Theft Auto](https://www.multitheftauto.com/) (MTA) is a software project that adds network play functionality to Rockstar North's Grand Theft Auto game series, in which this functionality is not originally found. It is a unique modification that incorporates an extendable network play element into a proprietary commercial single-player PC game.
66

@@ -27,13 +27,15 @@ Using a framework based on resources has a number of advantages. It allows conte
2727
Our project's code repository can be found on the [multitheftauto/mtasa-blue](https://github.com/multitheftauto/mtasa-blue/) Git repository at [GitHub](https://github.com/). We are always looking for new developers, so if you're interested, here are some useful links:
2828

2929
* [Coding guidelines](https://github.com/multitheftauto/mtasa-blue/blob/master/CONTRIBUTING.md#contributors-guide)
30-
* [Nightly Builds](https://nightly.mtasa.com/)
30+
* [Nightly Builds](https://nightly.multitheftauto.com/)
3131
* [Milestones](https://github.com/multitheftauto/mtasa-blue/milestones)
3232

3333
### IDE Setup
34-
If not using Visual Studio 2017, download and install the [EditorConfig](https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328) plugin to automatically set up your IDE for the correct formatting.
34+
35+
If not using Visual Studio 2017, download and install the [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig) plugin to automatically set up your IDE for the correct formatting.
3536

3637
### Build Instructions
38+
3739
#### Windows
3840

3941
Prerequisites
@@ -98,30 +100,31 @@ $ docker pull ghcr.io/multitheftauto/mtasa-blue-build:latest
98100
```
99101

100102
| Architecture | Docker image tag | Required build-time CLI-arguments |
101-
| ------------ | ---------------- | ------------------------------- |
102-
| x86 | latest | `-e BUILD_ARCHITECTURE=x86` |
103-
| x86_64 | latest | |
104-
| arm | armhf | |
105-
| arm64 | arm64 | |
106-
103+
| ------------ | ---------------- | --------------------------------- |
104+
| x86 | latest | `-e BUILD_ARCHITECTURE=x86` |
105+
| x86_64 | latest | |
106+
| arm | armhf | |
107+
| arm64 | arm64 | |
107108

108109
**Building with Docker**
109110

110111
These examples assume that your current directory is the mtasa-blue checkout directory. You should also know that `/build` is the code directory required by our Docker images inside the container. If the current directory is not a valid git repository, it instead create a (shallow) clone of the mtasa-blue repository. After compiling, you will find the resulting binaries in `./Bin`. To build the unoptimised debug build, add `-e BUILD_CONFIG=debug` to the docker run arguments.
111112

112-
| Architecture | Build command |
113-
| ------------ | -------------------------------------------------------------------------------------------- |
113+
| Architecture | Build command |
114+
| ------------ | ---------------------------------------------------------------------------------------------------------------- |
114115
| x86 | ``` docker run --rm -v `pwd`:/build -e BUILD_ARCHITECTURE=x86 ghcr.io/multitheftauto/mtasa-blue-build:latest ``` |
115116
| x86_64 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:latest ``` |
116117
| arm | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:armhf ``` |
117118
| arm64 | ``` docker run --rm -v `pwd`:/build ghcr.io/multitheftauto/mtasa-blue-build:arm64 ``` |
118119

119120
### Premake FAQ
121+
120122
#### How to add new C++ source files?
121-
Execute `win-create-projects.bat`.
123+
124+
Execute `win-create-projects.bat`
122125

123126
## License
124127

125-
Unless otherwise specified, all source code hosted on this repository is licensed under the GPLv3 license. See the LICENSE file for more details.
128+
Unless otherwise specified, all source code hosted on this repository is licensed under the GPLv3 license. See the [LICENSE](./LICENSE) file for more details.
126129

127130
Grand Theft Auto and all related trademarks are © Rockstar North 1997–2022.

Server/mods/deathmatch/logic/CResource.cpp

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,24 +2369,49 @@ ResponseCode CResource::HandleRequest(HttpRequest* ipoHttpRequest, HttpResponse*
23692369
return HTTPRESPONSECODE_200_OK;
23702370
}
23712371

2372-
void Unescape(std::string& str)
2372+
std::string Unescape(std::string_view sv)
23732373
{
2374-
const char* pPercent = strchr(str.c_str(), '%');
2374+
// Converts a character to a hexadecimal value
2375+
auto toHex = [](char c)
2376+
{
2377+
if (c >= '0' && c <= '9')
2378+
return c - '0';
2379+
if (c >= 'a' && c <= 'f')
2380+
return c - 'a' + 10;
2381+
if (c >= 'A' && c <= 'F')
2382+
return c - 'A' + 10;
2383+
return 0;
2384+
};
23752385

2376-
while (pPercent)
2386+
std::string out;
2387+
// String can only shrink here
2388+
// as %?? is collapsed to a single char
2389+
out.reserve(sv.length());
2390+
auto it = sv.begin();
2391+
while (it != sv.end())
23772392
{
2378-
if (pPercent[1] && pPercent[2])
2393+
if (*it == '%')
23792394
{
2380-
int iCharCode = 0;
2381-
sscanf(&pPercent[1], "%02X", &iCharCode);
2382-
str.replace(pPercent - str.c_str(), 3, (char*)&iCharCode);
2383-
pPercent = strchr(pPercent + 3, '%');
2395+
// Avoid reading past the end
2396+
if (std::distance(it, sv.end()) < 3)
2397+
{
2398+
out.push_back(*it++);
2399+
continue;
2400+
}
2401+
// Skip %
2402+
++it;
2403+
// Read two digits/letters and convert to char
2404+
uint8_t digit1 = toHex(*it++);
2405+
uint8_t digit2 = toHex(*it++);
2406+
out.push_back(static_cast<char>(digit1 * 0x10 + digit2));
23842407
}
23852408
else
23862409
{
2387-
break;
2410+
// Push normally
2411+
out.push_back(*it++);
23882412
}
23892413
}
2414+
return out;
23902415
}
23912416

23922417
ResponseCode CResource::HandleRequestCall(HttpRequest* ipoHttpRequest, HttpResponse* ipoHttpResponse, CAccount* pAccount)
@@ -2447,7 +2472,7 @@ ResponseCode CResource::HandleRequestCall(HttpRequest* ipoHttpRequest, HttpRespo
24472472
if (iKey >= 0 && iKey < MAX_INPUT_VARIABLES)
24482473
{
24492474
std::string strValue(pEqual + 1, pAnd - (pEqual + 1));
2450-
Unescape(strValue);
2475+
strValue = Unescape(strValue);
24512476

24522477
if (iKey + 1 > static_cast<int>(vecArguments.size()))
24532478
vecArguments.resize(iKey + 1);
@@ -2463,7 +2488,7 @@ ResponseCode CResource::HandleRequestCall(HttpRequest* ipoHttpRequest, HttpRespo
24632488
}
24642489
}
24652490

2466-
Unescape(strFuncName);
2491+
strFuncName = Unescape(strFuncName);
24672492

24682493
for (CExportedFunction& Exported : m_ExportedFunctions)
24692494
{
@@ -2673,6 +2698,7 @@ ResponseCode CResource::HandleRequestActive(HttpRequest* ipoHttpRequest, HttpRes
26732698
}
26742699

26752700
Unescape(strFile);
2701+
strFile = Unescape(strFile);
26762702

26772703
for (CResourceFile* pResourceFile : m_ResourceFiles)
26782704
{
@@ -2705,7 +2731,7 @@ ResponseCode CResource::HandleRequestActive(HttpRequest* ipoHttpRequest, HttpRes
27052731
}
27062732
else
27072733
{
2708-
SString err("Resource %s is not running.", m_strResourceName.c_str());
2734+
SString err = "That resource is not running.";
27092735
ipoHttpResponse->SetBody(err.c_str(), err.size());
27102736
return HTTPRESPONSECODE_401_UNAUTHORIZED;
27112737
}
@@ -2751,7 +2777,7 @@ ResponseCode CResource::HandleRequestActive(HttpRequest* ipoHttpRequest, HttpRes
27512777
}
27522778
}
27532779

2754-
SString err("Cannot find a resource file named '%s' in the resource %s.", strFile.c_str(), m_strResourceName.c_str());
2780+
SString err = "That resource file could not be found in that resource.";
27552781
ipoHttpResponse->SetBody(err.c_str(), err.size());
27562782
return HTTPRESPONSECODE_404_NOTFOUND;
27572783
}

0 commit comments

Comments
 (0)