summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/char_sql/int_party.c2
-rw-r--r--src/map/battle.h2
-rw-r--r--src/map/clif.c40
-rw-r--r--src/map/intif.c12
-rw-r--r--src/map/irc.c2
-rw-r--r--src/map/npc.c396
-rw-r--r--src/map/npc.h76
-rw-r--r--src/map/script.c8
-rw-r--r--src/map/skill.c4
9 files changed, 263 insertions, 279 deletions
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index 3f3a88de1..c1c09e9a4 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -244,7 +244,7 @@ struct party_data *inter_party_fromsql(int party_id)
return NULL;
}
p->party.party_id = party_id;
- strncpy(&p->party.name, sql_row[1], NAME_LENGTH);
+ strncpy(p->party.name, sql_row[1], NAME_LENGTH);
p->party.exp = atoi(sql_row[2])?1:0;
p->party.item = atoi(sql_row[3]);
leader_id = atoi(sql_row[4]);
diff --git a/src/map/battle.h b/src/map/battle.h
index 8796ac48e..64efa3f70 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -430,7 +430,7 @@ extern struct Battle_Config {
unsigned short override_mob_names; //Enables overriding spawn mob names with the mob_db names. [Skotlex]
unsigned short min_chat_delay; //Minimum time between client messages. [Skotlex]
unsigned short friend_auto_add; //When accepting friends, both get friended. [Skotlex]
- unsigned int hvan_explosion_intimate ; // fix [albator]
+ int hvan_explosion_intimate; // fix [albator]
unsigned short hom_rename;
unsigned short homunculus_show_growth ; //[orn]
unsigned short homunculus_friendly_rate;
diff --git a/src/map/clif.c b/src/map/clif.c
index 4cc6da374..80e863483 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1454,7 +1454,7 @@ int clif_homskillinfoblock(struct map_session_data *sd)
WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv ;
WFIFOW(fd,len+8) = skill_get_sp(id,hd->homunculus.hskill[j].lv) ;
WFIFOW(fd,len+10)= skill_get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv) ;
- strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH) ;
+ strncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH) ;
WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, hd->homunculus.class_))?1:0;
len+=37;
}
@@ -4161,7 +4161,7 @@ int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range)
range = skill_get_range2(&sd->bl, id,sd->status.skill[skillid].lv);
WFIFOW(fd,12)= range;
- strncpy(WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH);
if(sd->status.skill[skillid].flag ==0)
WFIFOB(fd,38)= (sd->status.skill[skillid].lv < skill_tree_get_max(id, sd->status.class_))? 1:0;
else
@@ -4194,7 +4194,7 @@ int clif_skillinfoblock(struct map_session_data *sd)
WFIFOW(fd,len+6) = sd->status.skill[i].lv;
WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv);
- strncpy(WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
if(sd->status.skill[i].flag ==0)
WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_))? 1:0;
else
@@ -6511,7 +6511,7 @@ int clif_guild_memberlogin_notice(struct guild *g,int idx,int flag)
int clif_guild_send_onlineinfo(struct map_session_data *sd)
{
struct guild *g;
- char buf[14*128];
+ unsigned char buf[14*128];
int i, count=0, p_len;
nullpo_retr(0, sd);
@@ -6534,7 +6534,7 @@ int clif_guild_send_onlineinfo(struct map_session_data *sd)
}
}
- clif_send(buf,p_len*count,&sd->bl,SELF);
+ clif_send(buf, p_len*count, &sd->bl, SELF);
return 0;
}
@@ -6815,7 +6815,7 @@ int clif_guild_skillinfo(struct map_session_data *sd)
WFIFOW(fd,c*37+12) = g->skill[i].lv;
WFIFOW(fd,c*37+14) = skill_get_sp(id,g->skill[i].lv);
WFIFOW(fd,c*37+16) = skill_get_range(id,g->skill[i].lv);
- strncpy(WFIFOP(fd,c*37+18), skill_get_name(id), NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,c*37+18), skill_get_name(id), NAME_LENGTH);
if(g->skill[i].lv < guild_skill_get_max(id) && (sd == g->member[0].sd))
up = 1;
else
@@ -7785,9 +7785,9 @@ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int cl
WFIFOHEAD(fd,packet_len(0x20e));
WFIFOW(fd,0)=0x20e;
if (pcdb_checkid(class_))
- strncpy(WFIFOP(fd,2),job_name(class_), NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,2),job_name(class_), NAME_LENGTH);
else if (mobdb_checkid(class_))
- strncpy(WFIFOP(fd,2),mob_db(class_)->jname, NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,2),mob_db(class_)->jname, NAME_LENGTH);
else //Really shouldn't happen...
memset(WFIFOP(fd,2), 0, NAME_LENGTH);
WFIFOL(fd,26)=sd->bl.id;
@@ -7804,7 +7804,7 @@ void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char pr
int fd=sd->fd;
WFIFOHEAD(fd,packet_len(0x20e));
WFIFOW(fd,0)=0x20e;
- strncpy(WFIFOP(fd,2),mob_db(mob_id)->jname, NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd,2),mob_db(mob_id)->jname, NAME_LENGTH);
WFIFOL(fd,26)=mob_id;
WFIFOB(fd,30)=progress; //Message to display
WFIFOB(fd,31)=20;
@@ -8381,7 +8381,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
//Asked name of invisible player, this shouldn't be possible!
//Possible bot? Thanks to veider and qspirit
//FIXME: Still isn't perfected as clients keep asking for this on legitimate situations.
- unsigned char gm_msg[256];
+ char gm_msg[256];
sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target.", sd->status.name, sd->status.account_id);
ShowWarning(gm_msg);
// information is sended to all online GM
@@ -8549,7 +8549,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd)
if(pc_isGM(sd) < get_atcommand_level(AtCommand_MapMove))
return;
- map_name = RFIFOP(fd,2);
+ map_name = (char*)RFIFOP(fd,2);
map_name[MAP_NAME_LENGTH_EXT-1]='\0';
sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
atcommand_rura(fd, sd, "@rura", output);
@@ -8960,7 +8960,7 @@ void clif_parse_GMmessage(int fd, struct map_session_data *sd)
return;
size = RFIFOW(fd,2)-4;
- mes = RFIFOP(fd,4);
+ mes = (char*)RFIFOP(fd,4);
mes_len_check(mes, size, CHAT_SIZE);
intif_GMmessage(mes, size, 0);
@@ -9926,7 +9926,7 @@ void clif_parse_LGMmessage(int fd, struct map_session_data *sd)
return;
len = RFIFOW(fd,2) - 4;
- mes = RFIFOP(fd,4);
+ mes = (char*)RFIFOP(fd,4);
mes_len_check(mes, len, CHAT_SIZE);
WBUFW(buf,0) = 0x9a;
@@ -10149,7 +10149,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data *sd)
int len;
len = RFIFOW(fd,2) - 4;
- mes = RFIFOP(fd,4);
+ mes = (char*)RFIFOP(fd,4);
mes_len_check(mes, len, CHAT_SIZE);
if (is_charcommand(fd, sd, mes) != CharCommand_None ||
@@ -10333,7 +10333,7 @@ void clif_parse_GuildChangeNotice(int fd,struct map_session_data *sd)
}
// compensate for the client's adding of an extra space at the end of the message
if (RFIFOB(fd, 66) == '|') {
- memset(RFIFOP(fd, 66 + strnlen(RFIFOP(fd, 66), 120)-1), 0x00, 1); // delete extra space at the end
+ memset(RFIFOP(fd, 66 + strnlen((char*)RFIFOP(fd, 66), 120)-1), 0x00, 1); // delete extra space at the end
}
guild_change_notice(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6),(char*)RFIFOP(fd,66));
@@ -10406,7 +10406,7 @@ void clif_parse_GuildMessage(int fd,struct map_session_data *sd)
int len;
len = RFIFOW(fd,2) - 4;
- mes = RFIFOP(fd,4);
+ mes = (char*)RFIFOP(fd,4);
mes_len_check(mes, len, CHAT_SIZE);
if (is_charcommand(fd, sd, mes) != CharCommand_None ||
@@ -10611,7 +10611,7 @@ void clif_parse_Shift(int fd, struct map_session_data *sd)
if (pc_isGM(sd) < (lv=get_atcommand_level(AtCommand_JumpTo)))
return;
- player_name = RFIFOP(fd,2);
+ player_name = (char*)RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
atcommand_jumpto(fd, sd, "@jumpto", player_name); // as @jumpto
if(log_config.gm && lv >= log_config.gm) {
@@ -10636,7 +10636,7 @@ void clif_parse_Recall(int fd, struct map_session_data *sd)
if (pc_isGM(sd) < (lv=get_atcommand_level(AtCommand_Recall)))
return;
- player_name = RFIFOP(fd,2);
+ player_name = (char*)RFIFOP(fd,2);
player_name[NAME_LENGTH-1] = '\0';
atcommand_recall(fd, sd, "@recall", player_name); // as @recall
if(log_config.gm && lv >= log_config.gm) {
@@ -10659,7 +10659,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
if (battle_config.atc_gmonly && !pc_isGM(sd))
return;
- monster_item_name = RFIFOP(fd,2);
+ monster_item_name = (char*)RFIFOP(fd,2);
monster_item_name[NAME_LENGTH-1] = '\0';
if (mobdb_searchname(monster_item_name)) {
@@ -11421,7 +11421,7 @@ void clif_parse_AdoptRequest(int fd,struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_ChangeHomunculusName(int fd, struct map_session_data *sd)
{
- merc_hom_change_name(sd,RFIFOP(fd,2));
+ merc_hom_change_name(sd,(char*)RFIFOP(fd,2));
}
void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
diff --git a/src/map/intif.c b/src/map/intif.c
index 92c234c56..8e66c0e1e 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -293,8 +293,8 @@ int intif_saveregistry(struct map_session_data *sd, int type)
int i,p;
for (p=13,i = 0; i < count; i++) {
if (reg[i].str[0] && reg[i].value != 0) {
- p+= sprintf(WFIFOP(inter_fd,p), "%s", reg[i].str)+1; //We add 1 to consider the '\0' in place.
- p+= sprintf(WFIFOP(inter_fd,p), "%s", reg[i].value)+1;
+ 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;
@@ -971,10 +971,10 @@ int intif_parse_Registers(int fd)
return 0;
}
for(j=0,p=13;j<max && p<RFIFOW(fd,2);j++){
- sscanf(RFIFOP(fd,p), "%31c%n", reg[j].str,&len);
+ sscanf((char*)RFIFOP(fd,p), "%31c%n", reg[j].str,&len);
reg[j].str[len]='\0';
p += len+1; //+1 to skip the '\0' between strings.
- sscanf(RFIFOP(fd,p), "%255c%n", reg[j].value,&len);
+ sscanf((char*)RFIFOP(fd,p), "%255c%n", reg[j].value,&len);
reg[j].value[len]='\0';
p += len+1;
}
@@ -1399,10 +1399,10 @@ int intif_parse_ChangeNameOk(int fd)
case 0: //Players [NOT SUPPORTED YET]
break;
case 1: //Pets
- pet_change_name_ack(sd, RFIFOP(fd,12), RFIFOB(fd,11));
+ pet_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
break;
case 2: //Hom
- merc_hom_change_name_ack(sd, RFIFOP(fd,12), RFIFOB(fd,11));
+ merc_hom_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
break;
}
return 0;
diff --git a/src/map/irc.c b/src/map/irc.c
index c9ca87202..de9edd87b 100644
--- a/src/map/irc.c
+++ b/src/map/irc.c
@@ -39,7 +39,7 @@ char irc_channel[32]="";
char irc_channel_pass[32]="";
char irc_trade_channel[32]="";
-unsigned char irc_ip_str[128]="";
+char irc_ip_str[128]="";
unsigned long irc_ip=0;
unsigned short irc_port = 6667;
int irc_fd=0;
diff --git a/src/map/npc.c b/src/map/npc.c
index eca640b1f..03ef54007 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -34,9 +34,9 @@
// linked list of npc source files
struct npc_src_list {
struct npc_src_list* next;
- char name[4];// dynamic array, the structure is allocated with extra bytes (string length)
+ char name[4]; // dynamic array, the structure is allocated with extra bytes (string length)
};
-static struct npc_src_list* npc_src_files=NULL;
+static struct npc_src_list* npc_src_files = NULL;
static int npc_id=START_NPC_NUM;
static int npc_warp=0;
@@ -67,7 +67,7 @@ static struct script_event_s
struct npc_data *nd;
struct event_data *event[UCHAR_MAX];
const char *event_name[UCHAR_MAX];
- unsigned char event_count;
+ uint8 event_count;
} script_event[NPCE_MAX];
struct view_data* npc_get_viewdata(int class_)
@@ -83,7 +83,7 @@ struct view_data* npc_get_viewdata(int class_)
* npc_enable
* npc_enable_sub 有効時にOnTouchイベントを実行
*------------------------------------------*/
-int npc_enable_sub( struct block_list *bl, va_list ap )
+int npc_enable_sub(struct block_list *bl, va_list ap)
{
struct map_session_data *sd;
struct npc_data *nd;
@@ -108,9 +108,9 @@ int npc_enable_sub( struct block_list *bl, va_list ap )
//aFree(name);
return 0;
}
-int npc_enable(const char *name,int flag)
+int npc_enable(const char* name, int flag)
{
- struct npc_data *nd= strdb_get(npcname_db,(unsigned char*)name);
+ struct npc_data* nd = strdb_get(npcname_db, name);
if (nd==NULL)
return 0;
@@ -141,15 +141,15 @@ int npc_enable(const char *name,int flag)
/*==========================================
* NPCを名前で探す
*------------------------------------------*/
-struct npc_data* npc_name2id(const char *name)
+struct npc_data* npc_name2id(const char* name)
{
- return (struct npc_data *) strdb_get(npcname_db,(unsigned char*)name);
+ return (struct npc_data *) strdb_get(npcname_db, name);
}
/*==========================================
* イベントキューのイベント処理
*------------------------------------------*/
-int npc_event_dequeue(struct map_session_data *sd)
+int npc_event_dequeue(struct map_session_data* sd)
{
nullpo_retr(0, sd);
@@ -185,12 +185,12 @@ int npc_event_dequeue(struct map_session_data *sd)
/*==========================================
* イベントの遅延実行
*------------------------------------------*/
-int npc_event_timer(int tid,unsigned int tick,int id,int data)
+int npc_event_timer(int tid, unsigned int tick, int id, int data)
{
- unsigned char *eventname = (unsigned char *)data;
- struct event_data *ev = strdb_get(ev_db,eventname);
- struct npc_data *nd;
- struct map_session_data *sd=map_id2sd(id);
+ char* eventname = (char *)data;
+ struct event_data* ev = strdb_get(ev_db,eventname);
+ struct npc_data* nd;
+ struct map_session_data* sd = map_id2sd(id);
size_t i;
if((ev==NULL || (nd=ev->nd)==NULL))
@@ -215,9 +215,9 @@ int npc_event_timer(int tid,unsigned int tick,int id,int data)
return 0;
}
-int npc_timer_event(const unsigned char *eventname) // Added by RoVeRT
+int npc_timer_event(const char* eventname) // Added by RoVeRT
{
- struct event_data *ev=strdb_get(ev_db,(unsigned char*)eventname);
+ struct event_data* ev = strdb_get(ev_db, eventname);
struct npc_data *nd;
// int xs,ys;
@@ -276,20 +276,20 @@ int npc_timer(int tid,unsigned int tick,int id,int data) // Added by RoVeRT
}*/
/*==========================================
- * イベント用ラベルのエクスポート
+ * exports a npc event label
* npc_parse_script->strdb_foreachから呼ばれる
*------------------------------------------*/
-int npc_event_export(char *lname,void *data,va_list ap)
+int npc_event_export(char* lname, void* data, va_list ap)
{
- int pos=(int)data;
- struct npc_data *nd=va_arg(ap,struct npc_data *);
+ int pos = (int)data;
+ struct npc_data* nd = va_arg(ap, struct npc_data *);
if ((lname[0]=='O' || lname[0]=='o')&&(lname[1]=='N' || lname[1]=='n')) {
struct event_data *ev;
- unsigned char buf[51];
- char *p=strchr(lname,':');
+ char buf[51];
+ char* p = strchr(lname, ':');
// エクスポートされる
- ev=(struct event_data *) aMalloc(sizeof(struct event_data));
+ ev = (struct event_data *) aMalloc(sizeof(struct event_data));
if (ev==NULL) {
ShowFatalError("npc_event_export: out of memory !\n");
exit(1);
@@ -297,35 +297,35 @@ int npc_event_export(char *lname,void *data,va_list ap)
ShowFatalError("npc_event_export: label name error !\n");
exit(1);
}else{
- ev->nd=nd;
- ev->pos=pos;
- *p='\0';
- sprintf(buf,"%s::%s",nd->exname,lname);
- *p=':';
- strdb_put(ev_db,buf,ev);
+ ev->nd = nd;
+ ev->pos = pos;
+ *p = '\0';
+ sprintf(buf, "%s::%s", nd->exname, lname);
+ *p = ':';
+ strdb_put(ev_db, buf, ev);
}
}
return 0;
}
-int npc_event_sub(struct map_session_data *, struct event_data *, const unsigned char *); //[Lance]
+int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char* eventname); //[Lance]
/*==========================================
* 全てのNPCのOn*イベント実行
*------------------------------------------*/
-int npc_event_doall_sub(DBKey key,void *data,va_list ap)
+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* p = key.str;
+ struct event_data* ev;
+ int* c;
int rid;
- unsigned char *name;
+ char* name;
- ev=(struct event_data *)data;
- c=va_arg(ap,int *);
- name=va_arg(ap,unsigned char *);
- rid=va_arg(ap, int);
+ ev = (struct event_data *)data;
+ c = va_arg(ap, int *);
+ name = va_arg(ap,char *);
+ rid = va_arg(ap, int);
- if( (p=strchr(p,':')) && p && strcmpi(name,p)==0 ){
+ if( (p=strchr(p, ':')) && p && strcmpi(name, p)==0 ) {
if(rid)
npc_event_sub(((struct map_session_data *)map_id2bl(rid)),ev,key.str);
else
@@ -335,50 +335,50 @@ int npc_event_doall_sub(DBKey key,void *data,va_list ap)
return 0;
}
-int npc_event_doall(const unsigned char *name)
+int npc_event_doall(const char* name)
{
- int c=0;
- unsigned char buf[64]="::";
+ int c = 0;
+ char buf[64] = "::";
- strncpy(buf+2,name,62);
+ 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 unsigned char *name, int rid)
+int npc_event_doall_id(const char* name, int rid)
{
- int c=0;
- unsigned char buf[64]="::";
+ int c = 0;
+ char buf[64] = "::";
- strncpy(buf+2,name,62);
+ 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)
+int npc_event_do_sub(DBKey key, void* data, va_list ap)
{
- const char *p = key.str;
- struct event_data *ev;
- int *c;
- const unsigned char *name;
+ const char* p = key.str;
+ struct event_data* ev;
+ int* c;
+ const char* name;
- nullpo_retr(0, ev=(struct event_data *)data);
+ nullpo_retr(0, ev = (struct event_data *)data);
nullpo_retr(0, ap);
- nullpo_retr(0, c=va_arg(ap,int *));
+ nullpo_retr(0, c = va_arg(ap, int *));
- name=va_arg(ap,const unsigned 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;
}
-int npc_event_do(const unsigned char *name)
+int npc_event_do(const char* name)
{
- int c=0;
+ int c = 0;
- if (*name==':' && name[1]==':') {
+ if (*name == ':' && name[1] == ':') {
return npc_event_doall(name+2);
}
@@ -389,7 +389,7 @@ int npc_event_do(const unsigned char *name)
/*==========================================
* 時計イベント実行
*------------------------------------------*/
-int npc_event_do_clock(int tid,unsigned int tick,int id,int data)
+int npc_event_do_clock(int tid, unsigned int tick, int id, int data)
{
time_t timer;
struct tm *t;
@@ -446,21 +446,21 @@ int npc_event_do_oninit(void)
/*==========================================
* OnTimer NPC event - by RoVeRT
*------------------------------------------*/
-int npc_addeventtimer(struct npc_data *nd,int tick,const char *name)
+int npc_addeventtimer(struct npc_data* nd, int tick, const char* name)
{
int i;
- unsigned char *evname;
+ char* evname;
for(i=0;i<MAX_EVENTTIMER;i++)
if( nd->eventtimer[i]==-1 )
break;
if(i<MAX_EVENTTIMER){
- if (!strdb_get(ev_db,(unsigned char*)name)) {
+ if (!strdb_get(ev_db,name)) {
if (battle_config.error_log)
ShowError("npc_addeventimer: Event %s does not exists.\n", name);
return 1; //Event does not exists!
}
- evname =(unsigned char *) aMallocA(NAME_LENGTH*sizeof(char));
+ evname = (char *)aMallocA(NAME_LENGTH*sizeof(char));
if(evname==NULL){
ShowFatalError("npc_addeventtimer: out of memory !\n");exit(1);
}
@@ -474,21 +474,20 @@ int npc_addeventtimer(struct npc_data *nd,int tick,const char *name)
return 0;
}
-int npc_deleventtimer(struct npc_data *nd,const unsigned char *name)
+int npc_deleventtimer(struct npc_data* nd, const char* name)
{
int i;
for(i=0;i<MAX_EVENTTIMER;i++)
- if( nd->eventtimer[i]!=-1 && strcmp(
- (unsigned char *)(get_timer(nd->eventtimer[i])->data), name)==0 ){
- delete_timer(nd->eventtimer[i],npc_event_timer);
- nd->eventtimer[i]=-1;
- break;
+ if( nd->eventtimer[i]!=-1 && strcmp((char *)(get_timer(nd->eventtimer[i])->data), name)==0 ){
+ delete_timer(nd->eventtimer[i],npc_event_timer);
+ nd->eventtimer[i]=-1;
+ break;
}
return 0;
}
-int npc_cleareventtimer(struct npc_data *nd)
+int npc_cleareventtimer(struct npc_data* nd)
{
int i;
for(i=0;i<MAX_EVENTTIMER;i++)
@@ -500,7 +499,7 @@ int npc_cleareventtimer(struct npc_data *nd)
return 0;
}
-int npc_do_ontimer_sub(DBKey key,void *data,va_list ap)
+int npc_do_ontimer_sub(DBKey key, void* data, va_list ap)
{
const char *p = key.str;
struct event_data *ev = (struct event_data *)data;
@@ -535,7 +534,7 @@ int npc_do_ontimer(int npc_id, int option)
* タイマーイベント用ラベルの取り込み
* npc_parse_script->strdb_foreachから呼ばれる
*------------------------------------------*/
-int npc_timerevent_import(char *lname,void *data,va_list ap)
+int npc_timerevent_import(char* lname, void* data, va_list ap)
{
int pos=(int)data;
struct npc_data *nd=va_arg(ap,struct npc_data *);
@@ -574,7 +573,7 @@ struct timer_event_data {
/*==========================================
* タイマーイベント実行
*------------------------------------------*/
-int npc_timerevent(int tid,unsigned int tick,int id,int data)
+int npc_timerevent(int tid, unsigned int tick, int id, int data)
{
int next,t,old_rid,old_timer;
unsigned int old_tick;
@@ -634,7 +633,7 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data)
/*==========================================
* タイマーイベント開始
*------------------------------------------*/
-int npc_timerevent_start(struct npc_data *nd, int rid)
+int npc_timerevent_start(struct npc_data* nd, int rid)
{
int j,n, next;
struct map_session_data *sd=NULL; //Player to whom script is attached.
@@ -690,7 +689,7 @@ int npc_timerevent_start(struct npc_data *nd, int rid)
/*==========================================
* タイマーイベント終了
*------------------------------------------*/
-int npc_timerevent_stop(struct npc_data *nd)
+int npc_timerevent_stop(struct npc_data* nd)
{
struct map_session_data *sd =NULL;
struct TimerData *td = NULL;
@@ -722,7 +721,7 @@ int npc_timerevent_stop(struct npc_data *nd)
/*==========================================
* Aborts a running npc timer that is attached to a player.
*------------------------------------------*/
-void npc_timerevent_quit(struct map_session_data *sd)
+void npc_timerevent_quit(struct map_session_data* sd)
{
struct TimerData *td;
struct npc_data* nd;
@@ -743,7 +742,7 @@ void npc_timerevent_quit(struct map_session_data *sd)
char buf[sizeof(nd->exname)+sizeof("::OnTimerQuit")+1];
struct event_data *ev;
sprintf(buf,"%s::OnTimerQuit",nd->exname);
- ev = strdb_get(ev_db,(unsigned char*)buf);
+ ev = strdb_get(ev_db, buf);
if(ev && ev->nd != nd) {
ShowWarning("npc_timerevent_quit: Unable to execute \"OnTimerQuit\", two NPCs have the same event name [%s]!\n",buf);
ev = NULL;
@@ -776,7 +775,7 @@ void npc_timerevent_quit(struct map_session_data *sd)
/*==========================================
* タイマー値の所得
*------------------------------------------*/
-int npc_gettimerevent_tick(struct npc_data *nd)
+int npc_gettimerevent_tick(struct npc_data* nd)
{
int tick;
nullpo_retr(0, nd);
@@ -789,7 +788,7 @@ int npc_gettimerevent_tick(struct npc_data *nd)
/*==========================================
* タイマー値の設定
*------------------------------------------*/
-int npc_settimerevent_tick(struct npc_data *nd,int newtimer)
+int npc_settimerevent_tick(struct npc_data* nd, int newtimer)
{
int flag;
struct map_session_data *sd=NULL;
@@ -815,7 +814,7 @@ int npc_settimerevent_tick(struct npc_data *nd,int newtimer)
return 0;
}
-int npc_event_sub(struct map_session_data *sd, struct event_data *ev, const unsigned char *eventname)
+int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char* eventname)
{
if ( sd->npc_id!=0) {
//Enqueue the event trigger.
@@ -841,12 +840,12 @@ int npc_event_sub(struct map_session_data *sd, struct event_data *ev, const unsi
/*==========================================
* イベント型のNPC処理
*------------------------------------------*/
-int npc_event (struct map_session_data *sd, const unsigned char *eventname, int mob_kill)
+int npc_event(struct map_session_data* sd, const char* eventname, int mob_kill)
{
- struct event_data *ev=strdb_get(ev_db,(unsigned char*)eventname);
+ struct event_data* ev = strdb_get(ev_db, eventname);
struct npc_data *nd;
int xs,ys;
- unsigned char mobevent[100];
+ char mobevent[100];
if (sd == NULL) {
nullpo_info(NLP_MARK);
@@ -897,7 +896,7 @@ int npc_command_sub(DBKey key,void *data,va_list ap)
struct event_data *ev=(struct event_data *)data;
const char* npcname = va_arg(ap, const char*);
const char* command = va_arg(ap, const char*);
- unsigned char temp[100];
+ char temp[100];
if(strcmp(ev->nd->name,npcname)==0 && (p=strchr(p,':')) && strnicmp("::OnCommand",p,10)==0 ){
sscanf(&p[11],"%s",temp);
@@ -918,7 +917,7 @@ int npc_command(struct map_session_data* sd, const char* npcname, const char* co
/*==========================================
* 接触型のNPC処理
*------------------------------------------*/
-int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y)
+int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y)
{
int i,f=1;
int xs,ys;
@@ -987,7 +986,7 @@ int npc_touch_areanpc(struct map_session_data *sd,int m,int x,int y)
return 0;
}
-int npc_touch_areanpc2(struct block_list *bl)
+int npc_touch_areanpc2(struct block_list* bl)
{
int i,m=bl->m;
int xs,ys;
@@ -1023,7 +1022,7 @@ int npc_touch_areanpc2(struct block_list *bl)
//Flag determines the type of object to check for:
//&1: NPC Warps
//&2: NPCs with on-touch events.
-int npc_check_areanpc(int flag,int m,int x,int y,int range)
+int npc_check_areanpc(int flag, int m, int x, int y, int range)
{
int i;
int x0,y0,x1,y1;
@@ -1083,7 +1082,7 @@ int npc_check_areanpc(int flag,int m,int x,int y,int range)
/*==========================================
* 近くかどうかの判定
*------------------------------------------*/
-int npc_checknear2(struct map_session_data *sd,struct block_list *bl)
+int npc_checknear2(struct map_session_data* sd, struct block_list* bl)
{
nullpo_retr(1, sd);
if(bl == NULL) return 1;
@@ -1102,7 +1101,7 @@ int npc_checknear2(struct map_session_data *sd,struct block_list *bl)
return 0;
}
-TBL_NPC *npc_checknear(struct map_session_data *sd,struct block_list *bl)
+TBL_NPC* npc_checknear(struct map_session_data* sd, struct block_list* bl)
{
struct npc_data *nd;
@@ -1128,15 +1127,15 @@ TBL_NPC *npc_checknear(struct map_session_data *sd,struct block_list *bl)
/*==========================================
* NPCのオープンチャット発言
*------------------------------------------*/
-int npc_globalmessage(const char *name,const char *mes)
+int npc_globalmessage(const char* name, const char* mes)
{
- struct npc_data *nd=(struct npc_data *) strdb_get(npcname_db,(unsigned char*)name);
+ struct npc_data* nd = (struct npc_data *) strdb_get(npcname_db, name);
char temp[100];
if (!nd)
return 0;
- snprintf(temp, sizeof temp ,"%s : %s",name,mes);
+ snprintf(temp, sizeof(temp), "%s : %s", name, mes);
clif_GlobalMessage(&nd->bl,temp);
return 0;
@@ -1145,7 +1144,7 @@ int npc_globalmessage(const char *name,const char *mes)
/*==========================================
* クリック時のNPC処理
*------------------------------------------*/
-int npc_click(struct map_session_data *sd,struct npc_data *nd)
+int npc_click(struct map_session_data* sd, struct npc_data* nd)
{
nullpo_retr(1, sd);
@@ -1177,7 +1176,7 @@ int npc_click(struct map_session_data *sd,struct npc_data *nd)
/*==========================================
*
*------------------------------------------*/
-int npc_scriptcont(struct map_session_data *sd,int id)
+int npc_scriptcont(struct map_session_data* sd, int id)
{
nullpo_retr(1, sd);
@@ -1204,7 +1203,7 @@ int npc_scriptcont(struct map_session_data *sd,int id)
/*==========================================
*
*------------------------------------------*/
-int npc_buysellsel(struct map_session_data *sd,int id,int type)
+int npc_buysellsel(struct map_session_data* sd, int id, int type)
{
struct npc_data *nd;
@@ -1233,9 +1232,9 @@ int npc_buysellsel(struct map_session_data *sd,int id,int type)
}
//npc_buylist for script-controlled shops.
-static int npc_buylist_sub(struct map_session_data *sd, int n, unsigned short *item_list, struct npc_data *nd)
+static int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd)
{
- unsigned char npc_ev[51];
+ char npc_ev[51];
int i;
int regkey = add_str("@bought_nameid");
int regkey2 = add_str("@bought_quantity");
@@ -1251,7 +1250,7 @@ static int npc_buylist_sub(struct map_session_data *sd, int n, unsigned short *i
/*==========================================
*
*------------------------------------------*/
-int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
+int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
{
struct npc_data *nd;
double z;
@@ -1348,7 +1347,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
/*==========================================
*
*------------------------------------------*/
-int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list)
+int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
{
double z;
int i,skill,itemamount=0;
@@ -1417,7 +1416,7 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list)
}
if(nd) {
- unsigned char npc_ev[51];
+ char npc_ev[51];
sprintf(npc_ev, "%s::OnSellItem", nd->exname);
npc_event(sd, npc_ev, 0);
}
@@ -1433,7 +1432,7 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list)
return 0;
}
-int npc_remove_map(struct npc_data *nd)
+int npc_remove_map(struct npc_data* nd)
{
int m,i;
nullpo_retr(1, nd);
@@ -1473,10 +1472,10 @@ int npc_remove_map(struct npc_data *nd)
return 0;
}
-static int npc_unload_ev(DBKey key,void *data,va_list ap)
+static int npc_unload_ev(DBKey key, void* data, va_list ap)
{
- struct event_data *ev=(struct event_data *)data;
- unsigned char *npcname=va_arg(ap,unsigned char *);
+ struct event_data* ev = (struct event_data *)data;
+ char* npcname = va_arg(ap, char *);
if(strcmp(ev->nd->exname,npcname)==0){
db_remove(ev_db, key);
@@ -1485,7 +1484,7 @@ static int npc_unload_ev(DBKey key,void *data,va_list ap)
return 0;
}
-static int npc_unload_dup_sub(DBKey key,void * data,va_list ap)
+static int npc_unload_dup_sub(DBKey key, void* data, va_list ap)
{
struct npc_data *nd = (struct npc_data *)data;
int src_id;
@@ -1498,13 +1497,14 @@ static int npc_unload_dup_sub(DBKey key,void * data,va_list ap)
npc_unload(nd);
return 0;
}
+
//Removes all npcs that are duplicates of the passed one. [Skotlex]
-void npc_unload_duplicates (struct npc_data *nd)
+void npc_unload_duplicates(struct npc_data* nd)
{
map_foreachiddb(npc_unload_dup_sub,nd->bl.id);
}
-int npc_unload(struct npc_data *nd)
+int npc_unload(struct npc_data* nd)
{
nullpo_ret(nd);
@@ -1547,10 +1547,6 @@ int npc_unload(struct npc_data *nd)
}
//
-// 初期化関係
-//
-
-//
// NPC Source Files
//
@@ -1631,7 +1627,7 @@ void npc_delsrcfile(const char* name)
/*==========================================
* warp行解析
*------------------------------------------*/
-int npc_parse_warp (char *w1,char *w2,char *w3,char *w4)
+int npc_parse_warp(char* w1, char* w2, char* w3, char* w4)
{
int x, y, xs, ys, to_x, to_y, m;
int i;
@@ -1693,7 +1689,7 @@ int npc_parse_warp (char *w1,char *w2,char *w3,char *w4)
/*==========================================
* shop行解析
*------------------------------------------*/
-static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
+static int npc_parse_shop(char* w1, char* w2, char* w3, char* w4)
{
#define MAX_SHOPITEM 100
char *p;
@@ -1791,7 +1787,7 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
/*==========================================
* NPCのラベルデータコンバート
*------------------------------------------*/
-int npc_convertlabel_db (DBKey key, void *data, va_list ap)
+int npc_convertlabel_db(DBKey key, void* data, va_list ap)
{
const char *lname = (const char*)key.str;
int pos = (int)data;
@@ -1833,26 +1829,25 @@ int npc_convertlabel_db (DBKey key, void *data, va_list ap)
}
/*==========================================
- * script行解析
+ * parses a script line
*------------------------------------------*/
-static void npc_parse_script_line(unsigned char *p,int *curly_count,int line)
+static void npc_parse_script_line(char* p, int* curly_count, int line)
{
- int i = strlen((char *)p),j;
+ int i = strlen(p),j;
int string_flag = 0;
static int comment_flag = 0;
- for(j = 0; j < i ; j++) {
+ for(j = 0; j < i; j++)
+ {
if(comment_flag) {
- if(p[j] == '*' && p[j+1] == '/') {
- // マルチラインコメント終了
- j++;
+ if(p[j] == '*' && p[j+1] == '/') { // end of multiline comment
(*curly_count)--;
comment_flag = 0;
+ j++;
}
} else if(string_flag) {
if(p[j] == '"') {
string_flag = 0;
- } else if(p[j] == '\\' && p[j-1]<=0x7e) {
- // エスケープ
+ } else if(p[j] == '\\' && (unsigned char)(p[j-1])<=0x7e) { // escape
j++;
}
} else {
@@ -1866,57 +1861,55 @@ static void npc_parse_script_line(unsigned char *p,int *curly_count,int line)
}
} else if(p[j] == '{') {
(*curly_count)++;
- } else if(p[j] == '/' && p[j+1] == '/') {
- // コメント
+ } else if(p[j] == '/' && p[j+1] == '/') { // comment
break;
- } else if(p[j] == '/' && p[j+1] == '*') {
- // マルチラインコメント
- j++;
+ } else if(p[j] == '/' && p[j+1] == '*') { // multiline comment start
(*curly_count)++;
comment_flag = 1;
+ j++;
}
}
}
if(string_flag) {
- printf("Missing '\"' at file %s line %d\n",current_file,line);
+ printf("Missing '\"' at file %s line %d\n", current_file, line);
exit(1);
}
}
// Like npc_parse_script, except it's sole use is to skip the contents of a script. [Skotlex]
-static int npc_skip_script (char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines)
+static int npc_skip_script(char* w1, char* w2, char* w3, char* w4, char* first_line, FILE* fp, int* lines)
{
- unsigned char *srcbuf = NULL;
+ char *srcbuf = NULL;
int srcsize = 65536;
int startline = 0;
- unsigned char line[1024];
+ char line[1024];
int curly_count = 0;
- srcbuf = (unsigned char *)aMallocA(srcsize*sizeof(char));
+ srcbuf = (char *)aMallocA(srcsize*sizeof(char));
if (strchr(first_line, '{')) {
- strcpy((char *)srcbuf, strchr(first_line, '{'));
+ strcpy(srcbuf, strchr(first_line, '{'));
startline = *lines;
} else
srcbuf[0] = 0;
npc_parse_script_line(srcbuf,&curly_count,*lines);
while (curly_count > 0) {
- fgets ((char *)line, sizeof(line), fp);
+ fgets(line, sizeof(line), fp);
(*lines)++;
npc_parse_script_line(line,&curly_count,*lines);
if (feof(fp))
break;
- if (strlen((char *)srcbuf) + strlen((char *)line) + 1 >= (size_t)srcsize) {
+ if (strlen(srcbuf) + strlen(line) + 1 >= (size_t)srcsize) {
srcsize += 65536;
- srcbuf = (unsigned char *)aRealloc(srcbuf, srcsize);
+ srcbuf = (char *)aRealloc(srcbuf, srcsize);
memset(srcbuf + srcsize - 65536, '\0', 65536);
}
if (srcbuf[0] != '{') {
- if (strchr((char *) line,'{')) {
- strcpy((char *) srcbuf, strchr((const char *) line, '{'));
+ if (strchr(line, '{')) {
+ strcpy(srcbuf, strchr(line, '{'));
startline = *lines;
}
} else
- strcat((char *) srcbuf, (const char *) line);
+ strcat(srcbuf, line);
}
if(curly_count > 0)
ShowError("Missing right curly at file %s, line %d\n",current_file, *lines);
@@ -1924,15 +1917,15 @@ static int npc_skip_script (char *w1,char *w2,char *w3,char *w4,char *first_line
return 0;
}
-static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines,const char* file)
+static int npc_parse_script(char* w1, char* w2, char* w3, char* w4, char* first_line, FILE* fp, int* lines, const char* file)
{
int x, y, dir = 0, m, xs = 0, ys = 0, class_ = 0; // [Valaris] thanks to fov
char mapname[MAP_NAME_LENGTH_EXT];
- unsigned char *srcbuf = NULL;
+ char *srcbuf = NULL;
struct script_code *script;
int srcsize = 65536;
int startline = 0;
- unsigned char line[1024];
+ char line[1024];
int i;
struct npc_data *nd, *dnd;
DB label_db;
@@ -1956,34 +1949,34 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
if (strcmp(w2, "script") == 0){
// parsing script with curly
int curly_count = 0;
- srcbuf = (unsigned char *)aMallocA(srcsize*sizeof(char));
+ srcbuf = (char *)aMallocA(srcsize*sizeof(char));
if (strchr(first_line, '{')) {
- strcpy((char *)srcbuf, strchr(first_line, '{'));
+ strcpy(srcbuf, strchr(first_line, '{'));
startline = *lines;
} else
srcbuf[0] = 0;
npc_parse_script_line(srcbuf,&curly_count,*lines);
while (curly_count > 0) {
- fgets((char *)line, sizeof(line), fp);
+ fgets(line, sizeof(line), fp);
(*lines)++;
npc_parse_script_line(line,&curly_count,*lines);
if (feof(fp))
break;
- if (strlen((char *)srcbuf) + strlen((char *)line) + 1 >= (size_t)srcsize) {
+ if (strlen(srcbuf) + strlen(line) + 1 >= (size_t)srcsize) {
srcsize += 65536;
- srcbuf = (unsigned char *)aRealloc(srcbuf, srcsize);
+ srcbuf = (char *)aRealloc(srcbuf, srcsize);
memset(srcbuf + srcsize - 65536, '\0', 65536);
}
if (srcbuf[0] != '{') {
- if (strchr((char *) line,'{')) {
- strcpy((char *) srcbuf, strchr((const char *) line, '{'));
+ if (strchr(line, '{')) {
+ strcpy(srcbuf, strchr(line, '{'));
startline = *lines;
}
} else
- strcat((char *) srcbuf, (const char *) line);
+ strcat(srcbuf, line);
}
if(curly_count > 0) {
- ShowError("Missing right curly at file %s, line %d\n",file, *lines);
+ ShowError("Missing right curly at file %s, line %d\n", file, *lines);
script = NULL;
} else {
// printf("Ok line %d\n",*lines);
@@ -2112,28 +2105,21 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
// イベント用ラベルデータのエクスポート
for (i = 0; i < nd->u.scr.label_list_num; i++)
{
- char *lname = nd->u.scr.label_list[i].name;
+ char* lname = nd->u.scr.label_list[i].name;
int pos = nd->u.scr.label_list[i].pos;
- if ((lname[0] == 'O' || lname[0] == 'o') && (lname[1] == 'N' || lname[1] == 'n')) {
- // this check is useless here because the buffer is only 24 chars
- // and already overwritten if this is here is reached
- // I leave the check anyway but place it correctly to npc_convertlabel_db
- if (strlen(lname)>NAME_LENGTH-1) {
- ShowError("npc_parse_script: label name longer than %d chars! '%s' (%s)\n", NAME_LENGTH-1, lname, file);
- exit(1);
- } else {
- struct event_data *ev;
- unsigned char buf[50+1]; // 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
- sprintf(buf,"%s::%s",nd->exname,lname);
-
- // generate the data and insert it
- ev=(struct event_data *)aMalloc(sizeof(struct event_data));
- ev->nd=nd;
- ev->pos=pos;
- if (strdb_put(ev_db,buf,ev) != NULL) //There was already another event of the same name?
- ShowWarning("npc_parse_script : duplicate event %s (%s)\n",buf, file);
- }
+ if ((lname[0] == 'O' || lname[0] == 'o') && (lname[1] == 'N' || lname[1] == 'n'))
+ {
+ struct event_data* ev;
+ char buf[50+1]; // 24 for npc name + 24 for label + 2 for a "::" and 1 for EOS
+ snprintf(buf, sizeof(buf), "%s::%s", nd->exname, lname);
+
+ // generate the data and insert it
+ ev = (struct event_data *)aMalloc(sizeof(struct event_data));
+ ev->nd = nd;
+ ev->pos = pos;
+ if (strdb_put(ev_db, buf, ev) != NULL) //There was already another event of the same name?
+ ShowWarning("npc_parse_script : duplicate event %s (%s)\n", buf, file);
}
}
@@ -2168,7 +2154,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line
return 0;
}
-void npc_setcells(struct npc_data *nd)
+void npc_setcells(struct npc_data* nd)
{
int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys;
int i,j;
@@ -2193,7 +2179,7 @@ void npc_setcells(struct npc_data *nd)
}
}
-int npc_unsetcells_sub(struct block_list *bl, va_list ap)
+int npc_unsetcells_sub(struct block_list* bl, va_list ap)
{
struct npc_data *nd = (struct npc_data*)bl;
int id = va_arg(ap,int);
@@ -2202,7 +2188,7 @@ int npc_unsetcells_sub(struct block_list *bl, va_list ap)
return 1;
}
-void npc_unsetcells(struct npc_data *nd)
+void npc_unsetcells(struct npc_data* nd)
{
int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys;
int i,j, x0, x1, y0, y1;
@@ -2232,7 +2218,7 @@ void npc_unsetcells(struct npc_data *nd)
map_foreachinarea( npc_unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id);
}
-void npc_movenpc(struct npc_data *nd, int x, int y)
+void npc_movenpc(struct npc_data* nd, int x, int y)
{
const int m = nd->bl.m;
if (m < 0 || nd->bl.prev == NULL) return; //Not on a map.
@@ -2251,9 +2237,9 @@ void npc_movenpc(struct npc_data *nd, int x, int y)
/*==========================================
* function行解析
*------------------------------------------*/
-static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *first_line, FILE *fp, int *lines,const char* file)
+static int npc_parse_function(char* w1, char* w2, char* w3, char* w4, char* first_line, FILE* fp, int* lines, const char* file)
{
- unsigned char *srcbuf, *p;
+ char *srcbuf, *p;
struct script_code *script;
struct script_code *oldscript;
int srcsize = 65536;
@@ -2263,7 +2249,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
struct dbt *user_db;
// スクリプトの解析
- srcbuf = (unsigned char *) aMallocA (srcsize*sizeof(char));
+ srcbuf = (char *) aMallocA (srcsize*sizeof(char));
if (strchr(first_line,'{')) {
strcpy(srcbuf, strchr(first_line,'{'));
startline = *lines;
@@ -2318,9 +2304,6 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
// もう使わないのでバッファ解放
aFree(srcbuf);
-
-// printf("function %s => %p\n",p,script);
-
return 0;
}
@@ -2333,7 +2316,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
* index points to the index in the mob_list of the map_data cache.
* -1 indicates that it is not stored on the map.
*------------------------------------------*/
-int npc_parse_mob2 (struct spawn_data *mob, int index)
+int npc_parse_mob2(struct spawn_data* mob, int index)
{
int i;
struct mob_data *md;
@@ -2349,7 +2332,7 @@ int npc_parse_mob2 (struct spawn_data *mob, int index)
return 1;
}
-int npc_parse_mob (char *w1, char *w2, char *w3, char *w4)
+int npc_parse_mob(char* w1, char* w2, char* w3, char* w4)
{
int level, num, class_, mode, x,y,xs,ys;
char mapname[MAP_NAME_LENGTH_EXT];
@@ -2483,7 +2466,7 @@ int npc_parse_mob (char *w1, char *w2, char *w3, char *w4)
/*==========================================
* マップフラグ行の解析
*------------------------------------------*/
-static int npc_parse_mapflag (char *w1, char *w2, char *w3, char *w4)
+static int npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4)
{
int m;
char mapname[MAP_NAME_LENGTH_EXT];
@@ -2736,7 +2719,7 @@ static int npc_parse_mapflag (char *w1, char *w2, char *w3, char *w4)
/*==========================================
* Setting up map cells
*------------------------------------------*/
-static int npc_parse_mapcell (char *w1, char *w2, char *w3, char *w4)
+static int npc_parse_mapcell(char* w1, char* w2, char* w3, char* w4)
{
int m, cell, x, y, x0, y0, x1, y1;
char type[24], mapname[MAP_NAME_LENGTH_EXT];
@@ -2855,7 +2838,8 @@ void npc_parsesrcfile(const char* name)
return;
}
-int npc_script_event(TBL_PC* sd, int type) {
+int npc_script_event(TBL_PC* sd, int type)
+{
int i;
if (type < 0 || type >= NPCE_MAX)
return 0;
@@ -2877,13 +2861,13 @@ int npc_script_event(TBL_PC* sd, int type) {
return 0;
}
-static int npc_read_event_script_sub(DBKey key,void *data,va_list ap)
+static int npc_read_event_script_sub(DBKey key, void* data, va_list ap)
{
- const char *p = key.str;
- unsigned char *name = va_arg(ap,unsigned char *);
- struct event_data **event_buf = va_arg(ap,struct event_data**);
- const char **event_name = va_arg(ap,const char **);
- unsigned char *count = va_arg(ap,char *);;
+ const char* p = key.str;
+ char* name = va_arg(ap, char *);
+ struct event_data** event_buf = va_arg(ap, struct event_data**);
+ const char** event_name = va_arg(ap,const char **);
+ unsigned char *count = va_arg(ap, unsigned char *);
if (*count >= UCHAR_MAX) return 0;
@@ -2947,7 +2931,7 @@ void npc_read_event_script(void)
/*==========================================
*
*------------------------------------------*/
-static int npc_cleanup_sub (struct block_list *bl, va_list ap)
+static int npc_cleanup_sub(struct block_list* bl, va_list ap)
{
nullpo_retr(0, bl);
@@ -2963,12 +2947,12 @@ static int npc_cleanup_sub (struct block_list *bl, va_list ap)
return 0;
}
-static int npc_cleanup_dbsub(DBKey key,void * data,va_list ap)
+static int npc_cleanup_dbsub(DBKey key, void* data, va_list ap)
{
return npc_cleanup_sub((struct block_list*)data, 0);
}
-int npc_reload (void)
+int npc_reload(void)
{
struct npc_src_list *nsl;
int m, i;
@@ -3068,7 +3052,7 @@ int do_final_npc(void)
return 0;
}
-static void npc_debug_warps_sub(struct npc_data *nd)
+static void npc_debug_warps_sub(struct npc_data* nd)
{
int m;
if (nd->bl.type != BL_NPC || nd->bl.subtype != WARP || nd->bl.m < 0)
@@ -3102,7 +3086,7 @@ static void npc_debug_warps(void)
}
/*==========================================
- * npc初期化
+ * npc initialization
*------------------------------------------*/
int do_init_npc(void)
{
@@ -3191,14 +3175,14 @@ int do_init_npc(void)
return 0;
}
// [Lance]
-int npc_changename(const char *name, const char *newname, short look)
+int npc_changename(const char* name, const char* newname, short look)
{
- struct npc_data *nd= (struct npc_data *) strdb_remove(npcname_db,(unsigned char*)name);
- if (nd==NULL)
+ struct npc_data* nd = (struct npc_data *) strdb_remove(npcname_db, name);
+ if (nd == NULL)
return 0;
- npc_enable(name,0);
- strcpy(nd->name,newname);
+ npc_enable(name, 0);
+ strcpy(nd->name, newname);
nd->class_ = look;
- npc_enable(newname,1);
+ npc_enable(newname, 1);
return 0;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index 0ef12de7f..74d49dd3c 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -17,8 +17,8 @@
#define npcdb_checkid(id) ((id >= 46 && id <= 125) || id == 139 || (id >= 700 && id <= MAX_NPC_CLASS) || id == INVISIBLE_CLASS)
#ifdef PCRE_SUPPORT
-void npc_chat_finalize(struct npc_data *nd);
-int mob_chat_sub(struct block_list *bl, va_list ap);
+void npc_chat_finalize(struct npc_data* nd);
+int mob_chat_sub(struct block_list* bl, va_list ap);
#endif
//Script NPC events.
@@ -34,32 +34,32 @@ enum {
NPCE_MAX
};
struct view_data* npc_get_viewdata(int class_);
-int npc_chat_sub(struct block_list *bl, va_list ap);
-int npc_event_dequeue(struct map_session_data *sd);
-int npc_event_timer(int tid,unsigned int tick,int id,int data);
-int npc_event(struct map_session_data *sd, const unsigned char *eventname, int mob_kill);
-int npc_timer_event(const unsigned char *eventname); // Added by RoVeRT
+int npc_chat_sub(struct block_list* bl, va_list ap);
+int npc_event_dequeue(struct map_session_data* sd);
+int npc_event_timer(int tid,unsigned int tick, int id, int data);
+int npc_event(struct map_session_data* sd, const char* eventname, int mob_kill);
+int npc_timer_event(const char* eventname); // Added by RoVeRT
int npc_command(struct map_session_data* sd, const char* npcname, const char* command);
-int npc_touch_areanpc(struct map_session_data *,int,int,int);
-int npc_touch_areanpc2(struct block_list *bl); // [Skotlex]
-int npc_check_areanpc(int flag,int m,int x,int y,int range);
-int npc_click(struct map_session_data *sd,struct npc_data *nd);
-int npc_scriptcont(struct map_session_data *,int);
-TBL_NPC *npc_checknear(struct map_session_data *sd,struct block_list *bl);
-int npc_checknear2(struct map_session_data *sd,struct block_list *bl);
-int npc_buysellsel(struct map_session_data *,int,int);
-int npc_buylist(struct map_session_data *,int,unsigned short *);
-int npc_selllist(struct map_session_data *,int,unsigned short *);
-int npc_parse_mob(char *w1,char *w2,char *w3,char *w4);
-int npc_parse_mob2 (struct spawn_data*, int index); // [Wizputer]
-int npc_parse_warp(char *w1,char *w2,char *w3,char *w4);
-int npc_globalmessage(const char *name,const char *mes);
+int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y);
+int npc_touch_areanpc2(struct block_list* bl); // [Skotlex]
+int npc_check_areanpc(int flag, int m, int x, int y, int range);
+int npc_click(struct map_session_data* sd, struct npc_data* nd);
+int npc_scriptcont(struct map_session_data* sd, int id);
+TBL_NPC* npc_checknear(struct map_session_data* sd, struct block_list* bl);
+int npc_checknear2(struct map_session_data* sd, struct block_list* bl);
+int npc_buysellsel(struct map_session_data* sd, int id, int type);
+int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);
+int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list);
+int npc_parse_mob(char* w1, char* w2, char* w3, char* w4);
+int npc_parse_mob2(struct spawn_data* mob, int index); // [Wizputer]
+int npc_parse_warp(char* w1,char* w2,char* w3,char* w4);
+int npc_globalmessage(const char* name,const char* mes);
-void npc_setcells(struct npc_data *nd);
-void npc_movenpc(struct npc_data *nd, int x, int y);
-int npc_enable(const char *name,int flag);
-int npc_changename(const char *name, const char *newname, short look); // [Lance]
-struct npc_data* npc_name2id(const char *name);
+void npc_setcells(struct npc_data* nd);
+void npc_movenpc(struct npc_data* nd, int x, int y);
+int npc_enable(const char* name, int flag);
+int npc_changename(const char* name, const char* newname, short look); // [Lance]
+struct npc_data* npc_name2id(const char* name);
int npc_get_new_npc_id(void);
@@ -69,20 +69,20 @@ void npc_parsesrcfile(const char* name);
int do_final_npc(void);
int do_init_npc(void);
int npc_event_do_oninit(void);
-int npc_do_ontimer(int,int);
+int npc_do_ontimer(int npc_id, int option);
-int npc_event_doall(const unsigned char *name);
-int npc_event_do(const unsigned char *name);
-int npc_event_doall_id(const unsigned char *name, int id);
+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_timerevent_start(struct npc_data *nd, int rid);
-int npc_timerevent_stop(struct npc_data *nd);
-void npc_timerevent_quit(struct map_session_data *sd);
-int npc_gettimerevent_tick(struct npc_data *nd);
-int npc_settimerevent_tick(struct npc_data *nd,int newtimer);
-int npc_remove_map(struct npc_data *nd);
-void npc_unload_duplicates (struct npc_data *nd);
-int npc_unload(struct npc_data *nd);
+int npc_timerevent_start(struct npc_data* nd, int rid);
+int npc_timerevent_stop(struct npc_data* nd);
+void npc_timerevent_quit(struct map_session_data* sd);
+int npc_gettimerevent_tick(struct npc_data* nd);
+int npc_settimerevent_tick(struct npc_data* nd, int newtimer);
+int npc_remove_map(struct npc_data* nd);
+void npc_unload_duplicates (struct npc_data* nd);
+int npc_unload(struct npc_data* nd);
int npc_reload(void);
void npc_read_event_script(void);
int npc_script_event(TBL_PC* sd, int type);
diff --git a/src/map/script.c b/src/map/script.c
index 56e8174ae..8dd8cf071 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -363,7 +363,7 @@ static void check_event(struct script_state *st, const char *evt)
* 文字列のハッシュを計算
*------------------------------------------*/
#define calc_hash(x) (calc_hash2(x)%SCRIPT_HASH_SIZE)
-static unsigned int calc_hash2(const unsigned char *p)
+static unsigned int calc_hash2(const char* p)
{
#if defined(SCRIPT_HASH_DJB2)
unsigned int h = 5381;
@@ -2862,7 +2862,7 @@ void run_script_main(struct script_state *st)
push_val(stack,c,0);
break;
case C_STR:
- push_str(stack,C_CONSTSTR,(st->script->script_buf+st->pos));
+ push_str(stack,C_CONSTSTR,(char*)(st->script->script_buf+st->pos));
while(st->script->script_buf[st->pos++]);
break;
case C_FUNC:
@@ -4553,7 +4553,7 @@ BUILDIN_FUNC(callfunc)
struct script_code *scr, *oldscr;
const char *str=script_getstr(st,2);
- if( (scr=strdb_get(userfunc_db,(unsigned char*)str)) ){
+ if( (scr = strdb_get(userfunc_db, str)) ){
int i,j;
struct linkdb_node **oldval = st->stack->var_function;
for(i=st->start+3,j=0;i<st->end;i++,j++)
@@ -10258,7 +10258,7 @@ BUILDIN_FUNC(petloot)
BUILDIN_FUNC(getinventorylist)
{
TBL_PC *sd=script_rid2sd(st);
- unsigned char card_var[NAME_LENGTH];
+ char card_var[NAME_LENGTH];
int i,j=0,k;
if(!sd) return 0;
diff --git a/src/map/skill.c b/src/map/skill.c
index efadefe9c..918f90737 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -2442,7 +2442,7 @@ static int skill_check_condition_hom (struct homun_data *hd, int skill, int lv,
return 0;
break;
case HVAN_EXPLOSION:
- if(hd->homunculus.intimacy < battle_config.hvan_explosion_intimate)
+ if(hd->homunculus.intimacy < (unsigned int)battle_config.hvan_explosion_intimate)
return 0;
break;
}
@@ -6115,7 +6115,7 @@ int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, int s
case WZ_METEOR:
{
int flag=0, area = skill_get_splash(skillid, skilllv);
- short tmpx, tmpy, x1 = 0, y1 = 0;
+ short tmpx = 0, tmpy = 0, x1 = 0, y1 = 0;
if (sc && sc->data[SC_MAGICPOWER].timer != -1)
flag = flag|2; //Store the magic power flag for future use. [Skotlex]
for(i=0;i<2+(skilllv>>1);i++) {