From 1ce3792a3a0c9f6f0fd9b8f3039772173eb0e775 Mon Sep 17 00:00:00 2001 From: Aleos Date: Sat, 16 Jun 2018 18:50:02 -0400 Subject: [PATCH] Resolved some compile issues (#3206) * Fixes #3205. * Follow up to 801d3ed. * Resolved some string literals requiring a space. * Redefine my_bool for MySQL 8.0 or later. Thanks to @bentheexo and @secretdataz! --- src/char/int_guild.cpp | 2 +- src/char/int_party.cpp | 4 ++-- src/common/db.cpp | 6 +++--- src/common/showmsg.cpp | 6 +++--- src/common/sql.cpp | 11 +++++++++++ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/char/int_guild.cpp b/src/char/int_guild.cpp index 0a876de8a9..93e961ed50 100644 --- a/src/char/int_guild.cpp +++ b/src/char/int_guild.cpp @@ -126,7 +126,7 @@ int inter_guild_tosql(struct guild *g,int flag) if (g->guild_id<=0 && g->guild_id != -1) return 0; #ifdef NOISY - ShowInfo("Save guild request ("CL_BOLD"%d"CL_RESET" - flag 0x%x).",g->guild_id, flag); + ShowInfo("Save guild request (" CL_BOLD "%d" CL_RESET " - flag 0x%x).",g->guild_id, flag); #endif Sql_EscapeStringLen(sql_handle, esc_name, g->name, strnlen(g->name, NAME_LENGTH)); diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp index b5f44b46ff..fc14f78d1f 100644 --- a/src/char/int_party.cpp +++ b/src/char/int_party.cpp @@ -123,7 +123,7 @@ int inter_party_tosql(struct party *p, int flag, int index) party_id = p->party_id; #ifdef NOISY - ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name); + ShowInfo("Save party request (" CL_BOLD "%d" CL_RESET " - %s).\n", party_id, p->name); #endif Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH)); @@ -197,7 +197,7 @@ struct party_data *inter_party_fromsql(int party_id) int i; #ifdef NOISY - ShowInfo("Load party request ("CL_BOLD"%d"CL_RESET")\n", party_id); + ShowInfo("Load party request (" CL_BOLD "%d" CL_RESET ")\n", party_id); #endif if( party_id <= 0 ) return NULL; diff --git a/src/common/db.cpp b/src/common/db.cpp index f49d21f43d..e63a5469bb 100644 --- a/src/common/db.cpp +++ b/src/common/db.cpp @@ -2774,10 +2774,10 @@ void db_final(void) { #ifdef DB_ENABLE_STATS DB_COUNTSTAT(db_final); - ShowInfo(CL_WHITE"Database nodes"CL_RESET":\n" + ShowInfo(CL_WHITE "Database nodes" CL_RESET ":\n" "allocated %u, freed %u\n", stats.db_node_alloc, stats.db_node_free); - ShowInfo(CL_WHITE"Database types"CL_RESET":\n" + ShowInfo(CL_WHITE "Database types" CL_RESET ":\n" "DB_INT : allocated %10u, destroyed %10u\n" "DB_UINT : allocated %10u, destroyed %10u\n" "DB_STRING : allocated %10u, destroyed %10u\n" @@ -2790,7 +2790,7 @@ void db_final(void) stats.db_istring_alloc, stats.db_istring_destroy, stats.db_int64_alloc, stats.db_int64_destroy, stats.db_uint64_alloc, stats.db_uint64_destroy); - ShowInfo(CL_WHITE"Database function counters"CL_RESET":\n" + ShowInfo(CL_WHITE "Database function counters" CL_RESET ":\n" "db_rotate_left %10u, db_rotate_right %10u,\n" "db_rebalance %10u, db_rebalance_erase %10u,\n" "db_is_key_null %10u,\n" diff --git a/src/common/showmsg.cpp b/src/common/showmsg.cpp index 03b189d6c9..694f756cd5 100644 --- a/src/common/showmsg.cpp +++ b/src/common/showmsg.cpp @@ -727,7 +727,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) case MSG_NONE: // direct printf replacement break; case MSG_STATUS: //Bright Green (To inform about good things) - strcat(prefix,CL_GREEN "[Status]" CL_RESET":"); + strcat(prefix,CL_GREEN "[Status]" CL_RESET ":"); break; case MSG_SQL: //Bright Violet (For dumping out anything related with SQL) <- Actually, this is mostly used for SQL errors with the database, as successes can as well just be anything else... [Skotlex] strcat(prefix,CL_MAGENTA "[SQL]" CL_RESET ":"); @@ -775,7 +775,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) if(strlen(DEBUGLOGPATH) > 0) { fp=fopen(DEBUGLOGPATH,"a"); if (fp == NULL) { - FPRINTF(STDERR, CL_RED"[ERROR]"CL_RESET": Could not open '"CL_WHITE"%s"CL_RESET"', access denied.\n", DEBUGLOGPATH); + FPRINTF(STDERR, CL_RED "[ERROR]" CL_RESET ": Could not open '" CL_WHITE "%s" CL_RESET "', access denied.\n", DEBUGLOGPATH); FFLUSH(STDERR); } else { fprintf(fp,"%s ", prefix); @@ -785,7 +785,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) fclose(fp); } } else { - FPRINTF(STDERR, CL_RED"[ERROR]"CL_RESET": DEBUGLOGPATH not defined!\n"); + FPRINTF(STDERR, CL_RED "[ERROR]" CL_RESET ": DEBUGLOGPATH not defined!\n"); FFLUSH(STDERR); } #endif diff --git a/src/common/sql.cpp b/src/common/sql.cpp index b8b652c720..e32778ba5c 100644 --- a/src/common/sql.cpp +++ b/src/common/sql.cpp @@ -12,8 +12,15 @@ #include "winapi.hpp" #endif #include +#include #include // strtoul +// MySQL 8.0 or later removed my_bool typedef. +// Reintroduce it as a bandaid fix. +#if MYSQL_VERSION_ID >= 80000 +#define my_bool bool +#endif + #define SQL_CONF_NAME "conf/inter_athena.conf" void ra_mysql_error_handler(unsigned int ecode); @@ -1040,3 +1047,7 @@ void Sql_inter_server_read(const char* cfgName, bool first) { void Sql_Init(void) { Sql_inter_server_read(SQL_CONF_NAME,true); } + +#ifdef my_bool +#undef my_bool +#endif