summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-12 09:55:13 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-12 09:55:13 +0000
commited87621c65d7c13ddd4993101a5b7c2287b6609e (patch)
treea035e4d010d2b9a690c82114dff33dfa36d9f889 /src/map
parent1c5fab35e935b870939bcae24ea95e957ed76d5a (diff)
downloadhercules-ed87621c65d7c13ddd4993101a5b7c2287b6609e.tar.gz
hercules-ed87621c65d7c13ddd4993101a5b7c2287b6609e.tar.bz2
hercules-ed87621c65d7c13ddd4993101a5b7c2287b6609e.tar.xz
hercules-ed87621c65d7c13ddd4993101a5b7c2287b6609e.zip
* Some preparations for the guild script update
- cleaned up npc event execution code - cleaned up guild data loading/saving code; to be improved later - removed dummy 'account name' expulsion list management code - removed columns 'rsv1' and 'rsv2' from guild member data - removed columns 'rsv1' 'rsv2' 'rsv3' and 'acc' from guild expulsion data - added upgrade_svn11895.sql for SQL git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11895 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c4
-rw-r--r--src/map/chrif.c10
-rw-r--r--src/map/clif.c32
-rw-r--r--src/map/guild.c133
-rw-r--r--src/map/guild.h3
-rw-r--r--src/map/intif.c5
-rw-r--r--src/map/irc.c2
-rw-r--r--src/map/npc.c105
-rw-r--r--src/map/npc.h4
-rw-r--r--src/map/status.c2
-rw-r--r--src/map/status.h2
11 files changed, 126 insertions, 176 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 346948cb6..eeb368feb 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3232,7 +3232,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
int t_guild = status_get_guild_id(t_bl);
if (
!(map[m].flag.pvp && map[m].flag.pvp_noguild) &&
- s_guild && t_guild && (s_guild == t_guild || guild_idisallied(s_guild, t_guild))
+ s_guild && t_guild && (s_guild == t_guild || guild_isallied(s_guild, t_guild))
)
state |= BCT_GUILD;
else
@@ -3260,7 +3260,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if (flag&BCT_GUILD || state&BCT_ENEMY) {
int s_guild = status_get_guild_id(s_bl);
int t_guild = status_get_guild_id(t_bl);
- if(s_guild && t_guild && (s_guild == t_guild || guild_idisallied(s_guild, t_guild)))
+ if(s_guild && t_guild && (s_guild == t_guild || guild_isallied(s_guild, t_guild)))
state |= BCT_GUILD;
}
}
diff --git a/src/map/chrif.c b/src/map/chrif.c
index b2a3af4bf..a041d9957 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -92,7 +92,6 @@ static uint32 char_ip = 0;
static uint16 char_port = 6121;
static char userid[NAME_LENGTH], passwd[NAME_LENGTH];
static int chrif_state = 0;
-static int char_init_done = 0;
int other_mapserver_count=0; //Holds count of how many other map servers are online (apart of this instance) [Skotlex]
//Interval at which map server updates online listing. [Valaris]
@@ -342,20 +341,23 @@ int chrif_changemapserverack(int account_id, int login_id1, int login_id2, int c
*------------------------------------------*/
int chrif_connectack(int fd)
{
+ static bool char_init_done = false;
+
if (RFIFOB(fd,2)) {
ShowFatalError("Connection to char-server failed %d.\n", RFIFOB(fd,2));
exit(EXIT_FAILURE);
}
+
ShowStatus("Successfully logged on to Char Server (Connection: '"CL_WHITE"%d"CL_RESET"').\n",fd);
chrif_state = 1;
- chrif_connected=1;
+ chrif_connected = 1;
chrif_sendmap(fd);
ShowStatus("Event '"CL_WHITE"OnCharIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnCharIfInit"));
ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit"));
- if(!char_init_done) {
- char_init_done = 1;
+ if( !char_init_done ) {
+ char_init_done = true;
ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce"));
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 53227d286..e0d4c1ca0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -6472,6 +6472,7 @@ int clif_guild_inviteack(struct map_session_data *sd,int flag)
WFIFOSET(fd,packet_len(0x169));
return 0;
}
+
/*==========================================
* ギルドメンバ脱退通知
*------------------------------------------*/
@@ -6487,23 +6488,24 @@ int clif_guild_leave(struct map_session_data *sd,const char *name,const char *me
clif_send(buf,packet_len(0x15a),&sd->bl,GUILD);
return 0;
}
+
/*==========================================
* ギルドメンバ追放通知
*------------------------------------------*/
-int clif_guild_expulsion(struct map_session_data *sd,const char *name,const char *mes,
- int account_id)
+int clif_guild_expulsion(struct map_session_data *sd,const char *name,const char *mes,int account_id)
{
unsigned char buf[128];
nullpo_retr(0, sd);
WBUFW(buf, 0)=0x15c;
- memcpy(WBUFP(buf, 2),name,NAME_LENGTH);
- memcpy(WBUFP(buf,26),mes,40);
- memcpy(WBUFP(buf,66),"dummy",NAME_LENGTH);
+ safestrncpy(WBUFP(buf, 2),name,NAME_LENGTH);
+ safestrncpy(WBUFP(buf,26),mes,40);
+ safestrncpy(WBUFP(buf,66),"",NAME_LENGTH); // account name (not used for security reasons)
clif_send(buf,packet_len(0x15c),&sd->bl,GUILD);
return 0;
}
+
/*==========================================
* ギルド追放メンバリスト
*------------------------------------------*/
@@ -6519,18 +6521,18 @@ int clif_guild_expulsionlist(struct map_session_data *sd)
g=guild_search(sd->status.guild_id);
if(g==NULL)
return 0;
- WFIFOHEAD(fd,MAX_GUILDEXPULSION * 88 + 4);
+ WFIFOHEAD(fd,4 + MAX_GUILDEXPULSION * 88);
WFIFOW(fd,0)=0x163;
for(i=c=0;i<MAX_GUILDEXPULSION;i++){
struct guild_expulsion *e=&g->expulsion[i];
if(e->account_id>0){
- memcpy(WFIFOP(fd,c*88+ 4),e->name,NAME_LENGTH);
- memcpy(WFIFOP(fd,c*88+28),e->acc,24);
- memcpy(WFIFOP(fd,c*88+52),e->mes,44);
+ safestrncpy(WFIFOP(fd,4 + c*88),e->name,NAME_LENGTH);
+ safestrncpy(WFIFOP(fd,4 + c*88+24),"",24); // account name (not used for security reasons)
+ safestrncpy(WFIFOP(fd,4 + c*88+48),e->mes,40);
c++;
}
}
- WFIFOW(fd,2)=c*88+4;
+ WFIFOW(fd,2) = 4 + c*88;
WFIFOSET(fd,WFIFOW(fd,2));
return 0;
}
@@ -8542,7 +8544,9 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_DropItem(int fd, struct map_session_data *sd)
{
- int item_index, item_amount;
+ int item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
+ int item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
+
item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2;
item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]);
do {
@@ -8564,7 +8568,8 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd)
return;
} while (0);
- //Because the client does not likes being ignored.
+
+ //Because the client does not like being ignored.
clif_delitem(sd, item_index,0);
}
@@ -9991,7 +9996,8 @@ void clif_parse_GuildLeave(int fd,struct map_session_data *sd)
}
/*==========================================
- * ギルド追放
+ * Request to expel a member of a guild
+ * S 015b <guild_id>.L <account_id>.L <char_id>.L <reason>.39B 00
*------------------------------------------*/
void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd)
{
diff --git a/src/map/guild.c b/src/map/guild.c
index 889338a9c..ca571b3ce 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -655,9 +655,7 @@ int guild_invite(struct map_session_data *sd,struct map_session_data *tsd)
}
// 定員確認
- for(i=0;i<g->max_member;i++)
- if(g->member[i].account_id==0)
- break;
+ ARR_FIND( 0, g->max_member, i, g->member[i].account_id == 0 );
if(i==g->max_member){
clif_guild_inviteack(sd,3);
return 0;
@@ -669,60 +667,52 @@ int guild_invite(struct map_session_data *sd,struct map_session_data *tsd)
clif_guild_invite(tsd,g);
return 0;
}
-// ギルド勧誘への返答
-int guild_reply_invite(struct map_session_data *sd,int guild_id,int flag)
+
+/// Guild invitation reply.
+/// flag: 0:rejected, 1:accepted
+int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag)
{
- struct map_session_data *tsd;
+ struct map_session_data* tsd;
nullpo_retr(0, sd);
-
- //nullpo_retr(0, tsd= map_id2sd( sd->guild_invite_account ));
- //I checked the code, and there's no "check" for the case where the guy
- //that invites another to a guild quits the map-server before being replied.
- //Hence that's a valid null pointer scenario. :) [Skotlex]
- if ((tsd= map_id2sd( sd->guild_invite_account )) == NULL)
- { //Do we send a "invitation failed" msg or something to the player?
- //Or should we accept the invitation and add it to the guild anyway?
- //afterall, guild_invite holds the guild id that the player was invited to.
- sd->guild_invite=0;
- sd->guild_invite_account=0;
- return 0;
- }
- if(sd->guild_invite!=guild_id) // 勧誘とギルドIDが違う
- return 0;
+ // subsequent requests may override the value
+ if( sd->guild_invite != guild_id )
+ return 0; // mismatch
- if(flag==1){ // 承諾
+ // look up the person who sent the invite
+ //NOTE: this can be NULL because the person might have logged off in the meantime
+ tsd = map_id2sd(sd->guild_invite_account);
+
+ // zero out the status data
+ sd->guild_invite = 0;
+ sd->guild_invite_account = 0;
+
+ if( flag == 0 )
+ {// rejected
+ if( tsd ) clif_guild_inviteack(tsd,1);
+ }
+ else
+ {// accepted
struct guild_member m;
- struct guild *g;
+ struct guild* g;
int i;
- // 定員確認
- if( (g=guild_search(tsd->status.guild_id))==NULL ){
- sd->guild_invite=0;
- sd->guild_invite_account=0;
+ if( (g=guild_search(guild_id)) == NULL )
return 0;
- }
- for(i=0;i<g->max_member;i++)
- if(g->member[i].account_id==0)
- break;
- if(i==g->max_member){
- sd->guild_invite=0;
- sd->guild_invite_account=0;
- clif_guild_inviteack(tsd,3);
+
+ ARR_FIND( 0, g->max_member, i, g->member[i].account_id == 0 );
+ if( i == g->max_member )
+ {
+ if( tsd ) clif_guild_inviteack(tsd,3);
return 0;
}
- //inter鯖へ追加要求
guild_makemember(&m,sd);
- intif_guild_addmember( sd->guild_invite, &m );
+ intif_guild_addmember(guild_id, &m);
//TODO: send a minimap update to this player
- return 0;
- }else{ // 拒否
- sd->guild_invite=0;
- sd->guild_invite_account=0;
- clif_guild_inviteack(tsd,1);
}
+
return 0;
}
// ギルドメンバが追加された
@@ -1821,7 +1811,9 @@ int guild_castlealldataload(int len,struct guild_castle *gc)
for( i = n-1; i >= 0 && !(gc[i].guild_id); --i );
ev = i; // offset of castle or -1
- // load received castles into memory, one by one
+ if( ev < 0 ) //No castles owned, invoke OnAgitInit as it is.
+ npc_event_doall("OnAgitInit");
+ else // 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);
@@ -1842,9 +1834,6 @@ int guild_castlealldataload(int len,struct guild_castle *gc)
}
}
- if( ev < 0 ) //No castles owned, invoke OnAgitInit as it is.
- npc_event_doall("OnAgitInit");
-
return 0;
}
@@ -1906,57 +1895,15 @@ int guild_checkcastles(struct guild *g)
return nb_cas;
}
-// [MouseJstr]
-// is this guild allied with this castle?
-int guild_isallied(struct guild *g, struct guild_castle *gc)
-{
- int i;
-
- nullpo_retr(0, g);
-
- if(g->guild_id == gc->guild_id)
- return 1;
-
- if (gc->guild_id == 0)
- return 0;
-
-
- for(i=0;i<MAX_GUILDALLIANCE;i++)
- if(g->alliance[i].guild_id == gc->guild_id) {
- if(g->alliance[i].opposition == 0)
- return 1;
- else
- return 0;
- }
-
- return 0;
-}
-
-int guild_idisallied(int guild_id, int guild_id2)
+// Are these two guilds allied?
+bool guild_isallied(int guild_id, int guild_id2)
{
int i;
- struct guild *g;
-
- if (guild_id <= 0 || guild_id2 <= 0)
- return 0;
-
- if(guild_id == guild_id2)
- return 1;
-
- g = guild_search(guild_id);
-
+ struct guild* g = guild_search(guild_id);
nullpo_retr(0, g);
-
- for(i=0;i<MAX_GUILDALLIANCE;i++)
- if(g->alliance[i].guild_id == guild_id2) {
- if(g->alliance[i].opposition == 0)
- return 1;
- else
- return 0;
- }
-
- return 0;
+ ARR_FIND( 0, MAX_GUILDALLIANCE, i, g->alliance[i].guild_id == guild_id2 );
+ return( i < MAX_GUILDALLIANCE && g->alliance[i].opposition == 0 );
}
static int guild_infoevent_db_final(DBKey key,void *data,va_list ap)
diff --git a/src/map/guild.h b/src/map/guild.h
index 61c9e1778..bfa359fb1 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -18,8 +18,7 @@ int guild_skill_get_max(int id);
int guild_checkskill(struct guild *g,int id);
int guild_check_skill_require(struct guild *g,int id); // [Komurka]
int guild_checkcastles(struct guild *g); // [MouseJstr]
-int guild_isallied(struct guild *g, struct guild_castle *gc);
-int guild_idisallied(int guild_id, int guild_id2); //Checks alliance based on guild Ids. [Skotlex]
+bool guild_isallied(int guild_id, int guild_id2); //Checks alliance based on guild Ids. [Skotlex]
void do_init_guild(void);
struct guild *guild_search(int guild_id);
diff --git a/src/map/intif.c b/src/map/intif.c
index 5c8cfc9a0..bcb1eef2a 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -587,13 +587,12 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha
WFIFOL(inter_fd, 6) = account_id;
WFIFOL(inter_fd,10) = char_id;
WFIFOB(inter_fd,14) = flag;
- memcpy(WFIFOP(inter_fd,15),mes,40);
+ safestrncpy(WFIFOP(inter_fd,15),mes,40);
WFIFOSET(inter_fd,55);
return 0;
}
// ギルドメンバのオンライン状況/Lv更新要求
-int intif_guild_memberinfoshort(int guild_id,
- int account_id,int char_id,int online,int lv,int class_)
+int intif_guild_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_)
{
if (CheckForCharServer())
return 0;
diff --git a/src/map/irc.c b/src/map/irc.c
index 986efd51b..a7995e615 100644
--- a/src/map/irc.c
+++ b/src/map/irc.c
@@ -52,7 +52,7 @@ int irc_connect_timer(int tid, unsigned int tick, int id, int data)
return 0;
//Ok, this ShowInfo and printf are a little ugly, but they are meant to
//debug just how long the code freezes here. [Skotlex]
- ShowInfo("(IRC) Connecting to %s... ", irc_ip_str);
+ ShowInfo("(IRC) Connecting to %s...\n", irc_ip_str);
irc_fd = make_connection(irc_ip,irc_port);
if(irc_fd > 0){
printf("ok\n");
diff --git a/src/map/npc.c b/src/map/npc.c
index a9ea50e89..6ddbffe01 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -59,7 +59,6 @@ struct event_data {
struct npc_data *nd;
int pos;
};
-static struct tm ev_tm_b; // 時計イベント用
static struct eri *timer_event_ers; //For the npc timer data. [Skotlex]
@@ -227,17 +226,20 @@ int npc_event_doall_sub(DBKey key, void* data, va_list ap)
const char* p = key.str;
struct event_data* ev;
int* c;
+ const char* name;
int rid;
- char* name;
- ev = (struct event_data *)data;
- c = va_arg(ap, int *);
- name = va_arg(ap,char *);
+ nullpo_retr(0, ev = (struct event_data *)data);
+ nullpo_retr(0, ap);
+ nullpo_retr(0, c = va_arg(ap, int *));
+ nullpo_retr(0, name = va_arg(ap, const char *));
rid = va_arg(ap, int);
- if( (p=strchr(p, ':')) && p && strcmpi(name, p)==0 ) {
- if(rid)
- npc_event_sub(((struct map_session_data *)map_id2bl(rid)),ev,key.str);
+ p = strchr(p, ':'); // match only the event name
+ if( p && strcmpi(name, p) == 0 )
+ {
+ if(rid) // a player may only have 1 script running at the same time
+ npc_event_sub(map_id2sd(rid),ev,key.str);
else
run_script(ev->nd->u.scr.script,ev->pos,rid,ev->nd->bl.id);
(*c)++;
@@ -245,26 +247,8 @@ int npc_event_doall_sub(DBKey key, void* data, va_list ap)
return 0;
}
-int npc_event_doall(const char* name)
-{
- int c = 0;
- char buf[64] = "::";
- strncpy(buf+2, name, 62);
- ev_db->foreach(ev_db,npc_event_doall_sub,&c,buf,0);
- return c;
-}
-int npc_event_doall_id(const char* name, int rid)
-{
- int c = 0;
- char buf[64] = "::";
-
- strncpy(buf+2, name, 62);
- ev_db->foreach(ev_db,npc_event_doall_sub,&c,buf,rid);
- return c;
-}
-
-int npc_event_do_sub(DBKey key, void* data, va_list ap)
+static int npc_event_do_sub(DBKey key, void* data, va_list ap)
{
const char* p = key.str;
struct event_data* ev;
@@ -274,43 +258,61 @@ int npc_event_do_sub(DBKey key, void* data, va_list ap)
nullpo_retr(0, ev = (struct event_data *)data);
nullpo_retr(0, ap);
nullpo_retr(0, c = va_arg(ap, int *));
+ nullpo_retr(0, name = va_arg(ap, const char *));
- name = va_arg(ap, const char *);
-
- if (p && strcmpi(name, p)==0) {
+ if( p && strcmpi(name, p) == 0 )
+ {
run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id);
(*c)++;
}
return 0;
}
+
+// runs the specified event (supports both single-npc and global events)
int npc_event_do(const char* name)
{
int c = 0;
- if (*name == ':' && name[1] == ':') {
- return npc_event_doall(name+2);
- }
+ if( name[0] == ':' && name[1] == ':' )
+ ev_db->foreach(ev_db,npc_event_doall_sub,&c,name,0);
+ else
+ ev_db->foreach(ev_db,npc_event_do_sub,&c,name);
- ev_db->foreach(ev_db,npc_event_do_sub,&c,name);
return c;
}
+// runs the specified event (global only)
+int npc_event_doall(const char* name)
+{
+ return npc_event_doall_id(name, 0);
+}
+// runs the specified event, with a RID attached (global only)
+int npc_event_doall_id(const char* name, int rid)
+{
+ int c = 0;
+ char buf[64];
+ safesnprintf(buf, sizeof(buf), "::%s", name);
+ ev_db->foreach(ev_db,npc_event_doall_sub,&c,buf,rid);
+ return c;
+}
+
/*==========================================
* 時計イベント実行
*------------------------------------------*/
int npc_event_do_clock(int tid, unsigned int tick, int id, int data)
{
+ static struct tm ev_tm_b; // tracks previous execution time
time_t timer;
- struct tm *t;
+ struct tm* t;
char buf[64];
- char *day="";
- int c=0;
+ char* day;
+ int c = 0;
- time(&timer);
- t=localtime(&timer);
+ timer = time(NULL);
+ t = localtime(&timer);
- switch (t->tm_wday) {
+ switch (t->tm_wday) {
case 0: day = "Sun"; break;
case 1: day = "Mon"; break;
case 2: day = "Tue"; break;
@@ -318,6 +320,7 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, int data)
case 4: day = "Thu"; break;
case 5: day = "Fri"; break;
case 6: day = "Sat"; break;
+ default:day = ""; break;
}
if (t->tm_min != ev_tm_b.tm_min ) {
@@ -336,6 +339,7 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, int data)
sprintf(buf,"OnDay%02d%02d",t->tm_mon+1,t->tm_mday);
c+=npc_event_doall(buf);
}
+
memcpy(&ev_tm_b,t,sizeof(ev_tm_b));
return c;
}
@@ -345,8 +349,7 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, int data)
*------------------------------------------*/
void npc_event_do_oninit(void)
{
- 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);
+ ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc_event_doall("OnInit"));
add_timer_interval(gettick()+100,npc_event_do_clock,0,0,1000);
}
@@ -361,7 +364,8 @@ int npc_timerevent_import(char* lname, void* data, va_list ap)
struct npc_data *nd=va_arg(ap,struct npc_data *);
int t=0,i=0;
- if(sscanf(lname,"OnTimer%d%n",&t,&i)==1 && lname[i]==':') {
+ if(sscanf(lname,"OnTimer%d%n",&t,&i)==1 && lname[i]==':')
+ {
// タイマーイベント
struct npc_timerevent_list *te=nd->u.scr.timer_event;
int j,i=nd->u.scr.timeramount;
@@ -371,12 +375,9 @@ int npc_timerevent_import(char* lname, void* data, va_list ap)
ShowFatalError("npc_timerevent_import: out of memory !\n");
exit(EXIT_FAILURE);
}
- for(j=0;j<i;j++){
- if(te[j].timer>t){
- memmove(te+j+1,te+j,sizeof(struct npc_timerevent_list)*(i-j));
- break;
- }
- }
+ ARR_FIND( 0, i, j, te[j].timer > t );
+ if( j < i )
+ memmove(te+j+1,te+j,sizeof(struct npc_timerevent_list)*(i-j));
te[j].timer=t;
te[j].pos=pos;
nd->u.scr.timer_event=te;
@@ -465,10 +466,7 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
if( n==0 )
return 0;
- for(j=0;j<n;j++){
- if( nd->u.scr.timer_event[j].timer > nd->u.scr.timer )
- break;
- }
+ ARR_FIND( 0, n, j, nd->u.scr.timer_event[j].timer > nd->u.scr.timer );
if(j>=n) // check if there is a timer to use !!BEFORE!! you write stuff to the structures [Shinomori]
return 0;
if (nd->u.scr.rid > 0) {
@@ -2931,7 +2929,6 @@ int do_init_npc(void)
ev_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1);
npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH);
- memset(&ev_tm_b, -1, sizeof(ev_tm_b));
timer_event_ers = ers_new(sizeof(struct timer_event_data));
// process all npc files
diff --git a/src/map/npc.h b/src/map/npc.h
index 6580e4f21..a0c1956b7 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -74,9 +74,9 @@ int do_init_npc(void);
void npc_event_do_oninit(void);
int npc_do_ontimer(int npc_id, int option);
-int npc_event_doall(const char* name);
int npc_event_do(const char* name);
-int npc_event_doall_id(const char* name, int id);
+int npc_event_doall(const char* name);
+int npc_event_doall_id(const char* name, int rid);
int npc_timerevent_start(struct npc_data* nd, int rid);
int npc_timerevent_stop(struct npc_data* nd);
diff --git a/src/map/status.c b/src/map/status.c
index c8ffde37c..f9237f565 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -4065,7 +4065,7 @@ struct regen_data *status_get_regen_data(struct block_list *bl)
struct status_data *status_get_status_data(struct block_list *bl)
{
nullpo_retr(&dummy_status, bl);
-
+
switch (bl->type) {
case BL_PC: return &((TBL_PC*)bl)->battle_status;
case BL_MOB: return &((TBL_MOB*)bl)->status;
diff --git a/src/map/status.h b/src/map/status.h
index 0526bbd65..eac4b9d55 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -20,8 +20,8 @@ extern unsigned long StatusChangeFlagTable[];
// Status changes listing. These code are for use by the server.
enum sc_type {
//First we enumerate common status ailments which are often used around.
- SC_COMMON_MIN = 0, // begin
SC_STONE = 0,
+ SC_COMMON_MIN = 0, // begin
SC_FREEZE,
SC_STUN,
SC_SLEEP,