MCPcopy Create free account
hub / github.com/ZDoom/Raze / D_ArbitrateNetStart

Function D_ArbitrateNetStart

source/core/d_net.cpp:1545–1626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1543}
1544
1545bool D_ArbitrateNetStart (void)
1546{
1547 ArbitrateData data;
1548 int i;
1549
1550 // Return right away if we're just playing with ourselves.
1551 if (doomcom.numnodes == 1)
1552 return true;
1553
1554 autostart = true;
1555
1556 memset (data.playersdetected, 0, sizeof(data.playersdetected));
1557 memset (data.gotsetup, 0, sizeof(data.gotsetup));
1558
1559 // The arbitrator knows about himself, but the other players must
1560 // be told about themselves, in case the host had to adjust their
1561 // userinfo (e.g. assign them to a different team).
1562 if (myconnectindex == Net_Arbitrator)
1563 {
1564 data.playersdetected[0] = 1 << myconnectindex;
1565 }
1566
1567 // Assign nodes to players. The local player is always node 0.
1568 // If the local player is not the host, then the host is node 1.
1569 // Any remaining players are assigned node numbers in the order
1570 // they were detected.
1571 playerfornode[0] = myconnectindex;
1572 nodeforplayer[myconnectindex] = 0;
1573 if (myconnectindex == Net_Arbitrator)
1574 {
1575 for (i = 1; i < doomcom.numnodes; ++i)
1576 {
1577 playerfornode[i] = i;
1578 nodeforplayer[i] = i;
1579 }
1580 }
1581 else
1582 {
1583 playerfornode[1] = 0;
1584 nodeforplayer[0] = 1;
1585 for (i = 1; i < doomcom.numnodes; ++i)
1586 {
1587 if (i < myconnectindex)
1588 {
1589 playerfornode[i+1] = i;
1590 nodeforplayer[i] = i+1;
1591 }
1592 else if (i > myconnectindex)
1593 {
1594 playerfornode[i] = i;
1595 nodeforplayer[i] = i;
1596 }
1597 }
1598 }
1599
1600 if (myconnectindex == Net_Arbitrator)
1601 {
1602 data.gotsetup[0] = 0x80;

Callers 1

D_CheckNetGameFunction · 0.85

Calls 4

I_NetInitFunction · 0.85
I_NetLoopFunction · 0.85
SendSetupFunction · 0.85
I_NetDoneFunction · 0.85

Tested by

no test coverage detected