Compare commits

..

15 Commits

Author SHA1 Message Date
Ponk
799cb97564 Merge pull request #217 from P0nk/fix/210-clean-slate-scroll #minor
Fix able to gain infinite slots with clean slate scroll
2024-02-05 08:39:25 +01:00
P0nk
851b57e8ef Fix able to gain infinite slots with clean slate scroll
And remove a GM config option.
Thanks Crabo for the suggested solution.
2024-02-05 08:34:36 +01:00
Ponk
ceb2866aa1 Merge pull request #214 from leevccc/master #patch
fix: item lock cant extend lock time
2024-02-04 14:22:00 +01:00
Ponk
11c1e4655e Merge pull request #213 from yuzumika/ppq-npc-fix #patch
Fix bug in PPQ where non-party leader can get stuck in an NPC dialogue loop
2024-02-04 12:09:33 +01:00
Ponk
aca9cbf91d Merge pull request #212 from yuzumika/fix-selection-underflow #minor
NPCMoreTalkHandler: don't underflow selection
2024-02-04 12:07:46 +01:00
leevccc
08b089d9be fix: seal lock cant extend lock time 2024-01-14 22:13:16 +08:00
leevccc
8b254a294e fix: item lock cant extend lock time 2024-01-14 18:15:48 +08:00
yuzumika
7004de6e71 ppq: fix bug where non-party leader can get stuck in an npc dialogue loop 2024-01-04 14:30:59 -08:00
yuzumika
738e1b24e6 add unit tests for ByteBufInPacketTest.readUnsignedByte 2024-01-04 13:42:20 -08:00
yuzumika
5a4200cc8e implement ByteBufInPacket.readUnsignedByte 2024-01-04 10:55:07 -08:00
yuzumika
cb0320a471 NPCMoreTalkHandler: don't underflow selection 2024-01-03 16:10:23 -08:00
Ponk
058f034c2b Merge pull request #209 from yuzumika/minigame-npc-dispose #patch
Minigame NPC (Casey) tweaks
2024-01-03 20:13:59 +01:00
yuzumika
9c54f3a8ea minigame npc: add more disposes, fix typo 2023-12-27 15:35:45 -08:00
yuzumika
ee8cb545e1 minigame npc: use omokamount constant consistently; tiny text tweak to
make it more GMS-like
2023-12-27 15:18:22 -08:00
yuzumika
64bbff462d minigame npc: dispose after creating a set of match cards 2023-12-27 14:54:10 -08:00
11 changed files with 105 additions and 39 deletions

View File

@@ -347,7 +347,6 @@ server:
USE_PERFECT_SCROLLING: false #Scrolls doesn't use slots upon failure. USE_PERFECT_SCROLLING: false #Scrolls doesn't use slots upon failure.
USE_ENHANCED_CHSCROLL: false #Equips even more powerful with chaos upgrade. USE_ENHANCED_CHSCROLL: false #Equips even more powerful with chaos upgrade.
USE_ENHANCED_CRAFTING: false #Apply chaos scroll on every equip crafted. USE_ENHANCED_CRAFTING: false #Apply chaos scroll on every equip crafted.
USE_ENHANCED_CLNSLATE: false #Clean slates can be applied to recover successfully used slots as well.
SCROLL_CHANCE_ROLLS: 1 #Number of rolls for success on a scroll, set 1 for default. SCROLL_CHANCE_ROLLS: 1 #Number of rolls for success on a scroll, set 1 for default.
CHSCROLL_STAT_RATE: 1 #Number of rolls of stat upgrade on a successfully applied chaos scroll, set 1 for default. CHSCROLL_STAT_RATE: 1 #Number of rolls of stat upgrade on a successfully applied chaos scroll, set 1 for default.
CHSCROLL_STAT_RANGE: 6 #Stat upgrade range (-N, N) on chaos scrolls. CHSCROLL_STAT_RANGE: 6 #Stat upgrade range (-N, N) on chaos scrolls.

View File

@@ -31,7 +31,7 @@ function action(mode, type, selection) {
} }
if (status == 0) { if (status == 0) {
cm.sendSimple("Hey, you look like you need a breather. You should be enjoying the life, just like I am. Well, if you have a couple of items, I can trade you for an item you can play minigames with. Now... what can I do for you?#b\r\n#L0#Create a minigame item#l\r\n#L1#Explain to me what the minigames are about#l#k"); cm.sendSimple("Hey, you look like you need a breather from all that hunting. You should be enjoying the life, just like I am. Well, if you have a couple of items, I can trade you for an item you can play minigames with. Now... what can I do for you?#b\r\n#L0#Create a minigame item#l\r\n#L1#Explain to me what the minigames are about#l#k");
} else if (status == 1) { } else if (status == 1) {
if (selection == 0) { if (selection == 0) {
@@ -57,6 +57,7 @@ function action(mode, type, selection) {
if (cm.haveItem(4030012, 15)) { if (cm.haveItem(4030012, 15)) {
cm.gainItem(4030012, -15); cm.gainItem(4030012, -15);
cm.gainItem(4080100, 1); cm.gainItem(4080100, 1);
cm.dispose();
} else { } else {
cm.sendNext("You want #bA set of Match Cards#k? Hmm...to make A set of Match Cards, you'll need some #bMonster Cards#k. Monster Card can be obtained by taking out the monsters all around the island. Collect 15 Monster Cards and you can make a set of A set of Match Cards."); //Lmfao a set of A set xD cm.sendNext("You want #bA set of Match Cards#k? Hmm...to make A set of Match Cards, you'll need some #bMonster Cards#k. Monster Card can be obtained by taking out the monsters all around the island. Collect 15 Monster Cards and you can make a set of A set of Match Cards."); //Lmfao a set of A set xD
cm.dispose(); cm.dispose();
@@ -81,7 +82,7 @@ function action(mode, type, selection) {
if (current == 1 || current == 2) { if (current == 1 || current == 2) {
cm.sendNextPrev("Enter the room, and when you're ready to play, click on #bReady#k.\r\nOnce the visitor clicks on #bReady#k, the room owner can press #bStart#k to begin the game. If an unwanted visitor walks in, and you don't want to play with that person, the room owner has the right to kick the visitor out of the room. There will be a square box with x written on the right of that person. Click on that for a cold goodbye, okay?"); //Oh yeah, because people WALK in Omok Rooms. cm.sendNextPrev("Enter the room, and when you're ready to play, click on #bReady#k.\r\nOnce the visitor clicks on #bReady#k, the room owner can press #bStart#k to begin the game. If an unwanted visitor walks in, and you don't want to play with that person, the room owner has the right to kick the visitor out of the room. There will be a square box with x written on the right of that person. Click on that for a cold goodbye, okay?"); //Oh yeah, because people WALK in Omok Rooms.
} else if (current == 3) { } else if (current == 3) {
if (cm.haveItem(omok1piece[selection], 99) && cm.haveItem(omok2piece[selection], 99) && cm.haveItem(4030009, 1)) { if (cm.haveItem(omok1piece[selection], omokamount) && cm.haveItem(omok2piece[selection], omokamount) && cm.haveItem(4030009, 1)) {
cm.gainItem(omok1piece[selection], -omokamount); cm.gainItem(omok1piece[selection], -omokamount);
cm.gainItem(omok2piece[selection], -omokamount); cm.gainItem(omok2piece[selection], -omokamount);
cm.gainItem(4030009, -1); cm.gainItem(4030009, -1);
@@ -95,7 +96,7 @@ function action(mode, type, selection) {
} else if (status == 5) { } else if (status == 5) {
if (current == 1) { if (current == 1) {
cm.sendNextPrev("When the first fame starts, #bthe room owner goes first#k. Beward that you'll be given a time limit, and you may lose your turn if you don't make your move on time. Normally, 3 x 3 is not allowed, but if there comes a point that it's absolutely necessary to put your piece there or face ending the game, then you can put it there. 3 x 3 is allowed as the last line of defense! Oh, and it won't count if it's #r6 or 7 straight#k. Only 5!"); cm.sendNextPrev("When the first game starts, #bthe room owner goes first#k. Beward that you'll be given a time limit, and you may lose your turn if you don't make your move on time. Normally, 3 x 3 is not allowed, but if there comes a point that it's absolutely necessary to put your piece there or face ending the game, then you can put it there. 3 x 3 is allowed as the last line of defense! Oh, and it won't count if it's #r6 or 7 straight#k. Only 5!");
} else if (current == 2) { } else if (current == 2) {
cm.sendNextPrev("Oh, and unlike Omok, when you create the game room for Match Cards, you'll need to set your game on the number of cards you'll use for the game. There are 3 modes avaliable, 3x4, 4x5, and 5x6, which will require 12, 20, and 30 cards respectively. Remember that you won't beable to change it up once the room is open, so if you really wish to change it up, you may have to close the room and open another one."); cm.sendNextPrev("Oh, and unlike Omok, when you create the game room for Match Cards, you'll need to set your game on the number of cards you'll use for the game. There are 3 modes avaliable, 3x4, 4x5, and 5x6, which will require 12, 20, and 30 cards respectively. Remember that you won't beable to change it up once the room is open, so if you really wish to change it up, you may have to close the room and open another one.");
} }
@@ -110,12 +111,14 @@ function action(mode, type, selection) {
} else if (status == 7) { } else if (status == 7) {
if (current == 1) { if (current == 1) {
cm.sendPrev("When the next game starts, the loser will go first. Also, no one is allowed to leave in the middle of a game. If you do, you may need to request either a #bforfeit or tie#k. (Of course, if you request a forfeit, you'll lose the game.) And if you click on 'Leave' in the middle of the game and call to leave after the game, you'll leave the room right after the game is over. This will be a much more useful way to leave."); cm.sendPrev("When the next game starts, the loser will go first. Also, no one is allowed to leave in the middle of a game. If you do, you may need to request either a #bforfeit or tie#k. (Of course, if you request a forfeit, you'll lose the game.) And if you click on 'Leave' in the middle of the game and call to leave after the game, you'll leave the room right after the game is over. This will be a much more useful way to leave.");
cm.dispose();
} else if (current == 2) { } else if (current == 2) {
cm.sendNextPrev("If you and your opponent have the same number of matched pairs, then whoever had a longer streak of matched pairs will win. If you ever feel the need to go to the bathroom, or take an extended break, you can request a #btie#k. The game will end in a tie if the opponent accepts the request. Tip: this may be a good way to keep your friendships in tact."); cm.sendNextPrev("If you and your opponent have the same number of matched pairs, then whoever had a longer streak of matched pairs will win. If you ever feel the need to go to the bathroom, or take an extended break, you can request a #btie#k. The game will end in a tie if the opponent accepts the request. Tip: this may be a good way to keep your friendships in tact.");
} }
} else if (status == 8) { } else if (status == 8) {
if (current == 2) { if (current == 2) {
cm.sendPrev("When the next game starts, the loser will go first. Also, no one is allowed to leave in the middle of a game. If you do, you may need to request either a #bforfeit or tie#k. (Of course, if you request a forfeit, you'll lose the game.) And if you click on 'Leave' in the middle of the game and call to leave after the game, you'll leave the room right after the game is over. This will be a much more useful way to leave."); cm.sendPrev("When the next game starts, the loser will go first. Also, no one is allowed to leave in the middle of a game. If you do, you may need to request either a #bforfeit or tie#k. (Of course, if you request a forfeit, you'll lose the game.) And if you click on 'Leave' in the middle of the game and call to leave after the game, you'll leave the room right after the game is over. This will be a much more useful way to leave.");
cm.dispose();
} }
} }
} }

View File

@@ -23,7 +23,12 @@ function action(mode, type, selection) {
} }
if (!cm.isEventLeader()) { if (!cm.isEventLeader()) {
cm.sendYesNo("I wish for your leader to talk to me. Alternatively, you may be wanting to quit. Are you going to abandon this campaign?"); // Player chose "No" or "End Chat"
if (mode <= 0) {
cm.dispose();
} else {
cm.sendYesNo("I wish for your leader to talk to me. Alternatively, you may be wanting to quit. Are you going to abandon this campaign?");
}
} else { } else {
var eim = cm.getEventInstance(); var eim = cm.getEventInstance();
if (eim == null) { if (eim == null) {

View File

@@ -195,7 +195,6 @@ public class ServerConfig {
public boolean USE_PERFECT_SCROLLING; public boolean USE_PERFECT_SCROLLING;
public boolean USE_ENHANCED_CHSCROLL; public boolean USE_ENHANCED_CHSCROLL;
public boolean USE_ENHANCED_CRAFTING; public boolean USE_ENHANCED_CRAFTING;
public boolean USE_ENHANCED_CLNSLATE;
public int SCROLL_CHANCE_ROLLS; public int SCROLL_CHANCE_ROLLS;
public int CHSCROLL_STAT_RATE; public int CHSCROLL_STAT_RATE;
public int CHSCROLL_STAT_RANGE; public int CHSCROLL_STAT_RANGE;

View File

@@ -22,6 +22,8 @@ public class ByteBufInPacket implements InPacket {
public byte readByte() { public byte readByte() {
return byteBuf.readByte(); return byteBuf.readByte();
} }
@Override
public short readUnsignedByte() { return byteBuf.readUnsignedByte(); }
@Override @Override
public short readShort() { public short readShort() {

View File

@@ -4,6 +4,7 @@ import java.awt.*;
public interface InPacket extends Packet { public interface InPacket extends Packet {
byte readByte(); byte readByte();
short readUnsignedByte();
short readShort(); short readShort();
int readInt(); int readInt();
long readLong(); long readLong();

View File

@@ -59,7 +59,7 @@ public final class NPCMoreTalkHandler extends AbstractPacketHandler {
if (p.available() >= 4) { if (p.available() >= 4) {
selection = p.readInt(); selection = p.readInt();
} else if (p.available() > 0) { } else if (p.available() > 0) {
selection = p.readByte(); selection = p.readUnsignedByte();
} }
if (c.getQM() != null) { if (c.getQM() != null) {
if (c.getQM().isStart()) { if (c.getQM().isStart()) {

View File

@@ -25,8 +25,12 @@ import client.Character;
import client.Client; import client.Client;
import client.Skill; import client.Skill;
import client.SkillFactory; import client.SkillFactory;
import client.inventory.*; import client.inventory.Equip;
import client.inventory.Equip.ScrollResult; import client.inventory.Equip.ScrollResult;
import client.inventory.Inventory;
import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.ModifyInventory;
import client.inventory.manipulator.InventoryManipulator; import client.inventory.manipulator.InventoryManipulator;
import constants.id.ItemId; import constants.id.ItemId;
import constants.inventory.ItemConstants; import constants.inventory.ItemConstants;
@@ -37,7 +41,6 @@ import tools.PacketCreator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author Matze * @author Matze
@@ -50,8 +53,8 @@ public final class ScrollHandler extends AbstractPacketHandler {
if (c.tryacquireClient()) { if (c.tryacquireClient()) {
try { try {
p.readInt(); // whatever... p.readInt(); // whatever...
short slot = p.readShort(); short scrollSlot = p.readShort();
short dst = p.readShort(); short equipSlot = p.readShort();
byte ws = (byte) p.readShort(); byte ws = (byte) p.readShort();
boolean whiteScroll = false; // white scroll being used? boolean whiteScroll = false; // white scroll being used?
boolean legendarySpirit = false; // legendary spirit skill boolean legendarySpirit = false; // legendary spirit skill
@@ -61,24 +64,21 @@ public final class ScrollHandler extends AbstractPacketHandler {
ItemInformationProvider ii = ItemInformationProvider.getInstance(); ItemInformationProvider ii = ItemInformationProvider.getInstance();
Character chr = c.getPlayer(); Character chr = c.getPlayer();
Equip toScroll = (Equip) chr.getInventory(InventoryType.EQUIPPED).getItem(dst); Equip toScroll = (Equip) chr.getInventory(InventoryType.EQUIPPED).getItem(equipSlot);
Skill LegendarySpirit = SkillFactory.getSkill(1003); Skill LegendarySpirit = SkillFactory.getSkill(1003);
if (chr.getSkillLevel(LegendarySpirit) > 0 && dst >= 0) { if (chr.getSkillLevel(LegendarySpirit) > 0 && equipSlot >= 0) {
legendarySpirit = true; legendarySpirit = true;
toScroll = (Equip) chr.getInventory(InventoryType.EQUIP).getItem(dst); toScroll = (Equip) chr.getInventory(InventoryType.EQUIP).getItem(equipSlot);
} }
byte oldLevel = toScroll.getLevel(); byte oldLevel = toScroll.getLevel();
byte oldSlots = toScroll.getUpgradeSlots(); byte oldSlots = toScroll.getUpgradeSlots();
Inventory useInventory = chr.getInventory(InventoryType.USE); Inventory useInventory = chr.getInventory(InventoryType.USE);
Item scroll = useInventory.getItem(slot); Item scroll = useInventory.getItem(scrollSlot);
Item wscroll = null; Item wscroll = null;
if (ItemConstants.isCleanSlate(scroll.getItemId())) { if (ItemConstants.isCleanSlate(scroll.getItemId()) && !ii.canUseCleanSlate(toScroll)) {
Map<String, Integer> eqStats = ii.getEquipStats(toScroll.getItemId()); // clean slate issue found thanks to Masterrulax announceCannotScroll(c, legendarySpirit);
if (eqStats == null || eqStats.get("tuc") == 0) { return;
announceCannotScroll(c, legendarySpirit);
return;
}
} else if (!ItemConstants.isModifierScroll(scroll.getItemId()) && toScroll.getUpgradeSlots() < 1) { } else if (!ItemConstants.isModifierScroll(scroll.getItemId()) && toScroll.getUpgradeSlots() < 1) {
announceCannotScroll(c, legendarySpirit); // thanks onechord for noticing zero upgrade slots freezing Legendary Scroll UI announceCannotScroll(c, legendarySpirit); // thanks onechord for noticing zero upgrade slots freezing Legendary Scroll UI
return; return;
@@ -103,11 +103,6 @@ public final class ScrollHandler extends AbstractPacketHandler {
} }
} }
if (ItemConstants.isCleanSlate(scroll.getItemId()) && !ii.canUseCleanSlate(toScroll)) {
announceCannotScroll(c, legendarySpirit);
return;
}
Equip scrolled = (Equip) ii.scrollEquipWithId(toScroll, scroll.getItemId(), whiteScroll, 0, chr.isGM()); Equip scrolled = (Equip) ii.scrollEquipWithId(toScroll, scroll.getItemId(), whiteScroll, 0, chr.isGM());
ScrollResult scrollSuccess = Equip.ScrollResult.FAIL; // fail ScrollResult scrollSuccess = Equip.ScrollResult.FAIL; // fail
if (scrolled == null) { if (scrolled == null) {
@@ -141,7 +136,7 @@ public final class ScrollHandler extends AbstractPacketHandler {
if (scrollSuccess == Equip.ScrollResult.CURSE) { if (scrollSuccess == Equip.ScrollResult.CURSE) {
if (!ItemId.isWeddingRing(toScroll.getItemId())) { if (!ItemId.isWeddingRing(toScroll.getItemId())) {
mods.add(new ModifyInventory(3, toScroll)); mods.add(new ModifyInventory(3, toScroll));
if (dst < 0) { if (equipSlot < 0) {
Inventory inv = chr.getInventory(InventoryType.EQUIPPED); Inventory inv = chr.getInventory(InventoryType.EQUIPPED);
inv.lockInventory(); inv.lockInventory();
@@ -174,7 +169,7 @@ public final class ScrollHandler extends AbstractPacketHandler {
} }
c.sendPacket(PacketCreator.modifyInventory(true, mods)); c.sendPacket(PacketCreator.modifyInventory(true, mods));
chr.getMap().broadcastMessage(PacketCreator.getScrollEffect(chr.getId(), scrollSuccess, legendarySpirit, whiteScroll)); chr.getMap().broadcastMessage(PacketCreator.getScrollEffect(chr.getId(), scrollSuccess, legendarySpirit, whiteScroll));
if (dst < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) { if (equipSlot < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) {
chr.equipChanged(); chr.equipChanged();
} }
} finally { } finally {

View File

@@ -228,10 +228,10 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
return; return;
} }
short flag = eq.getFlag(); short flag = eq.getFlag();
flag |= ItemConstants.LOCK; if (eq.getExpiration() > -1 && (eq.getFlag() & ItemConstants.LOCK) != ItemConstants.LOCK) {
if (eq.getExpiration() > -1) {
return; //No perma items pls return; //No perma items pls
} }
flag |= ItemConstants.LOCK;
eq.setFlag(flag); eq.setFlag(flag);
long period = 0; long period = 0;
@@ -246,7 +246,8 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
} }
if (period > 0) { if (period > 0) {
eq.setExpiration(currentServerTime() + DAYS.toMillis(period)); long expiration = eq.getExpiration() > -1 ? eq.getExpiration() : currentServerTime();
eq.setExpiration(expiration + DAYS.toMillis(period));
} }
// double-remove found thanks to BHB // double-remove found thanks to BHB

View File

@@ -22,9 +22,16 @@
package server; package server;
import client.Character; import client.Character;
import client.*; import client.Client;
import client.Job;
import client.Skill;
import client.SkillFactory;
import client.autoban.AutobanFactory; import client.autoban.AutobanFactory;
import client.inventory.*; import client.inventory.Equip;
import client.inventory.Inventory;
import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.WeaponType;
import config.YamlConfig; import config.YamlConfig;
import constants.id.ItemId; import constants.id.ItemId;
import constants.inventory.EquipSlot; import constants.inventory.EquipSlot;
@@ -35,19 +42,36 @@ import constants.skills.NightWalker;
import net.server.Server; import net.server.Server;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import provider.*; import provider.Data;
import provider.DataDirectoryEntry;
import provider.DataFileEntry;
import provider.DataProvider;
import provider.DataProviderFactory;
import provider.DataTool;
import provider.wz.WZFiles; import provider.wz.WZFiles;
import server.MakerItemFactory.MakerItemCreateEntry; import server.MakerItemFactory.MakerItemCreateEntry;
import server.life.LifeFactory; import server.life.LifeFactory;
import server.life.MonsterInformationProvider; import server.life.MonsterInformationProvider;
import tools.*; import tools.DatabaseConnection;
import tools.PacketCreator;
import tools.Pair;
import tools.Randomizer;
import tools.StringUtil;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
/** /**
* @author Matze * @author Matze
@@ -1025,9 +1049,16 @@ public class ItemInformationProvider {
Issue with clean slate found thanks to Masterrulax Issue with clean slate found thanks to Masterrulax
Vicious added in the clean slate check thanks to Crypter (CrypterDEV) Vicious added in the clean slate check thanks to Crypter (CrypterDEV)
*/ */
public boolean canUseCleanSlate(Equip nEquip) { public boolean canUseCleanSlate(Equip equip) {
Map<String, Integer> eqstats = this.getEquipStats(nEquip.getItemId()); Map<String, Integer> eqStats = getEquipStats(equip.getItemId());
return YamlConfig.config.server.USE_ENHANCED_CLNSLATE || nEquip.getUpgradeSlots() < (byte) (eqstats.get("tuc") + nEquip.getVicious()); if (eqStats == null || eqStats.get("tuc") == 0 ) {
return false;
}
int totalUpgradeCount = eqStats.get("tuc");
int freeUpgradeCount = equip.getUpgradeSlots();
int viciousCount = equip.getVicious();
int appliedScrollCount = equip.getLevel();
return freeUpgradeCount + appliedScrollCount < totalUpgradeCount + viciousCount;
} }
public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, int vegaItemId, boolean isGM) { public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, int vegaItemId, boolean isGM) {

View File

@@ -38,6 +38,36 @@ class ByteBufInPacketTest {
assertEquals(writtenByte, readByte); assertEquals(writtenByte, readByte);
} }
@Test
void readUnsignedByte() {
final byte writtenByte = Byte.MAX_VALUE;
byteBuf.writeByte(writtenByte);
short readUnsignedByte = inPacket.readUnsignedByte();
assertEquals(writtenByte, readUnsignedByte);
}
@Test
void readUnsignedByte_shouldBeNonnegative() {
final byte writtenByte = Byte.MIN_VALUE;
byteBuf.writeByte(writtenByte);
short readUnsignedByte = inPacket.readUnsignedByte();
assertEquals((short)writtenByte + 256, readUnsignedByte);
}
@Test
void readUnsignedByte_shouldBeNonnegative2() {
final byte writtenByte = -1;
byteBuf.writeByte(writtenByte);
short readUnsignedByte = inPacket.readUnsignedByte();
assertEquals((short)writtenByte + 256, readUnsignedByte);
}
@Test @Test
void readShort() { void readShort() {
final short writtenShort = 12_345; final short writtenShort = 12_345;