mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Revert "Started fixing teleporters - credits to quadral"
This reverts commit d77d18b27f
This commit is contained in:
parent
2d83bca513
commit
ca54316715
@ -37,7 +37,7 @@ public final class Emulator {
|
|||||||
public final static int BUILD = 0;
|
public final static int BUILD = 0;
|
||||||
|
|
||||||
|
|
||||||
public final static String PREVIEW = "RC-3";
|
public final static String PREVIEW = "RC-2";
|
||||||
|
|
||||||
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
|
public static final String version = "Arcturus Morningstar" + " " + MAJOR + "." + MINOR + "." + BUILD + " " + PREVIEW;
|
||||||
private static final String logo =
|
private static final String logo =
|
||||||
@ -49,7 +49,7 @@ public final class Emulator {
|
|||||||
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
|
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
|
||||||
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
|
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
|
||||||
" /____/ \n" +
|
" /____/ \n" +
|
||||||
" 'the only emulator with broken teleporters' \n" ;
|
" 'RC Stands for Race Car.' \n" ;
|
||||||
public static String build = "";
|
public static String build = "";
|
||||||
public static boolean isReady = false;
|
public static boolean isReady = false;
|
||||||
public static boolean isShuttingDown = false;
|
public static boolean isShuttingDown = false;
|
||||||
|
@ -1,22 +1,3 @@
|
|||||||
/*
|
|
||||||
* Morning Star
|
|
||||||
* Copyright (C) 2019
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.eu.habbo.habbohotel.gameclients;
|
package com.eu.habbo.habbohotel.gameclients;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
@ -35,134 +16,114 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class GameClient
|
public class GameClient {
|
||||||
{
|
|
||||||
/// Constructor
|
public final ConcurrentHashMap<Integer, Integer> incomingPacketCounter = new ConcurrentHashMap<>(25);
|
||||||
/// @p_Channel : Channel
|
private final Channel channel;
|
||||||
public GameClient(Channel p_Channel) {
|
public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp();
|
||||||
this.m_Channel = p_Channel;
|
private Habbo habbo;
|
||||||
|
private String machineId = "";
|
||||||
|
|
||||||
|
public GameClient(Channel channel) {
|
||||||
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Composer class - Abstract class
|
public void sendResponse(MessageComposer composer) {
|
||||||
/// @p_Composer : Composer
|
if (this.channel.isOpen()) {
|
||||||
public void sendResponse(MessageComposer p_Composer) {
|
try {
|
||||||
if (this.m_Channel.isOpen())
|
ServerMessage msg = composer.compose();
|
||||||
{
|
this.sendResponse(msg);
|
||||||
try
|
} catch (Exception e) {
|
||||||
{
|
Emulator.getLogging().logPacketError(e);
|
||||||
ServerMessage l_ServerMessage = p_Composer.compose();
|
|
||||||
this.sendResponse(l_ServerMessage);
|
|
||||||
|
|
||||||
} catch (Exception l_Exception)
|
|
||||||
{
|
|
||||||
Emulator.getLogging().logPacketError(l_Exception);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send Raw Response
|
|
||||||
/// @p_Response : Response
|
public void sendResponse(ServerMessage response) {
|
||||||
public void sendResponse(ServerMessage p_Response)
|
if (this.channel.isOpen()) {
|
||||||
{
|
if (response == null || response.getHeader() <= 0) {
|
||||||
if (this.m_Channel.isOpen())
|
|
||||||
{
|
|
||||||
if (p_Response == null || p_Response.getHeader() <= 0)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PacketManager.DEBUG_SHOW_PACKETS)
|
if (PacketManager.DEBUG_SHOW_PACKETS)
|
||||||
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + p_Response.getHeader() + "] -> " + p_Response.getBodyString());
|
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString());
|
||||||
|
|
||||||
this.m_Channel.write(p_Response.get(), this.m_Channel.voidPromise());
|
this.channel.write(response.get(), this.channel.voidPromise());
|
||||||
this.m_Channel.flush();
|
this.channel.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send packed response
|
|
||||||
/// @p_Responses : Response Array
|
|
||||||
public void sendResponses(ArrayList<ServerMessage> p_Responses)
|
|
||||||
{
|
|
||||||
ByteBuf l_Buffer = Unpooled.buffer();
|
|
||||||
|
|
||||||
if (this.m_Channel.isOpen()) {
|
public void sendResponses(ArrayList<ServerMessage> responses) {
|
||||||
for (ServerMessage l_Itr : p_Responses)
|
ByteBuf buffer = Unpooled.buffer();
|
||||||
{
|
|
||||||
if (l_Itr == null || l_Itr.getHeader() <= 0) {
|
if (this.channel.isOpen()) {
|
||||||
|
for (ServerMessage response : responses) {
|
||||||
|
if (response == null || response.getHeader() <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PacketManager.DEBUG_SHOW_PACKETS)
|
if (PacketManager.DEBUG_SHOW_PACKETS)
|
||||||
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + l_Itr.getHeader() + "] -> " + l_Itr.getBodyString());
|
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_PURPLE + "SERVER" + Logging.ANSI_RESET + "] => [" + response.getHeader() + "] -> " + response.getBodyString());
|
||||||
|
|
||||||
l_Buffer.writeBytes(l_Itr.get());
|
buffer.writeBytes(response.get());
|
||||||
}
|
}
|
||||||
this.m_Channel.write(l_Buffer.copy(), this.m_Channel.voidPromise());
|
this.channel.write(buffer.copy(), this.channel.voidPromise());
|
||||||
this.m_Channel.flush();
|
this.channel.flush();
|
||||||
}
|
}
|
||||||
l_Buffer.release();
|
buffer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dispose Habbo
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
try {
|
||||||
|
this.channel.close();
|
||||||
|
|
||||||
try
|
if (this.habbo != null) {
|
||||||
{
|
if (this.habbo.isOnline()) {
|
||||||
this.m_Channel.close();
|
this.habbo.getHabboInfo().setOnline(false);
|
||||||
|
this.habbo.disconnect();
|
||||||
if (this.m_Habbo != null) {
|
|
||||||
if (this.m_Habbo.isOnline())
|
|
||||||
{
|
|
||||||
this.m_Habbo.getHabboInfo().setOnline(false);
|
|
||||||
this.m_Habbo.disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.m_Habbo = null;
|
this.habbo = null;
|
||||||
}
|
}
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
Emulator.getLogging().logErrorLine(e);
|
Emulator.getLogging().logErrorLine(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////
|
public Channel getChannel() {
|
||||||
// GETTERS/SETTERS
|
return this.channel;
|
||||||
///////////////////////////////////////////
|
}
|
||||||
|
|
||||||
public Channel getChannel() { return this.m_Channel; }
|
public Habbo getHabbo() {
|
||||||
public String getMachineId() { return this.m_MachineId; }
|
return this.habbo;
|
||||||
public Habbo getHabbo() { return this.m_Habbo; }
|
}
|
||||||
|
|
||||||
public void setHabbo(Habbo p_Habbo) { this.m_Habbo = p_Habbo; }
|
public void setHabbo(Habbo habbo) {
|
||||||
public void setMachineId(String p_MachineId)
|
this.habbo = habbo;
|
||||||
{
|
}
|
||||||
if (p_MachineId == null)
|
|
||||||
{
|
public String getMachineId() {
|
||||||
|
return this.machineId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMachineId(String machineId) {
|
||||||
|
if (machineId == null) {
|
||||||
throw new RuntimeException("Cannot set machineID to NULL");
|
throw new RuntimeException("Cannot set machineID to NULL");
|
||||||
}
|
}
|
||||||
this.m_MachineId = p_MachineId;
|
this.machineId = machineId;
|
||||||
|
|
||||||
if (this.m_MachineId != null)
|
if (this.habbo != null) {
|
||||||
{
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET machine_id = ? WHERE id = ? LIMIT 1")) {
|
||||||
statement.setString(1, this.m_MachineId);
|
statement.setString(1, this.machineId);
|
||||||
statement.setInt(2, this.m_Habbo.getHabboInfo().getId());
|
statement.setInt(2, this.habbo.getHabboInfo().getId());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
Emulator.getLogging().logSQLException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public final ConcurrentHashMap<Integer, Integer> incomingPacketCounter = new ConcurrentHashMap<>(25);
|
|
||||||
public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp();
|
|
||||||
|
|
||||||
private final Channel m_Channel;
|
|
||||||
private Habbo m_Habbo;
|
|
||||||
private String m_MachineId;
|
|
||||||
}
|
}
|
@ -17,8 +17,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/// how u find files? where is file search bar on this ide
|
|
||||||
public class InteractionTeleport extends HabboItem {
|
public class InteractionTeleport extends HabboItem {
|
||||||
private int targetId;
|
private int targetId;
|
||||||
private int targetRoomId;
|
private int targetRoomId;
|
||||||
@ -64,37 +62,27 @@ public class InteractionTeleport extends HabboItem {
|
|||||||
|
|
||||||
Habbo habbo = client.getHabbo();
|
Habbo habbo = client.getHabbo();
|
||||||
|
|
||||||
/// Habbo must exist
|
|
||||||
if (habbo == null)
|
if (habbo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/// Get Unit of habbo (extension class)
|
|
||||||
RoomUnit unit = habbo.getRoomUnit();
|
RoomUnit unit = habbo.getRoomUnit();
|
||||||
|
|
||||||
/// Unit must exit - this should be logged as this should never happen
|
|
||||||
if (unit == null)
|
if (unit == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/// Get current tile habbo is standing on
|
|
||||||
RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY());
|
RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY());
|
||||||
|
|
||||||
/// dont proceed is our current tile is null - this should never happen
|
|
||||||
if (currentLocation == null)
|
if (currentLocation == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/// Get the tile infront
|
|
||||||
RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation());
|
RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation());
|
||||||
|
|
||||||
/// Check whether we can use the teleport
|
|
||||||
if (!canUseTeleport(client, room))
|
if (!canUseTeleport(client, room))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation))
|
if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
|
||||||
{
|
|
||||||
startTeleport(room, habbo);
|
startTeleport(room, habbo);
|
||||||
|
} else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
|
||||||
} else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile))
|
|
||||||
{
|
|
||||||
// set state 1 and walk on item
|
// set state 1 and walk on item
|
||||||
this.roomUnitID = unit.getId();
|
this.roomUnitID = unit.getId();
|
||||||
this.setExtradata("1");
|
this.setExtradata("1");
|
||||||
@ -199,25 +187,19 @@ public class InteractionTeleport extends HabboItem {
|
|||||||
|
|
||||||
public boolean canUseTeleport(GameClient client, Room room) {
|
public boolean canUseTeleport(GameClient client, Room room) {
|
||||||
|
|
||||||
/// Get habbo
|
|
||||||
Habbo habbo = client.getHabbo();
|
Habbo habbo = client.getHabbo();
|
||||||
|
|
||||||
/// this should never happen....
|
|
||||||
if (habbo == null)
|
if (habbo == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/// Get extension class
|
|
||||||
RoomUnit unit = habbo.getRoomUnit();
|
RoomUnit unit = habbo.getRoomUnit();
|
||||||
|
|
||||||
/// this should never happen...
|
|
||||||
if (unit == null)
|
if (unit == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/// Habbo cannot use the teleport if riding
|
|
||||||
if (habbo.getHabboInfo().getRiding() != null)
|
if (habbo.getHabboInfo().getRiding() != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/// check whether the room unit Id is valid
|
|
||||||
return this.roomUnitID == -1 || this.roomUnitID == unit.getId();
|
return this.roomUnitID == -1 || this.roomUnitID == unit.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +208,6 @@ public class InteractionTeleport extends HabboItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startTeleport(Room room, Habbo habbo, int delay) {
|
public void startTeleport(Room room, Habbo habbo, int delay) {
|
||||||
/// dont teleport if we are already teleporting
|
|
||||||
if (habbo.getRoomUnit().isTeleporting)
|
if (habbo.getRoomUnit().isTeleporting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -4318,60 +4318,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return FurnitureMovementError.NO_RIGHTS;
|
return FurnitureMovementError.NO_RIGHTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HabboItem OverrideItem(HabboItem p_Item, Habbo p_Owner)
|
|
||||||
{
|
|
||||||
if (p_Item instanceof InteractionTeleport)
|
|
||||||
{
|
|
||||||
TIntObjectIterator<HabboItem> l_Itr = this.roomItems.iterator();
|
|
||||||
|
|
||||||
for (int l_I = 0; l_I < this.roomItems.size(); l_I++)
|
|
||||||
{
|
|
||||||
l_Itr.advance();
|
|
||||||
|
|
||||||
if (l_Itr.value() instanceof InteractionTeleport)
|
|
||||||
{
|
|
||||||
InteractionTeleport l_Item = (InteractionTeleport)l_Itr.value();
|
|
||||||
|
|
||||||
/// If the item matches our hand item, then we have the correct item
|
|
||||||
if (p_Item.getId() == l_Item.getTargetId())
|
|
||||||
{
|
|
||||||
return p_Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// If the pair item is not placed in the room, check whether its placed in any other rooms
|
|
||||||
if (this.getHabboItem(l_Item.getTargetId()) == null)
|
|
||||||
{
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT room_id FROM items WHERE id = ?"))
|
|
||||||
{
|
|
||||||
statement.setInt(1, l_Item.getTargetId());
|
|
||||||
try (ResultSet set = statement.executeQuery())
|
|
||||||
{
|
|
||||||
set.next();
|
|
||||||
|
|
||||||
/// Check if pair item is placed in any rooms, if not then return that i
|
|
||||||
if (set.getInt("room_id") == 0)
|
|
||||||
{
|
|
||||||
HabboItem l_HandItem = p_Owner.getInventory().getItemsComponent().getHabboItem(l_Item.getTargetId());
|
|
||||||
|
|
||||||
if (l_HandItem != null)
|
|
||||||
{
|
|
||||||
return l_HandItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SQLException e) {
|
|
||||||
Emulator.getLogging().logSQLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return p_Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) {
|
public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation) {
|
||||||
if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
|
if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
|
||||||
return FurnitureMovementError.INVALID_MOVE;
|
return FurnitureMovementError.INVALID_MOVE;
|
||||||
@ -4422,14 +4368,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
return fits;
|
return fits;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item instanceof InteractionTeleport)
|
|
||||||
{
|
|
||||||
InteractionTeleport l_Test = (InteractionTeleport)item;
|
|
||||||
int hello = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
item = this.OverrideItem(item, owner);
|
|
||||||
|
|
||||||
item.setZ(tile.getStackHeight());
|
item.setZ(tile.getStackHeight());
|
||||||
item.setX(tile.x);
|
item.setX(tile.x);
|
||||||
item.setY(tile.y);
|
item.setY(tile.y);
|
||||||
|
@ -65,9 +65,8 @@ class TeleportActionThree implements Runnable {
|
|||||||
|
|
||||||
targetTeleport.setExtradata("2");
|
targetTeleport.setExtradata("2");
|
||||||
targetRoom.updateItem(targetTeleport);
|
targetRoom.updateItem(targetTeleport);
|
||||||
targetRoom.updateHabbo(this.client.getHabbo());
|
//targetRoom.updateHabbo(this.client.getHabbo());
|
||||||
//System.out.println(targetTeleport.getX() + " | " + tokay so basically
|
//System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY());
|
||||||
// after goargetTeleport.getY());
|
|
||||||
this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom);
|
this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom);
|
||||||
//Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500);
|
//Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500);
|
||||||
Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500);
|
Emulator.getThreading().run(new TeleportActionFour(targetTeleport, targetRoom, this.client), this.currentTeleport instanceof InteractionTeleportTile ? 0 : 500);
|
||||||
|
Loading…
Reference in New Issue
Block a user