int mapif_parse_SaveGuildStorage(int fd) { int guild_id; int len; guild_id = RFIFOL(fd,8); len = RFIFOW(fd,2); if( sizeof(struct guild_storage) != len - 12 ) { ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12); } else { if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) Sql_ShowDebug(sql_handle); else if( Sql_NumRows(sql_handle) > 0 ) {// guild exists Sql_FreeResult(sql_handle); guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12)); mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); return 0; } Sql_FreeResult(sql_handle); } mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1); return 0; }
int mapif_parse_SaveGuildStorage(int fd) { int guild_exist=1; int guild_id=RFIFOL(fd,8); int len=RFIFOW(fd,2); if(sizeof(struct guild_storage)!=len-12){ ShowError("inter storage: data size error %d %d\n",sizeof(struct guild_storage),len-12); } else { #if 0 // Again, innodb key checks make the check pointless // Check if guild exists, I may write a function for this later, coz I use it several times. //printf("- Check if guild %d exists\n",g->guild_id); sprintf(tmp_sql, "SELECT count(*) FROM `%s` WHERE `guild_id`='%d'",guild_db, guild_id); 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); } sql_res = mysql_store_result(&mysql_handle) ; if (sql_res!=NULL && mysql_num_rows(sql_res)>0) { sql_row = mysql_fetch_row(sql_res); guild_exist = atoi (sql_row[0]); //printf("- Check if guild %d exists : %s\n",g->guild_id,((guild_exist==0)?"No":"Yes")); } mysql_free_result(sql_res) ; //resource free #endif if(guild_exist==1) { memcpy(guild_storage_pt,RFIFOP(fd,12),sizeof(struct guild_storage)); guild_storage_tosql(guild_id,guild_storage_pt); mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,0); } else mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,1); } return 0; }
int mapif_parse_SaveGuildStorage(int fd) { int guild_id; int len; RFIFOHEAD(fd); guild_id = RFIFOL(fd,8); len = RFIFOW(fd,2); if( sizeof(struct guild_storage) != len - 12 ) { ShowError("[Inter_Stor] - Dados corrompidos! (%d != %d)\n", sizeof(struct guild_storage), len - 12); } else { if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) ) Sql_ShowDebug(sql_handle); else if( SQL->NumRows(sql_handle) > 0 ) {// guild exists SQL->FreeResult(sql_handle); guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12)); mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0); return 0; } SQL->FreeResult(sql_handle); } mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1); return 0; }
int mapif_parse_SaveGuildStorage(int fd) { struct guild_storage *gs; int guild_id, len; guild_id=RFIFOL(fd,8); len=RFIFOW(fd,2); if(sizeof(struct guild_storage)!=len-12){ ShowError("inter storage: data size error %d %d\n",sizeof(struct guild_storage),len-12); } else { gs=guild2storage(guild_id); if(gs) { memcpy(gs,RFIFOP(fd,12),sizeof(struct guild_storage)); mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,0); } else mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,1); } return 0; }