Bläddra i källkod

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!
Aleos 7 år sedan
förälder
incheckning
1ce3792a3a
5 ändrade filer med 20 tillägg och 9 borttagningar
  1. 1 1
      src/char/int_guild.cpp
  2. 2 2
      src/char/int_party.cpp
  3. 3 3
      src/common/db.cpp
  4. 3 3
      src/common/showmsg.cpp
  5. 11 0
      src/common/sql.cpp

+ 1 - 1
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));

+ 2 - 2
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;

+ 3 - 3
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"

+ 3 - 3
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

+ 11 - 0
src/common/sql.cpp

@@ -12,8 +12,15 @@
 #include "winapi.hpp"
 #endif
 #include <mysql.h>
+#include <mysql_version.h>
 #include <stdlib.h>// 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