diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-12-26 15:07:18 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-12-26 15:07:18 +0000 |
commit | 5abd5bd1f8f53b73560cecd4496bfd4bc2acc226 (patch) | |
tree | 1599a2cfc0f4079ce75a649e04542bdc1d8d06d7 /src | |
parent | 391ac7a8a4aedafe818d0559a2011722fa54163c (diff) | |
download | hercules-5abd5bd1f8f53b73560cecd4496bfd4bc2acc226.tar.gz hercules-5abd5bd1f8f53b73560cecd4496bfd4bc2acc226.tar.bz2 hercules-5abd5bd1f8f53b73560cecd4496bfd4bc2acc226.tar.xz hercules-5abd5bd1f8f53b73560cecd4496bfd4bc2acc226.zip |
- Cleaned up some more the code so it works for -DTURBO
- Cleaned the pvpoff @ and script commands.
- mob_get_random_id now has two additional flags to specify that the monster to acquire should not be a boss type (4) or that it should give exp (8).
- TK_MISSION will now pick any mob from the DB as long as it is not a boss type and it gives base exp.
- Fixed the double-stone issue when hitting a petrified character.
- Minor cleanups
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9573 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 7 | ||||
-rw-r--r-- | src/char_sql/char.c | 2 | ||||
-rw-r--r-- | src/common/socket.h | 2 | ||||
-rw-r--r-- | src/map/atcommand.c | 31 | ||||
-rw-r--r-- | src/map/clif.c | 56 | ||||
-rw-r--r-- | src/map/intif.c | 2 | ||||
-rw-r--r-- | src/map/mob.c | 19 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 41 | ||||
-rw-r--r-- | src/map/skill.c | 2 | ||||
-rw-r--r-- | src/map/status.c | 1 |
11 files changed, 77 insertions, 88 deletions
diff --git a/src/char/char.c b/src/char/char.c index ce84dd0aa..dd229999d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1665,11 +1665,8 @@ int count_users(void) { int mmo_char_send006b(int fd, struct char_session_data *sd) { int i, j, found_num; struct mmo_charstatus *p; -//#ifdef NEW_006b const int offset = 24; -//#else -// const int offset = 4; -//#endif + WFIFOHEAD(fd, offset + 9*108); set_char_online(-1, 99,sd->account_id); @@ -1687,11 +1684,9 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { #if PACKETVER > 7 //Updated packet structure with rename-button included. Credits to Sara-chan - WFIFOHEAD(fd, offset + found_num * 108); memset(WFIFOP(fd,0), 0, offset + found_num * 108); WFIFOW(fd,2) = offset + found_num * 108; #else - WFIFOHEAD(fd, offset + found_num * 106); memset(WFIFOP(fd,0), 0, offset + found_num * 106); WFIFOW(fd,2) = offset + found_num * 106; #endif diff --git a/src/char_sql/char.c b/src/char_sql/char.c index b64dc68e4..95b713307 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -1708,11 +1708,9 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { #if PACKETVER > 7 //Updated packet structure with rename-button included. Credits to Sara-chan - WFIFOHEAD(fd, offset + found_num * 108); memset(WFIFOP(fd, 0), 0, offset + found_num * 108); WFIFOW(fd, 2) = offset + found_num * 108; #else - WFIFOHEAD(fd, offset + found_num * 106); memset(WFIFOP(fd, 0), 0, offset + found_num * 106); WFIFOW(fd, 2) = offset + found_num * 106; #endif diff --git a/src/common/socket.h b/src/common/socket.h index 6b1032eb3..71dc07ea9 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -58,7 +58,7 @@ extern time_t stall_time; #define WFIFOSPACE(fd) (session[fd]->max_wdata-session[fd]->wdata_size) #ifdef TURBO -#define WFIFOHEAD(fd, x) uint8 *wbPtr ## fd = fd?(session[fd]->wdata+session[fd]->wdata_size):0; +#define WFIFOHEAD(fd, x) uint8 *wbPtr ## fd = (fd>0&&session[fd])?(session[fd]->wdata+session[fd]->wdata_size):NULL; #define WFIFOP(fd,pos) (&wbPtr ## fd[pos]) #else #define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); }while(0) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a6c92a593..cd4ed4dbd 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3013,6 +3013,16 @@ int atcommand_gm( return 0; } +static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) { + TBL_PC* sd = (TBL_PC*)bl; + clif_pvpset(sd, 0, 0, 2); + if (sd->pvp_timer != UINT_MAX) { + delete_timer(sd->pvp_timer, pc_calc_pvprank_timer); + sd->pvp_timer = UINT_MAX; + } + return 0; +} + /*========================================== * *------------------------------------------ @@ -3030,26 +3040,15 @@ int atcommand_pvpoff( return -1; } - if (map[sd->bl.m].flag.pvp) { - map[sd->bl.m].flag.pvp = 0; - clif_send0199(sd->bl.m, 0); - - pl_allsd = map_getallusers(&users); - for (i = 0; i < users; i++) { //人数分ループ - if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) { - clif_pvpset(pl_sd, 0, 0, 2); - if (pl_sd->pvp_timer != -1) { - delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer); - pl_sd->pvp_timer = -1; - } - } - } - clif_displaymessage(fd, msg_txt(31)); // PvP: Off. - } else { + if (!map[sd->bl.m].flag.pvp) { clif_displaymessage(fd, msg_txt(160)); // PvP is already Off. return -1; } + map[sd->bl.m].flag.pvp = 0; + clif_send0199(sd->bl.m, 0); + map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC); + clif_displaymessage(fd, msg_txt(31)); // PvP: Off. return 0; } diff --git a/src/map/clif.c b/src/map/clif.c index 87389d29b..937509fa6 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5182,15 +5182,15 @@ int clif_set0199(int fd,int type) */ int clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) { - nullpo_retr(0, sd); + int fd = sd->fd; if(type == 2) { - WFIFOHEAD(sd->fd,packet_len(0x19a)); - WFIFOW(sd->fd,0) = 0x19a; - WFIFOL(sd->fd,2) = sd->bl.id; - WFIFOL(sd->fd,6) = pvprank; - WFIFOL(sd->fd,10) = pvpnum; - WFIFOSET(sd->fd,packet_len(0x19a)); + WFIFOHEAD(fd,packet_len(0x19a)); + WFIFOW(fd,0) = 0x19a; + WFIFOL(fd,2) = sd->bl.id; + WFIFOL(fd,6) = pvprank; + WFIFOL(fd,10) = pvpnum; + WFIFOSET(fd,packet_len(0x19a)); } else { unsigned char buf[32]; WBUFW(buf,0) = 0x19a; @@ -5971,27 +5971,21 @@ int clif_party_option(struct party_data *p,struct map_session_data *sd,int flag) nullpo_retr(0, p); -// if(battle_config.etc_log) -// printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag); - if(sd==NULL && flag==0){ + if(!sd && flag==0){ int i; for(i=0;i<MAX_PARTY && !p->data[i].sd;i++); if (i < MAX_PARTY) sd = p->data[i].sd; } - if(sd==NULL) - return 0; + if(!sd) return 0; WBUFW(buf,0)=0x101; // WBUFL(buf,2) // that's how the client reads it, still need to check it's uses [FlavioJS] WBUFW(buf,2)=((flag&0x01)?2:p->party.exp); - WBUFW(buf,4)=0; //NOTE: We don't know yet what this is for, it is NOT for item share rules, though. [Skotlex] + WBUFW(buf,4)=0; if(flag==0) clif_send(buf,packet_len(0x101),&sd->bl,PARTY); - else { - WFIFOHEAD(sd->fd,packet_len(0x101)); - memcpy(WFIFOP(sd->fd,0),buf,packet_len(0x101)); - WFIFOSET(sd->fd,packet_len(0x101)); - } + else + clif_send(buf,packet_len(0x101),&sd->bl,SELF); return 0; } /*========================================== @@ -6005,24 +5999,24 @@ int clif_party_leaved(struct party_data *p,struct map_session_data *sd,int accou nullpo_retr(0, p); + if(!sd && (flag&0xf0)==0) + { + for(i=0;i<MAX_PARTY && !p->data[i].sd;i++); + if (i < MAX_PARTY) + sd = p->data[i].sd; + } + + if(!sd) return 0; + WBUFW(buf,0)=0x105; WBUFL(buf,2)=account_id; memcpy(WBUFP(buf,6),name,NAME_LENGTH); WBUFB(buf,30)=flag&0x0f; - if((flag&0xf0)==0){ - if(sd==NULL) { - for(i=0;i<MAX_PARTY && !p->data[i].sd;i++); - if (i < MAX_PARTY) - sd = p->data[i].sd; - } - if (sd) - clif_send(buf,packet_len(0x105),&sd->bl,PARTY); - } else if (sd!=NULL) { - WFIFOHEAD(sd->fd,packet_len(0x105)); - memcpy(WFIFOP(sd->fd,0),buf,packet_len(0x105)); - WFIFOSET(sd->fd,packet_len(0x105)); - } + if((flag&0xf0)==0) + clif_send(buf,packet_len(0x105),&sd->bl,PARTY); + else + clif_send(buf,packet_len(0x105),&sd->bl,SELF); return 0; } /*========================================== diff --git a/src/map/intif.c b/src/map/intif.c index b1a147d0f..c89d0c567 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -364,7 +364,7 @@ int intif_send_guild_storage(int account_id,struct guild_storage *gstor) return 0; WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12); WFIFOW(inter_fd,0) = 0x3019; - WFIFOW(inter_fd,2) = sizeof(struct guild_storage)+12; + WFIFOW(inter_fd,2) = (unsigned short)sizeof(struct guild_storage)+12; WFIFOL(inter_fd,4) = account_id; WFIFOL(inter_fd,8) = gstor->guild_id; memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) ); diff --git a/src/map/mob.c b/src/map/mob.c index 935e80384..f2fdaabe2 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -237,15 +237,17 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) * 1: poring list * 2: bloody branch list * flag: - * &1: Apply the summon success chance found in the list. + * &1: Apply the summon success chance found in the list (otherwise get any monster from the db) * &2: Apply a monster check level. + * &4: Selected monster should not be a boss type + * &8: Selected monster must give base exp. * lv: Mob level to check against *------------------------------------------ */ int mob_get_random_id(int type, int flag, int lv) { struct mob_db *mob; - int i=0, k=0, class_; + int i=0, class_; if(type < 0 || type >= MAX_RANDOMMONSTER) { if (battle_config.error_log) ShowError("mob_get_random_id: Invalid type (%d) of random monster.\n", type); @@ -253,11 +255,14 @@ int mob_get_random_id(int type, int flag, int lv) { } do { class_ = rand() % MAX_MOB_DB; - if (flag&1) - k = rand() % 1000000; mob = mob_db(class_); - } while ((mob == mob_dummy || mob->summonper[type] <= k || - (flag&2 && lv < mob->lv)) && (i++) < MAX_MOB_DB); + } while ((mob == mob_dummy || + (flag&1 && mob->summonper[type] <= rand() % 1000000) || + (flag&2 && lv < mob->lv) || + (flag&4 && mob->status.mode&MD_BOSS) || + (flag&8 && mob->base_exp < 1) + ) && (i++) < MAX_MOB_DB); + if(i >= MAX_MOB_DB) class_ = mob_db_data[0]->summonper[type]; return class_; @@ -1738,7 +1743,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if (hp||sp) status_heal(src, hp, sp, battle_config.show_hp_sp_gain?2:0); if (sd->mission_mobid == md->class_) { //TK_MISSION [Skotlex] - if (++sd->mission_count >= 100 && (temp = mob_get_random_id(0, 0, sd->status.base_level))) + if (++sd->mission_count >= 100 && (temp = mob_get_random_id(0,0xC, sd->status.base_level))) { pc_addfame(sd, 1); sd->mission_mobid = temp; diff --git a/src/map/pc.c b/src/map/pc.c index 2a8f8487c..9f72f82c1 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6665,7 +6665,7 @@ int pc_calc_pvprank_timer(int tid,unsigned int tick,int id,int data) sd=map_id2sd(id); if(sd==NULL) return 0; - sd->pvp_timer=-1; + sd->pvp_timer=UINT_MAX; if( pc_calc_pvprank(sd)>0 ) sd->pvp_timer=add_timer( gettick()+PVP_CALCRANK_INTERVAL, diff --git a/src/map/script.c b/src/map/script.c index dc054ee1b..77dd2d2d0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8671,36 +8671,33 @@ int buildin_pvpon(struct script_state *st) return 0; } +static int buildin_pvpoff_sub(struct block_list *bl,va_list ap) { + TBL_PC* sd = (TBL_PC*)bl; + clif_pvpset(sd, 0, 0, 2); + if (sd->pvp_timer != UINT_MAX) { + delete_timer(sd->pvp_timer, pc_calc_pvprank_timer); + sd->pvp_timer = UINT_MAX; + } + return 0; +} + int buildin_pvpoff(struct script_state *st) { - int m,i,users; + int m; char *str; - struct map_session_data *pl_sd=NULL, **pl_allsd; str=conv_str(st,& (st->stack->stack_data[st->start+2])); m = map_mapname2mapid(str); - if(m >= 0 && map[m].flag.pvp) { //fixed Lupus - map[m].flag.pvp = 0; - clif_send0199(m,0); + if(m < 0 || !map[m].flag.pvp) + return 0; //fixed Lupus - if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris] - return 0; - - pl_allsd = map_getallusers(&users); - - for(i=0;i<users;i++) - { - if((pl_sd=pl_allsd[i]) && m == pl_sd->bl.m) - { - clif_pvpset(pl_sd,0,0,2); - if(pl_sd->pvp_timer != UINT_MAX) { - delete_timer(pl_sd->pvp_timer,pc_calc_pvprank_timer); - pl_sd->pvp_timer = -1; - } - } - } - } + map[m].flag.pvp = 0; + clif_send0199(m,0); + if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris] + return 0; + + map_foreachinmap(buildin_pvpoff_sub, m, BL_PC); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index 9695a1f76..d732d5b80 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -3832,7 +3832,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in clif_skill_fail(sd,skillid,0,0); break; } - id = mob_get_random_id(0,0, sd->status.base_level); + id = mob_get_random_id(0,0xC, sd->status.base_level); if (!id) { clif_skill_fail(sd,skillid,0,0); break; diff --git a/src/map/status.c b/src/map/status.c index c287321b8..bfc257f7b 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6057,6 +6057,7 @@ int status_change_end( struct block_list* bl , int type,int tid ) //delays status change ending so that a skill that sets opt1 fails to //trigger when it also removed one case SC_STONE: + sc->data[type].val3 = 0; //Petrify time counter. case SC_FREEZE: case SC_STUN: case SC_SLEEP: |