summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c38
-rw-r--r--src/char/char.h15
-rw-r--r--src/char/int_guild.c12
-rw-r--r--src/char/int_guild.h3
-rw-r--r--src/char/int_party.c13
-rw-r--r--src/char/int_party.h2
-rw-r--r--src/char/int_pet.c7
-rw-r--r--src/char/int_pet.h2
-rw-r--r--src/char/int_storage.c10
-rw-r--r--src/char/int_storage.h3
-rw-r--r--src/char/inter.c46
-rw-r--r--src/char/inter.h7
12 files changed, 97 insertions, 61 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 2d7e5af57..691dcf2a4 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -42,7 +42,13 @@
#include "int_status.h"
#endif
-struct mmo_map_server server[MAX_MAP_SERVERS];
+#ifndef TXT_SQL_CONVERT
+struct mmo_map_server{
+ long ip;
+ short port;
+ int users;
+ unsigned short map[MAX_MAP_PER_SERVER];
+} server[MAX_MAP_SERVERS];
int server_fd[MAX_MAP_SERVERS];
int login_fd, char_fd;
@@ -62,9 +68,11 @@ int char_maintenance;
int char_new;
int char_new_display;
int email_creation = 0; // disabled by default
+#endif
char char_txt[1024]="save/athena.txt";
char backup_txt[1024]="save/backup.txt"; //By zanetheinsane
char friends_txt[1024]="save/friends.txt"; // davidsiaw
+#ifndef TXT_SQL_CONVERT
char backup_txt_flag = 0; // The backup_txt file was created because char deletion bug existed. Now it's finish and that take a lot of time to create a second file when there are a lot of characters. => option By [Yor]
char unknown_char_name[1024] = "Unknown";
char char_log_filename[1024] = "log/char.log";
@@ -107,11 +115,7 @@ int check_ip_flag = 1; // It's to check IP of a player between char-server and o
static int online_check = 1; //If one, it won't let players connect when their account is already registered online and will send the relevant map server a kick user request. [Skotlex]
int char_id_count = START_CHAR_NUM;
-struct character_data {
- struct mmo_charstatus status;
- int global_num;
- struct global_reg global[GLOBAL_REG_NUM];
-} *char_dat;
+struct character_data *char_dat;
int char_num, char_max;
int max_connect_user = 0;
@@ -487,7 +491,7 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg,
*str_p = '\0';
return 0;
}
-
+#endif //TXT_SQL_CONVERT
//-------------------------------------------------------------------------
// Function to set the character from the line (at read of characters file)
//-------------------------------------------------------------------------
@@ -701,6 +705,7 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg
p->last_point.map = tmp_int[45];
p->save_point.map = tmp_int[46];
+#ifndef TXT_SQL_CONVERT
// Some checks
for(i = 0; i < char_num; i++) {
if (char_dat[i].status.char_id == p->char_id) {
@@ -723,7 +728,7 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg
char_log("mmo_auth_init: ******WARNING: character name has wisp server name: Character name '%s' = wisp server name '%s'." RETCODE,
p->name, wisp_server_name);
}
-
+#endif //TXT_SQL_CONVERT
if (str[next] == '\n' || str[next] == '\r')
return 1; // 新規データ
@@ -887,7 +892,7 @@ int parse_friend_txt(struct mmo_charstatus *p)
fclose(fp);
return count;
}
-
+#ifndef TXT_SQL_CONVERT
//---------------------------------
// Function to read characters file
//---------------------------------
@@ -1680,7 +1685,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
for(i = found_num; i < 9; i++)
sd->found_char[i] = -1;
- WFIFOHEAD(fd, offset + found_num * 106);
+ WFIFOHEAD(fd, offset + found_num * 106);
memset(WFIFOP(fd,0), 0, offset + found_num * 106);
WFIFOW(fd,0) = 0x6b;
WFIFOW(fd,2) = offset + found_num * 106;
@@ -4076,6 +4081,7 @@ int char_lan_config_read(const char *lancfgName) {
fclose(fp);
return 0;
}
+#endif //TXT_SQL_CONVERT
int char_config_read(const char *cfgName) {
char line[1024], w1[1024], w2[1024];
@@ -4103,6 +4109,7 @@ int char_config_read(const char *cfgName) {
msg_silent = 0; //To always allow the next line to show up.
ShowInfo("Console Silent Setting: %d\n", atoi(w2));
msg_silent = atoi(w2);
+#ifndef TXT_SQL_CONVERT
} else if (strcmpi(w1, "userid") == 0) {
strncpy(userid, w2, 24);
} else if (strcmpi(w1, "passwd") == 0) {
@@ -4149,14 +4156,16 @@ int char_config_read(const char *cfgName) {
char_new_display = atoi(w2);
} else if (strcmpi(w1, "email_creation") == 0) {
email_creation = config_switch(w2);
- } else if (strcmpi(w1, "char_txt") == 0) {
- strcpy(char_txt, w2);
} else if (strcmpi(w1, "scdata_txt") == 0) { //By Skotlex
strcpy(scdata_txt, w2);
+#endif
+ } else if (strcmpi(w1, "char_txt") == 0) {
+ strcpy(char_txt, w2);
} else if (strcmpi(w1, "backup_txt") == 0) { //By zanetheinsane
strcpy(backup_txt, w2);
} else if (strcmpi(w1, "friends_txt") == 0) { //By davidsiaw
strcpy(friends_txt, w2);
+#ifndef TXT_SQL_CONVERT
} else if (strcmpi(w1, "backup_txt_flag") == 0) { // The backup_txt file was created because char deletion bug existed. Now it's finish and that take a lot of time to create a second file when there are a lot of characters. By [Yor]
backup_txt_flag = config_switch(w2);
} else if (strcmpi(w1, "max_connect_user") == 0) {
@@ -4258,6 +4267,7 @@ int char_config_read(const char *cfgName) {
}
} else if (strcmpi(w1, "guild_exp_rate") == 0) {
guild_exp_rate = atoi(w2);
+#endif //TXT_SQL_CONVERT
} else if (strcmpi(w1, "import") == 0) {
char_config_read(w2);
}
@@ -4268,6 +4278,7 @@ int char_config_read(const char *cfgName) {
return 0;
}
+#ifndef TXT_SQL_CONVERT
int chardb_final(int key, void* data, va_list va)
{
aFree(data);
@@ -4379,7 +4390,7 @@ int do_init(int argc, char **argv) {
update_online = time(NULL);
create_online_files(); // update online players files at start of the server
- inter_init((argc > 2) ? argv[2] : inter_cfgName); // inter server 初期化
+ inter_init_txt((argc > 2) ? argv[2] : inter_cfgName); // inter server 初期化
set_defaultparse(parse_char);
@@ -4411,3 +4422,4 @@ int do_init(int argc, char **argv) {
return 0;
}
+#endif //TXT_SQL_CONVERT
diff --git a/src/char/char.h b/src/char/char.h
index b6849f80f..d6ec8e5cb 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -16,11 +16,10 @@
#define DEFAULT_AUTOSAVE_INTERVAL 300*1000
-struct mmo_map_server{
- long ip;
- short port;
- int users;
- unsigned short map[MAX_MAP_PER_SERVER];
+struct character_data {
+ struct mmo_charstatus status;
+ int global_num;
+ struct global_reg global[GLOBAL_REG_NUM];
};
struct mmo_charstatus* search_character(int aid, int cid);
@@ -50,4 +49,10 @@ extern char char_name_letters[];
extern int autosave_interval;
extern char db_path[];
extern int guild_exp_rate;
+extern int log_inter;
+//Exported for use in the TXT-SQL converter.
+extern char char_txt[];
+int char_config_read(const char *cfgName);
+int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int *reg_num);
+int parse_friend_txt(struct mmo_charstatus *p);
#endif
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index dcb576d86..cb7fa232c 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -19,6 +19,7 @@
char guild_txt[1024] = "save/guild.txt";
char castle_txt[1024] = "save/castle.txt";
+#ifndef TXT_SQL_CONVERT
static struct dbt *guild_db;
static struct dbt *castle_db;
@@ -95,7 +96,7 @@ int inter_guild_tostr(char *str, struct guild *g) {
return 0;
}
-
+#endif //TXT_SQL_CONVERT
// ギルドデータの文字列からの変換
int inter_guild_fromstr(char *str, struct guild *g) {
int i, j, c;
@@ -118,7 +119,9 @@ int inter_guild_fromstr(char *str, struct guild *g) {
g->max_member = tmp_int[2];
g->exp = exp;
g->skill_point = tmp_int[4];
+#ifndef TXT_SQL_CONVERT
g->castle_id = tmp_int[5];
+#endif
memcpy(g->name, tmp_str[0], NAME_LENGTH-1);
memcpy(g->master, tmp_str[1], NAME_LENGTH-1);
memcpy(g->mes1, tmp_str[2], 60);
@@ -242,7 +245,7 @@ int inter_guild_fromstr(char *str, struct guild *g) {
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
// ギルド城データの文字列への変換
int inter_guildcastle_tostr(char *str, struct guild_castle *gc) {
int len;
@@ -257,7 +260,7 @@ int inter_guildcastle_tostr(char *str, struct guild_castle *gc) {
return 0;
}
-
+#endif ///TXT_SQL_CONVERT
// ギルド城データの文字列からの変換
int inter_guildcastle_fromstr(char *str, struct guild_castle *gc) {
int tmp_int[26];
@@ -334,7 +337,7 @@ int inter_guildcastle_fromstr(char *str, struct guild_castle *gc) {
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
// ギルド関連データベース読み込み
int inter_guild_readdb(void) {
int i;
@@ -1560,3 +1563,4 @@ int inter_guild_mapif_init(int fd) {
int inter_guild_leave(int guild_id, int account_id, int char_id) {
return mapif_parse_GuildLeave(-1, guild_id, account_id, char_id, 0, "** Character Deleted **");
}
+#endif //TXT_SQL_CONVERT
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index 0b0105af3..2cd26a516 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -16,4 +16,7 @@ int inter_guild_sex_changed(int guild_id,int account_id,int char_id, int gender)
extern char guild_txt[1024];
extern char castle_txt[1024];
+//For the TXT->SQL converter
+int inter_guild_fromstr(char *str, struct guild *g);
+int inter_guildcastle_fromstr(char *str, struct guild_castle *gc);
#endif
diff --git a/src/char/int_party.c b/src/char/int_party.c
index e80a5de63..cae69193f 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -16,7 +16,7 @@
#include "int_party.h"
char party_txt[1024] = "save/party.txt";
-
+#ifndef TXT_SQL_CONVERT
struct party_data {
struct party party;
unsigned int min_lv, max_lv;
@@ -107,13 +107,15 @@ int inter_party_tostr(char *str, struct party *p) {
return 0;
}
-
+#endif //TXT_SQL_CONVERT
// パ?ティデ?タの文字列からの?換
int inter_party_fromstr(char *str, struct party *p) {
int i, j;
int tmp_int[16];
char tmp_str[256];
+#ifndef TXT_SQL_CONVERT
struct mmo_charstatus* status;
+#endif
memset(p, 0, sizeof(struct party));
@@ -144,7 +146,7 @@ int inter_party_fromstr(char *str, struct party *p) {
m->leader = tmp_int[2]?1:0;
str = strchr(str + 1, '\t');
-
+#ifndef TXT_SQL_CONVERT
if (!m->account_id) continue;
//Lookup player for rest of data.
status = search_character(m->account_id, m->char_id);
@@ -154,11 +156,12 @@ int inter_party_fromstr(char *str, struct party *p) {
m->class_ = status->class_;
m->map = status->last_point.map;
m->lv = status->base_level;
+#endif //TXT_SQL_CONVERT
}
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
// パ?ティデ?タのロ?ド
int inter_party_init() {
char line[8192];
@@ -736,4 +739,4 @@ int inter_party_parse_frommap(int fd) {
int inter_party_leave(int party_id, int account_id, int char_id) {
return mapif_parse_PartyLeave(-1, party_id, account_id, char_id);
}
-
+#endif //TXT_SQL_CONVERT
diff --git a/src/char/int_party.h b/src/char/int_party.h
index 8b54948b0..5c2fbefb1 100644
--- a/src/char/int_party.h
+++ b/src/char/int_party.h
@@ -15,4 +15,6 @@ int inter_party_logged(int party_id, int account_id, int char_id);
extern char party_txt[1024];
+//For the TXT->SQL converter
+int inter_party_fromstr(char *str, struct party *p);
#endif
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 53a222393..6e1b8ad83 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -16,6 +16,7 @@
char pet_txt[1024]="save/pet.txt";
+#ifndef TXT_SQL_CONVERT
static struct dbt *pet_db;
static int pet_newid = 100;
@@ -38,7 +39,7 @@ int inter_pet_tostr(char *str,struct s_pet *p)
return 0;
}
-
+#endif //TXT_SQL_CONVERT
int inter_pet_fromstr(char *str,struct s_pet *p)
{
int s;
@@ -78,7 +79,7 @@ int inter_pet_fromstr(char *str,struct s_pet *p)
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
int inter_pet_init()
{
char line[8192];
@@ -416,4 +417,4 @@ int inter_pet_parse_frommap(int fd)
}
return 1;
}
-
+#endif //TXT_SQL_CONVERT
diff --git a/src/char/int_pet.h b/src/char/int_pet.h
index 0495994fe..31489579f 100644
--- a/src/char/int_pet.h
+++ b/src/char/int_pet.h
@@ -13,4 +13,6 @@ int inter_pet_parse_frommap(int fd);
extern char pet_txt[1024];
+//Exported for use in the TXT-SQL converter.
+int inter_pet_fromstr(char *str,struct s_pet *p);
#endif
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index f8ae42c0f..89e9a540a 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -20,6 +20,7 @@
char storage_txt[1024]="save/storage.txt";
char guild_storage_txt[1024]="save/g_storage.txt";
+#ifndef TXT_SQL_CONVERT
static struct dbt *storage_db;
static struct dbt *guild_storage_db;
@@ -48,7 +49,7 @@ int storage_tostr(char *str,struct storage *p)
str[0]=0;
return 0;
}
-
+#endif //TXT_SQL_CONVERT
// 文字列を倉庫データに変換
int storage_fromstr(char *str,struct storage *p)
{
@@ -89,7 +90,7 @@ int storage_fromstr(char *str,struct storage *p)
ShowWarning("storage_fromstr: Found a storage line with more items than MAX_STORAGE (%d), remaining items have been discarded!\n", MAX_STORAGE);
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
int guild_storage_tostr(char *str,struct guild_storage *p)
{
int i,j,f=0;
@@ -114,7 +115,7 @@ int guild_storage_tostr(char *str,struct guild_storage *p)
str[0]=0;
return 0;
}
-
+#endif //TXT_SQL_CONVERT
int guild_storage_fromstr(char *str,struct guild_storage *p)
{
int tmp_int[256];
@@ -153,7 +154,7 @@ int guild_storage_fromstr(char *str,struct guild_storage *p)
ShowWarning("guild_storage_fromstr: Found a storage line with more items than MAX_GUILD_STORAGE (%d), remaining items have been discarded!\n", MAX_GUILD_STORAGE);
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
static void* create_storage(DBKey key, va_list args) {
struct storage *s;
s = (struct storage *) aCalloc(sizeof(struct storage), 1);
@@ -474,3 +475,4 @@ int inter_storage_parse_frommap(int fd)
}
return 1;
}
+#endif //TXT_SQL_CONVERT
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index 678312b1d..c15af003e 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -16,4 +16,7 @@ int inter_storage_parse_frommap(int fd);
extern char storage_txt[1024];
extern char guild_storage_txt[1024];
+//Exported for use in the TXT-SQL converter.
+int storage_fromstr(char *str,struct storage *p);
+int guild_storage_fromstr(char *str,struct guild_storage *p);
#endif
diff --git a/src/char/inter.c b/src/char/inter.c
index 8127a60a4..17b8ddc56 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -25,18 +25,13 @@
// that is the waiting time of answers of all map-servers
#define WISDELLIST_MAX 256 // Number of elements of Wisp/page data deletion list
+char accreg_txt[1024] = "save/accreg.txt";
+#ifndef TXT_SQL_CONVERT
char inter_log_filename[1024] = "log/inter.log";
char main_chat_nick[16] = "Main";
-char accreg_txt[1024] = "save/accreg.txt";
static struct dbt *accreg_db = NULL;
-struct accreg {
- int account_id, char_id;
- int reg_num;
- struct global_reg reg[ACCOUNT_REG_NUM];
-};
-
unsigned int party_share_level = 10;
// sending packet list
@@ -89,7 +84,7 @@ int inter_accreg_tostr(char *str, struct accreg *reg) {
return 0;
}
-
+#endif //TXT_SQL_CONVERT
// アカウント変数を文字列から変換
int inter_accreg_fromstr(const char *str, struct accreg *reg) {
int j, n;
@@ -106,7 +101,7 @@ int inter_accreg_fromstr(const char *str, struct accreg *reg) {
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
// アカウント変数の読み込み
int inter_accreg_init(void) {
char line[8192];
@@ -172,12 +167,12 @@ int inter_accreg_save(void) {
}
//--------------------------------------------------------
-
+#endif //TXT_SQL_CONVERT
/*==========================================
* 設定ファイルを読み込む
*------------------------------------------
*/
-int inter_config_read(const char *cfgName) {
+static int inter_config_read(const char *cfgName) {
char line[1024], w1[1024], w2[1024];
FILE *fp;
@@ -198,18 +193,19 @@ int inter_config_read(const char *cfgName) {
strncpy(storage_txt, w2, sizeof(storage_txt));
} else if (strcmpi(w1, "party_txt") == 0) {
strncpy(party_txt, w2, sizeof(party_txt));
- } else if (strcmpi(w1, "guild_txt") == 0) {
- strncpy(guild_txt, w2, sizeof(guild_txt));
} else if (strcmpi(w1, "pet_txt") == 0) {
strncpy(pet_txt, w2, sizeof(pet_txt));
- } else if (strcmpi(w1, "homun_txt") == 0) {
- strncpy(homun_txt, w2, sizeof(homun_txt));
- } else if (strcmpi(w1, "castle_txt") == 0) {
- strncpy(castle_txt, w2, sizeof(castle_txt));
} else if (strcmpi(w1, "accreg_txt") == 0) {
strncpy(accreg_txt, w2, sizeof(accreg_txt));
+ } else if (strcmpi(w1, "guild_txt") == 0) {
+ strncpy(guild_txt, w2, sizeof(guild_txt));
+ } else if (strcmpi(w1, "castle_txt") == 0) {
+ strncpy(castle_txt, w2, sizeof(castle_txt));
} else if (strcmpi(w1, "guild_storage_txt") == 0) {
strncpy(guild_storage_txt, w2, sizeof(guild_storage_txt));
+#ifndef TXT_SQL_CONVERT
+ } else if (strcmpi(w1, "homun_txt") == 0) {
+ strncpy(homun_txt, w2, sizeof(homun_txt));
} else if (strcmpi(w1, "party_share_level") == 0) {
party_share_level = (unsigned int)atof(w2);
} else if (strcmpi(w1, "inter_log_filename") == 0) {
@@ -217,7 +213,8 @@ int inter_config_read(const char *cfgName) {
} else if(strcmpi(w1,"log_inter")==0) {
log_inter = atoi(w2);
} else if(strcmpi(w1, "main_chat_nick")==0){ // Main chat nick [LuzZza]
- strcpy(main_chat_nick, w2); //
+ strcpy(main_chat_nick, w2);
+#endif //TXT_SQL_CONVERT
} else if (strcmpi(w1, "import") == 0) {
inter_config_read(w2);
}
@@ -226,7 +223,7 @@ int inter_config_read(const char *cfgName) {
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
// ログ書き出し
int inter_log(char *fmt,...) {
FILE *logfp;
@@ -258,11 +255,12 @@ int inter_save(void) {
return 0;
}
-
+#endif //TXT_SQL_CONVERT
// 初期化
-int inter_init(const char *file) {
+int inter_init_txt(const char *file) {
inter_config_read(file);
+#ifndef TXT_SQL_CONVERT
wis_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int));
inter_party_init();
@@ -271,10 +269,10 @@ int inter_init(const char *file) {
inter_pet_init();
inter_homun_init();
inter_accreg_init();
-
+#endif //TXT_SQL_CONVERT
return 0;
}
-
+#ifndef TXT_SQL_CONVERT
// finalize
void inter_final(void) {
accreg_db->destroy(accreg_db, NULL);
@@ -690,4 +688,4 @@ int inter_check_length(int fd, int length) {
return length;
}
-
+#endif //TXT_SQL_CONVERT
diff --git a/src/char/inter.h b/src/char/inter.h
index 7f9ed0a64..75489c387 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -4,7 +4,7 @@
#ifndef _INTER_H_
#define _INTER_H_
-int inter_init(const char *file);
+int inter_init_txt(const char *file);
void inter_final(void);
int inter_save(void);
int inter_parse_frommap(int fd);
@@ -20,8 +20,9 @@ int inter_log(char *fmt,...);
extern unsigned int party_share_level;
extern char inter_log_filename[1024];
-extern int log_inter;
-
extern char main_chat_nick[16];
+//For TXT->SQL conversion
+extern char accreg_txt[];
+int inter_accreg_fromstr(const char *str, struct accreg *reg);
#endif