summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chat.c8
-rw-r--r--src/map/clif.c143
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/guild.c57
-rw-r--r--src/map/intif.c156
-rw-r--r--src/map/npc.c13
-rw-r--r--src/map/npc.h2
-rw-r--r--src/map/skill.c17
8 files changed, 194 insertions, 204 deletions
diff --git a/src/map/chat.c b/src/map/chat.c
index 1a0730b51..67a4dbaee 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -151,15 +151,15 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
return -1;
}
- leavechar = i;
-
clif_leavechat(cd, sd, kicked);
+ pc_setchatid(sd, 0);
+ cd->users--;
+
+ leavechar = i;
for( i = leavechar; i < cd->users; i++ )
cd->usersd[i] = cd->usersd[i+1];
- pc_setchatid(sd, 0);
- cd->users--;
if( cd->users == 0 && cd->owner->type == BL_PC )
{ // Delete empty chatroom
diff --git a/src/map/clif.c b/src/map/clif.c
index 36a306f0c..3b2fefc1c 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7964,9 +7964,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(map_flag_gvg(sd->bl.m))
clif_set0199(fd,3);
- map_foreachinarea(clif_getareachar, sd->bl.m,
- sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE,
- BL_ALL, sd);
+ // info about nearby objects
+ map_foreachinrange(clif_getareachar, &sd->bl, AREA_SIZE, BL_ALL, sd);
// pet
if(sd->pd) {
@@ -11296,11 +11295,12 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
}
#ifndef TXT_ONLY
-
/*==========================================
* MAIL SYSTEM
* By Zephyrus
- *------------------------------------------
+ *==========================================*/
+
+/*------------------------------------------
* Opens Mail Window on Client
*------------------------------------------*/
void clif_Mail_openmail(int fd)
@@ -11310,6 +11310,7 @@ void clif_Mail_openmail(int fd)
WFIFOL(fd,2) = 0;
WFIFOSET(fd,packet_len(0x260));
}
+
/*------------------------------------------
* Send Inbox Data to Client
*------------------------------------------*/
@@ -11368,7 +11369,12 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
int i, fd = sd->fd;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
- if (i < MAIL_MAX_INBOX)
+ if( i == MAIL_MAX_INBOX )
+ {
+ ShowWarning("clif_parse_Mail_read: account %d trying to read a message not the inbox.\n", sd->status.account_id);
+ return;
+ }
+ else
{
struct mail_message *msg = &sd->mail.inbox.msg[i];
struct item *item = &msg->item;
@@ -11416,8 +11422,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
WFIFOW(fd,95) = item->card[2];
WFIFOW(fd,97) = item->card[3];
WFIFOB(fd,99) = (unsigned char)msg_len;
- memcpy(WFIFOP(fd,100), msg->body, msg_len);
- WFIFOB(fd,len - 1) = 0x00;
+ safestrncpy((char*)WFIFOP(fd,100), msg->body, msg_len);
WFIFOSET(fd,len);
if (!msg->read) {
@@ -11426,8 +11431,6 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
clif_parse_Mail_refreshinbox(fd, sd);
}
}
- else
- ShowWarning("clif_parse_Mail_read: account %d trying to read a message not the inbox.\n", sd->status.account_id);
}
void clif_parse_Mail_read(int fd, struct map_session_data *sd)
@@ -11445,44 +11448,45 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
nullpo_retv(sd);
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
- if (i < MAIL_MAX_INBOX)
+ if( i == MAIL_MAX_INBOX )
+ return;
+
+ if( sd->mail.inbox.msg[i].zeny < 1 && (sd->mail.inbox.msg[i].item.nameid < 1 || sd->mail.inbox.msg[i].item.amount < 1) )
+ return;
+
+ if( sd->mail.inbox.msg[i].item.nameid > 0 )
{
- if (sd->mail.inbox.msg[i].zeny < 1 && (sd->mail.inbox.msg[i].item.nameid < 1 || sd->mail.inbox.msg[i].item.amount < 1))
+ struct item_data *data;
+ unsigned int weight;
+
+ if ((data = itemdb_search(sd->mail.inbox.msg[i].item.nameid)) == NULL)
return;
- if (sd->mail.inbox.msg[i].item.nameid > 0)
+ weight = data->weight * sd->mail.inbox.msg[i].item.amount;
+ if (weight > sd->max_weight - sd->weight)
{
- struct item_data *data;
- unsigned int weight;
-
- if ((data = itemdb_search(sd->mail.inbox.msg[i].item.nameid)) == NULL)
- return;
-
- weight = data->weight * sd->mail.inbox.msg[i].item.amount;
- if (weight > sd->max_weight - sd->weight)
- {
- clif_displaymessage(fd, "Attachment to heavy for you...");
- return;
- }
+ clif_displaymessage(fd, "Attachment to heavy for you...");
+ return;
}
+ }
- sd->mail.inbox.msg[i].zeny = 0;
- memset(&sd->mail.inbox.msg[i].item, 0, sizeof(struct item));
- clif_Mail_read(sd, mail_id);
+ sd->mail.inbox.msg[i].zeny = 0;
+ memset(&sd->mail.inbox.msg[i].item, 0, sizeof(struct item));
+ clif_Mail_read(sd, mail_id);
- // Send the request for Char Server to delete the attachment
- // If it is done, the client will receive it.
- intif_Mail_getattach(sd->status.char_id, mail_id);
- }
+ // Send the request for Char Server to delete the attachment
+ // If it is done, the client will receive it.
+ intif_Mail_getattach(sd->status.char_id, mail_id);
}
+
/*------------------------------------------
* Delete Message
*------------------------------------------*/
-void clif_Mail_delete(struct map_session_data *sd, int mail_id, short flag)
+void clif_Mail_delete(struct map_session_data *sd, int mail_id, bool failed)
{
int fd = sd->fd;
- if (!flag)
+ if( !failed )
{
int i;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
@@ -11491,16 +11495,16 @@ void clif_Mail_delete(struct map_session_data *sd, int mail_id, short flag)
memset(&sd->mail.inbox.msg[i], 0, sizeof(struct mail_message));
sd->mail.inbox.amount--;
}
+
+ if( sd->mail.inbox.full )
+ intif_Mail_requestinbox(sd->status.char_id, 1); // Reload the Mail Inbox
}
WFIFOHEAD(fd, packet_len(0x257));
WFIFOW(fd,0) = 0x257;
WFIFOL(fd,2) = mail_id;
- WFIFOW(fd,6) = flag;
+ WFIFOW(fd,6) = failed;
WFIFOSET(fd, packet_len(0x257));
-
- if( !flag && sd->mail.inbox.full )
- intif_Mail_requestinbox(sd->status.char_id, 1); // Reload the Mail Inbox
}
void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
@@ -11585,7 +11589,8 @@ void clif_Mail_return(struct map_session_data *sd, int mail_id, int new_mail)
*------------------------------------------*/
void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
{
- int idx = RFIFOW(fd,2), amount = RFIFOL(fd,4);
+ int idx = RFIFOW(fd,2);
+ int amount = RFIFOL(fd,4);
char flag;
nullpo_retv(sd);
@@ -11610,9 +11615,9 @@ void clif_parse_Mail_winopen(int fd, struct map_session_data *sd)
int flag = RFIFOW(fd,2);
nullpo_retv(sd);
- if (!flag || flag == 1)
+ if (flag == 0 || flag == 1)
mail_removeitem(sd, 0);
- if (!flag || flag == 2)
+ if (flag == 0 || flag == 2)
mail_removezeny(sd, 0);
}
@@ -11627,10 +11632,11 @@ void clif_Mail_send(int fd, unsigned char flag)
WFIFOSET(fd,packet_len(0x249));
}
+/// S 0248 <packet len>.w <nick>.24B <title>.40B <body len>.B <message>.?B
void clif_parse_Mail_send(int fd, struct map_session_data *sd)
{
struct map_session_data *rd;
- struct mail_message *msg;
+ struct mail_message msg;
int body_len;
nullpo_retv(sd);
@@ -11659,41 +11665,36 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
if (body_len > MAIL_BODY_LENGTH)
body_len = MAIL_BODY_LENGTH;
- msg = (struct mail_message*)aCalloc(sizeof(struct mail_message), 1);
-
- if (mail_getattach(sd, msg))
+ if( !mail_getattach(sd, &msg) )
{
- msg->send_id = sd->status.char_id;
- safestrncpy(msg->send_name, sd->status.name, NAME_LENGTH);
-
- if (rd) {
- msg->dest_id = rd->status.char_id;
- safestrncpy(msg->dest_name, rd->status.name, NAME_LENGTH);
- } else {
- msg->dest_id = 0;
- safestrncpy(msg->dest_name, RFIFOP(fd,4), NAME_LENGTH);
- }
+ clif_Mail_send(sd->fd, 1); // Fail
+ mail_removeitem(sd,0);
+ mail_removezeny(sd,0);
+ return;
+ }
- memcpy(msg->title, RFIFOP(fd,28), MAIL_TITLE_LENGTH);
-
- if (body_len)
- memcpy(msg->body, RFIFOP(fd,69), body_len);
- else
- memset(msg->body, 0x00, MAIL_BODY_LENGTH);
-
- msg->timestamp = (int)mail_calctimes();
- intif_Mail_send(sd->status.account_id, msg);
+ msg.send_id = sd->status.char_id;
+ safestrncpy(msg.send_name, sd->status.name, NAME_LENGTH);
- sd->cansendmail_tick = gettick() + 1000; // 5 Seconds flood Protection
+ if (rd) {
+ msg.dest_id = rd->status.char_id;
+ safestrncpy(msg.dest_name, rd->status.name, NAME_LENGTH);
+ } else {
+ msg.dest_id = 0;
+ safestrncpy(msg.dest_name, (char*)RFIFOP(fd,4), NAME_LENGTH);
}
+
+ safestrncpy(msg.title, (char*)RFIFOP(fd,28), MAIL_TITLE_LENGTH);
+
+ if (body_len)
+ memcpy(msg.body, RFIFOP(fd,69), body_len);
else
- {
- mail_removeitem(sd,0);
- mail_removezeny(sd,0);
- clif_Mail_send(sd->fd, 1); // Fail
- }
+ memset(msg.body, 0x00, MAIL_BODY_LENGTH);
+
+ msg.timestamp = (int)mail_calctimes();
+ intif_Mail_send(sd->status.account_id, &msg);
- aFree(msg);
+ sd->cansendmail_tick = gettick() + 1000; // 5 Seconds flood Protection
}
#endif
diff --git a/src/map/clif.h b/src/map/clif.h
index 117c7fb24..a3bc84d74 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -386,7 +386,7 @@ int do_init_clif(void);
// MAIL SYSTEM
void clif_Mail_openmail(int fd);
void clif_Mail_read(struct map_session_data *sd, int mail_id);
-void clif_Mail_delete(struct map_session_data *sd, int mail_id, short flag);
+void clif_Mail_delete(struct map_session_data *sd, int mail_id, bool failed);
void clif_Mail_return(struct map_session_data *sd, int mail_id, int new_mail);
void clif_Mail_send(int fd, unsigned char flag);
void clif_Mail_new(int fd, int mail_id, const char *sender, const char *title);
diff --git a/src/map/guild.c b/src/map/guild.c
index 1fda18d9f..12577a8fd 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -475,21 +475,23 @@ int guild_request_info(int guild_id)
// イベント付き情報要求
int guild_npc_request_info(int guild_id,const char *event)
{
- struct eventlist *ev;
-
- if( guild_search(guild_id) ){
- if(event && *event)
+ if( guild_search(guild_id) )
+ {
+ if( event && *event )
npc_event_do(event);
+
return 0;
}
- if(event==NULL || *event==0)
- return guild_request_info(guild_id);
+ if( event && *event )
+ {
+ struct eventlist* ev;
+ ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1);
+ memcpy(ev->name,event,strlen(event));
+ //The one in the db becomes the next event from this.
+ ev->next=idb_put(guild_infoevent_db,guild_id,ev);
+ }
- ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1);
- memcpy(ev->name,event,strlen(event));
- //The one in the db becomes the next event from this.
- ev->next=idb_put(guild_infoevent_db,guild_id,ev);
return guild_request_info(guild_id);
}
@@ -1723,8 +1725,8 @@ int guild_castledataloadack(int castle_id,int index,int value)
switch(index){
case 1:
gc->guild_id = value;
- if (value && guild_search(value)==NULL) //Request guild data which will be required for spawned guardians. [Skotlex]
- guild_request_info(value);
+ if (gc->guild_id && guild_search(gc->guild_id)==NULL) //Request guild data which will be required for spawned guardians. [Skotlex]
+ guild_request_info(gc->guild_id);
break;
case 2: gc->economy = value; break;
case 3: gc->defense = value; break;
@@ -1826,34 +1828,39 @@ int guild_castledatasaveack(int castle_id,int index,int value)
int guild_castlealldataload(int len,struct guild_castle *gc)
{
int i;
- int n = (len-4) / sizeof(struct guild_castle), ev = -1;
+ int n = (len-4) / sizeof(struct guild_castle);
+ int ev;
nullpo_retr(0, gc);
//Last owned castle in the list invokes ::OnAgitinit
- for(i = 0; i < n; i++) {
- if ((gc + i)->guild_id)
- ev = i;
- }
+ for( i = n-1; i >= 0 && !(gc[i].guild_id); --i );
+ ev = i; // offset of castle or -1
- // 城データ格納とギルド情報要求
- for(i = 0; i < n; i++, gc++) {
+ // load received castles into memory, one by one
+ for( i = 0; i < n; i++, gc++ )
+ {
struct guild_castle *c = guild_castle_search(gc->castle_id);
if (!c) {
ShowError("guild_castlealldataload Castle id=%d not found.\n", gc->castle_id);
continue;
}
- memcpy(&c->guild_id,&gc->guild_id,
- sizeof(struct guild_castle) - ((int)&c->guild_id - (int)c) );
- if( c->guild_id ){
- if(i!=ev)
+
+ // update mapserver castle data with new info
+ memcpy(&c->guild_id, &gc->guild_id, sizeof(struct guild_castle) - ((int)&c->guild_id - (int)c));
+
+ if( c->guild_id )
+ {
+ if( i != ev )
guild_request_info(c->guild_id);
- else
+ else // last owned one
guild_npc_request_info(c->guild_id, "::OnAgitInit");
}
}
- if (ev == -1) //No castles owned, invoke OnAgitInit as it is.
+
+ if( ev < 0 ) //No castles owned, invoke OnAgitInit as it is.
npc_event_doall("OnAgitInit");
+
return 0;
}
diff --git a/src/map/intif.c b/src/map/intif.c
index e6fe15242..d6839b180 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -6,6 +6,7 @@
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/malloc.h"
+#include "../common/strlib.h"
#include "map.h"
#include "battle.h"
#include "chrif.h"
@@ -33,7 +34,7 @@ static const int packet_len_table[]={
-1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810
39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820
10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830
- 9, 9,-1,14, 0, 0, 0, 0, -1, 0,-1,12, 14,-1, 0, 0, //0x3840
+ 9, 9,-1,14, 0, 0, 0, 0, -1, 0,-1,11, 14,-1, 0, 0, //0x3840
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -259,6 +260,7 @@ int intif_saveregistry(struct map_session_data *sd, int type)
{
struct global_reg *reg;
int count;
+ int i, p;
if (CheckForCharServer())
return -1;
@@ -289,18 +291,13 @@ int intif_saveregistry(struct map_session_data *sd, int type)
WFIFOL(inter_fd,4)=sd->status.account_id;
WFIFOL(inter_fd,8)=sd->status.char_id;
WFIFOB(inter_fd,12)=type;
- if(count ==0){
- WFIFOW(inter_fd,2)=13;
- }else{
- int i,p;
- for (p=13,i = 0; i < count; i++) {
- if (reg[i].str[0] && reg[i].value != 0) {
- p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
- p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].value)+1;
- }
+ for( p = 13, i = 0; i < count; i++ ) {
+ if (reg[i].str[0] && reg[i].value != 0) {
+ p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
+ p+= sprintf((char*)WFIFOP(inter_fd,p), "%s", reg[i].value)+1;
}
- WFIFOW(inter_fd,2)=p;
}
+ WFIFOW(inter_fd,2)=p;
WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
return 0;
}
@@ -853,8 +850,7 @@ int intif_parse_WisMessage(int fd)
id=RFIFOL(fd,4);
- memcpy(name, RFIFOP(fd,32), NAME_LENGTH);
- name[NAME_LENGTH-1] = '\0'; //In case name arrived without it's terminator. [Skotlex]
+ safestrncpy(name, (char*)RFIFOP(fd,32), NAME_LENGTH);
sd = map_nick2sd(name);
if(sd == NULL || strcmp(sd->status.name, name) != 0)
{ //Not found
@@ -923,10 +919,8 @@ int mapif_parse_WisToGM(int fd)
message = (char *) (mes_len >= 255 ? (char *) aMallocA(mes_len) : mbuf);
min_gm_level = (int)RFIFOW(fd,28);
- memcpy(Wisp_name, RFIFOP(fd,4), NAME_LENGTH);
- Wisp_name[NAME_LENGTH-1] = '\0';
- memcpy(message, RFIFOP(fd,30), mes_len);
- message[mes_len-1] = '\0';
+ safestrncpy(Wisp_name, (char*)RFIFOP(fd,4), NAME_LENGTH);
+ safestrncpy(message, (char*)RFIFOP(fd,30), mes_len);
// information is sended to all online GM
clif_foreachclient(mapif_parse_WisToGM_sub, min_gm_level, Wisp_name, message, mes_len);
@@ -1216,70 +1210,59 @@ int intif_parse_GuildBroken(int fd)
return 0;
}
-// ギルド基本情報変更通知
+// basic guild info change notice
+// 0x3839 <packet len>.w <guild id>.l <type>.w <data>.?b
int intif_parse_GuildBasicInfoChanged(int fd)
{
- int type, guild_id;
- unsigned int dd;
- void *data;
- struct guild *g;
- short dw;
- type=RFIFOW(fd,8);
- guild_id=RFIFOL(fd,4);
- data=RFIFOP(fd,10);
- g=guild_search(guild_id);
- dw=*((short *)data);
- dd=*((unsigned int *)data);
- if( g==NULL )
- return 0;
- switch(type){
- case GBI_EXP: g->exp=dd; break;
- case GBI_GUILDLV: g->guild_lv=dw; break;
- case GBI_SKILLPOINT: g->skill_point=dd; break;
+ //int len = RFIFOW(fd,2) - 10;
+ int guild_id = RFIFOL(fd,4);
+ int type = RFIFOW(fd,8);
+ //void* data = RFIFOP(fd,10);
+
+ struct guild* g = guild_search(guild_id);
+ if( g == NULL )
+ return 0;
+
+ switch(type) {
+ case GBI_EXP: g->exp = RFIFOL(fd,10); break;
+ case GBI_GUILDLV: g->guild_lv = RFIFOW(fd,10); break;
+ case GBI_SKILLPOINT: g->skill_point = RFIFOL(fd,10); break;
}
+
return 0;
}
-// ギルドメンバ情報変更通知
+
+// guild member info change notice
+// 0x383a <packet len>.w <guild id>.l <account id>.l <char id>.l <type>.w <data>.?b
int intif_parse_GuildMemberInfoChanged(int fd)
{
- int type, guild_id, account_id, char_id, idx, dd;
- void* data;
- struct guild *g;
- type=RFIFOW(fd,16);
- guild_id=RFIFOL(fd,4);
- account_id=RFIFOL(fd,8);
- char_id=RFIFOL(fd,12);
- data=RFIFOP(fd,18);
- g=guild_search(guild_id);
- dd=*((int *)data);
- if( g==NULL )
- return 0;
- idx=guild_getindex(g,account_id,char_id);
- if (idx == -1)
- return 0;
- switch(type){
- case GMI_POSITION:
- g->member[idx].position=dd;
- guild_memberposition_changed(g,idx,dd);
- break;
- case GMI_EXP:
- g->member[idx].exp=dd;
- break;
- case GMI_HAIR:
- g->member[idx].hair=dd;
- break;
- case GMI_HAIR_COLOR:
- g->member[idx].hair_color=dd;
- break;
- case GMI_GENDER:
- g->member[idx].gender=dd;
- break;
- case GMI_CLASS:
- g->member[idx].class_=dd;
- break;
- case GMI_LEVEL:
- g->member[idx].lv=dd;
- break;
+ //int len = RFIFOW(fd,2) - 18;
+ int guild_id = RFIFOL(fd,4);
+ int account_id = RFIFOL(fd,8);
+ int char_id = RFIFOL(fd,12);
+ int type = RFIFOW(fd,16);
+ void* data = RFIFOP(fd,18);
+ int dd = *((int *)data);
+
+ struct guild* g;
+ int idx;
+
+ g = guild_search(guild_id);
+ if( g == NULL )
+ return 0;
+
+ idx = guild_getindex(g,account_id,char_id);
+ if( idx == -1 )
+ return 0;
+
+ switch( type ) {
+ case GMI_POSITION: g->member[idx].position = dd; guild_memberposition_changed(g,idx,dd); break;
+ case GMI_EXP: g->member[idx].exp = dd; break;
+ case GMI_HAIR: g->member[idx].hair = dd; break;
+ case GMI_HAIR_COLOR: g->member[idx].hair_color = dd; break;
+ case GMI_GENDER: g->member[idx].gender = dd; break;
+ case GMI_CLASS: g->member[idx].class_ = dd; break;
+ case GMI_LEVEL: g->member[idx].lv = dd; break;
}
return 0;
}
@@ -1303,8 +1286,7 @@ int intif_parse_GuildSkillUp(int fd)
// ギルド同盟/敵対通知
int 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),(char *) RFIFOP(fd,19),(char *) RFIFOP(fd,43));
return 0;
}
// ギルド告知変更通知
@@ -1460,15 +1442,16 @@ int intif_parse_DeleteHomunculusOk(int fd)
return 0;
}
+#ifndef TXT_ONLY
/*==========================================
* MAIL SYSTEM
* By Zephyrus
- *------------------------------------------
+ *==========================================*/
+
+/*------------------------------------------
* Inbox Request
* flag: 0 Update Inbox | 1 OpenMail
*------------------------------------------*/
-#ifndef TXT_ONLY
-
int intif_Mail_requestinbox(int char_id, unsigned char flag)
{
if (CheckForCharServer())
@@ -1488,7 +1471,7 @@ int intif_parse_Mail_inboxreceived(int fd)
struct map_session_data *sd;
unsigned char flag = RFIFOB(fd,8);
- sd = map_charid2sd( RFIFOL(fd,4) );
+ sd = map_charid2sd(RFIFOL(fd,4));
if (sd == NULL)
{
@@ -1507,7 +1490,7 @@ int intif_parse_Mail_inboxreceived(int fd)
return 1;
}
- memset(&sd->mail.inbox, 0, sizeof(struct mail_data));
+ //FIXME: this operation is not safe [ultramage]
memcpy(&sd->mail.inbox, RFIFOP(fd,9), sizeof(struct mail_data));
if (flag)
@@ -1515,7 +1498,7 @@ int intif_parse_Mail_inboxreceived(int fd)
else
{
char output[128];
- sprintf(output, "You have %d new emails (%d unreaded)", sd->mail.inbox.unchecked, sd->mail.inbox.unreaded + sd->mail.inbox.unchecked);
+ sprintf(output, "You have %d new emails (%d unread)", sd->mail.inbox.unchecked, sd->mail.inbox.unread + sd->mail.inbox.unchecked);
clif_disp_onlyself(sd, output, strlen(output));
}
return 0;
@@ -1611,21 +1594,22 @@ int intif_Mail_delete(int char_id, int mail_id)
int intif_parse_Mail_delete(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ int char_id = RFIFOL(fd,2);
int mail_id = RFIFOL(fd,6);
- short flag = RFIFOW(fd,10);
+ bool failed = RFIFOB(fd,10);
+ struct map_session_data *sd = map_charid2sd(char_id);
if (sd == NULL)
{
if (battle_config.error_log)
- ShowError("intif_parse_Mail_delete: char not found %d\n",RFIFOL(fd,2));
+ ShowError("intif_parse_Mail_delete: char not found %d\n", char_id);
return 1;
}
if (sd->state.finalsave)
return 1;
- clif_Mail_delete(sd, mail_id, flag);
+ clif_Mail_delete(sd, mail_id, failed);
return 0;
}
/*------------------------------------------
diff --git a/src/map/npc.c b/src/map/npc.c
index b2de0af2a..87ceb8afb 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -337,19 +337,16 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, int data)
memcpy(&ev_tm_b,t,sizeof(ev_tm_b));
return c;
}
+
/*==========================================
* OnInitイベント実行(&時計イベント開始)
*------------------------------------------*/
-int npc_event_do_oninit(void)
+void npc_event_do_oninit(void)
{
-// int c = npc_event_doall("OnInit");
- ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"
- CL_WHITE"%d"CL_RESET"' NPCs.\n",npc_event_doall("OnInit"));
-
- add_timer_interval(gettick()+100,
- npc_event_do_clock,0,0,1000);
+ int count = npc_event_doall("OnInit");
+ ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", count);
- return 0;
+ add_timer_interval(gettick()+100,npc_event_do_clock,0,0,1000);
}
/*==========================================
diff --git a/src/map/npc.h b/src/map/npc.h
index 7293b4a7c..908ca3382 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -69,7 +69,7 @@ void npc_delsrcfile(const char* name);
void npc_parsesrcfile(const char* filepath);
int do_final_npc(void);
int do_init_npc(void);
-int npc_event_do_oninit(void);
+void npc_event_do_oninit(void);
int npc_do_ontimer(int npc_id, int option);
int npc_event_doall(const char* name);
diff --git a/src/map/skill.c b/src/map/skill.c
index bd58f6a9b..130087e33 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -7399,15 +7399,17 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
int count=0;
int x = bl->x, y = bl->y;
//If target isn't knocked back it should hit every 20ms [Playtester]
- while (count++ < SKILLUNITTIMER_INTERVAL/sg->interval && x == bl->x && y == bl->y && !status_isdead(bl)){
- if (bl->type==BL_PC)
+ while( count++ < SKILLUNITTIMER_INTERVAL/sg->interval && x == bl->x && y == bl->y && !status_isdead(bl) )
+ {
+ if( bl->type == BL_PC )
status_zap(bl, 0, 15); //Only damage SP [Skotlex]
- else if (!status_charge(ss, 0, 2)){ //should end when out of sp.
- sg->limit=DIFF_TICK(tick,sg->tick);
+ else // mobs
+ if( status_charge(ss, 0, 2) ) // costs 2 SP per hit
+ skill_attack(BF_WEAPON,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick+count*20,0);
+ else { //should end when out of sp.
+ sg->limit = DIFF_TICK(tick,sg->tick);
break;
}
- else
- skill_attack(BF_WEAPON,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick+count*20,0);
}
}
break;
@@ -8020,8 +8022,7 @@ int skill_check_pc_partner (struct map_session_data *sd, short skill_id, short*
//Else: new search for partners.
c = 0;
memset (p_sd, 0, sizeof(p_sd));
- i = map_foreachinrange(skill_check_condition_char_sub, &sd->bl,
- range, BL_PC, &sd->bl, &c, &p_sd, skill_id);
+ i = map_foreachinrange(skill_check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id);
if (skill_id != PR_BENEDICTIO) //Apply the average lv to encore skills.
*skill_lv = (i+(*skill_lv))/(c+1); //I know c should be one, but this shows how it could be used for the average of n partners.