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 /src/map | |
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>
Diffstat (limited to 'src/map')
-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 |
4 files changed, 97 insertions, 96 deletions
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); |