summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c246
1 files changed, 135 insertions, 111 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 2257df0aa..6a55ad344 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -578,12 +578,12 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
struct hQueue *queue = &script->hq[sd->bg_queue.arena->queue_id];
for( i = 0; i < queue->size; i++ ) {
- struct map_session_data * sd = NULL;
+ struct map_session_data *qsd = NULL;
- if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) {
- WFIFOHEAD(sd->fd,len);
- memcpy(WFIFOP(sd->fd,0), buf, len);
- WFIFOSET(sd->fd,len);
+ if( queue->item[i] > 0 && ( qsd = map->id2sd(queue->item[i]) ) ) {
+ WFIFOHEAD(qsd->fd,len);
+ memcpy(WFIFOP(qsd->fd,0), buf, len);
+ WFIFOSET(qsd->fd,len);
}
}
}
@@ -930,6 +930,8 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
struct view_data* vd = status->get_viewdata(bl);
struct packet_idle_unit p;
int g_id = status->get_guild_id(bl);
+
+ nullpo_retv(bl);
#if PACKETVER < 20091103
if( !pcdb_checkid(vd->class_) ) {
@@ -1060,6 +1062,8 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
struct packet_spawn_unit p;
int g_id = status->get_guild_id(bl);
+ nullpo_retv(bl);
+
#if PACKETVER < 20091103
if( !pcdb_checkid(vd->class_) ) {
clif->spawn_unit2(bl,target);
@@ -1123,6 +1127,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
}
#endif
if( disguised(bl) ) {
+ nullpo_retv(sd);
if( sd->status.class_ != sd->disguise )
clif->send(&p,sizeof(p),bl,target);
#if PACKETVER >= 20091103
@@ -1146,6 +1151,8 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
struct view_data* vd = status->get_viewdata(bl);
struct packet_unit_walking p;
int g_id = status->get_guild_id(bl);
+
+ nullpo_retv(bl);
sd = BL_CAST(BL_PC, bl);
@@ -1663,7 +1670,7 @@ void clif_changemap(struct map_session_data *sd, short m, int x, int y) {
WFIFOHEAD(fd,packet_len(0x91));
WFIFOW(fd,0) = 0x91;
- mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name, (char*)WFIFOP(fd,2));
+ mapindex->getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name, (char*)WFIFOP(fd,2));
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOSET(fd,packet_len(0x91));
@@ -1679,7 +1686,7 @@ void clif_changemapserver(struct map_session_data* sd, unsigned short map_index,
WFIFOHEAD(fd,packet_len(0x92));
WFIFOW(fd,0) = 0x92;
- mapindex_getmapname_ext(mapindex_id2name(map_index), (char*)WFIFOP(fd,2));
+ mapindex->getmapname_ext(mapindex_id2name(map_index), (char*)WFIFOP(fd,2));
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOL(fd,22) = htonl(ip);
@@ -1798,13 +1805,13 @@ void clif_selllist(struct map_session_data *sd)
{
if( sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] )
{
- if( !itemdb_cansell(&sd->status.inventory[i], pc->get_group_level(sd)) )
+ if( !itemdb_cansell(&sd->status.inventory[i], pc_get_group_level(sd)) )
continue;
if( sd->status.inventory[i].expire_time )
continue; // Cannot Sell Rental Items
- if( sd->status.inventory[i].bound && !pc->can_give_bound_items(sd))
+ if( sd->status.inventory[i].bound && !pc_can_give_bound_items(sd))
continue; // Don't allow sale of bound items
val=sd->inventory_data[i]->value_sell;
@@ -1831,7 +1838,7 @@ void clif_selllist(struct map_session_data *sd)
/// - append this text
void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) {
int fd = sd->fd;
- int slen = strlen(mes) + 9;
+ size_t slen = strlen(mes) + 9;
sd->state.dialog = 1;
@@ -1943,7 +1950,7 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) {
/// TODO investigate behavior of other windows [FlavioJS]
void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) {
int fd = sd->fd;
- int slen = strlen(mes) + 9;
+ size_t slen = strlen(mes) + 9;
struct block_list *bl = NULL;
if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = map->id2bl(npcid)) && (bl->m!=sd->bl.m ||
@@ -2714,7 +2721,7 @@ void read_channels_config(void) {
if( (colors = config_setting_get_member(settings, "colors")) != NULL ) {
int color_count = config_setting_length(colors);
- CREATE( hChSys.colors, unsigned long, color_count );
+ CREATE( hChSys.colors, unsigned int, color_count );
CREATE( hChSys.colors_name, char *, color_count );
for(i = 0; i < color_count; i++) {
config_setting_t *color = config_setting_get_elem(colors, i);
@@ -2723,7 +2730,7 @@ void read_channels_config(void) {
safestrncpy(hChSys.colors_name[i], config_setting_name(color), HCHSYS_NAME_LENGTH);
- hChSys.colors[i] = strtoul(config_setting_get_string_elem(colors,i),NULL,0);
+ hChSys.colors[i] = (unsigned int)strtoul(config_setting_get_string_elem(colors,i),NULL,0);
hChSys.colors[i] = (hChSys.colors[i] & 0x0000FF) << 16 | (hChSys.colors[i] & 0x00FF00) | (hChSys.colors[i] & 0xFF0000) >> 16;//RGB to BGR
}
hChSys.colors_count = color_count;
@@ -2839,7 +2846,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) {
if( !tsd->fd || tsd == sd )
return 0;
- if( !pc->has_permission(tsd, PC_PERM_VIEW_HPMETER) )
+ if( !pc_has_permission(tsd, PC_PERM_VIEW_HPMETER) )
return 0;
WFIFOHEAD(tsd->fd,packet_len(cmd));
WFIFOW(tsd->fd,0) = cmd;
@@ -3141,7 +3148,7 @@ void clif_changelook(struct block_list *bl,int type,int val)
sd = BL_CAST(BL_PC, bl);
sc = status->get_sc(bl);
vd = status->get_viewdata(bl);
- //nullpo_ret(vd);
+
if( vd ) //temp hack to let Warp Portal change appearance
switch(type) {
case LOOK_WEAPON:
@@ -3250,6 +3257,7 @@ void clif_changelook(struct block_list *bl,int type,int val)
WBUFW(buf,0)=0x1d7;
WBUFL(buf,2)=bl->id;
if(type == LOOK_WEAPON || type == LOOK_SHIELD) {
+ nullpo_retv(vd);
WBUFB(buf,6)=LOOK_WEAPON;
WBUFW(buf,7)=vd->weapon;
WBUFW(buf,9)=vd->shield;
@@ -3258,7 +3266,7 @@ void clif_changelook(struct block_list *bl,int type,int val)
WBUFL(buf,7)=val;
}
clif->send(buf,packet_len(0x1d7),bl,target);
- if( disguised(bl) && ((TBL_PC*)sd)->fontcolor ) {
+ if( disguised(bl) && sd && sd->fontcolor ) {
WBUFL(buf,2)=-bl->id;
clif->send(buf,packet_len(0x1d7),bl,SELF);
}
@@ -3655,7 +3663,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok)
}
void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, const char *msg) {
- if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), timer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), timer->gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
clif->colormes(sd->fd,COLOR_RED,msg_txt(1455));
return;
} else {
@@ -4224,7 +4232,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
}
if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting.
(sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround
- pc->has_permission(sd, PC_PERM_VIEW_HPMETER)
+ pc_has_permission(sd, PC_PERM_VIEW_HPMETER)
)
clif->hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp);
@@ -4501,7 +4509,7 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe
WBUFW(buf,2) = x;
WBUFW(buf,4) = y;
WBUFW(buf,6) = type;
- mapindex_getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name,(char*)WBUFP(buf,8));
+ mapindex->getmapname_ext(map->list[m].custom_name ? map->list[map->list[m].instance_src_map].name : map->list[m].name,(char*)WBUFP(buf,8));
if( fd ) {
WFIFOHEAD(fd,packet_len(0x192));
@@ -4696,6 +4704,7 @@ int clif_outsight(struct block_list *bl,va_list ap)
tsd = BL_CAST(BL_PC, tbl);
if (tsd && tsd->fd) { //tsd has lost sight of the bl object.
+ nullpo_ret(bl);
switch(bl->type){
case BL_PC:
if (sd->vd.class_ != INVISIBLE_CLASS)
@@ -4728,6 +4737,7 @@ int clif_outsight(struct block_list *bl,va_list ap)
}
}
if (sd && sd->fd) { //sd is watching tbl go out of view.
+ nullpo_ret(tbl);
if (((vd=status->get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) &&
!(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->option&OPTION_INVISIBLE)))
clif->clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd);
@@ -4750,6 +4760,7 @@ int clif_insight(struct block_list *bl,va_list ap)
tsd = BL_CAST(BL_PC, tbl);
if (tsd && tsd->fd) { //Tell tsd that bl entered into his view
+ nullpo_ret(bl);
switch(bl->type) {
case BL_ITEM:
clif->getareachar_item(tsd,(struct flooritem_data*)bl);
@@ -5258,10 +5269,10 @@ void clif_skill_warppoint(struct map_session_data* sd, uint16 skill_id, uint16 s
memset(WFIFOP(fd,4), 0x00, 4*MAP_NAME_LENGTH_EXT);
if (map1 == (unsigned short)-1) strcpy((char*)WFIFOP(fd,4), "Random");
else // normal map name
- if (map1 > 0) mapindex_getmapname_ext(mapindex_id2name(map1), (char*)WFIFOP(fd,4));
- if (map2 > 0) mapindex_getmapname_ext(mapindex_id2name(map2), (char*)WFIFOP(fd,20));
- if (map3 > 0) mapindex_getmapname_ext(mapindex_id2name(map3), (char*)WFIFOP(fd,36));
- if (map4 > 0) mapindex_getmapname_ext(mapindex_id2name(map4), (char*)WFIFOP(fd,52));
+ if (map1 > 0) mapindex->getmapname_ext(mapindex_id2name(map1), (char*)WFIFOP(fd,4));
+ if (map2 > 0) mapindex->getmapname_ext(mapindex_id2name(map2), (char*)WFIFOP(fd,20));
+ if (map3 > 0) mapindex->getmapname_ext(mapindex_id2name(map3), (char*)WFIFOP(fd,36));
+ if (map4 > 0) mapindex->getmapname_ext(mapindex_id2name(map4), (char*)WFIFOP(fd,52));
WFIFOSET(fd,packet_len(0x11c));
sd->menuskill_id = skill_id;
@@ -5528,7 +5539,7 @@ void clif_displaymessage(const int fd, const char* mes) {
if( fd == -2 ) {
ShowInfo("HCP: %s\n",mes);
} else if ( fd > 0 ) {
- int len;
+ size_t len;
if ( ( len = strnlen(mes, 255) ) > 0 ) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
WFIFOHEAD(fd, 5 + len);
@@ -5554,7 +5565,7 @@ void clif_displaymessage2(const int fd, const char* mes) {
line = strtok(message, "\n");
while(line != NULL) {
// Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client)
- int len = strnlen(line, 255);
+ size_t len = strnlen(line, 255);
if (len > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
if( fd == -2 ) {
@@ -5606,7 +5617,7 @@ void clif_displaymessage_sprintf(const int fd, const char* mes, ...) {
}
/// Send broadcast message in yellow or blue without font formatting (ZC_BROADCAST).
/// 009a <packet len>.W <message>.?B
-void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, enum send_target target)
+void clif_broadcast(struct block_list* bl, const char* mes, size_t len, int type, enum send_target target)
{
int lp = (type&BC_COLOR_MASK) ? 4 : 0;
unsigned char *buf = (unsigned char*)aMalloc((4 + lp + len)*sizeof(unsigned char));
@@ -5630,7 +5641,7 @@ void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, e
*------------------------------------------*/
void clif_GlobalMessage(struct block_list* bl, const char* message) {
char buf[256];
- int len;
+ size_t len;
nullpo_retv(bl);
if(!message)
@@ -5653,7 +5664,7 @@ void clif_GlobalMessage(struct block_list* bl, const char* message) {
/// Send broadcast message with font formatting (ZC_BROADCAST2).
/// 01c3 <packet len>.W <fontColor>.L <fontType>.W <fontSize>.W <fontAlign>.W <fontY>.W <message>.?B
-void clif_broadcast2(struct block_list* bl, const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target)
+void clif_broadcast2(struct block_list* bl, const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target)
{
unsigned char *buf = (unsigned char*)aMalloc((16 + len)*sizeof(unsigned char));
@@ -5829,7 +5840,7 @@ void clif_upgrademessage(int fd, int result, int item_id)
/// Whisper is transmitted to the destination player (ZC_WHISPER).
/// 0097 <packet len>.W <nick>.24B <message>.?B
/// 0097 <packet len>.W <nick>.24B <isAdmin>.L <message>.?B (PACKETVER >= 20091104)
-void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) {
+void clif_wis_message(int fd, const char* nick, const char* mes, size_t mes_len) {
#if PACKETVER < 20091104
WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4);
WFIFOW(fd,0) = 0x97;
@@ -5844,7 +5855,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) {
WFIFOW(fd,0) = 0x97;
WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8;
safestrncpy((char*)WFIFOP(fd,4), nick, NAME_LENGTH);
- WFIFOL(fd,28) = (ssd && pc->get_group_level(ssd) == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char
+ WFIFOL(fd,28) = (ssd && pc_get_group_level(ssd) == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char
safestrncpy((char*)WFIFOP(fd,32), mes, mes_len);
WFIFOSET(fd,WFIFOW(fd,2));
#endif
@@ -6430,7 +6441,7 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
WBUFB(buf,14) = (p->party.member[i].online)?0:1;
memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
- mapindex_getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, (char*)WBUFP(buf,63));
+ mapindex->getmapname_ext(map->list[sd->bl.m].custom_name ? map->list[map->list[sd->bl.m].instance_src_map].name : map->list[sd->bl.m].name, (char*)WBUFP(buf,63));
WBUFB(buf,79) = (p->party.item&1)?1:0;
WBUFB(buf,80) = (p->party.item&2)?1:0;
clif->send(buf,packet_len(0x1e9),&sd->bl,PARTY);
@@ -6464,7 +6475,7 @@ void clif_party_info(struct party_data* p, struct map_session_data *sd)
WBUFL(buf,28+c*46) = m->account_id;
memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH);
- mapindex_getmapname_ext(mapindex_id2name(m->map), (char*)WBUFP(buf,28+c*46+28));
+ mapindex->getmapname_ext(mapindex_id2name(m->map), (char*)WBUFP(buf,28+c*46+28));
WBUFB(buf,28+c*46+44) = (m->leader) ? 0 : 1;
WBUFB(buf,28+c*46+45) = (m->online) ? 0 : 1;
c++;
@@ -8053,14 +8064,14 @@ void clif_marriage_proposal(int fd, struct map_session_data *sd, struct map_sess
/*==========================================
*
*------------------------------------------*/
-void clif_disp_onlyself(struct map_session_data *sd, const char *mes, int len) {
+void clif_disp_onlyself(struct map_session_data *sd, const char *mes, size_t len) {
clif->disp_message(&sd->bl, mes, len, SELF);
}
/*==========================================
* Displays a message using the guild-chat colors to the specified targets. [Skotlex]
*------------------------------------------*/
-void clif_disp_message(struct block_list* src, const char* mes, int len, enum send_target target)
+void clif_disp_message(struct block_list* src, const char* mes, size_t len, enum send_target target)
{
unsigned char buf[256];
@@ -8317,7 +8328,7 @@ void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, sen
// Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead)
/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
int clif_colormes(int fd, enum clif_colors color, const char* msg) {
- unsigned short msg_len = strlen(msg) + 1;
+ size_t msg_len = strlen(msg) + 1;
WFIFOHEAD(fd,msg_len + 12);
WFIFOW(fd,0) = 0x2C1;
@@ -8332,8 +8343,8 @@ int clif_colormes(int fd, enum clif_colors color, const char* msg) {
/// Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT).
/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
-void clif_messagecolor(struct block_list* bl, unsigned long color, const char* msg) {
- unsigned short msg_len = strlen(msg) + 1;
+void clif_messagecolor(struct block_list* bl, unsigned int color, const char* msg) {
+ size_t msg_len = strlen(msg) + 1;
uint8 buf[256];
color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR
@@ -8657,7 +8668,7 @@ void clif_slide(struct block_list *bl, int x, int y)
void clif_disp_overhead(struct block_list *bl, const char* mes)
{
unsigned char buf[256]; //This should be more than sufficient, the theorical max is CHAT_SIZE + 8 (pads and extra inserted crap)
- int len_mes = strlen(mes)+1; //Account for \0
+ 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);
@@ -8771,7 +8782,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig
{
char mapname[MAP_NAME_LENGTH_EXT];
- mapindex_getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname);
+ mapindex->getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname);
clif->starskill(sd, mapname, 0, feel_level, type ? 1 : 0);
}
@@ -8946,9 +8957,10 @@ void clif_viewequip_fail(struct map_session_data* sd)
/// Returns true if the packet was parsed successfully.
/// Formats: 0 - <packet id>.w <packet len>.w (<name> : <message>).?B 00
/// 1 - <packet id>.w <packet len>.w <name>.24B <message>.?B 00
-bool clif_process_message(struct map_session_data* sd, int format, char** name_, int* namelen_, char** message_, int* messagelen_) {
+bool clif_process_message(struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_) {
char *text, *name, *message;
- unsigned int packetlen, textlen, namelen, messagelen;
+ unsigned int packetlen, textlen;
+ size_t namelen, messagelen;
int fd = sd->fd;
*name_ = NULL;
@@ -9255,7 +9267,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
instance->check_idle(map->list[sd->bl.m].instance_id);
}
- if( pc->has_permission(sd,PC_PERM_VIEW_HPMETER) ) {
+ if( pc_has_permission(sd,PC_PERM_VIEW_HPMETER) ) {
map->list[sd->bl.m].hpmeter_visible++;
sd->state.hpmeter_visible = 1;
}
@@ -9604,7 +9616,7 @@ void clif_parse_Hotkey(int fd, struct map_session_data *sd) {
/// Displays cast-like progress bar (ZC_PROGRESS).
/// 02f0 <color>.L <time>.L
-void clif_progressbar(struct map_session_data * sd, unsigned long color, unsigned int second)
+void clif_progressbar(struct map_session_data * sd, unsigned int color, unsigned int second)
{
int fd = sd->fd;
@@ -9737,7 +9749,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) {
sc = status->get_sc(bl);
if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) &&
bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple
- pc->get_group_level(sd) < battle_config.hack_info_GM_level
+ pc_get_group_level(sd) < battle_config.hack_info_GM_level
) {
char gm_msg[256];
sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id);
@@ -9766,10 +9778,10 @@ int clif_undisguise_timer(int tid, int64 tick, int id, intptr_t data) {
void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
{
const char* text = (char*)RFIFOP(fd,4);
- int textlen = RFIFOW(fd,2) - 4;
+ size_t textlen = RFIFOW(fd,2) - 4;
char *name, *message, *fakename = NULL;
- int namelen, messagelen;
+ size_t namelen, messagelen;
bool is_fake;
@@ -10274,7 +10286,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
int i;
char *target, *message;
- int namelen, messagelen;
+ size_t namelen, messagelen;
// validate packet and retrieve name and message
if( !clif->process_message(sd, 1, &target, &namelen, &message, &messagelen) )
@@ -10354,7 +10366,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
channel = (struct hChSysCh *)g->channel;
}
if( channel || (channel = strdb_get(clif->channel_db,chname)) ) {
- unsigned char k;
+ int k;
for( k = 0; k < sd->channel_count; k++ ) {
if( sd->channels[k] == channel )
break;
@@ -10364,7 +10376,6 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
} else if( channel->pass[0] == '\0' && !(channel->banned && idb_exists(channel->banned, sd->status.account_id)) ) {
if( channel->type == hChSys_ALLY ) {
struct guild *g = sd->guild, *sg = NULL;
- int k;
for (k = 0; k < MAX_GUILDALLIANCE; k++) {
if( g->alliance[k].opposition == 0 && g->alliance[k].guild_id && (sg = guild->search(g->alliance[k].guild_id) ) ) {
if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
@@ -10395,8 +10406,8 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
// if player ignores everyone
- if (dstsd->state.ignoreAll && pc->get_group_level(sd) <= pc->get_group_level(dstsd)) {
- if (dstsd->sc.option & OPTION_INVISIBLE && pc->get_group_level(sd) < pc->get_group_level(dstsd))
+ if (dstsd->state.ignoreAll && pc_get_group_level(sd) <= pc_get_group_level(dstsd)) {
+ if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd))
clif->wis_end(fd, 1); // 1: target character is not logged in
else
clif->wis_end(fd, 3); // 3: everyone ignored by target
@@ -10411,7 +10422,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
return;
}
- if( pc->get_group_level(sd) <= pc->get_group_level(dstsd) ) {
+ if( pc_get_group_level(sd) <= pc_get_group_level(dstsd) ) {
// if player ignores the source character
ARR_FIND(0, MAX_IGNORE_LIST, i, dstsd->ignore[i].name[0] == '\0' || strcmp(dstsd->ignore[i].name, sd->status.name) == 0);
if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0') { // source char present in ignore list
@@ -11088,8 +11099,10 @@ void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
{// TODO: State tracking?
int type;
+
+ nullpo_retv(sd);
- if( sd && pc->checkskill(sd, MC_CHANGECART) < 1 )
+ if( pc->checkskill(sd, MC_CHANGECART) < 1 )
return;
#ifdef RENEWAL
@@ -11462,7 +11475,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((char*)RFIFOP(fd,4), map_name);
sd->state.workinprogress = 0;
if(skill_id != sd->menuskill_id)
@@ -12095,7 +12108,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
int textlen = RFIFOW(fd,2) - 4;
char *name, *message;
- int namelen, messagelen;
+ size_t namelen, messagelen;
// validate packet and retrieve name and message
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
@@ -12627,7 +12640,7 @@ void clif_PartyBookingFailedRecall(int fd, struct map_session_data *sd)
void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_data *sd)
{
#ifdef PARTY_RECRUIT
- unsigned long aid = RFIFOL(fd, 2);
+ unsigned int aid = RFIFOL(fd, 2);
clif->PartyBookingRefuseVolunteer(aid, sd);
#else
@@ -12636,7 +12649,7 @@ void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_data *sd)
}
/// 08fa <index>.L
-void clif_PartyBookingRefuseVolunteer(unsigned long aid, struct map_session_data *sd)
+void clif_PartyBookingRefuseVolunteer(unsigned int aid, struct map_session_data *sd)
{
#ifdef PARTY_RECRUIT
unsigned char buf[2+6];
@@ -13033,7 +13046,7 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) {
/// 0153 <packet len>.W <emblem data>.?B
void clif_parse_GuildChangeEmblem(int fd,struct map_session_data *sd)
{
- unsigned long emblem_len = RFIFOW(fd,2)-4;
+ unsigned int emblem_len = RFIFOW(fd,2)-4;
const uint8* emblem = RFIFOP(fd,4);
if( !emblem_len || !sd->state.gmaster_flag )
@@ -13155,7 +13168,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
int textlen = RFIFOW(fd,2) - 4;
char *name, *message;
- int namelen, messagelen;
+ size_t namelen, messagelen;
// validate packet and retrieve name and message
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
@@ -13524,7 +13537,12 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
if ( (count=itemdb->search_name_array(item_array, 10, item_monster_name, 1)) > 0 ){
for(i = 0; i < count; i++){
- if( item_array[i] && strcmp(item_array[i]->name, item_monster_name) == 0 )// It only accepts aegis name
+ if( !item_array[i] )
+ continue;
+ // It only accepts aegis name
+ if( battle_config.case_sensitive_aegisnames && strcmp(item_array[i]->name, item_monster_name) == 0 )
+ break;
+ if( !battle_config.case_sensitive_aegisnames && strcasecmp(item_array[i]->name, item_monster_name) == 0 )
break;
}
@@ -13546,7 +13564,12 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
if( (count=mob->db_searchname_array(mob_array, 10, item_monster_name, 1)) > 0){
for(i = 0; i < count; i++){
- if( mob_array[i] && strcmp(mob_array[i]->sprite, item_monster_name) == 0 ) // It only accepts sprite name
+ if( !mob_array[i] )
+ continue;
+ // It only accepts sprite name
+ if( battle_config.case_sensitive_aegisnames && strcmp(mob_array[i]->sprite, item_monster_name) == 0 )
+ break;
+ if( !battle_config.case_sensitive_aegisnames && strcasecmp(mob_array[i]->sprite, item_monster_name) == 0 )
break;
}
@@ -13592,7 +13615,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) {
if (type == 2) {
if (!battle_config.client_accept_chatdori)
return;
- if (pc->get_group_level(sd) > 0 || sd->bl.id != id)
+ if (pc_get_group_level(sd) > 0 || sd->bl.id != id)
return;
value = battle_config.client_accept_chatdori;
@@ -13603,7 +13626,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) {
return;
}
- if (type == 2 || ( (pc->get_group_level(sd)) > pc->get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) {
+ if (type == 2 || ( (pc_get_group_level(sd)) > pc_get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) {
clif->manner_message(sd, 0);
clif->manner_message(dstsd, 5);
@@ -13672,7 +13695,7 @@ void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd)
void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) {
int x,y,type;
- if (!pc->has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE))
+ if (!pc_has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE))
return;
x = RFIFOW(fd,2);
@@ -14556,12 +14579,12 @@ void clif_parse_Check(int fd, struct map_session_data *sd)
char charname[NAME_LENGTH];
struct map_session_data* pl_sd;
- if(!pc->has_permission(sd, PC_PERM_USE_CHECK))
+ 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));
- if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) {
+ if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) {
return;
}
@@ -14749,7 +14772,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
struct mail_message *msg = &sd->mail.inbox.msg[i];
struct item *item = &msg->item;
struct item_data *data;
- int msg_len = strlen(msg->body), len;
+ size_t msg_len = strlen(msg->body), len;
if( msg_len == 0 ) {
strcpy(msg->body, "(no message)");
@@ -14843,6 +14866,11 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
if ((data = itemdb->exists(sd->mail.inbox.msg[i].item.nameid)) == NULL)
return;
+ if( pc_is90overweight(sd) ) {
+ clif->mail_getattachment(fd, 2);
+ return;
+ }
+
switch( pc->checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) {
case ADDITEM_NEW:
fail = ( pc->inventoryblank(sd) == 0 );
@@ -15143,10 +15171,10 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
return;
}
- if( !pc->can_give_items(sd) || sd->status.inventory[idx].expire_time ||
+ if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
!sd->status.inventory[idx].identify ||
- !itemdb_canauction(&sd->status.inventory[idx],pc->get_group_level(sd)) || // Quest Item or something else
- (sd->status.inventory[idx].bound && !pc->can_give_bound_items(sd)) ) {
+ !itemdb_canauction(&sd->status.inventory[idx],pc_get_group_level(sd)) || // Quest Item or something else
+ (sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd)) ) {
clif->auction_setitem(sd->fd, idx, true);
return;
}
@@ -15254,7 +15282,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
}
// Auction checks...
- if( sd->status.inventory[sd->auction.index].bound && !pc->can_give_bound_items(sd) ) {
+ if( sd->status.inventory[sd->auction.index].bound && !pc_can_give_bound_items(sd) ) {
clif->message(sd->fd, msg_txt(293));
clif->auction_message(fd, 2); // The auction has been canceled
return;
@@ -15307,7 +15335,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
unsigned int auction_id = RFIFOL(fd,2);
int bid = RFIFOL(fd,6);
- if( !pc->can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish]
+ if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish]
clif->message(sd->fd, msg_txt(246));
return;
}
@@ -15598,7 +15626,7 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) {
if (!tsd)
return;
- if( tsd->status.show_equip || pc->has_permission(sd, PC_PERM_VIEW_EQUIPMENT) )
+ if( tsd->status.show_equip || pc_has_permission(sd, PC_PERM_VIEW_EQUIPMENT) )
clif->viewequip_ack(sd, tsd);
else
clif->viewequip_fail(sd);
@@ -15635,8 +15663,7 @@ void clif_parse_PartyTick(int fd, struct map_session_data* sd)
/// Sends list of all quest states (ZC_ALL_QUEST_LIST).
/// 02b1 <packet len>.W <num>.L { <quest id>.L <active>.B }*num
-void clif_quest_send_list(struct map_session_data * sd)
-{
+void clif_quest_send_list(struct map_session_data *sd) {
int fd = sd->fd;
int i;
int len = sd->avail_quests*5+8;
@@ -15657,8 +15684,7 @@ void clif_quest_send_list(struct map_session_data * sd)
/// Sends list of all quest missions (ZC_ALL_QUEST_MISSION).
/// 02b2 <packet len>.W <num>.L { <quest id>.L <start time>.L <expire time>.L <mobs>.W { <mob id>.L <mob count>.W <mob name>.24B }*3 }*num
-void clif_quest_send_mission(struct map_session_data * sd)
-{
+void clif_quest_send_mission(struct map_session_data *sd) {
int fd = sd->fd;
int i, j;
int len = sd->avail_quests*104+8;
@@ -15670,17 +15696,17 @@ void clif_quest_send_mission(struct map_session_data * sd)
WFIFOL(fd, 4) = sd->avail_quests;
for( i = 0; i < sd->avail_quests; i++ ) {
+ struct quest_db *qi = quest->db(sd->quest_log[i].quest_id);
WFIFOL(fd, i*104+8) = sd->quest_log[i].quest_id;
- WFIFOL(fd, i*104+12) = sd->quest_log[i].time - quest->db[sd->quest_index[i]].time;
+ WFIFOL(fd, i*104+12) = sd->quest_log[i].time - qi->time;
WFIFOL(fd, i*104+16) = sd->quest_log[i].time;
- WFIFOW(fd, i*104+20) = quest->db[sd->quest_index[i]].num_objectives;
+ WFIFOW(fd, i*104+20) = qi->num_objectives;
- for( j = 0 ; j < quest->db[sd->quest_index[i]].num_objectives; j++ )
- {
- WFIFOL(fd, i*104+22+j*30) = quest->db[sd->quest_index[i]].mob[j];
+ for( j = 0 ; j < qi->num_objectives; j++ ) {
+ WFIFOL(fd, i*104+22+j*30) = qi->mob[j];
WFIFOW(fd, i*104+26+j*30) = sd->quest_log[i].count[j];
- monster = mob->db(quest->db[sd->quest_index[i]].mob[j]);
- memcpy(WFIFOP(fd, i*104+28+j*30), monster?monster->jname:"NULL", NAME_LENGTH);
+ monster = mob->db(qi->mob[j]);
+ memcpy(WFIFOP(fd, i*104+28+j*30), monster->jname, NAME_LENGTH);
}
}
@@ -15690,25 +15716,25 @@ void clif_quest_send_mission(struct map_session_data * sd)
/// Notification about a new quest (ZC_ADD_QUEST).
/// 02b3 <quest id>.L <active>.B <start time>.L <expire time>.L <mobs>.W { <mob id>.L <mob count>.W <mob name>.24B }*3
-void clif_quest_add(struct map_session_data * sd, struct quest * qd, int index)
-{
+void clif_quest_add(struct map_session_data *sd, struct quest *qd) {
int fd = sd->fd;
int i;
struct mob_db *monster;
+ struct quest_db *qi = quest->db(qd->quest_id);
WFIFOHEAD(fd, packet_len(0x2b3));
WFIFOW(fd, 0) = 0x2b3;
WFIFOL(fd, 2) = qd->quest_id;
WFIFOB(fd, 6) = qd->state;
- WFIFOB(fd, 7) = qd->time - quest->db[index].time;
+ WFIFOB(fd, 7) = qd->time - qi->time;
WFIFOL(fd, 11) = qd->time;
- WFIFOW(fd, 15) = quest->db[index].num_objectives;
+ WFIFOW(fd, 15) = qi->num_objectives;
- for( i = 0; i < quest->db[index].num_objectives; i++ ) {
- WFIFOL(fd, i*30+17) = quest->db[index].mob[i];
+ for( i = 0; i < qi->num_objectives; i++ ) {
+ WFIFOL(fd, i*30+17) = qi->mob[i];
WFIFOW(fd, i*30+21) = qd->count[i];
- monster = mob->db(quest->db[index].mob[i]);
- memcpy(WFIFOP(fd, i*30+23), monster?monster->jname:"NULL", NAME_LENGTH);
+ monster = mob->db(qi->mob[i]);
+ memcpy(WFIFOP(fd, i*30+23), monster->jname, NAME_LENGTH);
}
WFIFOSET(fd, packet_len(0x2b3));
@@ -15717,8 +15743,7 @@ void clif_quest_add(struct map_session_data * sd, struct quest * qd, int index)
/// Notification about a quest being removed (ZC_DEL_QUEST).
/// 02b4 <quest id>.L
-void clif_quest_delete(struct map_session_data * sd, int quest_id)
-{
+void clif_quest_delete(struct map_session_data *sd, int quest_id) {
int fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x2b4));
@@ -15730,21 +15755,21 @@ void clif_quest_delete(struct map_session_data * sd, int quest_id)
/// Notification of an update to the hunting mission counter (ZC_UPDATE_MISSION_HUNT).
/// 02b5 <packet len>.W <mobs>.W { <quest id>.L <mob id>.L <total count>.W <current count>.W }*3
-void clif_quest_update_objective(struct map_session_data * sd, struct quest * qd, int index)
-{
+void clif_quest_update_objective(struct map_session_data *sd, struct quest *qd) {
int fd = sd->fd;
int i;
- int len = quest->db[index].num_objectives*12+6;
+ struct quest_db *qi = quest->db(qd->quest_id);
+ int len = qi->num_objectives*12+6;
WFIFOHEAD(fd, len);
WFIFOW(fd, 0) = 0x2b5;
WFIFOW(fd, 2) = len;
- WFIFOW(fd, 4) = quest->db[index].num_objectives;
+ WFIFOW(fd, 4) = qi->num_objectives;
- for( i = 0; i < quest->db[index].num_objectives; i++ ) {
+ for( i = 0; i < qi->num_objectives; i++ ) {
WFIFOL(fd, i*12+6) = qd->quest_id;
- WFIFOL(fd, i*12+10) = quest->db[index].mob[i];
- WFIFOW(fd, i*12+14) = quest->db[index].count[i];
+ WFIFOL(fd, i*12+10) = qi->mob[i];
+ WFIFOW(fd, i*12+14) = qi->count[i];
WFIFOW(fd, i*12+16) = qd->count[i];
}
@@ -15754,16 +15779,14 @@ void clif_quest_update_objective(struct map_session_data * sd, struct quest * qd
/// Request to change the state of a quest (CZ_ACTIVE_QUEST).
/// 02b6 <quest id>.L <active>.B
-void clif_parse_questStateAck(int fd, struct map_session_data * sd)
-{
+void clif_parse_questStateAck(int fd, struct map_session_data *sd) {
quest->update_status(sd, RFIFOL(fd,2), RFIFOB(fd,6)?Q_ACTIVE:Q_INACTIVE);
}
/// Notification about the change of a quest state (ZC_ACTIVE_QUEST).
/// 02b7 <quest id>.L <active>.B
-void clif_quest_update_status(struct map_session_data * sd, int quest_id, bool active)
-{
+void clif_quest_update_status(struct map_session_data *sd, int quest_id, bool active) {
int fd = sd->fd;
WFIFOHEAD(fd, packet_len(0x2b7));
@@ -16075,7 +16098,7 @@ void clif_bg_xy_remove(struct map_session_data *sd)
/// Notifies clients of a battleground message (ZC_BATTLEFIELD_CHAT).
/// 02dc <packet len>.W <account id>.L <name>.24B <message>.?B
-void clif_bg_message(struct battleground_data *bgd, int src_id, const char *name, const char *mes, int len)
+void clif_bg_message(struct battleground_data *bgd, int src_id, const char *name, const char *mes, size_t len)
{
struct map_session_data *sd;
unsigned char *buf;
@@ -16104,7 +16127,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd)
int textlen = RFIFOW(fd,2) - 4;
char *name, *message;
- int namelen, messagelen;
+ size_t namelen, messagelen;
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
@@ -16982,7 +17005,7 @@ void clif_parse_debug(int fd,struct map_session_data *sd) {
}
ShowDebug("Packet debug of 0x%04X (length %d), %s session #%d, %d/%d (AID/CID)\n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id);
} else {
- packet_len = RFIFOREST(fd);
+ packet_len = (int)RFIFOREST(fd);
ShowDebug("Packet debug of 0x%04X (length %d), session #%d\n", cmd, packet_len, fd);
}
@@ -17590,7 +17613,7 @@ void clif_partytickack(struct map_session_data* sd, bool flag) {
void clif_ShowScript(struct block_list* bl, const char* message) {
char buf[256];
- int len;
+ size_t len;
nullpo_retv(bl);
if(!message)
@@ -17933,7 +17956,7 @@ void clif_parse_GMFullStrip(int fd, struct map_session_data *sd) {
int i;
/* TODO maybe this could be a new permission? using gm level in the meantime */
- if( !tsd || pc->get_group_level(tsd) >= pc->get_group_level(sd) )
+ if( !tsd || pc_get_group_level(tsd) >= pc_get_group_level(sd) )
return;
for( i = 0; i < EQI_MAX; i++ ) {
@@ -18240,6 +18263,7 @@ static void __attribute__ ((unused)) packetdb_addpacket(short cmd, int len, ...)
packet_db[cmd].pos[i] = pos;
}
+ va_end(va);
}
void packetdb_loaddb(void) {
@@ -18284,7 +18308,7 @@ int do_init_clif(bool minimal) {
* Setup Color Table (saves unnecessary load of strtoul on every call)
**/
for(i = 0; i < COLOR_MAX; i++) {
- color_table[i] = strtoul(colors[i],NULL,0);
+ color_table[i] = (unsigned int)strtoul(colors[i],NULL,0);
color_table[i] = (color_table[i] & 0x0000FF) << 16 | (color_table[i] & 0x00FF00) | (color_table[i] & 0xFF0000) >> 16;//RGB to BGR
}