From 5dde0fb4868ebb48b6ec58c702bf0a3a03a2ccd8 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Wed, 1 Apr 2020 12:27:45 +0200 Subject: [PATCH] Menu: Switch to the new manifest based mod/game info stuff --- cstrike/modinfo.txt | 8 ----- default.fmf | 18 +++++++++++ gearbox/modinfo.txt | 8 ----- hunger/modinfo.txt | 6 ---- poke646/modinfo.txt | 11 ------- scihunt/modinfo.txt | 7 ----- src/menu-fn/m_chatrooms.cpp | 18 +++++------ src/menu-fn/m_customgame.cpp | 59 +++++++++++++++++++++--------------- src/menu-fn/m_customize.cpp | 6 +++- src/menu-fn/modserver.cpp | 45 +++++++++++++++------------ src/menu-fn/w_modlist.cpp | 36 ++++++++++++++++------ tfc/modinfo.txt | 8 ----- valve/modinfo.txt | 5 --- 13 files changed, 118 insertions(+), 117 deletions(-) delete mode 100644 cstrike/modinfo.txt delete mode 100755 gearbox/modinfo.txt delete mode 100644 hunger/modinfo.txt delete mode 100644 poke646/modinfo.txt delete mode 100644 scihunt/modinfo.txt delete mode 100644 tfc/modinfo.txt delete mode 100644 valve/modinfo.txt diff --git a/cstrike/modinfo.txt b/cstrike/modinfo.txt deleted file mode 100644 index 4247c688..00000000 --- a/cstrike/modinfo.txt +++ /dev/null @@ -1,8 +0,0 @@ -game "Counter-Strike" -nohimodel "1" -nomodels "1" -size "184000000" -trainmap "tr_1" -type "multiplayer_only" -url_info "www.counter-strike.net" -version "1.5" diff --git a/default.fmf b/default.fmf index 98b5de87..ceffb8d3 100755 --- a/default.fmf +++ b/default.fmf @@ -6,3 +6,21 @@ basegame logos basegame valve disablehomedir 1 rtcbroker master.frag-net.com:27950 + +// hastily converted +-seta gameinfo_game "Nuclide" +-seta gameinfo_gamedir "valve" +-seta gameinfo_fallback_dir "" +-seta gameinfo_mpentity "info_player_deathmatch" +-seta gameinfo_size "496200000" +-seta gameinfo_url_info "www.icculus.org/~marco/" +-seta gameinfo_version "1.0" +-seta gameinfo_url_dl "" +-seta gameinfo_type "" +-seta gameinfo_nomodels 0 +-seta gameinfo_gamedll "progs.dat" +-seta gameinfo_startmap "c0a0" +-seta gameinfo_trainingmap "t0a0" +-seta gameinfo_cldll 1 +-seta gameinfo_hlversion "1110" +-seta gameinfo_svonly "0" diff --git a/gearbox/modinfo.txt b/gearbox/modinfo.txt deleted file mode 100755 index df19ed5b..00000000 --- a/gearbox/modinfo.txt +++ /dev/null @@ -1,8 +0,0 @@ -gamedir "gearbox" -game "Opposing Force" -size "96000000" -startmap "of0a0" -trainmap "ofboot0" -type "Single" -url_info "www.gearboxsoftware.com" -version "1" diff --git a/hunger/modinfo.txt b/hunger/modinfo.txt deleted file mode 100644 index 278291d5..00000000 --- a/hunger/modinfo.txt +++ /dev/null @@ -1,6 +0,0 @@ -game "They Hunger" -url_info "www.planethalflife.com/manke" -version "3.0" -size "142600000" -startmap "thintro" -trainmap "they30" diff --git a/poke646/modinfo.txt b/poke646/modinfo.txt deleted file mode 100644 index 86af5442..00000000 --- a/poke646/modinfo.txt +++ /dev/null @@ -1,11 +0,0 @@ -game "Poke646" -url_info "www.poke646.com" -url_dl "" -version "1.0" -startmap "po_intro" -trainmap "po_haz01" -type "singleplayer_only" -svonly "0" -cldll "1" -nomodels "0" -size "123055258" diff --git a/scihunt/modinfo.txt b/scihunt/modinfo.txt deleted file mode 100644 index 52b49161..00000000 --- a/scihunt/modinfo.txt +++ /dev/null @@ -1,7 +0,0 @@ -game "Scientist Hunt" -mpentity "info_player_deathmatch" -size "800000" -startmap "c1a0" -type "multiplayer_only" -url_info "www.richwhitehouse.com" -version "1.0" diff --git a/src/menu-fn/m_chatrooms.cpp b/src/menu-fn/m_chatrooms.cpp index 3237ab99..cd93aa77 100644 --- a/src/menu-fn/m_chatrooms.cpp +++ b/src/menu-fn/m_chatrooms.cpp @@ -58,7 +58,7 @@ void cr_btndone_start(void) static void cr_btndone_end(void) { g_menupage = PAGE_MULTIPLAYER; } - cr_closeconnection(); + //cr_closeconnection(); localsound("../media/launch_dnmenu1.wav"); header.SetStartEndPos(45,45,50,239); header.SetStartEndSize(460,80,156,26); @@ -85,7 +85,7 @@ void cr_btnlistrooms_start(void) /* 'Done' button */ void cr_btnservers_prepare(void) { - cr_closeconnection(); + //cr_closeconnection(); cr_btnservers_start(); } @@ -174,13 +174,6 @@ void menu_chatrooms_draw(void) int tab_id; string tmp; - /* establish the connection */ - if (!g_iIRCActive) { - cr_makeconnection(); - g_iIRCActive = TRUE; - g_irc.timer = 10.0f; - } - Widget_Draw(fn_chatrooms); drawpic([g_menuofs[0]+550,g_menuofs[1]+10], "gfx/shell/fragnet",[80,80], [1,1,1], 1.0f, 0); @@ -210,6 +203,13 @@ void menu_chatrooms_draw(void) } g_irc.cur_tab = g_irc.show_tab; + /* establish the connection if nothing is found */ + if (!g_iIRCActive && !g_irc.show_tab) { + cr_makeconnection(); + g_iIRCActive = TRUE; + g_irc.timer = 10.0f; + } + /* draw the irc-log buffer when ready */ if (g_irc.show_tab) { drawsetcliparea(g_menuofs[0] + 33, g_menuofs[1] + 104, 450,331); diff --git a/src/menu-fn/m_customgame.cpp b/src/menu-fn/m_customgame.cpp index 6189e20a..59eb47e5 100644 --- a/src/menu-fn/m_customgame.cpp +++ b/src/menu-fn/m_customgame.cpp @@ -31,6 +31,11 @@ void games_init(void) gameinfo_count = 0; for (id = 0; (gamedirname = getgamedirinfo(id, 0)); id++) { + /* skip any manifest (or modinfo) without cvars setting things */ + if (getgamedirinfo(id, 2) == "") { + continue; + } + gameinfo_count++; } @@ -43,7 +48,13 @@ void games_init(void) games = memalloc(sizeof(gameinfo_t) * gameinfo_count); for (id = 0; (gamedirname = getgamedirinfo(id, 0)); id++) { - gamedescription = getgamedirinfo(id, 1); + gamedescription = getgamedirinfo(id, 2); + + /* CONT: skip any manifest (or modinfo) without cvars setting things */ + if (gamedescription == "") { + continue; + } + county = tokenize_console(gamedescription); /* Fill in the defaults */ @@ -64,55 +75,54 @@ void games_init(void) games[id].svonly = 0; games[id].installed = 1; - for ( int i = 0; i < county; i+=2 ) { + for ( int i = 0; i < county; i++ ) { switch( argv(i) ) { - case "game": + case "gameinfo_game": games[id].game = argv(i+1); break; - case "gamedir": + case "gameinfo_gamedir": games[id].gamedir = argv(i+1); break; - case "fallback_dir": + case "gameinfo_fallback_dir": games[id].fallback_dir = argv(i+1); break; - case "url_info": + case "gameinfo_url_info": games[id].url_info = argv(i+1); break; - case "url_dl": + case "gameinfo_url_dl": games[id].url_dl = argv(i+1); break; - case "version": + case "gameinfo_version": games[id].version = argv(i+1); break; - case "size": - games[id].size = stof(argv(i+1)); + case "gameinfo_size": + games[id].size = (int)stof(argv(i+1)); break; - case "svonly": - games[id].svonly = stof(argv(i+1)); + case "gameinfo_svonly": + games[id].svonly = (int)stof(argv(i+1)); break; - case "cldll": - games[id].cldll = stof(argv(i+1)); + case "gameinfo_cldll": + games[id].cldll = (int)stof(argv(i+1)); break; - case "type": + case "gameinfo_type": games[id].type = argv(i+1); break; - case "hlversion": + case "gameinfo_hlversion": games[id].hlversion = argv(i+1); break; - case "nomodels": - games[id].nomodels = stof(argv(i+1)); + case "gameinfo_nomodels": + games[id].nomodels = (int)stof(argv(i+1)); break; - case "mpentity": + case "gameinfo_mpentity": games[id].mpentity = argv(i+1); break; - case "gamedll": + case "gameinfo_gamedll": games[id].gamedll = argv(i+1); break; - case "startmap": + case "gameinfo_startmap": games[id].startmap = argv(i+1); break; - case "trainingmap": - case "trainmap": + case "gameinfo_trainingmap": games[id].trainingmap = argv(i+1); break; default: @@ -164,7 +174,8 @@ void customgame_btnactivate_start(void) void customgame_btninstall_start(void) { int gid = customgame_lbMods.GetSelected(); - localcmd(sprintf("fs_changegame %s\n", games[gid].url_dl)); + print(sprintf("Requesting download for http://www.frag-net.com/mods/%s.fmf...\n", games[gid].gamedir)); + localcmd(sprintf("fs_changegame http://www.frag-net.com/mods/%s.fmf\n", games[gid].game)); } void customgame_btndeactivate_start(void) { diff --git a/src/menu-fn/m_customize.cpp b/src/menu-fn/m_customize.cpp index fe4126ad..e8a3330e 100644 --- a/src/menu-fn/m_customize.cpp +++ b/src/menu-fn/m_customize.cpp @@ -119,7 +119,11 @@ void menu_customize_init(void) cz_psSpray.SetCallback(cz_cbSprayChanged); cz_psSpray.SetValueS(cvar_string("_cl_playerspray")); Widget_Add(fn_customize, cz_psSpray); - + + if (games[gameinfo_current].nomodels == 1) { + return; + } + cz_psModel = spawn(CPictureSwitch); cz_psModel.SetPos(410,160); cz_psModel.SetSize(170,221); diff --git a/src/menu-fn/modserver.cpp b/src/menu-fn/modserver.cpp index 1c24c91f..79f4bd7b 100644 --- a/src/menu-fn/modserver.cpp +++ b/src/menu-fn/modserver.cpp @@ -26,7 +26,13 @@ void* memrealloc(__variant *oldptr, int elementsize, int old_num, int new_num) { void *n = memalloc(elementsize * new_num); - memcpy(n, oldptr, elementsize * min(old_num, new_num)); + + if (!n) { + print("^1memrealloc^7: Out of memory\n"); + return 0; + } + + memcpy(n, oldptr, elementsize * old_num); memfree(oldptr); return n; } @@ -64,7 +70,7 @@ ModServer_ParseList(string data) } print(sprintf("^2ModServer_ParseList^7: Querying mod-data for %s\n", gamedir)); - uri_get(sprintf("http://www.frag-net.com/mods/%s.txt",gamedir), 101); + uri_get(sprintf("http://www.frag-net.com/mods/%s.fmf",uri_escape(gamedir)), MODSERVER_REQ_ITEM); finalcount++; } @@ -109,55 +115,54 @@ ModServer_ParseItem(string data) games[id].svonly = 0; games[id].installed = 0; - for (int i = 0; i < c; i+=2) { + for (int i = 0; i < c; i++) { switch( argv(i) ) { - case "game": + case "gameinfo_game": games[id].game = argv(i+1); break; - case "gamedir": + case "gameinfo_gamedir": games[id].gamedir = argv(i+1); break; - case "fallback_dir": + case "gameinfo_fallback_dir": games[id].fallback_dir = argv(i+1); break; - case "url_info": + case "gameinfo_url_info": games[id].url_info = argv(i+1); break; - case "url_dl": + case "gameinfo_url_dl": games[id].url_dl = argv(i+1); break; - case "version": + case "gameinfo_version": games[id].version = argv(i+1); break; - case "size": + case "gameinfo_size": games[id].size = stof(argv(i+1)); break; - case "svonly": + case "gameinfo_svonly": games[id].svonly = stof(argv(i+1)); break; - case "cldll": + case "gameinfo_cldll": games[id].cldll = stof(argv(i+1)); break; - case "type": + case "gameinfo_type": games[id].type = argv(i+1); break; - case "hlversion": + case "gameinfo_hlversion": games[id].hlversion = argv(i+1); break; - case "nomodels": + case "gameinfo_nomodels": games[id].nomodels = stof(argv(i+1)); break; - case "mpentity": + case "gameinfo_mpentity": games[id].mpentity = argv(i+1); break; - case "gamedll": + case "gameinfo_gamedll": games[id].gamedll = argv(i+1); break; - case "startmap": + case "gameinfo_startmap": games[id].startmap = argv(i+1); break; - case "trainingmap": - case "trainmap": + case "gameinfo_trainingmap": games[id].trainingmap = argv(i+1); break; default: diff --git a/src/menu-fn/w_modlist.cpp b/src/menu-fn/w_modlist.cpp index c3097e26..ec13af35 100644 --- a/src/menu-fn/w_modlist.cpp +++ b/src/menu-fn/w_modlist.cpp @@ -70,8 +70,10 @@ void CModList::Draw(void) } if (games[i].type != "") { - WLabel_Static(m_x + 2, pos + 3, sprintf("%.8s...",games[i].type), + drawsetcliparea(g_menuofs[0] + m_x + 2, g_menuofs[1] + pos + 3, 50,30); + WLabel_Static(m_x + 2, pos + 3, games[i].type, 11, 11, colo, 1.0f, 0, font_arial); + drawresetcliparea(); } /* Game */ @@ -92,15 +94,29 @@ void CModList::Draw(void) /* Rating */ WLabel_Static(m_x + 277, pos + 3, "0.0", 11, 11, colo, 1.0f, 0, font_arial); - /* Installed */ - WLabel_Static(m_x + 327, pos + 3, (games[i].installed == 1) ? "Yes" : "No", 11, 11, ML_COL_3, - 1.0f, 0, font_arial); - /* Servers */ - WLabel_Static(m_x + 377, pos + 3, "0", 11, 11, ML_COL_3, - 1.0f, 0, font_arial); - /* Players */ - WLabel_Static(m_x + 427, pos + 3, "0", 11, 11, ML_COL_3, - 1.0f, 0, font_arial); + + if (games[i].installed == 1) { + /* Installed */ + WLabel_Static(m_x + 327, pos + 3, "Yes", 11, 11, ML_COL_3, + 1.0f, 0, font_arial); + /* Servers */ + WLabel_Static(m_x + 377, pos + 3, "0", 11, 11, ML_COL_3, + 1.0f, 0, font_arial); + /* Players */ + WLabel_Static(m_x + 427, pos + 3, "0", 11, 11, ML_COL_3, + 1.0f, 0, font_arial); + } else { + /* Installed */ + WLabel_Static(m_x + 327, pos + 3, "No", 11, 11, ML_COL_4, + 1.0f, 0, font_arial); + /* Servers */ + WLabel_Static(m_x + 377, pos + 3, "0", 11, 11, ML_COL_4, + 1.0f, 0, font_arial); + /* Players */ + WLabel_Static(m_x + 427, pos + 3, "0", 11, 11, ML_COL_4, + 1.0f, 0, font_arial); + } + pos += 29; } } diff --git a/tfc/modinfo.txt b/tfc/modinfo.txt deleted file mode 100644 index 225549cb..00000000 --- a/tfc/modinfo.txt +++ /dev/null @@ -1,8 +0,0 @@ -game "Team Fortress" -mpentity "info_tfdetect" -nomodels "1" -size "37000000" -type "multiplayer_only" -url_dl "" -url_info "www.teamfortressclassic.com" -version "1.5" diff --git a/valve/modinfo.txt b/valve/modinfo.txt deleted file mode 100644 index efce61c4..00000000 --- a/valve/modinfo.txt +++ /dev/null @@ -1,5 +0,0 @@ -game "Half-Life" -mpentity "info_player_deathmatch" -size "496200000" -url_info "www.valvesoftware.com" -version "1.0"