More cleaning up.
- Brought remaining files in line with style guides, and improved comments.
This commit is contained in:
parent
f31f0c79a5
commit
f5cb3ad16e
|
@ -124,7 +124,7 @@ void * outputThreadHandler(void * parameters)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (&connectedPlayers[index] == message->recipients[targetIndex])
|
if (&connectedPlayers[index] == message->recipients[sentCount])
|
||||||
{
|
{
|
||||||
sentCount++;
|
sentCount++;
|
||||||
messageSend(tlssessions[index], message->content);
|
messageSend(tlssessions[index], message->content);
|
||||||
|
@ -156,7 +156,7 @@ void userInputSanatize(char * inputString, int length)
|
||||||
inputString[length - 1] = '\0';
|
inputString[length - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanatize user names so they display correctly;
|
// Sanatize user names so they display correctly:
|
||||||
void userNameSanatize(char * inputString, int length)
|
void userNameSanatize(char * inputString, int length)
|
||||||
{
|
{
|
||||||
for(int index = 0; index <= length; index++)
|
for(int index = 0; index <= length; index++)
|
||||||
|
|
|
@ -15,6 +15,7 @@ typedef struct playerSkill playerSkill;
|
||||||
// -=[ Data Structures ]=-:
|
// -=[ Data Structures ]=-:
|
||||||
// ========================
|
// ========================
|
||||||
|
|
||||||
|
// An enum of the possible data types that can be stored in a list:
|
||||||
typedef enum listDataType
|
typedef enum listDataType
|
||||||
{
|
{
|
||||||
PATH,
|
PATH,
|
||||||
|
@ -23,6 +24,7 @@ typedef enum listDataType
|
||||||
SKILL
|
SKILL
|
||||||
} listDataType;
|
} listDataType;
|
||||||
|
|
||||||
|
// A union containing a pointers to all data types that can be stored in a list:
|
||||||
typedef union listData
|
typedef union listData
|
||||||
{
|
{
|
||||||
playerPath * path;
|
playerPath * path;
|
||||||
|
@ -31,6 +33,7 @@ typedef union listData
|
||||||
playerSkill * skill;
|
playerSkill * skill;
|
||||||
} listData;
|
} listData;
|
||||||
|
|
||||||
|
// A doubly linked node for the linked list type:
|
||||||
typedef struct listNode listNode;
|
typedef struct listNode listNode;
|
||||||
typedef struct listNode
|
typedef struct listNode
|
||||||
{
|
{
|
||||||
|
@ -39,6 +42,7 @@ typedef struct listNode
|
||||||
listNode * previous;
|
listNode * previous;
|
||||||
} listNode;
|
} listNode;
|
||||||
|
|
||||||
|
// A header structure for the list containing the length, head, tail, and type of the list.
|
||||||
typedef struct list
|
typedef struct list
|
||||||
{
|
{
|
||||||
listDataType type;
|
listDataType type;
|
||||||
|
|
|
@ -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)
|
int deallocatePlayer(playerInfo * playerToDeallocate)
|
||||||
{
|
{
|
||||||
// Deallocate the skill list:
|
// Deallocate the skill list:
|
||||||
|
|
|
@ -14,6 +14,7 @@ typedef struct playerPath playerPath;
|
||||||
typedef struct listNode listNode;
|
typedef struct listNode listNode;
|
||||||
typedef struct list list;
|
typedef struct list list;
|
||||||
|
|
||||||
|
// The basic information that needs to be stored for a player or creature's stats:
|
||||||
typedef struct statBlock
|
typedef struct statBlock
|
||||||
{
|
{
|
||||||
// Levelling:
|
// Levelling:
|
||||||
|
@ -36,6 +37,7 @@ typedef struct statBlock
|
||||||
int skillPoints;
|
int skillPoints;
|
||||||
} statBlock;
|
} statBlock;
|
||||||
|
|
||||||
|
// Information about a skill, including skill levels and modifiers for the player:
|
||||||
typedef struct playerSkill
|
typedef struct playerSkill
|
||||||
{
|
{
|
||||||
char skillName[32];
|
char skillName[32];
|
||||||
|
@ -44,6 +46,7 @@ typedef struct playerSkill
|
||||||
bool trainedSkill;
|
bool trainedSkill;
|
||||||
} playerSkill;
|
} playerSkill;
|
||||||
|
|
||||||
|
// Information about a single player's character:
|
||||||
typedef struct playerInfo
|
typedef struct playerInfo
|
||||||
{
|
{
|
||||||
char playerName[32];
|
char playerName[32];
|
||||||
|
@ -52,6 +55,7 @@ typedef struct playerInfo
|
||||||
list * skills;
|
list * skills;
|
||||||
} playerInfo;
|
} playerInfo;
|
||||||
|
|
||||||
|
// An enum of the main stats of the game:
|
||||||
typedef enum coreStat
|
typedef enum coreStat
|
||||||
{
|
{
|
||||||
WITS,
|
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:
|
// Take a string containing a core stat name and return the core stat:
|
||||||
coreStat getCoreStatFromString(char * string, int stringLength);
|
coreStat getCoreStatFromString(char * string, int stringLength);
|
||||||
|
|
||||||
// Deallocate a player:
|
// Deallocate a player's information including the skill lists and stats:
|
||||||
int deallocatePlayer(playerInfo * playerToDeallocate);
|
int deallocatePlayer(playerInfo * playerToDeallocate);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ncurses.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;
|
int characterIndex = 0;
|
||||||
while (stringToPrint[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;
|
int characterIndex = 0;
|
||||||
if (bolded)
|
if (bolded)
|
||||||
|
@ -40,7 +42,8 @@ void slowPrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bol
|
||||||
wrefresh(window);
|
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;
|
unsigned int characterIndex = 0;
|
||||||
while (stringToPrint[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;
|
int characterIndex = 0;
|
||||||
if (bolded)
|
if (bolded)
|
||||||
|
@ -85,6 +89,7 @@ void bruteforcePrintNcurses(char * stringToPrint, int delay, WINDOW * window, bo
|
||||||
wrefresh(window);
|
wrefresh(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Word-wrap a string to a given width:
|
||||||
void wrapString(char * stringToWrap, int stringLength, int screenWidth)
|
void wrapString(char * stringToWrap, int stringLength, int screenWidth)
|
||||||
{
|
{
|
||||||
int characterCount = 0;
|
int characterCount = 0;
|
||||||
|
|
|
@ -5,20 +5,23 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
|
||||||
// A character by character print, similar to a serial terminal with lower baud rate.
|
// A character by character print, similar to a serial terminal with lower baud rate:
|
||||||
void slowPrint(char * stringToPrint, int delay);
|
void slowPrint(const char * stringToPrint, int delay);
|
||||||
|
|
||||||
// The same, altered to work with ncurses.
|
// The same, altered to work with ncurses:
|
||||||
void slowPrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bolded);
|
void slowPrintNcurses(const char * stringToPrint, int delay, WINDOW * window, bool bolded);
|
||||||
|
|
||||||
// A character by character "brute-force" print, similar to Hollywood hacking scenes.
|
// A character by character "brute-force" print, similar to Hollywood hacking scenes:
|
||||||
void bruteforcePrint(char * stringToPrint, int delay);
|
void bruteforcePrint(const char * stringToPrint, int delay);
|
||||||
|
|
||||||
// The same, altered to work with ncurses.
|
// The same, altered to work with ncurses:
|
||||||
void bruteforcePrintNcurses(char * stringToPrint, int delay, WINDOW * window, bool bolded);
|
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.
|
// A string containing an ASCII art version of the Silverkin Industries logo.
|
||||||
char * logostring =
|
const char * logostring =
|
||||||
" ///////\n"
|
" ///////\n"
|
||||||
" //////////////////////////////////////////\n"
|
" //////////////////////////////////////////\n"
|
||||||
" ///////////////////////////////////////////////////////////\n"
|
" ///////////////////////////////////////////////////////////\n"
|
||||||
|
@ -32,6 +35,4 @@ char * logostring =
|
||||||
" # # # # # # # # ## # ### # # ## //\n"
|
" # # # # # # # # ## # ### # # ## //\n"
|
||||||
" # # ### ##### ##### ### # # # # #### ### /\n";
|
" # # ### ##### ##### ### # # # # #### ### /\n";
|
||||||
|
|
||||||
void wrapString(char * stringToWrap, int stringLength, int screenWidth);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue