Example #1
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 #2
0
int mapif_load_guild_storage(int fd,int account_id,int guild_id)
{
	struct guild_storage *gs=guild2storage(guild_id);
	WFIFOHEAD(fd, sizeof(struct guild_storage)+12);
	WFIFOW(fd,0)=0x3818;
	if(gs) {
		WFIFOW(fd,2)=sizeof(struct guild_storage)+12;
		WFIFOL(fd,4)=account_id;
		WFIFOL(fd,8)=guild_id;
		memcpy(WFIFOP(fd,12),gs,sizeof(struct guild_storage));
	}
	else {
		WFIFOW(fd,2)=12;
		WFIFOL(fd,4)=account_id;
		WFIFOL(fd,8)=0;
	}
	WFIFOSET(fd,WFIFOW(fd,2));

	return 0;
}
Example #3
0
int mapif_parse_SaveGuildStorage(int fd)
{
	struct guild_storage *gs;
	int guild_id, len;

	guild_id=RFIFOL(fd,8);
	len=RFIFOW(fd,2);
	if(sizeof(struct guild_storage)!=len-12){
		ShowError("inter storage: data size error %d %d\n",sizeof(struct guild_storage),len-12);
	}
	else {
		gs=guild2storage(guild_id);
		if(gs) {
			memcpy(gs,RFIFOP(fd,12),sizeof(struct guild_storage));
			mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,0);
		}
		else
			mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,1);
	}
	return 0;
}
Example #4
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;
}