Skip to content

Commit

Permalink
Revert "New MapManager (test)"
Browse files Browse the repository at this point in the history
This reverts commit 0868599.
  • Loading branch information
byjumpe committed Dec 8, 2023
1 parent 0868599 commit a877bd0
Showing 1 changed file with 2 additions and 74 deletions.
76 changes: 2 additions & 74 deletions cstrike/addons/amxmodx/scripting/regg_mapmanager.sma
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
#include <amxmodx>
#include <amxmisc>
#include <regg>

new VoteType, gMapNums;
new Array:gMapName;
new VoteType;

public plugin_init() {
register_plugin("[ReGG] Map Manager", REGG_VERSION_STR, "Jumper & d3m37r4");

bind_pcvar_num(create_cvar(
"regg_mapchange_type", "1",
.has_min = true,
.min_val = 0.0
.min_val = 1.0
), VoteType);

gMapName = ArrayCreate(MAX_NAME_LENGTH);

loadMapCfg();
}

public ReGG_FinishPost(const killer, const victim) {
Expand All @@ -25,13 +19,6 @@ public ReGG_FinishPost(const killer, const victim) {

public MapChange() {
switch(VoteType){
case 0: {
new mapname[MAX_NAME_LENGTH];
ArrayGetString(gMapName, random(gMapNums), mapname, charsmax(mapname));
message_begin(MSG_ALL, SVC_INTERMISSION);
message_end();
engine_changelevel(mapname);
}
case 1: {
server_cmd("mapm_start_vote");
}
Expand All @@ -43,62 +30,3 @@ public MapChange() {
}
}
}

loadMapCfg() {
new maps_file[PLATFORM_MAX_PATH];
get_configsdir(maps_file, charsmax(maps_file));
format(maps_file, charsmax(maps_file), "%s/maps.ini", maps_file);

if(!file_exists(maps_file)) {
get_cvar_string("mapcyclefile", maps_file, charsmax(maps_file));
}

if(!file_exists(maps_file)) {
format(maps_file, charsmax(maps_file), "mapcycle.txt")
}

loadMapsFile(maps_file);
}

loadMapsFile(file[]) {
new iFile = fopen(file, "rt");
if(!iFile) {
set_fail_state("File ^"%s^" is not found", file);
}

new szBuffer[PLATFORM_MAX_PATH], szMaps[MAX_NAME_LENGTH];
while(!feof(iFile)) {
fgets(iFile, szBuffer, charsmax(szBuffer));
parse(szBuffer, szMaps, charsmax(szMaps));

if(!szBuffer[0] || szBuffer[0] == ';' || !isValidMap(szMaps)) {
continue;
}

ArrayPushString(gMapName, szMaps);
gMapNums++;
}

fclose(iFile);
}

stock bool:isValidMap(mapname[]) {
if (is_map_valid(mapname)){
return true;
}

new len = strlen(mapname) - 4;
if (len < 0) {
return false;
}

if (equali(mapname[len], ".bsp")){
mapname[len] = '^0';

if (is_map_valid(mapname)) {
return true;
}
}

return false;
}

0 comments on commit a877bd0

Please sign in to comment.