summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-04 16:16:44 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-04 16:16:44 +0000
commitb8431ef147bb1f98ace6dcad5bfaa7d5e0a02897 (patch)
tree748e07ec74b74e79c5240dcec014e0cc948a2851 /src/map
parent12bca4654c96b32bd282a9ce25b30bbf2f7e08b9 (diff)
downloadhercules-b8431ef147bb1f98ace6dcad5bfaa7d5e0a02897.tar.gz
hercules-b8431ef147bb1f98ace6dcad5bfaa7d5e0a02897.tar.bz2
hercules-b8431ef147bb1f98ace6dcad5bfaa7d5e0a02897.tar.xz
hercules-b8431ef147bb1f98ace6dcad5bfaa7d5e0a02897.zip
* Added MAX_HOTKEYS to supplement the HOTKEY_SAVING define
* Fixed a compile problem when hotkey saving is disabled (topic:167265) * Added script source error reporting to countitem() (topic:167165) * Removed integer mob skill state/target definition support (unused) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11353 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c6
-rw-r--r--src/map/itemdb.c6
-rw-r--r--src/map/mob.c111
-rw-r--r--src/map/script.c1
-rw-r--r--src/map/status.h1
5 files changed, 60 insertions, 65 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index e48714c4e..a66bd72d5 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8003,9 +8003,9 @@ void clif_hotkeys_send(struct map_session_data *sd) {
const int fd = sd->fd;
int i;
if (!fd) return;
- WFIFOHEAD(fd, 2+HOTKEY_SAVING*7);
+ WFIFOHEAD(fd, 2+MAX_HOTKEYS*7);
WFIFOW(fd, 0) = 0x02b9;
- for(i = 0; i < HOTKEY_SAVING; i++) {
+ for(i = 0; i < MAX_HOTKEYS; i++) {
WFIFOB(fd, 2 + 0 + i * 7) = sd->status.hotkeys[i].type; // type: 0: item, 1: skill
WFIFOL(fd, 2 + 1 + i * 7) = sd->status.hotkeys[i].id; // item or skill ID
WFIFOW(fd, 2 + 5 + i * 7) = sd->status.hotkeys[i].lv; // skill level
@@ -8021,7 +8021,7 @@ void clif_parse_Hotkey(int fd, struct map_session_data *sd) {
cmd = RFIFOW(fd, 0);
idx = RFIFOW(fd, packet_db[sd->packet_ver][cmd].pos[0]);
- if (idx >= HOTKEY_SAVING) return;
+ if (idx >= MAX_HOTKEYS) return;
sd->status.hotkeys[idx].type = RFIFOB(fd, packet_db[sd->packet_ver][cmd].pos[1]);
sd->status.hotkeys[idx].id = RFIFOL(fd, packet_db[sd->packet_ver][cmd].pos[2]);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 91eaeafce..7d6514446 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -799,7 +799,7 @@ static bool itemdb_parse_dbrow(char** str, char* source, int line)
*------------------------------------------*/
static int itemdb_readdb(void)
{
- char* filename[] = { "item_db.txt", "item_db2.txt" };
+ const char* filename[] = { "item_db.txt", "item_db2.txt" };
int fi;
for( fi = 0; fi < ARRAYLENGTH(filename); ++fi )
@@ -911,10 +911,10 @@ static int itemdb_readdb(void)
*======================================*/
static int itemdb_read_sqldb(void)
{
- char* item_db_name[] = { item_db_db, item_db2_db };
+ const char* item_db_name[] = { item_db_db, item_db2_db };
int fi;
- for (fi = 0; fi < 2; fi++)
+ for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi )
{
uint32 lines = 0, count = 0;
diff --git a/src/map/mob.c b/src/map/mob.c
index d83229af1..da151faed 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2588,12 +2588,8 @@ int mob_skillid2skillidx(int class_,int skillid)
if(ms==NULL)
return -1;
- for(i=0;i<max;i++){
- if(ms[i].skill_id == skillid)
- return i;
- }
- return -1;
-
+ ARR_FIND( 0, max, i, ms[i].skill_id == skillid );
+ return ( i < max ) ? i : -1;
}
/*==========================================
@@ -2689,12 +2685,10 @@ int mob_getfriendstatus_sub(struct block_list *bl,va_list ap)
struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2)
{
- struct mob_data *fr=NULL;
-
+ struct mob_data* fr = NULL;
nullpo_retr(0, md);
- map_foreachinrange(mob_getfriendstatus_sub, &md->bl, 8,
- BL_MOB,md,cond1,cond2,&fr);
+ map_foreachinrange(mob_getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr);
return fr;
}
@@ -2953,12 +2947,8 @@ int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char
nullpo_retr(0, sd);
- for(class_=MOB_CLONE_START; class_<MOB_CLONE_END; class_++){
- if(mob_db_data[class_]==NULL)
- break;
- }
-
- if(class_>MOB_CLONE_END)
+ ARR_FIND( MOB_CLONE_START, MOB_CLONE_END, class_, mob_db_data[class_] == NULL );
+ if(class_ >= MOB_CLONE_END)
return 0;
mob_db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db));
@@ -3459,10 +3449,10 @@ static bool mob_parse_dbrow(char** str)
*------------------------------------------*/
static int mob_readdb(void)
{
- char* filename[] = { "mob_db.txt", "mob_db2.txt" };
+ const char* filename[] = { "mob_db.txt", "mob_db2.txt" };
int fi;
- for(fi = 0; fi < 2; fi++)
+ for( fi = 0; fi < ARRAYLENGTH(filename); ++fi )
{
uint32 lines = 0, count = 0;
char line[1024];
@@ -3520,10 +3510,10 @@ static int mob_readdb(void)
*------------------------------------------*/
static int mob_read_sqldb(void)
{
- char* mob_db_name[] = { mob_db_db, mob_db2_db };
+ const char* mob_db_name[] = { mob_db_db, mob_db2_db };
int fi;
- for (fi = 0; fi < 2; fi++)
+ for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi )
{
uint32 lines = 0, count = 0;
@@ -3630,7 +3620,7 @@ static int mob_readdb_mobavail(void)
mob_db_data[class_]->vd.head_top=atoi(str[7]);
mob_db_data[class_]->vd.head_mid=atoi(str[8]);
mob_db_data[class_]->vd.head_bottom=atoi(str[9]);
- mob_db_data[class_]->option=atoi(str[10])&~0x46;
+ mob_db_data[class_]->option=atoi(str[10])&~(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE);
mob_db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris
}
else if(str[2] && atoi(str[2]) > 0)
@@ -3661,7 +3651,8 @@ static int mob_read_randommonster(void)
memset(&summon, 0, sizeof(summon));
- for(i=0;i<MAX_RANDOMMONSTER;i++){
+ for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ )
+ {
mob_db_data[0]->summonper[i] = 1002; // 設定し忘れた場合はポリンが出るようにしておく
sprintf(line, "%s/%s", db_path, mobfile[i]);
fp=fopen(line,"r");
@@ -3689,7 +3680,7 @@ static int mob_read_randommonster(void)
continue;
mob_db_data[class_]->summonper[i]=atoi(str[2]);
if (i) {
- if (summon[i].qty < sizeof(summon[i].class_)/sizeof(summon[i].class_[0])) //MvPs
+ if( summon[i].qty < ARRAYLENGTH(summon[i].class_) ) //MvPs
summon[i].class_[summon[i].qty++] = class_;
else {
ShowDebug("Can't store more random mobs from %s, increase size of mob.c:summon variable!\n", mobfile[i]);
@@ -3748,7 +3739,7 @@ static int mob_readskilldb(void)
{ "anybad", -1 },
{ "stone", SC_STONE },
{ "freeze", SC_FREEZE },
- { "stan", SC_STUN },
+ { "stun", SC_STUN },
{ "sleep", SC_SLEEP },
{ "poison", SC_POISON },
{ "curse", SC_CURSE },
@@ -3786,13 +3777,15 @@ static int mob_readskilldb(void)
};
int x;
- char *filename[]={ "mob_skill_db.txt","mob_skill_db2.txt" };
+ const char* filename[] = { "mob_skill_db.txt","mob_skill_db2.txt" };
- if (!battle_config.mob_skill_rate) {
+ if( battle_config.mob_skill_rate == 0 ) {
ShowStatus("Mob skill use disabled. Not reading mob skills.\n");
return 0;
}
- for(x=0;x<2;x++){
+
+ for( x = 0; x < ARRAYLENGTH(filename); ++x )
+ {
int last_mob_id = 0;
count = 0;
sprintf(line, "%s/%s", db_path, filename[x]);
@@ -3837,7 +3830,7 @@ static int mob_readskilldb(void)
if (mob_id < 0)
continue;
memset(mob_db_data[mob_id]->skill,0,sizeof(struct mob_skill));
- mob_db_data[mob_id]->maxskill=0;
+ mob_db_data[mob_id]->maxskill=0;
continue;
}
@@ -3845,28 +3838,24 @@ static int mob_readskilldb(void)
{ //Prepare global skill. [Skotlex]
memset(&gms, 0, sizeof (struct mob_skill));
ms = &gms;
- } else {
- for(i=0;i<MAX_MOBSKILL;i++)
- if( (ms=&mob_db_data[mob_id]->skill[i])->skill_id == 0)
- break;
- if(i==MAX_MOBSKILL){
+ } else {
+ ARR_FIND( 0, MAX_MOBSKILL, i, (ms = &mob_db_data[mob_id]->skill[i])->skill_id == 0 );
+ if( i == MAX_MOBSKILL ) {
if (mob_id != last_mob_id) {
- ShowError("mob_skill: readdb: too many skill! Line %d in %d[%s]\n",
- count,mob_id,mob_db_data[mob_id]->sprite);
+ ShowError("mob_skill: readdb: too many skills! Line %d in %d[%s]\n", count,mob_id,mob_db_data[mob_id]->sprite);
last_mob_id = mob_id;
}
continue;
}
}
- ms->state=atoi(sp[2]);
- tmp = sizeof(state)/sizeof(state[0]);
- for(j=0;j<tmp && strcmp(sp[2],state[j].str);j++);
- if (j < tmp)
- ms->state=state[j].id;
- else if (!ms->state) {
+ //State
+ ARR_FIND( 0, ARRAYLENGTH(state), j, strcmp(sp[2],state[j].str) == 0 );
+ if( j < ARRAYLENGTH(state) )
+ ms->state = state[j].id;
+ else {
ShowWarning("mob_skill: Unrecognized state %s at %s, line %d\n", sp[2], filename[x], count);
- ms->state=MSS_ANY;
+ ms->state = MSS_ANY;
}
//Skill ID
@@ -3880,6 +3869,7 @@ static int mob_readskilldb(void)
continue;
}
ms->skill_id=j;
+
//Skill lvl
j= atoi(sp[4])<=0 ? 1 : atoi(sp[4]);
ms->skill_lv= j>battle_config.mob_max_skilllvl ? battle_config.mob_max_skilllvl : j; //we strip max skill level
@@ -3900,10 +3890,14 @@ static int mob_readskilldb(void)
ms->delay = INT_MAX;
ms->cancel=atoi(sp[8]);
if( strcmp(sp[8],"yes")==0 ) ms->cancel=1;
- ms->target=atoi(sp[9]);
- for(j=0;j<sizeof(target)/sizeof(target[0]);j++){
- if( strcmp(sp[9],target[j].str)==0)
- ms->target=target[j].id;
+
+ //Target
+ ARR_FIND( 0, ARRAYLENGTH(target), j, strcmp(sp[9],target[j].str) == 0 );
+ if( j < ARRAYLENGTH(target) )
+ ms->target = target[j].id;
+ else {
+ ShowWarning("mob_skill: Unrecognized target %s at %s, line %d\n", sp[9], filename[x], count);
+ ms->target = MST_TARGET;
}
//Check that the target condition is right for the skill type. [Skotlex]
@@ -3925,21 +3919,22 @@ static int mob_readskilldb(void)
ms->target = MST_TARGET;
}
- tmp = sizeof(cond1)/sizeof(cond1[0]);
- for(j=0;j<tmp && strcmp(sp[10],cond1[j].str);j++);
- if (j < tmp)
- ms->cond1=cond1[j].id;
+ //Cond1
+ ARR_FIND( 0, ARRAYLENGTH(cond1), j, strcmp(sp[10],cond1[j].str) == 0 );
+ if( j < ARRAYLENGTH(cond1) )
+ ms->cond1 = cond1[j].id;
else {
- ShowWarning("mob_skill: Unrecognized condition 1 %s at %s, line %d\n",
- sp[10], filename[x], count);
- ms->cond1=-1;
+ ShowWarning("mob_skill: Unrecognized condition 1 %s at %s, line %d\n", sp[10], filename[x], count);
+ ms->cond1 = -1;
}
- ms->cond2=atoi(sp[11]);
- tmp = sizeof(cond2)/sizeof(cond2[0]);
- for(j=0;j<tmp && strcmp(sp[11],cond2[j].str);j++);
- if (j < tmp)
- ms->cond2=cond2[j].id;
+ //Cond2
+ // numeric value
+ ms->cond2 = atoi(sp[11]);
+ // or special constant
+ ARR_FIND( 0, ARRAYLENGTH(cond2), j, strcmp(sp[11],cond2[j].str) == 0 );
+ if( j < ARRAYLENGTH(cond2) )
+ ms->cond2 = cond2[j].id;
ms->val[0]=(int)strtol(sp[12],NULL,0);
ms->val[1]=(int)strtol(sp[13],NULL,0);
diff --git a/src/map/script.c b/src/map/script.c
index fc2d75eee..09113d577 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -5863,6 +5863,7 @@ BUILDIN_FUNC(countitem)
if (nameid < 500) {
if(battle_config.error_log) ShowError("wrong item ID : countitem(%i)\n", nameid);
+ script_reportsrc(st);
script_pushint(st,0);
return 1;
}
diff --git a/src/map/status.h b/src/map/status.h
index 91981bdf4..489a08c66 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -579,7 +579,6 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe
#define status_percent_heal(bl, hp_rate, sp_rate) status_percent_change(NULL, bl, -(hp_rate), -(sp_rate), 1)
#define status_percent_damage(src, target, hp_rate, sp_rate) status_percent_change(src, target, hp_rate, sp_rate, 0)
//Instant kill with no drops/exp/etc
-//
#define status_kill(bl) status_percent_damage(NULL, bl, 100, 0)
//Used to set the hp/sp of an object to an absolute value (can't kill)
int status_set_hp(struct block_list *bl, unsigned int hp, int flag);