diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-09-23 03:14:57 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-09-23 03:14:57 +0000 |
commit | 7d10ecf3d159a3d4765b65a1eb1bd11399b0ef37 (patch) | |
tree | 32d69f53bacb7597d55e5a27839dde6d952aca77 | |
parent | a278eb2e074ce0cb0c9c68e372c66b87f84577a1 (diff) | |
download | hercules-7d10ecf3d159a3d4765b65a1eb1bd11399b0ef37.tar.gz hercules-7d10ecf3d159a3d4765b65a1eb1bd11399b0ef37.tar.bz2 hercules-7d10ecf3d159a3d4765b65a1eb1bd11399b0ef37.tar.xz hercules-7d10ecf3d159a3d4765b65a1eb1bd11399b0ef37.zip |
* map_addflooritem and struct item_drop_list using id's instead of struct map_session_data's (fixes bugreport:36).
* Fixed buildin_escape_sql not properly escaping in sql servers.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11279 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 4 | ||||
-rw-r--r-- | src/map/atcommand.c | 2 | ||||
-rw-r--r-- | src/map/map.c | 36 | ||||
-rw-r--r-- | src/map/map.h | 2 | ||||
-rw-r--r-- | src/map/mob.c | 30 | ||||
-rw-r--r-- | src/map/mob.h | 2 | ||||
-rw-r--r-- | src/map/pc.c | 4 | ||||
-rw-r--r-- | src/map/pet.c | 14 | ||||
-rw-r--r-- | src/map/script.c | 34 | ||||
-rw-r--r-- | src/map/skill.c | 12 |
10 files changed, 68 insertions, 72 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index f43f917a3..26e8242f9 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,10 @@ Date Added 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. +2007/09/23 + * map_addflooritem and struct item_drop_list using id's instead of + struct map_session_data's (fixes bugreport:36). + * Fixed buildin_escape_sql not properly escaping in sql servers. [FlavioJS] 2007/09/22 * Fixed a severe bug in inventory saving code (caused by r11192) * Applied changes to clif_parse_globalmessage() from my WiP code diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 3ddac9a9d..44d3bdc58 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6617,7 +6617,7 @@ void getring (struct map_session_data* sd) if((flag = pc_additem(sd,&item_tmp,1))) { clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } diff --git a/src/map/map.c b/src/map/map.c index 2476e0e0e..8084881ca 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1544,20 +1544,18 @@ int map_search_freecell(struct block_list *src, int m, short *x,short *y, int rx * item_dataはamount以外をcopyする * type flag: &1 MVP item. &2 do stacking check. *------------------------------------------*/ -int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,struct map_session_data *first_sd, - struct map_session_data *second_sd,struct map_session_data *third_sd,int type) +int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int first_id,int second_id,int third_id,int flags) { int r; - unsigned int tick; struct flooritem_data *fitem=NULL; nullpo_retr(0, item_data); - if(!map_searchrandfreecell(m,&x,&y,type&2?1:0)) + if(!map_searchrandfreecell(m,&x,&y,flags&2?1:0)) return 0; r=rand(); - fitem = (struct flooritem_data *)aCalloc(1,sizeof(*fitem)); + CREATE(fitem, struct flooritem_data, 1); fitem->bl.type=BL_ITEM; fitem->bl.prev = fitem->bl.next = NULL; fitem->bl.m=m; @@ -1569,28 +1567,12 @@ int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,struct return 0; } - tick = gettick(); - if(first_sd) { - fitem->first_get_id = first_sd->bl.id; - if(type&1) - fitem->first_get_tick = tick + battle_config.mvp_item_first_get_time; - else - fitem->first_get_tick = tick + battle_config.item_first_get_time; - } - if(second_sd) { - fitem->second_get_id = second_sd->bl.id; - if(type&1) - fitem->second_get_tick = tick + battle_config.mvp_item_first_get_time + battle_config.mvp_item_second_get_time; - else - fitem->second_get_tick = tick + battle_config.item_first_get_time + battle_config.item_second_get_time; - } - if(third_sd) { - fitem->third_get_id = third_sd->bl.id; - if(type&1) - fitem->third_get_tick = tick + battle_config.mvp_item_first_get_time + battle_config.mvp_item_second_get_time + battle_config.mvp_item_third_get_time; - else - fitem->third_get_tick = tick + battle_config.item_first_get_time + battle_config.item_second_get_time + battle_config.item_third_get_time; - } + fitem->first_get_id = first_id; + fitem->first_get_tick = gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time); + fitem->second_get_id = second_id; + fitem->second_get_tick = fitem->first_get_tick + (flags&1 ? battle_config.mvp_item_second_get_time : battle_config.item_second_get_time); + fitem->third_get_id = third_id; + fitem->third_get_tick = fitem->second_get_tick + (flags&1 ? battle_config.mvp_item_third_get_time : battle_config.item_third_get_time); memcpy(&fitem->item_data,item_data,sizeof(*item_data)); fitem->item_data.amount=amount; diff --git a/src/map/map.h b/src/map/map.h index b83c965af..b91e91d51 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1324,7 +1324,7 @@ int map_addnpc(int,struct npc_data *); int map_clearflooritem_timer(int,unsigned int,int,int); int map_removemobs_timer(int,unsigned int,int,int); #define map_clearflooritem(id) map_clearflooritem_timer(0,0,id,1) -int map_addflooritem(struct item *,int,int,int,int,struct map_session_data *,struct map_session_data *,struct map_session_data *,int); +int map_addflooritem(struct item *item_data,int amount,int m,int x,int y,int first_id,int second_id,int third_id,int flags); // キャラid=>キャラ名 変換関連 void map_addchariddb(int charid,char *name); diff --git a/src/map/mob.c b/src/map/mob.c index b5c83413c..f8be3806b 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1498,7 +1498,7 @@ static int mob_delay_item_drop(int tid, unsigned int tick, int id, int data) while (ditem) { map_addflooritem(&ditem->item_data,ditem->item_data.amount, list->m,list->x,list->y, - list->first_sd,list->second_sd,list->third_sd,0); + list->first_id,list->second_id,list->third_id,0); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -1514,6 +1514,8 @@ static int mob_delay_item_drop(int tid, unsigned int tick, int id, int data) *------------------------------------------*/ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate) { + TBL_PC* sd; + if(log_config.enable_logs&0x10) { //Logs items, dropped by mobs [Lupus] if (loot) @@ -1522,14 +1524,16 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str log_pick_mob(md, "M", ditem->item_data.nameid, -ditem->item_data.amount, NULL); } - if (dlist->first_sd && dlist->first_sd->state.autoloot && - drop_rate <= dlist->first_sd->state.autoloot + sd = map_id2sd(dlist->first_id); + if( sd == NULL ) sd = map_id2sd(dlist->second_id); + if( sd == NULL ) sd = map_id2sd(dlist->third_id); + if( sd && drop_rate <= sd->state.autoloot #ifdef AUTOLOOT_DISTANCE - && check_distance_blxy(&dlist->first_sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE) + && check_distance_blxy(&sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE) #endif ) { //Autoloot. - if (party_share_loot(party_search(dlist->first_sd->status.party_id), - dlist->first_sd, &ditem->item_data, dlist->first_sd->bl.id) == 0 + if (party_share_loot(party_search(sd->status.party_id), + sd, &ditem->item_data, sd->bl.id) == 0 ) { ers_free(item_drop_ers, ditem); return; @@ -1978,9 +1982,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) dlist->m = md->bl.m; dlist->x = md->bl.x; dlist->y = md->bl.y; - dlist->first_sd = mvp_sd; - dlist->second_sd = second_sd; - dlist->third_sd = third_sd; + dlist->first_id = (mvp_sd ? mvp_sd->bl.id : 0); + dlist->second_id = (second_sd ? second_sd->bl.id : 0); + dlist->third_id = (third_sd ? third_sd->bl.id : 0); dlist->item = NULL; for (i = 0; i < MAX_MOB_DROP; i++) @@ -2086,9 +2090,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) dlist->m = md->bl.m; dlist->x = md->bl.x; dlist->y = md->bl.y; - dlist->first_sd = mvp_sd; - dlist->second_sd = second_sd; - dlist->third_sd = third_sd; + dlist->first_id = (mvp_sd ? mvp_sd->bl.id : 0); + dlist->second_id = (second_sd ? second_sd->bl.id : 0); + dlist->third_id = (third_sd ? third_sd->bl.id : 0); dlist->item = NULL; for(i = 0; i < md->lootitem_count; i++) mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000); @@ -2155,7 +2159,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if((temp = pc_additem(mvp_sd,&item,1)) != 0) { clif_additem(sd,0,0,temp); - map_addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd,second_sd,third_sd,1); + map_addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->bl.id,(second_sd?second_sd->bl.id:0),(third_sd?third_sd->bl.id:0),1); } if(log_config.enable_logs&0x200) {//Logs items, MVP prizes [Lupus] diff --git a/src/map/mob.h b/src/map/mob.h index 25a314d75..ec4d58432 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -142,7 +142,7 @@ struct item_drop { }; struct item_drop_list { int m, x, y; // coordinates - struct map_session_data *first_sd, *second_sd, *third_sd; // sd's of players with higher pickup priority + int first_id, second_id, third_id; // id's of players with higher pickup priority struct item_drop* item; // linked list of drops }; diff --git a/src/map/pc.c b/src/map/pc.c index d6a41db37..0423ffb78 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2894,7 +2894,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) log_pick_pc(sd, "P", sd->status.inventory[n].nameid, -amount, (struct item*)&sd->status.inventory[n]); //Logs - if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, NULL, NULL, NULL, 2)) + if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2)) return 0; pc_delitem(sd, n, amount, 0); @@ -5043,7 +5043,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) item_tmp.card[1]=0; item_tmp.card[2]=GetWord(sd->status.char_id,0); // CharId item_tmp.card[3]=GetWord(sd->status.char_id,1); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } // activate Steel body if a super novice dies at 99+% exp [celest] diff --git a/src/map/pet.c b/src/map/pet.c index 9bebf27bc..f66492799 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -353,7 +353,7 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) tmp_item.card[3] = pd->pet.rename_flag; if((flag = pc_additem(sd,&tmp_item,1))) { clif_additem(sd,0,0,flag); - map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } pd->pet.incuvate = 1; //No need, pet is saved on unit_free below. @@ -622,7 +622,7 @@ int pet_get_egg(int account_id,int pet_id,int flag) tmp_item.card[3] = 0; //New pets are not named. if((ret = pc_additem(sd,&tmp_item,1))) { clif_additem(sd,0,0,ret); - map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } return 1; @@ -751,7 +751,7 @@ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) tmp_item.identify = 1; if((flag = pc_additem(sd,&tmp_item,1))) { clif_additem(sd,0,0,flag); - map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } if (battle_config.pet_equip_required) { //Skotlex: halt support timers if needed @@ -1028,7 +1028,7 @@ static int pet_delay_item_drop(int tid,unsigned int tick,int id,int data) while (ditem) { map_addflooritem(&ditem->item_data,ditem->item_data.amount, list->m,list->x,list->y, - list->first_sd,list->second_sd,list->third_sd,0); + list->first_id,list->second_id,list->third_id,0); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -1049,9 +1049,9 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) dlist->m = pd->bl.m; dlist->x = pd->bl.x; dlist->y = pd->bl.y; - dlist->first_sd = NULL; - dlist->second_sd = NULL; - dlist->third_sd = NULL; + dlist->first_id = 0; + dlist->second_id = 0; + dlist->third_id = 0; dlist->item = NULL; for(i=0;i<pd->loot->count;i++) { diff --git a/src/map/script.c b/src/map/script.c index 37dd99229..1aeff2e2e 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6038,7 +6038,7 @@ BUILDIN_FUNC(getitem) else if( (flag=pc_additem(sd,&it,amount)) ){ clif_additem(sd,0,0,flag); if( pc_candrop(sd,&it) ) - map_addflooritem(&it,amount,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&it,amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } //Logs items, got from (N)PC scripts [Lupus] @@ -6122,7 +6122,7 @@ BUILDIN_FUNC(getitem2) item_tmp.card[3]=c4; if((flag = pc_additem(sd,&item_tmp,amount))) { clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,amount,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } //Logs items, got from (N)PC scripts [Lupus] @@ -6269,7 +6269,7 @@ BUILDIN_FUNC(makeitem) else item_tmp.identify=itemdb_isidentified(nameid); - map_addflooritem(&item_tmp,amount,m,x,y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,0); } return 0; @@ -9806,7 +9806,7 @@ BUILDIN_FUNC(successremovecards) if((flag=pc_additem(sd,&item_tmp,1))){ // 持てないならドロップ clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } }while(c--); @@ -9831,7 +9831,7 @@ BUILDIN_FUNC(successremovecards) if((flag=pc_additem(sd,&item_tmp,1))){ // もてないならドロップ clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } clif_misceffect(&sd->bl,3); return 0; @@ -9883,7 +9883,7 @@ BUILDIN_FUNC(failedremovecards) if((flag=pc_additem(sd,&item_tmp,1))){ clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -9920,7 +9920,7 @@ BUILDIN_FUNC(failedremovecards) if((flag=pc_additem(sd,&item_tmp,1))){ clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } clif_misceffect(&sd->bl,2); @@ -12219,13 +12219,19 @@ BUILDIN_FUNC(query_sql) //Allows escaping of a given string. BUILDIN_FUNC(escape_sql) { - const char *query; - char *t_query; - query = script_getstr(st,2); - - t_query = aMallocA((strlen(query)*2+1)*sizeof(char)); - jstrescapecpy(t_query,query); - script_pushstr(st,t_query); + const char *str; + char *esc_str; + size_t len; + + str = script_getstr(st,2); + len = strlen(str); + esc_str = aMallocA(len*2+1); +#if defined(TXT_ONLY) + jstrescapecpy(esc_str, str); +#else + Sql_EscapeStringLen(mmysql_handle, esc_str, str, len); +#endif + script_pushstr(st, esc_str); return 0; } diff --git a/src/map/skill.c b/src/map/skill.c index d5462eef8..173de5c0b 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -4624,7 +4624,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in eflag = pc_additem(sd,&item_tmp,1); if(eflag) { clif_additem(sd,0,0,eflag); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } break; @@ -5206,7 +5206,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in item_tmp.identify = 1; if(item_tmp.nameid && (flag=pc_additem(sd,&item_tmp,skill_db[su->group->skill_id].amount[i]))){ clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,skill_db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,skill_db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -5216,7 +5216,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in item_tmp.identify = 1; if(item_tmp.nameid && (flag=pc_additem(sd,&item_tmp,1))){ clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } } @@ -10271,7 +10271,7 @@ int skill_unit_timer_sub (struct block_list *bl, va_list ap) memset(&item_tmp,0,sizeof(item_tmp)); item_tmp.nameid=1065; item_tmp.identify=1; - map_addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,NULL,NULL,NULL,0); + map_addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0); } skill_delunit(unit, 0); break; @@ -10907,7 +10907,7 @@ int skill_produce_mix (struct map_session_data *sd, int skill_id, int nameid, in if (tmp_item.amount) { //Success if((flag = pc_additem(sd,&tmp_item,tmp_item.amount))) { clif_additem(sd,0,0,flag); - map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } return 1; } @@ -10982,7 +10982,7 @@ int skill_arrow_create (struct map_session_data *sd, int nameid) continue; if((flag = pc_additem(sd,&tmp_item,tmp_item.amount))) { clif_additem(sd,0,0,flag); - map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0); + map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } } |