Cleaned up legacy save code

This commit is contained in:
Player Name
2025-02-03 00:48:51 +00:00
committed by Ryan
parent acc6c182a5
commit c03947e0b0
23 changed files with 53 additions and 708 deletions
@@ -20,7 +20,6 @@ import core.game.world.GameWorld;
import org.rs09.consts.Sounds;
import java.awt.*;
import java.nio.ByteBuffer;
import static core.api.ContentAPIKt.*;
import static core.api.regionspec.RegionSpecificationKt.fillWith;
@@ -99,36 +98,6 @@ public final class HouseManager {
}
public void save(ByteBuffer buffer) {
buffer.put((byte) location.ordinal());
buffer.put((byte) style.ordinal());
if (hasServant()) {
servant.save(buffer);
} else {
buffer.put((byte) -1);
}
for (int z = 0; z < 4; z++) {
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
Room room = rooms[z][x][y];
if (room != null) {
buffer.put((byte) z).put((byte) x).put((byte) y);
buffer.put((byte) room.getProperties().ordinal());
buffer.put((byte) room.getRotation().toInteger());
for (int i = 0; i < room.getHotspots().length; i++) {
if (room.getHotspots()[i].getDecorationIndex() > -1) {
buffer.put((byte) i);
buffer.put((byte) room.getHotspots()[i].getDecorationIndex());
}
}
buffer.put((byte) -1);
}
}
}
}
buffer.put((byte) -1);//Eof
}
public void parse(JSONObject data){
location = HouseLocation.values()[Integer.parseInt( data.get("location").toString())];
style = HousingStyle.values()[Integer.parseInt( data.get("style").toString())];
@@ -155,28 +124,6 @@ public final class HouseManager {
}
}
public void parse(ByteBuffer buffer) {
location = HouseLocation.values()[buffer.get() & 0xFF];
style = HousingStyle.values()[buffer.get() & 0xFF];
servant = Servant.parse(buffer);
int z = 0;
while ((z = buffer.get()) != -1) {
if (z == 3) {
hasDungeon = true;
}
int x = buffer.get();
int y = buffer.get();
Room room = rooms[z][x][y] = new Room(RoomProperties.values()[buffer.get() & 0xFF]);
room.configure(style);
room.setRotation(Direction.get(buffer.get() & 0xFF));
int spot = 0;
while ((spot = buffer.get()) != -1) {
room.getHotspots()[spot].setDecorationIndex(buffer.get() & 0xFF);
}
}
}
/**
* Prepares for entering the player's house.
* @param player
@@ -5,8 +5,6 @@ import core.game.node.entity.npc.NPC;
import core.game.node.item.Item;
import org.json.simple.JSONObject;
import java.nio.ByteBuffer;
/**
* Represents a player's servant.
* @author Emperor
@@ -44,26 +42,9 @@ public final class Servant extends NPC {
}
/**
* Saves the servant details.
* @param buffer The buffer to write on.
*/
public void save(ByteBuffer buffer) {
buffer.put((byte) type.ordinal());
buffer.putShort((byte) uses);
if (item == null) {
buffer.putShort((short) -1);
} else {
buffer.putShort((short) item.getId());
buffer.putInt(item.getAmount());
}
buffer.put((byte) (greet ? 1 : 0));
}
/**
* Parses the servant from the buffer.
* Parses the servant from the save file.
* @return The servant.
*/
public static Servant parse(JSONObject data){
int type = Integer.parseInt( data.get("type").toString());
Servant servant = new Servant(ServantType.values()[type]);
@@ -77,21 +58,6 @@ public final class Servant extends NPC {
return servant;
}
public static Servant parse(ByteBuffer buffer) {
int type = buffer.get();
if (type == -1) {
return null;
}
Servant servant = new Servant(ServantType.values()[type]);
servant.uses = buffer.getShort() & 0xFFFF;
int itemId = buffer.getShort() & 0xFFFF;
if ((short) itemId != -1) {
servant.item = new Item(itemId, buffer.getInt());
}
servant.greet = buffer.get() == 1;
return servant;
}
/**
* Gets the item value.
* @return The item.
@@ -11,6 +11,7 @@ import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.entity.skill.Skills
import content.data.skill.SkillingTool
import content.global.activity.shootingstar.StarBonus
import content.global.skill.skillcapeperks.SkillcapePerks
import core.game.node.item.ChanceItem
import core.game.node.scenery.Scenery
@@ -224,7 +225,7 @@ class MiningSkillPulse(private val player: Player, private val node: Node) : Pul
}
// If player has mining boost from Shooting Star, roll chance at extra ore
if (player.hasActiveState("shooting-star")) {
if (hasTimerActive<StarBonus>(player)) {
if (RandomFunction.getRandom(5) == 3) {
sendMessage(player, "...you manage to mine a second ore thanks to the Star Sprite.")
amount += 1