Code improvements.

This commit is contained in:
MobiusDev
2016-04-24 16:30:15 +00:00
parent 8bd51aba1c
commit 2dd14bef9b
860 changed files with 8865 additions and 17041 deletions

View File

@@ -102,5 +102,4 @@ public class AdminForgePacket extends L2GameServerPacket
{
_parts.add(new Part(b, string));
}
}

View File

@@ -235,19 +235,15 @@ public class CharSelectionInfo extends L2GameServerPacket
// See if the char must be deleted
final long deletetime = chardata.getLong("deletetime");
if (deletetime > 0)
if ((deletetime > 0) && (System.currentTimeMillis() > deletetime))
{
if (System.currentTimeMillis() > deletetime)
final L2Clan clan = ClanTable.getInstance().getClan(chardata.getInt("clanid"));
if (clan != null)
{
final L2Clan clan = ClanTable.getInstance().getClan(chardata.getInt("clanid"));
if (clan != null)
{
clan.removeClanMember(objectId, 0);
}
L2GameClient.deleteCharByObjId(objectId);
return null;
clan.removeClanMember(objectId, 0);
}
L2GameClient.deleteCharByObjId(objectId);
return null;
}
final CharSelectInfoPackage charInfopackage = new CharSelectInfoPackage(objectId, name);

View File

@@ -44,12 +44,9 @@ public class ExAcquireAPSkillList extends L2GameServerPacket
for (L2SkillLearn sk : SkillTreesData.getInstance().getAbilitySkillTree().values())
{
final Skill knownSkill = activeChar.getKnownSkill(sk.getSkillId());
if (knownSkill != null)
if ((knownSkill != null) && (knownSkill.getLevel() == sk.getSkillLevel()))
{
if (knownSkill.getLevel() == sk.getSkillLevel())
{
_skills.add(knownSkill);
}
_skills.add(knownSkill);
}
}
_enable = !activeChar.isSubClassActive() && (activeChar.getLevel() >= 99) && activeChar.isNoble();

View File

@@ -47,5 +47,4 @@ public class ExBrBuffEventState extends L2GameServerPacket
writeD(_state);
writeD(_endtime);
}
}

View File

@@ -34,12 +34,9 @@ public class ExChangeAttributeItemList extends AbstractItemPacket
_itemsList = new ArrayList<>();
for (L2ItemInstance item : player.getInventory().getItems())
{
if (item.isWeapon())
if (item.isWeapon() && (item.getAttackElementPower() > 0))
{
if (item.getAttackElementPower() > 0)
{
_itemsList.add(item);
}
_itemsList.add(item);
}
}
_itemOID = itemOID;

View File

@@ -57,17 +57,13 @@ public final class ExEnchantSkillInfo extends L2GameServerPacket
_routes.add(_lvl + 1); // current enchant add firts
}
final int skillLvL = (_lvl % 1000);
for (int route : enchantLearn.getAllRoutes())
{
if (((route * 1000) + skillLvL) == _lvl)
if (((route * 1000) + (_lvl % 1000)) == _lvl)
{
continue;
}
// add other levels of all routes - same lvl as enchanted
// lvl
_routes.add((route * 1000) + skillLvL);
_routes.add((route * 1000) + (_lvl % 1000));
}
}
else

View File

@@ -46,14 +46,7 @@ public class ExFlyMove extends L2GameServerPacket
writeH(0xe8);
writeD(_objId);
if (_jw.size() == 1)
{
writeD(2);
}
else
{
writeD(0);
}
writeD(_jw.size() == 1 ? 2 : 0);
writeD(0);
writeD(_trackId);

View File

@@ -30,8 +30,7 @@ public class ExLoginVitalityEffectInfo extends L2GameServerPacket
public ExLoginVitalityEffectInfo(L2GameClient client)
{
final AccountVariables vars = new AccountVariables(client.getAccountName());
_points = vars.getInt(PcStat.VITALITY_VARIABLE, Config.STARTING_VITALITY_POINTS);
_points = (new AccountVariables(client.getAccountName())).getInt(PcStat.VITALITY_VARIABLE, Config.STARTING_VITALITY_POINTS);
}
@Override

View File

@@ -42,5 +42,4 @@ public class ExShowAgitInfo extends L2GameServerPacket
writeD(ch.getGrade() > 0 ? 0x00 : 0x01); // 0 - auction 1 - war clanhall 2 - ETC (rainbow spring clanhall)
}
}
}

View File

@@ -61,5 +61,4 @@ public class ExShowCastleInfo extends L2GameServerPacket
writeD((int) (castle.getSiege().getSiegeDate().getTimeInMillis() / 1000));
}
}
}

View File

@@ -54,14 +54,7 @@ public class ExShowFortressMapInfo extends L2GameServerPacket
{
for (FortSiegeSpawn spawn : commanders)
{
if (isSpawned(spawn.getId()))
{
writeD(0);
}
else
{
writeD(1);
}
writeD(isSpawned(spawn.getId()) ? 0 : 1);
}
break;
}
@@ -75,14 +68,7 @@ public class ExShowFortressMapInfo extends L2GameServerPacket
{
writeD(1); // TODO: control room emulated
}
if (isSpawned(spawn.getId()))
{
writeD(0);
}
else
{
writeD(1);
}
writeD(isSpawned(spawn.getId()) ? 0 : 1);
}
break;
}

View File

@@ -46,22 +46,19 @@ public class ExUISetting extends L2GameServerPacket
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList1 = _uiSettings.getCategories().get(category);
size = size + catElList1.size();
size = size + _uiSettings.getCategories().get(category).size();
}
category++;
size++;
if (_uiSettings.getCategories().containsKey(category))
{
final List<Integer> catElList2 = _uiSettings.getCategories().get(category);
size = size + catElList2.size();
size = size + _uiSettings.getCategories().get(category).size();
}
category++;
size = size + 4;
if (_uiSettings.getKeys().containsKey(i))
{
final List<ActionKey> keyElList = _uiSettings.getKeys().get(i);
size = size + (keyElList.size() * 20);
size = size + (_uiSettings.getKeys().get(i).size() * 20);
}
}
buffsize = size;

View File

@@ -36,8 +36,7 @@ public class ExVitalityEffectInfo extends L2GameServerPacket
public ExVitalityEffectInfo(L2GameClient client)
{
final AccountVariables vars = new AccountVariables(client.getAccountName());
_points = vars.getInt(PcStat.VITALITY_VARIABLE, Config.STARTING_VITALITY_POINTS);
_points = (new AccountVariables(client.getAccountName())).getInt(PcStat.VITALITY_VARIABLE, Config.STARTING_VITALITY_POINTS);
}
@Override

View File

@@ -41,7 +41,7 @@ public class GMViewSkillInfo extends L2GameServerPacket
writeS(_activeChar.getName());
writeD(_skills.size());
final boolean isDisabled = (_activeChar.getClan() != null) ? (_activeChar.getClan().getReputationScore() < 0) : false;
final boolean isDisabled = (_activeChar.getClan() != null) && (_activeChar.getClan().getReputationScore() < 0);
for (Skill skill : _skills)
{

View File

@@ -64,14 +64,7 @@ public class ListPartyWating extends L2GameServerPacket
final int size = _rooms.size();
writeC(0x9c);
if (size > 0)
{
writeD(0x01);
}
else
{
writeD(0x00);
}
writeD(size > 0 ? 0x01 : 0x00);
writeD(_rooms.size());
for (PartyMatchRoom room : _rooms)

View File

@@ -60,14 +60,7 @@ public class MonRaceInfo extends L2GameServerPacket
writeD(120); // ?? unknown
for (int j = 0; j < 20; j++)
{
if (_unknown1 == 0)
{
writeC(_speeds[i][j]);
}
else
{
writeC(0x00);
}
writeC(_unknown1 == 0 ? _speeds[i][j] : 0x00);
}
}
}

View File

@@ -106,7 +106,6 @@ public final class MultiSellList extends L2GameServerPacket
writeH(ing.getItemInfo().getElementals()[3]); // earth
writeH(ing.getItemInfo().getElementals()[4]); // holy
writeH(ing.getItemInfo().getElementals()[5]); // dark
writeH(0x00);
}
else
{
@@ -122,8 +121,8 @@ public final class MultiSellList extends L2GameServerPacket
writeH(0x00); // earth
writeH(0x00); // holy
writeH(0x00); // dark
writeH(0x00);
}
writeH(0x00);
}
for (Ingredient ing : ent.getIngredients())
@@ -144,7 +143,6 @@ public final class MultiSellList extends L2GameServerPacket
writeH(ing.getItemInfo().getElementals()[3]); // earth
writeH(ing.getItemInfo().getElementals()[4]); // holy
writeH(ing.getItemInfo().getElementals()[5]); // dark
writeH(0x00);
}
else
{
@@ -159,8 +157,8 @@ public final class MultiSellList extends L2GameServerPacket
writeH(0x00); // earth
writeH(0x00); // holy
writeH(0x00); // dark
writeH(0x00);
}
writeH(0x00);
}
}
}

View File

@@ -74,14 +74,7 @@ public class PledgeShowMemberListAll extends L2GameServerPacket
{
_name = subPledge.getName();
}
if ((_name == "") || (_name == name))
{
writeD(0);
}
else
{
writeD(1);
}
writeD((_name == "") || (_name == name) ? 0 : 1);
writeD(_clan.getId());
writeD(Config.SERVER_ID);
writeD(_pledgeType);

View File

@@ -83,14 +83,7 @@ public class QuestList extends L2GameServerPacket
}
final int states = qs.getInt("__compltdStateFlags");
if (states != 0)
{
writeD(states);
}
else
{
writeD(qs.getInt("cond"));
}
writeD(states != 0 ? states : qs.getInt("cond"));
}
for (Quest q : completedQuests)

View File

@@ -477,14 +477,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if (item.isWeapon() || (item.getItem().getType2() == L2Item.TYPE2_WEAPON) || (item.isEtcItem() && (item.getItemType() == EtcItemType.ARROW)) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -504,14 +501,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if (item.isArmor() || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -531,14 +525,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if (item.isEtcItem() || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -558,14 +549,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && (item.getEtcItem().getItemType() == EtcItemType.MATERIAL)) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -585,14 +573,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && (item.getEtcItem().getItemType() == EtcItemType.RECIPE)) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -612,14 +597,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && (item.getItemName().toUpperCase().startsWith("AMULET"))) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -639,14 +621,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && (!item.getItemName().toUpperCase().startsWith("AMULET"))) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -666,14 +645,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && ((item.getEtcItem().getItemType() == EtcItemType.SCROLL) || (item.getEtcItem().getItemType() == EtcItemType.SHOT))) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -693,14 +669,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && (item.getEtcItem().getItemType() == EtcItemType.SHOT)) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -720,14 +693,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && (item.getEtcItem().getItemType() == EtcItemType.SCROLL)) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -747,14 +717,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && (item.getEtcItem().getItemType() == EtcItemType.SEED)) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -774,14 +741,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
{
if ((item.isEtcItem() && ((item.getEtcItem().getItemType() != EtcItemType.MATERIAL) && (item.getEtcItem().getItemType() != EtcItemType.RECIPE) && (item.getEtcItem().getItemType() != EtcItemType.SCROLL) && (item.getEtcItem().getItemType() != EtcItemType.SHOT))) || (item.getItem().getType2() == L2Item.TYPE2_MONEY))
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
}
return list;
@@ -798,14 +762,11 @@ public class SortedWareHouseWithdrawalList extends AbstractItemPacket
final List<L2WarehouseItem> list = new ArrayList<>();
for (L2ItemInstance item : _items)
{
if (list.size() < MAX_SORT_LIST_ITEMS)
{
list.add(new L2WarehouseItem(item));
}
else
if (list.size() >= MAX_SORT_LIST_ITEMS)
{
continue;
}
list.add(new L2WarehouseItem(item));
}
return list;
}

View File

@@ -35,30 +35,32 @@ public final class TradeStart extends AbstractItemPacket
_partner = player.getActiveTradeList().getPartner();
_itemList = _activeChar.getInventory().getAvailableItems(true, (_activeChar.canOverrideCond(PcCondOverride.ITEM_CONDITIONS) && Config.GM_TRADE_RESTRICTED_ITEMS), false);
if (_partner != null)
if (_partner == null)
{
if (player.getFriendList().containsKey(_partner.getObjectId()))
{
_mask |= 0x01;
}
if ((player.getClanId() > 0) && (_partner.getClanId() == _partner.getClanId()))
{
_mask |= 0x02;
}
if ((MentorManager.getInstance().getMentee(player.getObjectId(), _partner.getObjectId()) != null) || (MentorManager.getInstance().getMentee(_partner.getObjectId(), player.getObjectId()) != null))
{
_mask |= 0x04;
}
if ((player.getAllyId() > 0) && (player.getAllyId() == _partner.getAllyId()))
{
_mask |= 0x08;
}
// Does not shows level
if (_partner.isGM())
{
_mask |= 0x10;
}
return;
}
if (player.getFriendList().containsKey(_partner.getObjectId()))
{
_mask |= 0x01;
}
if ((player.getClanId() > 0) && (_partner.getClanId() == _partner.getClanId()))
{
_mask |= 0x02;
}
if ((MentorManager.getInstance().getMentee(player.getObjectId(), _partner.getObjectId()) != null) || (MentorManager.getInstance().getMentee(_partner.getObjectId(), player.getObjectId()) != null))
{
_mask |= 0x04;
}
if ((player.getAllyId() > 0) && (player.getAllyId() == _partner.getAllyId()))
{
_mask |= 0x08;
}
// Does not shows level
if (_partner.isGM())
{
_mask |= 0x10;
}
}

View File

@@ -72,12 +72,7 @@ public class ExResponseCommissionList extends AbstractItemPacket
writeD((int) Instant.now().getEpochSecond());
writeD(_chunkId);
int chunkSize = _items.size() - _listIndexStart;
if (chunkSize > MAX_CHUNK_SIZE)
{
chunkSize = MAX_CHUNK_SIZE;
}
final int chunkSize = (_items.size() - _listIndexStart) > MAX_CHUNK_SIZE ? MAX_CHUNK_SIZE : _items.size() - _listIndexStart;
writeD(chunkSize);
for (int i = _listIndexStart; i < (_listIndexStart + chunkSize); i++)
{