diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 8 | ||||
-rw-r--r-- | src/map/chrif.c | 5 | ||||
-rw-r--r-- | src/map/clif.c | 16 | ||||
-rw-r--r-- | src/map/elemental.c | 5 | ||||
-rw-r--r-- | src/map/homunculus.c | 1 | ||||
-rw-r--r-- | src/map/mob.c | 30 | ||||
-rw-r--r-- | src/map/npc.c | 8 | ||||
-rw-r--r-- | src/map/script.c | 8 | ||||
-rw-r--r-- | src/map/skill.c | 120 |
9 files changed, 82 insertions, 119 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index feda37060..59222a7d5 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2406,14 +2406,14 @@ ACMD_FUNC(produce) return -1; } - item_id = 0; - if ((item_data = itemdb_searchname(item_name)) == NULL && - (item_data = itemdb_exists(atoi(item_name))) == NULL) - { + if ( (item_data = itemdb_searchname(item_name)) == NULL && + (item_data = itemdb_exists(atoi(item_name))) == NULL ) { clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment. return -1; } + item_id = item_data->nameid; + if (itemdb_isequip2(item_data)) { if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE) attribute = ATTRIBUTE_NORMAL; diff --git a/src/map/chrif.c b/src/map/chrif.c index 7d11507a1..23b7b372f 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -647,20 +647,17 @@ void chrif_authok(int fd) } // client authentication failed -void chrif_authfail(int fd) -{ +void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (but is available) */ int account_id; int char_id; uint32 login_id1; char sex; - uint32 ip; struct auth_node* node; account_id = RFIFOL(fd,2); char_id = RFIFOL(fd,6); login_id1 = RFIFOL(fd,10); sex = RFIFOB(fd,14); - ip = ntohl(RFIFOL(fd,15)); node = chrif_search(account_id); if( node != NULL && diff --git a/src/map/clif.c b/src/map/clif.c index 9ee0a27bf..b71c8e21c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -3054,8 +3054,8 @@ void clif_changelook(struct block_list *bl,int type,int val) val = sd->inventory_data[n]->view_id; else val = sd->status.inventory[n].nameid; - } - val = 0; + } else + val = 0; } #endif //Shoes? No packet uses this.... @@ -10047,14 +10047,14 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) /// /b /nb (CZ_BROADCAST). /// Request to broadcast a message on whole server. /// 0099 <packet len>.W <text>.?B 00 -void clif_parse_Broadcast(int fd, struct map_session_data* sd) -{ +void clif_parse_Broadcast(int fd, struct map_session_data* sd) { char command[CHAT_SIZE_MAX+11]; char* msg = (char*)RFIFOP(fd,4); unsigned int len = RFIFOW(fd,2)-4; // as the length varies depending on the command used, just block unreasonably long strings - len = mes_len_check(msg, len, CHAT_SIZE_MAX); + mes_len_check(msg, len, CHAT_SIZE_MAX); + sprintf(command, "%ckami %s", atcommand_symbol, msg); is_atcommand(fd, sd, command, 1); } @@ -11248,7 +11248,7 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd) unsigned int len = RFIFOW(fd,2)-4; // as the length varies depending on the command used, just block unreasonably long strings - len = mes_len_check(msg, len, CHAT_SIZE_MAX); + mes_len_check(msg, len, CHAT_SIZE_MAX); sprintf(command, "%clkami %s", atcommand_symbol, msg); is_atcommand(fd, sd, command, 1); @@ -12919,11 +12919,11 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) { struct map_session_data *f_sd; - int char_id, account_id; + int account_id; char reply; account_id = RFIFOL(fd,2); - char_id = RFIFOL(fd,6); + //char_id = RFIFOL(fd,6); #if PACKETVER < 6 reply = RFIFOB(fd,10); #else diff --git a/src/map/elemental.c b/src/map/elemental.c index 9a9a3d4f5..ae3c738d8 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -605,14 +605,14 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_ target = map_id2bl(ed->ud.target); if( !target ) - map_foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, ed->db->range2, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); + map_foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl)); if( !target ) { //No targets available. elemental_unlocktarget(ed); return 1; } - if( battle_check_range(&ed->bl,target,ed->db->range2) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. + if( battle_check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill. if( elemental_action(ed,target,tick) ) return 1; } @@ -786,7 +786,6 @@ int read_elemental_skilldb(void) { skillmode = atoi(str[3]); if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) { ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k); - skillmode = EL_SKILLMODE_PASIVE; continue; } ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skillid ); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 3856dd939..06b7343cd 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -183,7 +183,6 @@ int merc_hom_calc_skilltree(struct homun_data *hd) } f = 1; - id = c = 0; } c = hd->homunculus.class_ - HM_CLASS_BASE; diff --git a/src/map/mob.c b/src/map/mob.c index 14a520ab8..6266f3042 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1189,16 +1189,13 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap) return 0; } -static int mob_warpchase_sub(struct block_list *bl,va_list ap) -{ - struct mob_data* md; +static int mob_warpchase_sub(struct block_list *bl,va_list ap) { struct block_list *target; struct npc_data **target_nd; struct npc_data *nd; int *min_distance; int cur_distance; - md=va_arg(ap,struct mob_data *); target= va_arg(ap, struct block_list*); target_nd= va_arg(ap, struct npc_data**); min_distance= va_arg(ap, int*); @@ -1410,7 +1407,7 @@ int mob_warpchase(struct mob_data *md, struct block_list *target) //Search for warps within mob's viewing range. map_foreachinrange (mob_warpchase_sub, &md->bl, - md->db->range2, BL_NPC, md, target, &warp, &distance); + md->db->range2, BL_NPC, target, &warp, &distance); if (warp && unit_walktobl(&md->bl, &warp->bl, 1, 1)) return 1; @@ -3903,20 +3900,17 @@ static int mob_read_sqldb(void) const char* mob_db_name[] = { mob_db_db, mob_db2_db }; int fi; - for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) - { + for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) { uint32 lines = 0, count = 0; // retrieve all rows from the mob database - if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) - { + if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", mob_db_name[fi]) ) { Sql_ShowDebug(mmysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) - { + while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) { // wrap the result into a TXT-compatible format char line[1024]; char* str[31+2*MAX_MVP_DROP+2*MAX_MOB_DROP]; @@ -3945,7 +3939,6 @@ static int mob_read_sqldb(void) Sql_FreeResult(mmysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_db_name[fi]); - count = 0; } return 0; } @@ -4476,27 +4469,23 @@ static int mob_read_sqlskilldb(void) const char* mob_skill_db_name[] = { mob_skill_db_db, mob_skill_db2_db }; int fi; - if( battle_config.mob_skill_rate == 0 ) - { + if( battle_config.mob_skill_rate == 0 ) { ShowStatus("Mob skill use disabled. Not reading mob skills.\n"); return 0; } - for( fi = 0; fi < ARRAYLENGTH(mob_skill_db_name); ++fi ) - { + for( fi = 0; fi < ARRAYLENGTH(mob_skill_db_name); ++fi ) { uint32 lines = 0, count = 0; // retrieve all rows from the mob skill database - if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) - { + if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `%s`", mob_skill_db_name[fi]) ) { Sql_ShowDebug(mmysql_handle); continue; } // process rows one by one - while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) - { + while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) ) { // wrap the result into a TXT-compatible format char* str[19]; char* dummy = ""; @@ -4518,7 +4507,6 @@ static int mob_read_sqlskilldb(void) Sql_FreeResult(mmysql_handle); ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, mob_skill_db_name[fi]); - count = 0; } return 0; } diff --git a/src/map/npc.c b/src/map/npc.c index d5c7c021a..97b41e033 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -814,14 +814,13 @@ int npc_event(struct map_session_data* sd, const char* eventname, int ontouch) int npc_touch_areanpc_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd; - int pc_id,npc_id; + int pc_id; char *name; nullpo_ret(bl); nullpo_ret((sd = map_id2sd(bl->id))); pc_id = va_arg(ap,int); - npc_id = va_arg(ap,int); name = va_arg(ap,char*); if( pc_ishiding(sd) ) @@ -854,7 +853,7 @@ int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) nd->touching_id = sd->touching_id = 0; snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script_config.ontouch_name); - map_forcountinarea(npc_touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,nd->bl.id,name); + map_forcountinarea(npc_touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name); } return 0; } @@ -1649,11 +1648,10 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) // delete items for( i = 0; i < n; i++ ) { - int nameid, amount, idx; + int amount, idx; idx = item_list[i*2]-2; amount = item_list[i*2+1]; - nameid = sd->status.inventory[idx].nameid; if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET ) { diff --git a/src/map/script.c b/src/map/script.c index ff12cc06f..dfa5cec7f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1328,15 +1328,15 @@ const char* parse_subexpr(const char* p,int limit) p=skip_space(p); - if(*p=='-'){ - tmpp=skip_space(p+1); - if(*tmpp==';' || *tmpp==','){ + if( *p == '-' ){ + tmpp = skip_space(p+1); + if( *tmpp == ';' || *tmpp == ',' ){ add_scriptl(LABEL_NEXTLINE); p++; return p; } } - tmpp=p; + if((op=C_NEG,*p=='-') || (op=C_LNOT,*p=='!') || (op=C_NOT,*p=='~')){ p=parse_subexpr(p+1,10); add_scriptc(op); diff --git a/src/map/skill.c b/src/map/skill.c index 0150cd0c5..3b06d9fea 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1928,7 +1928,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in j = sd->equip_index[i]; if (j < 0 || sd->status.inventory[j].attribute == 1 || !sd->inventory_data[j]) continue; - flag = 0; + switch(i) { case EQI_HEAD_TOP: //Upper Head flag = (where&EQP_HELM); @@ -7383,7 +7383,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in i = skill_get_splash(skillid,skilllv); if( skillid == LG_EARTHDRIVE ) { int dummy = 1; - map_foreachinarea(skill_cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, &dummy, src); + map_foreachinarea(skill_cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, src); } map_foreachinrange(skill_area_sub, bl,i,BL_CHAR, src,skillid,skilllv,tick,flag|BCT_ENEMY|1,skill_castend_damage_id); @@ -7760,8 +7760,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in if( status_isimmune(bl) || !tsc ) break; - if( flag&1 ) - { + if( flag&1 ) { if( bl->id == skill_area_temp[1] ) break; // Already work on this target @@ -7769,24 +7768,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in status_change_end(bl,SC_STONE,INVALID_TIMER); else status_change_start(bl,SC_STONE,10000,skilllv,0,0,1000,(8+2*skilllv)*1000,2); - } - else - { + } else { int rate = 40 + 8 * skilllv + ( sd? sd->status.job_level : 50 ) / 4; // IroWiki says Rate should be reduced by target stats, but currently unknown - if( rnd()%100 < rate ) - { // Success on First Target - rate = 0; + if( rnd()%100 < rate ) { // Success on First Target if( !tsc->data[SC_STONE] ) rate = status_change_start(bl,SC_STONE,10000,skilllv,0,0,1000,(8+2*skilllv)*1000,2); - else - { + else { rate = 1; status_change_end(bl,SC_STONE,INVALID_TIMER); } - if( rate ) - { + if( rate ) { skill_area_temp[1] = bl->id; map_foreachinrange(skill_area_sub,bl,skill_get_splash(skillid,skilllv),BL_CHAR,src,skillid,skilllv,tick,flag|BCT_ENEMY|1,skill_castend_nodamage_id); } @@ -9740,7 +9733,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk int dummy = 1; clif_skill_poseffect(src,skillid,skilllv,x,y,tick); i = skill_get_splash(skillid, skilllv); - map_foreachinarea(skill_cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, &dummy, src); + map_foreachinarea(skill_cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, src); } else { if (sd) clif_skill_fail(sd,skillid,USESKILL_FAIL_LEVEL,0); return 1; @@ -10738,7 +10731,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, short skilli } if( range <= 0 ) - map_foreachincell(skill_cell_overlap,src->m,ux,uy,BL_SKILL,skillid,&alive, src); + map_foreachincell(skill_cell_overlap,src->m,ux,uy,BL_SKILL,skillid, src); if( !alive ) continue; @@ -10867,7 +10860,6 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un sg->val1 = (count<<16)|working; pc_setpos(sd,m,x,y,CLR_TELEPORT); - sg = src->group; // avoid dangling pointer (pc_setpos can cause deletion of 'sg') } } else if(bl->type == BL_MOB && battle_config.mob_warp&2) { int m = map_mapindex2mapid(sg->val3); @@ -11212,17 +11204,15 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns case UNT_ELECTRICSHOCKER: if( bl->id != ss->id ) { - int sec = skill_get_time2(sg->skill_id, sg->skill_lv); if( status_get_mode(bl)&MD_BOSS ) break; - if( status_change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,sec, 8) ) { - const struct TimerData* td = tsc->data[type]?get_timer(tsc->data[type]->timer):NULL; - if( td ) - sec = DIFF_TICK(td->tick, tick); + if( status_change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill_get_time2(sg->skill_id, sg->skill_lv), 8) ) { + map_moveblock(bl, src->bl.x, src->bl.y, tick); clif_fixpos(bl); - } else - sec = 3000; //Couldn't trap it? + + } + map_foreachinrange(skill_trap_splash, &src->bl, skill_get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick); sg->unit_id = UNT_USED_TRAPS; //Changed ID so it does not invoke a for each in area again. } @@ -12994,17 +12984,13 @@ int skill_check_condition_castend(struct map_session_data* sd, short skill, shor if( skill == NC_MAGICDECOY ) mob_class = 2043; - if( battle_config.land_skill_limit && maxcount > 0 && ( battle_config.land_skill_limit&BL_PC ) ) - { - if( skill == NC_MAGICDECOY ) - { + if( battle_config.land_skill_limit && maxcount > 0 && ( battle_config.land_skill_limit&BL_PC ) ) { + if( skill == NC_MAGICDECOY ) { for( j = mob_class; j <= 2046; j++ ) - i = map_foreachinmap(skill_check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill, &c); - } - else - i = map_foreachinmap(skill_check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill, &c); - if( c >= maxcount ) - { + map_foreachinmap(skill_check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill, &c); + } else + map_foreachinmap(skill_check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill, &c); + if( c >= maxcount ) { clif_skill_fail(sd , skill, USESKILL_FAIL_LEVEL, 0); return 0; } @@ -13382,37 +13368,41 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, short /*========================================== * Does cast-time reductions based on dex, item bonuses and config setting *------------------------------------------*/ -int skill_castfix (struct block_list *bl, int skill_id, int skill_lv) -{ +int skill_castfix (struct block_list *bl, int skill_id, int skill_lv) { int time = skill_get_cast(skill_id, skill_lv); - struct map_session_data *sd; nullpo_ret(bl); - sd = BL_CAST(BL_PC, bl); #ifndef RENEWAL_CAST - // calculate base cast time (reduced by dex) - if( !(skill_get_castnodex(skill_id, skill_lv)&1) ) { - int scale = battle_config.castrate_dex_scale - status_get_dex(bl); - if( scale > 0 ) // not instant cast - time = time * scale / battle_config.castrate_dex_scale; - else - return 0; // instant cast - } - - // calculate cast time reduced by item/card bonuses - if( !(skill_get_castnodex(skill_id, skill_lv)&4) && sd ) { - int i; - if( sd->castrate != 100 ) - time = time * sd->castrate / 100; - for( i = 0; i < ARRAYLENGTH(sd->skillcast) && sd->skillcast[i].id; i++ ) + struct map_session_data *sd; + + sd = BL_CAST(BL_PC, bl); + + // calculate base cast time (reduced by dex) + if( !(skill_get_castnodex(skill_id, skill_lv)&1) ) { + int scale = battle_config.castrate_dex_scale - status_get_dex(bl); + if( scale > 0 ) // not instant cast + time = time * scale / battle_config.castrate_dex_scale; + else + return 0; // instant cast + } + + // calculate cast time reduced by item/card bonuses + if( !(skill_get_castnodex(skill_id, skill_lv)&4) && sd ) { - if( sd->skillcast[i].id == skill_id ) + int i; + if( sd->castrate != 100 ) + time = time * sd->castrate / 100; + for( i = 0; i < ARRAYLENGTH(sd->skillcast) && sd->skillcast[i].id; i++ ) { - time+= time * sd->skillcast[i].val / 100; - break; + if( sd->skillcast[i].id == skill_id ) + { + time+= time * sd->skillcast[i].val / 100; + break; + } } } + } #endif // config cast time multiplier @@ -14328,27 +14318,22 @@ static int skill_cell_overlap(struct block_list *bl, va_list ap) int skillid; int *alive; struct skill_unit *unit; - struct block_list *src; skillid = va_arg(ap,int); alive = va_arg(ap,int *); - src = va_arg(ap,struct block_list *); unit = (struct skill_unit *)bl; if (unit == NULL || unit->group == NULL || (*alive) == 0) return 0; - switch (skillid) - { + switch (skillid) { case SA_LANDPROTECTOR: - if( unit->group->skill_id == SA_LANDPROTECTOR ) - { //Check for offensive Land Protector to delete both. [Skotlex] + if( unit->group->skill_id == SA_LANDPROTECTOR ) {//Check for offensive Land Protector to delete both. [Skotlex] (*alive) = 0; skill_delunit(unit); return 1; } - if( !(skill_get_inf2(unit->group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP)) ) - { //It deletes everything except songs/dances and traps + if( !(skill_get_inf2(unit->group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP)) ) { //It deletes everything except songs/dances and traps skill_delunit(unit); return 1; } @@ -14383,8 +14368,7 @@ static int skill_cell_overlap(struct block_list *bl, va_list ap) */ break; case PF_FOGWALL: - switch(unit->group->skill_id) - { + switch(unit->group->skill_id) { case SA_VOLCANO: //Can't be placed on top of these case SA_VIOLENTGALE: (*alive) = 0; @@ -14405,9 +14389,7 @@ static int skill_cell_overlap(struct block_list *bl, va_list ap) break; } - if (unit->group->skill_id == SA_LANDPROTECTOR && - !(skill_get_inf2(skillid)&(INF2_SONG_DANCE|INF2_TRAP))) - { //It deletes everything except songs/dances/traps + if (unit->group->skill_id == SA_LANDPROTECTOR && !(skill_get_inf2(skillid)&(INF2_SONG_DANCE|INF2_TRAP))) { //It deletes everything except songs/dances/traps (*alive) = 0; return 1; } |