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:
@@ -245,6 +245,7 @@ public final class PacketProcessor {
|
||||
registerHandler(RecvOpcode.MONSTER_CARNIVAL, new MonsterCarnivalHandler());
|
||||
registerHandler(RecvOpcode.REMOTE_STORE, new RemoteStoreHandler());
|
||||
registerHandler(RecvOpcode.WEDDING_ACTION, new WeddingHandler());
|
||||
registerHandler(RecvOpcode.WATER_OF_LIFE, new UseWaterOfLifeHandler());
|
||||
registerHandler(RecvOpcode.ADMIN_CHAT, new AdminChatHandler());
|
||||
registerHandler(RecvOpcode.MOVE_DRAGON, new MoveDragonHandler());
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ public enum RecvOpcode {
|
||||
USE_ITEM_REWARD(0x70),
|
||||
MAKER_SKILL(0x71),
|
||||
USE_REMOTE(0x74),
|
||||
WATER_OF_LIFE(0x75),
|
||||
ADMIN_CHAT(0x76),
|
||||
PARTYCHAT(0x77),
|
||||
WHISPER(0x78),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
34
src/net/server/channel/handlers/UseWaterOfLifeHandler.java
Normal file
34
src/net/server/channel/handlers/UseWaterOfLifeHandler.java
Normal 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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user