Browse Source

Initial plugin commit.

nosoop 7 years ago
parent
commit
2c66d42fbd
2 changed files with 59 additions and 2 deletions
  1. 23 2
      README.md
  2. 36 0
      scripting/csrd_mounted_directory_fix.sp

+ 23 - 2
README.md

@@ -1,3 +1,24 @@
-# CSRD-MountedDirectoryFix
+# Mounted Directory Download Fix
 
-Fixes maps in custom search paths not being added to the download table.
+Fixes maps in custom search paths not being downloadable.
+
+As posted in the [CSRD update for 25 September 2016][csrd-20160925], there is a bug with the
+download list generation that prevents custom maps in manually-defined search paths from being
+added to the download table; clients were not able to download the map from the server if they
+were missing it.
+
+This plugin's only purpose is to work around that issue.
+
+[csrd-20160925]: http://csrd.science/blag/2016/csrd-update-25-september-2016.html
+
+
+## A "CSRD Internal" Plugin
+
+This is a plugin mainly intended for use in [Pikachu's Canadian Server of Romance and
+Drama][csrd].
+
+While I'm happy if you find some useful code for your own plugins, I can't provide any support
+for said code, nor will I offer any guarantees that the plugin will remain usable outside of its
+main use.
+
+[csrd]: https://csrd.science/

+ 36 - 0
scripting/csrd_mounted_directory_fix.sp

@@ -0,0 +1,36 @@
+/**
+ * [CSRD] Mounted Directory Map Fix
+ * 
+ * Fixes maps in custom search paths not being added to the download table.
+ */
+#pragma semicolon 1
+#include <sourcemod>
+
+#include <sdktools>
+
+#pragma newdecls required
+
+#define PLUGIN_VERSION "1.0.0"
+public Plugin myinfo = {
+	name = "[CSRD] Mounted Directory Map Fix",
+	author = "nosoop",
+	description = "Fixes maps not being added to the download table.",
+	version = PLUGIN_VERSION,
+	url = "https://git.csrd.science/"
+}
+
+public void OnMapStart() {
+	char mapName[PLATFORM_MAX_PATH], mapPath[PLATFORM_MAX_PATH];
+	GetCurrentMap(mapName, sizeof(mapName));
+	
+	Format(mapPath, sizeof(mapPath), "maps/%s.bsp", mapName);
+	
+	if (!FileExists(mapPath) && StrContains(mapName, "workshop/") == -1) {
+		FindMapResult findResult = FindMap(mapName, mapName, sizeof(mapName));
+		if (findResult != FindMap_NotFound && findResult != FindMap_PossiblyAvailable) {
+			Format(mapPath, sizeof(mapPath), "maps/%s.bsp", mapName, sizeof(mapName));
+			
+			AddFileToDownloadsTable(mapPath);
+		}
+	}
+}