From 18b8ec2594cd4a8748d8c69a82f61c8637ef400e Mon Sep 17 00:00:00 2001 From: skotlex Date: Tue, 12 Sep 2006 16:17:57 +0000 Subject: - Updated battle_switch to use strncmpi instead of strcmpi, it makes it so using "yessir" will match "yes", this is actually needed because if you set a config setting to "yes " (notice the trailing space), then the map config engine fails to read it right, and will set the config setting to 0 (no). - Added function pc_resethate to more easily handle Angel trigger - Made feel_var and hate_var static variables to pc.c to simplify things and avoid errors due to redundancy. - Updated the show_mob_info setting to add another space to the separating pipes, so that each field is separated by " | " instead of " |". git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8721 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/battle.c | 12 ++++++++++-- src/map/clif.c | 8 ++++---- src/map/pc.c | 19 ++++++++++++++++--- src/map/pc.h | 1 + src/map/status.c | 5 +---- 5 files changed, 32 insertions(+), 13 deletions(-) (limited to 'src/map') diff --git a/src/map/battle.c b/src/map/battle.c index 749a71aa6..6ee40df35 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3429,10 +3429,18 @@ int battle_check_range(struct block_list *src,struct block_list *bl,int range) *------------------------------------------ */ int battle_config_switch(const char *str) { - if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0) + if(strncmpi(str, "on",2) == 0 || + strncmpi(str, "yes",3) == 0 || + strncmpi(str, "oui",3) == 0 || + strncmpi(str, "ja",2) == 0 || + strncmpi(str, "si",2) == 0) return 1; - if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0) + if(strncmpi(str, "off",3) == 0 || + strncmpi(str, "no",2) == 0 || + strncmpi(str, "non",3) == 0 || + strncmpi(str, "nein",4) == 0) return 0; + return atoi(str); } diff --git a/src/map/clif.c b/src/map/clif.c index 569359049..17acf4ee7 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7857,15 +7857,15 @@ int clif_charnameack (int fd, struct block_list *bl) WBUFW(buf, 0) = cmd = 0x195; if (battle_config.show_mob_info&4) - str_p += sprintf(str_p, "Lv. %d |", md->level); + str_p += sprintf(str_p, "Lv. %d | ", md->level); if (battle_config.show_mob_info&1) - str_p += sprintf(str_p, "HP: %u/%u |", md->status.hp, md->status.max_hp); + str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp); if (battle_config.show_mob_info&2) - str_p += sprintf(str_p, "HP: %d%% |", 100*md->status.hp/md->status.max_hp); + str_p += sprintf(str_p, "HP: %d%% | ", 100*md->status.hp/md->status.max_hp); //Even thought mobhp ain't a name, we send it as one so the client //can parse it. [Skotlex] if (str_p != mobhp) { - *(str_p-2) = '\0'; //Remove trailing space + pipe. + *(str_p-3) = '\0'; //Remove trailing space + pipe. memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH); WBUFB(buf,54) = 0; memcpy(WBUFP(buf,78), mobhp, NAME_LENGTH); diff --git a/src/map/pc.c b/src/map/pc.c index f6bed1846..057e5e59d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -66,6 +66,9 @@ static int GM_num = 0; #define MOTD_LINE_SIZE 128 char motd_text[MOTD_LINE_SIZE][256]; // Message of the day buffer [Valaris] +static const char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"}; +static const char hate_var[3][NAME_LENGTH] = {"PC_HATE_MOB_SUN","PC_HATE_MOB_MOON","PC_HATE_MOB_STAR"}; + int pc_isGM(struct map_session_data *sd) { int i; @@ -796,8 +799,6 @@ int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl) int pc_reg_received(struct map_session_data *sd) { int i,j; - const char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"}; - const char hate_var[3][NAME_LENGTH] = {"PC_HATE_MOB_SUN","PC_HATE_MOB_MOON","PC_HATE_MOB_STAR"}; sd->change_level = pc_readglobalreg(sd,"jobchange_level"); sd->die_counter = pc_readglobalreg(sd,"PC_DIE_COUNTER"); @@ -4732,7 +4733,6 @@ int pc_resetskill(struct map_session_data* sd, int flag) int pc_resetfeel(struct map_session_data* sd) { int i; - char feel_var[3][NAME_LENGTH] = {"PC_FEEL_SUN","PC_FEEL_MOON","PC_FEEL_STAR"}; nullpo_retr(0, sd); for (i=0; i<3; i++) @@ -4745,6 +4745,19 @@ int pc_resetfeel(struct map_session_data* sd) return 0; } +int pc_resethate(struct map_session_data* sd) +{ + int i; + nullpo_retr(0, sd); + + for (i=0; i<3; i++) + { + sd->hate_mob[i] = -1; + pc_setglobalreg(sd,hate_var[i],0); + } + return 0; +} + static int pc_respawn(int tid,unsigned int tick,int id,int data) { struct map_session_data *sd = map_id2sd(id); diff --git a/src/map/pc.h b/src/map/pc.h index ee688cd41..d0928c203 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -196,6 +196,7 @@ int pc_resetlvl(struct map_session_data*,int type); int pc_resetstate(struct map_session_data*); int pc_resetskill(struct map_session_data*, int); int pc_resetfeel(struct map_session_data*); +int pc_resethate(struct map_session_data*); int pc_equipitem(struct map_session_data*,int,int); int pc_unequipitem(struct map_session_data*,int,int); int pc_checkitem(struct map_session_data*); diff --git a/src/map/status.c b/src/map/status.c index 7cf7109b2..341e7e85e 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -7022,10 +7022,7 @@ static int status_natural_heal(DBKey key,void * data,va_list app) (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && rand()%10000 < battle_config.sg_angel_skill_ratio ) { //Angel of the Sun/Moon/Star - malloc_set(sd->hate_mob, 0, sizeof(sd->hate_mob)); - pc_setglobalreg(sd,"PC_HATE_MOB_STAR", 0); - pc_setglobalreg(sd,"PC_HATE_MOB_SUN", 0); - pc_setglobalreg(sd,"PC_HATE_MOB_MOON", 0); + pc_resethate(sd); pc_resetfeel(sd); //TODO: Figure out how to make the client-side msg show up. } -- cgit v1.2.3-70-g09d2