MCPcopy Create free account
hub / github.com/bwapi/bwapi / passAdvertisement

Function passAdvertisement

bwapi/SNP_DirectIP/SNP/SNPModule.cpp:79–110  ·  view source on GitHub ↗

Overview: spiInitialize // lifetime start spiDestroy // lifetime end spiLockGameList // retrieve games list spiUnlockGameList // free spiStartAdvertisingLadderGame // when a game is hosted spiStopAdvertisingGame // when you, the host, leaves spiGetGameInfo // retrieve game info spiSend // send pa

Source from the content-addressed store, hash-verified

77 */
78 //------------------------------------------------------------------------------------------------------------------------------------
79 void passAdvertisement(const SOCKADDR& host, Util::MemoryFrame ad)
80 {
81 INTERLOCKED;
82
83 // find if the list already has an ad from this host
84 AdFile *adFile = nullptr;
85 for(auto &g : gameList)
86 {
87 // if peer IDs equal
88 if ( !memcmp(&g.gameInfo.saHost, &host, sizeof(SOCKADDR)) )
89 {
90 adFile = &g;
91 break;
92 }
93 }
94
95 // if the ad is from a new host, create a new adFile
96 if(!adFile)
97 {
98 AdFile g;
99 gameList.push_back(g);
100 adFile = &gameList.back();
101 adFile->gameInfo.dwIndex = ++nextGameAdID;
102 }
103
104 // init the new entry
105 Util::MemoryFrame::from(adFile->gameInfo).writeAs(ad.readAs<game>());
106 Util::MemoryFrame::from(adFile->extraBytes).write(ad);
107 adFile->gameInfo.dwTimer = GetTickCount();
108 adFile->gameInfo.saHost = host;
109 adFile->gameInfo.pExtra = adFile->extraBytes;
110 }
111 void removeAdvertisement(const SOCKADDR& host)
112 {
113 }

Callers 3

requestAdsMethod · 0.85
passAdvertisementMethod · 0.85

Calls 2

writeAsMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected