3.5.4 commit for some bug fixes

This commit is contained in:
ArpyAge 2024-04-03 17:57:50 +02:00
parent 2e576809e0
commit dfb97f37e9
16 changed files with 70 additions and 24 deletions

View File

@ -16,7 +16,7 @@ Arcturus Morningstar is as a fork of Arcturus Emulator by TheGeneral. Arcturus M
[![image](https://img.shields.io/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=KREWS&logoColor=fff)](https://discord.gg/BzfFsTp) [![image](https://img.shields.io/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=KREWS&logoColor=fff)](https://discord.gg/BzfFsTp)
## Download ## ## Download ##
[![image](https://img.shields.io/badge/STABLE%20RELEASES-3.5.3-success.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/releases) [![image](https://img.shields.io/badge/STABLE%20RELEASES-3.5.4-success.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/releases)
[![image](https://img.shields.io/badge/DEVELOPER%20BUILDS-4.0-red.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/jobs) * [![image](https://img.shields.io/badge/DEVELOPER%20BUILDS-4.0-red.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/jobs) *

View File

@ -6,7 +6,7 @@
<groupId>com.eu.habbo</groupId> <groupId>com.eu.habbo</groupId>
<artifactId>Habbo</artifactId> <artifactId>Habbo</artifactId>
<version>3.5.3</version> <version>3.5.4</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -37,7 +37,7 @@ public final class Emulator {
public final static int MAJOR = 3; public final static int MAJOR = 3;
public final static int MINOR = 5; public final static int MINOR = 5;
public final static int BUILD = 3; public final static int BUILD = 4;
public final static String PREVIEW = ""; public final static String PREVIEW = "";
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW; public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
@ -49,7 +49,7 @@ public final class Emulator {
"██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" + "██║╚██╔╝██║██║ ██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║╚════██║ ██║ ██╔══██║██╔══██╗\n" +
"██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" + "██║ ╚═╝ ██║╚██████╔╝██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝███████║ ██║ ██║ ██║██║ ██║\n" +
"╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" + "╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝\n" +
"Still Rocking in 2023.\n"; "Still Rocking in 2024.\n";
public static String build = ""; public static String build = "";
public static boolean isReady = false; public static boolean isReady = false;

View File

@ -902,7 +902,9 @@ public class CatalogManager {
boolean badgeFound = false; boolean badgeFound = false;
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
if(item.isLimited()) {
habbo.getHabboStats().addLtdLog(item.getId(), Emulator.getIntUnixTimestamp()); habbo.getHabboStats().addLtdLog(item.getId(), Emulator.getIntUnixTimestamp());
}
for (Item baseItem : item.getBaseItems()) { for (Item baseItem : item.getBaseItems()) {
for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) { for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) {

View File

@ -62,7 +62,7 @@ public class CommandHandler {
public static boolean handleCommand(GameClient gameClient, String commandLine) { public static boolean handleCommand(GameClient gameClient, String commandLine) {
if (gameClient != null) { if (gameClient != null && commandLine != null) {
if (commandLine.startsWith(":")) { if (commandLine.startsWith(":")) {
commandLine = commandLine.replaceFirst(":", ""); commandLine = commandLine.replaceFirst(":", "");

View File

@ -16,11 +16,12 @@ 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.HashMap;
public abstract class InteractionWired extends InteractionDefault { public abstract class InteractionWired extends InteractionDefault {
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class); private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class);
private long cooldown; private long cooldown;
private TLongLongHashMap userExecutionCache = new TLongLongHashMap(3); private final HashMap<Long,Long> userExecutionCache = new HashMap<>();
InteractionWired(ResultSet set, Item baseItem) throws SQLException { InteractionWired(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem); super(set, baseItem);
@ -76,8 +77,10 @@ public abstract class InteractionWired extends InteractionDefault {
} }
public void activateBox(Room room, RoomUnit roomUnit, long millis) { public void activateBox(Room room, RoomUnit roomUnit, long millis) {
if(!room.isHideWired()) {
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1"); this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
room.sendComposer(new ItemStateComposer(this).compose()); room.sendComposer(new ItemStateComposer(this).compose());
}
if (roomUnit != null) { if (roomUnit != null) {
this.addUserExecutionCache(roomUnit.getId(), millis); this.addUserExecutionCache(roomUnit.getId(), millis);
} }
@ -112,7 +115,7 @@ public abstract class InteractionWired extends InteractionDefault {
} else { } else {
if (this.userExecutionCache.containsKey((long)roomUnitId)) { if (this.userExecutionCache.containsKey((long)roomUnitId)) {
long lastTimestamp = this.userExecutionCache.get((long)roomUnitId); long lastTimestamp = this.userExecutionCache.get((long)roomUnitId);
if (timestamp - lastTimestamp < 100L) { if (timestamp - lastTimestamp < Math.max(100L, this.requiredCooldown())) {
return false; return false;
} }
} }

View File

@ -125,10 +125,16 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
@Override @Override
public void cycle(Room room) { public void cycle(Room room) {
this.counter += 500; this.counter += 500;
if (this.counter >= this.repeatTime) { long currentMillis = System.currentTimeMillis();
String Key = Double.toString(this.getX()) + Double.toString(this.getY());
room.repeatersLastTick.putIfAbsent(Key, currentMillis);
if (this.counter >= this.repeatTime && room.repeatersLastTick.get(Key) < currentMillis - 450) {
this.counter = 0; this.counter = 0;
if (this.getRoomId() != 0) { if (this.getRoomId() != 0) {
if (room.isLoaded()) { if (room.isLoaded()) {
room.repeatersLastTick.put(Key, currentMillis);
WiredHandler.handle(this, null, room, new Object[]{this}); WiredHandler.handle(this, null, room, new Object[]{this});
} }
} }

View File

@ -119,10 +119,16 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
@Override @Override
public void cycle(Room room) { public void cycle(Room room) {
this.counter += 500; this.counter += 500;
if (this.counter >= this.repeatTime) { long currentMillis = System.currentTimeMillis();
String Key = Double.toString(this.getX()) + Double.toString(this.getY());
room.repeatersLastTick.putIfAbsent(Key, currentMillis);
if (this.counter >= this.repeatTime && room.repeatersLastTick.get(Key) < currentMillis - 4950) {
this.counter = 0; this.counter = 0;
if (this.getRoomId() != 0) { if (this.getRoomId() != 0) {
if (room.isLoaded()) { if (room.isLoaded()) {
room.repeatersLastTick.put(Key, currentMillis);
WiredHandler.handle(this, null, room, new Object[]{this}); WiredHandler.handle(this, null, room, new Object[]{this});
} }
} }

View File

@ -194,6 +194,10 @@ public class WordFilter {
} }
} }
public THashSet<WordFilterWord> getWords() {
return new THashSet<>(this.words);
}
public void addWord(WordFilterWord word) { public void addWord(WordFilterWord word) {
this.words.add(word); this.words.add(word);
} }

View File

@ -213,6 +213,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
private TraxManager traxManager; private TraxManager traxManager;
private boolean cycleOdd; private boolean cycleOdd;
private long cycleTimestamp; private long cycleTimestamp;
public Map<String, Long> repeatersLastTick = new HashMap<>();
public Room(ResultSet set) throws SQLException { public Room(ResultSet set) throws SQLException {
this.id = set.getInt("id"); this.id = set.getInt("id");

View File

@ -294,6 +294,10 @@ public class RoomManager {
public Room loadRoom(int id, boolean loadData) { public Room loadRoom(int id, boolean loadData) {
Room room = null; Room room = null;
if(id == 0) {
return null;
}
if (this.activeRooms.containsKey(id)) { if (this.activeRooms.containsKey(id)) {
room = this.activeRooms.get(id); room = this.activeRooms.get(id);
@ -414,7 +418,7 @@ public class RoomManager {
public RoomLayout loadLayout(String name, Room room) { public RoomLayout loadLayout(String name, Room room) {
RoomLayout layout = null; RoomLayout layout = null;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models WHERE name LIKE ? LIMIT 1")) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_models WHERE name = ? LIMIT 1")) {
statement.setString(1, name); statement.setString(1, name);
try (ResultSet set = statement.executeQuery()) { try (ResultSet set = statement.executeQuery()) {
if (set.next()) { if (set.next()) {

View File

@ -448,17 +448,22 @@ public class Habbo implements Runnable {
} }
public void clearCaches() { public void clearCaches() {
int timestamp = Emulator.getIntUnixTimestamp(); int currentTimestamp = Emulator.getIntUnixTimestamp();
int twentyFourHoursInSeconds = 24 * 60 * 60; // 24 hours in seconds
THashMap<Integer, List<Integer>> newLog = new THashMap<>(); THashMap<Integer, List<Integer>> newLog = new THashMap<>();
for (Map.Entry<Integer, List<Integer>> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) { for (Map.Entry<Integer, List<Integer>> ltdLog : this.habboStats.ltdPurchaseLog.entrySet()) {
List<Integer> filteredTimestamps = new ArrayList<>();
for (Integer time : ltdLog.getValue()) { for (Integer time : ltdLog.getValue()) {
if (time > timestamp) { if (currentTimestamp - time <= twentyFourHoursInSeconds) {
if (!newLog.containsKey(ltdLog.getKey())) { filteredTimestamps.add(time);
newLog.put(ltdLog.getKey(), new ArrayList<>()); }
} }
newLog.get(ltdLog.getKey()).add(time); if (!filteredTimestamps.isEmpty()) {
} newLog.put(ltdLog.getKey(), filteredTimestamps);
} }
} }

View File

@ -102,7 +102,7 @@ public class HabboStats implements Runnable {
public THashSet<Subscription> subscriptions; public THashSet<Subscription> subscriptions;
private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException { private HabboStats(ResultSet set, HabboInfo habboInfo) throws SQLException {
this.cache = new THashMap<>(0); this.cache = new THashMap<>(1000);
this.achievementProgress = new THashMap<>(0); this.achievementProgress = new THashMap<>(0);
this.achievementCache = new THashMap<>(0); this.achievementCache = new THashMap<>(0);
this.recentPurchases = new THashMap<>(0); this.recentPurchases = new THashMap<>(0);

View File

@ -234,7 +234,7 @@ public class WiredHandler {
executed = true; executed = true;
if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) {
Emulator.getThreading().run(() -> { Emulator.getThreading().run(() -> {
if (room.isLoaded()) { if (room.isLoaded() && room.getHabbos().size() > 0) {
try { try {
if (!effect.execute(roomUnit, room, stuff)) return; if (!effect.execute(roomUnit, room, stuff)) return;
effect.setCooldown(millis); effect.setCooldown(millis);

View File

@ -154,6 +154,18 @@ public class WiredHighscoreManager {
return false; return false;
} }
public HashMap<Integer, List<WiredHighscoreDataEntry>> getData() {
return this.data;
}
public List<WiredHighscoreDataEntry> getEntriesForItemId(int itemId) {
return this.data.get(itemId);
}
public void setEntriesForItemId(int itemId, List<WiredHighscoreDataEntry> entries) {
this.data.put(itemId, entries);
}
private long getTodayStartTimestamp() { private long getTodayStartTimestamp() {
return LocalDateTime.now().with(LocalTime.MIDNIGHT).atZone(zoneId).toEpochSecond(); return LocalDateTime.now().with(LocalTime.MIDNIGHT).atZone(zoneId).toEpochSecond();
} }

View File

@ -8,6 +8,8 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.Outgoing;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
import java.util.Objects;
public class UpdateStackHeightComposer extends MessageComposer { public class UpdateStackHeightComposer extends MessageComposer {
private int x; private int x;
private int y; private int y;
@ -34,6 +36,7 @@ public class UpdateStackHeightComposer extends MessageComposer {
//TODO: maybe do this another way? doesn't seem to be very clean but gets the job done //TODO: maybe do this another way? doesn't seem to be very clean but gets the job done
this.response.init(Outgoing.UpdateStackHeightComposer); this.response.init(Outgoing.UpdateStackHeightComposer);
if (this.updateTiles != null) { if (this.updateTiles != null) {
this.updateTiles.removeIf(Objects::isNull);
// prevent overflow. Byte max value is 127 // prevent overflow. Byte max value is 127
if(this.updateTiles.size() > 127) { if(this.updateTiles.size() > 127) {
RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]); RoomTile[] tiles = this.updateTiles.toArray(new RoomTile[updateTiles.size()]);