summaryrefslogtreecommitdiff
path: root/src/login_sql
diff options
context:
space:
mode:
authorwizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-11-28 00:01:39 +0000
committerwizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec>2004-11-28 00:01:39 +0000
commit6a079edada5a1abdbba3be15d0a8ac5f72fda0a9 (patch)
tree0ac2cf6071f6154f48f3816750cb9c56875cd4fa /src/login_sql
parentee2e4d8299abc3723b43ba915b01a7577a75c6cf (diff)
downloadhercules-6a079edada5a1abdbba3be15d0a8ac5f72fda0a9.tar.gz
hercules-6a079edada5a1abdbba3be15d0a8ac5f72fda0a9.tar.bz2
hercules-6a079edada5a1abdbba3be15d0a8ac5f72fda0a9.tar.xz
hercules-6a079edada5a1abdbba3be15d0a8ac5f72fda0a9.zip
Fixed online system, online column works and prevent double login at the login server
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@392 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/login_sql')
-rw-r--r--src/login_sql/login.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index 338ac92b4..b5a8d0ec1 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -137,6 +137,39 @@ int auth_fifo_pos = 0;
static char md5key[20], md5keylen = 16;
+struct dbt *online_db;
+
+//-----------------------------------------------------
+// Online User Database [Wizputer]
+//-----------------------------------------------------
+
+void add_online_user(int account_id) {
+ int *p;
+ p = malloc(sizeof(int));
+ if (p == NULL) {
+ printf("add_online_user: memory allocation failure (malloc)!\n");
+ exit(0);
+ }
+ p = &account_id;
+ numdb_insert(online_db, account_id, p);
+}
+
+int is_user_online(int account_id) {
+ int *p;
+
+ p = numdb_search(online_db, account_id);
+ if (p == NULL)
+ return 0;
+ printf("Acccount %d\n",*p);
+ return 1;
+}
+
+void remove_online_user(int account_id) {
+ int *p;
+ p = numdb_erase(online_db,account_id);
+ free(p);
+}
+
//-----------------------------------------------------
// check user level
//-----------------------------------------------------
@@ -528,6 +561,11 @@ int mmo_auth( struct mmo_account* account , int fd){
return 2; // 2 = This ID is expired
}
+ if ( is_user_online(atol(sql_row[0])) ) {
+ printf("User [%s] is already online - Rejected.\n",sql_row[1]);
+ return 3; // Rejected
+ }
+
account->account_id = atoi(sql_row[0]);
account->login_id1 = rand();
account->login_id2 = rand();
@@ -989,6 +1027,20 @@ int parse_fromchar(int fd){
}
return 0;
+ case 0x272b: // Set account_id to online [Wizputer]
+ if (RFIFOREST(fd) < 6)
+ return 0;
+ add_online_user(RFIFOL(fd,2));
+ RFIFOSKIP(fd,6);
+ break;
+
+ case 0x272c: // Set account_id to offline [Wizputer]
+ if (RFIFOREST(fd) < 6)
+ return 0;
+ remove_online_user(RFIFOL(fd,2));
+ RFIFOSKIP(fd,6);
+ break;
+
default:
printf("login: unknown packet %x! (from char).\n", RFIFOW(fd,0));
session[fd]->eof = 1;
@@ -1756,6 +1808,10 @@ int do_init(int argc,char **argv){
start_console();
}
+ // Online user database init
+ free(online_db);
+ online_db = numdb_init();
+
printf("The login-server is \033[1;32mready\033[0m (Server is listening on the port %d).\n\n", login_port);
return 0;