diff options
Diffstat (limited to 'src')
36 files changed, 475 insertions, 451 deletions
diff --git a/src/char/char.c b/src/char/char.c index fe17fd14f..9abb17257 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3146,9 +3146,8 @@ int parse_frommap(int fd) int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2); struct online_char_data* character; - if (size - 13 != sizeof(struct mmo_charstatus)) - { - ShowError("parse_from_map (save-char): Size mismatch! %d != %d\n", size-13, sizeof(struct mmo_charstatus)); + if (size - 13 != sizeof(struct mmo_charstatus)) { + ShowError("parse_from_map (save-char): Size mismatch! %d != %"PRIuS"\n", size-13, sizeof(struct mmo_charstatus)); RFIFOSKIP(fd,size); break; } @@ -5025,7 +5024,7 @@ int char_lan_config_read(const char *lancfgName) if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') continue; - if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) { + if (sscanf(line,"%63[^:]: %63[^:]:%63[^:]:%63[^\r\n]", w1, w2, w3, w4) != 4) { ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); continue; @@ -5074,7 +5073,7 @@ void sql_config_read(const char* cfgName) 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,"char_db")) @@ -5182,7 +5181,7 @@ int char_config_read(const char* cfgName) 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; remove_control_chars(w1); diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 8cd870647..ddfef68c2 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -115,7 +115,7 @@ unsigned int auction_create(struct auction_data *auction) auction->auction_id = (unsigned int)SQL->StmtLastInsertId(stmt); auction->auction_end_timer = timer->add( timer->gettick() + tick , auction_end_timer, auction->auction_id, 0); - ShowInfo("New Auction %u | time left %u ms | By %s.\n", auction->auction_id, tick, auction->seller_name); + ShowInfo("New Auction %u | time left %"PRId64" ms | By %s.\n", auction->auction_id, tick, auction->seller_name); CREATE(auction_, struct auction_data, 1); memcpy(auction_, auction, sizeof(struct auction_data)); diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 0f7c683f8..bf7961462 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -249,22 +249,21 @@ int mapif_save_pet(int fd, int account_id, struct s_pet *data) { int len; RFIFOHEAD(fd); len=RFIFOW(fd, 2); - if(sizeof(struct s_pet)!=len-8) { - ShowError("inter pet: data size error %d %d\n", sizeof(struct s_pet), len-8); + if (sizeof(struct s_pet) != len-8) { + ShowError("inter pet: data size mismatch: %d != %"PRIuS"\n", len-8, sizeof(struct s_pet)); + return 0; } - else{ - if(data->hungry < 0) - data->hungry = 0; - else if(data->hungry > 100) - data->hungry = 100; - if(data->intimate < 0) - data->intimate = 0; - else if(data->intimate > 1000) - data->intimate = 1000; - inter_pet_tosql(data->pet_id,data); - mapif_save_pet_ack(fd, account_id, 0); - } + if (data->hungry < 0) + data->hungry = 0; + else if (data->hungry > 100) + data->hungry = 100; + if (data->intimate < 0) + data->intimate = 0; + else if (data->intimate > 1000) + data->intimate = 1000; + inter_pet_tosql(data->pet_id,data); + mapif_save_pet_ack(fd, account_id, 0); return 0; } diff --git a/src/char/int_storage.c b/src/char/int_storage.c index bf7b76da0..882d9b2a5 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -220,16 +220,13 @@ int mapif_parse_SaveGuildStorage(int fd) guild_id = RFIFOL(fd,8); len = RFIFOW(fd,2); - if( sizeof(struct guild_storage) != len - 12 ) - { - ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12); - } - else - { - if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) + if (sizeof(struct guild_storage) != len - 12) { + ShowError("inter storage: data size mismatch: %d != %"PRIuS"\n", len - 12, sizeof(struct guild_storage)); + } else { + if (SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id)) { Sql_ShowDebug(sql_handle); - else if( SQL->NumRows(sql_handle) > 0 ) - {// guild exists + } else if(SQL->NumRows(sql_handle) > 0) { + // guild exists SQL->FreeResult(sql_handle); guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12)); mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); @@ -397,7 +394,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd) if( j ) StrBuf->AppendStr(&buf, ","); - StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d'", + StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%"PRIu64"'", guild_id, items[j].nameid, items[j].amount, items[j].equip, items[j].identify, items[j].refine, items[j].attribute, items[j].expire_time, items[j].bound, items[j].unique_id); for( s = 0; s < MAX_SLOTS; ++s ) diff --git a/src/char/inter.c b/src/char/inter.c index c2d8de37a..ab53fc6da 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -107,7 +107,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) @@ -562,7 +562,8 @@ void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap) { * @param msg Message format string * @param ... Additional parameters for (v)sprinf */ -void inter_msg_to_fd(int fd, int u_fd, int aid, char* msg, ...) { +void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) __attribute__((format(printf, 4, 5))); +void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) { va_list ap; va_start(ap,msg); inter_vmsg_to_fd(fd, u_fd, aid, msg, ap); @@ -917,9 +918,8 @@ static int inter_config_read(const char* cfgName) return 1; } - while(fgets(line, sizeof(line), fp)) - { - i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2); + while (fgets(line, sizeof(line), fp)) { + i = sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2); if(i != 2) continue; diff --git a/src/char/inter.h b/src/char/inter.h index ab2478ae6..0bea21363 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -18,7 +18,7 @@ int mapif_send_gmaccounts(void); int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason); void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state); -int inter_log(char *fmt,...); +int inter_log(char *fmt, ...) __attribute__((format(printf, 1, 2))); int inter_vlog(char *fmt, va_list ap); #define inter_cfgName "conf/inter-server.conf" diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 6ca67382f..18bc0b8cb 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -347,6 +347,19 @@ typedef char bool; #endif ////////////////////////////////////////////////////////////////////////// +// Additional printf specifiers +#if defined(_MSC_VER) +#define PRIS_PREFIX "I" +#else // gcc +#define PRIS_PREFIX "z" +#endif +#define PRIdS PRIS_PREFIX "d" +#define PRIxS PRIS_PREFIX "x" +#define PRIuS PRIS_PREFIX "u" +#define PRIXS PRIS_PREFIX "X" +#define PRIoS PRIS_PREFIX "o" + +////////////////////////////////////////////////////////////////////////// // path separator #if defined(WIN32) diff --git a/src/common/grfio.c b/src/common/grfio.c index 6e628a512..5be0c8237 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -655,7 +655,7 @@ static bool grfio_parse_restable_row(const char* row) char local[256]; FILELIST* entry; - if( sscanf(row, "%[^#\r\n]#%[^#\r\n]#", w1, w2) != 2 ) + if (sscanf(row, "%255[^#\r\n]#%255[^#\r\n]#", w1, w2) != 2) return false; if( strstr(w2, ".gat") == NULL && strstr(w2, ".rsw") == NULL ) @@ -805,7 +805,7 @@ void grfio_init(const char* fname) if( line[0] == '/' && line[1] == '/' ) continue; // skip comments - if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2 ) + if (sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2) != 2) continue; // skip unrecognized lines // Entry table reading diff --git a/src/common/malloc.c b/src/common/malloc.c index 3c9fa9c54..eae9ad423 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -241,7 +241,7 @@ void *mmalloc_(size_t size, const char *file, int line, const char *func) { struct unit_head *head; if (((long) size) < 0) { - ShowError("mmalloc_: %d\n", size); + ShowError("mmalloc_: %"PRIdS"\n", size); return NULL; } @@ -272,7 +272,8 @@ void *mmalloc_(size_t size, const char *file, int line, const char *func) { *(long*)((char*)p + sizeof(struct unit_head_large) - sizeof(long) + size) = 0xdeadbeaf; return (char *)p + sizeof(struct unit_head_large) - sizeof(long); } else { - ShowFatalError("Memory manager::memmgr_alloc failed (allocating %d+%d bytes at %s:%d).\n", sizeof(struct unit_head_large), size, file, line); + ShowFatalError("Memory manager::memmgr_alloc failed (allocating %"PRIuS"+%"PRIuS" bytes at %s:%d).\n", + sizeof(struct unit_head_large), size, file, line); exit(EXIT_FAILURE); } } @@ -760,10 +761,10 @@ void memmgr_report (int extra) { ShowMessage("[malloc] : reporting %u instances | %.2f MB\n",count,(double)((size)/1024)/1024); ShowMessage("[malloc] : internal usage %.2f MB | %.2f MB\n",(double)((memmgr_usage_bytes_t-memmgr_usage_bytes)/1024)/1024,(double)((memmgr_usage_bytes_t)/1024)/1024); - if( extra ) { - ShowMessage("[malloc] : unit_head_large: %d bytes\n",sizeof(struct unit_head_large)); - ShowMessage("[malloc] : unit_head: %d bytes\n",sizeof(struct unit_head)); - ShowMessage("[malloc] : block: %d bytes\n",sizeof(struct block)); + if (extra) { + ShowMessage("[malloc] : unit_head_large: %"PRIuS" bytes\n", sizeof(struct unit_head_large)); + ShowMessage("[malloc] : unit_head: %"PRIuS" bytes\n", sizeof(struct unit_head)); + ShowMessage("[malloc] : block: %"PRIuS" bytes\n", sizeof(struct block)); } } diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 644f2f619..f540c98d8 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -49,12 +49,12 @@ const char* mapindex_getmapname_ext(const char* string, char* output) { size_t len; strcpy(buf,string); - sscanf(string,"%*[^#]%*[#]%s",buf); + sscanf(string, "%*[^#]%*[#]%15s", buf); len = safestrnlen(buf, MAP_NAME_LENGTH); if (len == MAP_NAME_LENGTH) { - ShowWarning("(mapindex_normalize_name) Map name '%*s' is too long!\n", 2*MAP_NAME_LENGTH, buf); + ShowWarning("(mapindex_normalize_name) Map name '%s' is too long!\n", buf); len--; } safestrncpy(dest, buf, len+1); diff --git a/src/common/mutex.c b/src/common/mutex.c index ea3e0f8ce..f046febf6 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -54,8 +54,8 @@ ramutex *ramutex_create(void) { struct ramutex *m; m = (struct ramutex*)aMalloc( sizeof(struct ramutex) ); - if(m == NULL){ - ShowFatalError("ramutex_create: OOM while allocating %u bytes.\n", sizeof(struct ramutex)); + if (m == NULL) { + ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct ramutex)); return NULL; } @@ -128,8 +128,8 @@ racond *racond_create(void) { struct racond *c; c = (struct racond*)aMalloc( sizeof(struct racond) ); - if(c == NULL){ - ShowFatalError("racond_create: OOM while allocating %u bytes\n", sizeof(struct racond)); + if (c == NULL) { + ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct racond)); return NULL; } diff --git a/src/common/showmsg.c b/src/common/showmsg.c index b9bcef9b2..f3982d364 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -498,8 +498,8 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) return 0; } -int FPRINTF(HANDLE handle, const char *fmt, ...) -{ +int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int FPRINTF(HANDLE handle, const char *fmt, ...) { int ret; va_list argptr; va_start(argptr, fmt); @@ -634,8 +634,8 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) FREEBUF(tempbuf); return 0; } -int FPRINTF(FILE *file, const char *fmt, ...) -{ +int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int FPRINTF(FILE *file, const char *fmt, ...) { int ret; va_list argptr; va_start(argptr, fmt); @@ -782,8 +782,8 @@ void ClearScreen(void) ShowMessage(CL_CLS); // to prevent empty string passed messages #endif } -int ShowMessage_(enum msg_type flag, const char *string, ...) -{ +int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); +int ShowMessage_(enum msg_type flag, const char *string, ...) { int ret; va_list ap; va_start(ap, string); @@ -793,44 +793,50 @@ int ShowMessage_(enum msg_type flag, const char *string, ...) } // direct printf replacement +void ShowMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowMessage(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NONE, string, ap); va_end(ap); } +void ShowStatus(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowStatus(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_STATUS, string, ap); va_end(ap); } +void ShowSQL(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowSQL(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_SQL, string, ap); va_end(ap); } +void ShowInfo(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowInfo(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_INFORMATION, string, ap); va_end(ap); } +void ShowNotice(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowNotice(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NOTICE, string, ap); va_end(ap); } +void ShowWarning(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowWarning(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_WARNING, string, ap); va_end(ap); } -void ShowConfigWarning(config_setting_t *config, const char *string, ...) -{ +void ShowConfigWarning(config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); +void ShowConfigWarning(config_setting_t *config, const char *string, ...) { StringBuf buf; va_list ap; StrBuf->Init(&buf); @@ -841,18 +847,21 @@ void ShowConfigWarning(config_setting_t *config, const char *string, ...) va_end(ap); StrBuf->Destroy(&buf); } +void ShowDebug(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowDebug(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_DEBUG, string, ap); va_end(ap); } +void ShowError(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowError(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_ERROR, string, ap); va_end(ap); } +void ShowFatalError(const char *string, ...) __attribute__((format(printf, 1, 2))); void ShowFatalError(const char *string, ...) { va_list ap; va_start(ap, string); diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 83eb0ad89..4300c29d6 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -93,26 +93,26 @@ enum msg_type { extern void ClearScreen(void); #ifdef HERCULES_CORE - extern void ShowMessage(const char *, ...); - extern void ShowStatus(const char *, ...); - extern void ShowSQL(const char *, ...); - extern void ShowInfo(const char *, ...); - extern void ShowNotice(const char *, ...); - extern void ShowWarning(const char *, ...); - extern void ShowDebug(const char *, ...); - extern void ShowError(const char *, ...); - extern void ShowFatalError(const char *, ...); - extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); + extern void ShowMessage(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowStatus(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowSQL(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowInfo(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowNotice(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowWarning(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowDebug(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowError(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowFatalError(const char *, ...) __attribute__((format(printf, 1, 2))); + extern void ShowConfigWarning(config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); #else - HPExport void (*ShowMessage) (const char *, ...); - HPExport void (*ShowStatus) (const char *, ...); - HPExport void (*ShowSQL) (const char *, ...); - HPExport void (*ShowInfo) (const char *, ...); - HPExport void (*ShowNotice) (const char *, ...); - HPExport void (*ShowWarning) (const char *, ...); - HPExport void (*ShowDebug) (const char *, ...); - HPExport void (*ShowError) (const char *, ...); - HPExport void (*ShowFatalError) (const char *, ...); + HPExport void (*ShowMessage) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowStatus) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowSQL) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowInfo) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowNotice) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowWarning) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowDebug) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowError) (const char *, ...) __attribute__((format(printf, 1, 2))); + HPExport void (*ShowFatalError) (const char *, ...) __attribute__((format(printf, 1, 2))); #endif extern int vShowMessage_(enum msg_type flag, const char *string, va_list ap); diff --git a/src/common/socket.c b/src/common/socket.c index 85f0aa0ce..0c48c7c46 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -689,8 +689,8 @@ int RFIFOSKIP(int fd, size_t len) s = session[fd]; - if ( s->rdata_size < s->rdata_pos + len ) { - ShowError("RFIFOSKIP: skipped past end of read buffer! Adjusting from %d to %d (session #%d)\n", len, RFIFOREST(fd), fd); + if (s->rdata_size < s->rdata_pos + len) { + ShowError("RFIFOSKIP: skipped past end of read buffer! Adjusting from %"PRIuS" to %"PRIuS" (session #%d)\n", len, RFIFOREST(fd), fd); len = RFIFOREST(fd); } @@ -738,13 +738,15 @@ int WFIFOSET(int fd, size_t len) if( !s->flag.server ) { - if( len > socket_max_client_packet ) {// see declaration of socket_max_client_packet for details - ShowError("WFIFOSET: Dropped too large client packet 0x%04x (length=%u, max=%u).\n", WFIFOW(fd,0), len, socket_max_client_packet); + if (len > socket_max_client_packet) { // see declaration of socket_max_client_packet for details + ShowError("WFIFOSET: Dropped too large client packet 0x%04x (length=%"PRIuS", max=%"PRIuS").\n", + WFIFOW(fd,0), len, socket_max_client_packet); return 0; } - if( s->wdata_size+len > WFIFO_MAX ) {// reached maximum write fifo size - ShowError("WFIFOSET: Maximum write buffer size for client connection %d exceeded, most likely caused by packet 0x%04x (len=%u, ip=%lu.%lu.%lu.%lu).\n", fd, WFIFOW(fd,0), len, CONVIP(s->client_addr)); + if (s->wdata_size+len > WFIFO_MAX) { // reached maximum write fifo size + ShowError("WFIFOSET: Maximum write buffer size for client connection %d exceeded, most likely caused by packet 0x%04x (len=%"PRIuS", ip=%u.%u.%u.%u).\n", + fd, WFIFOW(fd,0), len, CONVIP(s->client_addr)); set_eof(fd); return 0; } @@ -1152,11 +1154,10 @@ int socket_config_read(const char* cfgName) return 1; } - while(fgets(line, sizeof(line), fp)) - { + 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, "stall_time")) { @@ -1545,9 +1546,9 @@ void send_shortlist_add_fd(int fd) if( (send_shortlist_set[i]>>bit)&1 ) return;// already in the list - if( send_shortlist_count >= ARRAYLENGTH(send_shortlist_array) ) - { - ShowDebug("send_shortlist_add_fd: shortlist is full, ignoring... (fd=%d shortlist.count=%d shortlist.length=%d)\n", fd, send_shortlist_count, ARRAYLENGTH(send_shortlist_array)); + if (send_shortlist_count >= ARRAYLENGTH(send_shortlist_array)) { + ShowDebug("send_shortlist_add_fd: shortlist is full, ignoring... (fd=%d shortlist.count=%d shortlist.length=%"PRIuS")\n", + fd, send_shortlist_count, ARRAYLENGTH(send_shortlist_array)); return; } diff --git a/src/common/sql.c b/src/common/sql.c index a562478ea..8ae9d3cdb 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -242,8 +242,8 @@ size_t Sql_EscapeStringLen(Sql* self, char *out_to, const char *from, size_t fro /// Executes a query. -int Sql_Query(Sql* self, const char* query, ...) -{ +int Sql_Query(Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +int Sql_Query(Sql *self, const char *query, ...) { int res; va_list args; @@ -517,15 +517,13 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type, /// Prints debug information about a field (type and length). /// /// @private -static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char* length_postfix) -{ - const char* sign = (is_unsigned ? "UNSIGNED " : ""); - const char* type_string; - switch( type ) - { - default: - ShowDebug("%stype=%s%u, length=%d\n", prefix, sign, type, length); - return; +static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char* length_postfix) { + const char *sign = (is_unsigned ? "UNSIGNED " : ""); + const char *type_string = NULL; + switch (type) { + default: + ShowDebug("%stype=%s%u, length=%lu\n", prefix, sign, type, length); + return; #define SHOW_DEBUG_OF(x) case x: type_string = #x; break SHOW_DEBUG_OF(MYSQL_TYPE_TINY); SHOW_DEBUG_OF(MYSQL_TYPE_SHORT); @@ -548,7 +546,7 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty SHOW_DEBUG_OF(MYSQL_TYPE_NULL); #undef SHOW_DEBUG_TYPE_OF } - ShowDebug("%stype=%s%s, length=%d%s\n", prefix, sign, type_string, length, length_postfix); + ShowDebug("%stype=%s%s, length=%lu%s\n", prefix, sign, type_string, length, length_postfix); } @@ -607,8 +605,8 @@ SqlStmt* SqlStmt_Malloc(Sql* sql) { /// Prepares the statement. -int SqlStmt_Prepare(SqlStmt* self, const char* query, ...) -{ +int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) { int res; va_list args; @@ -756,16 +754,13 @@ size_t SqlStmt_NumColumns(SqlStmt* self) /// Binds the result of a column to a buffer. -int SqlStmt_BindColumn(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null) -{ - if( self == NULL ) +int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null) { + if (self == NULL) return SQL_ERROR; - if( buffer_type == SQLDT_STRING || buffer_type == SQLDT_ENUM ) - { - if( buffer_len < 1 ) - { - ShowDebug("SqlStmt_BindColumn: buffer_len(%d) is too small, no room for the null-terminator\n", buffer_len); + if (buffer_type == SQLDT_STRING || buffer_type == SQLDT_ENUM) { + if (buffer_len < 1) { + ShowDebug("SqlStmt_BindColumn: buffer_len(%"PRIuS") is too small, no room for the null-terminator\n", buffer_len); return SQL_ERROR; } --buffer_len;// null-terminator @@ -974,9 +969,9 @@ void Sql_inter_server_read(const char* cfgName, bool first) { return; } - while(fgets(line, sizeof(line), fp)) { - i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2); - if(i != 2) + while (fgets(line, sizeof(line), fp)) { + i = sscanf(line, "%1023[^:]: %1023[^\r\n]", w1, w2); + if (i != 2) continue; if(!strcmpi(w1,"mysql_reconnect_type")) { diff --git a/src/common/sql.h b/src/common/sql.h index f9593978c..b1f1f41c3 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -98,7 +98,7 @@ struct sql_interface { /// The query is constructed as if it was sprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*Query) (Sql* self, const char* query, ...); + int (*Query) (Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); /// Executes a query. /// Any previous result is freed. /// The query is constructed as if it was svprintf. @@ -176,7 +176,7 @@ struct sql_interface { /// The query is constructed as if it was sprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtPrepare)(SqlStmt* self, const char* query, ...); + int (*StmtPrepare) (SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); /// Prepares the statement. /// Any previous result is freed and all parameter bindings are removed. diff --git a/src/common/strlib.c b/src/common/strlib.c index e2382e6fc..592390770 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -394,16 +394,15 @@ size_t safestrnlen(const char* string, size_t maxlen) /// @param fmt Format string /// @param ... Format arguments /// @return The size of the string or -1 if the buffer is too small -int safesnprintf(char* buf, size_t sz, const char* fmt, ...) -{ +int safesnprintf(char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +int safesnprintf(char *buf, size_t sz, const char *fmt, ...) { va_list ap; int ret; va_start(ap,fmt); ret = vsnprintf(buf, sz, fmt, ap); va_end(ap); - if( ret < 0 || (size_t)ret >= sz ) - {// overflow + if (ret < 0 || (size_t)ret >= sz) { // overflow buf[sz-1] = '\0';// always null-terminate return -1; } @@ -1020,7 +1019,8 @@ void StringBuf_Init(StringBuf* self) { } /// Appends the result of printf to the StringBuf -int StringBuf_Printf(StringBuf* self, const char* fmt, ...) { +int StringBuf_Printf(StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +int StringBuf_Printf(StringBuf *self, const char *fmt, ...) { int len; va_list ap; diff --git a/src/common/strlib.h b/src/common/strlib.h index 7f84d2893..00a588772 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -82,7 +82,7 @@ struct strlib_interface { /// Works like snprintf, but always null-terminates the buffer. /// Returns the size of the string (without null-terminator) /// or -1 if the buffer is too small. - int (*safesnprintf) (char* buf, size_t sz, const char* fmt, ...); + int (*safesnprintf) (char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4))); /// Returns the line of the target position in the string. /// Lines start at 1. @@ -99,7 +99,7 @@ struct strlib_interface *strlib; struct stringbuf_interface { StringBuf* (*Malloc) (void); void (*Init) (StringBuf* self); - int (*Printf) (StringBuf* self, const char* fmt, ...); + int (*Printf) (StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3))); int (*Vprintf) (StringBuf* self, const char* fmt, va_list args); int (*Append) (StringBuf* self, const StringBuf *sbuf); int (*AppendStr) (StringBuf* self, const char* str); diff --git a/src/common/timer.c b/src/common/timer.c index 370eafd4c..5d0a45b99 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -299,8 +299,9 @@ int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) { int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int interval) { int tid; - if( interval < 1 ) { - ShowError("timer_add_interval: invalid interval (tick=%"PRId64" %p[%s] id=%d data=%d diff_tick=%"PRId64")\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); + if (interval < 1) { + ShowError("timer_add_interval: invalid interval (tick=%"PRId64" %p[%s] id=%d data=%"PRIdPTR" diff_tick=%"PRId64")\n", + tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); return INVALID_TIMER; } diff --git a/src/common/utils.c b/src/common/utils.c index 4e6cb49c2..79232b25c 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -64,31 +64,27 @@ void WriteDump(FILE* fp, const void* buffer, size_t length) /// Dumps given buffer on the console. -void ShowDump(const void* buffer, size_t length) -{ +void ShowDump(const void *buffer, size_t length) { size_t i; char hex[48+1], ascii[16+1]; ShowDebug("--- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F 0123456789ABCDEF\n"); ascii[16] = 0; - for( i = 0; i < length; i++ ) - { + for (i = 0; i < length; i++) { char c = RBUFB(buffer,i); ascii[i%16] = ISCNTRL(c) ? '.' : c; sprintf(hex+(i%16)*3, "%02X ", RBUFB(buffer,i)); - if( (i%16) == 15 ) - { - ShowDebug("%03X %s %s\n", i/16, hex, ascii); + if ((i%16) == 15) { + ShowDebug("%03"PRIXS" %s %s\n", i/16, hex, ascii); } } - if( (i%16) != 0 ) - { + if ((i%16) != 0) { ascii[i%16] = 0; - ShowDebug("%03X %-48s %-16s\n", i/16, hex, ascii); + ShowDebug("%03"PRIXS" %-48s %-16s\n", i/16, hex, ascii); } } diff --git a/src/login/login.c b/src/login/login.c index 0488ae4ed..c8e219602 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -306,8 +306,7 @@ int login_lan_config_read(const char *lancfgName) if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n') continue; - if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) - { + if (sscanf(line, "%63[^:]: %63[^:]:%63[^:]:%63[^\r\n]", w1, w2, w3, w4) != 4) { ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num); continue; } @@ -618,10 +617,9 @@ int parse_fromchar(int fd) int sec = (short)RFIFOW(fd,16); RFIFOSKIP(fd,18); - if( !accounts->load_num(accounts, &acc, account_id) ) + if (!accounts->load_num(accounts, &acc, account_id)) { ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); - else - { + } else { time_t timestamp; struct tm *tmtime; if (acc.unban_time == 0 || acc.unban_time < time(NULL)) @@ -629,24 +627,23 @@ int parse_fromchar(int fd) else timestamp = acc.unban_time; // add to existing ban tmtime = localtime(×tamp); - tmtime->tm_year = tmtime->tm_year + year; - tmtime->tm_mon = tmtime->tm_mon + month; - tmtime->tm_mday = tmtime->tm_mday + mday; - tmtime->tm_hour = tmtime->tm_hour + hour; - tmtime->tm_min = tmtime->tm_min + min; - tmtime->tm_sec = tmtime->tm_sec + sec; + tmtime->tm_year += year; + tmtime->tm_mon += month; + tmtime->tm_mday += mday; + tmtime->tm_hour += hour; + tmtime->tm_min += min; + tmtime->tm_sec += sec; timestamp = mktime(tmtime); - if (timestamp == -1) + if (timestamp == -1) { ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", server[id].name, account_id, ip); - else - if( timestamp <= time(NULL) || timestamp == 0 ) + } else if( timestamp <= time(NULL) || timestamp == 0 ) { ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", server[id].name, account_id, ip); - else - { + } else { uint8 buf[11]; char tmpstr[24]; timestamp2string(tmpstr, sizeof(tmpstr), timestamp, login_config.date_format); - ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %d (%s), ip: %s).\n", server[id].name, account_id, timestamp, tmpstr, ip); + ShowNotice("Char-server '%s': Ban request (account: %d, new final date of banishment: %ld (%s), ip: %s).\n", + server[id].name, account_id, (long)timestamp, tmpstr, ip); acc.unban_time = timestamp; @@ -1589,7 +1586,7 @@ int login_config_read(const char* cfgName) 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,"timestamp_format")) 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) { diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 96d51aec6..2ead5edbb 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -129,9 +129,10 @@ void cache_map(char *name, struct map_data *m) encode_zip(write_buf, &len, m->cells, m->xs*m->ys); // Fill the map header - if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed. - ShowWarning ("Map name '%s' size '%d' is too long. Truncating to '%d'.\n", name, strlen(name), MAP_NAME_LENGTH); strncpy(info.name, name, MAP_NAME_LENGTH); + if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed. + ShowWarning("Map name '%s' (length %"PRIuS") is too long. Truncating to '%s' (lentgh %d).\n", + name, strlen(name), info.name, MAP_NAME_LENGTH); info.xs = MakeShortLE(m->xs); info.ys = MakeShortLE(m->ys); info.len = MakeLongLE((uint32)len); |