diff --git a/lib/bin/gmeng.h b/lib/bin/gmeng.h index 91edded..ba2e7e3 100755 --- a/lib/bin/gmeng.h +++ b/lib/bin/gmeng.h @@ -461,10 +461,10 @@ static std::vector bgcolornames = { static std::string colorformat(std::string data) { std::string formatted = data; - for (int i = 0; i < sizeof(Gmeng::colors); i++) { + for (int i = 0; i < (sizeof(Gmeng::colors)/sizeof(*Gmeng::colors)); i++) { formatted = str_replace(formatted, "~" + colornames[i] + "~", Gmeng::colors[i]); }; - for (int i = 0; i < sizeof(Gmeng::bgcolors); i++) { + for (int i = 0; i < (sizeof(Gmeng::bgcolors)/sizeof(*Gmeng::bgcolors)); i++) { formatted = str_replace(formatted, "~" + bgcolornames[i] + "~", Gmeng::bgcolors[i]); }; formatted = str_replace(formatted, "~h~", "\033[1m"); @@ -649,9 +649,9 @@ static void __explain_why_i_cannot_run_to_dumbass_using_windows() { exit(1); }; -static void _gargv_patch_global(int argc, char* argv[]) { - __annot__(_gargv_patch_global, "patches the Gmeng::global variable with the command-line arguments."); - __functree_call__(__FILE__, __LINE__, _gargv_patch_global); +static void patch_argv_global(int argc, char* argv[]) { + __annot__(patch_argv_global, "patches the Gmeng::global variable with the command-line arguments."); + __functree_call__(__FILE__, __LINE__, patch_argv_global); #if _WIN32 __explain_why_i_cannot_run_to_dumbass_using_windows(); return; @@ -666,7 +666,7 @@ static void _gargv_patch_global(int argc, char* argv[]) { ioctl(STDOUT_FILENO, TIOCGWINSZ, &size); int times = size.ws_col-11; __gmeng_write_log__("gmeng.log", "command-line argument requested help menu\n"); - SAY("~Br~\x0F~h~~y~GMENG " + (Gmeng::version) + "~n~ | " + Gmeng::colors[6] + "Terminal-Based 2D Game Engine~n~ | Help Menu\n"); + SAY("~Br~\x0F~h~\x0F~y~GMENG " + (Gmeng::version) + "~n~ | " + Gmeng::colors[6] + "Terminal-Based 2D Game Engine~n~ | Help Menu\n"); SAY("~_~~st~" + repeatString("-", times+11) + "~n~\n"); SAY("~h~~r~Gmeng~n~ is a standalone terminal-based game engine, utilizing ~y~pthread~n~ and the ~b~C++ Standard library~n~.\n"); SAY("~_~Currently, Gmeng is only available to MacOS and Linux users while on its active development phase.\n"); diff --git a/lib/bin/src/index.cpp b/lib/bin/src/index.cpp index 08a52ad..2c232b2 100755 --- a/lib/bin/src/index.cpp +++ b/lib/bin/src/index.cpp @@ -204,7 +204,7 @@ int main2( int argc, char** argv ) { }; int main(int argc, char** argv) { - _gargv_patch_global(argc, argv); + patch_argv_global(argc, argv); SAY("~b~~r~CLI to be implemented~n~\n"); return 0; }; diff --git a/makefile b/makefile index 28ee42f..0ff90be 100755 --- a/makefile +++ b/makefile @@ -1,7 +1,13 @@ # Compiler and flags CXX := g++ -CXXFLAGS := -lcurl -g --std=c++20 -pthread `pkg-config --libs --cflags ncursesw` -Wno-deprecated-declarations -Wno-writable-strings -Wno-switch-bool -Wno-format-security -framework ApplicationServices +CXXFLAGS := -lcurl --std=c++20 -pthread `pkg-config --libs --cflags ncursesw` -Wno-deprecated-declarations -Wno-writable-strings -Wno-switch-bool -Wno-format-security -framework ApplicationServices OUTFILE := -o gmeng + +ifeq ($(filter debug,$(MAKECMDGOALS)), debug) + CXXFLAGS += -fsanitize=address + CXXFLAGS += -g +endif + # Default target builds lib/bin/src/index.cpp all: lib/bin/out/gmeng @@ -17,5 +23,9 @@ test: test.cpp test2: tests/test.cpp $(CXX) $(CXXFLAGS) -o tests/out/test.o tests/test.cpp +# Target for building with the debug flag +debug: + @$(MAKE) CXXFLAGS="$(CXXFLAGS)" $(filter-out debug,$(MAKECMDGOALS)) + # Phony targets -.PHONY: all test test2 +.PHONY: all test test2 debug diff --git a/tests/out/test.o b/tests/out/test.o index 13b68c7..15dc2f9 100755 Binary files a/tests/out/test.o and b/tests/out/test.o differ diff --git a/tests/test.cpp b/tests/test.cpp index 977fce9..9548750 100755 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -379,7 +379,7 @@ int main(int argc, char* argv[]) { bool do_main1 = false; gm_log("test.cpp",__LINE__,"gmeng_tests -> SPAWN(1)"); gm::global.dev_console = false; - _gargv_patch_global(argc, argv); + patch_argv_global(argc, argv); for (int i = 0; i < argc; i++) { char *v_arg = argv[i]; std::string argument (v_arg);