Fixed online system for char not sending players left "online" to login when restarting

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@408 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
wizputer 2004-11-29 03:10:26 +00:00
parent 6038e48ed4
commit 48d6db7a75
4 changed files with 16 additions and 26 deletions

View File

@ -1,5 +1,6 @@
Date Added
11/28
* Fixed online system for char not sending players left "online" to login when restarting [Wizputer]
* Fixed damage formula of Cart revolution: 150% +1% per 80ea [Lupus]
* Removed 2x Chance of Equipment Breaking during CRITICAL attacks [Lupus]
* Fix some file props [MouseJstr]

View File

@ -170,26 +170,26 @@ 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);
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

View File

@ -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) );

View File

@ -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) );