Party Matching Room.

Contributed by gigilo1968.
This commit is contained in:
MobiusDev 2017-09-09 15:13:10 +00:00
parent f2c81a5e84
commit 6d9c159b91
36 changed files with 322 additions and 48 deletions

View File

@ -0,0 +1,23 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
public enum PartyMatchingRoomLevelType
{
MY_LEVEL_RANGE,
ALL
}

View File

@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
@ -87,12 +88,12 @@ public class MatchingRoomManager
return _rooms.get(MatchingRoomType.PARTY);
}
public List<MatchingRoom> getPartyMathchingRooms(int location, int level)
public List<MatchingRoom> getPartyMathchingRooms(int location, PartyMatchingRoomLevelType type, int requestorLevel)
{
//@formatter:off
return _rooms.getOrDefault(MatchingRoomType.PARTY, Collections.emptyMap()).values().stream()
.filter(r -> (location < 0) || (r.getLocation() == location))
.filter(r -> (r.getMinLvl() <= level) && (r.getMaxLvl() >= level))
.filter(room -> (location < 0) || (room.getLocation() == location))
.filter(room -> (type == PartyMatchingRoomLevelType.ALL) || ((room.getMinLvl() >= requestorLevel) && (room.getMaxLvl() <= requestorLevel)))
.collect(Collectors.toList());
//@formatter:on
}

View File

@ -126,6 +126,7 @@ public class L2Party extends AbstractPlayerGroup
_members.add(leader);
_partyLvl = leader.getLevel();
_distributionType = partyDistributionType;
L2World.getInstance().incrementParty();
}
/**
@ -393,6 +394,7 @@ public class L2Party extends AbstractPlayerGroup
}, PARTY_POSITION_BROADCAST_INTERVAL.toMillis() / 2, PARTY_POSITION_BROADCAST_INTERVAL.toMillis());
}
applyTacticalSigns(player, false);
L2World.getInstance().incrementPartyMember();
}
private Map<Integer, L2Character> getTacticalSigns()
@ -553,6 +555,8 @@ public class L2Party extends AbstractPlayerGroup
broadcastPacket(msg);
}
L2World.getInstance().decrementPartyMember();
// UI update.
player.sendPacket(PartySmallWindowDeleteAll.STATIC_PACKET);
player.setParty(null);
@ -632,6 +636,7 @@ public class L2Party extends AbstractPlayerGroup
}
}
}
L2World.getInstance().decrementParty();
}
/**

View File

@ -21,6 +21,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Logger;
@ -94,6 +95,9 @@ public final class L2World
/** Map with the pets instances and their owner ID. */
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
private final AtomicInteger _partyNumber = new AtomicInteger();
private final AtomicInteger _memberInPartyNumber = new AtomicInteger();
private final L2WorldRegion[][][] _worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1][REGIONS_Z + 1];
/** Constructor of L2World. */
@ -813,6 +817,36 @@ public final class L2World
_log.info(getClass().getSimpleName() + ": All visible NPC's deleted.");
}
public void incrementParty()
{
_partyNumber.incrementAndGet();
}
public void decrementParty()
{
_partyNumber.decrementAndGet();
}
public void incrementPartyMember()
{
_memberInPartyNumber.incrementAndGet();
}
public void decrementPartyMember()
{
_memberInPartyNumber.decrementAndGet();
}
public int getPartyCount()
{
return _partyNumber.get();
}
public int getPartyMemberCount()
{
return _memberInPartyNumber.get();
}
/**
* @return the current instance of L2World
*/

View File

@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.model.matching;
import com.l2jmobius.gameserver.enums.MatchingMemberType;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2Party;
@ -43,7 +44,8 @@ public final class PartyMatchingRoom extends MatchingRoom
protected void onRoomCreation(L2PcInstance player)
{
player.broadcastUserInfo(UserInfoType.CLAN);
player.sendPacket(new ListPartyWaiting(player.getLevel(), -1, 1));
player.sendPacket(new ListPartyWaiting(PartyMatchingRoomLevelType.ALL, -1, 1, player.getLevel()));
player.sendPacket(SystemMessageId.YOU_HAVE_CREATED_A_PARTY_ROOM);
}
@Override

View File

@ -33,6 +33,7 @@ public class RequestDismissPartyRoom implements IClientIncomingPacket
public boolean read(L2GameClient client, PacketReader packet)
{
_roomid = packet.readD();
packet.readD();
return true;
}

View File

@ -17,6 +17,7 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Party;
@ -28,14 +29,15 @@ import com.l2jmobius.gameserver.network.serverpackets.ListPartyWaiting;
public final class RequestPartyMatchConfig implements IClientIncomingPacket
{
private int _page, _location, _level;
private int _page, _location;
private PartyMatchingRoomLevelType _type;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_page = packet.readD();
_location = packet.readD();
_level = packet.readD();
_type = packet.readD() == 0 ? PartyMatchingRoomLevelType.MY_LEVEL_RANGE : PartyMatchingRoomLevelType.ALL;
return true;
}
@ -70,8 +72,7 @@ public final class RequestPartyMatchConfig implements IClientIncomingPacket
else
{
MatchingRoomManager.getInstance().addToWaitingList(activeChar);
activeChar.sendPacket(new ListPartyWaiting(_level, _location, _page));
activeChar.sendPacket(new ListPartyWaiting(_type, _location, _page, activeChar.getLevel()));
}
}
}

View File

@ -57,7 +57,7 @@ public class RequestPartyMatchList implements IClientIncomingPacket
return;
}
if (_roomId <= 0)
if ((_roomId <= 0) && (activeChar.getMatchingRoom() == null))
{
final PartyMatchingRoom room = new PartyMatchingRoom(_roomTitle, _lootType, _minLevel, _maxLevel, _maxMembers, activeChar);
activeChar.setMatchingRoom(room);

View File

@ -20,6 +20,7 @@ import java.util.LinkedList;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
@ -35,9 +36,9 @@ public class ListPartyWaiting implements IClientOutgoingPacket
private static final int NUM_PER_PAGE = 64;
public ListPartyWaiting(int level, int location, int page)
public ListPartyWaiting(PartyMatchingRoomLevelType type, int location, int page, int requestorLevel)
{
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, level);
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, type, requestorLevel);
_size = rooms.size();
final int startIndex = (page - 1) * NUM_PER_PAGE;

View File

@ -0,0 +1,23 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
public enum PartyMatchingRoomLevelType
{
MY_LEVEL_RANGE,
ALL
}

View File

@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
@ -87,12 +88,12 @@ public class MatchingRoomManager
return _rooms.get(MatchingRoomType.PARTY);
}
public List<MatchingRoom> getPartyMathchingRooms(int location, int level)
public List<MatchingRoom> getPartyMathchingRooms(int location, PartyMatchingRoomLevelType type, int requestorLevel)
{
//@formatter:off
return _rooms.getOrDefault(MatchingRoomType.PARTY, Collections.emptyMap()).values().stream()
.filter(r -> (location < 0) || (r.getLocation() == location))
.filter(r -> (r.getMinLvl() <= level) && (r.getMaxLvl() >= level))
.filter(room -> (location < 0) || (room.getLocation() == location))
.filter(room -> (type == PartyMatchingRoomLevelType.ALL) || ((room.getMinLvl() >= requestorLevel) && (room.getMaxLvl() <= requestorLevel)))
.collect(Collectors.toList());
//@formatter:on
}

View File

@ -126,6 +126,7 @@ public class L2Party extends AbstractPlayerGroup
_members.add(leader);
_partyLvl = leader.getLevel();
_distributionType = partyDistributionType;
L2World.getInstance().incrementParty();
}
/**
@ -393,6 +394,7 @@ public class L2Party extends AbstractPlayerGroup
}, PARTY_POSITION_BROADCAST_INTERVAL.toMillis() / 2, PARTY_POSITION_BROADCAST_INTERVAL.toMillis());
}
applyTacticalSigns(player, false);
L2World.getInstance().incrementPartyMember();
}
private Map<Integer, L2Character> getTacticalSigns()
@ -553,6 +555,8 @@ public class L2Party extends AbstractPlayerGroup
broadcastPacket(msg);
}
L2World.getInstance().decrementPartyMember();
// UI update.
player.sendPacket(PartySmallWindowDeleteAll.STATIC_PACKET);
player.setParty(null);
@ -632,6 +636,7 @@ public class L2Party extends AbstractPlayerGroup
}
}
}
L2World.getInstance().decrementParty();
}
/**

View File

@ -21,6 +21,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Logger;
@ -94,6 +95,9 @@ public final class L2World
/** Map with the pets instances and their owner ID. */
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
private final AtomicInteger _partyNumber = new AtomicInteger();
private final AtomicInteger _memberInPartyNumber = new AtomicInteger();
private final L2WorldRegion[][][] _worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1][REGIONS_Z + 1];
/** Constructor of L2World. */
@ -813,6 +817,36 @@ public final class L2World
_log.info(getClass().getSimpleName() + ": All visible NPC's deleted.");
}
public void incrementParty()
{
_partyNumber.incrementAndGet();
}
public void decrementParty()
{
_partyNumber.decrementAndGet();
}
public void incrementPartyMember()
{
_memberInPartyNumber.incrementAndGet();
}
public void decrementPartyMember()
{
_memberInPartyNumber.decrementAndGet();
}
public int getPartyCount()
{
return _partyNumber.get();
}
public int getPartyMemberCount()
{
return _memberInPartyNumber.get();
}
/**
* @return the current instance of L2World
*/

View File

@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.model.matching;
import com.l2jmobius.gameserver.enums.MatchingMemberType;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2Party;
@ -43,7 +44,8 @@ public final class PartyMatchingRoom extends MatchingRoom
protected void onRoomCreation(L2PcInstance player)
{
player.broadcastUserInfo(UserInfoType.CLAN);
player.sendPacket(new ListPartyWaiting(player.getLevel(), -1, 1));
player.sendPacket(new ListPartyWaiting(PartyMatchingRoomLevelType.ALL, -1, 1, player.getLevel()));
player.sendPacket(SystemMessageId.YOU_HAVE_CREATED_A_PARTY_ROOM);
}
@Override

View File

@ -33,6 +33,7 @@ public class RequestDismissPartyRoom implements IClientIncomingPacket
public boolean read(L2GameClient client, PacketReader packet)
{
_roomid = packet.readD();
packet.readD();
return true;
}

View File

@ -17,6 +17,7 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Party;
@ -28,14 +29,15 @@ import com.l2jmobius.gameserver.network.serverpackets.ListPartyWaiting;
public final class RequestPartyMatchConfig implements IClientIncomingPacket
{
private int _page, _location, _level;
private int _page, _location;
private PartyMatchingRoomLevelType _type;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_page = packet.readD();
_location = packet.readD();
_level = packet.readD();
_type = packet.readD() == 0 ? PartyMatchingRoomLevelType.MY_LEVEL_RANGE : PartyMatchingRoomLevelType.ALL;
return true;
}
@ -70,8 +72,7 @@ public final class RequestPartyMatchConfig implements IClientIncomingPacket
else
{
MatchingRoomManager.getInstance().addToWaitingList(activeChar);
activeChar.sendPacket(new ListPartyWaiting(_level, _location, _page));
activeChar.sendPacket(new ListPartyWaiting(_type, _location, _page, activeChar.getLevel()));
}
}
}

View File

@ -57,7 +57,7 @@ public class RequestPartyMatchList implements IClientIncomingPacket
return;
}
if (_roomId <= 0)
if ((_roomId <= 0) && (activeChar.getMatchingRoom() == null))
{
final PartyMatchingRoom room = new PartyMatchingRoom(_roomTitle, _lootType, _minLevel, _maxLevel, _maxMembers, activeChar);
activeChar.setMatchingRoom(room);

View File

@ -20,6 +20,7 @@ import java.util.LinkedList;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
@ -35,9 +36,9 @@ public class ListPartyWaiting implements IClientOutgoingPacket
private static final int NUM_PER_PAGE = 64;
public ListPartyWaiting(int level, int location, int page)
public ListPartyWaiting(PartyMatchingRoomLevelType type, int location, int page, int requestorLevel)
{
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, level);
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, type, requestorLevel);
_size = rooms.size();
final int startIndex = (page - 1) * NUM_PER_PAGE;

View File

@ -0,0 +1,23 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
public enum PartyMatchingRoomLevelType
{
MY_LEVEL_RANGE,
ALL
}

View File

@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
@ -87,12 +88,12 @@ public class MatchingRoomManager
return _rooms.get(MatchingRoomType.PARTY);
}
public List<MatchingRoom> getPartyMathchingRooms(int location, int level)
public List<MatchingRoom> getPartyMathchingRooms(int location, PartyMatchingRoomLevelType type, int requestorLevel)
{
//@formatter:off
return _rooms.getOrDefault(MatchingRoomType.PARTY, Collections.emptyMap()).values().stream()
.filter(r -> (location < 0) || (r.getLocation() == location))
.filter(r -> (r.getMinLvl() <= level) && (r.getMaxLvl() >= level))
.filter(room -> (location < 0) || (room.getLocation() == location))
.filter(room -> (type == PartyMatchingRoomLevelType.ALL) || ((room.getMinLvl() >= requestorLevel) && (room.getMaxLvl() <= requestorLevel)))
.collect(Collectors.toList());
//@formatter:on
}

View File

@ -126,6 +126,7 @@ public class L2Party extends AbstractPlayerGroup
_members.add(leader);
_partyLvl = leader.getLevel();
_distributionType = partyDistributionType;
L2World.getInstance().incrementParty();
}
/**
@ -393,6 +394,7 @@ public class L2Party extends AbstractPlayerGroup
}, PARTY_POSITION_BROADCAST_INTERVAL.toMillis() / 2, PARTY_POSITION_BROADCAST_INTERVAL.toMillis());
}
applyTacticalSigns(player, false);
L2World.getInstance().incrementPartyMember();
}
private Map<Integer, L2Character> getTacticalSigns()
@ -553,6 +555,8 @@ public class L2Party extends AbstractPlayerGroup
broadcastPacket(msg);
}
L2World.getInstance().decrementPartyMember();
// UI update.
player.sendPacket(PartySmallWindowDeleteAll.STATIC_PACKET);
player.setParty(null);
@ -632,6 +636,7 @@ public class L2Party extends AbstractPlayerGroup
}
}
}
L2World.getInstance().decrementParty();
}
/**

View File

@ -21,6 +21,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Logger;
@ -94,6 +95,9 @@ public final class L2World
/** Map with the pets instances and their owner ID. */
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
private final AtomicInteger _partyNumber = new AtomicInteger();
private final AtomicInteger _memberInPartyNumber = new AtomicInteger();
private final L2WorldRegion[][][] _worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1][REGIONS_Z + 1];
/** Constructor of L2World. */
@ -813,6 +817,36 @@ public final class L2World
_log.info(getClass().getSimpleName() + ": All visible NPC's deleted.");
}
public void incrementParty()
{
_partyNumber.incrementAndGet();
}
public void decrementParty()
{
_partyNumber.decrementAndGet();
}
public void incrementPartyMember()
{
_memberInPartyNumber.incrementAndGet();
}
public void decrementPartyMember()
{
_memberInPartyNumber.decrementAndGet();
}
public int getPartyCount()
{
return _partyNumber.get();
}
public int getPartyMemberCount()
{
return _memberInPartyNumber.get();
}
/**
* @return the current instance of L2World
*/

View File

@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.model.matching;
import com.l2jmobius.gameserver.enums.MatchingMemberType;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2Party;
@ -43,7 +44,8 @@ public final class PartyMatchingRoom extends MatchingRoom
protected void onRoomCreation(L2PcInstance player)
{
player.broadcastUserInfo(UserInfoType.CLAN);
player.sendPacket(new ListPartyWaiting(player.getLevel(), -1, 1));
player.sendPacket(new ListPartyWaiting(PartyMatchingRoomLevelType.ALL, -1, 1, player.getLevel()));
player.sendPacket(SystemMessageId.YOU_HAVE_CREATED_A_PARTY_ROOM);
}
@Override

View File

@ -33,6 +33,7 @@ public class RequestDismissPartyRoom implements IClientIncomingPacket
public boolean read(L2GameClient client, PacketReader packet)
{
_roomid = packet.readD();
packet.readD();
return true;
}

View File

@ -17,6 +17,7 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Party;
@ -28,14 +29,15 @@ import com.l2jmobius.gameserver.network.serverpackets.ListPartyWaiting;
public final class RequestPartyMatchConfig implements IClientIncomingPacket
{
private int _page, _location, _level;
private int _page, _location;
private PartyMatchingRoomLevelType _type;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_page = packet.readD();
_location = packet.readD();
_level = packet.readD();
_type = packet.readD() == 0 ? PartyMatchingRoomLevelType.MY_LEVEL_RANGE : PartyMatchingRoomLevelType.ALL;
return true;
}
@ -70,8 +72,7 @@ public final class RequestPartyMatchConfig implements IClientIncomingPacket
else
{
MatchingRoomManager.getInstance().addToWaitingList(activeChar);
activeChar.sendPacket(new ListPartyWaiting(_level, _location, _page));
activeChar.sendPacket(new ListPartyWaiting(_type, _location, _page, activeChar.getLevel()));
}
}
}

View File

@ -57,7 +57,7 @@ public class RequestPartyMatchList implements IClientIncomingPacket
return;
}
if (_roomId <= 0)
if ((_roomId <= 0) && (activeChar.getMatchingRoom() == null))
{
final PartyMatchingRoom room = new PartyMatchingRoom(_roomTitle, _lootType, _minLevel, _maxLevel, _maxMembers, activeChar);
activeChar.setMatchingRoom(room);

View File

@ -20,7 +20,9 @@ import java.util.LinkedList;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
import com.l2jmobius.gameserver.network.OutgoingPackets;
@ -35,9 +37,9 @@ public class ListPartyWaiting implements IClientOutgoingPacket
private static final int NUM_PER_PAGE = 64;
public ListPartyWaiting(int level, int location, int page)
public ListPartyWaiting(PartyMatchingRoomLevelType type, int location, int page, int requestorLevel)
{
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, level);
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, type, requestorLevel);
_size = rooms.size();
final int startIndex = (page - 1) * NUM_PER_PAGE;
@ -75,8 +77,8 @@ public class ListPartyWaiting implements IClientOutgoingPacket
packet.writeS(member.getName());
}
}
packet.writeD(0);
packet.writeD(0);
packet.writeD(L2World.getInstance().getPartyCount()); // Helios
packet.writeD(L2World.getInstance().getPartyMemberCount()); // Helios
return true;
}
}

View File

@ -0,0 +1,23 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.enums;
public enum PartyMatchingRoomLevelType
{
MY_LEVEL_RANGE,
ALL
}

View File

@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
@ -87,12 +88,12 @@ public class MatchingRoomManager
return _rooms.get(MatchingRoomType.PARTY);
}
public List<MatchingRoom> getPartyMathchingRooms(int location, int level)
public List<MatchingRoom> getPartyMathchingRooms(int location, PartyMatchingRoomLevelType type, int requestorLevel)
{
//@formatter:off
return _rooms.getOrDefault(MatchingRoomType.PARTY, Collections.emptyMap()).values().stream()
.filter(r -> (location < 0) || (r.getLocation() == location))
.filter(r -> (r.getMinLvl() <= level) && (r.getMaxLvl() >= level))
.filter(room -> (location < 0) || (room.getLocation() == location))
.filter(room -> (type == PartyMatchingRoomLevelType.ALL) || ((room.getMinLvl() >= requestorLevel) && (room.getMaxLvl() <= requestorLevel)))
.collect(Collectors.toList());
//@formatter:on
}

View File

@ -126,6 +126,7 @@ public class L2Party extends AbstractPlayerGroup
_members.add(leader);
_partyLvl = leader.getLevel();
_distributionType = partyDistributionType;
L2World.getInstance().incrementParty();
}
/**
@ -393,6 +394,7 @@ public class L2Party extends AbstractPlayerGroup
}, PARTY_POSITION_BROADCAST_INTERVAL.toMillis() / 2, PARTY_POSITION_BROADCAST_INTERVAL.toMillis());
}
applyTacticalSigns(player, false);
L2World.getInstance().incrementPartyMember();
}
private Map<Integer, L2Character> getTacticalSigns()
@ -553,6 +555,8 @@ public class L2Party extends AbstractPlayerGroup
broadcastPacket(msg);
}
L2World.getInstance().decrementPartyMember();
// UI update.
player.sendPacket(PartySmallWindowDeleteAll.STATIC_PACKET);
player.setParty(null);
@ -632,6 +636,7 @@ public class L2Party extends AbstractPlayerGroup
}
}
}
L2World.getInstance().decrementParty();
}
/**

View File

@ -21,6 +21,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Logger;
@ -94,6 +95,9 @@ public final class L2World
/** Map with the pets instances and their owner ID. */
private final Map<Integer, L2PetInstance> _petsInstance = new ConcurrentHashMap<>();
private final AtomicInteger _partyNumber = new AtomicInteger();
private final AtomicInteger _memberInPartyNumber = new AtomicInteger();
private final L2WorldRegion[][][] _worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1][REGIONS_Z + 1];
/** Constructor of L2World. */
@ -813,6 +817,36 @@ public final class L2World
_log.info(getClass().getSimpleName() + ": All visible NPC's deleted.");
}
public void incrementParty()
{
_partyNumber.incrementAndGet();
}
public void decrementParty()
{
_partyNumber.decrementAndGet();
}
public void incrementPartyMember()
{
_memberInPartyNumber.incrementAndGet();
}
public void decrementPartyMember()
{
_memberInPartyNumber.decrementAndGet();
}
public int getPartyCount()
{
return _partyNumber.get();
}
public int getPartyMemberCount()
{
return _memberInPartyNumber.get();
}
/**
* @return the current instance of L2World
*/

View File

@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.model.matching;
import com.l2jmobius.gameserver.enums.MatchingMemberType;
import com.l2jmobius.gameserver.enums.MatchingRoomType;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2Party;
@ -43,7 +44,8 @@ public final class PartyMatchingRoom extends MatchingRoom
protected void onRoomCreation(L2PcInstance player)
{
player.broadcastUserInfo(UserInfoType.CLAN);
player.sendPacket(new ListPartyWaiting(player.getLevel(), -1, 1));
player.sendPacket(new ListPartyWaiting(PartyMatchingRoomLevelType.ALL, -1, 1, player.getLevel()));
player.sendPacket(SystemMessageId.YOU_HAVE_CREATED_A_PARTY_ROOM);
}
@Override

View File

@ -33,6 +33,7 @@ public class RequestDismissPartyRoom implements IClientIncomingPacket
public boolean read(L2GameClient client, PacketReader packet)
{
_roomid = packet.readD();
packet.readD();
return true;
}

View File

@ -17,6 +17,7 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2CommandChannel;
import com.l2jmobius.gameserver.model.L2Party;
@ -28,14 +29,15 @@ import com.l2jmobius.gameserver.network.serverpackets.ListPartyWaiting;
public final class RequestPartyMatchConfig implements IClientIncomingPacket
{
private int _page, _location, _level;
private int _page, _location;
private PartyMatchingRoomLevelType _type;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_page = packet.readD();
_location = packet.readD();
_level = packet.readD();
_type = packet.readD() == 0 ? PartyMatchingRoomLevelType.MY_LEVEL_RANGE : PartyMatchingRoomLevelType.ALL;
return true;
}
@ -70,8 +72,7 @@ public final class RequestPartyMatchConfig implements IClientIncomingPacket
else
{
MatchingRoomManager.getInstance().addToWaitingList(activeChar);
activeChar.sendPacket(new ListPartyWaiting(_level, _location, _page));
activeChar.sendPacket(new ListPartyWaiting(_type, _location, _page, activeChar.getLevel()));
}
}
}

View File

@ -57,7 +57,7 @@ public class RequestPartyMatchList implements IClientIncomingPacket
return;
}
if (_roomId <= 0)
if ((_roomId <= 0) && (activeChar.getMatchingRoom() == null))
{
final PartyMatchingRoom room = new PartyMatchingRoom(_roomTitle, _lootType, _minLevel, _maxLevel, _maxMembers, activeChar);
activeChar.setMatchingRoom(room);

View File

@ -20,7 +20,9 @@ import java.util.LinkedList;
import java.util.List;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.PartyMatchingRoomLevelType;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.matching.MatchingRoom;
import com.l2jmobius.gameserver.network.OutgoingPackets;
@ -35,9 +37,9 @@ public class ListPartyWaiting implements IClientOutgoingPacket
private static final int NUM_PER_PAGE = 64;
public ListPartyWaiting(int level, int location, int page)
public ListPartyWaiting(PartyMatchingRoomLevelType type, int location, int page, int requestorLevel)
{
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, level);
final List<MatchingRoom> rooms = MatchingRoomManager.getInstance().getPartyMathchingRooms(location, type, requestorLevel);
_size = rooms.size();
final int startIndex = (page - 1) * NUM_PER_PAGE;
@ -75,8 +77,8 @@ public class ListPartyWaiting implements IClientOutgoingPacket
packet.writeS(member.getName());
}
}
packet.writeD(0);
packet.writeD(0);
packet.writeD(L2World.getInstance().getPartyCount()); // Helios
packet.writeD(L2World.getInstance().getPartyMemberCount()); // Helios
return true;
}
}