Skip to content

Commit

Permalink
Merge pull request #1019 from splewis/development
Browse files Browse the repository at this point in the history
0.14.4
  • Loading branch information
nickdnk authored Apr 15, 2023
2 parents 60e1919 + b7e989e commit 0696f59
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Whenever you update your Get5 plugin, remember to **always** update the `transla
Please see the [installation instructions](https://splewis.github.io/get5/latest/installation/#installation) for
details.

# 0.14.4

#### 2023-04-16

Minor bugfix.

1. Fix invalid parsing of workshop maps with IDs consisting of 64-bit integers.

# 0.14.3

#### 2023-04-10
Expand Down
15 changes: 11 additions & 4 deletions scripting/get5/maps.sp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@ static Action Timer_DelayedChangeMap(Handle timer, Handle pack) {
ResetPack(pack);
ReadPackString(pack, map, sizeof(map));
CloseHandle(pack);
if (IsMapWorkshop(map)) {
ServerCommand("host_workshop_map %d", GetMapIdFromString(map));
char workshopMap[PLATFORM_MAX_PATH];
if (IsMapWorkshop(map) && GetMapIdFromString(map, workshopMap, sizeof(workshopMap))) {
ServerCommand("host_workshop_map %s", workshopMap);
} else {
ServerCommand("changelevel %s", map);
}
return Plugin_Handled;
}

int GetMapIdFromString(const char[] map) {
bool GetMapIdFromString(const char[] map, char[] buffer, const int bufferSize) {
char buffers[4][PLATFORM_MAX_PATH];
ExplodeString(map, "/", buffers, sizeof(buffers), PLATFORM_MAX_PATH);
return StringToInt(buffers[1]);
int value[2];
StringToInt64(buffers[1], value);
if (value[0] > 0) {
strcopy(buffer, bufferSize, buffers[1]);
return true;
}
return false;
}
20 changes: 17 additions & 3 deletions scripting/get5/tests.sp
Original file line number Diff line number Diff line change
Expand Up @@ -892,17 +892,31 @@ static void Utils_Test() {
AssertStrEq("ConvertAuthToSteam64_4_value", output, expected);

char mapName[64] = "workshop/3374744/Old Aztec";
char mapWorkshopId[64];
char formattedMapName[64];
FormatMapName(mapName, formattedMapName, sizeof(formattedMapName));
AssertStrEq("Check workshop map name correctly formatted", "Old Aztec", formattedMapName);
AssertEq("Check workshop map ID extraction", GetMapIdFromString(mapName), 3374744);
AssertTrue("Check workshop map detected", IsMapWorkshop(mapName));
AssertTrue("Check workshop map ID extraction", GetMapIdFromString(mapName, mapWorkshopId, sizeof(mapWorkshopId)));
AssertStrEq("Check workshop map ID", mapWorkshopId, "3374744");

mapName = "workshop/837575"; // name missing
FormatMapName(mapName, formattedMapName, sizeof(formattedMapName));
AssertStrEq("Check workshop map name incorrectly formatted", "837575", formattedMapName);
AssertEq("Check workshop map ID extraction", GetMapIdFromString(mapName), 837575);
AssertStrEq("Check workshop map name without name", "837575", formattedMapName);
AssertTrue("Check workshop map ID extraction without name",
GetMapIdFromString(mapName, mapWorkshopId, sizeof(mapWorkshopId)));
AssertStrEq("Check workshop map ID without name", mapWorkshopId, "837575");

mapName = "workshop/33747383585844/Old Aztec";
FormatMapName(mapName, formattedMapName, sizeof(formattedMapName));
AssertStrEq("Check workshop map name correctly formatted 64 bit", "Old Aztec", formattedMapName);
AssertTrue("Check workshop map detected 64 bit", IsMapWorkshop(mapName));
AssertTrue("Check workshop map ID extraction 64 bit",
GetMapIdFromString(mapName, mapWorkshopId, sizeof(mapWorkshopId)));
AssertStrEq("Check workshop map ID 64 bit", mapWorkshopId, "33747383585844");

mapName = "de_dust2";
AssertFalse("Check regular map not detected as workshop", IsMapWorkshop(mapName));
FormatMapName(mapName, formattedMapName, sizeof(formattedMapName), true);
AssertStrEq("Check regular map name correctly formatted", "Dust II", formattedMapName);
FormatMapName(mapName, formattedMapName, sizeof(formattedMapName), true, true);
Expand Down
2 changes: 1 addition & 1 deletion scripting/get5/version.sp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define PLUGIN_VERSION "0.14.3-dev"
#define PLUGIN_VERSION "0.14.4-dev"
// This MUST be the latest version in x.y.z semver format followed by -dev.
// If this is not consistently applied, the update-checker might malfunction.
// In official releases, the CI flow will remove the -dev suffix when compiling the plugin.
Expand Down

0 comments on commit 0696f59

Please sign in to comment.