Skip to content

Commit f0d35f6

Browse files
committed
syndwarsfx: Some refactoring around network support
1 parent c61c969 commit f0d35f6

7 files changed

Lines changed: 124 additions & 99 deletions

File tree

conf/wrappers_game.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,3 +1143,4 @@ LbCommInit W p i
11431143
LbCommDeInit W i p
11441144
LbCommExchange W i ipi
11451145
LbCommStopExchange W i i
1146+
net_unkn_func_30 W o

src/fenet.c

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ extern ubyte byte_1C47EA;
7979
extern ubyte byte_1C4805;
8080
extern ubyte byte_1C4806;
8181
extern ubyte byte_1C4994;
82+
extern ubyte byte_1C4995;
8283
extern ubyte byte_155170[4];
8384
extern char net_unkn1_text[25];
85+
extern char byte_1811E2[16];
8486

8587
ubyte ac_do_net_protocol_option(ubyte click);
8688
ubyte ac_do_net_unkn40(ubyte click);
@@ -1431,20 +1433,22 @@ ubyte show_net_protocol_box(struct ScreenBox *p_box)
14311433
byte_1C4806 = 0;
14321434
addr = 0;
14331435
sscanf(net_proto_param_text, "%04x", &addr);
1436+
nsvc.I.Param = addr;
14341437
LbNetworkSetupIPXAddress(addr);
14351438
net_service_unkstruct04_clear();
14361439

1437-
if (LbNetworkServiceStart(&nsvc.I) == Lb_SUCCESS)
1438-
{
1439-
byte_1C4A7C = 1;
1440-
}
1441-
else
1440+
if (LbNetworkServiceStart(&nsvc.I) != Lb_SUCCESS)
14421441
{
1442+
LOGERR("Failed on LbNetworkServiceStart");
14431443
alert_box_text_fmt("%s", gui_strings[568]);
14441444
net_protocol_option_button.Text = net_baudrate_text;
14451445
net_protocol_option_button.CallBackFn = ac_do_serial_speed_switch;
14461446
net_protocol_select_button.Text = gui_strings[499];
1447-
nsvc.I.Type = 2;
1447+
nsvc.I.Type = NetSvc_COM1;
1448+
}
1449+
else
1450+
{
1451+
byte_1C4A7C = 1;
14481452
}
14491453
}
14501454
}
@@ -1806,6 +1810,37 @@ ubyte show_net_groups_box(struct ScreenBox *p_box)
18061810
return 0;
18071811
}
18081812

1813+
int refresh_users_in_net_game(void)
1814+
{
1815+
char locstr[16];
1816+
int n;
1817+
short plyr;
1818+
1819+
n = 0;
1820+
ingame.InNetGame_UNSURE = (1 << 8) - 1;
1821+
for (plyr = 0; plyr < 8; plyr++)
1822+
{
1823+
TbResult ret;
1824+
ret = LbNetworkPlayerName(locstr, plyr);
1825+
if (ret != Lb_SUCCESS)
1826+
{
1827+
unkn2_names[plyr][0] = '\0';
1828+
ingame.InNetGame_UNSURE &= ~(1 << plyr);
1829+
continue;
1830+
}
1831+
if (locstr[0] == '\0')
1832+
{
1833+
unkn2_names[plyr][0] = '\0';
1834+
ingame.InNetGame_UNSURE &= ~(1 << plyr);
1835+
continue;
1836+
}
1837+
strncpy(unkn2_names[plyr], locstr, sizeof(unkn2_names[0]));
1838+
n++;
1839+
}
1840+
LOGSYNC("Net players %d", n);
1841+
return n;
1842+
}
1843+
18091844
ubyte show_net_users_box(struct ScreenBox *p_box)
18101845
{
18111846
#if 0
@@ -1816,7 +1851,6 @@ ubyte show_net_users_box(struct ScreenBox *p_box)
18161851
#endif
18171852
const char *text;
18181853
struct TbNetworkPlayer *p_netplyr;
1819-
char locstr[16];
18201854
short plyr;
18211855
short scr_x, scr_y;
18221856
short tx_width, tx_height;
@@ -1853,21 +1887,13 @@ ubyte show_net_users_box(struct ScreenBox *p_box)
18531887
scr_y = 18;
18541888
if (login_control__State == 5)
18551889
{
1856-
ingame.InNetGame_UNSURE = -1;
1890+
refresh_users_in_net_game();
1891+
18571892
for (plyr = 0; plyr < 8; plyr++)
18581893
{
1859-
TbResult ret;
1860-
ret = LbNetworkPlayerName(locstr, plyr);
1861-
if (ret != Lb_SUCCESS)
1894+
text = unkn2_names[plyr];
1895+
if (text[0] == '\0')
18621896
{
1863-
ingame.InNetGame_UNSURE &= ~(1 << plyr);
1864-
unkn2_names[plyr][0] = '\0';
1865-
continue;
1866-
}
1867-
if (strlen(locstr) == 0)
1868-
{
1869-
unkn2_names[plyr][0] = '\0';
1870-
ingame.InNetGame_UNSURE &= ~(1 << plyr);
18711897
continue;
18721898
}
18731899
if (byte_15516D == plyr)
@@ -1879,12 +1905,11 @@ ubyte show_net_users_box(struct ScreenBox *p_box)
18791905
{
18801906
lbDisplay.DrawFlags = 0;
18811907
}
1882-
strncpy(unkn2_names[plyr], locstr, sizeof(unkn2_names[0]));
1883-
tx_width = my_string_width(locstr);
1908+
tx_width = my_string_width(text);
18841909
scr_x = (110 - tx_width) >> 1;
18851910
if (is_unkn_current_player())
18861911
lbDisplay.DrawFlags |= 0x8000;
1887-
text = loctext_to_gtext(locstr);
1912+
text = loctext_to_gtext(text);
18881913
draw_text_purple_list2(scr_x, scr_y + 3, text, 0);
18891914
lbDisplay.DrawFlags &= ~0x8000;
18901915

@@ -1924,12 +1949,11 @@ ubyte show_net_users_box(struct ScreenBox *p_box)
19241949
{
19251950
const char *name;
19261951
name = p_netplyr[plyr].Name;
1927-
if (strlen(name))
1952+
if (name[0] != '\0')
19281953
{
1929-
snprintf(locstr, sizeof(locstr), "%s", name);
1930-
tx_width = my_string_width(locstr);
1954+
tx_width = my_string_width(name);
19311955
scr_x = (110 - tx_width) >> 1;
1932-
text = loctext_to_gtext(locstr);
1956+
text = loctext_to_gtext(name);
19331957
draw_text_purple_list2(scr_x, scr_y + 3, text, 0);
19341958
scr_y += tx_height + 9;
19351959
}
@@ -1938,6 +1962,14 @@ ubyte show_net_users_box(struct ScreenBox *p_box)
19381962
return 0;
19391963
}
19401964

1965+
int net_unkn_func_30(void)
1966+
{
1967+
int ret;
1968+
asm volatile ("call ASM_net_unkn_func_30\n"
1969+
: "=r" (ret) : );
1970+
return ret;
1971+
}
1972+
19411973
ubyte do_unkn8_EJECT(ubyte click)
19421974
{
19431975
#if 0

src/fenet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern "C" {
3434
TbBool local_player_hosts_the_game(void);
3535

3636
void init_net_screen_boxes(void);
37+
void net_service_unkstruct04_clear(void);
3738
void show_netgame_unkn_case1(void);
3839
void reset_net_screen_boxes_flags(void);
3940
void reset_net_screen_EJECT_flags(void);

src/game.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5721,7 +5721,7 @@ void net_unkn_func_33_sub1(int plyr, int netplyr)
57215721
byte_15516D = -1;
57225722
reset_net_screen_EJECT_flags();
57235723
LbNetworkSessionStop();
5724-
if (word_1811AE == 1)
5724+
if (nsvc.I.Type == 1)
57255725
{
57265726
if (p_netplyr->U.Progress.val_15516D == netplyr)
57275727
{
@@ -5744,16 +5744,12 @@ void net_unkn_func_33_sub1(int plyr, int netplyr)
57445744
break;
57455745
case 13:
57465746
LbNetworkSessionStop();
5747-
if (word_1811AE == 1)
5747+
if (nsvc.I.Type == 1)
57485748
{
57495749
if (plyr == netplyr || net_host_player_no == plyr)
57505750
{
57515751
net_new_game_prepare();
5752-
memset(unkstruct04_arr, 0, 0x1108u);
5753-
byte_1C6D48 = 0;
5754-
for (i = 0; i < PLAYERS_LIMIT; i++) {
5755-
unkn2_names[i][0] = '\0';
5756-
}
5752+
net_service_unkstruct04_clear();
57575753
}
57585754
}
57595755
else
@@ -5883,7 +5879,7 @@ void net_unkn_func_33(void)
58835879
{
58845880
LbNetworkSessionStop();
58855881
net_new_game_prepare();
5886-
if (word_1811AE != 1)
5882+
if (nsvc.I.Type != 1)
58875883
{
58885884
if (byte_1C4A6F)
58895885
LbNetworkHangUp();
@@ -6158,10 +6154,10 @@ void show_load_and_prep_mission(void)
61586154
flic_unkn03(AniSl_BILLBOARD);
61596155
xdo_next_frame(AniSl_BILLBOARD);
61606156

6161-
if ( in_network_game )
6157+
if (in_network_game)
61626158
{
6163-
if (word_1811AE != 1)
6164-
ingame.InNetGame_UNSURE = 3;
6159+
if (nsvc.I.Type != NetSvc_IPX)
6160+
ingame.InNetGame_UNSURE = ((1 << 0) | (1 << 1)); // two players
61656161
ingame.DetailLevel = 0;
61666162
bang_set_detail(ingame.DetailLevel == 0);
61676163
}

src/game.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ extern ubyte refresh_equip_list;
419419
extern ubyte flic_mods[5];
420420
extern ubyte old_flic_mods[5];
421421
extern ubyte reload_background_flag;
422-
extern ushort word_1811AE;
423422

424423
extern struct LevelDef level_def;
425424

src/plyr_packet.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
void net_player_leave(PlayerIdx plyr)
4040
{
4141
kill_my_players(plyr);
42-
if ((plyr == net_host_player_no) || (plyr == local_player_no) || (nsvc.I.Type != 1))
42+
if ((plyr == net_host_player_no) || (plyr == local_player_no) || (nsvc.I.Type != NetSvc_IPX))
4343
{
4444
ingame.DisplayMode = DpM_PURPLEMNU;
4545
StopCD();
4646
StopAllSamples();
4747
SetMusicVolume(100, 0);
4848
LbNetworkSessionStop();
49-
if (nsvc.I.Type != 1 && byte_1C4A6F)
49+
if (nsvc.I.Type != NetSvc_IPX && byte_1C4A6F)
5050
LbNetworkHangUp();
5151
}
5252
else

0 commit comments

Comments
 (0)