diff options
Diffstat (limited to 'src/char_sql')
-rw-r--r-- | src/char_sql/char.c | 105 | ||||
-rw-r--r-- | src/char_sql/int_guild.c | 216 | ||||
-rw-r--r-- | src/char_sql/int_party.c | 4 | ||||
-rw-r--r-- | src/char_sql/int_pet.c | 4 | ||||
-rw-r--r-- | src/char_sql/int_storage.c | 2 |
5 files changed, 14 insertions, 317 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c index e26d92af7..1083235cf 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -37,18 +37,14 @@ #include "strlib.h" #include "itemdb.h" #include "inter.h" -#ifdef FASTCHAR #include "db.h" -#endif /* FASTCHAR */ #ifdef MEMWATCH #include "memwatch.h" #endif -#ifdef FASTCHAR static struct dbt *char_db_; -#endif /* FASTCHAR */ char char_db[256] = "char"; char cart_db[256] = "cart_inventory"; char inventory_db[256] = "inventory"; @@ -157,11 +153,8 @@ int GM_num = 0; int console = 0; -#ifdef FASTCHAR #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y) - -#endif /* FASTCHAR */ //------------------------------------------------- // Set Character online/offline [Wizputer] //------------------------------------------------- @@ -206,13 +199,22 @@ void set_all_offline(void) { } void set_char_offline(int char_id, int account_id) { + struct mmo_charstatus *cp; + if ( char_id == 99 ) sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `account_id`='%d'", char_db, account_id); - else - sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id); + else { + cp = numdb_search(char_db_,char_id); + if (cp != NULL) { + free(cp); + numdb_erase(char_db_,char_id); + } + + sprintf(tmp_sql,"UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id); if (mysql_query(&mysql_handle, tmp_sql)) printf("DB server Error (set_char_offline)- %s\n", mysql_error(&mysql_handle)); + } if (login_fd <= 0 || session[login_fd]->eof) return; @@ -297,7 +299,6 @@ void insert_friends(int char_id_count){ } } -#ifdef FASTCHAR int compare_item(struct item *a, struct item *b) { return ( (a->id == b->id) && @@ -313,39 +314,24 @@ int compare_item(struct item *a, struct item *b) { (a->card[3] == b->card[3])); } -#endif /* FASTCHAR */ //===================================================================================================== int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ int i=0,party_exist,guild_exist; int eqcount=1; int noteqcount=1; -#ifdef FASTCHAR int diff = 0; -#endif /* FASTCHAR */ char temp_str[1024]; char *tmp_p = tmp_sql; -#ifndef FASTCHAR - -#else /* FASTCHAR */ struct mmo_charstatus *cp; -#endif /* FASTCHAR */ struct itemtemp mapitem; -#ifdef FASTCHAR -#endif /* FASTCHAR */ if (char_id!=p->char_id) return 0; -#ifdef FASTCHAR cp = numdb_search(char_db_,char_id); -#endif /* FASTCHAR */ save_flag = p->char_id; printf("(\033[1;32m%d\033[0m) %s \trequest save char data - ",char_id,char_dat[0].name); -#ifndef FASTCHAR - - -#endif /* not FASTCHAR */ //for(testcount=1;testcount<50;testcount++){//---------------------------test count-------------------- // printf("test count : %d\n", testcount); // eqcount=1; @@ -355,16 +341,12 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ //----------------------------------------------------------------------------------------------------- //=========================================map inventory data > memory =============================== -#ifdef FASTCHAR diff = 0; -#endif /* FASTCHAR */ //map inventory data for(i=0;i<MAX_INVENTORY;i++){ -#ifdef FASTCHAR if (!compare_item(&p->inventory[i], &cp->inventory[i])) diff = 1; -#endif /* FASTCHAR */ if(p->inventory[i].nameid>0){ if(itemdb_isequip(p->inventory[i].nameid)==1){ mapitem.equip[eqcount].flag=0; @@ -398,30 +380,19 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } } -#ifdef FASTCHAR - -#endif /* FASTCHAR */ //printf("- Save item data to MySQL!\n"); -#ifndef FASTCHAR - memitemdata_to_sql(mapitem, eqcount, noteqcount, p->char_id,TABLE_INVENTORY); -#else /* FASTCHAR */ if (diff) memitemdata_to_sql(mapitem, eqcount, noteqcount, p->char_id,TABLE_INVENTORY); -#endif /* FASTCHAR */ //=========================================map cart data > memory ==================================== eqcount=1; noteqcount=1; -#ifdef FASTCHAR diff = 0; -#endif /* FASTCHAR */ //map cart data for(i=0;i<MAX_CART;i++){ -#ifdef FASTCHAR if (!compare_item(&p->cart[i], &cp->cart[i])) diff = 1; -#endif /* FASTCHAR */ if(p->cart[i].nameid>0){ if(itemdb_isequip(p->cart[i].nameid)==1){ mapitem.equip[eqcount].flag=0; @@ -457,16 +428,11 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } //printf("- Save cart data to MySQL!\n"); -#ifndef FASTCHAR - memitemdata_to_sql(mapitem, eqcount, noteqcount, p->char_id,TABLE_CART); -#else /* FASTCHAR */ if (diff) memitemdata_to_sql(mapitem, eqcount, noteqcount, p->char_id,TABLE_CART); -#endif /* FASTCHAR */ //===================================================================================================== -#ifdef FASTCHAR if ((p->base_exp != cp->base_exp) || (p->class != cp->class) || (p->base_level != cp->base_level) || (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || (p->zeny != cp->zeny) || @@ -484,7 +450,6 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->partner_id != cp->partner_id)) { -#endif /* FASTCHAR */ //}//---------------------------test count------------------------------ //check party_exist party_exist=0; @@ -541,7 +506,6 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle)); } -#ifdef FASTCHAR } diff = 0; @@ -554,7 +518,6 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } if (diff) { -#endif /* FASTCHAR */ //printf("- Save memo data to MySQL!\n"); //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",memo_db, p->char_id); @@ -571,11 +534,8 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ printf("DB server Error (insert `memo`)- %s\n", mysql_error(&mysql_handle)); } } -#ifdef FASTCHAR } -#endif /* FASTCHAR */ -#ifdef FASTCHAR diff = 0; for(i=0;i<MAX_SKILL;i++) if((p->skill[i].id != cp->skill[i].id) || (p->skill[i].lv != cp->skill[i].lv) || @@ -585,7 +545,6 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } if (diff) { -#endif /* FASTCHAR */ //printf("- Save skill data to MySQL!\n"); //`skill` (`char_id`, `id`, `lv`) sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",skill_db, p->char_id); @@ -597,11 +556,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ for(i=0;i<MAX_SKILL;i++){ if(p->skill[i].id){ if (p->skill[i].id && p->skill[i].flag!=1) { -#ifndef FASTCHAR - sprintf(tmp_sql,"INSERT delayed INTO `%s`(`char_id`, `id`, `lv`) VALUES ('%d', '%d','%d')", -#else /* FASTCHAR */ sprintf(tmp_sql,"INSERT INTO `%s`(`char_id`, `id`, `lv`) VALUES ('%d', '%d','%d')", -#endif /* FASTCHAR */ skill_db, char_id, p->skill[i].id, (p->skill[i].flag==0)?p->skill[i].lv:p->skill[i].flag-2); if(mysql_query(&mysql_handle, tmp_sql)) { printf("DB server Error (insert `skill`)- %s\n", mysql_error(&mysql_handle)); @@ -609,13 +564,8 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } } -#ifdef FASTCHAR } -#endif /* FASTCHAR */ - -#ifndef FASTCHAR -#else /* FASTCHAR */ diff = 0; for(i=0;i<p->global_reg_num;i++) { if ((p->global_reg[i].str == NULL) && (cp->global_reg[i].str == NULL)) @@ -629,7 +579,6 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } if (diff) { -#endif /* FASTCHAR */ //printf("- Save global_reg_value data to MySQL!\n"); //`global_reg_value` (`char_id`, `str`, `value`) sprintf(tmp_sql,"DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'",reg_db, p->char_id); @@ -649,54 +598,37 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus *p){ } } } -#ifdef FASTCHAR } -#endif /* FASTCHAR */ // Friends list // account_id, friend_id0, name0, ... tmp_p += sprintf(tmp_p, "REPLACE INTO `%s` (`id`, `account_id`",friend_db); -#ifdef FASTCHAR diff = 0; -#endif /* FASTCHAR */ for (i=0;i<20;i++) tmp_p += sprintf(tmp_p, ", `friend_id%d`, `name%d`", i, i); tmp_p += sprintf(tmp_p, ") VALUES (NULL, '%d'", char_id); -#ifndef FASTCHAR - - for (i=0;i<20;i++) -#else /* FASTCHAR */ for (i=0;i<20;i++) { -#endif /* FASTCHAR */ tmp_p += sprintf(tmp_p, ", '%d', '%s'", p->friend_id[i], p->friend_name[i]); -#ifdef FASTCHAR if ((p->friend_id[i] != cp->friend_id[i]) || strcmp(p->friend_name[i], cp->friend_name[i])) diff = 1; } -#endif /* FASTCHAR */ tmp_p += sprintf(tmp_p, ")"); -#ifndef FASTCHAR - mysql_query(&mysql_handle, tmp_sql); -#else /* FASTCHAR */ if (diff) mysql_query(&mysql_handle, tmp_sql); -#endif /* FASTCHAR */ printf("saving char is done.\n"); save_flag = 0; -#ifdef FASTCHAR memcpy(cp, p, sizeof(struct mmo_charstatus)); -#endif /* FASTCHAR */ return 0; } @@ -930,22 +862,17 @@ int memitemdata_to_sql(struct itemtemp mapitem, int eqcount, int noteqcount, int // printf("=================================================================================\n"); // } -#ifdef FASTCHAR - -#endif /* FASTCHAR */ return 0; } //===================================================================================================== int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ int i, n; char *tmp_p = tmp_sql; -#ifdef FASTCHAR struct mmo_charstatus *cp; cp = numdb_search(char_db_,char_id); if (cp != NULL) free(cp); -#endif /* FASTCHAR */ memset(p, 0, sizeof(struct mmo_charstatus)); @@ -1187,22 +1114,18 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus *p, int online){ printf("char data load success]\n"); //ok. all data load successfuly! -#ifdef FASTCHAR cp = (struct mmo_charstatus *) malloc(sizeof(struct mmo_charstatus)); memcpy(cp, p, sizeof(struct mmo_charstatus)); numdb_insert(char_db_, char_id,cp); -#endif /* FASTCHAR */ return 1; } //========================================================================================================== int mmo_char_sql_init(void) { int i; -#ifdef FASTCHAR char_db_=numdb_init(); -#endif /* FASTCHAR */ printf("init start.......\n"); // memory initialize // no need to set twice size in this routine. but some cause segmentation error. :P @@ -3396,13 +3319,11 @@ int do_init(int argc, char **argv){ return 0; } -#ifdef FASTCHAR - #undef mysql_query int debug_mysql_query(char *file, int line, void *mysql, const char *q) { - printf("sql: %s:%d# %s\n", file, line, q); +// printf("sql: %s:%d# %s\n", file, line, q); return mysql_query((MYSQL *) mysql, q); } -#endif /* FASTCHAR */ + diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 5c3480ca6..85c301cd1 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -3,9 +3,6 @@ // SQL conversion by hack // -#ifdef TWILIGHT -#define GUILDCACHE -#endif #include "char.h" #include "strlib.h" @@ -15,21 +12,17 @@ #include "int_storage.h" #include "mmo.h" #include "socket.h" -#ifdef GUILDCACHE #include "db.h" -#endif /* GUILDCACHE */ #include <string.h> #include <stdio.h> #include <stdlib.h> -#ifdef GUILDCACHE static struct dbt *guild_db_; static struct dbt *castle_db_; static struct dbt *guild_expcache_db_; static struct dbt *guild_infoevent_db_; static struct dbt *guild_castleinfoevent_db_; -#endif /* GUILDCACHE */ static struct guild *guild_pt; static struct guild *guild_pt2; @@ -46,9 +39,7 @@ int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len) int mapif_guild_info(int fd,struct guild *g); int guild_break_sub(void *key,void *data,va_list ap); -#ifdef FASTCHAR #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y) -#endif /* FASTCHAR */ // Save guild into sql int inter_guild_tosql(struct guild *g,int flag) @@ -68,11 +59,7 @@ int inter_guild_tosql(struct guild *g,int flag) if (g->guild_id<=0) return -1; -#ifndef FASTCHAR - printf("(\033[1;35m%d\033[0m) Request save guild - ",g->guild_id); -#else /* FASTCHAR */ printf("(\033[1;35m%d\033[0m) Request save guild -(flag 0x%x) ",g->guild_id, flag); -#endif /* FASTCHAR */ jstrescapecpy(t_name, g->name); @@ -206,35 +193,6 @@ int inter_guild_tosql(struct guild *g,int flag) } if (flag&2||guild_member==0){ -#ifndef FASTCHAR - //printf("- Insert guild %d to guild_member\n",g->guild_id); - for(i=0;i<g->max_member;i++){ - if (g->member[i].account_id>0){ - struct guild_member *m = &g->member[i]; - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `char_id`='%d'",guild_member_db, m->char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - printf("DB server Error (delete `guild_member`)- %s\n", mysql_error(&mysql_handle) ); - } - sprintf(tmp_sql,"INSERT INTO `%s` " - "(`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`rsv1`,`rsv2`,`name`) " - "VALUES ('%d','%d','%d','%d','%d', '%d','%d','%d','%d','%d','%d','%d','%d','%d','%s')", - guild_member_db, g->guild_id, - m->account_id,m->char_id, - m->hair,m->hair_color,m->gender, - m->class,m->lv,m->exp,m->exp_payper,m->online,m->position, - 0,0, - jstrescapecpy(t_member,m->name)); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - printf("DB server Error (insert `guild_member`)- %s\n", mysql_error(&mysql_handle) ); - } - sprintf(tmp_sql, "UPDATE `%s` SET `guild_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",char_db, g->guild_id,m->account_id,m->char_id); - if(mysql_query(&mysql_handle, tmp_sql) ) { - printf("DB server Error (update `char`)- %s\n", mysql_error(&mysql_handle) ); - } - } - } -#else /* FASTCHAR */ struct StringBuf sbuf; struct StringBuf sbuf2; int first = 1; @@ -275,7 +233,6 @@ int inter_guild_tosql(struct guild *g,int flag) StringBuf_Destroy(&sbuf2); StringBuf_Destroy(&sbuf); -#endif /* FASTCHAR */ } if (flag&4||guild_member==0){ @@ -350,16 +307,11 @@ int inter_guild_tosql(struct guild *g,int flag) } // Read guild from sql -#ifndef GUILDCACHE -int inter_guild_fromsql(int guild_id,struct guild *g) -#else /* GUILDCACHE */ struct guild * inter_guild_fromsql(int guild_id) -#endif /* GUILDCACHE */ { int i; char emblem_data[4096]; char *pstr; -#ifdef GUILDCACHE struct guild *g; if (guild_id==0) return 0; @@ -367,17 +319,9 @@ struct guild * inter_guild_fromsql(int guild_id) g = numdb_search(guild_db_,guild_id); if (g != NULL) return g; -#endif /* GUILDCACHE */ -#ifndef GUILDCACHE - if (g==NULL) return 0; -#else /* GUILDCACHE */ g = (struct guild *) malloc(sizeof(struct guild)); -#endif /* GUILDCACHE */ memset(g,0,sizeof(struct guild)); -#ifndef GUILDCACHE - if (guild_id==0) return 0; -#endif /* not GUILDCACHE */ // printf("Retrieve guild information from sql ......\n"); // printf("- Read guild %d from sql \n",guild_id); @@ -387,9 +331,7 @@ struct guild * inter_guild_fromsql(int guild_id) //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild`)- %s\n", mysql_error(&mysql_handle) ); -#ifdef GUILDCACHE free(g); -#endif /* GUILDCACHE */ return 0; } @@ -398,9 +340,7 @@ struct guild * inter_guild_fromsql(int guild_id) sql_row = mysql_fetch_row(sql_res); if (sql_row==NULL) { mysql_free_result(sql_res); -#ifdef GUILDCACHE free(g); -#endif /* GUILDCACHE */ return 0; } @@ -439,9 +379,7 @@ struct guild * inter_guild_fromsql(int guild_id) //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_member`)- %s\n", mysql_error(&mysql_handle) ); -#ifdef GUILDCACHE free(g); -#endif /* GUILDCACHE */ return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -470,9 +408,7 @@ struct guild * inter_guild_fromsql(int guild_id) //printf(" %s\n",tmp_sql); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_position`)- %s\n", mysql_error(&mysql_handle) ); -#ifdef GUILDCACHE free(g); -#endif /* GUILDCACHE */ return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -492,9 +428,7 @@ struct guild * inter_guild_fromsql(int guild_id) sprintf(tmp_sql,"SELECT `guild_id`,`opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'",guild_alliance_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_alliance`)- %s\n", mysql_error(&mysql_handle) ); -#ifdef GUILDCACHE free(g); -#endif /* GUILDCACHE */ return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -513,9 +447,7 @@ struct guild * inter_guild_fromsql(int guild_id) sprintf(tmp_sql,"SELECT `guild_id`,`name`,`mes`,`acc`,`account_id`,`rsv1`,`rsv2`,`rsv3` FROM `%s` WHERE `guild_id`='%d'",guild_expulsion_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_expulsion`)- %s\n", mysql_error(&mysql_handle) ); -#ifdef GUILDCACHE free(g); -#endif /* GUILDCACHE */ return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -540,9 +472,7 @@ struct guild * inter_guild_fromsql(int guild_id) sprintf(tmp_sql,"SELECT `guild_id`,`id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`",guild_skill_db, guild_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (select `guild_skill`)- %s\n", mysql_error(&mysql_handle) ); -#ifdef GUILDCACHE free(g); -#endif /* GUILDCACHE */ return 0; } sql_res = mysql_store_result(&mysql_handle) ; @@ -557,33 +487,19 @@ struct guild * inter_guild_fromsql(int guild_id) // printf("Successfully retrieve guild information from sql!\n"); -#ifndef GUILDCACHE - return 0; - -#else /* GUILDCACHE */ numdb_insert(guild_db_, guild_id,g); return g; -#endif /* GUILDCACHE */ } // Save guild_castle to sql int inter_guildcastle_tosql(struct guild_castle *gc) { -#ifdef FASTCHAR struct guild_castle *gcopy; -#endif /* FASTCHAR */ // `guild_castle` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`) if (gc==NULL) return 0; //printf("Save to guild_castle\n"); -#ifndef FASTCHAR - sprintf(tmp_sql,"DELETE FROM `%s` WHERE `castle_id`='%d'",guild_castle_db, gc->castle_id); - //printf(" %s\n",tmp_sql); - if(mysql_query(&mysql_handle, tmp_sql) ) { - printf("DB server Error - %s\n", mysql_error(&mysql_handle) ); - return 0; -#else /* FASTCHAR */ gcopy = numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { @@ -595,17 +511,11 @@ int inter_guildcastle_tosql(struct guild_castle *gc) (strcmp(gcopy->castle_event, gc->castle_event) == 0) && (memcmp(&gcopy->guild_id, &gc->guild_id, &gc->GID7 - &gc->guild_id) == 0)) return 0; -#endif /* FASTCHAR */ } -#ifndef FASTCHAR - - sprintf(tmp_sql,"INSERT INTO `%s` " -#else /* FASTCHAR */ memcpy(gcopy, gc, sizeof(struct guild_castle)); sprintf(tmp_sql,"REPLACE INTO `%s` " -#endif /* FASTCHAR */ "(`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`," "`visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`," "`Ghp0`, `Ghp1`, `Ghp2`, `Ghp3`, `Ghp4`, `Ghp5`, `Ghp6`, `Ghp7`)" @@ -638,15 +548,9 @@ int inter_guildcastle_tosql(struct guild_castle *gc) // Read guild_castle from sql int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) { -#ifndef FASTCHAR - -#else /* FASTCHAR */ - struct guild_castle *gcopy; -#endif /* FASTCHAR */ if (gc==NULL) return 0; //printf("Read from guild_castle\n"); -#ifdef FASTCHAR gcopy = numdb_search(castle_db_,gc->castle_id); if (gcopy == NULL) { @@ -657,7 +561,6 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) return 0; } -#endif /* FASTCHAR */ memset(gc,0,sizeof(struct guild_castle)); gc->castle_id=castle_id; if (castle_id==-1) return 0; @@ -707,11 +610,9 @@ int inter_guildcastle_fromsql(int castle_id,struct guild_castle *gc) } mysql_free_result(sql_res) ; //resource free -#ifdef FASTCHAR memcpy(gcopy, gc, sizeof(struct guild_castle)); -#endif /* FASTCHAR */ return 0; } @@ -746,13 +647,11 @@ int inter_guild_sql_init() { int i; -#ifdef GUILDCACHE guild_db_=numdb_init(); castle_db_=numdb_init(); guild_expcache_db_=numdb_init(); guild_infoevent_db_=numdb_init(); guild_castleinfoevent_db_=numdb_init(); -#endif /* GUILDCACHE */ printf("interserver guild memory initialize.... (%d byte)\n",sizeof(struct guild)); guild_pt = calloc(sizeof(struct guild), 1); @@ -795,9 +694,6 @@ int inter_guild_sql_init() // Get guild by its name struct guild* search_guildname(char *str) { -#ifndef GUILDCACHE - struct guild *g=guild_pt; -#endif /* not GUILDCACHE */ char t_name[24]; int guild_id=0; printf("search_guildname\n"); @@ -811,12 +707,7 @@ struct guild* search_guildname(char *str) guild_id = atoi (sql_row[0]); } mysql_free_result(sql_res); -#ifndef GUILDCACHE - inter_guild_fromsql(guild_id,g); - return g; -#else /* GUILDCACHE */ return inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ } // Check if guild is empty @@ -1248,13 +1139,7 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member // Return guild info to client int mapif_parse_GuildInfo(int fd,int guild_id) { -#ifndef GUILDCACHE - struct guild *g; - g=guild_pt; - inter_guild_fromsql(guild_id,g); -#else /* GUILDCACHE */ struct guild * g = inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ if(g!=NULL&&g->guild_id>0){ guild_calcinfo(g); mapif_guild_info(fd,g); @@ -1266,17 +1151,9 @@ int mapif_parse_GuildInfo(int fd,int guild_id) // Add member to guild int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) { -#ifndef GUILDCACHE - struct guild *g=guild_pt; -#else /* GUILDCACHE */ struct guild *g = inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ int i; -#ifndef GUILDCACHE - inter_guild_fromsql(guild_id,g); -#endif /* not GUILDCACHE */ - if(g==NULL||g->guild_id<=0){ mapif_guild_memberadded(fd,guild_id,m->account_id,m->char_id,1); return 0; @@ -1300,13 +1177,7 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) // Delete member from guild int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes) { -#ifndef GUILDCACHE - struct guild *g=guild_pt; - - inter_guild_fromsql(guild_id,g); -#else /* GUILDCACHE */ struct guild *g= inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ if(g!=NULL&&g->guild_id>0){ int i; @@ -1356,38 +1227,18 @@ int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int fl /* mapif_guild_leaved(guild_id,account_id,char_id,flag,g->member[i].name,mes); */ } -#ifndef GUILDCACHE - -#endif /* not GUILDCACHE */ return 0; } -#ifdef GUILDCACHE - -#endif /* GUILDCACHE */ // Change member info int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, int account_id,int char_id,int online,int lv,int class) { // Could speed up by manipulating only guild_member -#ifndef GUILDCACHE - struct guild * g=guild_pt; -#else /* GUILDCACHE */ struct guild * g= inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ int i,alv,c; -#ifndef GUILDCACHE - - - - -#endif /* not GUILDCACHE */ if(g==NULL||g->guild_id<=0) return 0; -#ifndef GUILDCACHE - - inter_guild_fromsql(guild_id,g); -#endif /* not GUILDCACHE */ g->connect_member=0; @@ -1418,19 +1269,9 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id, // BreakGuild int mapif_parse_BreakGuild(int fd,int guild_id) { -#ifndef GUILDCACHE - struct guild *g=guild_pt; -#else /* GUILDCACHE */ struct guild *g= inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ if(g==NULL) return 0; -#ifndef GUILDCACHE - inter_guild_fromsql(guild_id,g); - - - -#endif /* not GUILDCACHE */ // Delete guild from sql //printf("- Delete guild %d from guild\n",guild_id); @@ -1494,25 +1335,12 @@ int mapif_parse_GuildMessage(int fd,int guild_id,int account_id,char *mes,int le int mapif_parse_GuildBasicInfoChange(int fd,int guild_id, int type,const char *data,int len) { -#ifndef GUILDCACHE - struct guild * g=guild_pt; -#else /* GUILDCACHE */ struct guild * g = inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ // int dd=*((int *)data); short dw=*((short *)data); -#ifndef GUILDCACHE - - - - -#endif /* not GUILDCACHE */ if(g==NULL||g->guild_id<=0) return 0; -#ifndef GUILDCACHE - inter_guild_fromsql(guild_id,g); -#endif /* not GUILDCACHE */ switch(type){ case GBI_GUILDLV: { printf("GBI_GUILDLV\n"); @@ -1539,15 +1367,8 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha { // Could make some improvement in speed, because only change guild_member int i; -#ifndef GUILDCACHE - struct guild * g=guild_pt; -#else /* GUILDCACHE */ struct guild * g = inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ -#ifndef GUILDCACHE - inter_guild_fromsql(guild_id,g); -#endif /* not GUILDCACHE */ //printf("GuildMemberInfoChange %s \n",(type==GMI_EXP)?"GMI_EXP":"OTHER"); if(g==NULL){ @@ -1586,13 +1407,7 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha int mapif_parse_GuildPosition(int fd,int guild_id,int idx,struct guild_position *p) { // Could make some improvement in speed, because only change guild_position -#ifndef GUILDCACHE - struct guild * g=guild_pt; - - inter_guild_fromsql(guild_id,g); -#else /* GUILDCACHE */ struct guild * g = inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ if(g==NULL || idx<0 || idx>=MAX_GUILDPOSITION){ return 0; @@ -1607,16 +1422,9 @@ int mapif_parse_GuildPosition(int fd,int guild_id,int idx,struct guild_position int mapif_parse_GuildSkillUp(int fd,int guild_id,int skill_num,int account_id) { // Could make some improvement in speed, because only change guild_position -#ifndef GUILDCACHE - struct guild *g=guild_pt; -#else /* GUILDCACHE */ struct guild *g = inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ int idx = skill_num - GD_SKILLBASE; -#ifndef GUILDCACHE - inter_guild_fromsql(guild_id,g); -#endif /* not GUILDCACHE */ if(g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) return 0; @@ -1642,15 +1450,8 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2, // Could speed up struct guild *g[2]; int j,i; -#ifndef GUILDCACHE - g[0]=guild_pt; - g[1]=guild_pt2; - inter_guild_fromsql(guild_id1,g[0]); - inter_guild_fromsql(guild_id2,g[1]); -#else /* GUILDCACHE */ g[0]= inter_guild_fromsql(guild_id1); g[1]= inter_guild_fromsql(guild_id2); -#endif /* GUILDCACHE */ if(g[0]==NULL || g[1]==NULL || g[0]->guild_id ==0 || g[1]->guild_id==0) return 0; @@ -1684,13 +1485,7 @@ int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2, // ギルド告知変更要求 int mapif_parse_GuildNotice(int fd,int guild_id,const char *mes1,const char *mes2) { -#ifndef GUILDCACHE - struct guild *g=guild_pt; - - inter_guild_fromsql(guild_id,g); -#else /* GUILDCACHE */ struct guild *g= inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ if(g==NULL||g->guild_id<=0) return 0; @@ -1702,13 +1497,7 @@ int mapif_parse_GuildNotice(int fd,int guild_id,const char *mes1,const char *mes // ギルドエンブレム変更要求 int mapif_parse_GuildEmblem(int fd,int len,int guild_id,int dummy,const char *data) { -#ifndef GUILDCACHE - struct guild * g=guild_pt; - - inter_guild_fromsql(guild_id,g); -#else /* GUILDCACHE */ struct guild * g= inter_guild_fromsql(guild_id); -#endif /* GUILDCACHE */ if(g==NULL||g->guild_id<=0) return 0; @@ -1769,12 +1558,7 @@ int mapif_parse_GuildCastleDataSave(int fd,int castle_id,int index,int value) case 1: if( gc->guild_id!=value ){ int gid=(value)?value:gc->guild_id; -#ifndef GUILDCACHE - struct guild *g=guild_pt; - inter_guild_fromsql(gid, g); -#else /* GUILDCACHE */ struct guild *g=inter_guild_fromsql(gid); -#endif /* GUILDCACHE */ if(log_inter) inter_log("guild %s (id=%d) %s castle id=%d" RETCODE, (g)?g->name:"??" ,gid, (value)?"occupy":"abandon", index); diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index a03936744..ecc252185 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -17,10 +17,8 @@ int mapif_party_broken(int party_id,int flag); int party_check_empty(struct party *p); int mapif_parse_PartyLeave(int fd,int party_id,int account_id); -#ifdef FASTCHAR #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y) -#endif /* FASTCHAR */ // Save party to mysql int inter_party_tosql(int party_id,struct party *p) { @@ -124,7 +122,7 @@ int inter_party_tosql(int party_id,struct party *p) int i = 0; while (i<MAX_PARTY&&((p->member[i].account_id>0&&p->member[i].leader==0)||(p->member[i].account_id<0))) i++; if (i<MAX_PARTY) leader_id = p->member[i].account_id; - sprintf(tmp_sql,"INSERT DELAYED INTO `%s` (`party_id`, `name`, `exp`, `item`, `leader_id`) VALUES ('%d', '%s', '%d', '%d', '%d')", + sprintf(tmp_sql,"INSERT INTO `%s` (`party_id`, `name`, `exp`, `item`, `leader_id`) VALUES ('%d', '%s', '%d', '%d', '%d')", party_db, party_id, t_name, p->exp, p->item,leader_id); if(mysql_query(&mysql_handle, tmp_sql) ) { printf("DB server Error (inset/update `party`)- %s\n", mysql_error(&mysql_handle) ); diff --git a/src/char_sql/int_pet.c b/src/char_sql/int_pet.c index 96ab3f6f4..7f2ed2a7c 100644 --- a/src/char_sql/int_pet.c +++ b/src/char_sql/int_pet.c @@ -12,12 +12,8 @@ struct s_pet *pet_pt; static int pet_newid = 100; -#ifdef FASTCHAR #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y) - -#endif /* FASTCHAR */ - //--------------------------------------------------------- int inter_pet_tosql(int pet_id, struct s_pet *p) { //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) diff --git a/src/char_sql/int_storage.c b/src/char_sql/int_storage.c index 455ff42c4..a6ad01eea 100644 --- a/src/char_sql/int_storage.c +++ b/src/char_sql/int_storage.c @@ -13,9 +13,7 @@ struct storage *storage_pt=NULL; struct guild_storage *guild_storage_pt=NULL; -#ifdef FASTCHAR #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y) -#endif /* FASTCHAR */ // storage data -> DB conversion int storage_tosql(int account_id,struct storage *p){ |