mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 15:38:00 +02:00
send a different bird index to each subsequent assignee
This commit is contained in:
parent
384dffc441
commit
e1d7f752f2
1 changed files with 9 additions and 2 deletions
|
@ -29,13 +29,20 @@ int main(int argc, const char* argv[]) {
|
|||
unsigned char assignmentPacket[numHeaderBytes + sizeof(char)];
|
||||
populateTypeAndVersion(assignmentPacket, PACKET_TYPE_SEND_ASSIGNMENT);
|
||||
|
||||
int birdIndex = 0;
|
||||
|
||||
while (true) {
|
||||
if (serverSocket.receive((sockaddr*) &senderSocket, &senderData, &receivedBytes)) {
|
||||
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
||||
// for now just send back a dummy assignment packet
|
||||
|
||||
// pick a random number between 1 and 6 so the user grabs a random bird sound
|
||||
assignmentPacket[numHeaderBytes] = randIntInRange(1, 7);
|
||||
// give this assignee the next bird index
|
||||
assignmentPacket[numHeaderBytes] = birdIndex++;
|
||||
|
||||
// wrap back to 0 if the bird index is 6 now
|
||||
if (birdIndex == 6) {
|
||||
birdIndex = 0;
|
||||
}
|
||||
|
||||
// send the assignment
|
||||
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, sizeof(assignmentPacket));
|
||||
|
|
Loading…
Reference in a new issue