diff options
author | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-06-24 02:41:32 +0000 |
---|---|---|
committer | Lance <Lance@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-06-24 02:41:32 +0000 |
commit | e061189cdeb39b3efb0fd3a9e6f299379671fb2f (patch) | |
tree | a00b8b11e068c2beec5112f17a167cd5652d919d /src/map | |
parent | 2d740c0b724383ea09540509d7069d02b74db096 (diff) | |
download | hercules-e061189cdeb39b3efb0fd3a9e6f299379671fb2f.tar.gz hercules-e061189cdeb39b3efb0fd3a9e6f299379671fb2f.tar.bz2 hercules-e061189cdeb39b3efb0fd3a9e6f299379671fb2f.tar.xz hercules-e061189cdeb39b3efb0fd3a9e6f299379671fb2f.zip |
* [Optimized]:
- Setting of variables with defined scope in some frequently executed script events.
* [Added]:
- Missing script_require_trigger flags for some power hungry events.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7325 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/clif.c | 11 | ||||
-rw-r--r-- | src/map/map.h | 3 | ||||
-rw-r--r-- | src/map/mob.c | 14 | ||||
-rw-r--r-- | src/map/npc.c | 4 | ||||
-rw-r--r-- | src/map/pc.c | 20 | ||||
-rw-r--r-- | src/map/script.c | 2 | ||||
-rw-r--r-- | src/map/script.h | 1 |
7 files changed, 38 insertions, 17 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 324994d69..9994de65e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8231,7 +8231,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) sc_start(&sd->bl,SC_NOCHAT,100,0,0);
// Lance
- npc_script_event(sd, NPCE_LOADMAP);
+ if(sd->state.event_loadmap){
+ pc_setregstr(sd, add_str("@maploaded$"), map[sd->bl.m].name);
+ npc_script_event(sd, NPCE_LOADMAP);
+ }
if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka]
@@ -9273,10 +9276,12 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd) fail = 1;
else{
if((nd = ((struct npc_data *)map_id2bl(sd->npc_shopid))->master_nd)){
+ int regkey = add_str("@bought_nameid");
+ int regkey2 = add_str("@bought_quantity");
sprintf(npc_ev, "%s::OnBuyItem", nd->exname);
for(i=0;i<n;i++){
- setd_sub(NULL,sd, "@bought_nameid", i, (void *)((int)item_list[i*2+1]),NULL);
- setd_sub(NULL,sd, "@bought_quantity", i, (void *)((int)item_list[i*2]),NULL);
+ pc_setreg(sd,regkey+(i<<24),(int)item_list[i*2+1]);
+ pc_setreg(sd,regkey2+(i<<24),(int)item_list[i*2]);
}
npc_event(sd, npc_ev, 0);
fail = 0;
diff --git a/src/map/map.h b/src/map/map.h index a67a977cc..94415fcf5 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -470,6 +470,9 @@ struct map_session_data { unsigned event_kill_pc : 1;
unsigned event_disconnect : 1;
unsigned event_kill_mob : 1;
+ unsigned event_baselvup : 1;
+ unsigned event_joblvup : 1;
+ unsigned event_loadmap : 1;
// Abracadabra bugfix by Aru
unsigned abra_flag : 1;
unsigned autotrade : 1; //By Fantik
diff --git a/src/map/mob.c b/src/map/mob.c index abf92a691..2b1673687 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2992,14 +2992,18 @@ int mob_clone_delete(int class_) int mob_script_callback(struct mob_data *md, struct block_list *target, short action_type) { - // I will not add any protection here since I assume everything is checked before coming here. + // DEBUG: Uncomment these if errors occur. --- + // nullpo_retr(md, 0); + // nullpo_retr(md->nd, 0); + // ------------------------------------------- if(md->callback_flag&action_type){ - setd_sub(NULL, NULL, ".ai_action", 0, (void *)(int)action_type, &md->nd->u.scr.script->script_vars); + int regkey = add_str(".ai_action"); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)regkey, (void *)(int)action_type); if(target){ - setd_sub(NULL, NULL, ".ai_action", 1, (void *)(int)target->type, &md->nd->u.scr.script->script_vars); - setd_sub(NULL, NULL, ".ai_action", 2, (void *)target->id, &md->nd->u.scr.script->script_vars); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(1<<24)), (void *)(int)target->type); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(2<<24)), (void *)target->id); } - setd_sub(NULL, NULL, ".ai_action", 3, (void *)md->bl.id, &md->nd->u.scr.script->script_vars); + linkdb_replace(&md->nd->u.scr.script->script_vars,(void *)(regkey+(3<<24)), (void *)md->bl.id); run_script(md->nd->u.scr.script, 0, 0, md->nd->bl.id); return 1; } diff --git a/src/map/npc.c b/src/map/npc.c index 3d1557c1a..26ab060a7 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1312,8 +1312,8 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list) log_pick(sd, "S", 0, nameid, qty, &sd->status.inventory[idx]);
if(nd) {
- setd_sub(NULL,sd, "@sold_nameid", i, (void *)(int)sd->status.inventory[idx].nameid,NULL);
- setd_sub(NULL,sd, "@sold_quantity", i, (void *)(int)qty,NULL);
+ pc_setreg(sd,add_str("@sold_nameid")+(i<<24),(int)sd->status.inventory[idx].nameid);
+ pc_setreg(sd,add_str("@sold_quantity")+(i<<24),qty);
}
itemamount+=qty;
pc_delitem(sd,idx,qty,0);
diff --git a/src/map/pc.c b/src/map/pc.c index ee163433f..030c174bc 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -826,12 +826,18 @@ int pc_reg_received(struct map_session_data *sd) sd->state.event_kill_pc = pc_readglobalreg(sd, script_config.kill_pc_event_name);
sd->state.event_kill_mob = pc_readglobalreg(sd, script_config.kill_mob_event_name);
sd->state.event_disconnect = pc_readglobalreg(sd, script_config.logout_event_name);
+ sd->state.event_baselvup = pc_readglobalreg(sd, script_config.baselvup_event_name);
+ sd->state.event_joblvup = pc_readglobalreg(sd, script_config.joblvup_event_name);
+ sd->state.event_loadmap = pc_readglobalreg(sd, script_config.loadmap_event_name);
// if script triggers are not required
} else {
sd->state.event_death = 1;
sd->state.event_kill_pc = 1;
sd->state.event_disconnect = 1;
sd->state.event_kill_mob = 1;
+ sd->state.event_baselvup = 1;
+ sd->state.event_joblvup = 1;
+ sd->state.event_loadmap = 1;
}
npc_script_event(sd, NPCE_LOGIN);
@@ -3917,7 +3923,8 @@ int pc_checkbaselevelup(struct map_session_data *sd) }
clif_misceffect(&sd->bl,0);
//LORDALFA - LVLUPEVENT
- npc_script_event(sd, NPCE_BASELVUP);
+ if(sd->state.event_baselvup)
+ npc_script_event(sd, NPCE_BASELVUP);
return 1;
}
@@ -3948,7 +3955,8 @@ int pc_checkjoblevelup(struct map_session_data *sd) if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
clif_status_change(&sd->bl,SI_DEVIL, 1); //Permanent blind effect from SG_DEVIL.
- npc_script_event(sd, NPCE_JOBLVUP);
+ if(sd->state.event_joblvup)
+ npc_script_event(sd, NPCE_JOBLVUP);
return 1;
}
@@ -4700,8 +4708,10 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) case BL_PC:
{
struct map_session_data *ssd = (struct map_session_data *)src;
- if (sd->state.event_death)
+ if (sd->state.event_death){
pc_setglobalreg(sd,"killerrid",(ssd->status.account_id));
+ npc_script_event(sd,NPCE_DIE);
+ }
if (ssd->state.event_kill_pc) {
pc_setglobalreg(ssd, "killedrid", sd->bl.id);
npc_script_event(ssd, NPCE_KILLPC);
@@ -4736,9 +4746,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) }
break;
}
-
- if (sd->state.event_death)
- npc_script_event(sd,NPCE_DIE);
+
// PK/Karma system code (not enabled yet) [celest]
/*
diff --git a/src/map/script.c b/src/map/script.c index 234a5a11b..59fb02dc9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -856,7 +856,7 @@ static int search_str(const unsigned char *p) *------------------------------------------ */ // 既存のであれば番号、無ければ登録して新規番号 -static int add_str(const unsigned char *p) +int add_str(const unsigned char *p) { int i; char *lowcase; diff --git a/src/map/script.h b/src/map/script.h index 47de38c5c..d94348e43 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -83,6 +83,7 @@ int script_config_read(char *cfgName); void script_free_stack(struct script_stack*);
int do_init_script(void);
int do_final_script(void);
+int add_str(const unsigned char *p);
int script_reload(void);
extern char mapreg_txt[];
|