MCPcopy Create free account
hub / github.com/ddnet/ddnet / SendMapData

Method SendMapData

src/engine/server/server.cpp:1367–1401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1365}
1366
1367void CServer::SendMapData(int ClientId, int Chunk)
1368{
1369 int MapType = IsSixup(ClientId) ? MAP_TYPE_SIXUP : MAP_TYPE_SIX;
1370 unsigned int ChunkSize = NET_MAX_CHUNK_SIZE - 128;
1371 unsigned int Offset = Chunk * ChunkSize;
1372 int Last = 0;
1373
1374 // drop faulty map data requests
1375 if(Chunk < 0 || Offset > m_aCurrentMapSize[MapType])
1376 return;
1377
1378 if(Offset + ChunkSize >= m_aCurrentMapSize[MapType])
1379 {
1380 ChunkSize = m_aCurrentMapSize[MapType] - Offset;
1381 Last = 1;
1382 }
1383
1384 CMsgPacker Msg(NETMSG_MAP_DATA, true);
1385 if(MapType == MAP_TYPE_SIX)
1386 {
1387 Msg.AddInt(Last);
1388 Msg.AddInt(m_aCurrentMapCrc[MAP_TYPE_SIX]);
1389 Msg.AddInt(Chunk);
1390 Msg.AddInt(ChunkSize);
1391 }
1392 Msg.AddRaw(&m_apCurrentMapData[MapType][Offset], ChunkSize);
1393 SendMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH, ClientId);
1394
1395 if(Config()->m_Debug)
1396 {
1397 char aBuf[256];
1398 str_format(aBuf, sizeof(aBuf), "sending chunk %d with size %d", Chunk, ChunkSize);
1399 Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
1400 }
1401}
1402
1403void CServer::SendMapReload(int ClientId)
1404{

Callers

nothing calls this directly

Calls 5

str_formatFunction · 0.85
AddIntMethod · 0.80
AddRawMethod · 0.80
ConfigFunction · 0.50
PrintMethod · 0.45

Tested by

no test coverage detected