Cleaned up gamelogic.c/h
- Improved comments to clarify the purpose and usage of the data structures and functions. - Brought the files in line with the SilverMUD style guide.
This commit is contained in:
parent
c2af4a551a
commit
f31f0c79a5
|
@ -93,7 +93,7 @@ void * gameLogicHandler(void * parameters)
|
|||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
// Enqueue a messaged command to a commandQueue:
|
||||
// Evaluate the next commandEvent in a queue:
|
||||
void queueMessagedCommand(queue * queue, inputMessage * messageToQueue)
|
||||
{
|
||||
// Prepare the new commandEvent:
|
||||
|
@ -126,8 +126,9 @@ void queueMessagedCommand(queue * queue, inputMessage * messageToQueue)
|
|||
pushQueue(queue, newCommand, COMMAND);
|
||||
}
|
||||
|
||||
// Enqueue a command to a commandQueue:
|
||||
void queueCommand(queue * queue, char * command, char * arguments, int commandLength, int argumentsLength, playerInfo * callingPlayer)
|
||||
// Enqueue a command to a queue:
|
||||
void queueCommand(queue * queue, char * command, char * arguments, int commandLength, int argumentsLength,
|
||||
playerInfo * callingPlayer)
|
||||
{
|
||||
// Prepare the new commandEvent:
|
||||
commandEvent * newCommand = calloc(1, sizeof(commandEvent));
|
||||
|
@ -147,7 +148,7 @@ void queueCommand(queue * queue, char * command, char * arguments, int commandLe
|
|||
pushQueue(queue, newCommand, COMMAND);
|
||||
}
|
||||
|
||||
// Evaluate the next commandEvent:
|
||||
// Evaluate the next commandEvent in a queue:
|
||||
int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
||||
{
|
||||
commandEvent * currentCommand = peekQueue(queue)->data.command;
|
||||
|
@ -555,7 +556,7 @@ int evaluateNextCommand(gameLogicParameters * parameters, queue * queue)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Run a stat check:
|
||||
// Run a stat check for the given player, returning an outcome:
|
||||
outcome statCheck(playerInfo * player, int chance, coreStat statToCheck)
|
||||
{
|
||||
// Calculate the chance:
|
||||
|
@ -624,7 +625,7 @@ outcome statCheck(playerInfo * player, int chance, coreStat statToCheck)
|
|||
}
|
||||
}
|
||||
|
||||
// Run a skill check:
|
||||
// Run a skill check for the given player, returning an outcome:
|
||||
outcome skillCheck(playerInfo * player, int chance, char * skillName, size_t skillNameLength, list * globalSkillList)
|
||||
{
|
||||
// Calculate the chance:
|
||||
|
@ -697,7 +698,7 @@ outcome skillCheck(playerInfo * player, int chance, char * skillName, size_t ski
|
|||
}
|
||||
}
|
||||
|
||||
// Move a player to a different area given a path in the area:
|
||||
// Move a player along a path in their current area:
|
||||
int movePlayerToArea(playerInfo * player, char * requestedPath)
|
||||
{
|
||||
// Check if a number was given first:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// -=[ Data Structures ]=-:
|
||||
// ========================
|
||||
|
||||
// An event for storing the information
|
||||
// An event for storing the information needed to evaluate a command:
|
||||
typedef struct commandEvent commandEvent;
|
||||
typedef struct commandEvent
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ typedef struct commandEvent
|
|||
char * arguments;
|
||||
} commandEvent;
|
||||
|
||||
// A data-structure containing the needed parameters for a main game loop:
|
||||
// A data-structure containing the needed parameters for the main game loop:
|
||||
typedef struct gameLogicParameters
|
||||
{
|
||||
// Players:
|
||||
|
@ -42,22 +42,19 @@ typedef struct gameLogicParameters
|
|||
// -=[ Functions ]=-:
|
||||
// ========================
|
||||
|
||||
// Player movement:
|
||||
int movePlayerToArea(playerInfo * player, char * requestedPath);
|
||||
|
||||
// Thread function which runs the main game loop, given the needed parameters:
|
||||
void * gameLogicHandler(void * parameters);
|
||||
|
||||
// Enqueue a command to a commandQueue:
|
||||
void queueCommand(queue * queue, char * command, char * arguments,
|
||||
int commandLength, int argumentsLength , playerInfo * callingPlayer);
|
||||
|
||||
// Enqueue a messaged command to a commandQueue:
|
||||
// Enqueue a command that has been sent as a message from a user to a queue:
|
||||
void queueMessagedCommand(queue * queue, inputMessage * messageToQueue);
|
||||
|
||||
// Evaluate the next commandEvent:
|
||||
// Evaluate the next commandEvent in a queue:
|
||||
int evaluateNextCommand(gameLogicParameters * parameters, queue * queue);
|
||||
|
||||
// Enqueue a command to a queue:
|
||||
void queueCommand(queue * queue, char * command, char * arguments, int commandLength, int argumentsLength,
|
||||
playerInfo * callingPlayer);
|
||||
|
||||
// ============================
|
||||
// -=[ Gameplay Primitives ]=-:
|
||||
// ============================
|
||||
|
@ -72,13 +69,13 @@ typedef enum outcome
|
|||
ERROR
|
||||
} outcome;
|
||||
|
||||
// Player movement:
|
||||
// Move a player along a path in their current area:
|
||||
int movePlayerToArea(playerInfo * player, char * requestedPath);
|
||||
|
||||
// Run a stat check:
|
||||
// Run a stat check for the given player, returning an outcome:
|
||||
outcome statCheck(playerInfo * player, int chance, coreStat statToCheck);
|
||||
|
||||
// Run a skill check:
|
||||
// Run a skill check for the given player, returning an outcome:
|
||||
outcome skillCheck(playerInfo * player, int chance, char * skillName, size_t skillNameLength, list * globalSkillList);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue