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
| 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 | } |
no test coverage detected