Revert "owner_id" being used instead of "user_id" in bots manager.

Fixed duplicate packet id in outgoing.
This commit is contained in:
Harmonic 2024-01-13 01:53:16 +00:00
parent 0ab52d40af
commit 03f25c79f9
6 changed files with 9 additions and 9 deletions

View File

@ -71,10 +71,10 @@ public class Bot extends Avatar implements Runnable {
this.gender = HabboGender.valueOf(set.getString("gender"));
//@Deprecated
this.ownerId = set.getInt("owner_id");
this.ownerId = set.getInt("user_id");
this.ownerName = set.getString("owner_name");
this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt("owner_id"));
this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt("user_id"));
this.chatAuto = set.getString("chat_auto").equals("1");
this.chatRandom = set.getString("chat_random").equals("1");
@ -99,7 +99,7 @@ public class Bot extends Avatar implements Runnable {
@Override
public void run() {
if (this.sqlUpdateNeeded) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, owner_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ?, x = ?, y = ?, z = ? WHERE id = ?")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ?, x = ?, y = ?, z = ? WHERE id = ?")) {
statement.setString(1, this.name);
statement.setString(2, this.motto);
statement.setString(3, this.figure);

View File

@ -61,7 +61,7 @@ public class BotManager {
public Bot createBot(THashMap<String, String> data, String type) {
Bot bot = null;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, data.get("name"));
statement.setString(2, data.get("motto"));
statement.setString(3, data.get("figure"));
@ -70,7 +70,7 @@ public class BotManager {
statement.execute();
try (ResultSet set = statement.getGeneratedKeys()) {
if (set.next()) {
try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.owner_id = users.id WHERE bots.id = ? LIMIT 1")) {
try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.user_id = users.id WHERE bots.id = ? LIMIT 1")) {
stmt.setInt(1, set.getInt(1));
try (ResultSet resultSet = stmt.executeQuery()) {
if (resultSet.next()) {

View File

@ -189,7 +189,7 @@ public class RoomBundleLayout extends SingleBundle {
}
if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
synchronized (this.room.getRoomUnitManager().getRoomBotManager().getCurrentBots()) {
statement.setInt(1, userId);
statement.setInt(2, roomId);

View File

@ -57,7 +57,7 @@ public class RoomBotManager extends RoomUnitSubManager {
public synchronized void loadBots(Connection connection) {
this.currentBots.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.owner_id = users.id WHERE room_id = ?")) {
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.user_id = users.id WHERE room_id = ?")) {
statement.setInt(1, this.room.getRoomInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {

View File

@ -25,7 +25,7 @@ public class BotsComponent {
private void loadBots(Habbo habbo) {
synchronized (this.bots) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON users.id = bots.owner_id WHERE owner_id = ? AND room_id = 0 ORDER BY id ASC")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON users.id = bots.user_id WHERE user_id = ? AND room_id = 0 ORDER BY id ASC")) {
statement.setInt(1, habbo.getHabboInfo().getId());
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {

View File

@ -154,7 +154,7 @@ public class Outgoing {
public static final int game2GameDirectoryStatusMessageComposer = 2246; //todo?
public static final int game2InArenaQueueMessageComposer = 872;//todo?
public static final int game2JoiningGameFailedMessageComposer = 1730; // todo?
public static final int game2StopCounterMessageComposer = 2233; //todo?
public static final int game2StopCounterMessageComposer = -1; //todo?
public static final int game2UserLeftGameMessageComposer = 2383;//todo?
public static final int game2WeeklyFriendsLeaderboardComposer = 2270;//todo?
public static final int game2WeeklyLeaderboardComposer = 2196; //todo?