• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ idb_put函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中idb_put函数的典型用法代码示例。如果您正苦于以下问题:C++ idb_put函数的具体用法?C++ idb_put怎么用?C++ idb_put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了idb_put函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: chrif_sd_to_auth

//Moves the sd character to the auth_db structure.
static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
	struct auth_node *node;
	
	if ( chrif_search(sd->status.account_id) )
		return false; //Already exists?

	node = ers_alloc(auth_db_ers, struct auth_node);
	
	memset(node, 0, sizeof(struct auth_node));
	
	node->account_id = sd->status.account_id;
	node->char_id = sd->status.char_id;
	node->login_id1 = sd->login_id1;
	node->login_id2 = sd->login_id2;
	node->sex = sd->status.sex;
	node->fd = sd->fd;
	node->sd = sd;	//Data from logged on char.
	node->node_created = gettick(); //timestamp for node timeouts
	node->state = state;

	sd->state.active = 0;
	
	idb_put(auth_db, node->account_id, node);
	
	return true;
}
开发者ID:malufett,项目名称:Hercules,代码行数:27,代码来源:chrif.c


示例2: mapreg_setregstr

/// Modifies the value of a string variable.
bool mapreg_setregstr (int uid, const char *str)
{
    int num = (uid & 0x00ffffff);
    int i   = (uid & 0xff000000) >> 24;
    const char *name = get_str (num);

    if (str == NULL || *str == 0) {
        if (name[1] != '@') {
            if (SQL_ERROR == Sql_Query (mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i))
                Sql_ShowDebug (mmysql_handle);
        }

        idb_remove (mapregstr_db, uid);
    } else {
        if (idb_put (mapregstr_db, uid, aStrdup (str)))
            mapreg_dirty = true;
        else if (name[1] != '@') { //put returned null, so we must insert.
            // Someone is causing a database size infinite increase here without name[1] != '@' [Lance]
            char tmp_str[32 * 2 + 1];
            char tmp_str2[255 * 2 + 1];
            Sql_EscapeStringLen (mmysql_handle, tmp_str, name, strnlen (name, 32));
            Sql_EscapeStringLen (mmysql_handle, tmp_str2, str, strnlen (str, 255));

            if (SQL_ERROR == Sql_Query (mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2))
                Sql_ShowDebug (mmysql_handle);
        }
    }

    return true;
}
开发者ID:JoaoPedroAlves,项目名称:Cronus,代码行数:31,代码来源:mapreg_sql.c


示例3: chmapif_parse_reqchangemapserv

/**
 * Player requesting to change map-serv
 * @param fd: wich fd to parse from
 * @return : 0 not enough data received, 1 success
 */
int chmapif_parse_reqchangemapserv(int fd){
	if (RFIFOREST(fd) < 39)
		return 0;
	{
		int map_id, map_fd = -1;
		struct mmo_charstatus* char_data;
		struct mmo_charstatus char_dat;
		DBMap* char_db_ = char_get_chardb();

		map_id = char_search_mapserver(RFIFOW(fd,18), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28))); //Locate mapserver by ip and port.
		if (map_id >= 0)
			map_fd = map_server[map_id].fd;
		//Char should just had been saved before this packet, so this should be safe. [Skotlex]
		char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
		if (char_data == NULL) {	//Really shouldn't happen.
			char_mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
			char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
		}

		if( runflag == CHARSERVER_ST_RUNNING &&
			session_isActive(map_fd) &&
			char_data )
		{	//Send the map server the auth of this player.
			struct online_char_data* data;
			struct auth_node* node;
			DBMap*  auth_db = char_get_authdb();
			DBMap* online_char_db = char_get_onlinedb();

			int aid = RFIFOL(fd,2);

			//Update the "last map" as this is where the player must be spawned on the new map server.
			char_data->last_point.map = RFIFOW(fd,18);
			char_data->last_point.x = RFIFOW(fd,20);
			char_data->last_point.y = RFIFOW(fd,22);
			char_data->sex = RFIFOB(fd,30);

			// create temporary auth entry
			CREATE(node, struct auth_node, 1);
			node->account_id = aid;
			node->char_id = RFIFOL(fd,14);
			node->login_id1 = RFIFOL(fd,6);
			node->login_id2 = RFIFOL(fd,10);
			node->sex = RFIFOB(fd,30);
			node->expiration_time = 0; // FIXME (this thing isn't really supported we could as well purge it instead of fixing)
			node->ip = ntohl(RFIFOL(fd,31));
			node->group_id = RFIFOL(fd,35);
			node->changing_mapservers = 1;
			idb_put(auth_db, aid, node);

			data = idb_ensure(online_char_db, aid, char_create_online_data);
			data->char_id = char_data->char_id;
			data->server = map_id; //Update server where char is.

			//Reply with an ack.
			chmapif_changemapserv_ack(fd,0);
		} else { //Reply with nak
			chmapif_changemapserv_ack(fd,1);
		}
		RFIFOSKIP(fd,39);
	}
开发者ID:Insswer,项目名称:rathena,代码行数:65,代码来源:char_mapif.c


示例4: inter_pet_init

int inter_pet_init()
{
	char line[8192];
	struct s_pet *p;
	FILE *fp;
	int c=0;

	pet_db= idb_alloc(DB_OPT_RELEASE_DATA);

	if( (fp=fopen(pet_txt,"r"))==NULL )
		return 1;
	while(fgets(line, sizeof(line), fp))
	{
		p = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
		if(p==NULL){
			ShowFatalError("int_pet: out of memory!\n");
			exit(EXIT_FAILURE);
		}
		memset(p,0,sizeof(struct s_pet));
		if(inter_pet_fromstr(line,p)==0 && p->pet_id>0){
			if( p->pet_id >= pet_newid)
				pet_newid=p->pet_id+1;
			idb_put(pet_db,p->pet_id,p);
		}else{
			ShowError("int_pet: broken data [%s] line %d\n",pet_txt,c);
			aFree(p);
		}
		c++;
	}
	fclose(fp);
	return 0;
}
开发者ID:AxlSckay,项目名称:Ragnarok-OldTimes,代码行数:32,代码来源:int_pet.c


示例5: mapreg_setreg

/// Modifies the value of an integer variable.
bool mapreg_setreg(int uid, int val) {
	struct mapreg_save *m;
	int num = (uid & 0x00ffffff);
	int i   = (uid & 0xff000000) >> 24;
	const char* name = get_str(num);

	if( val != 0 ) {
		if( (m = idb_get(mapreg_db,uid)) ) {
			m->u.i = val;
			if(name[1] != '@') {
				m->save = true;
				mapreg_i_dirty = true;
			}
		} else {
			m = ers_alloc(mapreg_ers, struct mapreg_save);

			m->u.i = val;
			m->uid = uid;
			m->save = false;

			if(name[1] != '@') {// write new variable to database
				char tmp_str[32*2+1];
				SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
				if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) )
					Sql_ShowDebug(mmysql_handle);
			}
			idb_put(mapreg_db, uid, m);
		}
	} else { // val == 0
		if( (m = idb_get(mapreg_db,uid)) ) {
开发者ID:D0ugl4s,项目名称:Cronus,代码行数:31,代码来源:mapreg_sql.c


示例6: mapreg_setreg

/// Modifies the value of an integer variable.
bool mapreg_setreg(int uid, int val)
{
	int num = (uid & 0x00ffffff);
	int i   = (uid & 0xff000000) >> 24;
	const char* name = get_str(num);
	struct region_data* rd;

	if( !stricmp(name,"$Region") && i > 0 && i < SCRIPT_MAX_ARRAYSIZE && (rd = region_search(i)) != NULL )
		region_set_guild(i,val);

	if( val != 0 )
	{
		if( idb_put(mapreg_db,uid,(void*)(intptr_t)val) )
			mapreg_dirty = true; // already exists, delay write
		else if(name[1] != '@')
		{// write new wariable to database
			char tmp_str[32*2+1];
			Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
			if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) )
				Sql_ShowDebug(mmysql_handle);
		}
	}
	else // val == 0
	{
		idb_remove(mapreg_db,uid);

		if( name[1] != '@' )
		{// Remove from database because it is unused.
			if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) )
				Sql_ShowDebug(mmysql_handle);
		}
	}

	return true;
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:36,代码来源:mapreg_sql.c


示例7: clan_load_clandata

void clan_load_clandata( int count, struct clan* clans ){
	int i,j;

	nullpo_retv( clans );

	for( i = 0, j = 0; i < count; i++, clans++ ){
		struct clan* clan = clans;
		struct clan* clanCopy;

		clanCopy = (struct clan*)aMalloc( sizeof( struct clan ) );

		if( clanCopy == NULL ){
			ShowError("Memory could not be allocated for a clan.\n");
			break;
		}

		memcpy( clanCopy, clan, sizeof( struct clan ) );
		memset( clanCopy->members, 0, sizeof( clanCopy->members ) );

		idb_put( clan_db, clanCopy->id, clanCopy );
		j++;
	}

	ShowStatus( "Received '"CL_WHITE"%d"CL_RESET"' clans from char-server.\n", j );
}
开发者ID:AtlantisRO,项目名称:rathena,代码行数:25,代码来源:clan.c


示例8: chat_kickchat

/**
 * Kick a member from a chat room.
 * @param sd : player requesting
 * @param kickusername : player name to be kicked
 * @retur 1:success, 0:failure
 */
int chat_kickchat(struct map_session_data* sd, const char* kickusername)
{
	struct chat_data* cd;
	int i;

	nullpo_retr(1, sd);

	cd = (struct chat_data *)map_id2bl(sd->chatID);

	if( cd == NULL || (struct block_list *)sd != cd->owner )
		return -1;

	ARR_FIND( 0, cd->users, i, strncmp(cd->usersd[i]->status.name, kickusername, NAME_LENGTH) == 0 );
	if( i == cd->users )
		return -1;

	if (pc_has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK))
		return 0; //gm kick protection [Valaris]

	idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1);

	chat_leavechat(cd->usersd[i],1);

	return 0;
}
开发者ID:c0nflicts,项目名称:rathena,代码行数:31,代码来源:chat.c


示例9: inter_accreg_init

// アカウント変数の読み込み
int inter_accreg_init(void) {
	char line[8192];
	FILE *fp;
	int c = 0;
	struct accreg *reg;

	accreg_db = idb_alloc(DB_OPT_RELEASE_DATA);

	if( (fp = fopen(accreg_txt, "r")) == NULL)
		return 1;
	while(fgets(line, sizeof(line), fp))
	{
		reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1);
		if (reg == NULL) {
			ShowFatalError("inter: accreg: out of memory!\n");
			exit(EXIT_FAILURE);
		}
		if (inter_accreg_fromstr(line, reg) == 0 && reg->account_id > 0) {
			idb_put(accreg_db, reg->account_id, reg);
		} else {
			ShowError("inter: accreg: broken data [%s] line %d\n", accreg_txt, c);
			aFree(reg);
		}
		c++;
	}
	fclose(fp);

	return 0;
}
开发者ID:dbrocom,项目名称:syncragnarok,代码行数:30,代码来源:inter.c


示例10: party_booking_register

void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job)
{
    struct party_booking_ad_info *pb_ad;
    int i;

    pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id);

    if( pb_ad == NULL )
    {
        pb_ad = create_party_booking_data();
        idb_put(party_booking_db, sd->status.char_id, pb_ad);
    }
    else
    {   // already registered
        clif_PartyBookingRegisterAck(sd, 2);
        return;
    }

    memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH);
    pb_ad->starttime = (int)time(NULL);
    pb_ad->p_detail.level = level;
    pb_ad->p_detail.mapid = mapid;

    for(i=0; i<PARTY_BOOKING_JOBS; i++)
        if(job[i] != 0xFF)
            pb_ad->p_detail.job[i] = job[i];
        else pb_ad->p_detail.job[i] = -1;

    clif_PartyBookingRegisterAck(sd, 0);
    clif_PartyBookingInsertNotify(sd, pb_ad); // Notice
}
开发者ID:JulioCF,项目名称:cronus-txt,代码行数:31,代码来源:party.c


示例11: channel_ban

/**
 * Bans a character from the given channel.
 *
 * @param chan The channel.
 * @param ssd  The source character, if any.
 * @param tsd  The target character.
 * @retval HCS_STATUS_OK if the operation succeeded.
 * @retval HCS_STATUS_ALREADY if the target character is already banned.
 * @retval HCS_STATUS_NOPERM if the source character doesn't have enough permissions.
 * @retval HCS_STATUS_FAIL in case of generic failure.
 */
enum channel_operation_status channel_ban(struct channel_data *chan, const struct map_session_data *ssd, struct map_session_data *tsd)
{
	struct channel_ban_entry *entry = NULL;

	nullpo_retr(HCS_STATUS_FAIL, chan);
	nullpo_retr(HCS_STATUS_FAIL, tsd);

	if (ssd && chan->owner != ssd->status.char_id && !pc_has_permission(ssd, PC_PERM_HCHSYS_ADMIN))
		return HCS_STATUS_NOPERM;

	if (pc_has_permission(tsd, PC_PERM_HCHSYS_ADMIN))
		return HCS_STATUS_FAIL;

	if (chan->banned && idb_exists(chan->banned, tsd->status.account_id))
		return HCS_STATUS_ALREADY;

	if (!chan->banned)
		chan->banned = idb_alloc(DB_OPT_BASE|DB_OPT_ALLOW_NULL_DATA|DB_OPT_RELEASE_DATA);

	CREATE(entry, struct channel_ban_entry, 1);
	safestrncpy(entry->name, tsd->status.name, NAME_LENGTH);
	idb_put(chan->banned, tsd->status.account_id, entry);

	channel->leave(chan, tsd);

	return HCS_STATUS_OK;
}
开发者ID:xdgimf,项目名称:Renewal,代码行数:38,代码来源:channel.c


示例12: status_load_scdata

/*==========================================
 * Loads all scdata from the given filename.
 *------------------------------------------*/
void status_load_scdata(const char* filename)
{
	FILE *fp;
	int sd_count=0, sc_count=0;
	char line[8192];
	struct scdata *sc;

	if ((fp = fopen(filename, "r")) == NULL) {
		ShowError("status_load_scdata: Cannot open file %s!\n", filename);
		return;
	}

	while(fgets(line, sizeof(line), fp))
	{
		sc = (struct scdata*)aCalloc(1, sizeof(struct scdata));
		if (inter_scdata_fromstr(line, sc)) {
			sd_count++;
			sc_count+= sc->count;
			sc = (struct scdata*)idb_put(scdata_db, sc->char_id, sc);
			if (sc) {
				ShowError("Duplicate entry in %s for character %d\n", filename, sc->char_id);
				if (sc->data) aFree(sc->data);
				aFree(sc);
			}
		} else {
			ShowError("status_load_scdata: Broken line data: %s\n", line);
			aFree(sc);
		}
	}
	fclose(fp);
	ShowStatus("Loaded %d saved status changes for %d characters.\n", sc_count, sd_count);
}
开发者ID:bimsland,项目名称:eathena,代码行数:35,代码来源:int_status.c


示例13: party_created

// 作成可否
int party_created(int account_id,int char_id,int fail,int party_id,char *name)
{
	struct map_session_data *sd;
	sd=map_id2sd(account_id);

	nullpo_retr(0, sd);
	if (sd->status.char_id != char_id)
		return 0; //unlikely failure...
	
	if(fail==0){
		struct party *p;
		sd->status.party_id=party_id;
		if(idb_get(party_db,party_id)!=NULL){
			ShowFatalError("party: id already exists!\n");
			exit(1);
		}
		p=(struct party *)aCalloc(1,sizeof(struct party));
		p->party_id=party_id;
		memcpy(p->name, name, NAME_LENGTH);
		idb_put(party_db,party_id,p);
		clif_party_created(sd,0); //Success message
		clif_charnameupdate(sd); //Update other people's display. [Skotlex]
	}else{
		clif_party_created(sd,1);
	}
	return 0;
}
开发者ID:AxlSckay,项目名称:Ragnarok-OldTimes,代码行数:28,代码来源:party.c


示例14: party_booking_register

void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job)
{
	struct party_booking_ad_info *pb_ad;
	struct party_data *p=party_search(sd->status.party_id);
	int i;

	if (!check_party_leader(sd, p)) {
		clif_PartyBookingRegisterAck(sd, 1);
		return;
	}
	
	pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, p->party.party_id);

	if( pb_ad == NULL )
	{
		pb_ad = create_party_booking_data(p->party.party_id);
		idb_put(party_booking_db, pb_ad->index, pb_ad);
	}
	
	memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH);
	pb_ad->starttime = (int)time(NULL);
	pb_ad->p_detail.level = level;
	pb_ad->p_detail.mapid = mapid;

	for(i=0;i<6;i++)
		if(job[i] != 0xFF)
			pb_ad->p_detail.job[i] = job[i];
		else pb_ad->p_detail.job[i] = -1;

	clif_PartyBookingRegisterAck(sd, 0);
	clif_PartyBookingInsertNotify(sd, pb_ad); // Notice
	clif_PartyBookingSearchAck(sd->fd, &pb_ad->index, 1, false); // Update Client!
	return;
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:34,代码来源:party.c


示例15: inter_homun_init

int inter_homun_init()
{
	char line[8192];
	struct s_homunculus *p;
	FILE *fp;
	int c=0;

	homun_db= idb_alloc(DB_OPT_RELEASE_DATA);

	if( (fp=fopen(homun_txt,"r"))==NULL )
		return 1;
	while(fgets(line, sizeof(line), fp))
	{
		p = (struct s_homunculus*)aCalloc(sizeof(struct s_homunculus), 1);
		if(p==NULL){
			ShowFatalError("int_homun: out of memory!\n");
			exit(EXIT_FAILURE);
		}
		if(inter_homun_fromstr(line,p)==0 && p->hom_id>0){
			if( p->hom_id >= homun_newid)
				homun_newid=p->hom_id+1;
			idb_put(homun_db,p->hom_id,p);
		}else{
			ShowError("int_homun: broken data [%s] line %d\n",homun_txt,c);
			aFree(p);
		}
		c++;
	}
	fclose(fp);
	return 0;
}
开发者ID:Epsynus,项目名称:Tripping-nemesis,代码行数:31,代码来源:int_homun.c


示例16: bg_create

int bg_create(unsigned short mapindex, short rx, short ry, int guild_index, const char *ev, const char *dev)
{
	struct battleground_data *bg;
	int i;
	if( ++bg_team_counter <= 0 ) bg_team_counter = 1;

	CREATE(bg, struct battleground_data, 1);
	bg->bg_id = bg_team_counter;
	bg->creation_tick = 0;
	bg->count = 0;
	bg->g = &bg_guild[guild_index];
	bg->mapindex = mapindex;
	bg->x = rx;
	bg->y = ry;
	safestrncpy(bg->logout_event, ev, sizeof(bg->logout_event));
	safestrncpy(bg->die_event, dev, sizeof(bg->die_event));
	for( i = 0; i < MAX_GUILDSKILL; i++ )
		bg->skill_block_timer[i] = INVALID_TIMER;

	memset(&bg->members, 0, sizeof(bg->members));
	bg->color = bg_colors[guild_index];
	bg->pf_id = 0;

	idb_put(bg_team_db, bg_team_counter, bg);

	return bg->bg_id;
}
开发者ID:Chocolate31,项目名称:eamod,代码行数:27,代码来源:battleground.c


示例17: auction_create

unsigned int auction_create(struct auction_data *auction)
{
	int j;
	StringBuf buf;
	SqlStmt* stmt;

	if( !auction )
		return false;

	auction->timestamp = time(NULL) + (auction->hours * 3600);

	StringBuf_Init(&buf);
	StringBuf_Printf(&buf, "INSERT INTO `%s` (`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`,`unique_id`", auction_db);
	for( j = 0; j < MAX_SLOTS; j++ )
		StringBuf_Printf(&buf, ",`card%d`", j);
	StringBuf_Printf(&buf, ") VALUES ('%d',?,'%d',?,'%d','%d','%d','%lu','%d',?,'%d','%d','%d','%"PRIu64"'",
		auction->seller_id, auction->buyer_id, auction->price, auction->buynow, auction->hours, (unsigned long)auction->timestamp, auction->item.nameid, auction->type, auction->item.refine, auction->item.attribute, auction->item.unique_id);
	for( j = 0; j < MAX_SLOTS; j++ )
		StringBuf_Printf(&buf, ",'%d'", auction->item.card[j]);
	StringBuf_AppendStr(&buf, ")");

	//Unique Non Stackable Item ID
	updateLastUid(auction->item.unique_id);
	dbUpdateUid(sql_handle);

	stmt = SqlStmt_Malloc(sql_handle);
	if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
	||  SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
	||  SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
	||  SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH))
	||  SQL_SUCCESS != SqlStmt_Execute(stmt) )
	{
		SqlStmt_ShowDebug(stmt);
		auction->auction_id = 0;
	}
	else
	{
		struct auction_data *auction_;
		unsigned int tick = auction->hours * 3600000;

		auction->item.amount = 1;
		auction->item.identify = 1;
		auction->item.expire_time = 0;

		auction->auction_id = (unsigned int)SqlStmt_LastInsertId(stmt);
		auction->auction_end_timer = add_timer( gettick() + tick , auction_end_timer, auction->auction_id, 0);
		ShowInfo("New Auction %u | time left %u ms | By %s.\n", auction->auction_id, tick, auction->seller_name);

		CREATE(auction_, struct auction_data, 1);
		memcpy(auction_, auction, sizeof(struct auction_data));
		idb_put(auction_db_, auction_->auction_id, auction_);
	}

	SqlStmt_Free(stmt);
	StringBuf_Destroy(&buf);

	return auction->auction_id;
}
开发者ID:SNDBXIE,项目名称:myway-eathena,代码行数:58,代码来源:int_auction.c


示例18: script_load_mapreg

/// Loads permanent variables from database
static void script_load_mapreg(void)
{
	/*
	        0        1       2
	   +-------------------------+
	   | varname | index | value |
	   +-------------------------+
	                                */
	SqlStmt* stmt = SqlStmt_Malloc(mmysql_handle);
	char varname[32+1];
	int index;
	char value[255+1];
	uint32 length;

	if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table)
	  || SQL_ERROR == SqlStmt_Execute(stmt)
	  ) {
		SqlStmt_ShowDebug(stmt);
		SqlStmt_Free(stmt);
		return;
	}

	SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], sizeof(varname), &length, NULL);
	SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &index, 0, NULL, NULL);
	SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], sizeof(value), NULL, NULL);
	
	while ( SQL_SUCCESS == SqlStmt_NextRow(stmt) )
	{
		int s = add_str(varname);
		int i = index;

		if( varname[length-1] == '$' )
			idb_put(mapregstr_db, (i<<24)|s, aStrdup(value));
		else
		{
			idb_put(mapreg_db, (i<<24)|s, (void *)atoi(value));
			if( !strcmp(varname, "$Region") && i > 0 && i < MAX_REGIONS )
				region[i].guild_id = atoi(value); // Regional Control
		}
	}
	
	SqlStmt_Free(stmt);

	mapreg_dirty = false;
}
开发者ID:dbrocom,项目名称:syncragnarok,代码行数:46,代码来源:mapreg_sql.c


示例19: mapif_parse_CreateParty

// Create Party
int mapif_parse_CreateParty (int fd, char *name, int item, int item2, struct party_member *leader)
{
	struct party_data *p;
	int i;

	if ( (p = search_partyname (name)) != NULL)
	{
		mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
		return 0;
	}

	// Check Authorised letters/symbols in the name of the character
	if (char_name_option == 1)   // only letters/symbols in char_name_letters are authorised
	{
		for (i = 0; i < NAME_LENGTH && name[i]; i++)
			if (strchr (char_name_letters, name[i]) == NULL)
			{
				mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
				return 0;
			}
	}
	else if (char_name_option == 2)     // letters/symbols in char_name_letters are forbidden
	{
		for (i = 0; i < NAME_LENGTH && name[i]; i++)
			if (strchr (char_name_letters, name[i]) != NULL)
			{
				mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
				return 0;
			}
	}

	p = (struct party_data *) aCalloc (1, sizeof (struct party_data));
	memcpy (p->party.name, name, NAME_LENGTH);
	p->party.exp = 0;
	p->party.item = (item ? 1 : 0) | (item2 ? 2 : 0);
	memcpy (&p->party.member[0], leader, sizeof (struct party_member));
	p->party.member[0].leader = 1;
	p->party.member[0].online = 1;
	p->party.party_id = -1; //New party.

	if (inter_party_tosql (&p->party, PS_CREATE | PS_ADDMEMBER, 0))
	{
		//Add party to db
		int_party_calc_state (p);
		idb_put (party_db_, p->party.party_id, p);
		mapif_party_info (fd, &p->party, 0);
		mapif_party_created (fd, leader->account_id, leader->char_id, &p->party);
	}
	else     //Failed to create party.
	{
		aFree (p);
		mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
	}

	return 0;
}
开发者ID:Zellukas,项目名称:Radices,代码行数:57,代码来源:int_party.c


示例20: mapreg_setreg

/// Modifies the value of an integer variable.
bool mapreg_setreg(int uid, int val)
{
	if( val != 0 )
		idb_put(mapreg_db,uid,(void*)val);
	else
		idb_remove(mapreg_db,uid);

	mapreg_dirty = true;
	return true;
}
开发者ID:Drakkus,项目名称:eamod,代码行数:11,代码来源:mapreg_txt.c



注:本文中的idb_put函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ idb_remove函数代码示例发布时间:2022-05-30
下一篇:
C++ idb_get函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap