Talking messages now appear in the chat log correctly.
- Added logic to properly add the relevant users in the correct order to ensure message delivery.
This commit is contained in:
parent
84c20dfdbf
commit
8f08265c52
|
@ -89,14 +89,32 @@ void * gameLogicHandler(void * parameters)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Allocate an array of one playerInfo to store the pointer to the other player in the conversation:
|
||||
playerInfo ** recipients = calloc(1, (sizeof(playerInfo*)));
|
||||
// Allocate an array of two playerInfo to store the pointers to the players in the conversation:
|
||||
playerInfo ** recipients = calloc(2, (sizeof(playerInfo*)));
|
||||
|
||||
// Set the talkingWith player as the recipient of the message:
|
||||
recipients[0] = currentInput->sender->talkingWith;
|
||||
// Find which player is first in the player list:
|
||||
bool senderIsFirst = false;
|
||||
|
||||
for(int playerIndex = 0; playerIndex < *threadParameters->playerCount; playerIndex++)
|
||||
{
|
||||
if(&threadParameters->connectedPlayers[playerIndex] == currentInput->sender)
|
||||
{
|
||||
senderIsFirst = true;
|
||||
break;
|
||||
}
|
||||
if(&threadParameters->connectedPlayers[playerIndex] == currentInput->sender->talkingWith)
|
||||
{
|
||||
senderIsFirst = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the proper recipients:
|
||||
recipients[0] = (senderIsFirst) ? currentInput->sender : currentInput->sender->talkingWith;
|
||||
recipients[1] = (senderIsFirst) ? currentInput->sender->talkingWith : currentInput->sender;
|
||||
|
||||
// There's only one recipient:
|
||||
int recipientIndex = 1;
|
||||
int recipientIndex = 2;
|
||||
|
||||
// Create the outputMessage for the queue:
|
||||
outputMessage * newOutputMessage = createTargetedOutputMessage(currentInput->content, recipients, recipientIndex);
|
||||
|
@ -262,14 +280,13 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
parameters->connectedPlayers[index].playerName);
|
||||
strncat(lookMessage->messageContent, formattedString, 64);
|
||||
charCount += 38;
|
||||
|
||||
// Allocate another outputMessage for the queue:
|
||||
lookOutputMessage = createTargetedOutputMessage(lookMessage, ¤tCommand->caller, 1);
|
||||
|
||||
// Queue the outputMessage:
|
||||
pushQueue(parameters->outputQueue, lookOutputMessage, OUTPUT_MESSAGE);
|
||||
}
|
||||
}
|
||||
// Allocate another outputMessage for the queue:
|
||||
lookOutputMessage = createTargetedOutputMessage(lookMessage, ¤tCommand->caller, 1);
|
||||
|
||||
// Queue the outputMessage:
|
||||
pushQueue(parameters->outputQueue, lookOutputMessage, OUTPUT_MESSAGE);
|
||||
}
|
||||
|
||||
free(lookMessage);
|
||||
|
|
Loading…
Reference in New Issue