本文整理汇总了C++中dbi_next函数的典型用法代码示例。如果您正苦于以下问题:C++ dbi_next函数的具体用法?C++ dbi_next怎么用?C++ dbi_next使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbi_next函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: channel_delete
/**
* Deletes a chat channel.
*
* @param chan The channel to delete
*/
void channel_delete(struct channel_data *chan)
{
nullpo_retv(chan);
if (db_size(chan->users) && !channel->config->closing) {
DBIterator *iter;
struct map_session_data *sd;
iter = db_iterator(chan->users);
for (sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter)) {
channel->leave_sub(chan, sd);
}
dbi_destroy(iter);
}
if (chan->banned) {
db_destroy(chan->banned);
chan->banned = NULL;
}
db_destroy(chan->users);
if (chan->m) {
map->list[chan->m].channel = NULL;
aFree(chan);
} else if (chan->type == HCS_TYPE_ALLY) {
aFree(chan);
} else if (!channel->config->closing) {
strdb_remove(channel->db, chan->name);
}
}
开发者ID:Ancyker,项目名称:Hercules,代码行数:32,代码来源:channel.c
示例2: account_db_txt_iter_next
/// Fetches the next account in the database.
static bool account_db_txt_iter_next(AccountDBIterator* self, struct mmo_account* acc)
{
AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)self;
struct mmo_account* tmp = (struct mmo_account*)dbi_next(iter->iter);
if( dbi_exists(iter->iter) )
{
memcpy(acc, tmp, sizeof(struct mmo_account));
return true;
}
return false;
}
开发者ID:KimKyung-wook,项目名称:ilathena-project,代码行数:12,代码来源:account_txt.c
示例3: db_iterator
/// Party data lookup using party name.
struct party_data *party_searchname(const char *str)
{
struct party_data *p;
DBIterator *iter = db_iterator(party_db);
for( p = dbi_first(iter); dbi_exists(iter); p = dbi_next(iter) ) {
if( strncmpi(p->party.name,str,NAME_LENGTH) == 0 )
break;
}
dbi_destroy(iter);
return p;
}
开发者ID:SamuelHercules,项目名称:idathena,代码行数:14,代码来源:party.c
示例4: clan_searchname
struct clan* clan_searchname( const char* name ){
struct clan* c;
DBIterator *iter = db_iterator(clan_db);
for( c = (struct clan*)dbi_first(iter); dbi_exists(iter); c = (struct clan*)dbi_next(iter) ){
if( strncmpi( c->name, name, NAME_LENGTH ) == 0 ){
break;
}
}
dbi_destroy(iter);
return c;
}
开发者ID:AtlantisRO,项目名称:rathena,代码行数:13,代码来源:clan.c
示例5: mapif_parse_PartyShareLevel
//Used to update party share level range in run time
int mapif_parse_PartyShareLevel(int fd,unsigned int share_lvl)
{
struct party_data *p;
DBIterator* iter = db_iterator(party_db_);
party_share_level = share_lvl;
for(p = dbi_first(iter); dbi_exists(iter); p = dbi_next(iter)) { //Update online parties
if(p->party.count > 1)
int_party_calc_state(p);
}
dbi_destroy(iter);
return 1;
}
开发者ID:BlazingSpear,项目名称:rathena,代码行数:16,代码来源:int_party.c
示例6: auction_count
static int auction_count(int char_id, bool buy)
{
int i = 0;
struct auction_data *auction;
DBIterator *iter = db_iterator(auction_db_);
for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) )
{
if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) )
i++;
}
dbi_destroy(iter);
return i;
}
开发者ID:Boooo,项目名称:i-aint-quitting,代码行数:15,代码来源:int_auction.c
示例7: mapif_parse_PartyShareLevel
int mapif_parse_PartyShareLevel(int fd,unsigned int share_lvl)
{
struct party_data *p;
DBIterator* iter = db_iterator(party_db_);
party_share_level = share_lvl;
for(p = dbi_first(iter); dbi_exists(iter); p = dbi_next(iter)) { //Update online parties
if(p->party.count > 1)
int_party_calc_state(p);
else if(!p->party.count) //Remove parties from memory that have no players online
idb_remove(party_db_, p->party.party_id);
}
dbi_destroy(iter);
return 1;
}
开发者ID:SNDBXIE,项目名称:myway-eathena,代码行数:17,代码来源:int_party.c
示例8: 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 = db_iterator(auction_db_);
struct auction_data *auction;
short i = 0, j = 0, pages = 1;
memcpy(searchtext, RFIFOP(fd,16), NAME_LENGTH);
for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) )
{
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
}
dbi_destroy(iter);
mapif_Auction_sendlist(fd, char_id, j, pages, buf);
}
开发者ID:Boooo,项目名称:i-aint-quitting,代码行数:42,代码来源:int_auction.c
示例9: party_send_xy_timer
int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct party_data* p;
DBIterator *iter = db_iterator(party_db);
// for each existing party,
for( p = dbi_first(iter); dbi_exists(iter); p = dbi_next(iter) )
{
int i;
if( !p->party.count )
{// no online party members so do not iterate
continue;
}
// for each member of this party,
for( i = 0; i < MAX_PARTY; i++ )
{
struct map_session_data* sd = p->data[i].sd;
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;
}
}
}
dbi_destroy(iter);
return 0;
}
开发者ID:Raizen,项目名称:Cronus,代码行数:38,代码来源:party.c
示例10: 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;
struct party_booking_ad_info *result_list[PARTY_BOOKING_RESULTS];
bool more_result = false;
DBIterator *iter = db_iterator (party_booking_db);
memset (result_list, 0, sizeof (result_list));
for (pb_ad = dbi_first (iter); dbi_exists (iter); pb_ad = dbi_next (iter)) {
if (pb_ad->index < lastindex || (level && (pb_ad->p_detail.level < level - 15 || pb_ad->p_detail.level > level)))
continue;
if (count >= PARTY_BOOKING_RESULTS) {
more_result = true;
break;
}
if (mapid == 0 && job == -1)
result_list[count] = pb_ad;
else if (mapid == 0) {
for (i = 0; i < PARTY_BOOKING_JOBS; i++)
if (pb_ad->p_detail.job[i] == job && job != -1)
result_list[count] = pb_ad;
} else if (job == -1) {
if (pb_ad->p_detail.mapid == mapid)
result_list[count] = pb_ad;
}
if (result_list[count]) {
count++;
}
}
dbi_destroy (iter);
clif_PartyBookingSearchAck (sd->fd, result_list, count, more_result);
}
开发者ID:Celso1415,项目名称:Fusion,代码行数:37,代码来源:party.c
示例11: channel_pcban
/**
* A player is attempting to modify the banlist
* @param sd: Player data
* @param chname: Channel name
* @param pname: Player to ban or unban
* @param flag: Ban options (0 - Ban, 1 - Unban, 2 - Unban all, 3 - Ban list)
* @return 0 on success or -1 on failure
*/
int channel_pcban(struct map_session_data *sd, char *chname, char *pname, int flag){
struct Channel *channel;
char output[CHAT_SIZE_MAX];
struct map_session_data *tsd = map_nick2sd(pname,false);
if( channel_chk(chname,NULL,1) ) {
clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
return -1;
}
channel = channel_name2channel(chname,sd,0);
if( !channel ) {
sprintf(output, msg_txt(sd,1407), chname);// Channel '%s' is not available.
clif_displaymessage(sd->fd, output);
return -1;
}
if( !pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
if (channel->char_id != sd->status.char_id) {
sprintf(output, msg_txt(sd,1412), chname);// You're not the owner of channel '%s'.
clif_displaymessage(sd->fd, output);
return -1;
} else if (!channel_config.private_channel.ban) {
sprintf(output, msg_txt(sd,765), chname); // You're not allowed to ban a player.
clif_displaymessage(sd->fd, output);
return -1;
}
}
if(flag != 2 && flag != 3){
char banned;
if(!tsd || pc_has_permission(tsd, PC_PERM_CHANNEL_ADMIN) ) {
sprintf(output, msg_txt(sd,1464), pname);// Ban failed for player '%s'.
clif_displaymessage(sd->fd, output);
return -1;
}
banned = channel_haspcbanned(channel,tsd);
if(!flag && banned==1) {
sprintf(output, msg_txt(sd,1465), tsd->status.name);// Player '%s' is already banned from this channel.
clif_displaymessage(sd->fd, output);
return -1;
}
else if(flag==1 && banned==0) {
sprintf(output, msg_txt(sd,1440), tsd->status.name);// Player '%s' is not banned from this channel.
clif_displaymessage(sd->fd, output);
return -1;
}
}
else {
if( !db_size(channel->banned) ) {
sprintf(output, msg_txt(sd,1439), chname);// Channel '%s' contains no banned players.
clif_displaymessage(sd->fd, output);
return 0;
}
}
//let properly alter the list now
switch(flag){
case 0: {
struct chan_banentry *cbe;
if (!tsd)
return -1;
CREATE(cbe, struct chan_banentry, 1);
cbe->char_id = tsd->status.char_id;
strcpy(cbe->char_name,tsd->status.name);
idb_put(channel->banned, tsd->status.char_id, cbe);
channel_clean(channel,tsd,0);
sprintf(output, msg_txt(sd,1437),tsd->status.name,chname); // Player '%s' is banned from the '%s' channel.
break;
}
case 1:
if (!tsd)
return -1;
idb_remove(channel->banned, tsd->status.char_id);
sprintf(output, msg_txt(sd,1441),tsd->status.name,chname); // Player '%s' is unbanned from the '%s' channel.
break;
case 2:
db_clear(channel->banned);
sprintf(output, msg_txt(sd,1442),chname); // Cleared all bans from the '%s' channel.
break;
case 3: {
DBIterator *iter = db_iterator(channel->banned);
struct chan_banentry *cbe;
sprintf(output, msg_txt(sd,1443), channel->name);// ---- '#%s' Ban List:
clif_displaymessage(sd->fd, output);
for( cbe = (struct chan_banentry *)dbi_first(iter); dbi_exists(iter); cbe = (struct chan_banentry *)dbi_next(iter) ) { //for all users
if (cbe->char_name[0])
sprintf(output, "%d: %s",cbe->char_id,cbe->char_name);
else
sprintf(output, "%d: ****",cbe->char_id);
clif_displaymessage(sd->fd, output);
//.........这里部分代码省略.........
开发者ID:Atemo,项目名称:rathena,代码行数:101,代码来源:channel.cpp
示例12: searchstore_query
void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned int min_price, unsigned int max_price, const unsigned short* itemlist, unsigned int item_count, const unsigned short* cardlist, unsigned int card_count)
{
unsigned int i;
struct map_session_data* pl_sd;
struct DBIterator *iter;
struct s_search_store_search s;
searchstore_searchall_t store_searchall;
time_t querytime;
DBMap *vending_db = vending_getdb();
if( !battle_config.feature_search_stores ) {
return;
}
if( !sd->searchstore.open ) {
return;
}
if( ( store_searchall = searchstore_getsearchallfunc(type) ) == NULL ) {
ShowError("searchstore_query: Unknown search type %u (account_id=%d).\n", (unsigned int)type, sd->bl.id);
return;
}
time(&querytime);
if( sd->searchstore.nextquerytime > querytime ) {
clif_search_store_info_failed(sd, SSI_FAILED_LIMIT_SEARCH_TIME);
return;
}
if( !sd->searchstore.uses ) {
clif_search_store_info_failed(sd, SSI_FAILED_SEARCH_CNT);
return;
}
// validate lists
for( i = 0; i < item_count; i++ ) {
if( !itemdb_exists(itemlist[i]) ) {
ShowWarning("searchstore_query: Client resolved item %hu is not known.\n", itemlist[i]);
clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
}
}
for( i = 0; i < card_count; i++ ) {
if( !itemdb_exists(cardlist[i]) ) {
ShowWarning("searchstore_query: Client resolved card %hu is not known.\n", cardlist[i]);
clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
}
}
if( max_price < min_price ) {
swap(min_price, max_price);
}
sd->searchstore.uses--;
sd->searchstore.type = type;
sd->searchstore.nextquerytime = querytime+battle_config.searchstore_querydelay;
// drop previous results
searchstore_clear(sd);
// allocate max. amount of results
sd->searchstore.items = (struct s_search_store_info_item*)aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults);
// search
s.search_sd = sd;
s.itemlist = itemlist;
s.cardlist = cardlist;
s.item_count = item_count;
s.card_count = card_count;
s.min_price = min_price;
s.max_price = max_price;
iter = db_iterator(vending_db);
for( pl_sd = dbi_first(iter); dbi_exists(iter); pl_sd = dbi_next(iter) ) {
if( sd == pl_sd ) {// skip own shop, if any
continue;
}
if( !store_searchall(pl_sd, &s) ) {// exceeded result size
clif_search_store_info_failed(sd, SSI_FAILED_OVER_MAXCOUNT);
break;
}
}
dbi_destroy(iter);
if( sd->searchstore.count ) {
// reclaim unused memory
sd->searchstore.items = (struct s_search_store_info_item*)aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count);
// present results
clif_search_store_info_ack(sd);
// one page displayed
sd->searchstore.pages++;
} else {
// cleanup
searchstore_clear(sd);
//.........这里部分代码省略.........
开发者ID:BlazingSpear,项目名称:rathena,代码行数:101,代码来源:searchstore.c
示例13: channel_close
void channel_close(struct channel_data *cd)
{
int j;
char output[128];
struct map_session_data *pl_sd;
DBIterator* iter;
if( cd == NULL || cd->type != CHN_USER )
return;
sprintf(output, msg_txt(804), cd->name);
clif_channel_message(cd, output, -1);
iter = db_iterator(cd->users_db);
for( pl_sd = (struct map_session_data *)dbi_first(iter); dbi_exists(iter); pl_sd = (struct map_session_data *)dbi_next(iter) )
{
idb_remove(cd->users_db, pl_sd->bl.id);
ARR_FIND(0, MAX_USER_CHANNELS, j, pl_sd->cd[j] == cd);
if( j == MAX_USER_CHANNELS )
continue;
pl_sd->cd[j] = NULL;
}
dbi_destroy(iter);
db_destroy(cd->users_db);
strdb_remove(channel_db, cd->name);
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:28,代码来源:channel.c
示例14: itemdb_readdb
//.........这里部分代码省略.........
continue;// empty line
for( i = 0; i < 19; ++i )
{
str[i] = p;
p = strchr(p,',');
if( p == NULL )
break;// comma not found
*p = '\0';
++p;
}
if( p == NULL )
{
ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
// Script
if( *p != '{' )
{
ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
str[19] = p;
p = strstr(p+1,"},");
if( p == NULL )
{
ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
p[1] = '\0';
p += 2;
// OnEquip_Script
if( *p != '{' )
{
ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
str[20] = p;
p = strstr(p+1,"},");
if( p == NULL )
{
ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
p[1] = '\0';
p += 2;
// OnUnequip_Script (last column)
if( *p != '{' )
{
ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
str[21] = p;
p = strstr(p+1,"}");
if ( strchr(p,',') != NULL )
{
ShowError("itemdb_readdb: Extra columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
continue;
}
if ((ic = idb_get(item_combo_db, atoi(str[0])))) {
script2 = ic->script;
}
if (!itemdb_parse_dbrow(str, path, lines, 0, script2))
continue;
if( script2 != NULL )
idb_remove(item_combo_db,atoi(str[0]));
count++;
}
fclose(fp);
ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename[fi]);
}
if( db_size(item_combo_db) ) {
DBIterator * iter = db_iterator(item_combo_db);
struct item_combo * ic = NULL;
int icount = 1;
/* non-processed entries */
ShowWarning("item_combo_db: There are %d unused entries in the file (combo(s) with non-available item IDs)\n",db_size(item_combo_db));
for( ic = dbi_first(iter); dbi_exists(iter); ic = dbi_next(iter) ) {
ShowWarning("item_combo_db(%d): (ID:%d) \"%s\" combo unused\n",icount++,ic->nameid,ic->script);
}
dbi_destroy(iter);
}
db_destroy(item_combo_db);
return 0;
}
开发者ID:SorayaAguiar,项目名称:Traducoes,代码行数:101,代码来源:itemdb.c
示例15: do_init_buyingstore_autotrade
/**
* Initializing autotraders from table
*/
void do_init_buyingstore_autotrade( void ) {
if(battle_config.feature_autotrade) {
if (Sql_Query(mmysql_handle,
"SELECT `id`, `account_id`, `char_id`, `sex`, `title`, `limit`, `body_direction`, `head_direction`, `sit` "
"FROM `%s` "
"WHERE `autotrade` = 1 AND `limit` > 0 AND (SELECT COUNT(`buyingstore_id`) FROM `%s` WHERE `buyingstore_id` = `id`) > 0 "
"ORDER BY `id`;",
buyingstores_table, buyingstore_items_table ) != SQL_SUCCESS )
{
Sql_ShowDebug(mmysql_handle);
return;
}
if( Sql_NumRows(mmysql_handle) > 0 ) {
uint16 items = 0;
DBIterator *iter = NULL;
struct s_autotrader *at = NULL;
// Init each autotrader data
while (SQL_SUCCESS == Sql_NextRow(mmysql_handle)) {
size_t len;
char* data;
at = NULL;
CREATE(at, struct s_autotrader, 1);
Sql_GetData(mmysql_handle, 0, &data, NULL); at->id = atoi(data);
Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? 0 : 1;
Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, zmin(len + 1, MESSAGE_SIZE));
Sql_GetData(mmysql_handle, 5, &data, NULL); at->limit = atoi(data);
Sql_GetData(mmysql_handle, 6, &data, NULL); at->dir = atoi(data);
Sql_GetData(mmysql_handle, 7, &data, NULL); at->head_dir = atoi(data);
Sql_GetData(mmysql_handle, 8, &data, NULL); at->sit = atoi(data);
at->count = 0;
if (battle_config.feature_autotrade_direction >= 0)
at->dir = battle_config.feature_autotrade_direction;
if (battle_config.feature_autotrade_head_direction >= 0)
at->head_dir = battle_config.feature_autotrade_head_direction;
if (battle_config.feature_autotrade_sit >= 0)
at->sit = battle_config.feature_autotrade_sit;
// initialize player
CREATE(at->sd, struct map_session_data, 1);
pc_setnewpc(at->sd, at->account_id, at->char_id, 0, gettick(), at->sex, 0);
at->sd->state.autotrade = 1|4;
at->sd->state.monster_ignore = (battle_config.autotrade_monsterignore);
chrif_authreq(at->sd, true);
uidb_put(buyingstore_autotrader_db, at->char_id, at);
}
Sql_FreeResult(mmysql_handle);
// Init items for each autotraders
iter = db_iterator(buyingstore_autotrader_db);
for (at = (struct s_autotrader *)dbi_first(iter); dbi_exists(iter); at = (struct s_autotrader *)dbi_next(iter)) {
uint16 j = 0;
if (SQL_ERROR == Sql_Query(mmysql_handle,
"SELECT `item_id`, `amount`, `price` "
"FROM `%s` "
"WHERE `buyingstore_id` = %d "
"ORDER BY `index` ASC;",
buyingstore_items_table, at->id ) )
{
Sql_ShowDebug(mmysql_handle);
continue;
}
if (!(at->count = (uint16)Sql_NumRows(mmysql_handle))) {
map_quit(at->sd);
buyingstore_autotrader_remove(at, true);
continue;
}
//Init the list
CREATE(at->entries, struct s_autotrade_entry *,at->count);
//Add the item into list
j = 0;
while (SQL_SUCCESS == Sql_NextRow(mmysql_handle) && j < at->count) {
char *data;
CREATE(at->entries[j], struct s_autotrade_entry, 1);
Sql_GetData(mmysql_handle, 0, &data, NULL); at->entries[j]->item_id = atoi(data);
Sql_GetData(mmysql_handle, 1, &data, NULL); at->entries[j]->amount = atoi(data);
Sql_GetData(mmysql_handle, 2, &data, NULL); at->entries[j]->price = atoi(data);
j++;
}
items += j;
Sql_FreeResult(mmysql_handle);
}
dbi_destroy(iter);
ShowStatus("Done loading '"CL_WHITE"%d"CL_RESET"' buyingstore autotraders with '"CL_WHITE"%d"CL_RESET"' items.\n", db_size(buyingstore_autotrader_db), items);
}
}
开发者ID:Tenefer,项目名称:DLRO_Trunk,代码行数:99,代码来源:buyingstore.c
示例16: raconf_destroy
void raconf_destroy(raconf rc){
DBIterator *iter;
struct conf_value *v;
// Clear all entrys in db.
iter = db_iterator(rc->db);
for( v = (struct conf_value*)dbi_first(iter); dbi_exists(iter); v = (struct conf_value*)dbi_next(iter) ){
aFree(v);
}
dbi_destroy(iter);
db_destroy(rc->db);
aFree(rc);
}//end: raconf_destroy()
开发者ID:Abunay01,项目名称:Cronus,代码行数:16,代码来源:raconf.c
示例17: channel_message
//.........这里部分代码省略.........
}
else if( !strncasecmp(message, ".kick ", 6) && len > 9 )
{ // Kick Users
option_text = (char *)message + 6;
if( (p_sd = map_nick2sd(option_text)) == NULL || channel_slot_get(p_sd, cd) < 0 )
clif_displaymessage(sd->fd, msg_txt(817));
else if( p_sd == sd )
clif_displaymessage(sd->fd, msg_txt(818));
else
{
channel_leave(p_sd, cd->name, false);
sprintf(output, msg_txt(819), cd->name, p_sd->status.name);
clif_channel_message(cd, output, -1);
p_sd->canjoinchn_tick = gettick() + 10000;
}
}
else if( !strncasecmp(message, ".color ", 7) && len > 7 )
{ // Set Chat Room Color
short color = atoi(message + 7);
if( color < 1 || color > 39 )
clif_displaymessage(sd->fd, msg_txt(830));
else
{
cd->color = channel_color[color - 1];
sprintf(output, msg_txt(831), cd->name);
clif_channel_message(cd, output, -1);
}
}
else if( !strncasecmp(message, ".op ", 4) && len > 7 )
{
option_text = (char *)message + 4;
if( cd->type != CHN_USER )
clif_displaymessage(sd->fd, msg_txt(875));
else if( (p_sd = map_nick2sd(option_text)) == NULL || channel_slot_get(p_sd, cd) < 0 )
clif_displaymessage(sd->fd, msg_txt(817));
else if( p_sd == sd )
clif_displaymessage(sd->fd, msg_txt(832));
else
{
cd->op = p_sd->bl.id;
sprintf(output, msg_txt(833), cd->name, p_sd->status.name);
clif_channel_message(cd, output, -1);
}
}
else if( !strncasecmp(message, ".pass ", 6) && len > 6 )
{
option_text = trim((char *)message + 6);
if( cd->type != CHN_USER )
clif_displaymessage(sd->fd, msg_txt(875));
else if( !strcmpi(option_text, "off") )
{
memset(cd->pass, '\0', sizeof(cd->pass));
sprintf(output, msg_txt(834), cd->name);
clif_channel_message(cd, output, -1);
}
else if( strlen(option_text) > 1 && strlen(option_text) < NAME_LENGTH )
{
safestrncpy(cd->pass, option_text, sizeof(cd->pass));
sprintf(output, msg_txt(835), cd->name);
clif_channel_message(cd, output, -1);
}
else
clif_displaymessage(sd->fd, msg_txt(836));
}
else if( !strncasecmp(message, ".close", 6) )
{
if( cd->type != CHN_USER )
clif_displaymessage(sd->fd, msg_txt(875));
else
channel_close(cd);
}
else if( !strncasecmp(message, ".list", 6) )
{
DBIterator* iter = db_iterator(cd->users_db);
clif_displaymessage(sd->fd, msg_txt(837));
for( p_sd = (struct map_session_data *)dbi_first(iter); dbi_exists(iter); p_sd = (struct map_session_data *)dbi_next(iter) )
clif_displaymessage(sd->fd, p_sd->status.name);
dbi_destroy(iter);
clif_displaymessage(sd->fd, msg_txt(838));
}
else if( !strncasecmp(message, ".help", 5) )
{ // Command List
clif_displaymessage(sd->fd, msg_txt(839));
clif_displaymessage(sd->fd, msg_txt(840));
clif_displaymessage(sd->fd, msg_txt(841));
clif_displaymessage(sd->fd, msg_txt(842));
clif_displaymessage(sd->fd, msg_txt(843));
clif_displaymessage(sd->fd, msg_txt(844));
clif_displaymessage(sd->fd, msg_txt(845));
clif_displaymessage(sd->fd, msg_txt(846));
}
else
clif_displaymessage(sd->fd, msg_txt(847));
return;
}
snprintf(output, sizeof(output), "%s : [%s] %s", cd->name, sd->status.name, message);
clif_channel_message(cd, output, -1);
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:101,代码来源:channel.c
示例18: 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_bool(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;
group_settings->group_pos = i;
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 = db_iterator(pc_group_db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions;
int count = 0, j;
// 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 (j = 0; j < count; ++j) {
config_setting_t *command = config_setting_get_elem(commands, j);
const char *name = config_setting_name(command);
if (!atcommand_exists(name)) {
//.........这里部分代码省略.........
开发者ID:AsaK,项目名称:rathena,代码行数:101,代码来源:pc_groups.c
示例19: channel_delete
/**
* Delete a channel
* - Checks if there is any user in channel and make them quit
* @param channel: Channel data
* @param force: Forcefully remove channel
* @return
* 0: Success
* -1: Invalid channel
* -2: Can't delete now
*/
int channel_delete(struct Channel *channel, bool force) {
if(!channel)
return -1;
if(!force && channel->type == CHAN_TYPE_PUBLIC && runflag == MAPSERVER_ST_RUNNING) //only delete those serv stop
return -2;
if( db_size(channel->users)) {
struct map_session_data *sd;
DBIterator *iter = db_iterator(channel->users);
for( sd = (struct map_session_data *)dbi_first(iter); dbi_exists(iter); sd = (struct map_session_data *)dbi_next(iter) ) { //for all users
channel_clean(channel,sd,1); //make all quit
}
dbi_destroy(iter);
}
if (battle_config.etc_log)
ShowInfo("Deleting channel %s alias %s type %d\n",channel->name,channel->alias,channel->type);
db_destroy(channel->users);
db_destroy(channel->banned);
if (channel->groups)
aFree(channel->groups);
channel->groups = NULL;
channel->group_count = 0;
switch(channel->type){
case CHAN_TYPE_MAP:
map_getmapdata(channel->m)->channel = NULL;
aFree(channel);
break;
case CHAN_TYPE_ALLY: {
struct guild *g = guild_search(channel->gid);
if(g) g->channel = NULL;
aFree(channel);
break;
}
default:
strdb_remove(channel_db, channel->name);
break;
}
return 0;
}
开发者ID:Atemo,项目名称:rathena,代码行数:48,代码来源:channel.cpp
示例20: guild_emblem_changed
// ギルドエンブレム変更通知
int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data)
{
int i;
struct map_session_data *sd;
struct guild *g=guild_search(guild_id);
if(g==NULL)
return 0;
memcpy(g->emblem_data,data,len);
g->emblem_len=len;
g->emblem_id=emblem_id;
for(i=0;i<g->max_member;i++){
if((sd=g->member[i].sd)!=NULL){
sd->guild_emblem_id=emblem_id;
clif_guild_belonginfo(sd,g);
clif_guild_emblem(sd,g);
clif_guild_emblem_area(&sd->bl);
}
}
{// update guardians (mobs)
DBIterator* iter = db_iterator(castle_db);
struct guild_castle* gc;
for( gc = (struct guild_castle*)dbi_first(iter) ; dbi_exists(iter); gc = (struct guild_castle*)dbi_next(iter) )
{
if( gc->guild_id != guild_id )
continue;
// update permanent guardians
for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i )
{
TBL_MOB* md = (gc->guardian[i].id ? map_id2md(gc->guardian[i].id) : NULL);
if( md == NULL || md->guardian_data == NULL )
continue;
md->guardian_data->emblem_id = emblem_id;
clif_guild_emblem_area(&md->bl);
}
// update temporary guardians
for( i = 0; i < gc->temp_guardians_max; ++i )
{
TBL_MOB* md = (gc->temp_guardians[i] ? map_id2md(gc->temp_guardians[i]) : NULL);
if( md == NULL || md->guardian_data == NULL )
continue;
md->guardian_data->emblem_id = emblem_id;
clif_guild_emblem_area(&md->bl);
}
}
dbi_destroy(iter);
}
{// update npcs (flags or other npcs that used flagemblem to attach to this guild)
// TODO this is not efficient [FlavioJS]
struct s_mapiterator* iter = mapit_geteachnpc();
TBL_NPC* nd;
for( nd = (TBL_NPC*)mapit_first(iter) ; mapit_exists(iter); nd = (TBL_NPC*)mapit_next(iter) )
{
if( nd->subtype != SCRIPT || nd->u.scr.guild_id != guild_id )
continue;
clif_guild_emblem_area(&nd->bl);
}
mapit_free(iter);
}
return 0;
}
开发者ID:casioza,项目名称:server000,代码行数:63,代码来源:guild.c
注:本文中的dbi_next函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论