Menu-FN: set create-server maxplayers to 8 when cvar is at 1, search pak

archives in reverse for liblist etc. files to ensure we read the latest +
more fixes
This commit is contained in:
Marco Cawthorne 2021-08-01 11:49:00 +02:00
parent 0ca3d03927
commit 3ca7b5451c
3 changed files with 28 additions and 12 deletions

View file

@ -118,9 +118,14 @@ menu_creategame_init(void)
create_tbMaxplayers = spawn(CTextBox);
create_tbMaxplayers.SetPos(216,226);
create_tbMaxplayers.m_length = 156;
create_tbMaxplayers.SetText(cvar_string("sv_playerslots"));
Widget_Add(fn_createshared, create_tbMaxplayers);
/* if it's 1, that means we recently played a SP game, reset to default for now */
if (cvar("sv_playerslots") <= 1)
create_tbMaxplayers.SetText("8");
else
create_tbMaxplayers.SetText(cvar_string("sv_playerslots"));
create_tbPassword = spawn(CTextBox);
create_tbPassword.SetPos(216,280);
create_tbPassword.m_length = 156;

View file

@ -178,18 +178,20 @@ customgame_liblist_parse(int id, string strKey, string strValue)
switch (strtolower(strValue)) {
case "multiplayer_only":
case "multiplayer only":
case "mp":
case "multi":
case "multiplayer":
games[id].type = "Multiplayer";
break;
case "singleplayer_only":
case "singleplayer only":
games[id].type = "Singleplayer";
break;
/* this... kind of sucks, but some games (gearbox) never updated
* their liblist to reflect that they do multiplayer */
case "sp":
case "single":
case "singleplayer":
games[id].type = "Singleplayer";
break;
case "mp":
case "multi":
case "multiplayer":
default:
games[id].type = "Both";
}
@ -262,9 +264,13 @@ games_find_in_gamedir(string filename, string gamedirname)
/* let's search for every pk3 in the gamedir and search for a liblist, one at a time. */
psh = search_begin("*.pk3", SB_FULLPACKAGEPATH | SB_FORCESEARCH, FALSE, gamedirname);
/* loop through each pk3 */
for (int i = 0; i < search_getsize(psh); i++) {
/* loop through each pk3 in reverse (newest to old) */
for (int i = search_getsize(psh); i >= 0; i--) {
string full = search_getfilename(psh, i);
if (!full)
continue;
sh = search_begin(filename, SB_FULLPACKAGEPATH | SB_FORCESEARCH, FALSE, strcat(gamedirname, "/", full));
fh = search_fopen(sh, 0);
@ -277,12 +283,16 @@ games_find_in_gamedir(string filename, string gamedirname)
/* still nothing. let's search for pk4's to sift through */
if (fh < 0) {
/* let's search for every pk3 in the gamedir and search for a liblist, one at a time. */
/* let's search for every pk4 in the gamedir and search for a liblist, one at a time. */
psh = search_begin("*.pk4", SB_FULLPACKAGEPATH | SB_FORCESEARCH, FALSE, gamedirname);
/* loop through each pk3 */
for (int i = 0; i < search_getsize(psh); i++) {
/* loop through each pk4 in reverse (newest to old) */
for (int i = search_getsize(psh); i >= 0; i--) {
string full = search_getfilename(psh, i);
if (!full)
continue;
sh = search_begin(filename, SB_FULLPACKAGEPATH | SB_FORCESEARCH, FALSE, strcat(gamedirname, "/", full));
fh = search_fopen(sh, 0);

View file

@ -324,7 +324,8 @@ menu_main_init(void)
main_btn2Multiplayer = spawn(CMainButton);
main_btn2Multiplayer.SetImage(BTN_MULTIPLAYER);
main_btn2Multiplayer.SetPos(70,348);
main_btn2Multiplayer.SetExecute(btn_multiplayer_start);
if (games[gameinfo_current].type != "Singleplayer")
main_btn2Multiplayer.SetExecute(btn_multiplayer_start);
Widget_Add(fn_main2, main_btn2Multiplayer);
/* Custom game */