本文整理汇总了C++中DBIterator::exists方法的典型用法代码示例。如果您正苦于以下问题:C++ DBIterator::exists方法的具体用法?C++ DBIterator::exists怎么用?C++ DBIterator::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBIterator
的用法示例。
在下文中一共展示了DBIterator::exists方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: script_save_mapreg
/// Saves permanent variables to savefile
static void script_save_mapreg(void)
{
FILE *fp;
int lock;
DBIterator* iter;
void* data;
DBKey key;
fp = lock_fopen(mapreg_txt,&lock);
if( fp == NULL )
{
ShowError("script_save_mapreg: Unable to lock-open file [%s]!\n", mapreg_txt);
return;
}
iter = mapreg_db->iterator(mapreg_db);
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
{
int num = (key.i & 0x00ffffff);
int i = (key.i & 0xff000000) >> 24;
const char* name = get_str(num);
if( name[1] == '@' )
continue;
if( i == 0 )
fprintf(fp, "%s\t%d\n", name, (int)data);
else
fprintf(fp, "%s,%d\t%d\n", name, i, (int)data);
}
iter->destroy(iter);
iter = mapregstr_db->iterator(mapregstr_db);
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
{
int num = (key.i & 0x00ffffff);
int i = (key.i & 0xff000000) >> 24;
const char* name = get_str(num);
if( name[1] == '@' )
continue;
if( i == 0 )
fprintf(fp, "%s\t%s\n", name, (char *)data);
else
fprintf(fp, "%s,%d\t%s\n", name, i, (char *)data);
}
iter->destroy(iter);
lock_fclose(fp,mapreg_txt,&lock);
mapreg_dirty = false;
}
示例2: party_send_xy_timer
int party_send_xy_timer(int tid, unsigned int tick, int id, intptr data)
{
struct party_data* p;
DBIterator* iter = party_db->iterator(party_db);
// for each existing party,
for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) )
{
int i;
// for each member of this party,
for( i = 0; i < MAX_PARTY; i++ )
{
//struct map_session_data* sd = p->data[i].sd;
struct map_session_data* sd = map_charid2sd(p->party.member[i].char_id); //temporary crashfix
if( !sd ) continue;
if( p->data[i].x != sd->bl.x || p->data[i].y != sd->bl.y )
{// perform position update
clif_party_xy(sd);
p->data[i].x = sd->bl.x;
p->data[i].y = sd->bl.y;
}
if (battle_config.party_hp_mode && p->data[i].hp != sd->battle_status.hp)
{// perform hp update
clif_party_hp(sd);
p->data[i].hp = sd->battle_status.hp;
}
}
}
iter->destroy(iter);
return 0;
}
示例3: party_booking_search
void party_booking_search(struct map_session_data *sd, short level, short mapid, short job, unsigned long lastindex, short resultcount)
{
struct party_booking_ad_info *pb_ad;
int i, count=0;
unsigned long index_list[10];
bool more_result = false;
DBIterator* iter = party_booking_db->iterator(party_booking_db);
memset(index_list, 0, sizeof(index_list));
for( pb_ad = (struct party_booking_ad_info*)iter->first(iter,NULL); iter->exists(iter); pb_ad = (struct party_booking_ad_info*)iter->next(iter,NULL) )
{
if (pb_ad->index < lastindex || (pb_ad->p_detail.level < level || pb_ad->p_detail.level-15 > level))
continue;
if (count >= 10){
more_result = true;
break;
}
if (mapid == 0 && job == -1)
index_list[count] = pb_ad->index;
else if (mapid == 0) {
for(i=0; i<6; i++)
if (pb_ad->p_detail.job[i] == job && job != -1)
index_list[count] = pb_ad->index;
} else if (job == -1){
if (pb_ad->p_detail.mapid == mapid)
index_list[count] = pb_ad->index;
}
count++;
}
iter->destroy(iter);
clif_PartyBookingSearchAck(sd->fd, index_list, count, more_result);
}
示例4: inter_guild_save
// ギルドデ??のセ?ブ
int inter_guild_save()
{
FILE *fp;
int lock;
DBIterator* iter;
struct guild* g;
struct guild_castle* gc;
// save guild data
if ((fp = lock_fopen(guild_txt, &lock)) == NULL) {
ShowError("int_guild: can't write [%s] !!! data is lost !!!\n", guild_txt);
return 1;
}
iter = guild_db->iterator(guild_db);
for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) )
{
char line[16384];
inter_guild_tostr(line, g);
fprintf(fp, "%s\n", line);
}
iter->destroy(iter);
// fprintf(fp, "%d\t%%newid%%\n", guild_newid);
lock_fclose(fp, guild_txt, &lock);
// save castle data
if ((fp = lock_fopen(castle_txt,&lock)) == NULL) {
ShowError("int_guild: can't write [%s] !!! data is lost !!!\n", castle_txt);
return 1;
}
iter = castle_db->iterator(castle_db);
for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) )
{
char line[16384];
inter_guildcastle_tostr(line, gc);
fprintf(fp, "%s\n", line);
}
iter->destroy(iter);
lock_fclose(fp, castle_txt, &lock);
return 0;
}
示例5: script_save_mapreg
/// Saves permanent variables to database
static void script_save_mapreg(void)
{
DBIterator* iter;
DBData *data;
DBKey key;
iter = db_iterator(mapreg_db);
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
{
int num = (key.i & 0x00ffffff);
int i = (key.i & 0xff000000) >> 24;
const char* name = get_str(num);
if( name[1] == '@' )
continue;
if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d'", mapreg_table, db_data2i(data), name, i) )
Sql_ShowDebug(mmysql_handle);
}
dbi_destroy(iter);
iter = db_iterator(mapregstr_db);
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
{
int num = (key.i & 0x00ffffff);
int i = (key.i & 0xff000000) >> 24;
const char* name = get_str(num);
char tmp_str2[2*255+1];
if( name[1] == '@' )
continue;
Sql_EscapeStringLen(mmysql_handle, tmp_str2, db_data2ptr(data), safestrnlen(db_data2ptr(data), 255));
if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d'", mapreg_table, tmp_str2, name, i) )
Sql_ShowDebug(mmysql_handle);
}
dbi_destroy(iter);
mapreg_dirty = false;
}
示例6:
/// lookup: map index -> castle*
struct guild_castle* guild_mapindex2gc(short mapindex)
{
struct guild_castle* gc;
DBIterator* iter = castle_db->iterator(castle_db);
for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) )
{
if( gc->mapindex == mapindex )
break;
}
iter->destroy(iter);
return gc;
}
示例7: guild_searchname
/// lookup: guild name -> guild*
struct guild* guild_searchname(char* str)
{
struct guild* g;
DBIterator* iter = guild_db->iterator(guild_db);
for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) )
{
if( strcmpi(g->name, str) == 0 )
break;
}
iter->destroy(iter);
return g;
}
示例8: party_searchname
/// Party data lookup using party name.
struct party_data* party_searchname(const char* str)
{
struct party_data* p;
DBIterator* iter = party_db->iterator(party_db);
for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) )
{
if( strncmpi(p->party.name,str,NAME_LENGTH) == 0 )
break;
}
iter->destroy(iter);
return p;
}
示例9: auction_count
static int auction_count(int char_id, bool buy)
{
int i = 0;
struct auction_data *auction;
DBIterator* iter;
DBKey key;
iter = auction_db_->iterator(auction_db_);
for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) )
{
if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) )
i++;
}
iter->destroy(iter);
return i;
}
示例10: mapif_parse_Auction_requestlist
static void mapif_parse_Auction_requestlist(int fd)
{
char searchtext[NAME_LENGTH];
int char_id = RFIFOL(fd,4), len = sizeof(struct auction_data);
int price = RFIFOL(fd,10);
short type = RFIFOW(fd,8), page = max(1,RFIFOW(fd,14));
unsigned char buf[5 * sizeof(struct auction_data)];
DBIterator* iter;
DBKey key;
struct auction_data *auction;
short i = 0, j = 0, pages = 1;
memcpy(searchtext, RFIFOP(fd,16), NAME_LENGTH);
iter = auction_db_->iterator(auction_db_);
for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) )
{
if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) ||
(type == 1 && auction->type != IT_WEAPON) ||
(type == 2 && auction->type != IT_CARD) ||
(type == 3 && auction->type != IT_ETC) ||
(type == 4 && !strstr(auction->item_name, searchtext)) ||
(type == 5 && auction->price > price) ||
(type == 6 && auction->seller_id != char_id) ||
(type == 7 && auction->buyer_id != char_id) )
continue;
i++;
if( i > 5 )
{ // Counting Pages of Total Results (5 Results per Page)
pages++;
i = 1; // First Result of This Page
}
if( page != pages )
continue; // This is not the requested Page
memcpy(WBUFP(buf, j * len), auction, len);
j++; // Found Results
}
iter->destroy(iter);
mapif_Auction_sendlist(fd, char_id, j, pages, buf);
}
示例11: channel_list
void channel_list(struct map_session_data *sd)
{ // Display a list of all channels
char output[256];
struct channel_data *cd;
DBIterator* iter;
DBKey key;
iter = channel_db->iterator(channel_db);
for( cd = (struct channel_data *)iter->first(iter,&key); iter->exists(iter); cd = (struct channel_data *)iter->next(iter,&key) )
{
if( cd->users < 1 && cd->type == CHN_USER )
continue;
sprintf(output, msg_txt(812), cd->name, cd->users, !cd->pass[0] ? msg_txt(813) : msg_txt(814));
clif_displaymessage(sd->fd, output);
}
iter->destroy(iter);
return;
}
示例12: mapif_guild_castle_alldataload
int mapif_guild_castle_alldataload(int fd)
{
DBIterator* iter;
struct guild_castle* gc;
int len = 4;
WFIFOHEAD(fd, 4 + MAX_GUILDCASTLE*sizeof(struct guild_castle));
WFIFOW(fd,0) = 0x3842;
iter = castle_db->iterator(castle_db);
for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) )
{
memcpy(WFIFOP(fd,len), gc, sizeof(struct guild_castle));
len += sizeof(struct guild_castle);
}
iter->destroy(iter);
WFIFOW(fd,2) = len;
WFIFOSET(fd, len);
return 0;
}
示例13: read_config
/**
* Loads group configuration from config file into memory.
* @private
*/
static void read_config(void)
{
config_setting_t *groups = NULL;
const char *config_filename = "conf/groups.conf"; // FIXME hardcoded name
int group_count = 0;
if (conf_read_file(&pc_group_config, config_filename))
return;
groups = config_lookup(&pc_group_config, "groups");
if (groups != NULL) {
GroupSettings *group_settings = NULL;
DBIterator *iter = NULL;
int i, loop = 0;
group_count = config_setting_length(groups);
for (i = 0; i < group_count; ++i) {
int id = 0, level = 0;
const char *groupname = NULL;
int log_commands = 0;
config_setting_t *group = config_setting_get_elem(groups, i);
if (!config_setting_lookup_int(group, "id", &id)) {
ShowConfigWarning(group, "pc_groups:read_config: \"groups\" list member #%d has undefined id, removing...", i);
config_setting_remove_elem(groups, i);
--i;
--group_count;
continue;
}
if (id2group(id) != NULL) {
ShowConfigWarning(group, "pc_groups:read_config: duplicate group id %d, removing...", i);
config_setting_remove_elem(groups, i);
--i;
--group_count;
continue;
}
config_setting_lookup_int(group, "level", &level);
config_setting_lookup_int(group, "log_commands", &log_commands);
if (!config_setting_lookup_string(group, "name", &groupname)) {
char temp[20];
config_setting_t *name = NULL;
snprintf(temp, sizeof(temp), "Group %d", id);
if ((name = config_setting_add(group, "name", CONFIG_TYPE_STRING)) == NULL ||
!config_setting_set_string(name, temp)) {
ShowError("pc_groups:read_config: failed to set missing group name, id=%d, skipping... (%s:%d)\n",
id, config_setting_source_file(group), config_setting_source_line(group));
continue;
}
config_setting_lookup_string(group, "name", &groupname); // Retrieve the pointer
}
if (name2group(groupname) != NULL) {
ShowConfigWarning(group, "pc_groups:read_config: duplicate group name %s, removing...", groupname);
config_setting_remove_elem(groups, i);
--i;
--group_count;
continue;
}
CREATE(group_settings, GroupSettings, 1);
group_settings->id = id;
group_settings->level = level;
group_settings->name = groupname;
group_settings->log_commands = (bool)log_commands;
group_settings->inherit = config_setting_get_member(group, "inherit");
group_settings->commands = config_setting_get_member(group, "commands");
group_settings->permissions = config_setting_get_member(group, "permissions");
group_settings->inheritance_done = false;
group_settings->root = group;
strdb_put(pc_groupname_db, groupname, group_settings);
idb_put(pc_group_db, id, group_settings);
}
group_count = config_setting_length(groups); // Save number of groups
// Check if all commands and permissions exist
iter = pc_group_db->iterator(pc_group_db);
for (group_settings = (GroupSettings*)iter->first(iter, NULL);
iter->exists(iter);
group_settings = (GroupSettings*)iter->next(iter, NULL)) {
config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions;
int count = 0, i;
// Make sure there is "commands" group
if (commands == NULL)
commands = group_settings->commands = config_setting_add(group_settings->root, "commands", CONFIG_TYPE_GROUP);
count = config_setting_length(commands);
for (i = 0; i < count; ++i) {
config_setting_t *command = config_setting_get_elem(commands, i);
const char *name = config_setting_name(command);
//.........这里部分代码省略.........