Example #1
0
/*==========================================
 * カプラ倉庫を開く
 *------------------------------------------
 */
int storage_storageopen(struct map_session_data *sd)
{
	struct storage *stor;
	int gmlvl = 0;

	nullpo_retr(0, sd);

	if(sd->state.storage_flag == 1)
		return 0;	// 既にカプラ倉庫を開いている

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

	if((stor = (struct storage *)numdb_search(storage_db,sd->status.account_id)) != NULL) {
		if(stor->storage_status)
			return 1;
		stor->storage_status = 1;
	}

	if(sd->state.storage_flag == 2)
		storage_guild_storageclose(sd); // ギルド倉庫をすでに開いている場合閉じる

	if(stor != NULL) {
		sd->state.storage_flag = 1;
		clif_storageitemlist(sd,stor);
		clif_storageequiplist(sd,stor);
		clif_updatestorageamount(sd,stor);
	} else {
		intif_request_storage(sd->status.account_id);
	}
	return 0;
}
Example #2
0
// 倉庫データ受信
static
int intif_parse_LoadStorage (int fd)
{
    struct storage *stor;
    struct map_session_data *sd;

    sd = map_id2sd (RFIFOL (fd, 4));
    if (sd == NULL)
    {
        if (battle_config.error_log)
            printf ("intif_parse_LoadStorage: user not found %d\n",
                    RFIFOL (fd, 4));
        return 1;
    }
    stor = account2storage (RFIFOL (fd, 4));
    if (stor->storage_status == 1)
    {                           // Already open.. lets ignore this update
        if (battle_config.error_log)
            printf
                ("intif_parse_LoadStorage: storage received for a client already open (User %d:%d)\n",
                 sd->status.account_id, sd->status.char_id);
        return 1;
    }
    if (stor->dirty)
    {                           // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
        if (battle_config.error_log)
            printf
                ("intif_parse_LoadStorage: received storage for an already modified non-saved storage! (User %d:%d)\n",
                 sd->status.account_id, sd->status.char_id);
        return 1;
    }

    if (RFIFOW (fd, 2) - 8 != sizeof (struct storage))
    {
        if (battle_config.error_log)
            printf ("intif_parse_LoadStorage: data size error %d %d\n",
                    RFIFOW (fd, 2) - 8, sizeof (struct storage));
        return 1;
    }
    if (battle_config.save_log)
        printf ("intif_openstorage: %d\n", RFIFOL (fd, 4));
    memcpy (stor, RFIFOP (fd, 8), sizeof (struct storage));
    stor->dirty = 0;
    stor->storage_status = 1;
    sd->state.storage_flag = 1;
    clif_storageitemlist (sd, stor);
    clif_storageequiplist (sd, stor);
    clif_updatestorageamount (sd, stor);

    return 0;
}
Example #3
0
// 倉庫データ受信
static
int intif_parse_LoadStorage(Session *, const Packet_Payload<0x3810>& payload)
{
    dumb_ptr<map_session_data> sd;

    sd = map_id2sd(account_to_block(payload.account_id));
    if (sd == nullptr)
    {
        if (battle_config.error_log)
            PRINTF("intif_parse_LoadStorage: user not found %d\n"_fmt,
                    payload.account_id);
        return 1;
    }
    P<Storage> stor = account2storage(payload.account_id);
    if (stor->storage_status == 1)
    {                           // Already open.. lets ignore this update
        if (battle_config.error_log)
            PRINTF("intif_parse_LoadStorage: storage received for a client already open (User %d:%d)\n"_fmt,
                    sd->status_key.account_id, sd->status_key.char_id);
        return 1;
    }
    if (stor->dirty)
    {                           // Already have storage, and it has been modified and not saved yet! Exploit! [Skotlex]
        if (battle_config.error_log)
            PRINTF("intif_parse_LoadStorage: received storage for an already modified non-saved storage! (User %d:%d)\n"_fmt,
                    sd->status_key.account_id, sd->status_key.char_id);
        return 1;
    }

    if (battle_config.save_log)
        PRINTF("intif_openstorage: %d\n"_fmt, payload.account_id);
    *stor = payload.storage;
    stor->dirty = 0;
    stor->storage_status = 1;
    sd->state.storage_open = 1;
    clif_storageitemlist(sd, stor);
    clif_storageequiplist(sd, stor);
    clif_updatestorageamount(sd, stor);

    return 0;
}
Example #4
0
/*==========================================
 * カプラ倉庫データの受信
 *------------------------------------------
 */
int storage_storageload(int account_id, struct storage *s)
{
	struct map_session_data *sd;
	struct storage *stor;

	nullpo_retr(1, s);

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

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

	stor = account2storage(account_id);

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

	memcpy(stor, s, sizeof(struct storage));
	storage_sortitem(stor->store_item, MAX_STORAGE, &stor->sortkey, battle_config.personal_storage_sort);
	stor->storage_status   = 1;
	sd->state.storage_flag = 1;
	clif_storageitemlist(sd,stor);
	clif_storageequiplist(sd,stor);
	clif_updatestorageamount(sd,stor);

	return 0;
}