Exemple #1
0
bool party_booking_delete(struct map_session_data *sd)
{
	struct party_booking_ad_info* pb_ad;

	if((pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id))!=NULL)
	{
		clif->PartyBookingDeleteNotify(sd, pb_ad->index);
		idb_remove(party_booking_db,sd->status.char_id);
	}
	return true;
}
Exemple #2
0
/**
 * Request from char-server to authenticate an account.
 * @param fd: fd to parse from (char-serv)
 * @param id: id of char-serv
 * @param ip: char-serv ip (used for info)
 * @return 0 not enough info transmitted, 1 success
 */
int logchrif_parse_reqauth(int fd, int id,char* ip){
	if( RFIFOREST(fd) < 23 )
		return 0;
	else{
		struct auth_node* node;
		uint32 account_id = RFIFOL(fd,2);
		uint32 login_id1 = RFIFOL(fd,6);
		uint32 login_id2 = RFIFOL(fd,10);
		uint8 sex = RFIFOB(fd,14);
		//uint32 ip_ = ntohl(RFIFOL(fd,15));
		int request_id = RFIFOL(fd,19);
		RFIFOSKIP(fd,23);

		node = (struct auth_node*)idb_get(auth_db, account_id);
		if( runflag == LOGINSERVER_ST_RUNNING &&
			node != NULL &&
			node->account_id == account_id &&
			node->login_id1  == login_id1 &&
			node->login_id2  == login_id2 &&
			node->sex        == sex_num2str(sex) /*&&
			node->ip         == ip_*/ ){// found
			//ShowStatus("Char-server '%s': authentication of the account %d accepted (ip: %s).\n", server[id].name, account_id, ip);

			// send ack
			WFIFOHEAD(fd,21);
			WFIFOW(fd,0) = 0x2713;
			WFIFOL(fd,2) = account_id;
			WFIFOL(fd,6) = login_id1;
			WFIFOL(fd,10) = login_id2;
			WFIFOB(fd,14) = sex;
			WFIFOB(fd,15) = 0;// ok
			WFIFOL(fd,16) = request_id;
			WFIFOB(fd,20) = node->clienttype;
			WFIFOSET(fd,21);

			// each auth entry can only be used once
			idb_remove(auth_db, account_id);
		}else{// authentication not found
			ShowStatus("Char-server '%s': authentication of the account %d REFUSED (ip: %s).\n", ch_server[id].name, account_id, ip);
			WFIFOHEAD(fd,21);
			WFIFOW(fd,0) = 0x2713;
			WFIFOL(fd,2) = account_id;
			WFIFOL(fd,6) = login_id1;
			WFIFOL(fd,10) = login_id2;
			WFIFOB(fd,14) = sex;
			WFIFOB(fd,15) = 1;// auth failed
			WFIFOL(fd,16) = request_id;
			WFIFOB(fd,20) = 0;
			WFIFOSET(fd,21);
		}
	}
	return 1;
}
Exemple #3
0
void auction_delete(struct auction_data *auction)
{
	unsigned int auction_id = auction->auction_id;

	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) )
		Sql_ShowDebug(sql_handle);

	if( auction->auction_end_timer != INVALID_TIMER )
		delete_timer(auction->auction_end_timer, auction_end_timer);

	idb_remove(auction_db_, auction_id);
}
Exemple #4
0
/**
 * Closes a vending shop.
 *
 * @param sd       The shop owner character.
 * @param quitting Whether the character is quitting (to skip sending packets to it).
 */
void vending_closevending(struct map_session_data *sd, bool quitting)
{
	nullpo_retv(sd);

	if (sd->state.vending) {
		if (!quitting) {
			sd->state.vending = 0;
			clif->closevendingboard(&sd->bl, 0);
		}
		idb_remove(vending->p->db, sd->status.char_id);
	}
}
Exemple #5
0
int inter_pet_delete(int pet_id)
{
	struct s_pet *p;
	p = (struct s_pet*)idb_get(pet_db,pet_id);
	if( p == NULL)
		return 1;
	else {
		idb_remove(pet_db,pet_id);
		ShowInfo("Deleted pet (pet_id: %d)\n",pet_id);
	}
	return 0;
}
Exemple #6
0
int inter_party_CharOffline (int char_id, int party_id)
{
	struct party_data *p = NULL;
	int i;

	if (party_id == -1)
	{
		// Get guild_id from the database
		char *data;

		if (SQL_ERROR == Sql_Query (sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id))
		{
			Sql_ShowDebug (sql_handle);
			return 0;
		}

		if (SQL_SUCCESS != Sql_NextRow (sql_handle))
			return 0; //Eh? No party?

		Sql_GetData (sql_handle, 0, &data, NULL);
		party_id = atoi (data);
		Sql_FreeResult (sql_handle);
	}

	if (party_id == 0)
		return 0; //No party...

	//Character has a party, set character offline and check if they were the only member online
	if ( (p = inter_party_fromsql (party_id)) == NULL)
		return 0;

	//Set member offline
	for (i = 0; i < MAX_PARTY; i++)
	{
		if (p->party.member[i].char_id == char_id)
		{
			p->party.member[i].online = 0;
			p->party.count--;

			if (p->party.member[i].lv == p->min_lv ||
					p->party.member[i].lv == p->max_lv)
				int_party_check_lv (p);

			break;
		}
	}

	if (!p->party.count)
		//Parties don't have any data that needs be saved at this point... so just remove it from memory.
		idb_remove (party_db_, party_id);

	return 1;
}
Exemple #7
0
// ギルド倉庫データ削除
int inter_guild_storage_delete(int guild_id)
{
	struct guild_storage *gs = (struct guild_storage*)idb_get(guild_storage_db,guild_id);
	if(gs) {
		int i;
		for(i=0;i<gs->storage_amount;i++){
			if(gs->items[i].card[0] == (short)0xff00)
				inter_pet_delete( MakeDWord(gs->items[i].card[1],gs->items[i].card[2]) );
		}
		idb_remove(guild_storage_db,guild_id);
	}
	return 0;
}
// パ?ティが空かどうかチェック
int party_check_empty(struct party *p) {
	int i;

	for(i = 0; i < MAX_PARTY; i++) {
		if (p->member[i].account_id > 0) {
			return 0;
		}
	}
	mapif_party_broken(p->party_id, 0);
	idb_remove(party_db, p->party_id);

	return 1;
}
Exemple #9
0
/*==========================================
 * Loads (and creates if not found) an item from the db.
 *------------------------------------------
 */
struct item_data* itemdb_load(int nameid)
{
	struct item_data *id = idb_ensure(item_db,nameid,create_item_data);
	if (id == &dummy_item)
  	{	//Remove dummy_item, replace by real data.
		DBKey key;
		key.i = nameid;
		idb_remove(item_db,nameid);
		id = create_item_data(key, NULL);
		idb_put(item_db,nameid,id);
	}
	return id;
}
Exemple #10
0
// 倉庫データ削除
int inter_storage_delete(int account_id)
{
	struct storage_data *s = (struct storage_data*)idb_get(storage_db,account_id);
	if(s) {
		int i;
		for(i=0;i<s->storage_amount;i++){
			if(s->items[i].card[0] == (short)0xff00)
				inter_pet_delete( MakeDWord(s->items[i].card[1],s->items[i].card[2]) );
		}
		idb_remove(storage_db,account_id);
	}
	return 0;
}
Exemple #11
0
/// Writes provided data into storage cache.
/// If data contains 0 items, any existing entry in cache is destroyed.
/// If data contains 1+ items and no cache entry exists, a new one is created.
bool storage_save(int account_id, struct storage_data* storage)
{
	if( storage->storage_amount > 0 )
	{
		struct storage_data* s = (struct storage_data*)idb_ensure(storage_db, account_id, create_storage);
		memcpy(s, storage, sizeof(*storage));
	}
	else
	{
		idb_remove(storage_db, account_id);
	}

	return true;
}
// ギルドが空かどうか?ェック
static bool guild_check_empty(struct guild *g)
{
	int i;
	ARR_FIND( 0, g->max_member, i, g->member[i].account_id > 0 );
	if( i < g->max_member)
		return false; // not empty

	// 誰もいないので解散
	guild_db->foreach(guild_db, guild_break_sub, g->guild_id);
	inter_guild_storage_delete(g->guild_id);
	mapif_guild_broken(g->guild_id, 0);
	idb_remove(guild_db, g->guild_id);
	return true;
}
Exemple #13
0
/**
 * Leaves a channel.
 *
 * @param chan The channel to leave
 * @param sd   The character
 */
void channel_leave(struct channel_data *chan, struct map_session_data *sd)
{
	nullpo_retv(chan);
	nullpo_retv(sd);

	if (!idb_remove(chan->users,sd->status.char_id))
		return;

	if (chan == sd->gcbind)
		sd->gcbind = NULL;

	if (!db_size(chan->users) && chan->type == HCS_TYPE_PRIVATE) {
		channel->delete(chan);
	} else if (!channel->config->closing && (chan->options & HCS_OPT_ANNOUNCE_JOIN)) {
Exemple #14
0
// Wisp/page transmission result
int mapif_parse_WisReply(int fd) {
    int id = RFIFOL(fd,2), flag = RFIFOB(fd,6);
    struct WisData *wd = idb_get(wis_db, id);

    if (wd == NULL)
        return 0;	// This wisp was probably suppress before, because it was timeout of because of target was found on another map-server

    if ((--wd->count) <= 0 || flag != 1) {
        mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
        idb_remove(wis_db, id);
    }

    return 0;
}
Exemple #15
0
/**
 * Make a player close his shop
 * @param sd : player session
 */
void vending_closevending(struct map_session_data* sd)
{
	nullpo_retv(sd);

	if( sd->state.vending ) {
		if( Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE vending_id = %d;", vending_items_db, sd->vender_id ) != SQL_SUCCESS ||
			Sql_Query( mmysql_handle, "DELETE FROM `%s` WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
				Sql_ShowDebug(mmysql_handle);
		}
		
		sd->state.vending = false;
		clif_closevendingboard(&sd->bl, 0);
		idb_remove(vending_db, sd->status.char_id);
	}
}
// ギルドが空かどうかチェック
int guild_check_empty(struct guild *g) {
	int i;

	for(i = 0; i < g->max_member; i++) {
		if (g->member[i].account_id > 0) {
			return 0;
		}
	}
		// 誰もいないので解散
	guild_db->foreach(guild_db, guild_break_sub, g->guild_id);
	inter_guild_storage_delete(g->guild_id);
	mapif_guild_broken(g->guild_id, 0);
	idb_remove(guild_db, g->guild_id);
	return 1;
}
Exemple #17
0
bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
	struct auth_node *node;
	if ((node=chrif_auth_check(account_id, char_id, state)))
	{
		int fd = node->sd?node->sd->fd:node->fd;
		if (session[fd] && session[fd]->session_data == node->sd)
			session[fd]->session_data = NULL;
		if (node->char_dat) aFree(node->char_dat);
		if (node->sd) aFree(node->sd);
		ers_free(auth_db_ers, node);
		idb_remove(auth_db,account_id);
		return true;
	}
	return false;
}
Exemple #18
0
// ギルド城データ要求返信
int guild_castledataloadack(int castle_id,int index,int value)
{
	struct guild_castle *gc=guild_castle_search(castle_id);
	int code=castle_id|(index<<16);
	struct eventlist *ev,*ev2;

	if(gc==NULL){
		return 0;
	}
	switch(index){
	case 1:
		gc->guild_id = value;
		if (gc->guild_id && guild_search(gc->guild_id)==NULL) //Request guild data which will be required for spawned guardians. [Skotlex]
			guild_request_info(gc->guild_id);
		break;
	case 2: gc->economy = value; break;
	case 3: gc->defense = value; break;
	case 4: gc->triggerE = value; break;
	case 5: gc->triggerD = value; break;
	case 6: gc->nextTime = value; break;
	case 7: gc->payTime = value; break;
	case 8: gc->createTime = value; break;
	case 9: gc->visibleC = value; break;
	case 10:
	case 11:
	case 12:
	case 13:
	case 14:
	case 15:
	case 16:
	case 17:
		gc->guardian[index-10].visible = value; break;
	default:
		ShowError("guild_castledataloadack ERROR!! (Not found castle_id=%d index=%d)\n", castle_id, index);
		return 0;
	}

	if( (ev = (struct eventlist *)idb_remove(guild_castleinfoevent_db,code))!=NULL )
	{
		while(ev){
			npc_event_do(ev->name);
			ev2=ev->next;
			aFree(ev);
			ev=ev2;
		}
	}
	return 1;
}
Exemple #19
0
/// Deletes BG Team from db
bool bg_team_delete(int bg_id) {
	int i;
	struct battleground_data *bgd = bg->team_search(bg_id);

	if( bgd == NULL ) return false;
	for( i = 0; i < MAX_BG_MEMBERS; i++ ) {
		struct map_session_data *sd = bgd->members[i].sd;
		if (sd == NULL)
			continue;

		bg->send_dot_remove(sd);
		sd->bg_id = 0;
	}
	idb_remove(bg->team_db, bg_id);
	return true;
}
Exemple #20
0
/**
 * Close buying store and clear buying store data from tables
 * @param sd
 */
void buyingstore_close(struct map_session_data *sd) {
	nullpo_retv(sd);

	if( sd->state.buyingstore ) {
		if( Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE buyingstore_id = %d;", buyingstore_items_db, sd->buyer_id) != SQL_SUCCESS ||
			Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `id` = %d;", buyingstores_db, sd->buyer_id) != SQL_SUCCESS )
			Sql_ShowDebug(mmysql_handle);

		sd->state.buyingstore = 0;
		sd->buyer_id = 0;
		memset(&sd->buyingstore, 0, sizeof(sd->buyingstore));
		idb_remove(buyingstore_db, sd->status.char_id);

		// Notify other players
		clif_buyingstore_disappear_entry(sd);
	}
}
Exemple #21
0
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;
}
// ギルド解散要求
int mapif_parse_BreakGuild(int fd, int guild_id) {
	struct guild *g;

	g = idb_get(guild_db, guild_id);
	if(g == NULL)
		return 0;

	guild_db->foreach(guild_db, guild_break_sub, guild_id);
	inter_guild_storage_delete(guild_id);
	mapif_guild_broken(guild_id, 0);

	if(log_inter)
		inter_log("guild %s (id=%d) broken" RETCODE, g->name, guild_id);

	idb_remove(guild_db, guild_id);
	return 0;
}
Exemple #23
0
int bg_team_delete(int bg_id)
{ // Deletes BG Team from db
	int i;
	struct map_session_data *sd;
	struct battleground_data *bg = bg_team_search(bg_id);

	if( bg == NULL ) return 0;
	for( i = 0; i < MAX_BG_MEMBERS; i++ )
	{
		if( (sd = bg->members[i].sd) == NULL )
			continue;

		bg_send_dot_remove(sd);
		sd->bg_id = 0;
	}
	idb_remove(bg_team_db, bg_id);
	return 1;
}
Exemple #24
0
/// Invoked (from char-server) when a party is disbanded.
int party_broken(int party_id)
{
	struct party_data* p;
	int i;

	p = party_search(party_id);
	if( p == NULL )
		return 0;

	for(i=0;i<MAX_PARTY;i++){
		if(p->data[i].sd!=NULL){
			clif_party_leaved(p,p->data[i].sd,p->party.member[i].account_id,p->party.member[i].name,0x10);
			p->data[i].sd->status.party_id=0;
		}
	}
	idb_remove(party_db,party_id);
	return 0;
}
/// find an existing entry for this account id and delete it
static bool account_db_txt_remove(AccountDB* self, const int account_id)
{
	AccountDB_TXT* db = (AccountDB_TXT*)self;
	DBMap* accounts = db->accounts;

	//TODO: find out if this really works
	struct mmo_account* tmp = idb_remove(accounts, account_id);
	if( tmp == NULL )
	{// error condition - entry not present
		ShowError("account_db_txt_remove: no such account with id %d\n", account_id);
		return false;
	}

	// flush data
	mmo_auth_sync(db);

	return true;
}
Exemple #26
0
int check_ttl_wisdata(void) {
    unsigned long tick = gettick();
    int i;

    do {
        wis_delnum = 0;
        wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick);
        for(i = 0; i < wis_delnum; i++) {
            struct WisData *wd = idb_get(wis_db, wis_dellist[i]);
            ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst);
            // removed. not send information after a timeout. Just no answer for the player
            //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
            idb_remove(wis_db, wd->id);
        }
    } while(wis_delnum >= WISDELLIST_MAX);

    return 0;
}
Exemple #27
0
//Innvoked on /breakguild "Guild name"
int guild_broken(int guild_id,int flag)
{
	struct guild *g=guild_search(guild_id);
//	struct guild_castle *gc=NULL;
	struct map_session_data *sd;
	int i;
//	char *name;;

	if(flag!=0 || g==NULL)
		return 0;

	//we call castle_event::OnGuildBreak of all castlesof the guild
	//you can set all castle_events in the castle_db.txt
/*	name=(char *)aCalloc(50,sizeof(char)); //24 char = event name, + space for  "::OnGuildBreak"
	for(i=0;i<MAX_GUILDCASTLE;i++){
		if( (gc=guild_castle_search(i)) != NULL ){
			if(gc->guild_id == guild_id){
				memcpy(name,gc->castle_event,50);
				npc_event_do(strcat(name,"::OnGuildBreak"));
			}
		}
	}
	free(name);
*/
	for(i=0;i<g->max_member;i++){	// ギルド解散を通知
		if((sd=g->member[i].sd)!=NULL){
			if(sd->state.storage_flag == 2)
				storage_guild_storage_quit(sd,1);
			sd->status.guild_id=0;
			sd->state.guild_sent=0;
			clif_guild_broken(g->member[i].sd,0);
			clif_charnameupdate(sd); // [LuzZza]
		}
	}

	guild_db->foreach(guild_db,guild_broken_sub,guild_id);
	castle_db->foreach(castle_db,castle_guild_broken_sub,guild_id);
	if (guild_cache && guild_cache->guild_id == guild_id)
		guild_cache = NULL;
	guild_storage_delete(guild_id);
	idb_remove(guild_db,guild_id);
	return 0;
}
Exemple #28
0
int check_ttl_wisdata(void)
{
	int64 tick = gettick();
	int i;

	do {
		wis_delnum = 0;
		wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick);
		for(i = 0; i < wis_delnum; i++) {
			struct WisData *wd = (struct WisData *)idb_get(wis_db, wis_dellist[i]);
			ShowWarning(read_message("Source.char.inter_checkttlwisdata"), wd->id, wd->src, wd->dst);
			// removed. not send information after a timeout. Just no answer for the player
			//mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
			idb_remove(wis_db, wd->id);
		}
	} while(wis_delnum >= WISDELLIST_MAX);

	return 0;
}
Exemple #29
0
// パーティ解散通知
int party_broken(int party_id)
{
	struct party *p;
	int i;
	if( (p=party_search(party_id))==NULL )
		return 0;
	
	for(i=0;i<MAX_PARTY;i++){
		if(p->member[i].sd!=NULL){
			clif_party_leaved(p,p->member[i].sd,
				p->member[i].account_id,p->member[i].name,0x10);
			p->member[i].sd->status.party_id=0;
			p->member[i].sd->state.party_sent=0;
		}
	}
	if (party_cache && party_cache->party_id == party_id)
		party_cache = NULL;
	idb_remove(party_db,party_id);
	return 0;
}
Exemple #30
0
//Innvoked on /breakguild "Guild name"
int guild_broken(int guild_id,int flag)
{
	struct guild *g=guild_search(guild_id);
	struct guild_castle *gc=NULL;
	struct map_session_data *sd;
	int i;
	char name[EVENT_NAME_LENGTH];

	if(flag!=0 || g==NULL)
		return 0;

	//we call castle_event::OnGuildBreak of all castlesof the guild
	//you can set all castle_events in the castle_db.txt
	for(i=0;i<MAX_GUILDCASTLE;i++){
		if( (gc=guild_castle_search(i)) != NULL ){
			if(gc->guild_id == guild_id){
				safestrncpy(name, gc->castle_event, 50);
				npc_event_do(strcat(name,"::OnGuildBreak"));
			}
		}
	}

	for(i=0;i<g->max_member;i++){	// ギルド解散を通知
		if((sd=g->member[i].sd)!=NULL){
			if(sd->state.storage_flag == 2)
				storage_guild_storage_quit(sd,1);
			sd->status.guild_id=0;
			clif_guild_broken(g->member[i].sd,0);
			clif_charnameupdate(sd); // [LuzZza]
		}
	}

	guild_db->foreach(guild_db,guild_broken_sub,guild_id);
	castle_db->foreach(castle_db,castle_guild_broken_sub,guild_id);
	guild_storage_delete(guild_id);
	idb_remove(guild_db,guild_id);
	return 0;
}