- 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://svn.code.sf.net/p/rathena/svn/trunk@9573 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2006-12-26 15:07:18 +00:00
parent dd92bd13fd
commit 58bb9be68a
12 changed files with 82 additions and 88 deletions

View File

@ -3,6 +3,11 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/12/26
* 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.
[Skotlex]
2006/12/25 2006/12/25
* Fixed buildin_getscrate, thanks Trancid. * Fixed buildin_getscrate, thanks Trancid.
* Applied part 1 of TheUltraMage's socket cleanup. * Applied part 1 of TheUltraMage's socket cleanup.

View File

@ -1665,11 +1665,8 @@ int count_users(void) {
int mmo_char_send006b(int fd, struct char_session_data *sd) { int mmo_char_send006b(int fd, struct char_session_data *sd) {
int i, j, found_num; int i, j, found_num;
struct mmo_charstatus *p; struct mmo_charstatus *p;
//#ifdef NEW_006b
const int offset = 24; const int offset = 24;
//#else WFIFOHEAD(fd, offset + 9*108);
// const int offset = 4;
//#endif
set_char_online(-1, 99,sd->account_id); 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 #if PACKETVER > 7
//Updated packet structure with rename-button included. Credits to Sara-chan //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); memset(WFIFOP(fd,0), 0, offset + found_num * 108);
WFIFOW(fd,2) = offset + found_num * 108; WFIFOW(fd,2) = offset + found_num * 108;
#else #else
WFIFOHEAD(fd, offset + found_num * 106);
memset(WFIFOP(fd,0), 0, offset + found_num * 106); memset(WFIFOP(fd,0), 0, offset + found_num * 106);
WFIFOW(fd,2) = offset + found_num * 106; WFIFOW(fd,2) = offset + found_num * 106;
#endif #endif

View File

@ -1708,11 +1708,9 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
#if PACKETVER > 7 #if PACKETVER > 7
//Updated packet structure with rename-button included. Credits to Sara-chan //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); memset(WFIFOP(fd, 0), 0, offset + found_num * 108);
WFIFOW(fd, 2) = offset + found_num * 108; WFIFOW(fd, 2) = offset + found_num * 108;
#else #else
WFIFOHEAD(fd, offset + found_num * 106);
memset(WFIFOP(fd, 0), 0, offset + found_num * 106); memset(WFIFOP(fd, 0), 0, offset + found_num * 106);
WFIFOW(fd, 2) = offset + found_num * 106; WFIFOW(fd, 2) = offset + found_num * 106;
#endif #endif

View File

@ -58,7 +58,7 @@ extern time_t stall_time;
#define WFIFOSPACE(fd) (session[fd]->max_wdata-session[fd]->wdata_size) #define WFIFOSPACE(fd) (session[fd]->max_wdata-session[fd]->wdata_size)
#ifdef TURBO #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]) #define WFIFOP(fd,pos) (&wbPtr ## fd[pos])
#else #else
#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); }while(0) #define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); }while(0)

View File

@ -3013,6 +3013,16 @@ int atcommand_gm(
return 0; 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; return -1;
} }
if (map[sd->bl.m].flag.pvp) { 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 {
clif_displaymessage(fd, msg_txt(160)); // PvP is already Off. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
return -1; 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; return 0;
} }

View File

@ -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) 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) { if(type == 2) {
WFIFOHEAD(sd->fd,packet_len(0x19a)); WFIFOHEAD(fd,packet_len(0x19a));
WFIFOW(sd->fd,0) = 0x19a; WFIFOW(fd,0) = 0x19a;
WFIFOL(sd->fd,2) = sd->bl.id; WFIFOL(fd,2) = sd->bl.id;
WFIFOL(sd->fd,6) = pvprank; WFIFOL(fd,6) = pvprank;
WFIFOL(sd->fd,10) = pvpnum; WFIFOL(fd,10) = pvpnum;
WFIFOSET(sd->fd,packet_len(0x19a)); WFIFOSET(fd,packet_len(0x19a));
} else { } else {
unsigned char buf[32]; unsigned char buf[32];
WBUFW(buf,0) = 0x19a; 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); nullpo_retr(0, p);
// if(battle_config.etc_log) if(!sd && flag==0){
// printf("clif_party_option: %d %d %d\n",p->exp,p->item,flag);
if(sd==NULL && flag==0){
int i; int i;
for(i=0;i<MAX_PARTY && !p->data[i].sd;i++); for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
if (i < MAX_PARTY) if (i < MAX_PARTY)
sd = p->data[i].sd; sd = p->data[i].sd;
} }
if(sd==NULL) if(!sd) return 0;
return 0;
WBUFW(buf,0)=0x101; WBUFW(buf,0)=0x101;
// WBUFL(buf,2) // that's how the client reads it, still need to check it's uses [FlavioJS] // 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,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) if(flag==0)
clif_send(buf,packet_len(0x101),&sd->bl,PARTY); clif_send(buf,packet_len(0x101),&sd->bl,PARTY);
else { else
WFIFOHEAD(sd->fd,packet_len(0x101)); clif_send(buf,packet_len(0x101),&sd->bl,SELF);
memcpy(WFIFOP(sd->fd,0),buf,packet_len(0x101));
WFIFOSET(sd->fd,packet_len(0x101));
}
return 0; 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); 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; WBUFW(buf,0)=0x105;
WBUFL(buf,2)=account_id; WBUFL(buf,2)=account_id;
memcpy(WBUFP(buf,6),name,NAME_LENGTH); memcpy(WBUFP(buf,6),name,NAME_LENGTH);
WBUFB(buf,30)=flag&0x0f; WBUFB(buf,30)=flag&0x0f;
if((flag&0xf0)==0){ if((flag&0xf0)==0)
if(sd==NULL) { clif_send(buf,packet_len(0x105),&sd->bl,PARTY);
for(i=0;i<MAX_PARTY && !p->data[i].sd;i++); else
if (i < MAX_PARTY) clif_send(buf,packet_len(0x105),&sd->bl,SELF);
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));
}
return 0; return 0;
} }
/*========================================== /*==========================================

View File

@ -364,7 +364,7 @@ int intif_send_guild_storage(int account_id,struct guild_storage *gstor)
return 0; return 0;
WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12); WFIFOHEAD(inter_fd,sizeof(struct guild_storage)+12);
WFIFOW(inter_fd,0) = 0x3019; 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,4) = account_id;
WFIFOL(inter_fd,8) = gstor->guild_id; WFIFOL(inter_fd,8) = gstor->guild_id;
memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) ); memcpy( WFIFOP(inter_fd,12),gstor, sizeof(struct guild_storage) );

View File

@ -237,15 +237,17 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data)
* 1: poring list * 1: poring list
* 2: bloody branch list * 2: bloody branch list
* flag: * 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. * &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 * lv: Mob level to check against
*------------------------------------------ *------------------------------------------
*/ */
int mob_get_random_id(int type, int flag, int lv) { int mob_get_random_id(int type, int flag, int lv) {
struct mob_db *mob; struct mob_db *mob;
int i=0, k=0, class_; int i=0, class_;
if(type < 0 || type >= MAX_RANDOMMONSTER) { if(type < 0 || type >= MAX_RANDOMMONSTER) {
if (battle_config.error_log) if (battle_config.error_log)
ShowError("mob_get_random_id: Invalid type (%d) of random monster.\n", type); 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 { do {
class_ = rand() % MAX_MOB_DB; class_ = rand() % MAX_MOB_DB;
if (flag&1)
k = rand() % 1000000;
mob = mob_db(class_); mob = mob_db(class_);
} while ((mob == mob_dummy || mob->summonper[type] <= k || } while ((mob == mob_dummy ||
(flag&2 && lv < mob->lv)) && (i++) < MAX_MOB_DB); (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) if(i >= MAX_MOB_DB)
class_ = mob_db_data[0]->summonper[type]; class_ = mob_db_data[0]->summonper[type];
return class_; return class_;
@ -1738,7 +1743,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if (hp||sp) if (hp||sp)
status_heal(src, hp, sp, battle_config.show_hp_sp_gain?2:0); 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_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); pc_addfame(sd, 1);
sd->mission_mobid = temp; sd->mission_mobid = temp;

View File

@ -6665,7 +6665,7 @@ int pc_calc_pvprank_timer(int tid,unsigned int tick,int id,int data)
sd=map_id2sd(id); sd=map_id2sd(id);
if(sd==NULL) if(sd==NULL)
return 0; return 0;
sd->pvp_timer=-1; sd->pvp_timer=UINT_MAX;
if( pc_calc_pvprank(sd)>0 ) if( pc_calc_pvprank(sd)>0 )
sd->pvp_timer=add_timer( sd->pvp_timer=add_timer(
gettick()+PVP_CALCRANK_INTERVAL, gettick()+PVP_CALCRANK_INTERVAL,

View File

@ -8671,36 +8671,33 @@ int buildin_pvpon(struct script_state *st)
return 0; 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 buildin_pvpoff(struct script_state *st)
{ {
int m,i,users; int m;
char *str; char *str;
struct map_session_data *pl_sd=NULL, **pl_allsd;
str=conv_str(st,& (st->stack->stack_data[st->start+2])); str=conv_str(st,& (st->stack->stack_data[st->start+2]));
m = map_mapname2mapid(str); m = map_mapname2mapid(str);
if(m >= 0 && map[m].flag.pvp) { //fixed Lupus if(m < 0 || !map[m].flag.pvp)
map[m].flag.pvp = 0; return 0; //fixed Lupus
clif_send0199(m,0);
if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris] map[m].flag.pvp = 0;
return 0; clif_send0199(m,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;
}
}
}
}
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; return 0;
} }

View File

@ -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); clif_skill_fail(sd,skillid,0,0);
break; 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) { if (!id) {
clif_skill_fail(sd,skillid,0,0); clif_skill_fail(sd,skillid,0,0);
break; break;

View File

@ -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 //delays status change ending so that a skill that sets opt1 fails to
//trigger when it also removed one //trigger when it also removed one
case SC_STONE: case SC_STONE:
sc->data[type].val3 = 0; //Petrify time counter.
case SC_FREEZE: case SC_FREEZE:
case SC_STUN: case SC_STUN:
case SC_SLEEP: case SC_SLEEP: