Przeglądaj źródła

Removed redundant 'subnet' s_subnet structure variable.
Removed duplicate code from the sql charserver that somehow appeared after the tmpsql merge.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11333 54d463be-8e91-2dee-dedb-b68131a5f0ec

ultramage 17 lat temu
rodzic
commit
25ccf137f4
5 zmienionych plików z 39 dodań i 65 usunięć
  1. 2 0
      Changelog-Trunk.txt
  2. 13 19
      src/char/char.c
  3. 12 34
      src/char_sql/char.c
  4. 6 6
      src/login/login.c
  5. 6 6
      src/login_sql/login.c

+ 2 - 0
Changelog-Trunk.txt

@@ -3,6 +3,8 @@ 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/30
+	* Removed redundant 'subnet' s_subnet structure variable. [ultramage]
 2007/09/28
 	* Changed back the query to get the friends of a character to a LEFT JOIN.
 	* Setting the item script variables to NULL when they are freed. (bugreport:142 ?)

+ 13 - 19
src/char/char.c

@@ -96,8 +96,7 @@ int log_inter = 1;	// loggin inter or not [devil]
 static int online_check = 1; //If one, it won't let players connect when their account is already registered online and will send the relevant map server a kick user request. [Skotlex]
 
 // Advanced subnet check [LuzZza]
-struct _subnet {
-	uint32 subnet;
+struct s_subnet {
 	uint32 mask;
 	uint32 char_ip;
 	uint32 map_ip;
@@ -3331,20 +3330,14 @@ static int char_mapif_init(int fd)
 int lan_subnetcheck(uint32 ip)
 {
 	int i;
-	
-	for(i = 0; i < subnet_count; i++) {
-	
-		if((subnet[i].subnet & subnet[i].mask) == (ip & subnet[i].mask)) {
-			
-			ShowInfo("Subnet check [%u.%u.%u.%u]: Matches "CL_CYAN"%u.%u.%u.%u/%u.%u.%u.%u"CL_RESET"\n",
-				CONVIP(ip), CONVIP(subnet[i].subnet), CONVIP(subnet[i].mask));
-			
-			return subnet[i].map_ip;
-		}
+	ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) );
+	if ( i < subnet_count ) {
+		ShowInfo("Subnet check [%u.%u.%u.%u]: Matches "CL_CYAN"%u.%u.%u.%u/%u.%u.%u.%u"CL_RESET"\n", CONVIP(ip), CONVIP(subnet[i].char_ip & subnet[i].mask), CONVIP(subnet[i].mask));
+		return subnet[i].char_ip;
+	} else {
+		ShowInfo("Subnet check [%u.%u.%u.%u]: "CL_CYAN"WAN"CL_RESET"\n", CONVIP(ip));
+		return 0;
 	}
-	
-	ShowInfo("Subnet check [%u.%u.%u.%u]: "CL_CYAN"WAN"CL_RESET"\n", CONVIP(ip));
-	return 0;
 }
 
 int parse_char(int fd)
@@ -4033,13 +4026,14 @@ int char_lan_config_read(const char *lancfgName)
 		remove_control_chars(w3);
 		remove_control_chars(w4);
 
-		if(strcmpi(w1, "subnet") == 0) {
-	
+		if( strcmpi(w1, "subnet") == 0 )
+		{
 			subnet[subnet_count].mask = str2ip(w2);
 			subnet[subnet_count].char_ip = str2ip(w3);
 			subnet[subnet_count].map_ip = str2ip(w4);
-			subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask;
-			if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) {
+
+			if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) )
+			{
 				ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4);
 				continue;
 			}

+ 12 - 34
src/char_sql/char.c

@@ -125,7 +125,6 @@ static int online_check = 1; //If one, it won't let players connect when their a
 
 // Advanced subnet check [LuzZza]
 struct s_subnet {
-	uint32 subnet;
 	uint32 mask;
 	uint32 char_ip;
 	uint32 map_ip;
@@ -2799,20 +2798,14 @@ int char_mapif_init(int fd)
 int lan_subnetcheck(uint32 ip)
 {
 	int i;
-	
-	for(i = 0; i < subnet_count; i++) {
-	
-		if((subnet[i].subnet & subnet[i].mask) == (ip & subnet[i].mask)) {
-			
-			ShowInfo("Subnet check [%u.%u.%u.%u]: Matches "CL_CYAN"%u.%u.%u.%u/%u.%u.%u.%u"CL_RESET"\n",
-				CONVIP(ip), CONVIP(subnet[i].subnet), CONVIP(subnet[i].mask));
-			
-			return subnet[i].map_ip;
-		}
+	ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) );
+	if( i < subnet_count ) {
+		ShowInfo("Subnet check [%u.%u.%u.%u]: Matches "CL_CYAN"%u.%u.%u.%u/%u.%u.%u.%u"CL_RESET"\n", CONVIP(ip), CONVIP(subnet[i].char_ip & subnet[i].mask), CONVIP(subnet[i].mask));
+		return subnet[i].char_ip;
+	} else {
+		ShowInfo("Subnet check [%u.%u.%u.%u]: "CL_CYAN"WAN"CL_RESET"\n", CONVIP(ip));
+		return 0;
 	}
-	
-	ShowInfo("Subnet check [%u.%u.%u.%u]: "CL_CYAN"WAN"CL_RESET"\n", CONVIP(ip));
-	return 0;
 }
 
 int parse_char(int fd)
@@ -3005,22 +2998,6 @@ int parse_char(int fd)
 			WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip);
 			WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
 			WFIFOSET(fd,28);
-		}
-		{
-			//Send player to map
-			uint32 subnet_map_ip;
-			char map_name[MAP_NAME_LENGTH_EXT];
-			snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(char_dat.last_point.map));	
-			WFIFOHEAD(fd,28);
-			WFIFOW(fd,0) = 0x71;
-			WFIFOL(fd,2) = char_dat.char_id;
-			memcpy(WFIFOP(fd,6), map_name, MAP_NAME_LENGTH_EXT);
-			
-			// Advanced subnet check [LuzZza]
-			subnet_map_ip = lan_subnetcheck(ipl);
-			WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip);
-			WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
-			WFIFOSET(fd,28);
 		}
 			if (auth_fifo_pos >= AUTH_FIFO_SIZE)
 				auth_fifo_pos = 0;
@@ -3490,13 +3467,14 @@ int char_lan_config_read(const char *lancfgName)
 		remove_control_chars(w3);
 		remove_control_chars(w4);
 
-		if(strcmpi(w1, "subnet") == 0) {
-	
+		if( strcmpi(w1, "subnet") == 0 )
+		{
 			subnet[subnet_count].mask = str2ip(w2);
 			subnet[subnet_count].char_ip = str2ip(w3);
 			subnet[subnet_count].map_ip = str2ip(w4);
-			subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask;
-			if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) {
+
+			if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) )
+			{
 				ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4);
 				continue;
 			}

+ 6 - 6
src/login/login.c

@@ -54,7 +54,6 @@ struct mmo_char_server server[MAX_SERVERS]; // char server data
 
 // Advanced subnet check [LuzZza]
 struct s_subnet {
-	uint32 subnet;
 	uint32 mask;
 	uint32 char_ip;
 	uint32 map_ip;
@@ -2935,7 +2934,7 @@ int parse_admin(int fd)
 int lan_subnetcheck(uint32 ip)
 {
 	int i;
-	ARR_FIND( 0, subnet_count, i, subnet[i].subnet == (ip & subnet[i].mask) );
+	ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) );
 	return ( i < subnet_count ) ? subnet[i].char_ip : 0;
 }
 
@@ -3423,13 +3422,14 @@ int login_lan_config_read(const char *lancfgName)
 		remove_control_chars(w3);
 		remove_control_chars(w4);
 
-		if(strcmpi(w1, "subnet") == 0) {
-
+		if( strcmpi(w1, "subnet") == 0 )
+		{
 			subnet[subnet_count].mask = str2ip(w2);
 			subnet[subnet_count].char_ip = str2ip(w3);
 			subnet[subnet_count].map_ip = str2ip(w4);
-			subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask;
-			if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) {
+
+			if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip&subnet[subnet_count].mask) )
+			{
 				ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4);
 				continue;
 			}

+ 6 - 6
src/login_sql/login.c

@@ -54,7 +54,6 @@ struct mmo_char_server server[MAX_SERVERS]; // char server data
 
 // Advanced subnet check [LuzZza]
 struct s_subnet {
-	uint32 subnet;
 	uint32 mask;
 	uint32 char_ip;
 	uint32 map_ip;
@@ -1204,7 +1203,7 @@ int parse_fromchar(int fd)
 int lan_subnetcheck(uint32 ip)
 {
 	int i;
-	ARR_FIND( 0, subnet_count, i, subnet[i].subnet == (ip & subnet[i].mask) );
+	ARR_FIND( 0, subnet_count, i, (subnet[i].char_ip & subnet[i].mask) == (ip & subnet[i].mask) );
 	return ( i < subnet_count ) ? subnet[i].char_ip : 0;
 }
 
@@ -1677,13 +1676,14 @@ int login_lan_config_read(const char *lancfgName)
 		remove_control_chars(w3);
 		remove_control_chars(w4);
 
-		if(strcmpi(w1, "subnet") == 0) {
-
+		if( strcmpi(w1, "subnet") == 0 )
+		{
 			subnet[subnet_count].mask = str2ip(w2);
 			subnet[subnet_count].char_ip = str2ip(w3);
 			subnet[subnet_count].map_ip = str2ip(w4);
-			subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask;
-			if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) {
+
+			if( (subnet[subnet_count].char_ip & subnet[subnet_count].mask) != (subnet[subnet_count].map_ip & subnet[subnet_count].mask) )
+			{
 				ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4);
 				continue;
 			}