summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-08-07 03:39:13 +0200
committerHaru <haru@dotalux.com>2014-08-07 05:37:38 +0200
commitc45e3fa9793a273a0eab40d1626bcda7d710552c (patch)
tree4f6c9d47770a15c8cbfe065f7ee9203f77e57022 /src/map
parentcaf89724767465ecf339c391bb6d7a937d563fb2 (diff)
downloadhercules-c45e3fa9793a273a0eab40d1626bcda7d710552c.tar.gz
hercules-c45e3fa9793a273a0eab40d1626bcda7d710552c.tar.bz2
hercules-c45e3fa9793a273a0eab40d1626bcda7d710552c.tar.xz
hercules-c45e3fa9793a273a0eab40d1626bcda7d710552c.zip
Corrected several format-string errors through the code
- Functions that expect a printf-style format string are now marked as such, so that gcc/clang will emit a warning warn you if you mismatch format string and arguments. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c212
-rw-r--r--src/map/chrif.c4
-rw-r--r--src/map/clif.c54
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/intif.c66
-rw-r--r--src/map/itemdb.c17
-rw-r--r--src/map/log.c6
-rw-r--r--src/map/map.c49
-rw-r--r--src/map/mob.c8
-rw-r--r--src/map/npc.c7
-rw-r--r--src/map/pc.c117
-rw-r--r--src/map/script.c43
-rw-r--r--src/map/skill.c4
-rw-r--r--src/map/status.c16
14 files changed, 310 insertions, 295 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index e22e2101c..7e1b53a6f 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -108,7 +108,7 @@ bool msg_config_read(const char *cfg_name, bool allow_override) {
while(fgets(line, sizeof(line), fp)) {
if (line[0] == '/' && line[1] == '/')
continue;
- if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
+ if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2)
continue;
if (strcmpi(w1, "import") == 0) {
@@ -8640,7 +8640,7 @@ ACMD(join) {
struct hChSysCh *channel = NULL;
char name[HCHSYS_NAME_LENGTH], pass[HCHSYS_NAME_LENGTH];
- if( !message || !*message || sscanf(message, "%s %s", name, pass) < 1 ) {
+ if (!message || !*message || sscanf(message, "%19s %19s", name, pass) < 1) {
sprintf(atcmd_output, msg_txt(1399),command); // Unknown Channel (usage: %s <#channel_name>)
clif->message(fd, atcmd_output);
return false;
@@ -8767,24 +8767,25 @@ ACMD(channel) {
unsigned char k = 0;
sub1[0] = sub2[0] = sub3[0] = '\0';
- if( !message || !*message || sscanf(message, "%s %s %s %s", subcmd, sub1, sub2, sub3) < 1 ) {
+ if (!message || !*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) {
atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ));
return true;
}
- if( strcmpi(subcmd,"create") == 0 && ( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) ) {
- if( sub1[0] != '#' ) {
+ if (strcmpi(subcmd,"create") == 0 && (hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) {
+ // sub1 = channel name; sub2 = password; sub3 = unused
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
- } else if ( strlen(sub1) < 3 || strlen(sub1) > HCHSYS_NAME_LENGTH ) {
+ } else if (strlen(sub1) < 3 || strlen(sub1) > HCHSYS_NAME_LENGTH) {
sprintf(atcmd_output, msg_txt(1406), HCHSYS_NAME_LENGTH);// Channel length must be between 3 and %d
clif->message(fd, atcmd_output);
return false;
- } else if ( sub3[0] != '\0' ) {
+ } else if (sub3[0] != '\0') {
clif->message(fd, msg_txt(1408)); // Channel password may not contain spaces
return false;
}
- if( strcmpi(sub1 + 1,hChSys.local_name) == 0 || strcmpi(sub1 + 1,hChSys.ally_name) == 0 || strdb_exists(clif->channel_db, sub1 + 1) ) {
+ if (strcmpi(sub1 + 1,hChSys.local_name) == 0 || strcmpi(sub1 + 1,hChSys.ally_name) == 0 || strdb_exists(clif->channel_db, sub1 + 1)) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
@@ -8803,11 +8804,11 @@ ACMD(channel) {
}
clif->chsys_join(channel,sd);
-
- } else if ( strcmpi(subcmd,"list") == 0 ) {
- if( sub1[0] != '\0' && strcmpi(sub1,"colors") == 0 ) {
+ } else if (strcmpi(subcmd,"list") == 0) {
+ // sub1 = list type; sub2 = unused; sub3 = unused
+ if (sub1[0] != '\0' && strcmpi(sub1,"colors") == 0) {
char mout[40];
- for( k = 0; k < hChSys.colors_count; k++ ) {
+ for (k = 0; k < hChSys.colors_count; k++) {
unsigned short msg_len = 1;
msg_len += sprintf(mout, "[ %s list colors ] : %s",command,hChSys.colors_name[k]);
@@ -8823,48 +8824,48 @@ ACMD(channel) {
DBIterator *iter = db_iterator(clif->channel_db);
bool show_all = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false;
clif->message(fd, msg_txt(1410)); // -- Public Channels
- if( hChSys.local ) {
+ if (hChSys.local) {
sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
- if( hChSys.ally && sd->status.guild_id ) {
+ if (hChSys.ally && sd->status.guild_id) {
struct guild *g = sd->guild;
if( !g ) { dbi_destroy(iter); return false; }
sprintf(atcmd_output, msg_txt(1409), hChSys.ally_name, db_size(g->channel->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
- for(channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
- if( show_all || channel->type == hChSys_PUBLIC || channel->type == hChSys_IRC ) {
+ for (channel = dbi_first(iter); dbi_exists(iter); channel = dbi_next(iter)) {
+ if (show_all || channel->type == hChSys_PUBLIC || channel->type == hChSys_IRC) {
sprintf(atcmd_output, msg_txt(1409), channel->name, db_size(channel->users));// - #%s ( %d users )
clif->message(fd, atcmd_output);
}
}
dbi_destroy(iter);
}
- } else if ( strcmpi(subcmd,"setcolor") == 0 ) {
-
- if( sub1[0] != '#' ) {
+ } else if (strcmpi(subcmd,"setcolor") == 0) {
+ // sub1 = channel name; sub2 = color; sub3 = unused
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
- if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
- for( k = 0; k < hChSys.colors_count; k++ ) {
- if( strcmpi(sub2,hChSys.colors_name[k]) == 0 )
+ for (k = 0; k < hChSys.colors_count; k++) {
+ if (strcmpi(sub2, hChSys.colors_name[k]) == 0)
break;
}
- if( k == hChSys.colors_count ) {
+ if (k == hChSys.colors_count) {
sprintf(atcmd_output, msg_txt(1411), sub2);// Unknown color '%s'
clif->message(fd, atcmd_output);
return false;
@@ -8872,110 +8873,113 @@ ACMD(channel) {
channel->color = k;
sprintf(atcmd_output, msg_txt(1413),sub1,hChSys.colors_name[k]);// '%s' channel color updated to '%s'
clif->message(fd, atcmd_output);
- } else if ( strcmpi(subcmd,"leave") == 0 ) {
-
- if( sub1[0] != '#' ) {
+ } else if (strcmpi(subcmd,"leave") == 0) {
+ // sub1 = channel name; sub2 = unused; sub3 = unused
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- for(k = 0; k < sd->channel_count; k++) {
- if( strcmpi(sub1+1,sd->channels[k]->name) == 0 )
+ for (k = 0; k < sd->channel_count; k++) {
+ if (strcmpi(sub1+1,sd->channels[k]->name) == 0)
break;
}
- if( k == sd->channel_count ) {
+ if (k == sd->channel_count) {
sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel
clif->message(fd, atcmd_output);
return false;
}
- if( sd->channels[k]->type == hChSys_ALLY ) {
+ if (sd->channels[k]->type == hChSys_ALLY) {
do {
- for(k = 0; k < sd->channel_count; k++) {
- if( sd->channels[k]->type == hChSys_ALLY ) {
+ for (k = 0; k < sd->channel_count; k++) {
+ if (sd->channels[k]->type == hChSys_ALLY) {
clif->chsys_left(sd->channels[k],sd);
break;
}
}
- } while( k != sd->channel_count );
- } else
+ } while (k != sd->channel_count);
+ } else {
clif->chsys_left(sd->channels[k],sd);
+ }
sprintf(atcmd_output, msg_txt(1426),sub1); // You've left the '%s' channel
clif->message(fd, atcmd_output);
- } else if ( strcmpi(subcmd,"bindto") == 0 ) {
-
- if( sub1[0] != '#' ) {
+ } else if (strcmpi(subcmd,"bindto") == 0) {
+ // sub1 = channel name; sub2 = unused; sub3 = unused
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- for(k = 0; k < sd->channel_count; k++) {
- if( strcmpi(sub1+1,sd->channels[k]->name) == 0 )
+ for (k = 0; k < sd->channel_count; k++) {
+ if (strcmpi(sub1+1,sd->channels[k]->name) == 0)
break;
}
- if( k == sd->channel_count ) {
+ if (k == sd->channel_count) {
sprintf(atcmd_output, msg_txt(1425),sub1);// You're not part of the '%s' channel
clif->message(fd, atcmd_output);
return false;
}
sd->gcbind = sd->channels[k];
- sprintf(atcmd_output, msg_txt(1431),sub1); // Your global chat is now binded to the '%s' channel
+ sprintf(atcmd_output, msg_txt(1431),sub1); // Your global chat is now bound to the '%s' channel
clif->message(fd, atcmd_output);
- } else if ( strcmpi(subcmd,"unbind") == 0 ) {
-
- if( sd->gcbind == NULL ) {
- clif->message(fd, msg_txt(1432));// Your global chat is not binded to any channel
+ } else if (strcmpi(subcmd,"unbind") == 0) {
+ // sub1 = unused; sub2 = unused; sub3 = unused
+ if (sd->gcbind == NULL) {
+ clif->message(fd, msg_txt(1432));// Your global chat is not bound to any channel
return false;
}
- sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is now unbinded from the '#%s' channel
+ sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is no longer bound to the '#%s' channel
clif->message(fd, atcmd_output);
sd->gcbind = NULL;
- } else if ( strcmpi(subcmd,"ban") == 0 ) {
+ } else if (strcmpi(subcmd,"ban") == 0) {
+ // sub1 = channel name; sub2 = unused; sub3 = unused
struct map_session_data *pl_sd = NULL;
struct hChSysBanEntry *entry = NULL;
+ char sub4[NAME_LENGTH]; ///< player name
- if( sub1[0] != '#' ) {
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
- if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
- if (!message || !*message || sscanf(message, "%s %s %24[^\n]", subcmd, sub1, sub2) < 1) {
- sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found
+ if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
+ sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
}
- if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) {
- sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found
+ if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
+ sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
}
- if( pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if (pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN)) {
clif->message(fd, msg_txt(1464)); // Ban failed, not possible to ban this user.
return false;
}
- if( channel->banned && idb_exists(channel->banned,pl_sd->status.account_id) ) {
+ if (channel->banned && idb_exists(channel->banned,pl_sd->status.account_id)) {
sprintf(atcmd_output, msg_txt(1465), pl_sd->status.name);// Player '%s' is already banned from this channel
clif->message(fd, atcmd_output);
return false;
}
- if( !channel->banned )
+ if (!channel->banned)
channel->banned = idb_alloc(DB_OPT_BASE|DB_OPT_ALLOW_NULL_DATA|DB_OPT_RELEASE_DATA);
CREATE(entry, struct hChSysBanEntry, 1);
@@ -8988,39 +8992,47 @@ ACMD(channel) {
sprintf(atcmd_output, msg_txt(1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel
clif->message(fd, atcmd_output);
- } else if ( strcmpi(subcmd,"unban") == 0 ) {
+ } else if (strcmpi(subcmd,"unban") == 0) {
+ // sub1 = channel name; sub2 = unused; sub3 = unused
struct map_session_data *pl_sd = NULL;
+ char sub4[NAME_LENGTH]; ///< player name
- if( sub1[0] != '#' ) {
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
- if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
- if( !channel->banned ) {
+ if (!channel->banned) {
sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
return false;
}
- if( sub2[0] == '\0' || ( pl_sd = map->nick2sd(sub2) ) == NULL ) {
- sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found
+ if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) {
+ sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found
+ clif->message(fd, atcmd_output);
+ return false;
+ }
+
+ if (sub4[0] == '\0' || (pl_sd = map->nick2sd(sub4)) == NULL) {
+ sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
}
- if( !idb_exists(channel->banned,pl_sd->status.account_id) ) {
+ if (!idb_exists(channel->banned,pl_sd->status.account_id)) {
sprintf(atcmd_output, msg_txt(1440), pl_sd->status.name);// Player '%s' is not banned from this channel
clif->message(fd, atcmd_output);
return false;
@@ -9028,32 +9040,33 @@ ACMD(channel) {
idb_remove(channel->banned, pl_sd->status.account_id);
- if( !db_size(channel->banned) ) {
+ if (!db_size(channel->banned)) {
db_destroy(channel->banned);
channel->banned = NULL;
}
sprintf(atcmd_output, msg_txt(1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel
clif->message(fd, atcmd_output);
- } else if ( strcmpi(subcmd,"unbanall") == 0 ) {
- if( sub1[0] != '#' ) {
+ } else if (strcmpi(subcmd,"unbanall") == 0) {
+ // sub1 = channel name; sub2 = unused; sub3 = unused
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
- if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
- if( !channel->banned ) {
+ if (!channel->banned) {
sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
return false;
@@ -9064,29 +9077,30 @@ ACMD(channel) {
sprintf(atcmd_output, msg_txt(1442),sub1); // Removed all bans from '%s' channel
clif->message(fd, atcmd_output);
- } else if ( strcmpi(subcmd,"banlist") == 0 ) {
+ } else if (strcmpi(subcmd,"banlist") == 0) {
+ // sub1 = channel name; sub2 = unused; sub3 = unused
DBIterator *iter = NULL;
DBKey key;
DBData *data;
bool isA = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false;
- if( sub1[0] != '#' ) {
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
- if( channel->owner != sd->status.char_id && !isA ) {
+ if (channel->owner != sd->status.char_id && !isA) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
- if( !channel->banned ) {
+ if (!channel->banned) {
sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players
clif->message(fd, atcmd_output);
return false;
@@ -9096,10 +9110,10 @@ ACMD(channel) {
iter = db_iterator(channel->banned);
- for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
+ for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) {
struct hChSysBanEntry * entry = DB->data2ptr(data);
- if( !isA )
+ if (!isA)
sprintf(atcmd_output, msg_txt(1444), entry->name);// - %s %s
else
sprintf(atcmd_output, msg_txt(1445), entry->name, key.i);// - %s (%d)
@@ -9109,57 +9123,58 @@ ACMD(channel) {
dbi_destroy(iter);
- } else if ( strcmpi(subcmd,"setopt") == 0 ) {
+ } else if (strcmpi(subcmd,"setopt") == 0) {
+ // sub1 = channel name; sub2 = option name; sub3 = value
const char* opt_str[3] = {
"None",
"JoinAnnounce",
"MessageDelay",
};
- if( sub1[0] != '#' ) {
+ if (sub1[0] != '#') {
clif->message(fd, msg_txt(1405));// Channel name must start with a '#'
return false;
}
- if( !(channel = strdb_get(clif->channel_db, sub1 + 1)) ) {
+ if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) {
sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available
clif->message(fd, atcmd_output);
return false;
}
- if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s'
clif->message(fd, atcmd_output);
return false;
}
- if( sub2[0] == '\0' ) {
+ if (sub2[0] == '\0') {
clif->message(fd, msg_txt(1446));// You need to input a option
return false;
}
- for( k = 1; k < 3; k++ ) {
- if( strcmpi(sub2,opt_str[k]) == 0 )
+ for (k = 1; k < 3; k++) {
+ if (strcmpi(sub2,opt_str[k]) == 0)
break;
}
- if( k == 3 ) {
+ if (k == 3) {
sprintf(atcmd_output, msg_txt(1447), sub2);// '%s' is not a known channel option
clif->message(fd, atcmd_output);
clif->message(fd, msg_txt(1448)); // -- Available options
- for( k = 1; k < 3; k++ ) {
+ for (k = 1; k < 3; k++) {
sprintf(atcmd_output, msg_txt(1444), opt_str[k]);// - '%s'
clif->message(fd, atcmd_output);
}
return false;
}
- if( sub3[0] == '\0' ) {
- if ( k == hChSys_OPT_MSG_DELAY ) {
+ if (sub3[0] == '\0') {
+ if (k == hChSys_OPT_MSG_DELAY) {
sprintf(atcmd_output, msg_txt(1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10)
clif->message(fd, atcmd_output);
return false;
- } else if( channel->opt & k ) {
+ } else if (channel->opt & k) {
sprintf(atcmd_output, msg_txt(1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel setopt %s 0'
clif->message(fd, atcmd_output);
return false;
@@ -9171,13 +9186,13 @@ ACMD(channel) {
}
} else {
int v = atoi(sub3);
- if( k == hChSys_OPT_MSG_DELAY ) {
- if( v < 0 || v > 10 ) {
+ if (k == hChSys_OPT_MSG_DELAY) {
+ if (v < 0 || v > 10) {
sprintf(atcmd_output, msg_txt(1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10)
clif->message(fd, atcmd_output);
return false;
}
- if( v == 0 ) {
+ if (v == 0) {
channel->opt &=~ k;
channel->msg_delay = 0;
sprintf(atcmd_output, msg_txt(1453), opt_str[k],channel->name,v);// option '%s' is now disabled for channel '%s'
@@ -9191,8 +9206,8 @@ ACMD(channel) {
return true;
}
} else {
- if( v ) {
- if( channel->opt & k ) {
+ if (v) {
+ if (channel->opt & k) {
sprintf(atcmd_output, msg_txt(1449), opt_str[k],opt_str[k]); // option '%s' is already enabled, if you'd like to disable it type '@channel opt %s 0'
clif->message(fd, atcmd_output);
return false;
@@ -9202,7 +9217,7 @@ ACMD(channel) {
clif->message(fd, atcmd_output);
}
} else {
- if( !(channel->opt & k) ) {
+ if (!(channel->opt & k)) {
sprintf(atcmd_output, msg_txt(1454), opt_str[k],channel->name); // option '%s' is not enabled on channel '%s'
clif->message(fd, atcmd_output);
return false;
@@ -9216,7 +9231,6 @@ ACMD(channel) {
}
}
-
} else {
atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ));
}
@@ -10122,7 +10136,7 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command
idx = pcg->get_idx(group);
if (idx < 0 || idx >= sz) {
- ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%d]\n", idx, sz - 1);
+ ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%"PRIuS"]\n", idx, sz - 1);
continue;
}
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 54cc139f4..4c8cd747b 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -300,7 +300,7 @@ bool chrif_save(struct map_session_data *sd, int flag) {
// connects to char-server (plaintext)
void chrif_connect(int fd) {
- ShowStatus("Logging in to char server...\n", chrif->fd);
+ ShowStatus("Logging in to char server...\n");
WFIFOHEAD(fd,60);
WFIFOW(fd,0) = 0x2af8;
memcpy(WFIFOP(fd,2), chrif->userid, NAME_LENGTH);
@@ -576,7 +576,7 @@ void chrif_authok(int fd) {
//Check if both servers agree on the struct's size
if( RFIFOW(fd,2) - 25 != sizeof(struct mmo_charstatus) ) {
- ShowError("chrif_authok: Data size mismatch! %d != %d\n", RFIFOW(fd,2) - 25, sizeof(struct mmo_charstatus));
+ ShowError("chrif_authok: Data size mismatch! %d != %"PRIuS"\n", RFIFOW(fd,2) - 25, sizeof(struct mmo_charstatus));
return;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 9e105e4a9..e6a677a6f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -5645,16 +5645,17 @@ void clif_displaymessage2(const int fd, const char* mes) {
}
}
/* oh noo! another version of 0x8e! */
-void clif_displaymessage_sprintf(const int fd, const char* mes, ...) {
+void clif_displaymessage_sprintf(const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3)));
+void clif_displaymessage_sprintf(const int fd, const char *mes, ...) {
va_list ap;
- if( map->cpsd_active && fd == 0 ) {
+ if (map->cpsd_active && fd == 0) {
ShowInfo("HCP: ");
va_start(ap,mes);
vShowMessage_(MSG_NONE,mes,ap);
va_end(ap);
ShowMessage("\n");
- } else if ( fd > 0 ) {
+ } else if (fd > 0) {
int len = 1;
char *ptr;
@@ -5710,8 +5711,8 @@ void clif_GlobalMessage(struct block_list* bl, const char* message) {
len = strlen(message)+1;
- if( len > sizeof(buf)-8 ) {
- ShowWarning("clif_GlobalMessage: Truncating too long message '%s' (len=%d).\n", message, len);
+ if (len > sizeof(buf)-8) {
+ ShowWarning("clif_GlobalMessage: Truncating too long message '%s' (len=%"PRIuS").\n", message, len);
len = sizeof(buf)-8;
}
@@ -6743,9 +6744,9 @@ void clif_party_message(struct party_data* p, int account_id, const char* mes, i
if(i < MAX_PARTY){
unsigned char buf[1024];
- if( len > sizeof(buf)-8 )
- {
- ShowWarning("clif_party_message: Truncated message '%s' (len=%d, max=%d, party_id=%d).\n", mes, len, sizeof(buf)-8, p->party.party_id);
+ if (len > sizeof(buf)-8) {
+ ShowWarning("clif_party_message: Truncated message '%s' (len=%d, max=%"PRIuS", party_id=%d).\n",
+ mes, len, sizeof(buf)-8, p->party.party_id);
len = sizeof(buf)-8;
}
@@ -7858,13 +7859,11 @@ void clif_guild_message(struct guild *g,int account_id,const char *mes,int len)
struct map_session_data *sd;
uint8 buf[256];
- if( len == 0 )
- {
+ if (len == 0)
return;
- }
- else if( len > sizeof(buf)-5 )
- {
- ShowWarning("clif_guild_message: Truncated message '%s' (len=%d, max=%d, guild_id=%d).\n", mes, len, sizeof(buf)-5, g->guild_id);
+
+ if (len > sizeof(buf)-5) {
+ ShowWarning("clif_guild_message: Truncated message '%s' (len=%d, max=%"PRIuS", guild_id=%d).\n", mes, len, sizeof(buf)-5, g->guild_id);
len = sizeof(buf)-5;
}
@@ -8119,10 +8118,11 @@ void clif_disp_message(struct block_list* src, const char* mes, size_t len, enum
{
unsigned char buf[256];
- if( len == 0 ) {
+ if (len == 0)
return;
- } else if( len > sizeof(buf)-5 ) {
- ShowWarning("clif_disp_message: Truncated message '%s' (len=%d, max=%d, aid=%d).\n", mes, len, sizeof(buf)-5, src->id);
+
+ if (len > sizeof(buf)-5) {
+ ShowWarning("clif_disp_message: Truncated message '%s' (len=%"PRIuS", max=%"PRIuS", aid=%d).\n", mes, len, sizeof(buf)-5, src->id);
len = sizeof(buf)-5;
}
@@ -8394,8 +8394,8 @@ void clif_messagecolor(struct block_list* bl, unsigned int color, const char* ms
nullpo_retv(bl);
- if( msg_len > sizeof(buf)-12 ) {
- ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%u).\n", msg, msg_len);
+ if (msg_len > sizeof(buf)-12) {
+ ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%"PRIuS").\n", msg, msg_len);
msg_len = sizeof(buf)-12;
}
@@ -8744,7 +8744,7 @@ void clif_disp_overhead(struct block_list *bl, const char* mes)
size_t len_mes = strlen(mes)+1; //Account for \0
if (len_mes > sizeof(buf)-8) {
- ShowError("clif_disp_overhead: Message too long (length %d)\n", len_mes);
+ ShowError("clif_disp_overhead: Message too long (length %"PRIuS")\n", len_mes);
len_mes = sizeof(buf)-8; //Trunk it to avoid problems.
}
// send message to others
@@ -13151,8 +13151,9 @@ void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
if( !emblem_len || !sd->state.gmaster_flag )
return;
- if( !clif->validate_emblem(emblem, emblem_len) ) {
- ShowWarning("clif_parse_GuildChangeEmblem: Rejected malformed guild emblem (size=%lu, accound_id=%d, char_id=%d, guild_id=%d).\n", emblem_len, sd->status.account_id, sd->status.char_id, sd->status.guild_id);
+ if (!clif->validate_emblem(emblem, emblem_len)) {
+ ShowWarning("clif_parse_GuildChangeEmblem: Rejected malformed guild emblem (size=%u, accound_id=%d, char_id=%d, guild_id=%d).\n",
+ emblem_len, sd->status.account_id, sd->status.char_id, sd->status.guild_id);
return;
}
@@ -17749,8 +17750,8 @@ void clif_ShowScript(struct block_list* bl, const char* message) {
len = strlen(message)+1;
- if( len > sizeof(buf)-8 ) {
- ShowWarning("clif_ShowScript: Truncating too long message '%s' (len=%d).\n", message, len);
+ if (len > sizeof(buf)-8) {
+ ShowWarning("clif_ShowScript: Truncating too long message '%s' (len=%"PRIuS").\n", message, len);
len = sizeof(buf)-8;
}
@@ -18347,8 +18348,9 @@ int clif_parse(int fd) {
cmd = parse_cmd_func(fd,sd);
// filter out invalid / unsupported packets
- if( cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0 ) {
- ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x (0x%04x), %d bytes received), disconnecting session #%d.\n", cmd, RFIFOW(fd,0), RFIFOREST(fd), fd);
+ if (cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0) {
+ ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x (0x%04x), %"PRIuS" bytes received), disconnecting session #%d.\n",
+ cmd, RFIFOW(fd,0), RFIFOREST(fd), fd);
#ifdef DUMP_INVALID_PACKET
ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
#endif
diff --git a/src/map/clif.h b/src/map/clif.h
index 48316427f..e4de51a83 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -815,7 +815,7 @@ struct clif_interface {
void (*message) (const int fd, const char* mes);
void (*messageln) (const int fd, const char* mes);
/* message+s(printf) */
- void (*messages) (const int fd, const char* mes, ...);
+ void (*messages) (const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3)));
int (*colormes) (int fd, enum clif_colors color, const char* msg);
bool (*process_message) (struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_);
void (*wisexin) (struct map_session_data *sd,int type,int flag);
diff --git a/src/map/intif.c b/src/map/intif.c
index 432154f04..be82a7583 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1111,8 +1111,8 @@ void intif_parse_LoadGuildStorage(int fd)
ShowWarning("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n", flag?sd->status.account_id:0, flag?sd->status.char_id:0);
return;
}
- if( RFIFOW(fd,2)-13 != sizeof(struct guild_storage) ){
- ShowError("intif_parse_LoadGuildStorage: data size error %d %d\n",RFIFOW(fd,2)-13 , sizeof(struct guild_storage));
+ if (RFIFOW(fd,2)-13 != sizeof(struct guild_storage)) {
+ ShowError("intif_parse_LoadGuildStorage: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2)-13, sizeof(struct guild_storage));
gstor->storage_status = 0;
return;
}
@@ -1137,16 +1137,16 @@ void intif_parse_PartyCreated(int fd)
}
// Receive party info
-void intif_parse_PartyInfo(int fd)
-{
- if( RFIFOW(fd,2) == 12 ){
+void intif_parse_PartyInfo(int fd) {
+ if (RFIFOW(fd,2) == 12) {
ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8));
party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4));
return;
}
- if( RFIFOW(fd,2) != 8+sizeof(struct party) )
- ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party));
+ if (RFIFOW(fd,2) != 8+sizeof(struct party))
+ ShowError("intif: party info: data size mismatch (char_id=%d party_id=%d packet_len=%d expected_len=%"PRIuS")\n",
+ RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party));
party->recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4));
}
@@ -1195,13 +1195,14 @@ void intif_parse_GuildCreated(int fd) {
// ACK guild infos
void intif_parse_GuildInfo(int fd) {
- if(RFIFOW(fd,2) == 8) {
+ if (RFIFOW(fd,2) == 8) {
ShowWarning("intif: guild noinfo %d\n",RFIFOL(fd,4));
guild->recv_noinfo(RFIFOL(fd,4));
return;
}
- if( RFIFOW(fd,2)!=sizeof(struct guild)+4 )
- ShowError("intif: guild info : data size error Gid: %d recv size: %d Expected size: %d\n",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4);
+ if (RFIFOW(fd,2)!=sizeof(struct guild)+4)
+ ShowError("intif: guild info: data size mismatch - Gid: %d recv size: %d Expected size: %"PRIuS"\n",
+ RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild)+4);
guild->recv_info((struct guild *)RFIFOP(fd,4));
}
@@ -1295,8 +1296,9 @@ void intif_parse_GuildMemberInfoChanged(int fd) {
// ACK change of guild title
void intif_parse_GuildPosition(int fd) {
- if( RFIFOW(fd,2)!=sizeof(struct guild_position)+12 )
- ShowError("intif: guild info : data size error\n %d %d %d",RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
+ if (RFIFOW(fd,2)!=sizeof(struct guild_position)+12)
+ ShowError("intif: guild info: data size mismatch (%d) %d != %"PRIuS"\n",
+ RFIFOL(fd,4),RFIFOW(fd,2),sizeof(struct guild_position)+12);
guild->position_changed(RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12));
}
@@ -1345,9 +1347,9 @@ void intif_parse_RecvPetData(int fd) {
struct s_pet p;
int len;
len=RFIFOW(fd,2);
- if(sizeof(struct s_pet)!=len-9) {
- if(battle_config.etc_log)
- ShowError("intif: pet data: data size error %d %d\n",sizeof(struct s_pet),len-9);
+ if (sizeof(struct s_pet) != len-9) {
+ if (battle_config.etc_log)
+ ShowError("intif: pet data: data size mismatch %d != %"PRIuS"\n", len-9, sizeof(struct s_pet));
} else {
memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet));
pet->recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
@@ -1392,9 +1394,9 @@ void intif_parse_ChangeNameOk(int fd)
void intif_parse_CreateHomunculus(int fd) {
int len = RFIFOW(fd,2)-9;
- if(sizeof(struct s_homunculus)!=len) {
- if(battle_config.etc_log)
- ShowError("intif: create homun data: data size error %d != %d\n",sizeof(struct s_homunculus),len);
+ if (sizeof(struct s_homunculus) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: create homun data: data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_homunculus));
return;
}
homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8)) ;
@@ -1403,9 +1405,9 @@ void intif_parse_CreateHomunculus(int fd) {
void intif_parse_RecvHomunculusData(int fd) {
int len = RFIFOW(fd,2)-9;
- if(sizeof(struct s_homunculus)!=len) {
- if(battle_config.etc_log)
- ShowError("intif: homun data: data size error %d %d\n",sizeof(struct s_homunculus),len);
+ if (sizeof(struct s_homunculus) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: homun data: data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_homunculus));
return;
}
homun->recv_data(RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,9), RFIFOB(fd,8));
@@ -1571,7 +1573,7 @@ void intif_parse_MailInboxReceived(int fd) {
}
if (RFIFOW(fd,2) - 9 != sizeof(struct mail_data)) {
- ShowError("intif_parse_MailInboxReceived: data size error %d %d\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data));
+ ShowError("intif_parse_MailInboxReceived: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 9, sizeof(struct mail_data));
return;
}
@@ -1632,7 +1634,7 @@ void intif_parse_MailGetAttach(int fd) {
}
if (RFIFOW(fd,2) - 12 != sizeof(struct item)) {
- ShowError("intif_parse_MailGetAttach: data size error %d %d\n", RFIFOW(fd,2) - 16, sizeof(struct item));
+ ShowError("intif_parse_MailGetAttach: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 16, sizeof(struct item));
return;
}
@@ -1749,7 +1751,7 @@ void intif_parse_MailSend(int fd) {
bool fail;
if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) ) {
- ShowError("intif_parse_MailSend: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message));
+ ShowError("intif_parse_MailSend: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message));
return;
}
@@ -1838,8 +1840,8 @@ void intif_parse_AuctionRegister(int fd) {
struct map_session_data *sd;
struct auction_data auction;
- if( RFIFOW(fd,2) - 4 != sizeof(struct auction_data) ) {
- ShowError("intif_parse_AuctionRegister: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data));
+ if (RFIFOW(fd,2) - 4 != sizeof(struct auction_data)) {
+ ShowError("intif_parse_AuctionRegister: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2) - 4, sizeof(struct auction_data));
return;
}
@@ -1988,9 +1990,9 @@ int intif_mercenary_create(struct s_mercenary *merc)
void intif_parse_MercenaryReceived(int fd) {
int len = RFIFOW(fd,2) - 5;
- if( sizeof(struct s_mercenary) != len ) {
- if( battle_config.etc_log )
- ShowError("intif: create mercenary data size error %d != %d\n", sizeof(struct s_mercenary), len);
+ if (sizeof(struct s_mercenary) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: create mercenary data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_mercenary));
return;
}
@@ -2068,9 +2070,9 @@ int intif_elemental_create(struct s_elemental *ele)
void intif_parse_ElementalReceived(int fd) {
int len = RFIFOW(fd,2) - 5;
- if( sizeof(struct s_elemental) != len ) {
- if( battle_config.etc_log )
- ShowError("intif: create elemental data size error %d != %d\n", sizeof(struct s_elemental), len);
+ if (sizeof(struct s_elemental) != len) {
+ if (battle_config.etc_log)
+ ShowError("intif: create elemental data size mismatch %d != %"PRIuS"\n", len, sizeof(struct s_elemental));
return;
}
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 61b77748a..0d3146191 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -690,7 +690,7 @@ void itemdb_read_groups(void) {
libconfig->destroy(&item_group_conf);
aFree(gsize);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
}
/* [Ind/Hercules] - HCache for Packages */
void itemdb_write_cached_packages(const char *config_filename) {
@@ -883,7 +883,7 @@ bool itemdb_read_cached_packages(const char *config_filename) {
fclose(file);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"' ("CL_GREEN"C"CL_RESET").\n", pcount, config_filename);
+ ShowStatus("Done reading '"CL_WHITE"%hu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"' ("CL_GREEN"C"CL_RESET").\n", pcount, config_filename);
return true;
}
@@ -1091,7 +1091,8 @@ void itemdb_read_packages(void) {
for( r = 0; r < itemdb->packages[count].random_qty; r++ ) {
if( itemdb->packages[count].random_groups[r].random_qty == 1 ) {
//item packages don't stop looping until something comes out of them, so if you have only one item in it the drop is guaranteed.
- ShowWarning("itemdb_read_packages: in '%s' 'Random: %d' group has only 1 random option, drop rate will be 100%!\n",itemdb_name(itemdb->packages[count].id),r+1);
+ ShowWarning("itemdb_read_packages: in '%s' 'Random: %d' group has only 1 random option, drop rate will be 100%%!\n",
+ itemdb_name(itemdb->packages[count].id),r+1);
itemdb->packages[count].random_groups[r].random_list[0].rate = 10000;
}
}
@@ -1114,7 +1115,7 @@ void itemdb_read_packages(void) {
if( HCache->enabled )
itemdb->write_cached_packages(config_filename);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
}
void itemdb_read_chains(void) {
@@ -1182,7 +1183,7 @@ void itemdb_read_chains(void) {
else
itemdb->chain_cache[ECC_ORE] = i;
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
}
/**
@@ -1322,7 +1323,7 @@ void itemdb_read_combos() {
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"item_combo_db"CL_RESET"'.\n", count);
+ ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"item_combo_db"CL_RESET"'.\n", count);
return;
}
@@ -1940,7 +1941,7 @@ int itemdb_readdb_libconfig(const char *filename) {
duplicate[nameid] = true;
}
libconfig->destroy(&item_db_conf);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename);
return count;
}
@@ -1979,7 +1980,7 @@ int itemdb_readdb_sql(const char *tablename) {
// free the query result
SQL->FreeResult(map->mysql_handle);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, tablename);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, tablename);
return count;
}
diff --git a/src/map/log.c b/src/map/log.c
index 523ef1d65..b5179e16b 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -401,11 +401,11 @@ int log_config_read(const char* cfgName) {
return 1;
}
- while( fgets(line, sizeof(line), fp) ) {
- if( line[0] == '/' && line[1] == '/' )
+ while (fgets(line, sizeof(line), fp)) {
+ if (line[0] == '/' && line[1] == '/')
continue;
- if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 ) {
+ if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) == 2) {
if( strcmpi(w1, "enable_logs") == 0 )
logs->config.enable_logs = (e_log_pick_type)config_switch(w2);
else if( strcmpi(w1, "sql_logs") == 0 )
diff --git a/src/map/map.c b/src/map/map.c
index b254b6792..62d1aad75 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3253,13 +3253,13 @@ int map_waterheight(char* mapname)
// read & convert fn
rsw = (char *) grfio_read (fn);
- if (rsw)
- { //Load water height from file
+ if (rsw) {
+ //Load water height from file
int wh = (int) *(float*)(rsw+166);
aFree(rsw);
return wh;
}
- ShowWarning("Failed to find water level for (%s)\n", mapname, fn);
+ ShowWarning("Failed to find water level for %s (%s)\n", mapname, fn);
return NO_WATER;
}
@@ -3427,14 +3427,14 @@ int map_config_read(char *cfgName) {
return 1;
}
- while( fgets(line, sizeof(line), fp) ) {
+ while (fgets(line, sizeof(line), fp)) {
char* ptr;
- if( line[0] == '/' && line[1] == '/' )
+ if (line[0] == '/' && line[1] == '/')
continue;
- if( (ptr = strstr(line, "//")) != NULL )
+ if ((ptr = strstr(line, "//")) != NULL)
*ptr = '\n'; //Strip comments
- if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 )
+ if (sscanf(line, "%1023[^:]: %1023[^\t\r\n]", w1, w2) < 2)
continue;
//Strip trailing spaces
@@ -3514,19 +3514,19 @@ int map_config_read_sub(char *cfgName) {
FILE *fp;
fp = fopen(cfgName,"r");
- if( fp == NULL ) {
+ if (fp == NULL) {
ShowError("Map configuration file not found at: %s\n", cfgName);
return 1;
}
- while( fgets(line, sizeof(line), fp) ) {
+ while (fgets(line, sizeof(line), fp)) {
char* ptr;
- if( line[0] == '/' && line[1] == '/' )
+ if (line[0] == '/' && line[1] == '/')
continue;
- if( (ptr = strstr(line, "//")) != NULL )
+ if ((ptr = strstr(line, "//")) != NULL)
*ptr = '\n'; //Strip comments
- if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 )
+ if (sscanf(line, "%1023[^:]: %1023[^\t\r\n]", w1, w2) < 2)
continue;
//Strip trailing spaces
@@ -3546,27 +3546,24 @@ int map_config_read_sub(char *cfgName) {
fclose(fp);
return 0;
}
-void map_reloadnpc_sub(char *cfgName)
-{
+void map_reloadnpc_sub(char *cfgName) {
char line[1024], w1[1024], w2[1024];
FILE *fp;
fp = fopen(cfgName,"r");
- if( fp == NULL )
- {
+ if (fp == NULL) {
ShowError("Map configuration file not found at: %s\n", cfgName);
return;
}
- while( fgets(line, sizeof(line), fp) )
- {
+ while (fgets(line, sizeof(line), fp)) {
char* ptr;
- if( line[0] == '/' && line[1] == '/' )
+ if (line[0] == '/' && line[1] == '/')
continue;
- if( (ptr = strstr(line, "//")) != NULL )
+ if ((ptr = strstr(line, "//")) != NULL)
*ptr = '\n'; //Strip comments
- if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 )
+ if (sscanf(line, "%1023[^:]: %1023[^\t\r\n]", w1, w2) < 2)
continue;
//Strip trailing spaces
@@ -3609,15 +3606,15 @@ int inter_config_read(char *cfgName) {
char line[1024],w1[1024],w2[1024];
FILE *fp;
- if( !( fp = fopen(cfgName,"r") ) ){
+ if (!(fp = fopen(cfgName,"r"))) {
ShowError("File not found: %s\n",cfgName);
return 1;
}
- while(fgets(line, sizeof(line), fp)) {
- if(line[0] == '/' && line[1] == '/')
+ while (fgets(line, sizeof(line), fp)) {
+ if (line[0] == '/' && line[1] == '/')
continue;
- if( sscanf(line,"%[^:]: %[^\r\n]",w1,w2) < 2 )
+ if (sscanf(line,"%1023[^:]: %1023[^\r\n]", w1, w2) < 2)
continue;
/* table names */
if(strcmpi(w1,"item_db_db")==0)
@@ -4040,7 +4037,7 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
#if 0 /* not yet fully supported */
char drop_arg1[16], drop_arg2[16];
int drop_per = 0;
- if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
+ if (sscanf(w4, "%15[^,],%15[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
int drop_id = 0, drop_type = 0;
if (!strcmpi(drop_arg1, "random"))
drop_id = -1;
diff --git a/src/map/mob.c b/src/map/mob.c
index 38ddffa37..3f1769d37 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -3960,7 +3960,7 @@ int mob_read_sqldb(void) {
// free the query result
SQL->FreeResult(map->mysql_handle);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]);
+ ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]);
}
mob->name_constants();
return 0;
@@ -4082,7 +4082,7 @@ int mob_read_randommonster(void)
summon[i].qty = 1;
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",count,mobfile[i]);
+ ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n",count,mobfile[i]);
}
return 0;
}
@@ -4196,7 +4196,7 @@ void mob_readchatdb(void) {
count++;
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, arc);
+ ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, arc);
}
/*==========================================
@@ -4532,7 +4532,7 @@ int mob_read_sqlskilldb(void) {
// free the query result
SQL->FreeResult(map->mysql_handle);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]);
+ ShowStatus("Done reading '"CL_WHITE"%"PRIu32""CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]);
}
return 0;
}
diff --git a/src/map/npc.c b/src/map/npc.c
index 417aa6c61..f1c6f4fbd 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -3615,8 +3615,9 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
return strchr(start,'\n');// skip and continue
}
m = map->mapname2mapid(mapname);
- if( m < 0 ) {
- ShowWarning("npc_parse_mapflag: Unknown map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", mapname, filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
+ if (m < 0) {
+ ShowWarning("npc_parse_mapflag: Unknown map in file '%s', line '%d': %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n",
+ filepath, strline(buffer,start-buffer), mapname, w1, w2, w3, w4);
if (retval) *retval = EXIT_FAILURE;
return strchr(start,'\n');// skip and continue
}
@@ -3698,7 +3699,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
else if (!strcmpi(w3, "pvp_nightmaredrop")) {
char drop_arg1[16], drop_arg2[16];
int drop_per = 0;
- if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
+ if (sscanf(w4, "%15[^,],%15[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
int drop_id = 0, drop_type = 0;
if (!strcmpi(drop_arg1, "random"))
drop_id = -1;
diff --git a/src/map/pc.c b/src/map/pc.c
index 5a21c7df0..6c8e3403d 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -2823,9 +2823,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
switch (sd->state.lr_flag) {
case 0: //Right hand
ARR_FIND(0, ARRAYLENGTH(sd->right_weapon.add_dmg), i, sd->right_weapon.add_dmg[i].rate == 0 || sd->right_weapon.add_dmg[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->right_weapon.add_dmg))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->right_weapon.add_dmg));
+ if (i == ARRAYLENGTH(sd->right_weapon.add_dmg)) {
+ ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class dmg bonuses per character!\n",
+ ARRAYLENGTH(sd->right_weapon.add_dmg));
break;
}
sd->right_weapon.add_dmg[i].class_ = type2;
@@ -2835,9 +2835,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
case 1: //Left hand
ARR_FIND(0, ARRAYLENGTH(sd->left_weapon.add_dmg), i, sd->left_weapon.add_dmg[i].rate == 0 || sd->left_weapon.add_dmg[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->left_weapon.add_dmg))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->left_weapon.add_dmg));
+ if (i == ARRAYLENGTH(sd->left_weapon.add_dmg)) {
+ ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class dmg bonuses per character!\n",
+ ARRAYLENGTH(sd->left_weapon.add_dmg));
break;
}
sd->left_weapon.add_dmg[i].class_ = type2;
@@ -2851,9 +2851,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->add_mdmg), i, sd->add_mdmg[i].rate == 0 || sd->add_mdmg[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->add_mdmg))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class magic dmg bonuses per character!\n", ARRAYLENGTH(sd->add_mdmg));
+ if (i == ARRAYLENGTH(sd->add_mdmg)) {
+ ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class magic dmg bonuses per character!\n", ARRAYLENGTH(sd->add_mdmg));
break;
}
sd->add_mdmg[i].class_ = type2;
@@ -2865,9 +2864,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->add_def), i, sd->add_def[i].rate == 0 || sd->add_def[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->add_def))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class def bonuses per character!\n", ARRAYLENGTH(sd->add_def));
+ if (i == ARRAYLENGTH(sd->add_def)) {
+ ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class def bonuses per character!\n", ARRAYLENGTH(sd->add_def));
break;
}
sd->add_def[i].class_ = type2;
@@ -2879,9 +2877,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->add_mdef), i, sd->add_mdef[i].rate == 0 || sd->add_mdef[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->add_mdef))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class mdef bonuses per character!\n", ARRAYLENGTH(sd->add_mdef));
+ if (i == ARRAYLENGTH(sd->add_mdef)) {
+ ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of add Class mdef bonuses per character!\n", ARRAYLENGTH(sd->add_mdef));
break;
}
sd->add_mdef[i].class_ = type2;
@@ -3004,9 +3001,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillatk), i, sd->skillatk[i].id == 0 || sd->skillatk[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillatk))
- { //Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("script->run: bonus2 bSkillAtk reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillatk), type2, val);
+ if (i == ARRAYLENGTH(sd->skillatk)) {
+ //Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("script->run: bonus2 bSkillAtk reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillatk), type2, val);
break;
}
if (sd->skillatk[i].id == type2)
@@ -3020,9 +3018,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillheal), i, sd->skillheal[i].id == 0 || sd->skillheal[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillheal))
- { // Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("script->run: bonus2 bSkillHeal reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal), type2, val);
+ if (i == ARRAYLENGTH(sd->skillheal)) {
+ // Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("script->run: bonus2 bSkillHeal reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillheal), type2, val);
break;
}
if (sd->skillheal[i].id == type2)
@@ -3036,9 +3035,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillheal2), i, sd->skillheal2[i].id == 0 || sd->skillheal2[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillheal2))
- { // Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("script->run: bonus2 bSkillHeal2 reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal2), type2, val);
+ if (i == ARRAYLENGTH(sd->skillheal2)) {
+ // Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("script->run: bonus2 bSkillHeal2 reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillheal2), type2, val);
break;
}
if (sd->skillheal2[i].id == type2)
@@ -3052,9 +3052,10 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillblown), i, sd->skillblown[i].id == 0 || sd->skillblown[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillblown))
- { //Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("script->run: bonus2 bSkillBlown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillblown), type2, val);
+ if (i == ARRAYLENGTH(sd->skillblown)) {
+ //Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("script->run: bonus2 bSkillBlown reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillblown), type2, val);
break;
}
if(sd->skillblown[i].id == type2)
@@ -3071,9 +3072,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillcast))
- { //Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("script->run: bonus2 %s reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",
+ if (i == ARRAYLENGTH(sd->skillcast)) {
+ //Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("script->run: bonus2 %s reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
#ifndef RENEWAL_CAST
"bCastRate",
@@ -3098,11 +3099,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
ARR_FIND(0, ARRAYLENGTH(sd->skillfixcastrate), i, sd->skillfixcastrate[i].id == 0 || sd->skillfixcastrate[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillfixcastrate))
-
- {
-
- ShowDebug("script->run: bonus2 bFixedCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcastrate), type2, val);
+ if (i == ARRAYLENGTH(sd->skillfixcastrate)) {
+ ShowDebug("script->run: bonus2 bFixedCastrate reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillfixcastrate), type2, val);
break;
}
@@ -3151,8 +3150,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
//Standard item bonus.
for(i=0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid && sd->itemhealrate[i].nameid != type2; i++);
- if(i == ARRAYLENGTH(sd->itemhealrate)) {
- ShowWarning("pc_bonus2: Reached max (%d) number of item heal bonuses per character!\n", ARRAYLENGTH(sd->itemhealrate));
+ if (i == ARRAYLENGTH(sd->itemhealrate)) {
+ ShowWarning("pc_bonus2: Reached max (%"PRIuS") number of item heal bonuses per character!\n", ARRAYLENGTH(sd->itemhealrate));
break;
}
sd->itemhealrate[i].nameid = type2;
@@ -3219,7 +3218,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillusesprate), i, sd->skillusesprate[i].id == 0 || sd->skillusesprate[i].id == type2);
if (i == ARRAYLENGTH(sd->skillusesprate)) {
- ShowDebug("script->run: bonus2 bSkillUseSPrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesprate), type2, val);
+ ShowDebug("script->run: bonus2 bSkillUseSPrate reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillusesprate), type2, val);
break;
}
if (sd->skillusesprate[i].id == type2)
@@ -3233,9 +3233,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillcooldown), i, sd->skillcooldown[i].id == 0 || sd->skillcooldown[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillcooldown))
- {
- ShowDebug("script->run: bonus2 bSkillCoolDown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillcooldown), type2, val);
+ if (i == ARRAYLENGTH(sd->skillcooldown)) {
+ ShowDebug("script->run: bonus2 bSkillCoolDown reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillcooldown), type2, val);
break;
}
if (sd->skillcooldown[i].id == type2)
@@ -3249,9 +3249,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillfixcast), i, sd->skillfixcast[i].id == 0 || sd->skillfixcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillfixcast))
- {
- ShowDebug("script->run: bonus2 bSkillFixedCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcast), type2, val);
+ if (i == ARRAYLENGTH(sd->skillfixcast)) {
+ ShowDebug("script->run: bonus2 bSkillFixedCast reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillfixcast), type2, val);
break;
}
if (sd->skillfixcast[i].id == type2)
@@ -3265,9 +3265,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillvarcast), i, sd->skillvarcast[i].id == 0 || sd->skillvarcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillvarcast))
- {
- ShowDebug("script->run: bonus2 bSkillVariableCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillvarcast), type2, val);
+ if (i == ARRAYLENGTH(sd->skillvarcast)) {
+ ShowDebug("script->run: bonus2 bSkillVariableCast reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillvarcast), type2, val);
break;
}
if (sd->skillvarcast[i].id == type2)
@@ -3282,9 +3282,9 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
if(sd->state.lr_flag == 2)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillcast))
- {
- ShowDebug("script->run: bonus2 bVariableCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",ARRAYLENGTH(sd->skillcast), type2, val);
+ if (i == ARRAYLENGTH(sd->skillcast)) {
+ ShowDebug("script->run: bonus2 bVariableCastrate reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillcast), type2, val);
break;
}
if(sd->skillcast[i].id == type2)
@@ -3300,7 +3300,8 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
break;
ARR_FIND(0, ARRAYLENGTH(sd->skillusesp), i, sd->skillusesp[i].id == 0 || sd->skillusesp[i].id == type2);
if (i == ARRAYLENGTH(sd->skillusesp)) {
- ShowDebug("script->run: bonus2 bSkillUseSP reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesp), type2, val);
+ ShowDebug("script->run: bonus2 bSkillUseSP reached it's limit (%"PRIuS" skills per character), bonus skill %d (+%d%%) lost.\n",
+ ARRAYLENGTH(sd->skillusesp), type2, val);
break;
}
if (sd->skillusesp[i].id == type2)
@@ -9961,11 +9962,11 @@ void pc_read_skill_tree(void) {
int skidx, offset = 0, h = 0, rlen = 0, rskid = 0;
ARR_FIND( 0, MAX_SKILL_TREE, skidx, pc->skill_tree[idx][skidx].id == 0 || pc->skill_tree[idx][skidx].id == skill_id );
- if( skidx == MAX_SKILL_TREE ) {
- ShowWarning("pc_read_skill_tree: Unable to load skill %hu (%s) into '%s's tree. Maximum number of skills per class has been reached.\n", skill_id, sk_name, name);
+ if (skidx == MAX_SKILL_TREE) {
+ ShowWarning("pc_read_skill_tree: Unable to load skill %d (%s) into '%s's tree. Maximum number of skills per class has been reached.\n", skill_id, sk_name, name);
continue;
- } else if(pc->skill_tree[idx][skidx].id) {
- ShowNotice("pc_read_skill_tree: Overwriting %hu for '%s' (%d)\n", skill_id, name, jnames[k].id);
+ } else if (pc->skill_tree[idx][skidx].id) {
+ ShowNotice("pc_read_skill_tree: Overwriting %d for '%s' (%d)\n", skill_id, name, jnames[k].id);
}
pc->skill_tree[idx][skidx].id = skill_id;
@@ -10182,7 +10183,7 @@ int pc_readdb(void) {
if (!pc->max_level[j][1])
ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i);
}
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"exp.txt");
+ ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"exp.txt");
count = 0;
// Reset and read skilltree
memset(pc->skill_tree,0,sizeof(pc->skill_tree));
@@ -10256,7 +10257,7 @@ int pc_readdb(void) {
}
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"attr_fix.txt");
+ ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"attr_fix.txt");
count = 0;
// reset then read statspoint
memset(pc->statp,0,sizeof(pc->statp));
@@ -10283,7 +10284,7 @@ int pc_readdb(void) {
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"statpoint.txt");
+ ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,map->db_path,"statpoint.txt");
}
// generate the remaining parts of the db if necessary
k = battle_config.use_statpoint_table; //save setting
diff --git a/src/map/script.c b/src/map/script.c
index 9fe746c8c..53161be5b 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -208,7 +208,7 @@ void script_reportdata(struct script_data* data)
ShowDebug("Data: nothing (nil)\n");
break;
case C_INT:// number
- ShowDebug("Data: number value=%d\n", data->u.num);
+ ShowDebug("Data: number value=%"PRId64"\n", data->u.num);
break;
case C_STR:
case C_CONSTSTR:// string
@@ -232,7 +232,7 @@ void script_reportdata(struct script_data* data)
}
break;
case C_POS:// label
- ShowDebug("Data: label pos=%d\n", data->u.num);
+ ShowDebug("Data: label pos=%"PRId64"\n", data->u.num);
break;
default:
ShowDebug("Data: %s\n", script->op2name(data->type));
@@ -2121,13 +2121,13 @@ void read_constdb(void) {
ShowError("can't read %s\n", line);
return ;
}
- while(fgets(line, sizeof(line), fp))
- {
- if(line[0]=='/' && line[1]=='/')
+ while (fgets(line, sizeof(line), fp)) {
+ if (line[0] == '/' && line[1] == '/')
continue;
- type=0;
- if(sscanf(line,"%[A-Za-z0-9_],%[-0-9xXA-Fa-f],%d",name,val,&type)>=2 ||
- sscanf(line,"%[A-Za-z0-9_] %[-0-9xXA-Fa-f] %d",name,val,&type)>=2) {
+ type = 0;
+ if (sscanf(line, "%1023[A-Za-z0-9_],%1023[-0-9xXA-Fa-f],%d", name, val, &type) >=2
+ || sscanf(line, "%1023[A-Za-z0-9_] %1023[-0-9xXA-Fa-f] %d", name, val, &type) >=2
+ ) {
script->set_constant(name, (int)strtol(val, NULL, 0), (bool)type);
}
}
@@ -2205,7 +2205,7 @@ void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file,
error_linepos = p;
if( line >= 0 )
- StrBuf->Printf(buf, "script error in file '%s' line %d column %d\n", file, line, error_pos-error_linepos+1);
+ StrBuf->Printf(buf, "script error in file '%s' line %d column %"PRIdPTR"\n", file, line, error_pos-error_linepos+1);
else
StrBuf->Printf(buf, "script error in file '%s' item ID %d\n", file, -line);
@@ -3826,7 +3826,8 @@ int run_func(struct script_state *st)
if (!(script->str_data[func].func(st))) //Report error
script->reportsrc(st);
} else {
- ShowError("script:run_func: '%s' (id=%"PRId64" type=%s) has no C function. please report this!!!\n", script->get_str(func), func, script->op2name(script->str_data[func].type));
+ ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!\n",
+ script->get_str(func), func, script->op2name(script->str_data[func].type));
script->reportsrc(st);
st->state = END;
}
@@ -4155,10 +4156,10 @@ int script_config_read(char *cfgName) {
ShowError("File not found: %s\n", cfgName);
return 1;
}
- while(fgets(line, sizeof(line), fp)) {
- if(line[0] == '/' && line[1] == '/')
+ while (fgets(line, sizeof(line), fp)) {
+ if (line[0] == '/' && line[1] == '/')
continue;
- i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
+ i = sscanf(line,"%1023[^:]: %1023[^\r\n]", w1, w2);
if(i!=2)
continue;
@@ -6107,9 +6108,8 @@ BUILDIN(getelementofarray)
id = reference_getid(data);
i = script_getnum(st, 3);
- if( i < 0 || i >= SCRIPT_MAX_ARRAYSIZE )
- {
- ShowWarning("script:getelementofarray: index out of range (%lld)\n", i);
+ if (i < 0 || i >= SCRIPT_MAX_ARRAYSIZE) {
+ ShowWarning("script:getelementofarray: index out of range (%"PRId64")\n", i);
script->reportdata(data);
script_pushnil(st);
st->state = END;
@@ -6526,7 +6526,7 @@ BUILDIN(getitem) {
return false;
}
if( item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR ) {
- ShowError("script_getitembound: can't bind a pet egg/armor!\n",bound);
+ ShowError("script_getitembound: can't bind a pet egg/armor! Type=%d\n",bound);
return false;
}
it.bound = (unsigned char)bound;
@@ -6606,8 +6606,8 @@ BUILDIN(getitem2) {
c3=(short)script_getnum(st,9);
c4=(short)script_getnum(st,10);
- if( bound && (itemdb_type(nameid) == IT_PETEGG || itemdb_type(nameid) == IT_PETARMOR) ) {
- ShowError("script_getitembound2: can't bind a pet egg/armor!\n",bound);
+ if (bound && (itemdb_type(nameid) == IT_PETEGG || itemdb_type(nameid) == IT_PETARMOR)) {
+ ShowError("script_getitembound2: can't bind a pet egg/armor! Type=%d\n",bound);
return false;
}
@@ -14883,15 +14883,14 @@ BUILDIN(escape_sql)
return true;
}
-BUILDIN(getd)
-{
+BUILDIN(getd) {
char varname[100];
const char *buffer;
int elem;
buffer = script_getstr(st, 2);
- if(sscanf(buffer, "%[^[][%d]", varname, &elem) < 2)
+ if (sscanf(buffer, "%99[^[][%d]", varname, &elem) < 2)
elem = 0;
// Push the 'pointer' so it's more flexible [Lance]
diff --git a/src/map/skill.c b/src/map/skill.c
index ca93a51aa..2bdd6d366 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -17367,8 +17367,8 @@ int skill_blockpc_end(int tid, int64 tick, int id, intptr_t data) {
break;
}
- if( i == cd->cursor ) {
- ShowError("skill_blockpc_end: '%s' : no data found for '%d'\n",sd->status.name,data);
+ if (i == cd->cursor) {
+ ShowError("skill_blockpc_end: '%s': no data found for '%"PRIdPTR"'\n", sd->status.name, data);
} else {
int cursor = 0;
diff --git a/src/map/status.c b/src/map/status.c
index 5ad096c1d..c8ed216f6 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -10453,21 +10453,19 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
struct status_change_entry *sce;
bl = map->id2bl(id);
- if(!bl) {
- ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data);
+ if (!bl) {
+ ShowDebug("status_change_timer: Null pointer id: %d data: %"PRIdPTR"\n", id, data);
return 0;
}
sc = status->get_sc(bl);
st = status->get_status_data(bl);
- if(!(sc && (sce = sc->data[type])))
- {
- ShowDebug("status_change_timer: Null pointer id: %d data: %d bl-type: %d\n", id, data, bl->type);
+ if (!(sc && (sce = sc->data[type]))) {
+ ShowDebug("status_change_timer: Null pointer id: %d data: %"PRIdPTR" bl-type: %d\n", id, data, bl->type);
return 0;
}
- if( sce->timer != tid )
- {
+ if (sce->timer != tid) {
ShowError("status_change_timer: Mismatch for type %d: %d != %d (bl id %d)\n",type,tid,sce->timer, bl->id);
return 0;
}
@@ -10476,10 +10474,10 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) {
// set the next timer of the sce (don't assume the status still exists)
#define sc_timer_next(t,f,i,d) do { \
- if( (sce=sc->data[type]) ) \
+ if ((sce=sc->data[type])) \
sce->timer = timer->add((t),(f),(i),(d)); \
else \
- ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data); \
+ ShowError("status_change_timer: Unexpected NULL status change id: %d data: %"PRIdPTR"\n", id, data); \
} while(0)
switch(type) {