From 0f9a3af9e466576cdb64b0e3b4ab1a5dec9549f5 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sat, 26 Jan 2013 17:29:37 -0200 Subject: Changing ASCI Art / Moving stat server to Hercules. Changed the ASCI art (not quite final; just changing it prior to release), moving stat server to hercules end Signed-off-by: shennetsind --- src/common/core.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/common/core.c') diff --git a/src/common/core.c b/src/common/core.c index e1f99885b..1e3dbb3d7 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -265,18 +265,19 @@ static void display_title(void) { //ClearScreen(); // clear screen and go up/left (0, 0 position in text) ShowMessage("\n"); - ShowMessage(""CL_PASS" "CL_BOLD" "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BT_WHITE" rAthena Development Team presents "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" ___ __ __ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" _____/ | / /_/ /_ ___ ____ ____ _ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" / ___/ /| |/ __/ __ \\/ _ \\/ __ \\/ __ `/ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" / / / ___ / /_/ / / / __/ / / / /_/ / "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" /_/ /_/ |_\\__/_/ /_/\\___/_/ /_/\\__,_/ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_GREEN" http://rathena.org/board/ "CL_PASS""CL_CLL""CL_NORMAL"\n"); - ShowMessage(""CL_PASS" "CL_BOLD" "CL_PASS""CL_CLL""CL_NORMAL"\n"); - - ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'.\n", get_svn_revision()); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" Hercules Development Team presents "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" _ _ _ "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | | | | | | "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | |_| | ___ _ __ ___ _ _| | ___ ___ "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | _ |/ _ \\ '__/ __| | | | |/ _ \\/ __|"CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" | | | | __/ | | (__| |_| | | __/\\__ \\"CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" \\_| |_/\\___|_| \\___|\\__,_|_|\\___||___/"CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" http://hercules.ws/board/ "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); + + //ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'.\n", get_svn_revision()); } // Warning if executed as superuser (root) @@ -284,7 +285,7 @@ void usercheck(void) { #ifndef _WIN32 if (geteuid() == 0) { - ShowWarning ("You are running rAthena with root privileges, it is not necessary.\n"); + ShowWarning ("You are running Hercules with root privileges, it is not necessary.\n"); } #endif } -- cgit v1.2.3-70-g09d2 From a4a549da77879c142ed9fe667ed312dfa6e6b70a Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 3 Feb 2013 12:25:53 -0200 Subject: Introducing MySQL Reconnect * mysql_reconnect_type ** 1: when mysql disconnects during runtime, the server tries to reconnect mysql_reconnect_count times and, if unsuccessful, the server is shut down ** 2: when mysql disconnects during runtime it tries to reconnect indefinitely mysql_reconnect_type:2 * mysql_reconnect_count ** number of reconnect attempts the server should do when the database disconnects during runtime ** only used when mysql_reconnect_type is 1 mysql_reconnect_count:1 ~Ind Signed-off-by: shennetsind --- conf/inter-server.conf | 12 ++++++++ src/common/core.c | 2 ++ src/common/sql.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++- src/common/sql.h | 1 + 4 files changed, 88 insertions(+), 1 deletion(-) (limited to 'src/common/core.c') diff --git a/conf/inter-server.conf b/conf/inter-server.conf index 70bf80e5c..523437007 100644 --- a/conf/inter-server.conf +++ b/conf/inter-server.conf @@ -56,6 +56,18 @@ log_db_db: ragnarok log_codepage: log_login_db: loginlog +// == MySQL Reconnect Settings +// =========================== +// - mysql_reconnect_type +// - 1: when mysql disconnects during runtime, the server tries to reconnect mysql_reconnect_count times and, +// -- if unsuccessful, the server is shut down +// - 2: when mysql disconnects during runtime it tries to reconnect indefinitely +mysql_reconnect_type:2 +// - mysql_reconnect_count +// - number of reconnect attempts the server should do when the database disconnects during runtime +// - only used when mysql_reconnect_type is 1 +mysql_reconnect_count:1 + // DO NOT CHANGE ANYTHING BEYOND THIS LINE UNLESS YOU KNOW YOUR DATABASE DAMN WELL // this is meant for people who KNOW their stuff, and for some reason want to change their // database layout. [CLOWNISIUS] diff --git a/src/common/core.c b/src/common/core.c index 1e3dbb3d7..bb536a255 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -11,6 +11,7 @@ #include "../common/timer.h" #include "../common/thread.h" #include "../common/mempool.h" +#include "../common/sql.h" #endif #include @@ -319,6 +320,7 @@ int main (int argc, char **argv) display_title(); usercheck(); + Sql_Init(); rathread_init(); mempool_init(); db_init(); diff --git a/src/common/sql.c b/src/common/sql.c index 800aa89b0..96346d68c 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -15,7 +15,10 @@ #include // strlen/strnlen/memcpy/memset #include // strtoul +void hercules_mysql_error_handler(unsigned int ecode); +int mysql_reconnect_type; +int mysql_reconnect_count; /// Sql handle struct Sql @@ -74,7 +77,7 @@ Sql* Sql_Malloc(void) self->lengths = NULL; self->result = NULL; self->keepalive = INVALID_TIMER; - + self->handle.reconnect = 1; return self; } @@ -266,12 +269,14 @@ int Sql_QueryV(Sql* self, const char* query, va_list args) if( mysql_real_query(&self->handle, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) { ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + hercules_mysql_error_handler(mysql_errno(&self->handle)); return SQL_ERROR; } self->result = mysql_store_result(&self->handle); if( mysql_errno(&self->handle) != 0 ) { ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + hercules_mysql_error_handler(mysql_errno(&self->handle)); return SQL_ERROR; } return SQL_SUCCESS; @@ -291,12 +296,14 @@ int Sql_QueryStr(Sql* self, const char* query) if( mysql_real_query(&self->handle, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) { ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + hercules_mysql_error_handler(mysql_errno(&self->handle)); return SQL_ERROR; } self->result = mysql_store_result(&self->handle); if( mysql_errno(&self->handle) != 0 ) { ShowSQL("DB error - %s\n", mysql_error(&self->handle)); + hercules_mysql_error_handler(mysql_errno(&self->handle)); return SQL_ERROR; } return SQL_SUCCESS; @@ -639,6 +646,7 @@ int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args) if( mysql_stmt_prepare(self->stmt, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) { ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + hercules_mysql_error_handler(mysql_stmt_errno(self->stmt)); return SQL_ERROR; } self->bind_params = false; @@ -660,6 +668,7 @@ int SqlStmt_PrepareStr(SqlStmt* self, const char* query) if( mysql_stmt_prepare(self->stmt, StringBuf_Value(&self->buf), (unsigned long)StringBuf_Length(&self->buf)) ) { ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + hercules_mysql_error_handler(mysql_stmt_errno(self->stmt)); return SQL_ERROR; } self->bind_params = false; @@ -721,12 +730,14 @@ int SqlStmt_Execute(SqlStmt* self) mysql_stmt_execute(self->stmt) ) { ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + hercules_mysql_error_handler(mysql_stmt_errno(self->stmt)); return SQL_ERROR; } self->bind_columns = false; if( mysql_stmt_store_result(self->stmt) )// store all the data { ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + hercules_mysql_error_handler(mysql_stmt_errno(self->stmt)); return SQL_ERROR; } @@ -868,6 +879,7 @@ int SqlStmt_NextRow(SqlStmt* self) if( err ) { ShowSQL("DB error - %s\n", mysql_stmt_error(self->stmt)); + hercules_mysql_error_handler(mysql_stmt_errno(self->stmt)); return SQL_ERROR; } @@ -946,3 +958,63 @@ void SqlStmt_Free(SqlStmt* self) aFree(self); } } +/* receives mysql error codes during runtime (not on first-time-connects) */ +void hercules_mysql_error_handler(unsigned int ecode) { + static unsigned int retry = 1; + switch( ecode ) { + case 2003:/* Can't connect to MySQL (this error only happens here when failing to reconnect) */ + if( mysql_reconnect_type == 1 ) { + if( ++retry > mysql_reconnect_count ) { + ShowFatalError("MySQL has been unreachable for too long, %d reconnects were attempted. Shutting Down\n", retry); + exit(EXIT_FAILURE); + } + } + break; + } +} +void Sql_inter_server_read(const char* cfgName, bool first) { + int i; + char line[1024], w1[1024], w2[1024]; + FILE* fp; + + fp = fopen(cfgName, "r"); + if(fp == NULL) { + if( first ) { + ShowFatalError("File not found: %s\n", cfgName); + exit(EXIT_FAILURE); + } else + ShowError("File not found: %s\n", cfgName); + return; + } + + while(fgets(line, sizeof(line), fp)) { + i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2); + if(i != 2) + continue; + + if(!strcmpi(w1,"mysql_reconnect_type")) { + mysql_reconnect_type = atoi(w2); + switch( mysql_reconnect_type ) { + case 1: + case 2: + break; + default: + ShowError("%s::mysql_reconnect_type is set to %d which is not valid, defaulting to 1...\n", cfgName, mysql_reconnect_type); + mysql_reconnect_type = 1; + break; + } + } else if(!strcmpi(w1,"mysql_reconnect_count")) { + mysql_reconnect_count = atoi(w2); + if( mysql_reconnect_count < 1 ) + mysql_reconnect_count = 1; + } else if(!strcmpi(w1,"import")) + Sql_inter_server_read(w2,false); + } + fclose(fp); + + return; +} + +void Sql_Init(void) { + Sql_inter_server_read("conf/inter-server.conf",true); +} diff --git a/src/common/sql.h b/src/common/sql.h index 898e2c778..a9d8c6136 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -339,6 +339,7 @@ void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned lo /// Frees a SqlStmt returned by SqlStmt_Malloc. void SqlStmt_Free(SqlStmt* self); +void Sql_Init(void); #endif /* _COMMON_SQL_H_ */ -- cgit v1.2.3-70-g09d2 From 24d6aba263ff25724b8e6c9d6a228bba9fd6e756 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 3 Feb 2013 13:12:57 -0200 Subject: Updating the headers of so-far modified files with outdated headers Signed-off-by: shennetsind --- src/common/core.c | 5 +++-- src/common/sql.c | 5 +++-- src/common/sql.h | 5 +++-- src/map/pc.c | 5 +++-- src/map/skill.c | 5 +++-- src/map/status.c | 5 +++-- 6 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src/common/core.c') diff --git a/src/common/core.c b/src/common/core.c index bb536a255..b1714b7a5 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules dev team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena dev team #include "../common/mmo.h" #include "../common/showmsg.h" diff --git a/src/common/sql.c b/src/common/sql.c index 96346d68c..d00b51694 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules dev team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena dev team #include "../common/cbasetypes.h" #include "../common/malloc.h" diff --git a/src/common/sql.h b/src/common/sql.h index a9d8c6136..5ac92665e 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules dev team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena dev team #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ diff --git a/src/map/pc.c b/src/map/pc.c index e26191717..49b905c0d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules dev team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena dev team #include "../common/cbasetypes.h" #include "../common/core.h" // get_svn_revision() diff --git a/src/map/skill.c b/src/map/skill.c index 448f54406..f806c4ec5 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules dev team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena dev team #include "../common/cbasetypes.h" #include "../common/timer.h" diff --git a/src/map/status.c b/src/map/status.c index 0379d05d2..8171f20ec 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules dev team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena dev team #include "../common/cbasetypes.h" #include "../common/timer.h" -- cgit v1.2.3-70-g09d2 From 2ae187d00651c406a7a1c0c1cbc1495566d1607b Mon Sep 17 00:00:00 2001 From: shennetsind Date: Thu, 7 Feb 2013 00:23:37 -0200 Subject: Fixing mistake in modified source code headers Signed-off-by: shennetsind --- src/char/int_guild.c | 2 +- src/char/int_pet.c | 2 +- src/common/core.c | 2 +- src/common/mapindex.c | 2 +- src/common/sql.c | 2 +- src/common/sql.h | 2 +- src/login/login.c | 2 +- src/map/battle.c | 2 +- src/map/battle.h | 2 +- src/map/chrif.c | 2 +- src/map/clif.c | 2 +- src/map/elemental.c | 2 +- src/map/homunculus.c | 2 +- src/map/map.c | 2 +- src/map/map.h | 2 +- src/map/mercenary.c | 2 +- src/map/mob.c | 2 +- src/map/npc.c | 2 +- src/map/pc.c | 2 +- src/map/pc.h | 2 +- src/map/script.c | 2 +- src/map/skill.c | 2 +- src/map/status.c | 2 +- src/map/unit.c | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/common/core.c') diff --git a/src/char/int_guild.c b/src/char/int_guild.c index c18bf7d3c..e25ebd902 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/mmo.h" diff --git a/src/char/int_pet.c b/src/char/int_pet.c index d9b0cf5ef..7a6c217f9 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/mmo.h" #include "../common/malloc.h" diff --git a/src/common/core.c b/src/common/core.c index b1714b7a5..42cdfa7cd 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/mmo.h" #include "../common/showmsg.h" diff --git a/src/common/mapindex.c b/src/common/mapindex.c index cea945ac0..685af641c 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/mmo.h" #include "../common/showmsg.h" diff --git a/src/common/sql.c b/src/common/sql.c index 73c4181d9..b842db46d 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/malloc.h" diff --git a/src/common/sql.h b/src/common/sql.h index 5ac92665e..b7159ec90 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #ifndef _COMMON_SQL_H_ #define _COMMON_SQL_H_ diff --git a/src/login/login.c b/src/login/login.c index 625e0f5c6..7f272e2a4 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/core.h" #include "../common/db.h" diff --git a/src/map/battle.c b/src/map/battle.c index f9748833f..2ad066d33 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/timer.h" diff --git a/src/map/battle.h b/src/map/battle.h index 1354da78a..cd626cd6b 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #ifndef _BATTLE_H_ #define _BATTLE_H_ diff --git a/src/map/chrif.c b/src/map/chrif.c index 3ad164b89..06eef0564 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/malloc.h" diff --git a/src/map/clif.c b/src/map/clif.c index 8d5090c2c..6d9e57bd2 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/socket.h" diff --git a/src/map/elemental.c b/src/map/elemental.c index f6c9eff84..33ef4d1b9 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/malloc.h" diff --git a/src/map/homunculus.c b/src/map/homunculus.c index c94a95775..92868c7c7 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/malloc.h" diff --git a/src/map/map.c b/src/map/map.c index d2cc9c4a9..6f9401dad 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/core.h" diff --git a/src/map/map.h b/src/map/map.h index 06995024f..73f8e694b 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #ifndef _MAP_H_ #define _MAP_H_ diff --git a/src/map/mercenary.c b/src/map/mercenary.c index c3fb8e3e2..a97651b87 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/malloc.h" diff --git a/src/map/mob.c b/src/map/mob.c index aceebc506..4f28923e9 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/timer.h" diff --git a/src/map/npc.c b/src/map/npc.c index 383cd031a..ba476e810 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/timer.h" diff --git a/src/map/pc.c b/src/map/pc.c index 6e24d7d49..0dd210394 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/core.h" // get_svn_revision() diff --git a/src/map/pc.h b/src/map/pc.h index ac1950a69..6e56a612e 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #ifndef _PC_H_ #define _PC_H_ diff --git a/src/map/script.c b/src/map/script.c index b4f0a5d9b..a6d588113 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams //#define DEBUG_DISP //#define DEBUG_DISASM diff --git a/src/map/skill.c b/src/map/skill.c index 2cc3ed1ab..972aa8129 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/timer.h" diff --git a/src/map/status.c b/src/map/status.c index 8fd48aefc..0ee993de4 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/timer.h" diff --git a/src/map/unit.c b/src/map/unit.c index 45aca7d41..1d37704e0 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1,6 +1,6 @@ // Copyright (c) Hercules dev team, licensed under GNU GPL. // See the LICENSE file -// Portions Copyright (c) Athena dev team +// Portions Copyright (c) Athena Dev Teams #include "../common/showmsg.h" #include "../common/timer.h" -- cgit v1.2.3-70-g09d2 From 82005a99f5b1cca68e9fb1ac6b1614c815e4bd45 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Thu, 14 Feb 2013 19:13:14 -0200 Subject: Introducing Git Hash Added 'Git Hash' way to identify where you last updated your working copy (it won't detect your local changes' hash -- intended). Also Implemented HERC_UNKNOWN_VER, a simple way to detect whether get_svn_revision or get_git_hash failed to detect (before you'd need to strncmp for "unknown" or similars) Signed-off-by: shennetsind --- src/common/core.c | 40 ++++++++++++++++++++++++++++++++++++---- src/common/core.h | 5 ++++- src/map/pc.c | 11 +++++++++-- src/map/script.c | 6 +++--- 4 files changed, 52 insertions(+), 10 deletions(-) (limited to 'src/common/core.c') diff --git a/src/common/core.c b/src/common/core.c index 42cdfa7cd..d1a374b29 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -254,17 +254,46 @@ const char* get_svn_revision(void) } // fallback - snprintf(svn_version_buffer, sizeof(svn_version_buffer), "Unknown"); + svn_version_buffer[0] = HERC_UNKNOWN_VER; return svn_version_buffer; } #endif - +/* whats our origin */ +#define GIT_ORIGIN "master" +/* Grabs the hash from the last time the user updated his working copy (last pull) */ +const char *get_git_hash (void) { + static char HerculesGitHash[41] = "";//Sha(40) + 1 + FILE *fp; + + if( HerculesGitHash[0] != '\0' ) + return HerculesGitHash; + + if ( (fp = fopen (".git/refs/remotes/origin/"GIT_ORIGIN, "r")) != NULL) { + char line[64]; + char *rev = malloc (sizeof (char) * 50); + + if (fgets (line, sizeof (line), fp) && sscanf (line, "%s", rev)) + snprintf (HerculesGitHash, sizeof (HerculesGitHash), "%s", rev); + + free (rev); + fclose (fp); + } else { + HerculesGitHash[0] = HERC_UNKNOWN_VER; + } + + if (! (*HerculesGitHash)) { + HerculesGitHash[0] = HERC_UNKNOWN_VER; + } + + return HerculesGitHash; +} /*====================================== * CORE : Display title * ASCII By CalciumKid 1/12/2011 *--------------------------------------*/ static void display_title(void) { - //ClearScreen(); // clear screen and go up/left (0, 0 position in text) + const char* svn = get_svn_revision(); + const char* git = get_git_hash(); ShowMessage("\n"); ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); @@ -279,7 +308,10 @@ static void display_title(void) { ShowMessage(""CL_BG_RED" "CL_BT_WHITE" http://hercules.ws/board/ "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); ShowMessage(""CL_BG_RED" "CL_BT_WHITE" "CL_BG_RED""CL_CLL""CL_NORMAL"\n"); - //ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'.\n", get_svn_revision()); + if( git[0] != HERC_UNKNOWN_VER ) + ShowInfo("Git Hash: '"CL_WHITE"%s"CL_RESET"'\n", git); + else if( svn[0] != HERC_UNKNOWN_VER ) + ShowInfo("SVN Revision: '"CL_WHITE"%s"CL_RESET"'\n", svn); } // Warning if executed as superuser (root) diff --git a/src/common/core.h b/src/common/core.h index f619d821f..8007e6036 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -16,6 +16,8 @@ extern char **arg_v; extern int buildbotflag; #endif +#define HERC_UNKNOWN_VER '\x02' + /// @see E_CORE_ST extern int runflag; extern char *SERVER_NAME; @@ -31,7 +33,8 @@ enum { extern char SERVER_TYPE; extern int parse_console(const char* buf); -extern const char *get_svn_revision(void); +const char *get_svn_revision(void); +const char *get_git_hash (void); extern int do_init(int,char**); extern void set_server_type(void); extern void do_abort(void); diff --git a/src/map/pc.c b/src/map/pc.c index 1bc37040e..e544fdd53 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1058,9 +1058,16 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim if( !changing_mapservers ) { - if (battle_config.display_version == 1){ + if (battle_config.display_version == 1) { + const char* svn = get_svn_revision(); + const char* git = get_git_hash(); char buf[256]; - sprintf(buf, "SVN version: %s", get_svn_revision()); + if( git[0] != HERC_UNKNOWN_VER ) + sprintf(buf,"Git Hash: %s", git); + else if( svn[0] != HERC_UNKNOWN_VER ) + sprintf(buf,"SVN Revision: %s", svn); + else + sprintf(buf,"Unknown Version"); clif_displaymessage(sd->fd, buf); } diff --git a/src/map/script.c b/src/map/script.c index 83b6c1a68..fe00599a6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -16992,10 +16992,10 @@ BUILDIN_FUNC(is_function) { * get_revision() -> retrieves the current svn revision (if available) **/ BUILDIN_FUNC(get_revision) { - const char * revision; + const char *svn = get_svn_revision(); - if ( (revision = get_svn_revision()) != 0 ) - script_pushint(st,atoi(revision)); + if ( svn[0] != HERC_UNKNOWN_VER ) + script_pushint(st,atoi(svn)); else script_pushint(st,-1);//unknown -- cgit v1.2.3-70-g09d2 From 2a83c9fb013e93fb16c34319f329be183da38d47 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 15 Feb 2013 21:05:36 -0200 Subject: Modified GIT_ORIGIN macro Made it possible to modify the whole path, making it flexible to users with customised repositories -- special thanks to Trojal Signed-off-by: shennetsind --- src/common/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/core.c') diff --git a/src/common/core.c b/src/common/core.c index d1a374b29..73416497d 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -259,7 +259,7 @@ const char* get_svn_revision(void) } #endif /* whats our origin */ -#define GIT_ORIGIN "master" +#define GIT_ORIGIN "refs/remotes/origin/master" /* Grabs the hash from the last time the user updated his working copy (last pull) */ const char *get_git_hash (void) { static char HerculesGitHash[41] = "";//Sha(40) + 1 @@ -268,7 +268,7 @@ const char *get_git_hash (void) { if( HerculesGitHash[0] != '\0' ) return HerculesGitHash; - if ( (fp = fopen (".git/refs/remotes/origin/"GIT_ORIGIN, "r")) != NULL) { + if ( (fp = fopen (".git/"GIT_ORIGIN, "r")) != NULL) { char line[64]; char *rev = malloc (sizeof (char) * 50); -- cgit v1.2.3-70-g09d2 From dac7186c370db4fa7d15fc0d223a6cfecb0e810b Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sat, 16 Feb 2013 19:43:15 -0200 Subject: Updating the Headers across source files And adding missing ones. Signed-off-by: shennetsind --- src/char/char.c | 5 +++-- src/char/int_guild.c | 2 +- src/char/int_pet.c | 2 +- src/common/core.c | 2 +- src/common/core.h | 2 +- src/common/mapindex.c | 2 +- src/common/sql.c | 2 +- src/common/sql.h | 2 +- src/login/login.c | 2 +- src/map/battle.c | 2 +- src/map/battle.h | 2 +- src/map/chrif.c | 2 +- src/map/clif.c | 2 +- src/map/elemental.c | 2 +- src/map/homunculus.c | 2 +- src/map/map.c | 2 +- src/map/map.h | 2 +- src/map/mercenary.c | 2 +- src/map/mob.c | 2 +- src/map/npc.c | 2 +- src/map/pc.c | 2 +- src/map/pc.h | 2 +- src/map/script.c | 2 +- src/map/skill.c | 2 +- src/map/status.c | 2 +- src/map/unit.c | 2 +- 26 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src/common/core.c') diff --git a/src/char/char.c b/src/char/char.c index b6c88623c..e7220aa36 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/cbasetypes.h" #include "../common/core.h" diff --git a/src/char/int_guild.c b/src/char/int_guild.c index e25ebd902..7c2086722 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 7a6c217f9..311ccd4be 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/common/core.c b/src/common/core.c index 73416497d..4495cf1a2 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/common/core.h b/src/common/core.h index dc4db6004..ccdfa6c35 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 685af641c..edf9f26f8 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/common/sql.c b/src/common/sql.c index c0ab19e4e..3df9bc1c5 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/common/sql.h b/src/common/sql.h index ebbd1711f..319581504 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/login/login.c b/src/login/login.c index 984326532..1ced8cb93 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/battle.c b/src/map/battle.c index a6605da5e..cfb3df52e 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/battle.h b/src/map/battle.h index e3a0a51ab..14bd70fee 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/chrif.c b/src/map/chrif.c index 06eef0564..573fd8501 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/clif.c b/src/map/clif.c index 7b4025b9d..ed2044127 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/elemental.c b/src/map/elemental.c index 33ef4d1b9..453845288 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 92868c7c7..6cc671526 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/map.c b/src/map/map.c index 901234687..c02506073 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/map.h b/src/map/map.h index 861a55d0a..38d9726cb 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/mercenary.c b/src/map/mercenary.c index a97651b87..665e6aeac 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/mob.c b/src/map/mob.c index 4f28923e9..b85238899 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/npc.c b/src/map/npc.c index 671b4485a..d734381af 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/pc.c b/src/map/pc.c index ad779a268..77b9948c4 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/pc.h b/src/map/pc.h index 6e56a612e..1b00b7191 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/script.c b/src/map/script.c index fe00599a6..dd137d575 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/skill.c b/src/map/skill.c index 86a03b64b..ccf25f911 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/status.c b/src/map/status.c index 97b7c61a1..b07625322 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams diff --git a/src/map/unit.c b/src/map/unit.c index 60de14093..4ca64d7f8 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1,4 +1,4 @@ -// Copyright (c) Hercules dev team, licensed under GNU GPL. +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. // See the LICENSE file // Portions Copyright (c) Athena Dev Teams -- cgit v1.2.3-70-g09d2 From 7e72f0cee8867837be53cb2119b610b00e9bd587 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Mon, 18 Feb 2013 00:30:28 -0300 Subject: Improvements all over the place Committing on the behalf of mkbu95 who is unable to do it himself, he coded it all and sent me the diff. Thanks mkbu95! Signed-off-by: shennetsind --- src/char/char.c | 14 +++++++------- src/char/int_guild.c | 11 ++++++----- src/common/core.c | 2 +- src/common/grfio.c | 16 +++++++++------- src/common/raconf.c | 6 +++--- src/common/socket.c | 6 +++--- src/login/account_sql.c | 2 +- src/login/login.c | 7 ++++--- src/map/atcommand.c | 43 ++++++++++++++++++++++--------------------- src/map/battle.c | 11 ++++++----- src/map/chat.c | 4 ++-- src/map/chrif.c | 3 ++- src/map/clif.c | 16 ++++++++-------- src/map/guild.c | 2 +- src/map/homunculus.c | 6 +++--- src/map/itemdb.c | 2 +- src/map/map.c | 4 ++-- src/map/mob.c | 20 ++++++++------------ src/map/npc.c | 14 ++++++++------ src/map/party.c | 5 ++--- src/map/pc.c | 33 ++++++++++++++++++--------------- src/map/pc_groups.c | 2 +- src/map/pet.c | 6 ++---- src/map/script.c | 15 ++++++++------- src/map/skill.c | 21 ++++++++++++--------- 25 files changed, 140 insertions(+), 131 deletions(-) (limited to 'src/common/core.c') diff --git a/src/char/char.c b/src/char/char.c index e7220aa36..cd1b1da66 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2833,8 +2833,6 @@ int parse_frommap(int fd) if( RFIFOREST(fd) < 18 ) return 0; { - struct auth_node* node; - int account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); uint32 login_id2 = RFIFOL(fd,10); @@ -2851,6 +2849,8 @@ int parse_frommap(int fd) } else { + struct auth_node* node; + // create temporary auth entry CREATE(node, struct auth_node, 1); node->account_id = account_id; @@ -2880,7 +2880,6 @@ int parse_frommap(int fd) return 0; { int map_id, map_fd = -1; - struct online_char_data* data; struct mmo_charstatus* char_data; struct mmo_charstatus char_dat; @@ -2898,6 +2897,7 @@ int parse_frommap(int fd) session_isActive(map_fd) && char_data ) { //Send the map server the auth of this player. + struct online_char_data* data; struct auth_node* node; //Update the "last map" as this is where the player must be spawned on the new map server. @@ -4571,25 +4571,25 @@ int char_config_read(const char* cfgName) safestrncpy(wisp_server_name, w2, sizeof(wisp_server_name)); } } else if (strcmpi(w1, "login_ip") == 0) { - char ip_str[16]; login_ip = host2ip(w2); if (login_ip) { + char ip_str[16]; safestrncpy(login_ip_str, w2, sizeof(login_ip_str)); ShowStatus("Login server IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str)); } } else if (strcmpi(w1, "login_port") == 0) { login_port = atoi(w2); } else if (strcmpi(w1, "char_ip") == 0) { - char ip_str[16]; char_ip = host2ip(w2); - if (char_ip){ + if (char_ip) { + char ip_str[16]; safestrncpy(char_ip_str, w2, sizeof(char_ip_str)); ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(char_ip, ip_str)); } } else if (strcmpi(w1, "bind_ip") == 0) { - char ip_str[16]; bind_ip = host2ip(w2); if (bind_ip) { + char ip_str[16]; safestrncpy(bind_ip_str, w2, sizeof(bind_ip_str)); ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str)); } diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 7c2086722..46bba63db 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -217,8 +217,8 @@ int inter_guild_tosql(struct guild *g,int flag) strcat(t_info, " level"); if( add_comma ) StringBuf_AppendStr(&buf, ", "); - else - add_comma = true; + //else //last condition using add_coma setting + // add_comma = true; StringBuf_Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member); } StringBuf_Printf(&buf, " WHERE `guild_id`=%d", g->guild_id); @@ -509,7 +509,7 @@ struct guild * inter_guild_fromsql(int guild_id) { int id; Sql_GetData(sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE; - if( id < 0 && id >= MAX_GUILDSKILL ) + if( id < 0 || id >= MAX_GUILDSKILL ) continue;// invalid guild skill Sql_GetData(sql_handle, 1, &data, NULL); g->skill[id].lv = atoi(data); } @@ -604,7 +604,7 @@ static bool exp_guild_parse_row(char* split[], int column, int current) { unsigned int exp = (unsigned int)atol(split[0]); - if (exp < 0 || exp >= UINT_MAX) { + if (exp >= UINT_MAX) { ShowError("exp_guild: Invalid exp %d at line %d\n", exp, current); return false; } @@ -1262,7 +1262,7 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) // Delete member from guild int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes) { - int i, j; + int i; struct guild* g = inter_guild_fromsql(guild_id); if( g == NULL ) @@ -1285,6 +1285,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in if( flag ) { // Write expulsion reason // Find an empty slot + int j; ARR_FIND( 0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0 ); if( j == MAX_GUILDEXPULSION ) { diff --git a/src/common/core.c b/src/common/core.c index 4495cf1a2..b004d2b96 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -272,7 +272,7 @@ const char *get_git_hash (void) { char line[64]; char *rev = malloc (sizeof (char) * 50); - if (fgets (line, sizeof (line), fp) && sscanf (line, "%s", rev)) + if (fgets (line, sizeof (line), fp) && sscanf (line, "%50s", rev)) snprintf (HerculesGitHash, sizeof (HerculesGitHash), "%s", rev); free (rev); diff --git a/src/common/grfio.c b/src/common/grfio.c index 8f430cfb9..cc2f866f7 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -393,12 +393,12 @@ void* grfio_reads(const char* fname, int* size) FILELIST* entry = filelist_find(fname); if( entry == NULL || entry->gentry <= 0 ) {// LocalFileCheck char lfname[256]; - int declen; FILE* in; grfio_localpath_create(lfname, sizeof(lfname), ( entry && entry->fnd ) ? entry->fnd : fname); in = fopen(lfname, "rb"); if( in != NULL ) { + int declen; fseek(in,0,SEEK_END); declen = ftell(in); fseek(in,0,SEEK_SET); @@ -475,14 +475,14 @@ static char* decode_filename(unsigned char* buf, int len) /// @return true if the file should undergo full mode 0 decryption, and true otherwise. static bool isFullEncrypt(const char* fname) { - static const char extensions[4][5] = { ".gnd", ".gat", ".act", ".str" }; - size_t i; - const char* ext = strrchr(fname, '.'); - if( ext != NULL ) + if( ext != NULL ) { + static const char extensions[4][5] = { ".gnd", ".gat", ".act", ".str" }; + size_t i; for( i = 0; i < ARRAYLENGTH(extensions); ++i ) if( strcmpi(ext, extensions[i]) == 0 ) return false; + } return true; } @@ -492,7 +492,7 @@ static bool isFullEncrypt(const char* fname) /// @param gentry index of the grf file name in the gentry_table static int grfio_entryread(const char* grfname, int gentry) { - long grf_size,list_size; + long grf_size; unsigned char grf_header[0x2e]; int entry,entrys,ofs,grf_version; unsigned char *grf_filelist; @@ -518,6 +518,7 @@ static int grfio_entryread(const char* grfname, int gentry) grf_version = getlong(grf_header+0x2a) >> 8; if( grf_version == 0x01 ) {// ****** Grf version 01xx ****** + long list_size; list_size = grf_size - ftell(fp); grf_filelist = (unsigned char *) aMalloc(list_size); if(fread(grf_filelist,1,list_size,fp) != list_size) { ShowError("Couldn't read all grf_filelist element of %s \n", grfname); } @@ -678,7 +679,7 @@ static bool grfio_parse_restable_row(const char* row) static void grfio_resourcecheck(void) { char restable[256]; - char *ptr, *buf; + char *buf; int size; FILE* fp; int i = 0; @@ -705,6 +706,7 @@ static void grfio_resourcecheck(void) buf = (char *)grfio_reads("data\\resnametable.txt", &size); if( buf != NULL ) { + char *ptr; buf[size] = '\0'; ptr = buf; diff --git a/src/common/raconf.c b/src/common/raconf.c index 2703560ff..f7d1284b7 100644 --- a/src/common/raconf.c +++ b/src/common/raconf.c @@ -41,12 +41,11 @@ struct conf_value{ static struct conf_value *makeValue(const char *key, char *val, size_t val_len){ struct conf_value *v; - char *p; - size_t sz; +/* size_t sz; sz = sizeof(struct conf_value); if(val_len >= sizeof(v->strval)) - sz += (val_len - sizeof(v->strval) + 1); + sz += (val_len - sizeof(v->strval) + 1);*/ v = (struct conf_value*)aCalloc(1, sizeof(struct conf_value)); if(v == NULL){ @@ -106,6 +105,7 @@ static struct conf_value *makeValue(const char *key, char *val, size_t val_len){ }else if( *val >='0' && *val <= '9'){ // begins with normal digit, so assume its dec. // is it float? bool is_float = false; + char *p; for(p = val; *p != '\0'; p++){ if(*p == '.'){ diff --git a/src/common/socket.c b/src/common/socket.c index 6977d4257..72633cf2b 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1017,14 +1017,14 @@ int access_ipmask(const char* str, AccessControl* acc) { uint32 ip; uint32 mask; - unsigned int a[4]; - unsigned int m[4]; - int n; if( strcmp(str,"all") == 0 ) { ip = 0; mask = 0; } else { + unsigned int a[4]; + unsigned int m[4]; + int n; if( ((n=sscanf(str,"%u.%u.%u.%u/%u.%u.%u.%u",a,a+1,a+2,a+3,m,m+1,m+2,m+3)) != 8 && // not an ip + standard mask (n=sscanf(str,"%u.%u.%u.%u/%u",a,a+1,a+2,a+3,m)) != 5 && // not an ip + bit mask (n=sscanf(str,"%u.%u.%u.%u",a,a+1,a+2,a+3)) != 4 ) || // not an ip diff --git a/src/login/account_sql.c b/src/login/account_sql.c index ae80163af..f89147334 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -486,7 +486,6 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self; AccountDB_SQL* db = (AccountDB_SQL*)iter->db; Sql* sql_handle = db->accounts; - int account_id; char* data; // get next account ID @@ -501,6 +500,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, NULL) && data != NULL ) {// get account data + int account_id; account_id = atoi(data); if( mmo_auth_fromsql(db, acc, account_id) ) { diff --git a/src/login/login.c b/src/login/login.c index 1ced8cb93..54f066b53 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1606,10 +1606,11 @@ int login_config_read(const char* cfgName) ShowInfo("Console Silent Setting: %d\n", atoi(w2)); } else if( !strcmpi(w1, "bind_ip") ) { - char ip_str[16]; login_config.login_ip = host2ip(w2); - if( login_config.login_ip ) + if( login_config.login_ip ) { + char ip_str[16]; ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_config.login_ip, ip_str)); + } } else if( !strcmpi(w1, "login_port") ) { login_config.login_port = (uint16)atoi(w2); @@ -1654,10 +1655,10 @@ int login_config_read(const char* cfgName) else if(!strcmpi(w1, "client_hash")) { int group = 0; char md5[33]; - int i; if (sscanf(w2, "%d, %32s", &group, md5) == 2) { struct client_hash_node *nnode; + int i; CREATE(nnode, struct client_hash_node, 1); for (i = 0; i < 32; i += 2) { diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 320ca83ff..ed42fdad4 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -920,7 +920,7 @@ ACMD_FUNC(option) if (!message || !*message || sscanf(message, "%d %d %d", ¶m1, ¶m2, ¶m3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {// failed to match the parameters so inform the user of the options - const char* text = NULL; + const char* text; // attempt to find the setting information for this command text = atcommand_help_string( command ); @@ -1230,8 +1230,6 @@ ACMD_FUNC(item2) int item_id, number = 0; int identify = 0, refine = 0, attr = 0; int c1 = 0, c2 = 0, c3 = 0, c4 = 0; - int flag = 0; - int loop, get_count, i; nullpo_retr(-1, sd); memset(item_name, '\0', sizeof(item_name)); @@ -1254,6 +1252,8 @@ ACMD_FUNC(item2) item_id = item_data->nameid; if (item_id > 500) { + int flag = 0; + int loop, get_count, i; loop = 1; get_count = number; if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR || @@ -2161,7 +2161,6 @@ ACMD_FUNC(produce) { char item_name[100]; int item_id, attribute = 0, star = 0; - int flag = 0; struct item_data *item_data; struct item tmp_item; nullpo_retr(-1, sd); @@ -2186,6 +2185,7 @@ ACMD_FUNC(produce) item_id = item_data->nameid; if (itemdb_isequip2(item_data)) { + int flag = 0; if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE) attribute = ATTRIBUTE_NORMAL; if (star < MIN_STAR || star > MAX_STAR) @@ -2822,7 +2822,7 @@ ACMD_FUNC(char_ban) memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) { + if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) { clif_displaymessage(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish