summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/char/char.c b/src/char/char.c
index c5afc0f63..66bfdd4ee 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -120,8 +120,6 @@ char char_achievement_db[256] = "char_achievements";
static struct char_interface char_s;
struct char_interface *chr;
-char db_path[1024] = "db";
-
static char wisp_server_name[NAME_LENGTH] = "Server";
static char login_ip_str[128];
static uint32 login_ip = 0;
@@ -3149,7 +3147,7 @@ static void char_parse_frommap_map_names(int fd, int id)
static void char_send_scdata(int fd, int aid, int cid)
{
#ifdef ENABLE_SC_SAVING
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `total_tick`, `val1`, `val2`, `val3`, `val4` "
"FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
scdata_db, aid, cid) )
{
@@ -3170,10 +3168,11 @@ static void char_send_scdata(int fd, int aid, int cid)
{
SQL->GetData(inter->sql_handle, 0, &data, NULL); scdata.type = atoi(data);
SQL->GetData(inter->sql_handle, 1, &data, NULL); scdata.tick = atoi(data);
- SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
- SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
- SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
- SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); scdata.total_tick = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); scdata.val1 = atoi(data);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); scdata.val2 = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); scdata.val3 = atoi(data);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); scdata.val4 = atoi(data);
memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
}
if (count >= 50)
@@ -3743,14 +3742,14 @@ static void char_parse_frommap_save_status_change_data(int fd)
int i;
StrBuf->Init(&buf);
- StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
+ StrBuf->Printf(&buf, "INSERT INTO `%s` (`account_id`, `char_id`, `type`, `tick`, `total_tick`, `val1`, `val2`, `val3`, `val4`) VALUES ", scdata_db);
for( i = 0; i < count; ++i )
{
memcpy (&data, RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data));
if( i > 0 )
StrBuf->AppendStr(&buf, ", ");
- StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d')", aid, cid,
- data.type, data.tick, data.val1, data.val2, data.val3, data.val4);
+ StrBuf->Printf(&buf, "('%d','%d','%hu','%d','%d','%d','%d','%d','%d')", aid, cid,
+ data.type, data.tick, data.total_tick, data.val1, data.val2, data.val3, data.val4);
}
if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) )
Sql_ShowDebug(inter->sql_handle);
@@ -3883,9 +3882,9 @@ static void char_parse_frommap_scdata_update(int fd)
short type = RFIFOW(fd, 10);
if (SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s`"
- " (`account_id`,`char_id`,`type`,`tick`,`val1`,`val2`,`val3`,`val4`)"
- " VALUES ('%d','%d','%d','%d','%d','%d','%d','%d')",
- scdata_db, account_id, char_id, type, INFINITE_DURATION, val1, val2, val3, val4)
+ " (`account_id`,`char_id`,`type`,`tick`,`total_tick`,`val1`,`val2`,`val3`,`val4`)"
+ " VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d')",
+ scdata_db, account_id, char_id, type, INFINITE_DURATION, INFINITE_DURATION, val1, val2, val3, val4)
) {
Sql_ShowDebug(inter->sql_handle);
}
@@ -5791,7 +5790,8 @@ static bool char_config_read_database(const char *filename, const struct config_
if (autosave_interval <= 0)
autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
}
- libconfig->setting_lookup_mutable_string(setting, "db_path", db_path, sizeof(db_path));
+ libconfig->setting_lookup_mutable_string(setting, "db_path", chr->db_path, sizeof(chr->db_path));
+ libconfig->set_db_path(chr->db_path);
libconfig->setting_lookup_bool_real(setting, "log_char", &chr->enable_logs);
return true;
}
@@ -6453,6 +6453,8 @@ void char_defaults(void)
chr = &char_s;
memset(chr->server, 0, sizeof(chr->server));
+ sprintf(chr->db_path, "db");
+ libconfig->set_db_path(chr->db_path);
chr->login_fd = 0;
chr->char_fd = -1;