From 8ea880a2aa643566cfec25256ce45bca10207a5f Mon Sep 17 00:00:00 2001 From: lakwsh Date: Thu, 19 Jan 2023 22:17:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=86=99=E5=85=A5=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- maptool.cpp | 21 ++++++++++++++------- maptool.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3485adc..ec470c3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # maptool -shell: `l4d2/srcds_run -game left4dead2 -condebug -nowatchdog` +shell: `l4d2/srcds_run -game left4dead2` console: `plugin_load addons/maptool` -file: `l4d2/left4dead2/console.log` +file: `l4d2/left4dead2/addons/maplist.txt` diff --git a/maptool.cpp b/maptool.cpp index 0ff82cd..476c968 100644 --- a/maptool.cpp +++ b/maptool.cpp @@ -1,8 +1,11 @@ #include "maptool.h" +#include #ifdef WIN32 const char *mat_dll = "left4dead2\\bin\\matchmaking_ds.dll"; +const char *path = "left4dead2\\addons\\maplist.txt"; #else const char *mat_dll = "left4dead2/bin/matchmaking_ds_srv.so"; +const char *path = "left4dead2/addons/maplist.txt"; #endif maptool g_maptool; @@ -18,29 +21,33 @@ bool maptool::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameSer KeyValues *mis = ((KeyValues *(*)(void *))match[0][0])(match); if(mis){ Msg("[maptool] Dumping all missions...\n"); + std::ofstream fs; + fs.open(path, std::ios::out|std::ios::trunc); KeyValues *map = mis->GetFirstSubKey(); while(map){ KeyValues *modes = map->FindKey("modes"); if(modes && !map->GetInt("BuiltIn")){ - Msg("<%s> %s\n", map->GetName(), map->GetString("DisplayTitle")); + fs<<"<"<GetName()<<"> "<GetString("DisplayTitle")<GetUint64("workshopid"); - if(id) Msg("url: https://steamcommunity.com/workshop/filedetails/?id=%llu\n", id); - else Msg("url: %s\n", map->GetString("Website")); + if(id) fs<<"url: https://steamcommunity.com/workshop/filedetails/?id="<GetString("Website")<FindKey(mlist[i]); if(!mode) continue; - Msg("[%s]\n", mode->GetName()); + fs<<"["<GetName()<<"]"<GetFirstSubKey(); for(int j = 1; chap && !chap->IsEmpty("Map"); j++){ - Msg("%2d: %s\n", j, chap->GetString("Map")); - Msg("name: %s\n", chap->GetString("DisplayName")); + fs.width(2); + fs<GetString("Map")<GetString("DisplayName")<GetNextKey(); } } - Msg("\n"); + fs<GetNextKey(); } + fs.close(); Msg("[maptool] done.\n"); } } diff --git a/maptool.h b/maptool.h index 08fae92..51c7323 100644 --- a/maptool.h +++ b/maptool.h @@ -6,7 +6,7 @@ class maptool:public IServerPluginCallbacks{ virtual void Unload(){ } virtual void Pause(){ } virtual void UnPause(){ } - virtual const char *GetPluginDescription(){ return "maptool v1.0.1, https://github.com/lakwsh/maptool"; } + virtual const char *GetPluginDescription(){ return "maptool v1.0.2, https://github.com/lakwsh/maptool"; } virtual void LevelInit(char const *pMapName){ } virtual void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax){ } virtual void GameFrame(bool simulating){ }