diff --git a/Descent3/config.cpp b/Descent3/config.cpp index 4a053eec..7ab97130 100644 --- a/Descent3/config.cpp +++ b/Descent3/config.cpp @@ -930,6 +930,7 @@ struct sound_menu { #define UID_SHORTCUT_JOYSETTINGS 0x1000 #define UID_SHORTCUT_KEYSETTINGS 0x1001 #define UID_SHORTCUT_FORCEFEED 0x1002 +#define UID_SHORTCUT_NETSETTINGS 0x1003 struct toggles_menu { newuiSheet *sheet; @@ -991,6 +992,10 @@ struct toggles_menu { if (ff_found) { sheet->AddLongButton(TXT_CFG_CONFIGFORCEFEEDBACK, UID_SHORTCUT_FORCEFEED); } + + sheet->NewGroup("Misc", 110, ff_found ? 200 : 190); + sheet->AddLongButton("Network Settings", UID_SHORTCUT_NETSETTINGS); + return sheet; }; @@ -1026,6 +1031,9 @@ struct toggles_menu { key_settings_dialog(); SaveControlConfig(); break; + case UID_SHORTCUT_NETSETTINGS: + net_settings_dialog(); + break; } }; }; diff --git a/Descent3/ctlconfig.cpp b/Descent3/ctlconfig.cpp index 2fdddfb4..88bdb1df 100644 --- a/Descent3/ctlconfig.cpp +++ b/Descent3/ctlconfig.cpp @@ -293,6 +293,8 @@ #include "hlsoundlib.h" #include "ddio.h" #include "pserror.h" +#include "networking.h" +#include "appdatabase.h" ////////////////////////////////////////////////////////////////////////////// #define IDV_KCONFIG 10 @@ -1289,6 +1291,62 @@ void key_settings_dialog() { wnd.Close(); wnd.Destroy(); } + +void net_settings_dialog() { + newuiTiledWindow wnd; + newuiSheet *sheet; + int res; + int16_t curpos; + int16_t *pps_client_current_t; + tSliderSettings slider_set; + + int cfg_range = CFG_NETWORK_CLIENT_PPS_MAX - CFG_NETWORK_CLIENT_PPS_MIN; + int nwRecommendPPS = nw_ReccomendPPS(); + + LOG_DEBUG.printf("Load network settings. PPS:%d.", nwRecommendPPS); + + // Create window + wnd.Create("Network Settings", 0, 0, 384, 256); + + // add group + sheet = wnd.GetSheet(); + sheet->NewGroup("", 0, 0); + + // slider setup + slider_set.min_val.i = CFG_NETWORK_CLIENT_PPS_MIN; + slider_set.max_val.i = CFG_NETWORK_CLIENT_PPS_MAX; + slider_set.type = SLIDER_UNITS_INT; + curpos = CALC_SLIDER_POS_INT(nwRecommendPPS, &slider_set, cfg_range); + + pps_client_current_t = sheet->AddSlider("PPS", cfg_range, curpos, &slider_set); + + // add group "window ctrl buttons" + sheet->NewGroup(NULL, 180, 160, NEWUI_ALIGN_HORIZ); + sheet->AddButton(TXT_OK, UID_OK); + sheet->AddButton(TXT_CANCEL, UID_CANCEL); + + // render + wnd.Open(); + do { + res = wnd.DoUI(); + + if (res == NEWUIRES_FORCEQUIT) { + break; + } + } while (res != UID_OK && res != UID_CANCEL); + + if (res == UID_OK) { + // save changes + nwRecommendPPS = CALC_SLIDER_INT_VALUE(*pps_client_current_t, CFG_NETWORK_CLIENT_PPS_MIN, CFG_NETWORK_CLIENT_PPS_MAX, cfg_range); + + LOG_DEBUG.printf("Write network client pps %d.", nwRecommendPPS); + + Database->write(CTLCONFIG_PPS_CLIENT_DB_KEY, nwRecommendPPS); + } + wnd.Close(); + wnd.Destroy(); +} + ////////////////////////////////////////////////////////////////////////////// // configure controller new way struct t_ctlcfgswitchcb_data { diff --git a/Descent3/ctlconfig.h b/Descent3/ctlconfig.h index 30934bf1..bdb6bf98 100644 --- a/Descent3/ctlconfig.h +++ b/Descent3/ctlconfig.h @@ -59,6 +59,12 @@ #define CTLCONFIG_CONTROLLER 1 #define CTLCONFIG_WPNSEL 2 +#define CTLCONFIG_PPS_CLIENT_DB_KEY "ClientPPS" + + +#define CFG_NETWORK_CLIENT_PPS_MIN 7 +#define CFG_NETWORK_CLIENT_PPS_MAX 30 + struct t_cfg_element { int16_t fn_id; // -1 = group start int16_t text; // text string id. @@ -76,5 +82,6 @@ void CtlConfig(int mode); // opens the settings dialogs. void joystick_settings_dialog(); void key_settings_dialog(); +void net_settings_dialog(); #endif diff --git a/Descent3/dedicated_server.cpp b/Descent3/dedicated_server.cpp index a4efa442..b6acec18 100644 --- a/Descent3/dedicated_server.cpp +++ b/Descent3/dedicated_server.cpp @@ -160,7 +160,7 @@ extern char PXO_hosted_lobby_name[]; // the dedicated server static cvar_entry CVars[] = { - {"PPS", CVAR_TYPE_INT, &Netgame.packets_per_second, 2, 20, CVAR_GAMEINIT}, // 0 + {"PPS", CVAR_TYPE_INT, &Netgame.packets_per_second, 2, 40, CVAR_GAMEINIT}, // 0 {"TimeLimit", CVAR_TYPE_INT, &Netgame.timelimit, 0, 10000, CVAR_GAMEINIT}, {"KillGoal", CVAR_TYPE_INT, &Netgame.killgoal, 0, 10000, CVAR_GAMEINIT}, {"RespawnTime", CVAR_TYPE_INT, &Netgame.respawn_time, 0, 10000, CVAR_GAMEINIT}, diff --git a/networking/networking.cpp b/networking/networking.cpp index 5c7af2f2..20338821 100644 --- a/networking/networking.cpp +++ b/networking/networking.cpp @@ -327,6 +327,7 @@ typedef int socklen_t; #include "game.h" #include "args.h" #include "byteswap.h" +#include "ctlconfig.h" #ifndef WIN32 bool Use_DirectPlay = false; @@ -2266,24 +2267,10 @@ void CDECLCALL gethostbynameworker(void *parm) } int nw_ReccomendPPS() { - static char szconnspeed[100]; - int len = 99; - strcpy(szconnspeed, ""); - Database->read("ConnectionSpeed", szconnspeed, &len); - if (stricmp(szconnspeed, "28K") == 0) - return 5; - else if (stricmp(szconnspeed, "33K") == 0) - return 6; - else if (stricmp(szconnspeed, "56K") == 0) - return 7; - else if (stricmp(szconnspeed, "ISDN") == 0) - return 8; - else if (stricmp(szconnspeed, "Cable") == 0) - return 9; - else if (stricmp(szconnspeed, "Fast") == 0) - return 12; - else - return 7; + int clientPPS = CFG_NETWORK_CLIENT_PPS_MAX; + Database->read_int(CTLCONFIG_PPS_CLIENT_DB_KEY, &clientPPS); + + return clientPPS; } // Register the networking library to call your function back