summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-14 14:18:30 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-14 14:18:30 +0000
commit50df12f5c8f485b12944182a53c43df975edd4cb (patch)
treee2f1949f32c5dab7c45cc0d2946062ff28904a8e
parent03cc029170d3ccdc02864d691b8aecd9d14ae7cd (diff)
downloadhercules-50df12f5c8f485b12944182a53c43df975edd4cb.tar.gz
hercules-50df12f5c8f485b12944182a53c43df975edd4cb.tar.bz2
hercules-50df12f5c8f485b12944182a53c43df975edd4cb.tar.xz
hercules-50df12f5c8f485b12944182a53c43df975edd4cb.zip
- Fixed main.sql adding a key on char_id rather than account_id for the char table.
- Cleaned up character saving in char-sql, it no longer needs to query the database to see if the player exists on each char-save, instead it checks the received data against the online-players db. - Added an error message on the char-server when the received player data size does not matches with the expected size (should avoid the crash that happens on such a memcpy). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7160 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt9
-rw-r--r--sql-files/main.sql2
-rw-r--r--src/char/char.c3
-rw-r--r--src/char_sql/char.c34
4 files changed, 27 insertions, 21 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 5ce09114c..05bfae692 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,15 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/06/14
+ * Fixed main.sql adding a key on char_id rather than account_id for the
+ char table. [Skotlex]
+ * Cleaned up character saving in char-sql, it no longer needs to query the
+ database to see if the player exists on each char-save, instead it checks
+ the received data against the online-players db. No such fix is required
+ for char-txt. [Skotlex]
+ * Added an error message on the char-server when the received player data
+ size does not matches with the expected size (should avoid the crash that
+ happens on such a memcpy). [Skotlex]
* [Improved]:
- script_save_mapreg for MapregSQL Saving to display perfomance only in slow
queries. [Lance]
diff --git a/sql-files/main.sql b/sql-files/main.sql
index c10ed7c15..f0350d929 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -78,7 +78,7 @@ CREATE TABLE `char` (
`child` int(11) unsigned NOT NULL default '0',
`fame` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`char_id`),
- KEY `char_id` (`char_id`),
+ KEY `account_id` (`account_id`),
KEY `party_id` (`party_id`),
KEY `guild_id` (`guild_id`)
) TYPE=InnoDB AUTO_INCREMENT=150000;
diff --git a/src/char/char.c b/src/char/char.c
index 5a9b2668a..701240f60 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2690,9 +2690,8 @@ int parse_frommap(int fd) {
}
if (i != char_num)
memcpy(&char_dat[i].status, RFIFOP(fd,13), sizeof(struct mmo_charstatus));
- if (RFIFOB(fd,12)) { //Flag, set character offline. [Skotlex]
+ if (RFIFOB(fd,12)) //Flag, set character offline. [Skotlex]
set_char_offline(RFIFOL(fd,8),RFIFOL(fd,4));
- }
RFIFOSKIP(fd,RFIFOW(fd,2));
break;
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 3a31e8030..aa84b1887 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -2548,29 +2548,27 @@ int parse_frommap(int fd) {
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
- int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8);
- i = 0;
- //check account
- sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",char_db, aid, cid); // TBR
- if (mysql_query(&mysql_handle, tmp_sql)) {
- ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
+ int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2);
+ struct online_char_data* character;
+ if (size - 13 != sizeof(struct mmo_charstatus))
+ {
+ ShowError("parse_from_map (save-char): Size mismatch! %d != %d\n", size-13, sizeof(struct mmo_charstatus));
+ RFIFOSKIP(fd,size);
+ break;
}
- sql_res = mysql_store_result(&mysql_handle);
- sql_row = sql_res?mysql_fetch_row(sql_res):NULL;
- if (sql_row) i = atoi(sql_row[0]);
- if (sql_res) mysql_free_result(sql_res);
-
- if (i == 1) {
+ //Check account
+ if (
+ (character = idb_get(online_char_db, aid)) != NULL &&
+ character->char_id == cid)
+ {
memcpy(&char_dat[0], RFIFOP(fd,13), sizeof(struct mmo_charstatus));
mmo_char_tosql(cid, char_dat);
- //save to DB
} else
- ShowError("parse_from_map (save-char): Received data for non-existant character (%d:%d)!\n", aid, cid);
- if (RFIFOB(fd,12)) { //Flag? Set character offline after saving [Skotlex]
+ ShowError("parse_from_map (save-char): Received data for non-existant/offline character (%d:%d)!\n", aid, cid);
+
+ if (RFIFOB(fd,12)) //Flag? Set character offline after saving [Skotlex]
set_char_offline(cid, aid);
- }
- RFIFOSKIP(fd,RFIFOW(fd,2));
+ RFIFOSKIP(fd,size);
break;
}
// req char selection