diff options
author | Haru <haru@dotalux.com> | 2016-01-07 16:47:24 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-02-24 21:00:26 +0100 |
commit | 3188738be5ee78651e31c1340fac7fed81bbefb5 (patch) | |
tree | 97ea854a3c77884e817c02dc069b980ccc42ee74 | |
parent | a79ab6c3d11c7d6fcd1f04400f50b93f72e570e1 (diff) | |
download | hercules-3188738be5ee78651e31c1340fac7fed81bbefb5.tar.gz hercules-3188738be5ee78651e31c1340fac7fed81bbefb5.tar.bz2 hercules-3188738be5ee78651e31c1340fac7fed81bbefb5.tar.xz hercules-3188738be5ee78651e31c1340fac7fed81bbefb5.zip |
Removed several unnecessary RFIFOP typecasts
- While this is arguable, those explicit typecasts are potentially
dangerous/misleading (for example, a const specifier might get
accidentally dropped without even generating a compiler warning, or a
variable type might change during code changes, and any related
warning would get silenced by the explicit typecast).
- As a reminder Hercules is written in C, and not in C++ (and there's
no such thing as "compiling in C++ mode" - they're two different
languages.) As such, it is legal to let the compiler automatically
promote void* from/to any non-const pointer type, as well as const
void* from/to any const pointer type.
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | src/char/char.c | 25 | ||||
-rw-r--r-- | src/char/int_auction.c | 2 | ||||
-rw-r--r-- | src/char/int_elemental.c | 4 | ||||
-rw-r--r-- | src/char/int_guild.c | 22 | ||||
-rw-r--r-- | src/char/int_homun.c | 6 | ||||
-rw-r--r-- | src/char/int_mercenary.c | 4 | ||||
-rw-r--r-- | src/char/int_party.c | 6 | ||||
-rw-r--r-- | src/char/int_pet.c | 4 | ||||
-rw-r--r-- | src/char/int_quest.c | 2 | ||||
-rw-r--r-- | src/char/int_storage.c | 2 | ||||
-rw-r--r-- | src/char/inter.c | 13 | ||||
-rw-r--r-- | src/char/pincode.c | 8 | ||||
-rw-r--r-- | src/login/account_sql.c | 4 | ||||
-rw-r--r-- | src/login/login.c | 22 | ||||
-rw-r--r-- | src/map/chrif.c | 8 | ||||
-rw-r--r-- | src/map/clif.c | 111 | ||||
-rw-r--r-- | src/map/intif.c | 72 | ||||
-rw-r--r-- | src/map/irc-bot.c | 2 |
18 files changed, 158 insertions, 159 deletions
diff --git a/src/char/char.c b/src/char/char.c index 1e477ba6e..7dad470ec 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2378,8 +2378,8 @@ void char_parse_fromlogin_account_data(int fd) sd->char_slots = MAX_CHARS;/* cap to maximum */ } else if ( sd->char_slots <= 0 )/* no value aka 0 in sql */ sd->char_slots = MAX_CHARS;/* cap to maximum */ - safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,52), sizeof(sd->birthdate)); - safestrncpy(sd->pincode, (const char*)RFIFOP(fd,63), sizeof(sd->pincode)); + safestrncpy(sd->birthdate, RFIFOP(fd,52), sizeof(sd->birthdate)); + safestrncpy(sd->pincode, RFIFOP(fd,63), sizeof(sd->pincode)); sd->pincode_change = RFIFOL(fd,68); // continued from chr->auth_ok... if( (max_connect_user == 0 && sd->group_id != gm_allow_group) || @@ -2606,9 +2606,8 @@ void char_parse_fromlogin_accinfo2_failed(int fd) void char_parse_fromlogin_accinfo2_ok(int fd) { mapif->parse_accinfo2(true, RFIFOL(fd,167), RFIFOL(fd,171), RFIFOL(fd,175), RFIFOL(fd,179), - (char*)RFIFOP(fd,2), (char*)RFIFOP(fd,26), (char*)RFIFOP(fd,59), - (char*)RFIFOP(fd,99), (char*)RFIFOP(fd,119), (char*)RFIFOP(fd,151), - (char*)RFIFOP(fd,156), RFIFOL(fd,115), RFIFOL(fd,143), RFIFOL(fd,147)); + RFIFOP(fd,2), RFIFOP(fd,26), RFIFOP(fd,59), RFIFOP(fd,99), RFIFOP(fd,119), + RFIFOP(fd,151), RFIFOP(fd,156), RFIFOL(fd,115), RFIFOL(fd,143), RFIFOL(fd,147)); RFIFOSKIP(fd,183); } @@ -3513,7 +3512,7 @@ void char_parse_frommap_change_account(int fd) char esc_name[NAME_LENGTH*2+1]; int acc = RFIFOL(fd,2); // account_id of who ask (-1 if server itself made this request) - const char* name = (char*)RFIFOP(fd,6); // name of the target character + const char *name = RFIFOP(fd,6); // name of the target character int type = RFIFOW(fd,30); // type of operation: 1-block, 2-ban, 3-unblock, 4-unban, 5 changesex, 6 charban, 7 charunban short year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0; int sex = SEX_MALE; @@ -3856,7 +3855,7 @@ void char_parse_frommap_request_stats_report(int fd) WFIFOHEAD(sfd, RFIFOW(fd,2) ); - memcpy((char*)WFIFOP(sfd,0), (char*)RFIFOP(fd, 0), RFIFOW(fd,2)); + memcpy((char*)WFIFOP(sfd,0), RFIFOP(fd, 0), RFIFOW(fd,2)); WFIFOSET(sfd, RFIFOW(fd,2) ); @@ -4734,9 +4733,9 @@ void char_parse_char_create_new_char(int fd, struct char_session_data* sd) result = -2; } else { #if PACKETVER >= 20120307 - result = chr->make_new_char_sql(sd, (char*)RFIFOP(fd,2), 1, 1, 1, 1, 1, 1, RFIFOB(fd,26),RFIFOW(fd,27),RFIFOW(fd,29)); + result = chr->make_new_char_sql(sd, RFIFOP(fd,2), 1, 1, 1, 1, 1, 1, RFIFOB(fd,26),RFIFOW(fd,27),RFIFOW(fd,29)); #else - result = chr->make_new_char_sql(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35)); + result = chr->make_new_char_sql(sd, RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35)); #endif } @@ -4850,7 +4849,7 @@ void char_parse_char_rename_char(int fd, struct char_session_data* sd) int i, cid =RFIFOL(fd,2); char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1]; - safestrncpy(name, (char *)RFIFOP(fd,6), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,6), NAME_LENGTH); RFIFOSKIP(fd,30); ARR_FIND( 0, MAX_CHARS, i, sd->found_char[i] == cid ); @@ -4875,7 +4874,7 @@ void char_parse_char_rename_char2(int fd, struct char_session_data* sd) int i, aid = RFIFOL(fd,2), cid =RFIFOL(fd,6); char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1]; - safestrncpy(name, (char *)RFIFOP(fd,10), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,10), NAME_LENGTH); RFIFOSKIP(fd,34); if( aid != sd->account_id ) @@ -4974,8 +4973,8 @@ void char_parse_char_login_map_server(int fd, uint32 ipl) { char l_user[24], l_pass[24]; int i; - safestrncpy(l_user, (char *)RFIFOP(fd,2), 24); - safestrncpy(l_pass, (char *)RFIFOP(fd,26), 24); + safestrncpy(l_user, RFIFOP(fd,2), 24); + safestrncpy(l_pass, RFIFOP(fd,26), 24); ARR_FIND( 0, ARRAYLENGTH(chr->server), i, chr->server[i].fd <= 0 ); if (core->runflag != CHARSERVER_ST_RUNNING || diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 90dd75962..464a2092b 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -462,7 +462,7 @@ void mapif_parse_auction_bid(int fd) } auction->buyer_id = char_id; - safestrncpy(auction->buyer_name, (char*)RFIFOP(fd,16), NAME_LENGTH); + safestrncpy(auction->buyer_name, RFIFOP(fd,16), NAME_LENGTH); auction->price = bid; if( bid >= auction->buynow ) diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 70275725d..fe8bab0de 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -212,10 +212,10 @@ int inter_elemental_parse_frommap(int fd) { unsigned short cmd = RFIFOW(fd,0); switch( cmd ) { - case 0x307c: mapif->parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break; + case 0x307c: mapif->parse_elemental_create(fd, RFIFOP(fd,4)); break; case 0x307d: mapif->parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; case 0x307e: mapif->parse_elemental_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x307f: mapif->parse_elemental_save(fd, (struct s_elemental*)RFIFOP(fd,4)); break; + case 0x307f: mapif->parse_elemental_save(fd, RFIFOP(fd,4)); break; default: return 0; } diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 04de75a20..2ba50d277 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -1902,22 +1902,22 @@ int inter_guild_parse_frommap(int fd) { RFIFOHEAD(fd); switch(RFIFOW(fd,0)) { - case 0x3030: mapif->parse_CreateGuild(fd,RFIFOL(fd,4),(char*)RFIFOP(fd,8),(struct guild_member *)RFIFOP(fd,32)); break; + case 0x3030: mapif->parse_CreateGuild(fd, RFIFOL(fd,4), RFIFOP(fd,8), RFIFOP(fd,32)); break; case 0x3031: mapif->parse_GuildInfo(fd,RFIFOL(fd,2)); break; - case 0x3032: mapif->parse_GuildAddMember(fd,RFIFOL(fd,4),(struct guild_member *)RFIFOP(fd,8)); break; - case 0x3033: mapif->parse_GuildMasterChange(fd,RFIFOL(fd,4),(const char*)RFIFOP(fd,8),RFIFOW(fd,2)-8); break; - case 0x3034: mapif->parse_GuildLeave(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(const char*)RFIFOP(fd,15)); break; + case 0x3032: mapif->parse_GuildAddMember(fd, RFIFOL(fd,4), RFIFOP(fd,8)); break; + case 0x3033: mapif->parse_GuildMasterChange(fd, RFIFOL(fd,4), RFIFOP(fd,8), RFIFOW(fd,2)-8); break; + case 0x3034: mapif->parse_GuildLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOP(fd,15)); break; case 0x3035: mapif->parse_GuildChangeMemberInfoShort(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),RFIFOW(fd,15),RFIFOW(fd,17)); break; case 0x3036: mapif->parse_BreakGuild(fd,RFIFOL(fd,2)); break; - case 0x3037: mapif->parse_GuildMessage(fd,RFIFOL(fd,4),RFIFOL(fd,8),(char*)RFIFOP(fd,12),RFIFOW(fd,2)-12); break; - case 0x3039: mapif->parse_GuildBasicInfoChange(fd,RFIFOL(fd,4),RFIFOW(fd,8),(const int16 *)RFIFOP(fd,10),RFIFOW(fd,2)-10); break; - case 0x303A: mapif->parse_GuildMemberInfoChange(fd,RFIFOL(fd,4),RFIFOL(fd,8),RFIFOL(fd,12),RFIFOW(fd,16),(const char*)RFIFOP(fd,18),RFIFOW(fd,2)-18); break; - case 0x303B: mapif->parse_GuildPosition(fd,RFIFOL(fd,4),RFIFOL(fd,8),(struct guild_position *)RFIFOP(fd,12)); break; + case 0x3037: mapif->parse_GuildMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break; + case 0x3039: mapif->parse_GuildBasicInfoChange(fd, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOP(fd,10), RFIFOW(fd,2)-10); break; + case 0x303A: mapif->parse_GuildMemberInfoChange(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOL(fd,12), RFIFOW(fd,16), RFIFOP(fd,18), RFIFOW(fd,2)-18); break; + case 0x303B: mapif->parse_GuildPosition(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12)); break; case 0x303C: mapif->parse_GuildSkillUp(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14)); break; case 0x303D: mapif->parse_GuildAlliance(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18)); break; - case 0x303E: mapif->parse_GuildNotice(fd,RFIFOL(fd,2),(const char*)RFIFOP(fd,6),(const char*)RFIFOP(fd,66)); break; - case 0x303F: mapif->parse_GuildEmblem(fd,RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8),(const char*)RFIFOP(fd,12)); break; - case 0x3040: mapif->parse_GuildCastleDataLoad(fd,RFIFOW(fd,2),(int *)RFIFOP(fd,4)); break; + case 0x303E: mapif->parse_GuildNotice(fd, RFIFOL(fd,2), RFIFOP(fd,6), RFIFOP(fd,66)); break; + case 0x303F: mapif->parse_GuildEmblem(fd, RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12)); break; + case 0x3040: mapif->parse_GuildCastleDataLoad(fd, RFIFOW(fd,2), RFIFOP(fd,4)); break; case 0x3041: mapif->parse_GuildCastleDataSave(fd,RFIFOW(fd,2),RFIFOB(fd,4),RFIFOL(fd,5)); break; default: diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 1377bfbd8..2179b2aa3 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -347,11 +347,11 @@ int inter_homunculus_parse_frommap(int fd) switch( cmd ) { - case 0x3090: mapif->parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; + case 0x3090: mapif->parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), RFIFOP(fd,8)); break; case 0x3091: mapif->parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; - case 0x3092: mapif->parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; + case 0x3092: mapif->parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), RFIFOP(fd,8)); break; case 0x3093: mapif->parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x3094: mapif->parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break; + case 0x3094: mapif->parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), RFIFOP(fd,10)); break; default: return 0; } diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index 671c71278..0c3a7fdf8 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -262,10 +262,10 @@ int inter_mercenary_parse_frommap(int fd) switch( cmd ) { - case 0x3070: mapif->parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; + case 0x3070: mapif->parse_mercenary_create(fd, RFIFOP(fd,4)); break; case 0x3071: mapif->parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; case 0x3072: mapif->parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x3073: mapif->parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; + case 0x3073: mapif->parse_mercenary_save(fd, RFIFOP(fd,4)); break; default: return 0; } diff --git a/src/char/int_party.c b/src/char/int_party.c index 8ff9ca3a2..c011f1b8f 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -769,14 +769,14 @@ int inter_party_parse_frommap(int fd) { RFIFOHEAD(fd); switch(RFIFOW(fd,0)) { - case 0x3020: mapif->parse_CreateParty(fd, (char*)RFIFOP(fd,4), RFIFOB(fd,28), RFIFOB(fd,29), (struct party_member*)RFIFOP(fd,30)); break; + case 0x3020: mapif->parse_CreateParty(fd, RFIFOP(fd,4), RFIFOB(fd,28), RFIFOB(fd,29), RFIFOP(fd,30)); break; case 0x3021: mapif->parse_PartyInfo(fd, RFIFOL(fd,2), RFIFOL(fd,6)); break; - case 0x3022: mapif->parse_PartyAddMember(fd, RFIFOL(fd,4), (struct party_member*)RFIFOP(fd,8)); break; + case 0x3022: mapif->parse_PartyAddMember(fd, RFIFOL(fd,4), RFIFOP(fd,8)); break; case 0x3023: mapif->parse_PartyChangeOption(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOW(fd,10), RFIFOW(fd,12)); break; case 0x3024: mapif->parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; case 0x3025: mapif->parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOW(fd,14), RFIFOB(fd,16), RFIFOW(fd,17)); break; case 0x3026: mapif->parse_BreakParty(fd, RFIFOL(fd,2)); break; - case 0x3027: mapif->parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break; + case 0x3027: mapif->parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break; case 0x3029: mapif->parse_PartyLeaderChange(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break; default: return 0; diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 676ce6ed6..eb9bda8d0 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -311,7 +311,7 @@ int mapif_parse_CreatePet(int fd) { RFIFOHEAD(fd); mapif->create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18), - RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24)); + RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), RFIFOP(fd, 24)); return 0; } @@ -325,7 +325,7 @@ int mapif_parse_LoadPet(int fd) int mapif_parse_SavePet(int fd) { RFIFOHEAD(fd); - mapif->save_pet(fd, RFIFOL(fd, 4), (struct s_pet *) RFIFOP(fd, 8)); + mapif->save_pet(fd, RFIFOL(fd, 4), RFIFOP(fd, 8)); return 0; } diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 9478b532d..b28c81331 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -223,7 +223,7 @@ int mapif_parse_quest_save(int fd) bool success = true; if (new_n > 0) - new_qd = (struct quest*)RFIFOP(fd,8); + new_qd = RFIFOP(fd,8); old_qd = mapif->quests_fromsql(char_id, &old_n); diff --git a/src/char/int_storage.c b/src/char/int_storage.c index e98f538a2..b41e6382d 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -247,7 +247,7 @@ int mapif_parse_SaveGuildStorage(int fd) } else if(SQL->NumRows(inter->sql_handle) > 0) { // guild exists SQL->FreeResult(inter->sql_handle); - inter_storage->guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12)); + inter_storage->guild_storage_tosql(guild_id, RFIFOP(fd,12)); mapif->save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); return 0; } diff --git a/src/char/inter.c b/src/char/inter.c index 8dec21a77..1e122ec08 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -446,7 +446,7 @@ void mapif_parse_accinfo(int fd) int account_id; char *data; - safestrncpy(query, (char*) RFIFOP(fd,14), NAME_LENGTH); + safestrncpy(query, RFIFOP(fd,14), NAME_LENGTH); SQL->EscapeString(inter->sql_handle, query_esq, query); @@ -1101,7 +1101,7 @@ int mapif_parse_WisRequest(int fd) return 0; } - safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex] + safestrncpy(name, RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex] SQL->EscapeStringLen(inter->sql_handle, esc_name, name, strnlen(name, NAME_LENGTH)); if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) ) @@ -1119,8 +1119,7 @@ int mapif_parse_WisRequest(int fd) memset(name, 0, NAME_LENGTH); memcpy(name, data, min(len, NAME_LENGTH)); // if source is destination, don't ask other servers. - if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 ) - { + if (strncmp(RFIFOP(fd,4), name, NAME_LENGTH) == 0) { mapif->wis_response(fd, RFIFOP(fd, 4), 1); } else @@ -1195,7 +1194,7 @@ int mapif_parse_Registry(int fd) for(i = 0; i < count; i++) { unsigned int index; int len = RFIFOB(fd, cursor); - safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); + safestrncpy(key, RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); cursor += len + 1; index = RFIFOL(fd, cursor); @@ -1213,7 +1212,7 @@ int mapif_parse_Registry(int fd) /* str */ case 2: len = RFIFOB(fd, cursor); - safestrncpy(sval, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); + safestrncpy(sval, RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); cursor += len + 1; inter->savereg(account_id,char_id,key,index,(intptr_t)sval,true); break; @@ -1267,7 +1266,7 @@ int mapif_parse_NameChangeRequest(int fd) account_id = RFIFOL(fd,2); char_id = RFIFOL(fd,6); type = RFIFOB(fd,10); - name = (char*)RFIFOP(fd,11); + name = RFIFOP(fd,11); // Check Authorized letters/symbols in the name if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorized diff --git a/src/char/pincode.c b/src/char/pincode.c index 371442fac..83509576a 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -67,7 +67,7 @@ void pincode_check(int fd, struct char_session_data* sd) { char pin[5] = "\0\0\0\0"; nullpo_retv(sd); - safestrncpy(pin, (char*)RFIFOP(fd, 6), sizeof(pin)); + safestrncpy(pin, RFIFOP(fd, 6), sizeof(pin)); pincode->decrypt(sd->pincode_seed, pin); if( pincode->compare( fd, sd, pin ) ){ struct online_char_data* character; @@ -96,12 +96,12 @@ void pincode_change(int fd, struct char_session_data* sd) { char oldpin[5] = "\0\0\0\0", newpin[5] = "\0\0\0\0"; nullpo_retv(sd); - safestrncpy(oldpin, (char*)RFIFOP(fd,6), sizeof(oldpin)); + safestrncpy(oldpin, RFIFOP(fd,6), sizeof(oldpin)); pincode->decrypt(sd->pincode_seed,oldpin); if( !pincode->compare( fd, sd, oldpin ) ) return; - safestrncpy(newpin, (char*)RFIFOP(fd,10), sizeof(newpin)); + safestrncpy(newpin, RFIFOP(fd,10), sizeof(newpin)); pincode->decrypt(sd->pincode_seed,newpin); pincode->update( sd->account_id, newpin ); safestrncpy(sd->pincode, newpin, sizeof(sd->pincode)); @@ -112,7 +112,7 @@ void pincode_setnew(int fd, struct char_session_data* sd) { char newpin[5] = "\0\0\0\0"; nullpo_retv(sd); - safestrncpy(newpin, (char*)RFIFOP(fd,6), sizeof(newpin)); + safestrncpy(newpin, RFIFOP(fd,6), sizeof(newpin)); pincode->decrypt(sd->pincode_seed,newpin); pincode->update( sd->account_id, newpin ); safestrncpy(sd->pincode, newpin, sizeof(sd->pincode)); diff --git a/src/login/account_sql.c b/src/login/account_sql.c index cb6fdba99..be797c443 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -719,7 +719,7 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { for (i = 0; i < count; i++) { unsigned int index; int len = RFIFOB(fd, cursor); - safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); + safestrncpy(key, RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); cursor += len + 1; index = RFIFOL(fd, cursor); @@ -739,7 +739,7 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { /* str */ case 2: len = RFIFOB(fd, cursor); - safestrncpy(sval, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); + safestrncpy(sval, RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); cursor += len + 1; if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", db->global_acc_reg_str_db, account_id, key, index, sval) ) Sql_ShowDebug(sql_handle); diff --git a/src/login/login.c b/src/login/login.c index 8181cdae9..cedaeec2b 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -352,7 +352,7 @@ void login_fromchar_parse_request_change_email(int fd, int id, const char *const char email[40]; int account_id = RFIFOL(fd,2); - safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email); + safestrncpy(email, RFIFOP(fd,6), 40); remove_control_chars(email); RFIFOSKIP(fd,46); if( e_mail_check(email) == 0 ) @@ -449,8 +449,8 @@ void login_fromchar_parse_change_email(int fd, int id, const char *const ip) char new_email[40]; int account_id = RFIFOL(fd,2); - safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); - safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); + safestrncpy(actual_email, RFIFOP(fd,6), 40); + safestrncpy(new_email, RFIFOP(fd,46), 40); RFIFOSKIP(fd, 86); if( e_mail_check(actual_email) == 0 ) @@ -699,7 +699,7 @@ void login_fromchar_parse_change_pincode(int fd) struct mmo_account acc; if (accounts->load_num(accounts, &acc, RFIFOL(fd,2))) { - safestrncpy(acc.pincode, (char*)RFIFOP(fd,6), sizeof(acc.pincode)); + safestrncpy(acc.pincode, RFIFOP(fd,6), sizeof(acc.pincode)); acc.pincode_change = ((unsigned int)time(NULL)); accounts->save(accounts, &acc); } @@ -1429,8 +1429,8 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char // Shinryo: For the time being, just use token as password. if(command == 0x0825) { - const char *accname = (char *)RFIFOP(fd, 9); - const char *token = (char *)RFIFOP(fd, 0x5C); + const char *accname = RFIFOP(fd, 9); + const char *token = RFIFOP(fd, 0x5C); size_t uAccLen = strlen(accname); size_t uTokenLen = RFIFOREST(fd) - 0x5C; @@ -1448,10 +1448,10 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char else { version = RFIFOL(fd,2); - safestrncpy(username, (const char*)RFIFOP(fd,6), NAME_LENGTH); + safestrncpy(username, RFIFOP(fd,6), NAME_LENGTH); if( israwpass ) { - safestrncpy(password, (const char*)RFIFOP(fd,30), NAME_LENGTH); + safestrncpy(password, RFIFOP(fd,30), NAME_LENGTH); clienttype = RFIFOB(fd,54); } else @@ -1534,15 +1534,15 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const uint16 new_; int result; - safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); - safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); + safestrncpy(sd->userid, RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(sd->passwd, RFIFOP(fd,26), NAME_LENGTH); if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; sd->version = login->config->client_version_to_connect; // hack to skip version check server_ip = ntohl(RFIFOL(fd,54)); server_port = ntohs(RFIFOW(fd,58)); - safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); + safestrncpy(server_name, RFIFOP(fd,60), 20); type = RFIFOW(fd,82); new_ = RFIFOW(fd,84); RFIFOSKIP(fd,86); diff --git a/src/map/chrif.c b/src/map/chrif.c index e14684e54..343892782 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -611,7 +611,7 @@ void chrif_authok(int fd) { expiration_time = (time_t)(int32)RFIFOL(fd,16); group_id = RFIFOL(fd,20); changing_mapservers = (RFIFOB(fd,24)); - charstatus = (struct mmo_charstatus*)RFIFOP(fd,25); + charstatus = RFIFOP(fd,25); char_id = charstatus->char_id; //Check if we don't already have player data in our server @@ -1221,7 +1221,7 @@ bool chrif_load_scdata(int fd) { count = RFIFOW(fd,12); //sc_count for (i = 0; i < count; i++) { - const struct status_change_data *data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data)); + const struct status_change_data *data = RFIFOP(fd,14 + i*sizeof(struct status_change_data)); status->change_start(NULL, &sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE); } @@ -1436,10 +1436,10 @@ int chrif_parse(int fd) { case 0x2b03: clif->charselectok(RFIFOL(fd,2), RFIFOB(fd,6)); break; case 0x2b04: chrif->recvmap(fd); break; case 0x2b06: chrif->changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break; - case 0x2b09: map->addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break; + case 0x2b09: map->addnickdb(RFIFOL(fd,2), RFIFOP(fd,6)); break; case 0x2b0a: sockt->datasync(fd, false); break; case 0x2b0d: chrif->changedsex(fd); break; - case 0x2b0f: chrif->char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break; + case 0x2b0f: chrif->char_ask_name_answer(RFIFOL(fd,2), RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break; case 0x2b12: chrif->divorceack(RFIFOL(fd,2), RFIFOL(fd,6)); break; case 0x2b14: chrif->idbanned(fd); break; case 0x2b1b: chrif->recvfamelist(fd); break; diff --git a/src/map/clif.c b/src/map/clif.c index 1cb925303..942330d29 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8894,7 +8894,7 @@ bool clif_process_message(struct map_session_data *sd, int format, const char ** return false; } - text = (char*)RFIFOP(fd,4); + text = RFIFOP(fd,4); textlen = packetlen - 4; // process <name> part of the packet @@ -9715,7 +9715,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) __attribute__ /// There are various variants of this packet. void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) { - const char* text = (char*)RFIFOP(fd,4); + const char *text = RFIFOP(fd,4); size_t textlen = RFIFOW(fd,2) - 4; const char *name = NULL, *message = NULL; @@ -9858,7 +9858,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd) char command[MAP_NAME_LENGTH_EXT+25]; char map_name[MAP_NAME_LENGTH_EXT]; - safestrncpy(map_name, (char*)RFIFOP(fd,2), MAP_NAME_LENGTH_EXT); + safestrncpy(map_name, RFIFOP(fd,2), MAP_NAME_LENGTH_EXT); sprintf(command, "%cmapmove %s %d %d", atcommand->at_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20)); atcommand->exec(fd, sd, command, true); } @@ -10275,7 +10275,7 @@ void clif_parse_Broadcast(int fd, struct map_session_data *sd) if (len >= (int)(sizeof command - strlen(command))) len = (int)(sizeof command - strlen(command)) - 1; - strncat(command, (char*)RFIFOP(fd,4), len); + strncat(command, RFIFOP(fd,4), len); atcommand->exec(fd, sd, command, true); } @@ -10539,7 +10539,7 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd) result = 1; } else { unsigned short *item_list = aMalloc(sizeof(*item_list) * 2 * n); - memcpy(item_list, (unsigned short*)RFIFOP(fd,4), sizeof(*item_list) * 2 * n); + memcpy(item_list, RFIFOP(fd,4), sizeof(*item_list) * 2 * n); result = npc->buylist(sd,n,item_list); aFree(item_list); } @@ -10578,7 +10578,7 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd) fail = 1; } else { unsigned short *item_list = aMalloc(sizeof(*item_list) * 2 * n); - memcpy(item_list, (unsigned short*)RFIFOP(fd,4), sizeof(*item_list) * 2 * n); + memcpy(item_list, RFIFOP(fd,4), sizeof(*item_list) * 2 * n); fail = npc->selllist(sd,n,item_list); aFree(item_list); } @@ -10599,8 +10599,8 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) int len = RFIFOW(fd,2)-15; int limit = RFIFOW(fd,4); bool pub = (RFIFOB(fd,6) != 0); - const char* password = (char*)RFIFOP(fd,7); //not zero-terminated - const char* title = (char*)RFIFOP(fd,15); // not zero-terminated + const char *password = RFIFOP(fd,7); //not zero-terminated + const char *title = RFIFOP(fd,15); // not zero-terminated char s_password[CHATROOM_PASS_SIZE]; char s_title[CHATROOM_TITLE_SIZE]; @@ -10634,7 +10634,7 @@ void clif_parse_ChatAddMember(int fd, struct map_session_data* sd) __attribute__ void clif_parse_ChatAddMember(int fd, struct map_session_data* sd) { int chatid = RFIFOL(fd,2); - const char* password = (char*)RFIFOP(fd,6); // not zero-terminated + const char *password = RFIFOP(fd,6); // not zero-terminated chat->join(sd,chatid,password); } @@ -10650,8 +10650,8 @@ void clif_parse_ChatRoomStatusChange(int fd, struct map_session_data* sd) int len = RFIFOW(fd,2)-15; int limit = RFIFOW(fd,4); bool pub = (RFIFOB(fd,6) != 0); - const char* password = (char*)RFIFOP(fd,7); // not zero-terminated - const char* title = (char*)RFIFOP(fd,15); // not zero-terminated + const char *password = RFIFOP(fd,7); // not zero-terminated + const char *title = RFIFOP(fd,15); // not zero-terminated char s_password[CHATROOM_PASS_SIZE]; char s_title[CHATROOM_TITLE_SIZE]; @@ -10672,7 +10672,7 @@ void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) __attribute /// 1 = normal void clif_parse_ChangeChatOwner(int fd, struct map_session_data* sd) { - chat->change_owner(sd,(char*)RFIFOP(fd,6)); + chat->change_owner(sd, RFIFOP(fd,6)); } void clif_parse_KickFromChat(int fd,struct map_session_data *sd) __attribute__((nonnull (2))); @@ -10680,7 +10680,7 @@ void clif_parse_KickFromChat(int fd,struct map_session_data *sd) __attribute__(( /// 00e2 <name>.24B void clif_parse_KickFromChat(int fd,struct map_session_data *sd) { - chat->kick(sd,(char*)RFIFOP(fd,2)); + chat->kick(sd, RFIFOP(fd,2)); } void clif_parse_ChatLeave(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); @@ -11168,7 +11168,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski return; } //You can't use Graffiti/TalkieBox AND have a vending open, so this is safe. - safestrncpy(sd->message, (char*)RFIFOP(fd,skillmoreinfo), MESSAGE_SIZE); + safestrncpy(sd->message, RFIFOP(fd,skillmoreinfo), MESSAGE_SIZE); } if( sd->ud.skilltimer != INVALID_TIMER ) @@ -11261,7 +11261,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) uint16 skill_id = RFIFOW(fd,2); char map_name[MAP_NAME_LENGTH]; - mapindex->getmapname((char*)RFIFOP(fd,4), map_name); + mapindex->getmapname(RFIFOP(fd,4), map_name); sd->state.workinprogress = 0; if(skill_id != sd->menuskill_id) @@ -11438,7 +11438,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) { int message_len = RFIFOW(fd,2)-8; int npcid = RFIFOL(fd,4); - const char* message = (char*)RFIFOP(fd,8); + const char *message = RFIFOP(fd,8); if( message_len <= 0 ) return; // invalid input @@ -11611,7 +11611,7 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data *sd) if (len >= (int)(sizeof command - strlen(command))) len = (int)(sizeof command - strlen(command)) - 1; - strncat(command, (char*)RFIFOP(fd,4), len); + strncat(command, RFIFOP(fd,4), len); atcommand->exec(fd, sd, command, true); } @@ -11762,7 +11762,7 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) { char name[NAME_LENGTH]; - safestrncpy(name, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,2), NAME_LENGTH); if( map->list[sd->bl.m].flag.partylock ) { // Party locked. @@ -11784,7 +11784,7 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) int item1 = RFIFOB(fd,26); int item2 = RFIFOB(fd,27); - safestrncpy(name, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,2), NAME_LENGTH); if( map->list[sd->bl.m].flag.partylock ) { // Party locked. @@ -11828,7 +11828,7 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) struct map_session_data *t_sd; char name[NAME_LENGTH]; - safestrncpy(name, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,2), NAME_LENGTH); if(map->list[sd->bl.m].flag.partylock) { // Party locked. @@ -11885,7 +11885,7 @@ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) { clif->message(fd, msg_fd(fd,227)); return; } - party->removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6)); + party->removemember(sd, RFIFOL(fd,2), RFIFOP(fd,6)); } void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -11924,7 +11924,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) __attribute__( /// 0108 <packet len>.W <text>.?B (<name> : <message>) 00 void clif_parse_PartyMessage(int fd, struct map_session_data* sd) { - const char* text = (char*)RFIFOP(fd,4); + const char *text = RFIFOP(fd,4); int textlen = RFIFOW(fd,2) - 4; const char *name, *message; @@ -12182,7 +12182,7 @@ void clif_parse_PartyRecruitRegisterReq(int fd, struct map_session_data* sd) { #ifdef PARTY_RECRUIT short level = RFIFOW(fd,2); - const char *notice = (const char*)RFIFOP(fd, 4); + const char *notice = RFIFOP(fd, 4); party->recruit_register(sd, level, notice); #else @@ -12305,9 +12305,7 @@ void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd) __att void clif_parse_PartyRecruitUpdateReq(int fd, struct map_session_data *sd) { #ifdef PARTY_RECRUIT - const char *notice; - - notice = (const char*)RFIFOP(fd, 2); + const char *notice = RFIFOP(fd, 2); party->recruit_update(sd, notice); #else @@ -12609,7 +12607,7 @@ void clif_parse_PurchaseReq(int fd, struct map_session_data* sd) { int len = (int)RFIFOW(fd,2) - 8; int id = (int)RFIFOL(fd,4); - const uint8* data = (uint8*)RFIFOP(fd,8); + const uint8 *data = RFIFOP(fd,8); vending->purchase(sd, id, sd->vended_id, data, len/4); @@ -12625,7 +12623,7 @@ void clif_parse_PurchaseReq2(int fd, struct map_session_data* sd) int len = (int)RFIFOW(fd,2) - 12; int aid = (int)RFIFOL(fd,4); int uid = (int)RFIFOL(fd,8); - const uint8* data = (uint8*)RFIFOP(fd,12); + const uint8 *data = RFIFOP(fd,12); vending->purchase(sd, aid, uid, data, len/4); @@ -12642,9 +12640,9 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) __attribute__(( /// 1 = open void clif_parse_OpenVending(int fd, struct map_session_data* sd) { short len = (short)RFIFOW(fd,2) - 85; - const char* message = (char*)RFIFOP(fd,4); + const char *message = RFIFOP(fd,4); bool flag = (bool)RFIFOB(fd,84); - const uint8* data = (uint8*)RFIFOP(fd,85); + const uint8 *data = RFIFOP(fd,85); if( !flag ) sd->state.prevend = sd->state.workinprogress = 0; @@ -12672,7 +12670,7 @@ void clif_parse_CreateGuild(int fd,struct map_session_data *sd) __attribute__((n void clif_parse_CreateGuild(int fd,struct map_session_data *sd) { char name[NAME_LENGTH]; - safestrncpy(name, (char*)RFIFOP(fd,6), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,6), NAME_LENGTH); if(map->list[sd->bl.m].flag.guildlock) { //Guild locked. @@ -12743,7 +12741,7 @@ void clif_parse_GuildChangePositionInfo(int fd, struct map_session_data *sd) return; for(i = 4; i < RFIFOW(fd,2); i += 40 ){ - guild->change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), (char*)RFIFOP(fd,i+16)); + guild->change_position(sd->status.guild_id, RFIFOL(fd,i), RFIFOL(fd,i+4), RFIFOL(fd,i+12), RFIFOP(fd,i+16)); } } @@ -12930,8 +12928,8 @@ void clif_parse_GuildChangeNotice(int fd, struct map_session_data* sd) if (!sd->state.gmaster_flag) return; - msg1 = aStrndup((char*)RFIFOP(fd,6), MAX_GUILDMES1-1); - msg2 = aStrndup((char*)RFIFOP(fd,66), MAX_GUILDMES2-1); + msg1 = aStrndup(RFIFOP(fd,6), MAX_GUILDMES1-1); + msg2 = aStrndup(RFIFOP(fd,66), MAX_GUILDMES2-1); // compensate for some client defects when using multilingual mode if (msg1[0] == '|' && msg1[3] == '|') msg1+= 3; // skip duplicate marker @@ -12983,7 +12981,7 @@ void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) char nick[NAME_LENGTH]; struct map_session_data *t_sd = NULL; - safestrncpy(nick, (char*)RFIFOP(fd, 2), NAME_LENGTH); + safestrncpy(nick, RFIFOP(fd, 2), NAME_LENGTH); t_sd = map->nick2sd(nick); clif_sub_guild_invite(fd, sd, t_sd); @@ -13014,7 +13012,7 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd) { return; } - guild->leave(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14)); + guild->leave(sd,RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOP(fd,14)); } void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) __attribute__((nonnull (2))); @@ -13026,7 +13024,7 @@ void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) { clif->message(fd, msg_fd(fd,228)); return; } - guild->expulsion(sd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),(char*)RFIFOP(fd,14)); + guild->expulsion(sd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOP(fd,14)); } void clif_parse_GuildMessage(int fd, struct map_session_data* sd) __attribute__((nonnull (2))); @@ -13034,7 +13032,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) __attribute__( /// 017e <packet len>.W <text>.?B (<name> : <message>) 00 void clif_parse_GuildMessage(int fd, struct map_session_data* sd) { - const char* text = (char*)RFIFOP(fd,4); + const char *text = RFIFOP(fd,4); int textlen = RFIFOW(fd,2) - 4; const char *name, *message; @@ -13157,7 +13155,7 @@ void clif_parse_GuildBreak(int fd, struct map_session_data *sd) { clif->message(fd, msg_fd(fd,228)); return; } - guild->dobreak(sd,(char*)RFIFOP(fd,2)); + guild->dobreak(sd, RFIFOP(fd,2)); } /// Pet @@ -13233,7 +13231,7 @@ void clif_parse_ChangePetName(int fd, struct map_session_data *sd) __attribute__ /// 01a5 <name>.24B void clif_parse_ChangePetName(int fd, struct map_session_data *sd) { - pet->change_name(sd,(char*)RFIFOP(fd,2)); + pet->change_name(sd, RFIFOP(fd,2)); } void clif_parse_GMKick(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -13319,7 +13317,7 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd) char player_name[NAME_LENGTH]; char command[NAME_LENGTH+8]; - safestrncpy(player_name, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(player_name, RFIFOP(fd,2), NAME_LENGTH); sprintf(command, "%cjumpto %s", atcommand->at_symbol, player_name); atcommand->exec(fd, sd, command, true); @@ -13355,7 +13353,7 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd) char player_name[NAME_LENGTH]; char command[NAME_LENGTH+8]; - safestrncpy(player_name, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(player_name, RFIFOP(fd,2), NAME_LENGTH); sprintf(command, "%crecall %s", atcommand->at_symbol, player_name); atcommand->exec(fd, sd, command, true); @@ -13523,7 +13521,7 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd) char command[NAME_LENGTH+15]; char name[NAME_LENGTH]; - safestrncpy(name, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,2), NAME_LENGTH); sprintf(command, "%cmute %d %s", atcommand->at_symbol, 60, name); atcommand->exec(fd, sd, command, true); @@ -13589,7 +13587,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd) uint8 type; int i; - safestrncpy(nick, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(nick, RFIFOP(fd,2), NAME_LENGTH); type = RFIFOB(fd,26); @@ -13854,7 +13852,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) int i; char nick[NAME_LENGTH]; - safestrncpy(nick, (char*)RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(nick, RFIFOP(fd,2), NAME_LENGTH); f_sd = map->nick2sd(nick); @@ -14327,8 +14325,9 @@ void clif_feel_req(int fd, struct map_session_data *sd, uint16 skill_lv) void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); /// Request to change homunculus' name (CZ_RENAME_MER). /// 0231 <name>.24B -void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) { - homun->change_name(sd,(char*)RFIFOP(fd,2)); +void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd) +{ + homun->change_name(sd, RFIFOP(fd,2)); } void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); @@ -14495,7 +14494,7 @@ void clif_parse_Check(int fd, struct map_session_data *sd) if(!pc_has_permission(sd, PC_PERM_USE_CHECK)) return; - safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname)); + safestrncpy(charname, RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname)); if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { return; @@ -14938,15 +14937,15 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) msg.send_id = sd->status.char_id; msg.dest_id = 0; // will attempt to resolve name safestrncpy(msg.send_name, sd->status.name, NAME_LENGTH); - safestrncpy(msg.dest_name, (char*)RFIFOP(fd,4), NAME_LENGTH); - safestrncpy(msg.title, (char*)RFIFOP(fd,28), MAIL_TITLE_LENGTH); + safestrncpy(msg.dest_name, RFIFOP(fd,4), NAME_LENGTH); + safestrncpy(msg.title, RFIFOP(fd,28), MAIL_TITLE_LENGTH); if (msg.title[0] == '\0') { return; // Message has no length and somehow client verification was skipped. } if (body_len) - safestrncpy(msg.body, (char*)RFIFOP(fd,69), body_len + 1); + safestrncpy(msg.body, RFIFOP(fd,69), body_len + 1); else memset(msg.body, 0x00, MAIL_BODY_LENGTH); @@ -15297,7 +15296,7 @@ void clif_parse_Auction_search(int fd, struct map_session_data* sd) clif->pAuction_cancelreg(fd, sd); - safestrncpy(search_text, (char*)RFIFOP(fd,8), sizeof(search_text)); + safestrncpy(search_text, RFIFOP(fd,8), sizeof(search_text)); intif->Auction_requestlist(sd->status.char_id, type, price, search_text, page); } @@ -15440,7 +15439,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) return; } item_list = aMalloc(sizeof(*item_list) * 2 * count); - memcpy(item_list, (unsigned short*)RFIFOP(fd,10), sizeof(*item_list) * 2 * count); + memcpy(item_list, RFIFOP(fd,10), sizeof(*item_list) * 2 * count); fail = npc->cashshop_buylist(sd,points,count,item_list); aFree(item_list); #endif @@ -16138,7 +16137,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) __attribute__((n /// 0x2db <packet len>.W <text>.?B (<name> : <message>) 00 void clif_parse_BattleChat(int fd, struct map_session_data* sd) { - const char* text = (char*)RFIFOP(fd,4); + const char *text = RFIFOP(fd,4); int textlen = RFIFOW(fd,2) - 4; const char *name, *message; @@ -16450,7 +16449,7 @@ void clif_parse_ItemListWindowSelected(int fd, struct map_session_data *sd) } item_list = aMalloc(sizeof *item_list * 2 * n); - memcpy(item_list, (unsigned short*)RFIFOP(fd,12), sizeof *item_list * 2 * n); + memcpy(item_list, RFIFOP(fd,12), sizeof *item_list * 2 * n); switch( type ) { case 0: // Change Material skill->changematerial(sd,n,item_list); @@ -16563,7 +16562,7 @@ void clif_parse_ReqOpenBuyingStore(int fd, struct map_session_data* sd) { zenylimit = RFIFOL(fd,info->pos[1]); result = RFIFOL(fd,info->pos[2]); - safestrncpy(storename, (const char*)RFIFOP(fd,info->pos[3]), sizeof(storename)); + safestrncpy(storename, RFIFOP(fd,info->pos[3]), sizeof(storename)); itemlist = RFIFOP(fd,info->pos[4]); // so that buyingstore_create knows, how many elements it has access to diff --git a/src/map/intif.c b/src/map/intif.c index e508b7b09..178bbc2f3 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -962,7 +962,7 @@ void intif_parse_WisMessage(int fd) { id=RFIFOL(fd,4); - safestrncpy(name, (char*)RFIFOP(fd,32), NAME_LENGTH); + safestrncpy(name, RFIFOP(fd,32), NAME_LENGTH); sd = map->nick2sd(name); if(sd == NULL || strcmp(sd->status.name, name) != 0) { //Not found @@ -973,7 +973,7 @@ void intif_parse_WisMessage(int fd) { intif_wis_replay(id, 2); return; } - wisp_source = (char *) RFIFOP(fd,8); // speed up [Yor] + wisp_source = RFIFOP(fd,8); // speed up [Yor] for(i=0; i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0' && strcmp(sd->ignore[i].name, wisp_source) != 0 @@ -985,17 +985,19 @@ void intif_parse_WisMessage(int fd) { return; } //Success to send whisper. - clif->wis_message(sd->fd, wisp_source, (char*)RFIFOP(fd,56),RFIFOW(fd,2)-56); + clif->wis_message(sd->fd, wisp_source, RFIFOP(fd,56),RFIFOW(fd,2)-56); intif_wis_replay(id,0); // success } // Wisp/page transmission result reception -void intif_parse_WisEnd(int fd) { +void intif_parse_WisEnd(int fd) +{ struct map_session_data* sd; + const char *playername = RFIFOP(fd, 2); if (battle_config.etc_log) - ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target - sd = map->nick2sd((char *)RFIFOP(fd,2)); + ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", playername, RFIFOB(fd,26)); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target + sd = map->nick2sd(playername); if (sd != NULL) clif->wis_end(sd->fd, RFIFOB(fd,26)); @@ -1032,8 +1034,8 @@ void mapif_parse_WisToGM(int fd) message = (char *) (mes_len >= 255 ? (char *) aMalloc(mes_len) : mbuf); permission = RFIFOL(fd,28); - safestrncpy(Wisp_name, (char*)RFIFOP(fd,4), NAME_LENGTH); - safestrncpy(message, (char*)RFIFOP(fd,32), mes_len); + safestrncpy(Wisp_name, RFIFOP(fd,4), NAME_LENGTH); + safestrncpy(message, RFIFOP(fd,32), mes_len); // information is sent to all online GM map->foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len); @@ -1098,14 +1100,14 @@ void intif_parse_Registers(int fd) char sval[254]; for (i = 0; i < max; i++) { int len = RFIFOB(fd, cursor); - safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); + safestrncpy(key, RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); cursor += len + 1; index = RFIFOL(fd, cursor); cursor += 4; len = RFIFOB(fd, cursor); - safestrncpy(sval, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); + safestrncpy(sval, RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); cursor += len + 1; script->set_reg(NULL,sd,reference_uid(script->add_str(key), index), key, (void*)sval, NULL); @@ -1121,7 +1123,7 @@ void intif_parse_Registers(int fd) int ival; int len = RFIFOB(fd, cursor); - safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); + safestrncpy(key, RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); cursor += len + 1; index = RFIFOL(fd, cursor); @@ -1195,7 +1197,7 @@ void intif_parse_PartyCreated(int fd) { if(battle_config.etc_log) ShowInfo("intif: party created by account %u\n\n", RFIFOL(fd,2)); - party->created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15)); + party->created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), RFIFOP(fd,15)); } // Receive party info @@ -1209,7 +1211,7 @@ void intif_parse_PartyInfo(int fd) { if (RFIFOW(fd,2) != 8+sizeof(struct party)) ShowError("intif: party info: data size mismatch (char_id=%u party_id=%u 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)); + party->recv_info(RFIFOP(fd,8), RFIFOL(fd,4)); } // ACK adding party member @@ -1247,7 +1249,7 @@ void intif_parse_PartyMove(int fd) // ACK party messages void intif_parse_PartyMessage(int fd) { - party->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); + party->recv_message(RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); } // ACK guild creation @@ -1265,7 +1267,7 @@ void intif_parse_GuildInfo(int fd) { if (RFIFOW(fd,2)!=sizeof(struct guild)+4) ShowError("intif: guild info: data size mismatch - Gid: %u 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)); + guild->recv_info(RFIFOP(fd,4)); } // ACK adding guild member @@ -1277,7 +1279,7 @@ void intif_parse_GuildMemberAdded(int fd) { // ACK member leaving guild void intif_parse_GuildMemberWithdraw(int fd) { - guild->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOB(fd,14),(char *)RFIFOP(fd,55),(char *)RFIFOP(fd,15)); + guild->member_withdraw(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOP(fd,55), RFIFOP(fd,15)); } // ACK guild member basic info @@ -1308,7 +1310,7 @@ void intif_parse_GuildBasicInfoChanged(int fd) { case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break; case GBI_SKILLLV: { int idx, max; - const struct guild_skill *p_gs = (struct guild_skill *)RFIFOP(fd,10); + const struct guild_skill *p_gs = RFIFOP(fd,10); struct guild_skill *gs = NULL; idx = p_gs->id - GD_SKILLBASE; @@ -1363,7 +1365,7 @@ void intif_parse_GuildPosition(int fd) { if (RFIFOW(fd,2)!=sizeof(struct guild_position)+12) ShowError("intif: guild info: data size mismatch (%u) %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)); + guild->position_changed(RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12)); } // ACK change of guild skill update @@ -1373,27 +1375,27 @@ void intif_parse_GuildSkillUp(int fd) { // ACK change of guild relationship void intif_parse_GuildAlliance(int fd) { - guild->allianceack(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOL(fd,14),RFIFOB(fd,18),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43)); + guild->allianceack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18), RFIFOP(fd,19), RFIFOP(fd,43)); } // ACK change of guild notice void intif_parse_GuildNotice(int fd) { - guild->notice_changed(RFIFOL(fd,2),(char *) RFIFOP(fd,6),(char *) RFIFOP(fd,66)); + guild->notice_changed(RFIFOL(fd,2), RFIFOP(fd,6), RFIFOP(fd,66)); } // ACK change of guild emblem void intif_parse_GuildEmblem(int fd) { - guild->emblem_changed(RFIFOW(fd,2)-12,RFIFOL(fd,4),RFIFOL(fd,8), (char *)RFIFOP(fd,12)); + guild->emblem_changed(RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12)); } // ACK guild message void intif_parse_GuildMessage(int fd) { - guild->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12); + guild->recv_message(RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); } // Reply guild castle data request void intif_parse_GuildCastleDataLoad(int fd) { - guild->castledataloadack(RFIFOW(fd,2), (struct guild_castle *)RFIFOP(fd,4)); + guild->castledataloadack(RFIFOW(fd,2), RFIFOP(fd,4)); } // ACK change of guildmaster @@ -1444,10 +1446,10 @@ void intif_parse_ChangeNameOk(int fd) case 0: //Players [NOT SUPPORTED YET] break; case 1: //Pets - pet->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11)); + pet->change_name_ack(sd, RFIFOP(fd,12), RFIFOB(fd,11)); break; case 2: //Hom - homun->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11)); + homun->change_name_ack(sd, RFIFOP(fd,12), RFIFOB(fd,11)); break; } return; @@ -1463,7 +1465,7 @@ void intif_parse_CreateHomunculus(int fd) { 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)) ; + homun->recv_data(RFIFOL(fd,4), RFIFOP(fd,9), RFIFOB(fd,8)) ; } void intif_parse_RecvHomunculusData(int fd) { @@ -1474,7 +1476,7 @@ void intif_parse_RecvHomunculusData(int fd) { 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)); + homun->recv_data(RFIFOL(fd,4), RFIFOP(fd,9), RFIFOB(fd,8)); } /* Really? Whats the point, shouldn't be sent when successful then [Ind] */ @@ -1531,7 +1533,7 @@ void intif_parse_QuestLog(int fd) { sd->quest_log = NULL; } } else { - const struct quest *received = (struct quest *)RFIFOP(fd, 8); + const struct quest *received = RFIFOP(fd, 8); int i, k = num_received; if (sd->quest_log) { RECREATE(sd->quest_log, struct quest, num_received); @@ -1841,8 +1843,8 @@ void intif_parse_MailSend(int fd) { void intif_parse_MailNew(int fd) { struct map_session_data *sd = map->charid2sd(RFIFOL(fd,2)); int mail_id = RFIFOL(fd,6); - const char* sender_name = (char*)RFIFOP(fd,10); - const char* title = (char*)RFIFOP(fd,34); + const char *sender_name = RFIFOP(fd,10); + const char *title = RFIFOP(fd,34); if( sd == NULL ) return; @@ -2067,7 +2069,7 @@ void intif_parse_MercenaryReceived(int fd) { return; } - mercenary->data_received((struct s_mercenary*)RFIFOP(fd,5), RFIFOB(fd,4)); + mercenary->data_received(RFIFOP(fd,5), RFIFOB(fd,4)); } int intif_mercenary_request(int merc_id, int char_id) @@ -2149,7 +2151,7 @@ void intif_parse_ElementalReceived(int fd) { return; } - elemental->data_received((struct s_elemental*)RFIFOP(fd,5), RFIFOB(fd,4)); + elemental->data_received(RFIFOP(fd,5), RFIFOB(fd,4)); } int intif_elemental_request(int ele_id, int char_id) @@ -2228,7 +2230,7 @@ void intif_parse_MessageToFD(int fd) { /* matching e.g. previous fd owner didn't dc during request or is still the same */ if( sd && sd->bl.id == aid ) { char msg[512]; - safestrncpy(msg, (char*)RFIFOP(fd,12), RFIFOW(fd,2) - 12); + safestrncpy(msg, RFIFOP(fd,12), RFIFOW(fd,2) - 12); clif->messagecolor_self(u_fd, COLOR_DEFAULT ,msg); } @@ -2292,9 +2294,9 @@ int intif_parse(int fd) switch(cmd){ case 0x3800: if (RFIFOL(fd,4) == 0xFF000000) //Normal announce. - clif->broadcast(NULL, (char *) RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT); + clif->broadcast(NULL, RFIFOP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT); else //Color announce. - clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); + clif->broadcast2(NULL, RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); break; case 0x3801: intif->pWisMessage(fd); break; case 0x3802: intif->pWisEnd(fd); break; diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index fa4216f18..c38d3064c 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -151,7 +151,7 @@ int irc_parse(int fd) { return 0; parse_string = aMalloc(RFIFOREST(fd)); - safestrncpy(parse_string, (char*)RFIFOP(fd,0), RFIFOREST(fd)); + safestrncpy(parse_string, RFIFOP(fd,0), RFIFOREST(fd)); RFIFOSKIP(fd, RFIFOREST(fd)); RFIFOFLUSH(fd); |