Example #1
0
/*==========================================
 * ギルド倉庫を開く
 *------------------------------------------
 */
int storage_guild_storageopen(struct map_session_data *sd)
{
	struct guild_storage *gstor;
	int gmlvl = 0;

	nullpo_retr(0, sd);

	if(sd->status.guild_id <= 0)
		return 2;
	if(sd->state.storage_flag == 2)
		return 3;	// 既にギルド倉庫を開いている

	gmlvl = pc_isGM(sd);
	if(gmlvl > 0 && battle_config.gm_can_drop_lv > gmlvl)
		return 2;	// 設定しているGMレベルより低い

	if(sd->state.storage_flag == 1)
		storage_storageclose(sd); // カプラ倉庫をすでに開いている場合閉じる

	if((gstor = (struct guild_storage *)numdb_search(guild_storage_db,sd->status.guild_id)) != NULL) {
		gstor->storage_status  = 1;
		sd->state.storage_flag = 2;
		clif_guildstorageitemlist(sd,gstor);
		clif_guildstorageequiplist(sd,gstor);
		clif_updateguildstorageamount(sd,gstor);
	} else {
		intif_request_guild_storage(sd->status.account_id,sd->status.guild_id);
	}

	return 0;
}
Example #2
0
/*==========================================
 * ギルド倉庫データの受信
 *------------------------------------------
 */
int storage_guild_storageload(int account_id, int guild_id, struct guild_storage *s)
{
	struct map_session_data *sd;
	struct guild_storage *gstor;

	nullpo_retr(1, s);

	if(guild_id <= 0)
		return 0;

	sd = map_id2sd(account_id);
	if(sd == NULL || sd->state.waitingdisconnect) {
		if(battle_config.error_log && sd == NULL)
			printf("storage_guild_storageload: user not found %d\n", account_id);
		intif_unlock_guild_storage(guild_id);
		return 1;
	}

	// 既に倉庫を開いてないかチェック
	if(sd->state.storage_flag == 2)
		return 0;
	if(sd->state.storage_flag == 1)
		storage_storageclose(sd);

	gstor = guild2storage(guild_id);
	if(!gstor) {
		if(battle_config.error_log)
			printf("storage_guild_storageload: error guild_id %d not exist\n", guild_id);
		return 1;
	}

	if(battle_config.save_log)
		printf("guild_storageload: %d\n", account_id);

	memcpy(gstor, s, sizeof(struct guild_storage));
	storage_sortitem(gstor->store_item, MAX_GUILD_STORAGE, &gstor->sortkey, battle_config.guild_storage_sort);
	gstor->storage_status  = 1;
	sd->state.storage_flag = 2;
	clif_guildstorageitemlist(sd,gstor);
	clif_guildstorageequiplist(sd,gstor);
	clif_updateguildstorageamount(sd,gstor);

	return 0;
}
Example #3
0
static
int intif_parse_LoadGuildStorage (int fd)
{
    struct guild_storage *gstor;
    struct map_session_data *sd;
    int  guild_id;

    guild_id = RFIFOL (fd, 8);
    if (guild_id > 0)
    {
        gstor = guild2storage (guild_id);
        if (!gstor)
        {
            if (battle_config.error_log)
                printf
                    ("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",
                     guild_id);
            return 1;
        }
        if (RFIFOW (fd, 2) - 12 != sizeof (struct guild_storage))
        {
            gstor->storage_status = 0;
            if (battle_config.error_log)
                printf
                    ("intif_parse_LoadGuildStorage: data size error %d %d\n",
                     RFIFOW (fd, 2) - 12, sizeof (struct guild_storage));
            return 1;
        }
        sd = map_id2sd (RFIFOL (fd, 4));
        if (sd == NULL)
        {
            if (battle_config.error_log)
                printf ("intif_parse_LoadGuildStorage: user not found %d\n",
                        RFIFOL (fd, 4));
            return 1;
        }
        if (gstor->storage_status == 1)
        {                       // Already open.. lets ignore this update
            if (battle_config.error_log)
                printf
                    ("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n",
                     sd->status.account_id, sd->status.char_id);
            return 1;
        }
        if (gstor->dirty)
        {                       // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
            if (battle_config.error_log)
                printf
                    ("intif_parse_LoadGuildStorage: received storage for an already modified non-saved storage! (User %d:%d)\n",
                     sd->status.account_id, sd->status.char_id);
            return 1;
        }
        if (battle_config.save_log)
            printf ("intif_open_guild_storage: %d\n", RFIFOL (fd, 4));
        memcpy (gstor, RFIFOP (fd, 12), sizeof (struct guild_storage));
        gstor->storage_status = 1;
        sd->state.storage_flag = 2;
        clif_guildstorageitemlist (sd, gstor);
        clif_guildstorageequiplist (sd, gstor);
        clif_updateguildstorageamount (sd, gstor);
    }
    return 0;
}