summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-11-29 03:10:26 +0000
committerwizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-11-29 03:10:26 +0000
commit6bf052b6b27325a808d16e3801d3bad8e271688c (patch)
treecdf4cf5cd84bac23f97f199835124ebbda687e13 /src
parent47a18a4c48be7213bd162c8544a20310ecc99aee (diff)
downloadhercules-6bf052b6b27325a808d16e3801d3bad8e271688c.tar.gz
hercules-6bf052b6b27325a808d16e3801d3bad8e271688c.tar.bz2
hercules-6bf052b6b27325a808d16e3801d3bad8e271688c.tar.xz
hercules-6bf052b6b27325a808d16e3801d3bad8e271688c.zip
Fixed online system for char not sending players left "online" to login when restarting
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@408 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/char_sql/char.c20
-rw-r--r--src/char_sql/int_guild.c6
-rw-r--r--src/char_sql/int_party.c15
3 files changed, 15 insertions, 26 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 805bdaf4e..25141e08f 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -168,28 +168,28 @@ void set_char_online(int char_id, int account_id) {
}
void set_all_offline(void) {
- sprintf(tmp_sql, "SELECT `account_id` FROM `%s` WHERE `online` = '1'",char_db);
+ sprintf(tmp_sql, "SELECT `account_id` FROM `%s` WHERE `online`='1'",char_db);
if (mysql_query(&mysql_handle, tmp_sql)) {
- printf("DB server Error (select `char`)- %s\n", mysql_error(&mysql_handle));
+ printf("DB server Error (select all online)- %s\n", mysql_error(&mysql_handle));
}
-
sql_res = mysql_store_result(&mysql_handle);
if (sql_res) {
while((sql_row = mysql_fetch_row(sql_res))) {
if ( login_fd > 0 ) {
+ printf("send user offline: %d\n",atoi(sql_row[0]));
WFIFOW(login_fd,0) = 0x272c;
- WFIFOL(login_fd,2) = atol(sql_row[0]);
+ WFIFOL(login_fd,2) = atoi(sql_row[0]);
WFIFOSET(login_fd,6);
- }
+ }
}
}
-
+
+ mysql_free_result(sql_res);
sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `online`='1'", char_db);
if (mysql_query(&mysql_handle, tmp_sql)) {
- printf("DB server Error (insert `char`)- %s\n", mysql_error(&mysql_handle));
+ printf("DB server Error (set_all_offline)- %s\n", mysql_error(&mysql_handle));
}
- mysql_free_result(sql_res);
}
void set_char_offline(int char_id, int account_id) {
@@ -199,7 +199,7 @@ void set_char_offline(int char_id, int account_id) {
sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id);
if (mysql_query(&mysql_handle, tmp_sql))
- printf("DB server Error (update online `%s`)- %s\n", char_db, mysql_error(&mysql_handle));
+ printf("DB server Error (set_char_offline)- %s\n", mysql_error(&mysql_handle));
WFIFOW(login_fd,0) = 0x272c;
WFIFOL(login_fd,2) = account_id;
@@ -967,7 +967,6 @@ int mmo_char_sql_init(void) {
} else
printf("set char_id_count: %d.......\n",char_id_count);
- set_all_offline();
printf("init end.......\n");
return 0;
@@ -1262,6 +1261,7 @@ int parse_tologin(int fd) {
//exit(1); //fixed for server shutdown.
}else {
printf("Connected to login-server (connection #%d).\n", fd);
+ set_all_offline();
// if no map-server already connected, display a message...
for(i = 0; i < MAX_MAP_SERVERS; i++)
if (server_fd[i] >= 0 && server[i].map[0][0]) // if map-server online and at least 1 map
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 900e2ceac..007a2eb0d 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -596,12 +596,6 @@ int inter_guild_sql_init()
inter_guild_readdb(); // Read exp
- sprintf(tmp_sql,"UPDATE `%s` SET `online`='0'",guild_member_db);
- if(mysql_query(&mysql_handle, tmp_sql) ) {
- printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) );
- exit(0);
- }
-
sprintf (tmp_sql , "SELECT count(*) FROM `%s`",guild_db);
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c
index 84de078c9..b5950d3a1 100644
--- a/src/char_sql/int_party.c
+++ b/src/char_sql/int_party.c
@@ -96,8 +96,8 @@ int inter_party_tosql(int party_id,struct party *p)
for (i=0;i<MAX_PARTY;i++){
if (p->member[i].account_id>0){
- sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='%d', `online`='%d' WHERE `account_id`='%d' AND `name`='%s'",
- char_db, party_id, p->member[i].online, p->member[i].account_id,jstrescapecpy(t_member,p->member[i].name));
+ sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `name`='%s'",
+ char_db, party_id, p->member[i].account_id,jstrescapecpy(t_member,p->member[i].name));
//printf("%s",tmp_sql);
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) );
@@ -127,7 +127,7 @@ int inter_party_tosql(int party_id,struct party *p)
return 0;
}
- sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='%d', `online`='1' WHERE `account_id`='%d' AND `name`='%s'",
+ sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `name`='%s'",
char_db, party_id,leader_id, jstrescapecpy(t_member,p->member[i].name));
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error (inset/update `party`)- %s\n", mysql_error(&mysql_handle) );
@@ -207,11 +207,6 @@ int inter_party_sql_init(){
printf("interserver party memory initialize.... (%d byte)\n",sizeof(struct party));
party_pt = calloc(sizeof(struct party), 1);
- sprintf(tmp_sql,"UPDATE `%s` SET `online`='0'", char_db);
- if(mysql_query(&mysql_handle, tmp_sql) ) {
- printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) );
- }
-
sprintf (tmp_sql , "SELECT count(*) FROM `%s`",party_db);
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
@@ -603,7 +598,7 @@ int mapif_parse_PartyLeave(int fd,int party_id,int account_id)
// Update char information, does the name need encoding?
- sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0', `online`='1' WHERE `party_id`='%d' AND `name`='%s'",
+ sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `name`='%s'",
char_db, party_id, jstrescapecpy(t_member,p->member[i].name));
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) );
@@ -617,7 +612,7 @@ int mapif_parse_PartyLeave(int fd,int party_id,int account_id)
if(p->member[j].account_id>0&&j!=i){
mapif_party_leaved(party_id,p->member[j].account_id,p->member[j].name);
// Update char information, does the name need encoding?
- sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0', `online`='1' WHERE `party_id`='%d' AND `name`='%s'",
+ sprintf(tmp_sql,"UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `name`='%s'",
char_db, party_id, jstrescapecpy(t_member,p->member[i].name));
if(mysql_query(&mysql_handle, tmp_sql) ) {
printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) );