Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e6404cf
Add new ResolveFuzzyMapName native, modifying internal ResolveFuzzyMa…
powerlord Jun 15, 2015
2a73371
Fix a typo and a bad description for the native
powerlord Jun 15, 2015
e018b46
Make it return true if the maps are the same.
powerlord Jun 16, 2015
04c02a0
TF2 doesn't support engine->IsMapValid any more... it's failing for c…
powerlord Jun 16, 2015
1a31d62
Add a way to use resolved maps to MapChooser. More plugins to go, as …
powerlord Jun 16, 2015
b947e48
Changes to a bunch of plugins. Still working on it and need to do a …
powerlord Jun 17, 2015
7c93e07
ResolveFuzzyMapName is now exposed as part of IGameHelpers and Bumped…
powerlord Jun 17, 2015
98458b9
Merge branch 'fuzzymapnative' into fuzzymap-plugins
powerlord Jun 17, 2015
3e751bf
Move the stocks from mapchooser.inc to sourcemod.inc (where ReadMapLi…
powerlord Jun 17, 2015
9e86fbf
Nominations now does the map resolving up front instead of one by one.
powerlord Jun 17, 2015
4985201
GetFriendlyMapName now works for CS:GO.
powerlord Jun 18, 2015
eaebdaf
Fixed Mapchooser's "Nextmap Voting Finished" to use the map's info, w…
powerlord Jun 19, 2015
a1a3cec
Update basetriggers to support friendly map names. Maps are assumed …
powerlord Jun 19, 2015
20db8a1
The next map may not be in resolved format, so lets resolve it when a…
powerlord Jun 19, 2015
159da4b
Change basetriggers back to not forcing resolve before GetFriendlyMap…
powerlord Jun 19, 2015
22f805b
Fix issues with basetriggers chat commands using a different method.
powerlord Jun 19, 2015
25266c6
basevotes now displays the friendlyname
powerlord Jun 19, 2015
6d5ab9d
Last change to basevotes won't work for single-item votes, implemente…
powerlord Jun 19, 2015
7693253
Removed ProduceResolvedMapList. Instead, resolve them manually as ne…
powerlord Jun 20, 2015
14da725
Missed nextmap in the ProduceResolvedMapList purge
powerlord Jun 20, 2015
fdf0bde
Missed converting a ClearArray in MapChooser when doing the New API c…
powerlord Jun 24, 2015
d275a0c
Merge branch 'master' of https://github.com/alliedmodders/sourcemod i…
powerlord Jun 27, 2015
5b0be64
Rewrite to use FindMap instead of ResolveFuzzyMapName. Still needs a…
powerlord Jun 27, 2015
21de7f3
Merge remote-tracking branch 'remotes/origin/expose-findmap' into fuz…
powerlord Jun 27, 2015
459c830
Merge branch 'expose-findmap' of https://github.com/alliedmodders/sou…
powerlord Jun 28, 2015
3cfb3a5
Merge branch 'expose-findmap' of https://github.com/alliedmodders/sou…
powerlord Jun 28, 2015
ccb5d68
Add a comment describing CS:GO workshop format, fix some cosmetic iss…
powerlord Jul 2, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions plugins/basecommands/map.sp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ public MenuHandler_ChangeMap(Menu menu, MenuAction action, int param1, int param
}
else if (action == MenuAction_Select)
{
decl String:map[64];
decl String:map[PLATFORM_MAX_PATH];
decl String:friendly_name[PLATFORM_MAX_PATH];

menu.GetItem(param2, map, sizeof(map));
menu.GetItem(param2, map, sizeof(map), _, friendly_name, sizeof(friendly_name));

ShowActivity2(param1, "[SM] ", "%t", "Changing map", map);
ShowActivity2(param1, "[SM] ", "%t", "Changing map", friendly_name);

LogAction(param1, -1, "\"%L\" changed map to \"%s\"", param1, map);

Expand Down Expand Up @@ -87,7 +88,7 @@ public Action:Command_Map(client, args)
return Plugin_Handled;
}

decl String:map[64];
decl String:map[PLATFORM_MAX_PATH];
GetCmdArg(1, map, sizeof(map));

if (!IsMapValid(map))
Expand All @@ -109,7 +110,7 @@ public Action:Command_Map(client, args)

public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
{
decl String:map[65];
decl String:map[PLATFORM_MAX_PATH];

ResetPack(dp);
ReadPackString(dp, map, sizeof(map));
Expand Down Expand Up @@ -142,13 +143,16 @@ int LoadMapList(Menu menu)

RemoveAllMenuItems(menu);

char map_name[64];
char map_name[PLATFORM_MAX_PATH];
char friendly_name[PLATFORM_MAX_PATH];

int map_count = GetArraySize(g_map_array);

for (int i = 0; i < map_count; i++)
{
GetArrayString(g_map_array, i, map_name, sizeof(map_name));
menu.AddItem(map_name, map_name);
GetFriendlyMapName(map_name, friendly_name, sizeof(friendly_name), false);
menu.AddItem(map_name, friendly_name);
}

return map_count;
Expand Down
12 changes: 8 additions & 4 deletions plugins/basetriggers.sp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ public Action:Command_Nextmap(client, args)
}
else
{
ReplyToCommand(client, "[SM] %t", "Next Map", map);
decl String:friendlyName[PLATFORM_MAX_PATH];
GetFriendlyMapName(map, friendlyName, sizeof(friendlyName), false);
ReplyToCommand(client, "[SM] %t", "Next Map", friendlyName);
}

return Plugin_Handled;
Expand Down Expand Up @@ -290,8 +292,10 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
else if (strcmp(sArgs, "nextmap", false) == 0)
{
char map[PLATFORM_MAX_PATH];
char friendlyName[PLATFORM_MAX_PATH];
GetNextMap(map, sizeof(map));

GetFriendlyMapName(map, friendlyName, sizeof(friendlyName), false);

if (g_Cvar_TriggerShow.IntValue)
{
if (mapchooser && EndOfMapVoteEnabled() && !HasEndOfMapVoteFinished())
Expand All @@ -300,7 +304,7 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
}
else
{
PrintToChatAll("[SM] %t", "Next Map", map);
PrintToChatAll("[SM] %t", "Next Map", friendlyName);
}
}
else
Expand All @@ -311,7 +315,7 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
}
else
{
PrintToChat(client, "[SM] %t", "Next Map", map);
PrintToChat(client, "[SM] %t", "Next Map", friendlyName);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions plugins/basevotes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public OnPluginStart()
OnAdminMenuReady(topmenu);
}

g_SelectedMaps = CreateArray(33);
g_SelectedMaps = CreateArray(ByteCountToCells(PLATFORM_MAX_PATH));

g_MapList = CreateMenu(MenuHandler_Map, MenuAction_DrawItem|MenuAction_Display);
g_MapList.SetTitle("%T", "Please select a map", LANG_SERVER);
Expand Down Expand Up @@ -311,8 +311,11 @@ public Handler_VoteCallback(Menu menu, MenuAction action, param1, param2)

case (voteType:map):
{
// single-vote items don't use the display item
char friendlyName[PLATFORM_MAX_PATH];
GetFriendlyMapName(item, friendlyName, sizeof(friendlyName), false);
LogAction(-1, -1, "Changing map to %s due to vote.", item);
PrintToChatAll("[SM] %t", "Changing map", item);
PrintToChatAll("[SM] %t", "Changing map", friendlyName);
new Handle:dp;
CreateDataTimer(5.0, Timer_ChangeMap, dp);
WritePackString(dp, item);
Expand Down
12 changes: 9 additions & 3 deletions plugins/basevotes/votemap.sp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ DisplayVoteMapMenu(client, mapCount, String:maps[5][])

if (mapCount == 1)
{
strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
decl String:friendlyName[PLATFORM_MAX_PATH];
GetFriendlyMapName(maps[0], friendlyName, sizeof(friendlyName), false);
strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), friendlyName);

g_hVoteMenu.SetTitle("Change Map To");
g_hVoteMenu.AddItem(maps[0], "Yes");
Expand All @@ -61,7 +63,9 @@ DisplayVoteMapMenu(client, mapCount, String:maps[5][])
g_hVoteMenu.SetTitle("Map Vote");
for (new i = 0; i < mapCount; i++)
{
g_hVoteMenu.AddItem(maps[i], maps[i]);
decl String:friendlyName[PLATFORM_MAX_PATH];
GetFriendlyMapName(maps[i], friendlyName, sizeof(friendlyName), false);
g_hVoteMenu.AddItem(maps[i], friendlyName);
}
}

Expand Down Expand Up @@ -288,8 +292,10 @@ int LoadMapList(Menu menu)

for (new i = 0; i < map_count; i++)
{
decl String:friendly_name[PLATFORM_MAX_PATH];
GetArrayString(g_map_array, i, map_name, sizeof(map_name));
menu.AddItem(map_name, map_name);
GetFriendlyMapName(map_name, friendly_name, sizeof(friendly_name), false);
menu.AddItem(map_name, friendly_name);
}

return map_count;
Expand Down
56 changes: 56 additions & 0 deletions plugins/include/sourcemod.inc
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,62 @@ native Handle:ReadMapList(Handle:array=INVALID_HANDLE,
*/
native SetMapListCompatBind(const String:name[], const String:file[]);

/**
* Get a "friendly" name for a Workshop map.
*
* Note: non-Workshop maps will be ignored.
*
* @param resolvedMap A map name returned from FindMap (or not, see bIsMapResolved)
* @param friendlyName The map name with the extra workshop path bits removed
* @param maxlength The max length of friendlyName
* (We recommend PLATFORM_MAX_PATH)
* @param bIsMapResolved True if map is a resolved Fuzzy Name, false if we need to resolve it first.
* Convenience field for plugins that don't need the resolved map name.
*/
stock void GetFriendlyMapName(const char[] resolvedMap, char[] friendlyName, int maxlength, bool bIsMapResolved=true)
{
char szTmp[PLATFORM_MAX_PATH];
strcopy(szTmp, sizeof(szTmp), resolvedMap);

if (!bIsMapResolved)
{
FindMap(szTmp, sizeof(szTmp));
}

EngineVersion version = GetEngineVersion();
switch (version)
{
case Engine_TF2:
{
int ugcPos;

// In TF2, workshop maps show up as workshop/mapname.ugc123456789
if (strncmp(szTmp, "workshop/", 9) == 0 && (ugcPos = StrContains(szTmp, ".ugc")) > -1)
{
// technically, this is (ugcPos + 1) - 9, but lets just cancel the 1.
strcopy(friendlyName, maxlength < ugcPos - 8 ? maxlength : ugcPos - 8, szTmp[9]);
return;
}
}

case Engine_CSGO:
{
int lastSlashPos;

// In CSGO, workshop maps show up as workshop/123456789/mapname
if (strncmp(szTmp, "workshop/", 9) == 0 && (lastSlashPos = FindCharInString(szTmp, '/', true)) > 9)
{
int newlength = strlen(szTmp) - lastSlashPos;
strcopy(friendlyName, maxlength < newlength ? maxlength : newlength, szTmp[lastSlashPos+1]);
return;
}
}
}

// Fallback to just copying the name back to itself
strcopy(friendlyName, maxlength, szTmp);
}

/**
* Called when a client has sent chat text. This must return either true or
* false to indicate that a client is or is not spamming the server.
Expand Down
38 changes: 28 additions & 10 deletions plugins/mapchooser.sp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ ConVar g_Cvar_RunOffPercent;
Handle g_VoteTimer = null;
Handle g_RetryTimer = null;

// g_MapList stores unresolved names so we can resolve them after every map change in the workshop updates.
// g_OldMapList and g_NextMapList are resolved. g_NominateList depends on the nominations implementation.
/* Data Handles */
ArrayList g_MapList;
ArrayList g_NominateList;
Expand Down Expand Up @@ -321,7 +323,7 @@ void SetupTimeleftTimer()
int startTime = g_Cvar_StartTime.IntValue * 60;
if (time - startTime < 0 && g_Cvar_EndOfMapVote.BoolValue && !g_MapVoteCompleted && !g_HasVoteStarted)
{
InitiateVote(MapChange_MapEnd, null);
InitiateVote(MapChange_MapEnd, null);
}
else
{
Expand Down Expand Up @@ -585,11 +587,14 @@ void InitiateVote(MapChange when, ArrayList inputlist=null)
/* Smaller of the two - It should be impossible for nominations to exceed the size though (cvar changed mid-map?) */
int nominationsToAdd = nominateCount >= voteSize ? voteSize : nominateCount;


char friendlyName[PLATFORM_MAX_PATH];
for (int i=0; i<nominationsToAdd; i++)
{

g_NominateList.GetString(i, map, sizeof(map));
g_VoteMenu.AddItem(map, map);
GetFriendlyMapName(map, friendlyName, sizeof(friendlyName), false);

g_VoteMenu.AddItem(map, friendlyName);
RemoveStringFromArray(g_NextMapList, map);

/* Notify Nominations that this map is now free */
Expand Down Expand Up @@ -630,7 +635,8 @@ void InitiateVote(MapChange when, ArrayList inputlist=null)
count++;

/* Insert the map and increment our count */
g_VoteMenu.AddItem(map, map);
GetFriendlyMapName(map, friendlyName, sizeof(friendlyName));
g_VoteMenu.AddItem(map, friendlyName);
i++;
}

Expand All @@ -648,7 +654,9 @@ void InitiateVote(MapChange when, ArrayList inputlist=null)

if (IsMapValid(map))
{
g_VoteMenu.AddItem(map, map);
char friendlyName[PLATFORM_MAX_PATH];
GetFriendlyMapName(map, friendlyName, sizeof(friendlyName));
g_VoteMenu.AddItem(map, friendlyName);
}
}
}
Expand Down Expand Up @@ -689,7 +697,8 @@ public void Handler_VoteFinishedGeneric(Menu menu,
const int[][] item_info)
{
char map[PLATFORM_MAX_PATH];
menu.GetItem(item_info[0][VOTEINFO_ITEM_INDEX], map, sizeof(map));
char friendlyName[PLATFORM_MAX_PATH];
menu.GetItem(item_info[0][VOTEINFO_ITEM_INDEX], map, sizeof(map), _, friendlyName, sizeof(friendlyName));

if (strcmp(map, VOTE_EXTEND, false) == 0)
{
Expand Down Expand Up @@ -771,7 +780,7 @@ public void Handler_VoteFinishedGeneric(Menu menu,
g_HasVoteStarted = false;
g_MapVoteCompleted = true;

PrintToChatAll("[SM] %t", "Nextmap Voting Finished", map, RoundToFloor(float(item_info[0][VOTEINFO_ITEM_VOTES])/float(num_votes)*100), num_votes);
PrintToChatAll("[SM] %t", "Nextmap Voting Finished", friendlyName, RoundToFloor(float(item_info[0][VOTEINFO_ITEM_VOTES])/float(num_votes)*100), num_votes);
LogAction(-1, -1, "Voting for next map has finished. Nextmap: %s.", map);
}
}
Expand Down Expand Up @@ -940,10 +949,19 @@ bool RemoveStringFromArray(ArrayList array, char[] str)

void CreateNextVote()
{
ClearArray(g_NextMapList);
g_NextMapList.Clear();

char map[PLATFORM_MAX_PATH];
ArrayList tempMaps = g_MapList.Clone();
ArrayList tempMaps = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH));

for (int i = 0; i < g_MapList.Length; i++)
{
g_MapList.GetString(i, map, sizeof(map));
if (FindMap(map, sizeof(map)) != FindMap_NotFound)
{
tempMaps.PushString(map);
}
}

GetCurrentMap(map, sizeof(map));
RemoveStringFromArray(tempMaps, map);
Expand All @@ -954,7 +972,7 @@ void CreateNextVote()
{
g_OldMapList.GetString(i, map, sizeof(map));
RemoveStringFromArray(tempMaps, map);
}
}
}

int limit = (g_Cvar_IncludeMaps.IntValue < tempMaps.Length ? g_Cvar_IncludeMaps.IntValue : tempMaps.Length);
Expand Down
5 changes: 4 additions & 1 deletion plugins/nextmap.sp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void FindAndSetNextMap()

int mapCount = g_MapList.Length;
char mapName[PLATFORM_MAX_PATH];
char resolvedMap[PLATFORM_MAX_PATH];

if (g_MapPos == -1)
{
Expand All @@ -153,7 +154,9 @@ void FindAndSetNextMap()
for (int i = 0; i < mapCount; i++)
{
g_MapList.GetString(i, mapName, sizeof(mapName));
if (strcmp(current, mapName, false) == 0)
strcopy(resolvedMap, sizeof(resolvedMap), mapName);
if (FindMap(resolvedMap, sizeof(resolvedMap)) != FindMap_NotFound &&
strcmp(current, resolvedMap, false) == 0)
{
g_MapPos = i;
break;
Expand Down
Loading