Example #1
0
/*==========================================
 * 傭兵削除
 *------------------------------------------
 */
bool mercdb_txt_delete(int merc_id)
{
	struct mmo_mercstatus *p = (struct mmo_mercstatus *)numdb_search(merc_db, merc_id);

	if(p == NULL)
		return false;

	numdb_erase(merc_db, merc_id);
	aFree(p);
	printf("merc_id: %d deleted\n", merc_id);

#ifdef TXT_JOURNAL
	if( merc_journal_enable )
		journal_write( &merc_journal, merc_id, NULL );
#endif

	return true;
}
Example #2
0
/*==========================================
 * セーブ
 *------------------------------------------
 */
bool mercdb_txt_save(struct mmo_mercstatus *p2)
{
	struct mmo_mercstatus *p1;

	nullpo_retr(false, p2);

	p1 = (struct mmo_mercstatus *)numdb_search(merc_db, p2->merc_id);
	if(p1 == NULL) {
		p1 = (struct mmo_mercstatus *)aMalloc(sizeof(struct mmo_mercstatus));
		numdb_insert(merc_db, p2->merc_id, p1);
	}
	memcpy(p1, p2, sizeof(struct mmo_mercstatus));

#ifdef TXT_JOURNAL
	if( merc_journal_enable )
		journal_write( &merc_journal, p1->merc_id, p1 );
#endif
	return true;
}
Example #3
0
/*==========================================
 * 倉庫データのセーブ
 *------------------------------------------
 */
bool storagedb_txt_save(struct storage *s2)
{
	struct storage *s1;

	nullpo_retr(false, s2);

	s1 = (struct storage *)numdb_search(storage_db, s2->account_id);
	if(s1 == NULL) {
		s1 = (struct storage *)aCalloc(1, sizeof(struct storage));
		s1->account_id = s2->account_id;
		numdb_insert(storage_db, s2->account_id, s1);
	}
	memcpy(s1, s2, sizeof(struct storage));
#ifdef TXT_JOURNAL
	if( storage_journal_enable )
		journal_write( &storage_journal, s1->account_id, s1 );
#endif
	return true;
}
Example #4
0
/*==========================================
 * ギルド倉庫データのセーブ
 *------------------------------------------
 */
bool gstoragedb_txt_save(struct guild_storage *gs2, int easy)
{
	struct guild_storage *gs1;

	nullpo_retr(false, gs2);

	gs1 = (struct guild_storage *)numdb_search(gstorage_db,gs2->guild_id);
	if(gs1 == NULL) {
		gs1 = (struct guild_storage *)aCalloc(1, sizeof(struct guild_storage));
		gs1->guild_id = gs2->guild_id;
		gs1->last_fd  = -1;
		numdb_insert(gstorage_db, gs1->guild_id, gs1);
	}
	memcpy(gs1, gs2, sizeof(struct guild_storage));
#ifdef TXT_JOURNAL
	if( storage_journal_enable )
		journal_write( &storage_journal, gs1->guild_id, gs1 );
#endif
	return true;
}
Example #5
0
/*==========================================
 * 倉庫データ削除
 *------------------------------------------
 */
bool storagedb_txt_delete(int account_id)
{
	struct storage *s = (struct storage *)numdb_search(storage_db, account_id);

	if(s) {
		int i;
		for(i = 0; i < s->storage_amount; i++) {
			// ペット削除
			if(s->store_item[i].card[0] == (short)0xff00)
				petdb_delete(*((int *)(&s->store_item[i].card[1])));
		}
		numdb_erase(storage_db, account_id);
		aFree(s);
#ifdef TXT_JOURNAL
		if( storage_journal_enable )
			journal_write( &storage_journal, account_id, NULL );
#endif
	}
	return true;
}
Example #6
0
void do_journal_write(int argc, char *argv[])
{
	blk64_t *blist = NULL, *rlist = NULL;
	size_t bn = 0, rn = 0;
	FILE *fp = NULL;
	int opt;
	int flags = 0;
	errcode_t err;

	if (current_journal == NULL) {
		printf("Journal not open.\n");
		return;
	}

	reset_getopt();
	while ((opt = getopt(argc, argv, "b:r:c")) != -1) {
		switch (opt) {
		case 'b':
			err = read_list(optarg, &blist, &bn);
			if (err)
				com_err(argv[0], err,
					"while reading block list");
			break;
		case 'r':
			err = read_list(optarg, &rlist, &rn);
			if (err)
				com_err(argv[0], err,
					"while reading revoke list");
			break;
		case 'c':
			flags |= JOURNAL_WRITE_NO_COMMIT;
			break;
		default:
			printf("%s [-b blocks] [-r revoke] [-c] file\n",
			       argv[0]);
			printf("-b: Write these blocks into transaction.\n");
			printf("-c: Do not commit transaction.\n");
			printf("-r: Revoke these blocks from transaction.\n");

			goto out;
		}
	}

	if (bn > 0 && optind != argc - 1) {
		printf("Need a file to read blocks from.\n");
		return;
	}

	if (bn > 0) {
		fp = fopen(argv[optind], "r");
		if (fp == NULL) {
			com_err(argv[0], errno,
				"while opening journal data file");
			goto out;
		}
	}

	err = journal_write(current_journal, flags, blist, bn,
			    rlist, rn, fp);
	if (err)
		com_err("journal_write", err, "while writing journal");

	if (fp)
		fclose(fp);
out:
	if (blist)
		free(blist);
	if (rlist)
		free(rlist);
}