summaryrefslogtreecommitdiff
path: root/src/map/intif.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-20 04:36:08 +0100
committerHaru <haru@dotalux.com>2015-01-20 04:41:33 +0100
commit4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4 (patch)
treedab9d12a6a4b95a37598e27e6e86d6047360d61b /src/map/intif.c
parent03709c136ad300be631adfd38dc36c2433bda718 (diff)
downloadhercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.gz
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.bz2
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.xz
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.zip
Minor fixes and tweaks suggested by cppcheck
- Variable scopes reduced - Parenthesized ambiguous expressions - Removed or added NULL checks where (un)necessary - Corrected format strings - Fixed typos potentially leading to bugs Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/intif.c')
-rw-r--r--src/map/intif.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/map/intif.c b/src/map/intif.c
index aac04df33..4dbb7e3eb 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -395,9 +395,9 @@ int intif_request_registry(struct map_session_data *sd, int flag)
WFIFOW(inter_fd,0) = 0x3005;
WFIFOL(inter_fd,2) = sd->status.account_id;
WFIFOL(inter_fd,6) = sd->status.char_id;
- WFIFOB(inter_fd,10) = (flag&1?1:0); //Request Acc Reg 2
- WFIFOB(inter_fd,11) = (flag&2?1:0); //Request Acc Reg
- WFIFOB(inter_fd,12) = (flag&4?1:0); //Request Char Reg
+ WFIFOB(inter_fd,10) = (flag&1) ? 1 : 0; //Request Acc Reg 2
+ WFIFOB(inter_fd,11) = (flag&2) ? 1 : 0; //Request Acc Reg
+ WFIFOB(inter_fd,12) = (flag&4) ? 1 : 0; //Request Char Reg
WFIFOSET(inter_fd,13);
return 0;
@@ -968,7 +968,7 @@ void mapif_parse_WisToGM(int fd)
{
int permission, mes_len;
char Wisp_name[NAME_LENGTH];
- char mbuf[255];
+ char mbuf[255] = { 0 };
char *message;
mes_len = RFIFOW(fd,2) - 32;
@@ -987,7 +987,7 @@ void mapif_parse_WisToGM(int fd)
// Request player registre
void intif_parse_Registers(int fd)
{
- int i, flag;
+ int flag;
struct map_session_data *sd;
int account_id = RFIFOL(fd,4), char_id = RFIFOL(fd,8);
struct auth_node *node = chrif->auth_check(account_id, char_id, ST_LOGIN);
@@ -1025,9 +1025,9 @@ void intif_parse_Registers(int fd)
pc->reg_load = true;
if( RFIFOW(fd, 14) ) {
- char key[32], sval[254];
+ char key[32];
unsigned int index;
- int max = RFIFOW(fd, 14), cursor = 16, ival;
+ int max = RFIFOW(fd, 14), cursor = 16, i;
script->parser_current_file = "loading char/acc variables";//for script_add_str to refer to here in case errors occur
@@ -1037,8 +1037,9 @@ void intif_parse_Registers(int fd)
* str type
* { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
**/
- if( type ) {
+ if (type) {
for(i = 0; i < max; i++) {
+ char sval[254];
safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
cursor += RFIFOB(fd, cursor) + 1;
@@ -1058,6 +1059,7 @@ void intif_parse_Registers(int fd)
**/
} else {
for(i = 0; i < max; i++) {
+ int ival;
safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
cursor += RFIFOB(fd, cursor) + 1;