1
0
mirror of https://github.com/solemnwarning/ipxwrapper synced 2024-12-30 16:45:37 +01:00

Add option to enable/disable packet coalescing.

This commit is contained in:
Daniel Collins 2023-12-03 13:21:45 +00:00
parent 0dd7f08993
commit 5e6430ea8b
4 changed files with 34 additions and 1 deletions

View File

@ -70,6 +70,12 @@ coalesce_dest *get_coalesce_by_dest(addr32_t netnum, addr48_t nodenum, uint16_t
{
FPROF_RECORD_SCOPE(&(ipxwrapper_fstats[IPXWRAPPER_FSTATS_get_coalesce_by_dest]));
if(!main_config.dosbox_coalesce)
{
/* Skip coalescing if disabled. */
return NULL;
}
coalesce_table_key dest = { netnum, nodenum, socket };
coalesce_dest *node;

View File

@ -37,6 +37,7 @@ main_config_t get_main_config(void)
config.dosbox_server_addr = NULL;
config.dosbox_server_port = 213;
config.dosbox_coalesce = false;
HKEY reg = reg_open_main(false);
@ -64,6 +65,7 @@ main_config_t get_main_config(void)
config.dosbox_server_addr = reg_get_string(reg, "dosbox_server_addr", "");
config.dosbox_server_port = reg_get_dword(reg, "dosbox_server_port", config.dosbox_server_port);
config.dosbox_coalesce = reg_get_dword(reg, "dosbox_coalesce", config.dosbox_coalesce);
/* Check for valid frame_type */
@ -96,7 +98,8 @@ bool set_main_config(const main_config_t *config)
&& reg_set_dword(reg, "profile", config->profile)
&& reg_set_string(reg, "dosbox_server_addr", config->dosbox_server_addr)
&& reg_set_dword(reg, "dosbox_server_port", config->dosbox_server_port);
&& reg_set_dword(reg, "dosbox_server_port", config->dosbox_server_port)
&& reg_set_dword(reg, "dosbox_coalesce", config->dosbox_coalesce);
reg_close(reg);

View File

@ -50,6 +50,7 @@ typedef struct main_config {
char *dosbox_server_addr;
uint16_t dosbox_server_port;
bool dosbox_coalesce;
enum ipx_log_level log_level;
bool profile;

View File

@ -53,6 +53,7 @@ enum {
ID_DOSBOX_SERVER_ADDR = 51,
ID_DOSBOX_SERVER_PORT = 52,
ID_DOSBOX_COALESCE = 53,
ID_DOSBOX_FW_EXCEPT = 55,
ID_IPXWRAPPER_PORT = 61,
@ -133,6 +134,7 @@ static struct {
HWND dosbox_server_addr;
HWND dosbox_server_port_lbl;
HWND dosbox_server_port;
HWND dosbox_coalesce;
HWND dosbox_fw_except;
HWND box_ipx_options;
@ -207,6 +209,21 @@ static LRESULT CALLBACK main_wproc(HWND window, UINT msg, WPARAM wp, LPARAM lp)
break;
}
case ID_DOSBOX_COALESCE: {
bool coalesce = get_checkbox(wh.dosbox_coalesce);
if(coalesce)
{
int result = MessageBox(NULL, "Packet coalescing requires all players to be using IPXWrapper 0.7.1 or later.\nAre you sure you want to enable it?", "Warning", MB_YESNO | MB_TASKMODAL | MB_ICONWARNING);
if(result != IDYES)
{
set_checkbox(wh.dosbox_coalesce, false);
}
}
break;
}
case ID_OPT_LOG_DEBUG: {
main_window_update();
break;
@ -570,6 +587,7 @@ static bool save_config()
}
main_config.dosbox_server_port = port;
main_config.dosbox_coalesce = get_checkbox(wh.dosbox_coalesce);
main_config.fw_except = get_checkbox(wh.dosbox_fw_except);
}
else if(main_config.encap_type == ENCAP_TYPE_PCAP)
@ -760,6 +778,7 @@ static void main_window_init()
wh.dosbox_server_port_lbl = create_STATIC(wh.box_dosbox_options, "DOSBox IPX server port");
wh.dosbox_server_port = create_child(wh.box_dosbox_options, "EDIT", "", WS_TABSTOP, WS_EX_CLIENTEDGE, ID_DOSBOX_SERVER_PORT);
wh.dosbox_coalesce = create_checkbox(wh.box_dosbox_options, "Coalesce packets when saturated", ID_DOSBOX_COALESCE);
wh.dosbox_fw_except = create_checkbox(wh.box_dosbox_options, "Automatically create Windows Firewall exceptions", ID_DOSBOX_FW_EXCEPT);
/* Initialise controls. */
@ -771,6 +790,7 @@ static void main_window_init()
sprintf(port_s, "%hu", main_config.dosbox_server_port);
SetWindowText(wh.dosbox_server_port, port_s);
set_checkbox(wh.dosbox_coalesce, main_config.dosbox_coalesce);
set_checkbox(wh.dosbox_fw_except, main_config.fw_except);
}
@ -938,6 +958,9 @@ static void main_window_init()
box_dosbox_options_y += text_h; /* Padding. */
MoveWindow(wh.dosbox_coalesce, BOX_SIDE_PAD, box_dosbox_options_y, width - 20, text_h, TRUE);
box_dosbox_options_y += text_h;
MoveWindow(wh.dosbox_fw_except, BOX_SIDE_PAD, box_dosbox_options_y, width - 20, text_h, TRUE);
box_dosbox_options_y += text_h;