diff --git a/.gitignore b/.gitignore index 3652a69..e49f673 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,8 @@ SilverMUDClientDebug SilverMUDServerDebug # Profiling Artifacts: -gmon.out \ No newline at end of file +gmon.out + +# LSP whatnot: +.cache +compile_commands.json \ No newline at end of file diff --git a/Makefile b/Makefile index a656190..3ae32bf 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,14 @@ serversrc = $(wildcard src/*.c) src/server/SilverMUDServer.c serverobj = $(serversrc:.c=.o) # Default target: Compile the client and server with aggressive optimizations and a big stack of warnings: -all: clean SilverMUDClient SilverMUDServer all: CFLAGS += -Wall -Wextra -Ofast +all: SilverMUDClient SilverMUDServer + # Debug target: Compile the client and server with profiling, debug information, debug optimization, and the # preprocessor flag "debug" set. debug: CFLAGS += -Wall -Wextra -pg -ggdb -Og -D debug -debug: clean SilverMUDClientDebug SilverMUDServerDebug +debug: SilverMUDClientDebug SilverMUDServerDebug SilverMUDClient: $(clientobj) cc $^ $(LDFLAGS) -o $@ @@ -29,7 +30,7 @@ SilverMUDClientDebug: $(clientobj) cc -pg $^ $(LDFLAGS) -o $@ SilverMUDServerDebug: $(serverobj) - cc -pg $^ $(LDFLAGS) -o $@ + cc -pg $^ $(LDFLAGS) -o @$ # Start from a clean slate: .PHONY: clean diff --git a/src/areadata.h b/src/areadata.h index 26356fe..ef58b36 100644 --- a/src/areadata.h +++ b/src/areadata.h @@ -3,7 +3,6 @@ #ifndef AREADATA_H #define AREADATA_H #include "constants.h" -#include "linkedlist.h" // ==================== // -=[ Area/Paths: ]=-: diff --git a/src/client/SilverMUDClient.c b/src/client/SilverMUDClient.c index a011f51..c2cf663 100644 --- a/src/client/SilverMUDClient.c +++ b/src/client/SilverMUDClient.c @@ -54,10 +54,10 @@ void * messageSender(void * parameters) { usleep(200000); // Clear the window: - wprintw(window, "\n\n\n"); + waddstr(window, "\n\n\n"); // Print the prompt: - wprintw(window, prompt); + waddstr(window, prompt); if (wgetnstr(window, sendBuffer.messageContent, MAX) == ERR) { diff --git a/src/gamelogic.h b/src/gamelogic.h index 2fd9b8d..f36b749 100644 --- a/src/gamelogic.h +++ b/src/gamelogic.h @@ -2,11 +2,13 @@ // Barry Kane, 2022. #ifndef GAMELOGIC_H #define GAMELOGIC_H -#include "queue.h" #include "areadata.h" #include "constants.h" #include "playerdata.h" -#include "inputoutput.h" + +// Forward-declare some data structures to prevent cyclic dependencies: +typedef struct queue queue; +typedef struct inputMessage inputMessage; // ======================== // -=[ Data Structures ]=-: diff --git a/src/inputoutput.h b/src/inputoutput.h index c7d6fc0..93a1cbb 100644 --- a/src/inputoutput.h +++ b/src/inputoutput.h @@ -7,12 +7,10 @@ #include #include #include - -#include "queue.h" #include "constants.h" #include "playerdata.h" -// Let the compiler know there will be structs defined elsewhere: +// Forward-declare some data structures to prevent cyclic dependencies: typedef struct queue queue; // ======================== diff --git a/src/linkedlist.h b/src/linkedlist.h index b43e9ba..3ac3940 100644 --- a/src/linkedlist.h +++ b/src/linkedlist.h @@ -3,7 +3,6 @@ #ifndef LINKEDLIST_H #define LINKEDLIST_H #include "areadata.h" -#include "playerdata.h" // Let the compiler know there will be structs defined elsewhere: typedef struct playerPath playerPath; diff --git a/src/queue.h b/src/queue.h index 3217698..616794c 100644 --- a/src/queue.h +++ b/src/queue.h @@ -5,13 +5,13 @@ #include "gamelogic.h" #include "inputoutput.h" +// Forward-declare some data structures to prevent cyclic dependencies: +typedef struct queue queue; + // ======================== // -=[ Data Structures ]=-: // ======================== -// Let the compiler know there will be structs defined elsewhere: -typedef struct queue queue; - // An enum which is used to state what type of data is being stored in a queueNode: typedef enum queueDataType { diff --git a/src/server/SilverMUDServer.c b/src/server/SilverMUDServer.c index d67b181..c921de2 100644 --- a/src/server/SilverMUDServer.c +++ b/src/server/SilverMUDServer.c @@ -64,7 +64,8 @@ int main(int argc, char ** argv) } case 'm': { - strncpy(motd, optarg, strlen(optarg) + 1); + strncpy(motd, optarg, 2047); + motd[2047] = '\0'; break; } }