MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiDoGetGameInfo

Function MultiDoGetGameInfo

Descent3/multi.cpp:3833–3917  ·  view source on GitHub ↗

Someone is asking about our game

Source from the content-addressed store, hash-verified

3831
3832// Someone is asking about our game
3833void MultiDoGetGameInfo(uint8_t *data, network_address *from_addr) {
3834 uint8_t outdata[MAX_GAME_DATA_SIZE];
3835 int count = 0;
3836 int size_offset;
3837 network_address my_addr;
3838 float ping_time;
3839
3840 // mprintf(0,"Got a request for knowledge about my game!\n");
3841
3842 // Get the time and stuff it back in the packet
3843 SKIP_HEADER(data, &count);
3844 ping_time = MultiGetFloat(data, &count);
3845 int version = MultiGetInt(data, &count);
3846
3847 if (version != MULTI_VERSION)
3848 return; // Versions don't match, so just return
3849
3850 count = 0;
3851
3852 if (Game_is_master_tracker_game)
3853 return;
3854
3855 if (!Multi_accept_state)
3856 return;
3857
3858 if ((Netgame.local_role == LR_SERVER) && (Game_mode & GM_MULTI)) {
3859 size_offset = START_DATA(MP_GAME_INFO, outdata, &count);
3860 // Copies my address into the passed argument
3861 nw_GetMyAddress(&my_addr);
3862 memcpy(&outdata[count], &my_addr, sizeof(network_address));
3863 count += sizeof(network_address);
3864
3865 int len = strlen(Netgame.name) + 1;
3866 MultiAddByte(len, outdata, &count);
3867 memcpy(&outdata[count], Netgame.name, len);
3868 count += len;
3869
3870 len = strlen(Netgame.mission) + 1;
3871
3872 MultiAddByte(len, outdata, &count);
3873 memcpy(&outdata[count], Netgame.mission, len);
3874 count += len;
3875
3876 len = strlen(Netgame.mission_name) + 1;
3877
3878 MultiAddByte(len, outdata, &count);
3879 memcpy(&outdata[count], Netgame.mission_name, len);
3880 count += len;
3881
3882 len = strlen(Netgame.scriptname) + 1;
3883
3884 MultiAddByte(len, outdata, &count);
3885 memcpy(&outdata[count], Netgame.scriptname, len);
3886 count += len;
3887
3888 MultiAddShort(Current_mission.cur_level, outdata, &count);
3889 uint16_t icurrplayers = 0;
3890 for (int i = 0; i < MAX_NET_PLAYERS; i++) {

Callers 1

MultiProcessDataFunction · 0.85

Calls 11

SKIP_HEADERFunction · 0.85
MultiGetFloatFunction · 0.85
MultiGetIntFunction · 0.85
START_DATAFunction · 0.85
nw_GetMyAddressFunction · 0.85
MultiAddByteFunction · 0.85
MultiAddShortFunction · 0.85
MultiAddFloatFunction · 0.85
MultiAddIntFunction · 0.85
END_DATAFunction · 0.85
nw_SendFunction · 0.85

Tested by

no test coverage detected