summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-11 13:51:20 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-11 13:51:20 +0000
commit119196fdc5fe9fd6746580f8bf015961cdd562f1 (patch)
tree552e9cea9dff2bf2b8af7e51e906622d96502b5c
parent770b5fc92df304517a37e701026b6f87f064a488 (diff)
downloadhercules-119196fdc5fe9fd6746580f8bf015961cdd562f1.tar.gz
hercules-119196fdc5fe9fd6746580f8bf015961cdd562f1.tar.bz2
hercules-119196fdc5fe9fd6746580f8bf015961cdd562f1.tar.xz
hercules-119196fdc5fe9fd6746580f8bf015961cdd562f1.zip
- Modified the login-sql server to do the ip-ban check only on the auth-packets instead of on every packet.
- Modified Cart Termination so the damage is scaled accordingly with the max-cart-weight setting (so max damage is always the same). Thanks to aresdfe for the idea. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7609 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt4
-rw-r--r--src/login_sql/login.c96
-rw-r--r--src/map/battle.c6
3 files changed, 60 insertions, 46 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 0ec0556b2..98c7a1a4e 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.
+
+2006/07/11
+ * Modified the login-sql server to do the ip-ban check only on the
+ auth-packets instead of on every packet. [Skotlex]
2006/07/10
* Corrected Warp Portal being unable to warp people who are standing on it
on the moment it triggers. [Skotlex]
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index fe1583429..2fe313d1e 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -1452,6 +1452,47 @@ int lan_subnetcheck(long *p) {
return 0;
}
+int login_ip_ban_check(char p*)
+{
+ MYSQL_RES* sql_res;
+ MYSQL_ROW sql_row;
+ //ip ban
+ //p[0], p[1], p[2], p[3]
+ //request DB connection
+ //check
+ sprintf(tmpsql, "SELECT count(*) FROM `ipbanlist` WHERE `list` = '%d.*.*.*' OR `list` = '%d.%d.*.*' OR `list` = '%d.%d.%d.*' OR `list` = '%d.%d.%d.%d'",
+ p[0], p[0], p[1], p[0], p[1], p[2], p[0], p[1], p[2], p[3]);
+ 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);
+ // close connection because we can't verify their connectivity.
+ return 1;
+ }
+ sql_res = mysql_store_result(&mysql_handle) ;
+ sql_row = sql_res?mysql_fetch_row(sql_res):NULL; //row fetching
+
+ if(!sql_row) return 1; //Shouldn't happen, but just in case...
+
+ if (atoi(sql_row[0]) == 0) { //No ban
+ mysql_free_result(sql_res);
+ return 0;
+ }
+
+ // ip ban ok.
+ ShowWarning("packet from banned ip : %d.%d.%d.%d\n" RETCODE, p[0], p[1], p[2], p[3]);
+
+ if (log_login)
+ {
+ sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%lu', 'unknown','-3', 'ip banned')", loginlog_db, *((ulong *)p));
+ // query
+ 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);
+ }
+ }
+ mysql_free_result(sql_res);
+ return 1;
+}
//----------------------------------------------------------------------------------------
// Default packet parsing (normal players or administation/char-server connection requests)
//----------------------------------------------------------------------------------------
@@ -1462,7 +1503,6 @@ int parse_login(int fd) {
MYSQL_ROW sql_row = NULL;
char t_uid[100];
- //int sql_fields, sql_cnt;
struct mmo_account account;
long subnet_char_ip;
int packet_len;
@@ -1474,47 +1514,8 @@ int parse_login(int fd) {
sprintf(ip, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
memset(&account, 0, sizeof(account));
+ i = RFIFOREST(fd)>=2?RFIFOW(fd,0):0;
- if (ipban > 0) {
- //ip ban
- //p[0], p[1], p[2], p[3]
- //request DB connection
- //check
- sprintf(tmpsql, "SELECT count(*) FROM `ipbanlist` WHERE `list` = '%d.*.*.*' OR `list` = '%d.%d.*.*' OR `list` = '%d.%d.%d.*' OR `list` = '%d.%d.%d.%d'",
- p[0], p[0], p[1], p[0], p[1], p[2], p[0], p[1], p[2], p[3]);
- 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);
- // close connection because we can't verify their connectivity.
- session[fd]->eof = 1;
- } else { //Avoid entering as it causes a crash.
- sql_res = mysql_store_result(&mysql_handle) ;
- sql_row = mysql_fetch_row(sql_res); //row fetching
-
- if (atoi(sql_row[0]) >0) {
- // ip ban ok.
- ShowWarning("packet from banned ip : %d.%d.%d.%d\n" RETCODE, p[0], p[1], p[2], p[3]);
- if (log_login)
- {
- sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%lu', 'unknown','-3', 'ip banned')", loginlog_db, *((ulong *)p));
-
- // query
- 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);
- }
- }
- ShowInfo ("close session connection...\n");
-
- // close connection
- session[fd]->eof = 1;
-
- } else {
- ShowInfo ("packet from ip (ban check ok) : %d.%d.%d.%d" RETCODE, p[0], p[1], p[2], p[3]);
- }
- mysql_free_result(sql_res);
- }
- }
if (session[fd]->eof) {
for(i = 0; i < MAX_SERVERS; i++)
if (server_fd[i] == fd)
@@ -1523,7 +1524,7 @@ int parse_login(int fd) {
return 0;
}
- while(RFIFOREST(fd)>=2){
+ while(RFIFOREST(fd)>=2 && !session[fd]->eof){
ShowDebug("parse_login : %d %d packet case=%x\n", fd, RFIFOREST(fd), RFIFOW(fd,0));
switch(RFIFOW(fd,0)){
@@ -1542,9 +1543,18 @@ int parse_login(int fd) {
case 0x277: // New login packet
case 0x64: // request client login
case 0x01dd: // request client login with encrypt
+
packet_len = RFIFOREST(fd);
- switch(RFIFOW(fd, 0)){
+ //Perform ip-ban check ONLY on login packets
+ if (ipban > 0 && login_ip_ban_check(p))
+ {
+ RFIFOSKIP(fd,packet_len);
+ session[fd]->eof = 1;
+ break;
+ }
+
+ switch(RFIFOW(fd,0)){
case 0x64:
if(packet_len < 55)
return 0;
diff --git a/src/map/battle.c b/src/map/battle.c
index c143fc470..bbe1e8279 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -1423,10 +1423,10 @@ static struct Damage battle_calc_weapon_attack(
case WS_CARTTERMINATION:
i = (10 * (16 - skill_lv));
if (i < 1) i = 1;
- if(sd && sd->cart_weight > 0)
- skillratio += sd->cart_weight / i - 100;
+ if(sd && sd->cart_weight > 0) //Preserve damage ratio when max cart weight is changed.
+ skillratio += (sd->cart_weight * 8000) / (i * battle_config.max_cart_weight) - 100;
else if (!sd)
- skillratio += battle_config.max_cart_weight / i - 100;
+ skillratio += 8000 / i - 100;
flag.cardfix = 0;
break;
case TK_DOWNKICK: