diff options
-rw-r--r-- | Changelog-Trunk.txt | 6 | ||||
-rw-r--r-- | src/map/chrif.c | 24 | ||||
-rw-r--r-- | src/map/chrif.h | 1 | ||||
-rw-r--r-- | src/map/intif.c | 23 |
4 files changed, 41 insertions, 13 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 321a49013..a8918a587 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,12 @@ 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/06/03
+ * Added variable other_mapserver_count to chrif.c which holds total count
+ of connected map-servers. By using this we prevent sending unnecessary
+ packets to the char-server when there's no more map-servers connected.
+ [Skotlex]
+ - Affected packets are whispers, announces, party messages, guild messages.
2006/06/02
* Fixed Visual Studio 7.1 Solution File (Login TXT and Map TXT were removed)
* Fixed a bug in unit_can_reach_bl which breaks path seeking when the
diff --git a/src/map/chrif.c b/src/map/chrif.c index 0ec1fdff7..f9a9e7620 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -101,6 +101,8 @@ static int char_port = 6121; static char userid[NAME_LENGTH], passwd[NAME_LENGTH];
static int chrif_state = 0;
static int char_init_done = 0;
+int other_mapserver_count=0; //Holds count of how many other map servers are online (apart of this instance) [Skotlex]
+
//Interval at which map server updates online listing. [Valaris]
#define CHECK_INTERVAL 3600000
//Interval at which map server sends number of connected users. [Skotlex]
@@ -268,10 +270,6 @@ int chrif_recvmap(int fd) int i, j, ip, port;
unsigned char *p = (unsigned char *)&ip;
RFIFOHEAD(fd);
-
- if (chrif_state < 2) // まだ準備中
- return -1;
-
ip = RFIFOL(fd,4);
port = RFIFOW(fd,8);
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
@@ -282,6 +280,7 @@ int chrif_recvmap(int fd) if (battle_config.etc_log)
ShowStatus("recv map on %d.%d.%d.%d:%d (%d maps)\n", p[0], p[1], p[2], p[3], port, j);
+ other_mapserver_count++;
return 0;
}
@@ -294,10 +293,6 @@ int chrif_removemap(int fd){ unsigned char *p = (unsigned char *)&ip;
RFIFOHEAD(fd);
- if(chrif_state < 2){
- return -1; //i dunno, but i know if its 3 the link is ok^^
- }
-
ip = RFIFOL(fd, 4);
port = RFIFOW(fd, 8);
@@ -305,9 +300,9 @@ int chrif_removemap(int fd){ map_eraseipport(RFIFOW(fd, i), ip, port);
}
- if(battle_config.etc_log){
+ other_mapserver_count--;
+ if(battle_config.etc_log)
ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", p[0], p[1], p[2], p[3], port, j);
- }
return 0;
}
@@ -323,6 +318,12 @@ int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y, chrif_check(-1);
+ if (other_mapserver_count < 1)
+ { //No other map servers are online!
+ pc_authfail(sd);
+ return -1;
+ }
+
s_ip = 0;
//for(i = 0; i < fd_max; i++)
// if (session[i] && session[i]->session_data == sd) {
@@ -1396,7 +1397,8 @@ int chrif_disconnect(int fd) { if (kick_on_disconnect)
clif_foreachclient(chrif_disconnect_sub);
chrif_connected = 0;
- // 他のmap 鯖のデータを消す
+
+ other_mapserver_count=0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
map_eraseallipport();
// 倉庫キャッシュを消す
diff --git a/src/map/chrif.h b/src/map/chrif.h index d6b9d2b6a..cc427fe92 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -21,6 +21,7 @@ void chrif_setport(int); int chrif_isconnect(void);
extern int chrif_connected;
+extern int other_mapserver_count;
void chrif_authreq(struct map_session_data *);
void chrif_authok(int fd);
diff --git a/src/map/intif.c b/src/map/intif.c index 926d03335..fc7fd6c3d 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -134,6 +134,9 @@ int intif_GMmessage(char* mes,int len,int flag) if (CheckForCharServer())
return 0;
+ if (other_mapserver_count < 1)
+ return 0; //No need to send.
+
WFIFOHEAD(inter_fd,lp + len + 4);
WFIFOW(inter_fd,0) = 0x3000;
WFIFOW(inter_fd,2) = lp + len + 4;
@@ -154,6 +157,10 @@ int intif_announce(char* mes,int len, unsigned long color, int flag) if (CheckForCharServer())
return 0;
+
+ if (other_mapserver_count < 1)
+ return 0; //No need to send.
+
WFIFOHEAD(inter_fd, 8 + len);
WFIFOW(inter_fd,0) = 0x3000;
WFIFOW(inter_fd,2) = 8 + len;
@@ -169,6 +176,12 @@ int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, int me if (CheckForCharServer())
return 0;
+ if (other_mapserver_count < 1)
+ { //Character not found.
+ clif_wis_end(sd->fd, 1);
+ return 0;
+ }
+
WFIFOHEAD(inter_fd,mes_len + 52);
WFIFOW(inter_fd,0) = 0x3001;
WFIFOW(inter_fd,2) = mes_len + 52;
@@ -467,8 +480,10 @@ int intif_party_message(int party_id,int account_id,char *mes,int len) {
if (CheckForCharServer())
return 0;
-// if(battle_config.etc_log)
-// printf("intif_party_message: %s\n",mes);
+
+ if (other_mapserver_count < 1)
+ return 0; //No need to send.
+
WFIFOHEAD(inter_fd,len + 12);
WFIFOW(inter_fd,0)=0x3027;
WFIFOW(inter_fd,2)=len+12;
@@ -608,6 +623,10 @@ int intif_guild_message(int guild_id,int account_id,char *mes,int len) {
if (CheckForCharServer())
return 0;
+
+ if (other_mapserver_count < 1)
+ return 0; //No need to send.
+
WFIFOHEAD(inter_fd, len + 12);
WFIFOW(inter_fd,0)=0x3037;
WFIFOW(inter_fd,2)=len+12;
|