summaryrefslogtreecommitdiff
path: root/src/txt-converter
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-05 13:23:07 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-12-05 13:23:07 +0000
commit288490094a7fe9167747dc78d416940759a31197 (patch)
tree53dc4f5c2375f4b688b53ca8841630ddec5e1f88 /src/txt-converter
parent8ec1c47aed09c90343949d57c92760ba84738a46 (diff)
downloadhercules-288490094a7fe9167747dc78d416940759a31197.tar.gz
hercules-288490094a7fe9167747dc78d416940759a31197.tar.bz2
hercules-288490094a7fe9167747dc78d416940759a31197.tar.xz
hercules-288490094a7fe9167747dc78d416940759a31197.zip
- Massive EOL normalization & 'svn:eol-style native' flag setting for all txt/conf/h/c files.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9410 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/txt-converter')
-rw-r--r--src/txt-converter/char-converter.c562
-rw-r--r--src/txt-converter/login-converter.c456
2 files changed, 509 insertions, 509 deletions
diff --git a/src/txt-converter/char-converter.c b/src/txt-converter/char-converter.c
index 4d435b4d1..29d1c393f 100644
--- a/src/txt-converter/char-converter.c
+++ b/src/txt-converter/char-converter.c
@@ -1,281 +1,281 @@
-// (c) eAthena Dev Team - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "../common/core.h"
-#include "../common/strlib.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/mapindex.h"
-
-#include "../char/char.h"
-#include "../char/int_storage.h"
-#include "../char/int_pet.h"
-#include "../char/int_party.h"
-#include "../char/int_guild.h"
-#include "../char/inter.h"
-
-#include "../char_sql/char.h"
-#include "../char_sql/int_storage.h"
-#include "../char_sql/int_pet.h"
-#include "../char_sql/int_party.h"
-#include "../char_sql/int_guild.h"
-#include "../char_sql/inter.h"
-
-char t_name[256];
-
-#define CHAR_CONF_NAME "conf/char_athena.conf"
-#define SQL_CONF_NAME "conf/inter_athena.conf"
-#define INTER_CONF_NAME "conf/inter_athena.conf"
-//--------------------------------------------------------
-int convert_init(void){
- char line[65536];
- int ret;
- int set,tmp_int[2], lineno, count;
- char input;
- FILE *fp;
-
- ShowWarning("Make sure you backup your databases before continuing!\n");
- printf("\n");
- ShowNotice("Do you wish to convert your Character Database to SQL? (y/n) : ");
- input=getchar();
- if(input == 'y' || input == 'Y'){
- struct character_data char_dat;
- struct accreg reg;
-
- ShowStatus("Converting Character Database...\n");
- fp = fopen(char_txt, "r");
- memset (&char_dat, 0, sizeof(struct character_data));
- if(fp==NULL) {
- ShowError("Unable to open file [%s]!\n", char_txt);
- return 0;
- }
- lineno = count = 0;
- while(fgets(line, 65535, fp)){
- lineno++;
- memset(&char_dat, 0, sizeof(char_dat));
- ret=mmo_char_fromstr(line, &char_dat.status, char_dat.global, &char_dat.global_num);
- if(ret > 0){
- count++;
- parse_friend_txt(&char_dat.status); //Retrieve friends.
- mmo_char_tosql(char_dat.status.char_id , &char_dat.status);
-
- memset(&reg, 0, sizeof(reg));
- reg.account_id = char_dat.status.account_id;
- reg.char_id = char_dat.status.char_id;
- reg.reg_num = char_dat.global_num;
- memcpy(&reg.reg, &char_dat.global, reg.reg_num*sizeof(struct global_reg));
- inter_accreg_tosql(reg.account_id, reg.char_id, &reg, 3); //Type 3: Character regs
- } else {
- ShowError("Error %d converting character line [%s] (at %s:%d).\n", ret, line, char_txt, lineno);
- }
- }
- ShowStatus("Converted %d characters.\n", count);
- fclose(fp);
- ShowStatus("Converting Account variables Database...\n");
- if( (fp=fopen(accreg_txt,"r")) ==NULL )
- {
- ShowError("Unable to open file %s!", accreg_txt);
- return 1;
- }
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
- lineno++;
- memset (&reg, 0, sizeof(struct accreg));
- if(inter_accreg_fromstr(line, &reg) == 0 && reg.account_id > 0) {
- count++;
- inter_accreg_tosql(reg.account_id, 0, &reg, 2); //Type 2: Account regs
- }else{
- ShowError("accreg reading: broken data [%s] at %s:%d\n", line, accreg_txt, lineno);
- }
- }
- ShowStatus("Converted %d account registries.\n", count);
- fclose(fp);
- }
-
- while(getchar() != '\n');
- printf("\n");
- ShowNotice("Do you wish to convert your Storage Database to SQL? (y/n) : ");
- input=getchar();
- if(input == 'y' || input == 'Y') {
- struct storage storage_;
- printf("\n");
- ShowStatus("Converting Storage Database...\n");
- fp=fopen(storage_txt,"r");
- if(fp==NULL){
- ShowError("cant't read : %s\n",storage_txt);
- return 0;
- }
- lineno=count=0;
- while(fgets(line,65535,fp)){
- lineno++;
- set=sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]);
- if(set==2) {
- memset(&storage_, 0, sizeof(struct storage));
- storage_.account_id=tmp_int[0];
- if (storage_fromstr(line,&storage_) == 0) {
- count++;
- storage_tosql(storage_.account_id,&storage_); //to sql. (dump)
- } else {
- ShowError("Error parsing storage line [%s] (at %s:%d)\n", line, storage_txt, lineno);
- }
- }
- }
- ShowStatus("Converted %d storages.\n", count);
- fclose(fp);
- }
-
- while(getchar() != '\n');
- printf("\n");
- ShowNotice("Do you wish to convert your Pet Database to SQL? (y/n) : ");
- input=getchar();
- if(input == 'y' || input == 'Y') {
- struct s_pet p;
- printf("\n");
- ShowStatus("Converting Pet Database...\n");
- if( (fp=fopen(pet_txt,"r")) ==NULL )
- {
- ShowError("Unable to open file %s!", pet_txt);
- return 1;
- }
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
- lineno++;
- memset (&p, 0, sizeof(struct s_pet));
- if(inter_pet_fromstr(line, &p)==0 && p.pet_id>0){
- count++;
- inter_pet_tosql(p.pet_id,&p);
- }else{
- ShowError("pet reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
- }
- }
- ShowStatus("Converted %d pets.\n", count);
- fclose(fp);
- }
-
- while(getchar() != '\n');
- printf("\n");
- ShowNotice("Do you wish to convert your Party Database to SQL? (y/n) : ");
- input=getchar();
- if(input == 'y' || input == 'Y') {
- struct party p;
- printf("\n");
- ShowStatus("Converting Party Database...\n");
- if( (fp=fopen(party_txt,"r")) ==NULL )
- {
- ShowError("Unable to open file %s!", party_txt);
- return 1;
- }
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
- lineno++;
- memset (&p, 0, sizeof(struct party));
- if(inter_party_fromstr(line, &p) == 0 &&
- p.party_id > 0 &&
- inter_party_tosql(&p, PS_CREATE, 0))
- count++;
- else{
- ShowError("party reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
- }
- }
- ShowStatus("Converted %d parties.\n", count);
- fclose(fp);
- }
-
- while(getchar() != '\n');
- printf("\n");
- ShowNotice("Do you wish to convert your Guilds/Guild Castles Database to SQL? (y/n) : ");
- input=getchar();
- if(input == 'y' || input == 'Y') {
- struct guild g;
- struct guild_castle gc;
- printf("\n");
- ShowStatus("Converting Guild Database...\n");
- if( (fp=fopen(guild_txt,"r")) ==NULL )
- {
- ShowError("Unable to open file %s!", guild_txt);
- return 1;
- }
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
- lineno++;
- memset (&g, 0, sizeof(struct guild));
- if (inter_guild_fromstr(line, &g) == 0 &&
- g.guild_id > 0 &&
- inter_guild_tosql(&g,GS_MASK))
- count++;
- else
- ShowError("guild reading: broken data [%s] at %s:%d\n", line, guild_txt, lineno);
- }
- ShowStatus("Converted %d guilds.\n", count);
- fclose(fp);
- ShowStatus("Converting Guild Castles Database...\n");
- if( (fp=fopen(castle_txt,"r")) ==NULL )
- {
- ShowError("Unable to open file %s!", castle_txt);
- return 1;
- }
- lineno=count=0;
- while(fgets(line, sizeof(line), fp)){
- lineno++;
- memset (&gc, 0, sizeof(struct guild_castle));
- if (inter_guildcastle_fromstr(line, &gc) == 0) {
- inter_guildcastle_tosql(&gc);
- count++;
- }
- else
- ShowError("guild castle reading: broken data [%s] at %s:%d\n", line, castle_txt, lineno);
- }
- ShowStatus("Converted %d guild castles.\n", count);
- fclose(fp);
- }
-
- while(getchar() != '\n');
- printf("\n");
- ShowNotice("Do you wish to convert your Guild Storage Database to SQL? (y/n) : ");
- input=getchar();
- if(input == 'y' || input == 'Y') {
- struct guild_storage storage_;
- printf("\n");
- ShowStatus("Converting Guild Storage Database...\n");
- fp=fopen(guild_storage_txt,"r");
- if(fp==NULL){
- ShowError("cant't read : %s\n",guild_storage_txt);
- return 0;
- }
- lineno=count=0;
- while(fgets(line,65535,fp)){
- lineno++;
- memset(&storage_, 0, sizeof(struct guild_storage));
- if (sscanf(line,"%d",&storage_.guild_id) == 1 &&
- storage_.guild_id > 0 &&
- guild_storage_fromstr(line,&storage_) == 0
- ) {
- count++;
- guild_storage_tosql(storage_.guild_id, &storage_);
- } else
- ShowError("Error parsing guild storage line [%s] (at %s:%d)\n", line, guild_storage_txt, lineno);
- }
- ShowStatus("Converted %d guild storages.\n", count);
- fclose(fp);
- }
- return 0;
-}
-
-int do_init(int argc, char **argv){
-
- char_config_read((argc>1)?argv[1]:CHAR_CONF_NAME);
- mapindex_init();
- sql_config_read((argc>2)?argv[2]:SQL_CONF_NAME);
- inter_init_txt((argc > 3) ? argv[3] :INTER_CONF_NAME);
- inter_init_sql((argc > 3) ? argv[3] :INTER_CONF_NAME);
- convert_init();
- ShowStatus("Everything's been converted!\n");
- mapindex_final();
- exit (0);
-}
-
-void do_final () {}
+// (c) eAthena Dev Team - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../common/core.h"
+#include "../common/strlib.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/mapindex.h"
+
+#include "../char/char.h"
+#include "../char/int_storage.h"
+#include "../char/int_pet.h"
+#include "../char/int_party.h"
+#include "../char/int_guild.h"
+#include "../char/inter.h"
+
+#include "../char_sql/char.h"
+#include "../char_sql/int_storage.h"
+#include "../char_sql/int_pet.h"
+#include "../char_sql/int_party.h"
+#include "../char_sql/int_guild.h"
+#include "../char_sql/inter.h"
+
+char t_name[256];
+
+#define CHAR_CONF_NAME "conf/char_athena.conf"
+#define SQL_CONF_NAME "conf/inter_athena.conf"
+#define INTER_CONF_NAME "conf/inter_athena.conf"
+//--------------------------------------------------------
+int convert_init(void){
+ char line[65536];
+ int ret;
+ int set,tmp_int[2], lineno, count;
+ char input;
+ FILE *fp;
+
+ ShowWarning("Make sure you backup your databases before continuing!\n");
+ printf("\n");
+ ShowNotice("Do you wish to convert your Character Database to SQL? (y/n) : ");
+ input=getchar();
+ if(input == 'y' || input == 'Y'){
+ struct character_data char_dat;
+ struct accreg reg;
+
+ ShowStatus("Converting Character Database...\n");
+ fp = fopen(char_txt, "r");
+ memset (&char_dat, 0, sizeof(struct character_data));
+ if(fp==NULL) {
+ ShowError("Unable to open file [%s]!\n", char_txt);
+ return 0;
+ }
+ lineno = count = 0;
+ while(fgets(line, 65535, fp)){
+ lineno++;
+ memset(&char_dat, 0, sizeof(char_dat));
+ ret=mmo_char_fromstr(line, &char_dat.status, char_dat.global, &char_dat.global_num);
+ if(ret > 0){
+ count++;
+ parse_friend_txt(&char_dat.status); //Retrieve friends.
+ mmo_char_tosql(char_dat.status.char_id , &char_dat.status);
+
+ memset(&reg, 0, sizeof(reg));
+ reg.account_id = char_dat.status.account_id;
+ reg.char_id = char_dat.status.char_id;
+ reg.reg_num = char_dat.global_num;
+ memcpy(&reg.reg, &char_dat.global, reg.reg_num*sizeof(struct global_reg));
+ inter_accreg_tosql(reg.account_id, reg.char_id, &reg, 3); //Type 3: Character regs
+ } else {
+ ShowError("Error %d converting character line [%s] (at %s:%d).\n", ret, line, char_txt, lineno);
+ }
+ }
+ ShowStatus("Converted %d characters.\n", count);
+ fclose(fp);
+ ShowStatus("Converting Account variables Database...\n");
+ if( (fp=fopen(accreg_txt,"r")) ==NULL )
+ {
+ ShowError("Unable to open file %s!", accreg_txt);
+ return 1;
+ }
+ lineno=count=0;
+ while(fgets(line, sizeof(line), fp)){
+ lineno++;
+ memset (&reg, 0, sizeof(struct accreg));
+ if(inter_accreg_fromstr(line, &reg) == 0 && reg.account_id > 0) {
+ count++;
+ inter_accreg_tosql(reg.account_id, 0, &reg, 2); //Type 2: Account regs
+ }else{
+ ShowError("accreg reading: broken data [%s] at %s:%d\n", line, accreg_txt, lineno);
+ }
+ }
+ ShowStatus("Converted %d account registries.\n", count);
+ fclose(fp);
+ }
+
+ while(getchar() != '\n');
+ printf("\n");
+ ShowNotice("Do you wish to convert your Storage Database to SQL? (y/n) : ");
+ input=getchar();
+ if(input == 'y' || input == 'Y') {
+ struct storage storage_;
+ printf("\n");
+ ShowStatus("Converting Storage Database...\n");
+ fp=fopen(storage_txt,"r");
+ if(fp==NULL){
+ ShowError("cant't read : %s\n",storage_txt);
+ return 0;
+ }
+ lineno=count=0;
+ while(fgets(line,65535,fp)){
+ lineno++;
+ set=sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]);
+ if(set==2) {
+ memset(&storage_, 0, sizeof(struct storage));
+ storage_.account_id=tmp_int[0];
+ if (storage_fromstr(line,&storage_) == 0) {
+ count++;
+ storage_tosql(storage_.account_id,&storage_); //to sql. (dump)
+ } else {
+ ShowError("Error parsing storage line [%s] (at %s:%d)\n", line, storage_txt, lineno);
+ }
+ }
+ }
+ ShowStatus("Converted %d storages.\n", count);
+ fclose(fp);
+ }
+
+ while(getchar() != '\n');
+ printf("\n");
+ ShowNotice("Do you wish to convert your Pet Database to SQL? (y/n) : ");
+ input=getchar();
+ if(input == 'y' || input == 'Y') {
+ struct s_pet p;
+ printf("\n");
+ ShowStatus("Converting Pet Database...\n");
+ if( (fp=fopen(pet_txt,"r")) ==NULL )
+ {
+ ShowError("Unable to open file %s!", pet_txt);
+ return 1;
+ }
+ lineno=count=0;
+ while(fgets(line, sizeof(line), fp)){
+ lineno++;
+ memset (&p, 0, sizeof(struct s_pet));
+ if(inter_pet_fromstr(line, &p)==0 && p.pet_id>0){
+ count++;
+ inter_pet_tosql(p.pet_id,&p);
+ }else{
+ ShowError("pet reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
+ }
+ }
+ ShowStatus("Converted %d pets.\n", count);
+ fclose(fp);
+ }
+
+ while(getchar() != '\n');
+ printf("\n");
+ ShowNotice("Do you wish to convert your Party Database to SQL? (y/n) : ");
+ input=getchar();
+ if(input == 'y' || input == 'Y') {
+ struct party p;
+ printf("\n");
+ ShowStatus("Converting Party Database...\n");
+ if( (fp=fopen(party_txt,"r")) ==NULL )
+ {
+ ShowError("Unable to open file %s!", party_txt);
+ return 1;
+ }
+ lineno=count=0;
+ while(fgets(line, sizeof(line), fp)){
+ lineno++;
+ memset (&p, 0, sizeof(struct party));
+ if(inter_party_fromstr(line, &p) == 0 &&
+ p.party_id > 0 &&
+ inter_party_tosql(&p, PS_CREATE, 0))
+ count++;
+ else{
+ ShowError("party reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
+ }
+ }
+ ShowStatus("Converted %d parties.\n", count);
+ fclose(fp);
+ }
+
+ while(getchar() != '\n');
+ printf("\n");
+ ShowNotice("Do you wish to convert your Guilds/Guild Castles Database to SQL? (y/n) : ");
+ input=getchar();
+ if(input == 'y' || input == 'Y') {
+ struct guild g;
+ struct guild_castle gc;
+ printf("\n");
+ ShowStatus("Converting Guild Database...\n");
+ if( (fp=fopen(guild_txt,"r")) ==NULL )
+ {
+ ShowError("Unable to open file %s!", guild_txt);
+ return 1;
+ }
+ lineno=count=0;
+ while(fgets(line, sizeof(line), fp)){
+ lineno++;
+ memset (&g, 0, sizeof(struct guild));
+ if (inter_guild_fromstr(line, &g) == 0 &&
+ g.guild_id > 0 &&
+ inter_guild_tosql(&g,GS_MASK))
+ count++;
+ else
+ ShowError("guild reading: broken data [%s] at %s:%d\n", line, guild_txt, lineno);
+ }
+ ShowStatus("Converted %d guilds.\n", count);
+ fclose(fp);
+ ShowStatus("Converting Guild Castles Database...\n");
+ if( (fp=fopen(castle_txt,"r")) ==NULL )
+ {
+ ShowError("Unable to open file %s!", castle_txt);
+ return 1;
+ }
+ lineno=count=0;
+ while(fgets(line, sizeof(line), fp)){
+ lineno++;
+ memset (&gc, 0, sizeof(struct guild_castle));
+ if (inter_guildcastle_fromstr(line, &gc) == 0) {
+ inter_guildcastle_tosql(&gc);
+ count++;
+ }
+ else
+ ShowError("guild castle reading: broken data [%s] at %s:%d\n", line, castle_txt, lineno);
+ }
+ ShowStatus("Converted %d guild castles.\n", count);
+ fclose(fp);
+ }
+
+ while(getchar() != '\n');
+ printf("\n");
+ ShowNotice("Do you wish to convert your Guild Storage Database to SQL? (y/n) : ");
+ input=getchar();
+ if(input == 'y' || input == 'Y') {
+ struct guild_storage storage_;
+ printf("\n");
+ ShowStatus("Converting Guild Storage Database...\n");
+ fp=fopen(guild_storage_txt,"r");
+ if(fp==NULL){
+ ShowError("cant't read : %s\n",guild_storage_txt);
+ return 0;
+ }
+ lineno=count=0;
+ while(fgets(line,65535,fp)){
+ lineno++;
+ memset(&storage_, 0, sizeof(struct guild_storage));
+ if (sscanf(line,"%d",&storage_.guild_id) == 1 &&
+ storage_.guild_id > 0 &&
+ guild_storage_fromstr(line,&storage_) == 0
+ ) {
+ count++;
+ guild_storage_tosql(storage_.guild_id, &storage_);
+ } else
+ ShowError("Error parsing guild storage line [%s] (at %s:%d)\n", line, guild_storage_txt, lineno);
+ }
+ ShowStatus("Converted %d guild storages.\n", count);
+ fclose(fp);
+ }
+ return 0;
+}
+
+int do_init(int argc, char **argv){
+
+ char_config_read((argc>1)?argv[1]:CHAR_CONF_NAME);
+ mapindex_init();
+ sql_config_read((argc>2)?argv[2]:SQL_CONF_NAME);
+ inter_init_txt((argc > 3) ? argv[3] :INTER_CONF_NAME);
+ inter_init_sql((argc > 3) ? argv[3] :INTER_CONF_NAME);
+ convert_init();
+ ShowStatus("Everything's been converted!\n");
+ mapindex_final();
+ exit (0);
+}
+
+void do_final () {}
diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c
index 667b331e3..ab236d322 100644
--- a/src/txt-converter/login-converter.c
+++ b/src/txt-converter/login-converter.c
@@ -1,228 +1,228 @@
-// (c) eAthena Dev Team - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <my_global.h>
-#include <mysql.h>
-
-#include "../common/core.h"
-#include "../common/db.h"
-#include "../common/mmo.h"
-
-struct auth_dat_ {
- int account_id, sex;
- char userid[24], pass[24], lastlogin[24];
- int logincount;
- int state; // packet 0x006a value + 1 (0: compte OK)
- char email[40]; // e-mail (by default: a@a.com)
- char error_message[20]; // Message of error code #6 = You are Prohibited to log in until %s (packet 0x006a)
- time_t ban_until_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban)
- time_t connect_until_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
- char last_ip[16]; // save of last IP of connection
- char memo[255]; // a memo field
- int account_reg2_num;
- struct global_reg account_reg2[ACCOUNT_REG2_NUM];
-} *auth_dat;
-
-char login_account_id[256]="account_id";
-char login_userid[256]="userid";
-char login_user_pass[256]="user_pass";
-char login_db[256]="login";
-
-static struct dbt *gm_account_db;
-
-int db_server_port = 3306;
-char db_server_ip[16] = "127.0.0.1";
-char db_server_id[32] = "ragnarok";
-char db_server_pw[32] = "ragnarok";
-char db_server_logindb[32] = "ragnarok";
-
-#define INTER_CONF_NAME "conf/inter_athena.conf"
-
-int isGM(int account_id)
-{
- struct gm_account *p;
- p = idb_get(gm_account_db,account_id);
- if( p == NULL)
- return 0;
- return p->level;
-}
-
-int read_gm_account()
-{
- char line[8192];
- struct gm_account *p;
- FILE *fp;
- int c=0;
-
- gm_account_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int));
-
- printf("Starting reading gm_account\n");
-
- if( (fp=fopen("conf/GM_account.txt","r"))==NULL )
- return 1;
- while(fgets(line,sizeof(line),fp)){
- if(line[0] == '/' || line[1] == '/' || line[2] == '/')
- continue;
-
- p = (struct gm_account*)malloc(sizeof(struct gm_account));
- if(p==NULL){
- printf("gm_account: out of memory!\n");
- exit(0);
- }
-
- if(sscanf(line,"%d %d",&p->account_id,&p->level) != 2 || p->level <= 0) {
- printf("gm_account: broken data [conf/GM_account.txt] line %d\n",c);
- continue;
- }
- else {
- if(p->level > 99)
- p->level = 99;
- idb_put(gm_account_db,p->account_id,p);
- c++;
- printf("GM ID: %d Level: %d\n",p->account_id,p->level);
- }
- }
- fclose(fp);
- printf("%d ID of gm_accounts read.\n",c);
- return 0;
-}
-
-int mmo_auth_init(void)
-{
- MYSQL mysql_handle;
- char tmpsql[1024];
- MYSQL_RES* sql_res ;
- MYSQL_ROW sql_row ;
- FILE *fp;
- int account_id, logincount, user_level, state, n, i;
- char line[2048], userid[2048], pass[2048], lastlogin[2048], sex, email[2048], error_message[2048], last_ip[2048], memo[2048];
- time_t ban_until_time;
- time_t connect_until_time;
- char t_uid[256];
-
- mysql_init(&mysql_handle);
- if(!mysql_real_connect(&mysql_handle, db_server_ip, db_server_id, db_server_pw,
- db_server_logindb ,db_server_port, (char *)NULL, 0)) {
- //pointer check
- printf("%s\n",mysql_error(&mysql_handle));
- exit(1);
- }
- else {
- printf ("Connect: Success!\n");
- }
- printf ("Convert start...\n");
-
-
- fp=fopen("save/account.txt","r");
- auth_dat = (struct auth_dat_*)malloc(sizeof(auth_dat[0])*256);
- if(fp==NULL)
- return 0;
- while(fgets(line,1023,fp)!=NULL){
-
- if(line[0]=='/' && line[1]=='/')
- continue;
-
- i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t"
- "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]\t%ld%n",
- &account_id, userid, pass, lastlogin, &sex, &logincount, &state,
- email, error_message, &connect_until_time, last_ip, memo, &ban_until_time, &n);
-
- sprintf(tmpsql, "SELECT `%s`,`%s`,`%s`,`lastlogin`,`logincount`,`sex`,`connect_until`,`last_ip`,`ban_until`,`state`"
- " FROM `%s` WHERE `%s`='%s'", login_account_id, login_userid, login_user_pass, login_db, login_userid, t_uid);
-
- if(mysql_query(&mysql_handle, tmpsql) ) {
- printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
- }
- user_level = isGM(account_id);
- printf ("userlevel: %s (%d)- %d\n",userid, account_id, user_level);
- sql_res = mysql_store_result(&mysql_handle) ;
- sql_row = mysql_fetch_row(sql_res); //row fetching
- if (!sql_row) //no row -> insert
- sprintf(tmpsql, "INSERT INTO `login` (`account_id`, `userid`, `user_pass`, `lastlogin`, `sex`, `logincount`, `email`, `level`) VALUES (%d, '%s', '%s', '%s', '%c', %d, 'user@athena', %d);",account_id , userid, pass,lastlogin,sex,logincount, user_level);
- else //row reside -> updating
- sprintf(tmpsql, "UPDATE `login` SET `account_id`='%d', `userid`='%s', `user_pass`='%s', `lastlogin`='%s', `sex`='%c', `logincount`='%d', `email`='user@athena', `level`='%d'\nWHERE `account_id`='%d';",account_id , userid, pass,lastlogin,sex,logincount, user_level, account_id);
- printf ("Query: %s\n",tmpsql);
- mysql_free_result(sql_res) ; //resource free
- if(mysql_query(&mysql_handle, tmpsql) ) {
- printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
- }
- }
- fclose(fp);
-
- printf ("Convert end...\n");
-
- return 0;
-}
-
-int login_config_read(const char *cfgName){
- int i;
- char line[1024], w1[1024], w2[1024];
- FILE *fp;
-
- printf ("Start reading interserver configuration: %s\n",cfgName);
-
- fp=fopen(cfgName,"r");
- if(fp==NULL){
- printf("File not found: %s\n", cfgName);
- return 1;
- }
-
- while(fgets(line, 1020, fp)){
- if(line[0] == '/' && line[1] == '/')
- continue;
-
- i=sscanf(line,"%[^:]:%s", w1, w2);
- if(i!=2)
- continue;
-
- //add for DB connection
- if(strcmpi(w1,"db_server_ip")==0){
- strcpy(db_server_ip, w2);
- printf ("set db_server_ip : %s\n",w2);
- }
- else if(strcmpi(w1,"db_server_port")==0){
- db_server_port=atoi(w2);
- printf ("set db_server_port : %s\n",w2);
- }
- else if(strcmpi(w1,"db_server_id")==0){
- strcpy(db_server_id, w2);
- printf ("set db_server_id : %s\n",w2);
- }
- else if(strcmpi(w1,"db_server_pw")==0){
- strcpy(db_server_pw, w2);
- printf ("set db_server_pw : %s\n",w2);
- }
- else if(strcmpi(w1,"db_server_logindb")==0){
- strcpy(db_server_logindb, w2);
- printf ("set db_server_logindb : %s\n",w2);
- }
- //support the import command, just like any other config
- else if(strcmpi(w1,"import")==0){
- login_config_read(w2);
- }
- }
- fclose(fp);
- printf ("End reading interserver configuration...\n");
- return 0;
-}
-
-int do_init(int argc,char **argv)
-{
- char input;
- login_config_read( (argc>1)?argv[1]:INTER_CONF_NAME );
- read_gm_account();
-
- printf("\nWarning : Make sure you backup your databases before continuing!\n");
- printf("\nDo you wish to convert your Login Database to SQL? (y/n) : ");
- input=getchar();
- if(input == 'y' || input == 'Y')
- mmo_auth_init();
- printf ("Everything's been converted!\n");
- exit (0);
-}
-
-
-void do_final() {}
+// (c) eAthena Dev Team - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <my_global.h>
+#include <mysql.h>
+
+#include "../common/core.h"
+#include "../common/db.h"
+#include "../common/mmo.h"
+
+struct auth_dat_ {
+ int account_id, sex;
+ char userid[24], pass[24], lastlogin[24];
+ int logincount;
+ int state; // packet 0x006a value + 1 (0: compte OK)
+ char email[40]; // e-mail (by default: a@a.com)
+ char error_message[20]; // Message of error code #6 = You are Prohibited to log in until %s (packet 0x006a)
+ time_t ban_until_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban)
+ time_t connect_until_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
+ char last_ip[16]; // save of last IP of connection
+ char memo[255]; // a memo field
+ int account_reg2_num;
+ struct global_reg account_reg2[ACCOUNT_REG2_NUM];
+} *auth_dat;
+
+char login_account_id[256]="account_id";
+char login_userid[256]="userid";
+char login_user_pass[256]="user_pass";
+char login_db[256]="login";
+
+static struct dbt *gm_account_db;
+
+int db_server_port = 3306;
+char db_server_ip[16] = "127.0.0.1";
+char db_server_id[32] = "ragnarok";
+char db_server_pw[32] = "ragnarok";
+char db_server_logindb[32] = "ragnarok";
+
+#define INTER_CONF_NAME "conf/inter_athena.conf"
+
+int isGM(int account_id)
+{
+ struct gm_account *p;
+ p = idb_get(gm_account_db,account_id);
+ if( p == NULL)
+ return 0;
+ return p->level;
+}
+
+int read_gm_account()
+{
+ char line[8192];
+ struct gm_account *p;
+ FILE *fp;
+ int c=0;
+
+ gm_account_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int));
+
+ printf("Starting reading gm_account\n");
+
+ if( (fp=fopen("conf/GM_account.txt","r"))==NULL )
+ return 1;
+ while(fgets(line,sizeof(line),fp)){
+ if(line[0] == '/' || line[1] == '/' || line[2] == '/')
+ continue;
+
+ p = (struct gm_account*)malloc(sizeof(struct gm_account));
+ if(p==NULL){
+ printf("gm_account: out of memory!\n");
+ exit(0);
+ }
+
+ if(sscanf(line,"%d %d",&p->account_id,&p->level) != 2 || p->level <= 0) {
+ printf("gm_account: broken data [conf/GM_account.txt] line %d\n",c);
+ continue;
+ }
+ else {
+ if(p->level > 99)
+ p->level = 99;
+ idb_put(gm_account_db,p->account_id,p);
+ c++;
+ printf("GM ID: %d Level: %d\n",p->account_id,p->level);
+ }
+ }
+ fclose(fp);
+ printf("%d ID of gm_accounts read.\n",c);
+ return 0;
+}
+
+int mmo_auth_init(void)
+{
+ MYSQL mysql_handle;
+ char tmpsql[1024];
+ MYSQL_RES* sql_res ;
+ MYSQL_ROW sql_row ;
+ FILE *fp;
+ int account_id, logincount, user_level, state, n, i;
+ char line[2048], userid[2048], pass[2048], lastlogin[2048], sex, email[2048], error_message[2048], last_ip[2048], memo[2048];
+ time_t ban_until_time;
+ time_t connect_until_time;
+ char t_uid[256];
+
+ mysql_init(&mysql_handle);
+ if(!mysql_real_connect(&mysql_handle, db_server_ip, db_server_id, db_server_pw,
+ db_server_logindb ,db_server_port, (char *)NULL, 0)) {
+ //pointer check
+ printf("%s\n",mysql_error(&mysql_handle));
+ exit(1);
+ }
+ else {
+ printf ("Connect: Success!\n");
+ }
+ printf ("Convert start...\n");
+
+
+ fp=fopen("save/account.txt","r");
+ auth_dat = (struct auth_dat_*)malloc(sizeof(auth_dat[0])*256);
+ if(fp==NULL)
+ return 0;
+ while(fgets(line,1023,fp)!=NULL){
+
+ if(line[0]=='/' && line[1]=='/')
+ continue;
+
+ i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t"
+ "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]\t%ld%n",
+ &account_id, userid, pass, lastlogin, &sex, &logincount, &state,
+ email, error_message, &connect_until_time, last_ip, memo, &ban_until_time, &n);
+
+ sprintf(tmpsql, "SELECT `%s`,`%s`,`%s`,`lastlogin`,`logincount`,`sex`,`connect_until`,`last_ip`,`ban_until`,`state`"
+ " FROM `%s` WHERE `%s`='%s'", login_account_id, login_userid, login_user_pass, login_db, login_userid, t_uid);
+
+ if(mysql_query(&mysql_handle, tmpsql) ) {
+ printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
+ }
+ user_level = isGM(account_id);
+ printf ("userlevel: %s (%d)- %d\n",userid, account_id, user_level);
+ sql_res = mysql_store_result(&mysql_handle) ;
+ sql_row = mysql_fetch_row(sql_res); //row fetching
+ if (!sql_row) //no row -> insert
+ sprintf(tmpsql, "INSERT INTO `login` (`account_id`, `userid`, `user_pass`, `lastlogin`, `sex`, `logincount`, `email`, `level`) VALUES (%d, '%s', '%s', '%s', '%c', %d, 'user@athena', %d);",account_id , userid, pass,lastlogin,sex,logincount, user_level);
+ else //row reside -> updating
+ sprintf(tmpsql, "UPDATE `login` SET `account_id`='%d', `userid`='%s', `user_pass`='%s', `lastlogin`='%s', `sex`='%c', `logincount`='%d', `email`='user@athena', `level`='%d'\nWHERE `account_id`='%d';",account_id , userid, pass,lastlogin,sex,logincount, user_level, account_id);
+ printf ("Query: %s\n",tmpsql);
+ mysql_free_result(sql_res) ; //resource free
+ if(mysql_query(&mysql_handle, tmpsql) ) {
+ printf("DB server Error - %s\n", mysql_error(&mysql_handle) );
+ }
+ }
+ fclose(fp);
+
+ printf ("Convert end...\n");
+
+ return 0;
+}
+
+int login_config_read(const char *cfgName){
+ int i;
+ char line[1024], w1[1024], w2[1024];
+ FILE *fp;
+
+ printf ("Start reading interserver configuration: %s\n",cfgName);
+
+ fp=fopen(cfgName,"r");
+ if(fp==NULL){
+ printf("File not found: %s\n", cfgName);
+ return 1;
+ }
+
+ while(fgets(line, 1020, fp)){
+ if(line[0] == '/' && line[1] == '/')
+ continue;
+
+ i=sscanf(line,"%[^:]:%s", w1, w2);
+ if(i!=2)
+ continue;
+
+ //add for DB connection
+ if(strcmpi(w1,"db_server_ip")==0){
+ strcpy(db_server_ip, w2);
+ printf ("set db_server_ip : %s\n",w2);
+ }
+ else if(strcmpi(w1,"db_server_port")==0){
+ db_server_port=atoi(w2);
+ printf ("set db_server_port : %s\n",w2);
+ }
+ else if(strcmpi(w1,"db_server_id")==0){
+ strcpy(db_server_id, w2);
+ printf ("set db_server_id : %s\n",w2);
+ }
+ else if(strcmpi(w1,"db_server_pw")==0){
+ strcpy(db_server_pw, w2);
+ printf ("set db_server_pw : %s\n",w2);
+ }
+ else if(strcmpi(w1,"db_server_logindb")==0){
+ strcpy(db_server_logindb, w2);
+ printf ("set db_server_logindb : %s\n",w2);
+ }
+ //support the import command, just like any other config
+ else if(strcmpi(w1,"import")==0){
+ login_config_read(w2);
+ }
+ }
+ fclose(fp);
+ printf ("End reading interserver configuration...\n");
+ return 0;
+}
+
+int do_init(int argc,char **argv)
+{
+ char input;
+ login_config_read( (argc>1)?argv[1]:INTER_CONF_NAME );
+ read_gm_account();
+
+ printf("\nWarning : Make sure you backup your databases before continuing!\n");
+ printf("\nDo you wish to convert your Login Database to SQL? (y/n) : ");
+ input=getchar();
+ if(input == 'y' || input == 'Y')
+ mmo_auth_init();
+ printf ("Everything's been converted!\n");
+ exit (0);
+}
+
+
+void do_final() {}