Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
改为写入文件
Browse files Browse the repository at this point in the history
  • Loading branch information
lakwsh committed Jan 19, 2023
1 parent e146cd4 commit 8ea880a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`
21 changes: 14 additions & 7 deletions maptool.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "maptool.h"
#include <fstream>
#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;
Expand All @@ -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<<"<"<<map->GetName()<<"> "<<map->GetString("DisplayTitle")<<std::endl;
uint64 id = map->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="<<id<<std::endl;
else fs<<"url: "<<map->GetString("Website")<<std::endl;
for(unsigned i = 0; i<sizeof(mlist)/sizeof(mlist[0]); i++){
KeyValues *mode = modes->FindKey(mlist[i]);
if(!mode) continue;
Msg("[%s]\n", mode->GetName());
fs<<"["<<mode->GetName()<<"]"<<std::endl;
KeyValues *chap = mode->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<<j<<": "<<chap->GetString("Map")<<std::endl;
fs<<"name: "<<chap->GetString("DisplayName")<<std::endl;
chap = chap->GetNextKey();
}
}
Msg("\n");
fs<<std::endl;
}
map = map->GetNextKey();
}
fs.close();
Msg("[maptool] done.\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion maptool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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){ }
Expand Down

0 comments on commit 8ea880a

Please sign in to comment.