From 5ab87d86bb158110fc7b32d9e1cd9ff39ace37cf Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 10 Aug 2006 14:25:32 +0000 Subject: - Fixed two instances in the login-sql server where the ip in the log-login table was being stored backwards. - Now when a skill's range is 0 and the skill is NOT casted on self, it will take the basic weapon's range (without Vulture/Snake Eye bonus). - Now when a duration is not specified, sc_start/sc_start2/sc_start4 will try to guess the duration by extracting it from the skill_db (it uses skill_get_time on whatever skill is associated to the status-change using val1 as skill-level) - Corrected that extra comma at the end of the Kaensin layout setup. - Some cleanups on trade_tradeaccept to prevent packets being resent when they shouldn't. - Corrected that ALLOW NULL thingie on main.sql git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8229 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/login_sql/login.c | 9 +++++---- src/map/script.c | 26 ++++++++++++++++++++++++++ src/map/skill.c | 18 ++++++++++++++++-- src/map/trade.c | 32 ++++++++++++++------------------ 4 files changed, 61 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 4c9393bc8..7cc240dcf 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -906,6 +906,7 @@ int parse_fromchar(int fd){ MYSQL_ROW sql_row = NULL; unsigned char *p = (unsigned char *) &session[fd]->client_addr.sin_addr.s_addr; + unsigned long ipl = session[fd]->client_addr.sin_addr.s_addr; char ip[16]; sprintf(ip, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); @@ -941,7 +942,7 @@ int parse_fromchar(int fd){ case 0x2709: if (log_login) { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s','%s', 'GM reload request')", loginlog_db, *((unsigned int*)p),server[id].name, RETCODE); + sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s','%s', 'GM reload request')", loginlog_db, (unsigned int)ntohl(ipl),server[id].name, RETCODE); if (mysql_query(&mysql_handle, tmpsql)) { ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); @@ -1452,7 +1453,7 @@ int lan_subnetcheck(long p) { return 0; } -int login_ip_ban_check(unsigned char *p) +int login_ip_ban_check(unsigned char *p, unsigned long ipl) { MYSQL_RES* sql_res; MYSQL_ROW sql_row; @@ -1483,7 +1484,7 @@ int login_ip_ban_check(unsigned char *p) if (log_login) { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', 'unknown','-3', 'ip banned')", loginlog_db, *((unsigned int *)p)); + sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', 'unknown','-3', 'ip banned')", loginlog_db, (unsigned int)ntohl(ipl)); // query if(mysql_query(&mysql_handle, tmpsql)) { ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); @@ -1547,7 +1548,7 @@ int parse_login(int fd) { packet_len = RFIFOREST(fd); //Perform ip-ban check ONLY on login packets - if (ipban > 0 && login_ip_ban_check(p)) + if (ipban > 0 && login_ip_ban_check(p,ipl)) { RFIFOSKIP(fd,packet_len); session[fd]->eof = 1; diff --git a/src/map/script.c b/src/map/script.c index 73b3b6e89..377785fe4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -7571,6 +7571,14 @@ int buildin_sc_start(struct script_state *st) tick/=2; //Thrown potions only last half. val4 = 1; //Mark that this was a thrown sc_effect } + if (type >= 0 && type < SC_MAX && val1 && !tick) + { //When there isn't a duration specified, try to get it from the skill_db + tick = StatusSkillChangeTable[type]; + if (tick) + tick = skill_get_time(tick,val1); + else //Failed to retrieve duration, reset to what it was. + tick = 0; + } if (bl) status_change_start(bl,type,10000,val1,0,0,val4,tick,11); return 0; @@ -7593,6 +7601,15 @@ int buildin_sc_start2(struct script_state *st) else bl = map_id2bl(st->rid); + if (type >= 0 && type < SC_MAX && val1 && !tick) + { //When there isn't a duration specified, try to get it from the skill_db + tick = StatusSkillChangeTable[type]; + if (tick) + tick = skill_get_time(tick,val1); + else //Failed to retrieve duration, reset to what it was. + tick = 0; + } + if (potion_flag==1 && potion_target) { bl = map_id2bl(potion_target); tick/=2; @@ -7625,6 +7642,15 @@ int buildin_sc_start4(struct script_state *st) else bl = map_id2bl(st->rid); + if (type >= 0 && type < SC_MAX && val1 && !tick) + { //When there isn't a duration specified, try to get it from the skill_db + tick = StatusSkillChangeTable[type]; + if (tick) + tick = skill_get_time(tick,val1); + else //Failed to retrieve duration, reset to what it was. + tick = 0; + } + if (potion_flag==1 && potion_target) { bl = map_id2bl(potion_target); tick/=2; diff --git a/src/map/skill.c b/src/map/skill.c index 3d7435dbe..8691aaff0 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -760,6 +760,20 @@ int skill_get_range2 (struct block_list *bl, int id, int lv) return status_get_range(bl); range *=-1; } + + if(!range && !(skill_get_inf(id)&INF_SELF_SKILL)) + { //Use weapon's basic range. + if (bl->type==BL_PC) { + struct map_session_data *sd = (TBL_PC*)bl; + range = sd->equip_index[EQI_HAND_R]; + if (range >= 0 && sd->inventory_data[range]) + range = sd->inventory_data[range]->range; + else + range = 1; //Assume fist range. + } else + range = status_get_range(bl); + } + //TODO: Find a way better than hardcoding the list of skills affected by AC_VULTURE switch (id) { case AC_SHOWER: @@ -10876,8 +10890,8 @@ void skill_init_unit_layout (void) } case NJ_KAENSIN: { - static const int dx[] = {-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,}; - static const int dy[] = { 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,}; + static const int dx[] = {-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; + static const int dy[] = { 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2}; skill_unit_layout[pos].count = 24; memcpy(skill_unit_layout[pos].dx,dx,sizeof(dx)); memcpy(skill_unit_layout[pos].dy,dy,sizeof(dy)); diff --git a/src/map/trade.c b/src/map/trade.c index 3bbf4385b..93f8490d4 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -86,7 +86,10 @@ void trade_tradeack(struct map_session_data *sd, int type) { sd->trade_partner=0; return; } - + + if (target_sd->state.trading || target_sd->trade_partner != sd->bl.id) + return; //Already trading or wrong partner. + //Copied here as well since the original character could had warped. if (type == 3 && pc_isGM(target_sd) < lowest_gm_level && (sd->bl.m != target_sd->bl.m || (sd->bl.x - target_sd->bl.x <= -5 || sd->bl.x - target_sd->bl.x >= 5) || @@ -97,14 +100,15 @@ void trade_tradeack(struct map_session_data *sd, int type) { clif_tradestart(sd, 0); // too far return; } - - clif_tradestart(target_sd, type); - clif_tradestart(sd, type); + + //TODO: Type 4/3? What would 1/2 and the rest do? if (type == 4) { // Cancel sd->state.deal_locked = 0; sd->trade_partner = 0; target_sd->state.deal_locked = 0; target_sd->trade_partner = 0; + clif_tradestart(target_sd, type); + clif_tradestart(sd, type); } if (type == 3) { //Initiate trade @@ -112,21 +116,13 @@ void trade_tradeack(struct map_session_data *sd, int type) { target_sd->state.trading = 1; memset(&sd->deal, 0, sizeof(sd->deal)); memset(&target_sd->deal, 0, sizeof(target_sd->deal)); + clif_tradestart(target_sd, type); + clif_tradestart(sd, type); + if (sd->npc_id) + npc_event_dequeue(sd); + if (target_sd->npc_id) + npc_event_dequeue(target_sd); } - - if (sd->npc_id) - npc_event_dequeue(sd); - if (target_sd->npc_id) - npc_event_dequeue(target_sd); - - /* Why? It should be allowed to bring items from storage to inventory for trading, but not the other way around - * (this is blocked on clif.c) [Skotlex] - //close STORAGE window if it's open. It protects from spooffing packets [Lupus] - if (sd->state.storage_flag == 1) - storage_storageclose(sd); - else if (sd->state.storage_flag == 2) - storage_guild_storageclose(sd); - */ } /*========================================== -- cgit v1.2.3-70-g09d2