Changed from bzero to memset
- All instances of bzero have been replaced in an effort to make SilverMUD slightly easier to port.
This commit is contained in:
parent
26a5496594
commit
0add957224
|
@ -7,6 +7,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
#include <ncurses.h>
|
||||
|
@ -73,7 +74,7 @@ void * messageSender(void * parameters)
|
|||
|
||||
// Send the message off to the server:
|
||||
messageSend(tlsSession, &sendBuffer);
|
||||
bzero(&sendBuffer, sizeof(char) * MAX);
|
||||
memset(&sendBuffer, 0, sizeof(char) * MAX);
|
||||
}
|
||||
|
||||
// Rejoin the main thread:
|
||||
|
|
|
@ -108,7 +108,7 @@ void * gameLogicHandler(void * parameters)
|
|||
free(recipients);
|
||||
}
|
||||
}
|
||||
bzero(currentInput, sizeof(inputMessage));
|
||||
memset(currentInput, 0, sizeof(inputMessage));
|
||||
currentInput = NULL;
|
||||
threadParameters->inputQueue->lock = false;
|
||||
popQueue(threadParameters->inputQueue);
|
||||
|
@ -204,7 +204,7 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
pushQueue(parameters->outputQueue, lookOutputMessage, OUTPUT_MESSAGE);
|
||||
|
||||
//queueTargetedOutputMessage(parameters->outputQueue, lookMessage, ¤tCommand->caller, 1);
|
||||
bzero(lookMessage, sizeof(userMessage));
|
||||
memset(lookMessage, 0, sizeof(userMessage));
|
||||
|
||||
// Loop through the paths and send the appropriate amount of messages:
|
||||
int charCount = 13;
|
||||
|
@ -221,7 +221,7 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
// Queue the outputMessage:
|
||||
pushQueue(parameters->outputQueue, lookOutputMessage, OUTPUT_MESSAGE);
|
||||
|
||||
bzero(lookMessage, sizeof(userMessage));
|
||||
memset(lookMessage, 0, sizeof(userMessage));
|
||||
charCount = 0;
|
||||
}
|
||||
snprintf(formattedString, 64, "\n\t%ld. %s", index + 1,
|
||||
|
@ -278,7 +278,7 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
// Queue the outputMessage:
|
||||
pushQueue(parameters->outputQueue, statOutputMessage, OUTPUT_MESSAGE);
|
||||
|
||||
bzero(statMessage->messageContent, sizeof(char) * MAX);
|
||||
memset(statMessage->messageContent, 0, sizeof(char) * MAX);
|
||||
if (currentCommand->caller->skills->head != NULL)
|
||||
{
|
||||
size_t skillIndex = 0;
|
||||
|
@ -299,7 +299,7 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
|
||||
// Queue the outputMessage:
|
||||
pushQueue(parameters->outputQueue, statOutputMessage, OUTPUT_MESSAGE);
|
||||
bzero(statMessage, sizeof(userMessage));
|
||||
memset(statMessage, 0, sizeof(userMessage));
|
||||
charCount = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
// Queue the outputMessage:
|
||||
pushQueue(parameters->outputQueue, listOutputMessage, OUTPUT_MESSAGE);
|
||||
|
||||
bzero(listMessage, sizeof(userMessage));
|
||||
memset(listMessage, 0, sizeof(userMessage));
|
||||
charCount = 0;
|
||||
addNewline = false;
|
||||
}
|
||||
|
@ -695,8 +695,8 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
}
|
||||
|
||||
// Remove the current command and unlock the queue:
|
||||
bzero(currentCommand->command, sizeof(char) * 16);
|
||||
bzero(currentCommand->arguments, sizeof(char) * MAX);
|
||||
memset(currentCommand->command, 0, sizeof(char) * 16);
|
||||
memset(currentCommand->arguments, 0, sizeof(char) * MAX);
|
||||
currentCommand = NULL;
|
||||
queue->lock = false;
|
||||
popQueue(queue);
|
||||
|
@ -747,7 +747,7 @@ outcome statCheck(playerInfo * player, int chance, coreStat statToCheck)
|
|||
return ERROR;
|
||||
}
|
||||
}
|
||||
int attempt = (random() % 100) + modifier;
|
||||
int attempt = (rand() % 100) + modifier;
|
||||
if (attempt >= chance)
|
||||
{
|
||||
if (attempt >= 98)
|
||||
|
@ -820,7 +820,7 @@ outcome skillCheck(playerInfo * player, int chance, char * skillName, size_t ski
|
|||
}
|
||||
|
||||
// Attempt the check:
|
||||
int attempt = (random() % 100) + modifier;
|
||||
int attempt = (rand() % 100) + modifier;
|
||||
if (attempt >= chance)
|
||||
{
|
||||
if (attempt >= 98)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <ncurses.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -131,7 +132,7 @@ int main(int argc, char ** argv)
|
|||
slowPrint("\n--==== \033[33;40mSILVERKIN INDUSTRIES\033[0m COMM-LINK SERVER ====--\nVersion Alpha 0.5\n", delay);
|
||||
|
||||
// Seed random number generator from the current time:
|
||||
srandom((unsigned)time(¤tTime));
|
||||
srand((unsigned)time(¤tTime));
|
||||
|
||||
// Initialize the sockets to 0, so we don't crash.
|
||||
for (int index = 0; index < PLAYERCOUNT; index++)
|
||||
|
@ -152,7 +153,7 @@ int main(int argc, char ** argv)
|
|||
slowPrint("\tSocket Creation is:\t\033[32;40mGREEN.\033[0m\n", delay);
|
||||
}
|
||||
|
||||
bzero(&serverAddress, sizeof(serverAddress));
|
||||
memset(&serverAddress, 0, sizeof(serverAddress));
|
||||
|
||||
// Assign IP and port:
|
||||
serverAddress.sin_family = AF_INET;
|
||||
|
|
Loading…
Reference in New Issue