More cleaning up.

- Brought remaining files in line with style guides, and improved comments.
This commit is contained in:
Barry Kane 2023-02-15 22:09:21 +00:00
parent f31f0c79a5
commit f5cb3ad16e
7 changed files with 105 additions and 90 deletions

View File

@ -124,7 +124,7 @@ void * outputThreadHandler(void * parameters)
{
break;
}
if (&connectedPlayers[index] == message->recipients[targetIndex])
if (&connectedPlayers[index] == message->recipients[sentCount])
{
sentCount++;
messageSend(tlssessions[index], message->content);
@ -156,7 +156,7 @@ void userInputSanatize(char * inputString, int length)
inputString[length - 1] = '\0';
}
// Sanatize user names so they display correctly;
// Sanatize user names so they display correctly:
void userNameSanatize(char * inputString, int length)
{
for(int index = 0; index <= length; index++)

View File

@ -15,6 +15,7 @@ typedef struct playerSkill playerSkill;
// -=[ Data Structures ]=-:
// ========================
// An enum of the possible data types that can be stored in a list:
typedef enum listDataType
{
PATH,
@ -23,6 +24,7 @@ typedef enum listDataType
SKILL
} listDataType;
// A union containing a pointers to all data types that can be stored in a list:
typedef union listData
{
playerPath * path;
@ -31,6 +33,7 @@ typedef union listData
playerSkill * skill;
} listData;
// A doubly linked node for the linked list type:
typedef struct listNode listNode;
typedef struct listNode
{
@ -39,6 +42,7 @@ typedef struct listNode
listNode * previous;
} listNode;
// A header structure for the list containing the length, head, tail, and type of the list.
typedef struct list
{
listDataType type;

View File

@ -209,6 +209,7 @@ coreStat getCoreStatFromString(char * inputString, int stringLength)
}
}
// Deallocate a player's information including the skill lists and stats:
int deallocatePlayer(playerInfo * playerToDeallocate)
{
// Deallocate the skill list:

View File

@ -14,6 +14,7 @@ typedef struct playerPath playerPath;
typedef struct listNode listNode;
typedef struct list list;
// The basic information that needs to be stored for a player or creature's stats:
typedef struct statBlock
{
// Levelling:
@ -36,6 +37,7 @@ typedef struct statBlock
int skillPoints;
} statBlock;
// Information about a skill, including skill levels and modifiers for the player:
typedef struct playerSkill
{
char skillName[32];
@ -44,6 +46,7 @@ typedef struct playerSkill
bool trainedSkill;
} playerSkill;
// Information about a single player's character:
typedef struct playerInfo
{
char playerName[32];
@ -52,6 +55,7 @@ typedef struct playerInfo
list * skills;
} playerInfo;
// An enum of the main stats of the game:
typedef enum coreStat
{
WITS,
@ -72,7 +76,7 @@ int takeSkillbyID(list * globalSkillList, int skillID, playerInfo * targetPlayer
// Take a string containing a core stat name and return the core stat:
coreStat getCoreStatFromString(char * string, int stringLength);
// Deallocate a player:
// Deallocate a player's information including the skill lists and stats:
int deallocatePlayer(playerInfo * playerToDeallocate);
#endif

View File

@ -5,7 +5,8 @@
#include <unistd.h>
#include <ncurses.h>
void slowPrint(char * stringToPrint, int delay)
// A character by character print, similar to a serial terminal with lower baud rate:
void slowPrint(const char * stringToPrint, int delay)
{
int characterIndex = 0;
while (stringToPrint[characterIndex] != '\0')
@ -18,7 +19,8 @@ void slowPrint(char * stringToPrint, int delay)
}
}
void slowPrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bolded)
// The same, altered to work with ncurses:
void slowPrintNcurses(const char * stringToPrint, int delay, WINDOW * window, bool bolded)
{
int characterIndex = 0;
if (bolded)
@ -40,7 +42,8 @@ void slowPrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bol
wrefresh(window);
}
void bruteforcePrint(char * stringToPrint, int delay)
// A character by character "brute-force" print, similar to Hollywood hacking scenes:
void bruteforcePrint(const char * stringToPrint, int delay)
{
unsigned int characterIndex = 0;
while (stringToPrint[characterIndex] != '\0')
@ -58,7 +61,8 @@ void bruteforcePrint(char * stringToPrint, int delay)
}
}
void bruteforcePrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bolded)
// The same, altered to work with ncurses:
void bruteforcePrintNcurses(const char * stringToPrint, int delay, WINDOW * window, bool bolded)
{
int characterIndex = 0;
if (bolded)
@ -85,6 +89,7 @@ void bruteforcePrintNcurses(char * stringToPrint, int delay, WINDOW * window, bo
wrefresh(window);
}
// Word-wrap a string to a given width:
void wrapString(char * stringToWrap, int stringLength, int screenWidth)
{
int characterCount = 0;

View File

@ -5,20 +5,23 @@
#include <stdio.h>
#include <ncurses.h>
// A character by character print, similar to a serial terminal with lower baud rate.
void slowPrint(char * stringToPrint, int delay);
// A character by character print, similar to a serial terminal with lower baud rate:
void slowPrint(const char * stringToPrint, int delay);
// The same, altered to work with ncurses.
void slowPrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bolded);
// The same, altered to work with ncurses:
void slowPrintNcurses(const char * stringToPrint, int delay, WINDOW * window, bool bolded);
// A character by character "brute-force" print, similar to Hollywood hacking scenes.
void bruteforcePrint(char * stringToPrint, int delay);
// A character by character "brute-force" print, similar to Hollywood hacking scenes:
void bruteforcePrint(const char * stringToPrint, int delay);
// The same, altered to work with ncurses.
void bruteforcePrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bolded);
// The same, altered to work with ncurses:
void bruteforcePrintNcurses(const char * stringToPrint, int delay, WINDOW * window, bool bolded);
// Word-wrap a string to a given width:
void wrapString(char * stringToWrap, int stringLength, int screenWidth);
// A string containing an ASCII art version of the Silverkin Industries logo.
char * logostring =
const char * logostring =
" ///////\n"
" //////////////////////////////////////////\n"
" ///////////////////////////////////////////////////////////\n"
@ -32,6 +35,4 @@ char * logostring =
" # # # # # # # # ## # ### # # ## //\n"
" # # ### ##### ##### ### # # # # #### ### /\n";
void wrapString(char * stringToWrap, int stringLength, int screenWidth);
#endif