From f4d39edff58dc2a8db9e517a6ffbe738e36b31e9 Mon Sep 17 00:00:00 2001 From: celest Date: Mon, 10 Jan 2005 15:25:24 +0000 Subject: * Completed adding packet DB reading * Added Shinomori's suggestions for npc timers, * Removed checking for script event timers' length, and added Shinomori's changes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@947 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 110 ++++++++++++++++++++++++++++++------------------------- src/map/map.h | 2 +- src/map/npc.c | 4 +- src/map/pc.c | 6 +-- src/map/script.c | 9 ++--- src/map/script.h | 1 - 6 files changed, 69 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/map/clif.c b/src/map/clif.c index 00de30b59..54bf3a452 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -55,6 +55,9 @@ #define MAX_PACKET_DB 0x224 int packet_db_ver = -1; +int *packet_db_size; +void (**packet_db_parse_func)(); +short packet_db_pos[MAX_PACKET_DB][20]; static const int packet_len_table[MAX_PACKET_DB] = { 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -10159,11 +10162,14 @@ void clif_parse_debug(int fd,struct map_session_data *sd) { int i, cmd; + if (packet_db_ver < 0) + return; + cmd = RFIFOW(fd,0); printf("packet debug 0x%4X\n",cmd); printf("---- 00-01-02-03-04-05-06-07-08-09-0A-0B-0C-0D-0E-0F"); - for(i=0;i 7) { // minimum packet version allowed + packet_db_size = packet_size_table[packet_db_ver - 5]; + packet_db_parse_func = clif_parse_func_table[packet_db_ver - 7]; - cmd=strtol(str[0],(char **)NULL,0); - if(cmd<=0 || cmd>=MAX_PACKET_DB) - continue; + while(fgets(line,1020,fp)){ + if(line[0]=='/' && line[1]=='/') + continue; + memset(str,0,sizeof(str)); + for(j=0,p=line;j<4 && p;j++){ + str[j]=p; + p=strchr(p,','); + if(p) *p++=0; + } + if(str[0]==NULL) + continue; - if(str[1]==NULL){ - sprintf(tmp_output, "packet_db: packet len error\n"); - ShowError(tmp_output); - continue; - } - packet_size_table[packet_db_ver - 5][cmd] = atoi(str[1]); + cmd=strtol(str[0],(char **)NULL,0); + if(cmd<=0 || cmd>=MAX_PACKET_DB) + continue; - if(str[2]==NULL){ - ln++; - continue; - } - for(j=0;j 2 /* && packet_db[cmd].pos[0] == 0 */) -// printf("packet_db: %d 0x%x %d %s %p\n",ln,cmd,packet_size_table[packet_db_ver - 5][cmd],str[2],clif_parse_func_table[packet_db_ver - 7][cmd]); + ln++; +// if(packet_size_table[packet_db_ver - 5][cmd] > 2 /* && packet_db[cmd].pos[0] == 0 */) +// printf("packet_db: %d 0x%x %d %s %p | %p\n",ln,cmd,packet_db_size[cmd],str[2],packet_db_parse_func[cmd],clif_parse_func_table[packet_db_ver - 7][cmd]); + } } fclose(fp); sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/packet_db.txt"); @@ -10982,6 +10991,9 @@ int do_init_clif(void) { // Size of packet version 16 (packet db) memcpy(&packet_size_table[11], &packet_size_table[10], sizeof(packet_len_table)); + packet_db_size = packet_size_table[0]; + packet_db_parse_func = clif_parse_func_table[0]; + packetdb_readdb(); set_defaultparse(clif_parse); diff --git a/src/map/map.h b/src/map/map.h index e6ad63b08..26fc3e6c8 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -375,7 +375,7 @@ struct npc_data { char *script; short xs,ys; int guild_id; - int timer,timerid,timeramount,nexttimer,timerrid; + int timer,timerid,timeramount,nexttimer,rid; unsigned int timertick; struct npc_timerevent_list *timer_event; int label_list_num; diff --git a/src/map/npc.c b/src/map/npc.c index d2379e5a8..ff752192a 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -589,7 +589,7 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data) nd->u.scr.timerid = add_timer(tick+next,npc_timerevent,id,next); } - run_script(nd->u.scr.script,te->pos,nd->u.scr.timerrid,nd->bl.id); + run_script(nd->u.scr.script,te->pos,nd->u.scr.rid,nd->bl.id); return 0; } /*========================================== @@ -612,7 +612,7 @@ int npc_timerevent_start(struct npc_data *nd) } nd->u.scr.nexttimer=j; nd->u.scr.timertick=gettick(); - nd->u.scr.timerrid=0; // no players attached by default [celest] + nd->u.scr.rid=0; // reset attached player [celest] if(j>=n) return 0; diff --git a/src/map/pc.c b/src/map/pc.c index 5ff5f06fd..2954dfddf 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6791,14 +6791,12 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name) nullpo_retr(0, sd); - Assert(strlen(name) < script_config.max_eventtimer_len); - for(i=0;ieventtimer[i]==-1 ) break; if(ieventtimer[i]=add_timer(gettick()+tick, pc_eventtimer,sd->bl.id,(int)evname); sd->eventcount++; diff --git a/src/map/script.c b/src/map/script.c index 6e00d15cb..64e4a7692 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3893,6 +3893,7 @@ int buildin_initnpctimer(struct script_state *st) npc_settimerevent_tick(nd,0); npc_timerevent_start(nd); + nd->u.scr.rid=st->rid; return 0; } /*========================================== @@ -3985,7 +3986,7 @@ int buildin_attachnpctimer(struct script_state *st) if (sd==NULL) return 0; - nd->u.scr.timerrid = sd->bl.id; + nd->u.scr.rid = sd->bl.id; return 0; } @@ -4001,7 +4002,7 @@ int buildin_detachnpctimer(struct script_state *st) else nd=(struct npc_data *)map_id2bl(st->oid); - nd->u.scr.timerrid = 0; + nd->u.scr.rid = 0; return 0; } @@ -7204,7 +7205,6 @@ int script_config_read(char *cfgName) script_config.warn_cmd_mismatch_paramnum=1; script_config.check_cmdcount=8192; script_config.check_gotocount=512; - script_config.max_eventtimer_len=32; fp=fopen(cfgName,"r"); if(fp==NULL){ @@ -7238,9 +7238,6 @@ int script_config_read(char *cfgName) else if(strcmpi(w1,"check_gotocount")==0) { script_config.check_gotocount = battle_config_switch(w2); } - else if(strcmpi(w1,"max_eventtimer_length")==0) { - script_config.max_eventtimer_len = battle_config_switch(w2); - } else if(strcmpi(w1,"import")==0){ script_config_read(w2); } diff --git a/src/map/script.h b/src/map/script.h index 5dd266174..50aac9dd7 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -9,7 +9,6 @@ extern struct Script_Config { int warn_cmd_mismatch_paramnum; int check_cmdcount; int check_gotocount; - int max_eventtimer_len; } script_config; struct script_data { -- cgit v1.2.3-70-g09d2