Skip to content

Commit 21efe80

Browse files
committed
blocklist: rework for case ignoring
fix for advlists
1 parent 3440be2 commit 21efe80

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

addons/amxmodx/scripting/map_manager_blocklist.sma

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <map_manager>
33

44
#define PLUGIN "Map Manager: BlockList"
5-
#define VERSION "0.0.1"
5+
#define VERSION "0.0.2"
66
#define AUTHOR "Mistrick"
77

88
#pragma semicolon 1
@@ -34,7 +34,10 @@ public plugin_natives()
3434
public native_get_blocked_count(plugin, params)
3535
{
3636
enum { arg_map = 1 };
37-
new map[MAPNAME_LENGTH]; get_string(arg_map, map, charsmax(map));
37+
38+
new map[MAPNAME_LENGTH];
39+
get_string(arg_map, map, charsmax(map));
40+
strtolower(map);
3841

3942
if(!TrieKeyExists(g_tBlockedList, map)) {
4043
return 0;
@@ -46,6 +49,12 @@ public native_get_blocked_count(plugin, params)
4649
}
4750
public mapm_maplist_loaded(Array:mapslist)
4851
{
52+
static bool:load_once;
53+
54+
if(load_once) {
55+
return;
56+
}
57+
4958
g_tBlockedList = TrieCreate();
5059
load_blocklist();
5160

@@ -66,6 +75,8 @@ public mapm_maplist_loaded(Array:mapslist)
6675
else if(valid_maps < votelist_size) {
6776
g_iMaxItems = valid_maps;
6877
}
78+
79+
load_once = true;
6980
}
7081
load_blocklist()
7182
{
@@ -85,7 +96,7 @@ load_blocklist()
8596
temp = fopen(temp_file_path, "wt");
8697

8798
new buffer[40], map[MAPNAME_LENGTH], str_count[6], count;
88-
// server_print("Blocked list:^n%s", cur_map);
99+
89100
while(!feof(f)) {
90101
fgets(f, buffer, charsmax(buffer));
91102
parse(buffer, map, charsmax(map), str_count, charsmax(str_count));
@@ -98,8 +109,8 @@ load_blocklist()
98109
if(count <= 0) continue;
99110

100111
fprintf(temp, "^"%s^" ^"%d^"^n", map, count);
112+
strtolower(map);
101113
TrieSetCell(g_tBlockedList, map, count);
102-
// server_print("%s", map);
103114
}
104115

105116
fprintf(temp, "^"%s^" ^"%d^"^n", cur_map, block_value);
@@ -127,7 +138,10 @@ public mapm_prepare_votelist(type)
127138
mapm_set_votelist_max_items(g_iMaxItems);
128139
}
129140
}
130-
public mapm_can_be_in_votelist(map[])
141+
public mapm_can_be_in_votelist(const map[])
131142
{
132-
return TrieKeyExists(g_tBlockedList, map) ? MAP_BLOCKED : MAP_ALLOWED;
143+
new lower[MAPNAME_LENGTH];
144+
copy(lower, charsmax(lower), map);
145+
strtolower(lower);
146+
return TrieKeyExists(g_tBlockedList, lower) ? MAP_BLOCKED : MAP_ALLOWED;
133147
}

0 commit comments

Comments
 (0)