summaryrefslogtreecommitdiff
path: root/src/char_sql/char.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-13 18:31:49 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-04-13 18:31:49 +0000
commit5d0416edfe1e529b4b24bbf453048168c4fda608 (patch)
tree3d43c77c25a7fc879e6dcb81d0cab00f0b06d8ab /src/char_sql/char.c
parentdc99d88746c2175dfa5007ae2cbbde795dd357d1 (diff)
downloadhercules-5d0416edfe1e529b4b24bbf453048168c4fda608.tar.gz
hercules-5d0416edfe1e529b4b24bbf453048168c4fda608.tar.bz2
hercules-5d0416edfe1e529b4b24bbf453048168c4fda608.tar.xz
hercules-5d0416edfe1e529b4b24bbf453048168c4fda608.zip
* Quick&dirty reversal of the inter-server behaviour introduced in r3255/r3256:
- the behaviour enabled a desynch between the char-server and the map-server - now the map-server asks the char-server to authenticate the auth info (the char-server doesn't send the auth info immediatelly) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12579 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/char.c')
-rw-r--r--src/char_sql/char.c84
1 files changed, 83 insertions, 1 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index ca1b74ce7..9afd6b59d 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -2532,17 +2532,21 @@ int parse_frommap(int fd)
if (char_data == NULL)
{ //Really shouldn't happen.
mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
- char_data = &char_dat;
+ char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
}
//Tell the new map server about this player using Kevin's new auth packet. [Skotlex]
if (map_fd >= 0 && session[map_fd] && char_data)
{ //Send the map server the auth of this player.
+ struct auth_node* node;
+
//Update the "last map" as this is where the player must be spawned on the new map server.
char_data->last_point.map = RFIFOW(fd,18);
char_data->last_point.x = RFIFOW(fd,20);
char_data->last_point.y = RFIFOW(fd,22);
char_data->sex = RFIFOB(fd,30);
+#if 0
+ // the map-server must request it [FlavioJS]
WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
WFIFOW(map_fd,0) = 0x2afd;
WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
@@ -2552,6 +2556,18 @@ int parse_frommap(int fd)
WFIFOL(map_fd,12) = (unsigned long)0; //TODO: expiration_time, how do I figure it out right now?
memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
WFIFOSET(map_fd, WFIFOW(map_fd,2));
+#endif
+
+ // create temporary auth entry
+ CREATE(node, struct auth_node, 1);
+ node->account_id = RFIFOL(fd,2);
+ node->char_id = RFIFOL(fd,14);
+ node->login_id1 = RFIFOL(fd,6);
+ node->login_id2 = RFIFOL(fd,10);
+ node->sex = RFIFOB(fd,30);
+ node->expiration_time = 0; // FIXME
+ node->ip = ntohl(RFIFOL(fd,31));
+ idb_put(auth_db, RFIFOL(fd,2), node);
data = (struct online_char_data*)idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data);
data->char_id = char_data->char_id;
@@ -2852,6 +2868,69 @@ int parse_frommap(int fd)
RFIFOSKIP(fd,2);
break;
+ case 0x2b26: // auth request from map-server
+ if (RFIFOREST(fd) < 19)
+ return 0;
+
+ {
+ int account_id;
+ int char_id;
+ int login_id1;
+ char sex;
+ uint32 ip;
+ struct auth_node* node;
+ struct mmo_charstatus* cd;
+ struct mmo_charstatus char_dat;
+
+ account_id = RFIFOL(fd,2);
+ char_id = RFIFOL(fd,6);
+ login_id1 = RFIFOL(fd,10);
+ sex = RFIFOB(fd,14);
+ ip = ntohl(RFIFOL(fd,15));
+ RFIFOSKIP(fd,19);
+
+ node = (struct auth_node*)idb_get(auth_db, account_id);
+ cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id);
+ if( cd == NULL )
+ { //Really shouldn't happen.
+ mmo_char_fromsql(char_id, &char_dat, true);
+ cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id);
+ }
+ if( node != NULL && cd != NULL &&
+ node->account_id == account_id &&
+ node->char_id == char_id &&
+ node->login_id1 == login_id1 &&
+ node->sex == sex &&
+ node->ip == ip )
+ {// auth ok
+ WFIFOHEAD(fd,20 + sizeof(struct mmo_charstatus));
+ WFIFOW(fd,0) = 0x2afd;
+ WFIFOW(fd,2) = 20 + sizeof(struct mmo_charstatus);
+ WFIFOL(fd,4) = account_id;
+ WFIFOL(fd,8) = login_id1;
+ WFIFOL(fd,12) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT"
+ WFIFOL(fd,16) = node->login_id2;
+ memcpy(WFIFOP(fd,20), cd, sizeof(struct mmo_charstatus));
+ WFIFOSET(fd, WFIFOW(fd,2));
+
+ // only use the auth once and mark user online
+ idb_remove(auth_db, account_id);
+ set_char_online(id, account_id, char_id);
+ }
+ else
+ {// auth failed
+ WFIFOHEAD(fd,19);
+ WFIFOW(fd,0) = 0x2b27;
+ WFIFOL(fd,2) = account_id;
+ WFIFOL(fd,6) = char_id;
+ WFIFOL(fd,10) = login_id1;
+ WFIFOB(fd,14) = sex;
+ WFIFOL(fd,15) = htonl(ip);
+ WFIFOSET(fd,19);
+ }
+ }
+ break;
+
case 0x2736: // ip address update
if (RFIFOREST(fd) < 6) return 0;
server[id].ip = ntohl(RFIFOL(fd, 2));
@@ -3139,6 +3218,8 @@ int parse_char(int fd)
WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
WFIFOSET(fd,28);
+#if 0
+ // The server must request it [FlavioJS]
//Send auth ok to map server
WFIFOHEAD(map_fd,20 + sizeof(struct mmo_charstatus));
WFIFOW(map_fd,0) = 0x2afd;
@@ -3149,6 +3230,7 @@ int parse_char(int fd)
WFIFOL(map_fd,12) = (unsigned long)sd->expiration_time;
memcpy(WFIFOP(map_fd,20), &char_dat, sizeof(struct mmo_charstatus));
WFIFOSET(map_fd, WFIFOW(map_fd,2));
+#endif
// create temporary auth entry
CREATE(node, struct auth_node, 1);