Water of Life + Fixed GPQ & Buff system

Added Water of Life. Fixed Shuang (GPQ) npc dc'ing the leader when first
trying to enter the waiting area. Fixed some cases with the revamped
buff system, that would not properly check for the best buffs in some
scenarios, and would throw exceptions, caused by not properly protecting
access to critical data.
This commit is contained in:
ronancpl
2017-09-25 02:16:24 -03:00
parent 7bbf512797
commit 28258530e4
47 changed files with 316 additions and 47 deletions

View File

@@ -28,11 +28,11 @@ import server.MapleStatEffect;
* @author Danny
*/
public class PlayerBuffValueHolder {
public long startTime;
public int usedTime;
public MapleStatEffect effect;
public PlayerBuffValueHolder(long startTime, MapleStatEffect effect) {
this.startTime = startTime;
public PlayerBuffValueHolder(int usedTime, MapleStatEffect effect) {
this.usedTime = usedTime;
this.effect = effect;
}
}

View File

@@ -41,7 +41,6 @@ public final class CancelBuffHandler extends AbstractMaplePacketHandler implemen
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int sourceid = slea.readInt();
if(sourceid < 0) sourceid = -sourceid; //oh my...
switch (sourceid) {
case FPArchMage.BIG_BANG:

View File

@@ -25,6 +25,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import net.AbstractMaplePacketHandler;
@@ -39,9 +40,11 @@ import net.server.world.PartyOperation;
import net.server.world.World;
import tools.DatabaseConnection;
import tools.MaplePacketCreator;
import tools.Pair;
import tools.data.input.SeekableLittleEndianAccessor;
import client.BuddylistEntry;
import client.CharacterNameAndId;
import client.MapleBuffStat;
import client.MapleCharacter;
import client.MapleClient;
import client.MapleFamily;
@@ -50,6 +53,8 @@ import client.inventory.MapleInventoryType;
import client.inventory.MaplePet;
import constants.GameConstants;
import constants.ServerConstants;
import java.util.Collections;
import java.util.Comparator;
public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
@@ -107,7 +112,8 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
List<PlayerBuffValueHolder> buffs = server.getPlayerBuffStorage().getBuffsFromStorage(cid);
if (buffs != null) {
player.silentGiveBuffs(buffs);
List<Pair<Long, PlayerBuffValueHolder>> timedBuffs = getLocalStartTimes(buffs);
player.silentGiveBuffs(timedBuffs);
}
Connection con = null;
PreparedStatement ps = null;
@@ -286,4 +292,22 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
player.receivePartyMemberHP();
}
private List<Pair<Long, PlayerBuffValueHolder>> getLocalStartTimes(List<PlayerBuffValueHolder> lpbvl) {
List<Pair<Long, PlayerBuffValueHolder>> timedBuffs = new ArrayList<>();
long curtime = System.currentTimeMillis();
for(PlayerBuffValueHolder pb : lpbvl) {
timedBuffs.add(new Pair<>(curtime - pb.usedTime, pb));
}
Collections.sort(timedBuffs, new Comparator<Pair<Long, PlayerBuffValueHolder>>() {
@Override
public int compare(Pair<Long, PlayerBuffValueHolder> p1, Pair<Long, PlayerBuffValueHolder> p2) {
return p1.getLeft().compareTo(p2.getLeft());
}
});
return timedBuffs;
}
}

View File

@@ -0,0 +1,34 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.server.channel.handlers;
import client.MapleClient;
import net.AbstractMaplePacketHandler;
import tools.data.input.SeekableLittleEndianAccessor;
public final class UseWaterOfLifeHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
c.getAbstractPlayerInteraction().openNpc(1032102, "waterOfLife");
}
}