Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSRS Integration #473

Open
wants to merge 63 commits into
base: kotlin-experiments
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
0930e66
Cache definitions, update server and most of login done for rev 181.
Feb 29, 2020
910a9c6
Replaced numeric constant '181' with the release revision.
Feb 29, 2020
36ee4c0
Bumped the JDK version in the azure-pipelines.yml to 11 from 1.8.
Feb 29, 2020
1f6041c
Binding on the same port is now filtered out. This occurs when the ne…
Feb 29, 2020
662570e
Login decoding updated to OSRS.
Mar 1, 2020
b901cb5
Documented user stats.
Mar 1, 2020
0cf9710
Updated UserStats to revision 8.
Mar 1, 2020
86cc048
Worldlist is now available. Currently it's just magic constants until…
Mar 1, 2020
72292a2
Worldlist is now available. Currently it's just magic constants until…
Mar 2, 2020
071b04d
Added the following encode messages: Varp
Mar 2, 2020
570745a
Player options decoders.
Mar 3, 2020
a45b4d3
Npc options decoders.
Mar 3, 2020
e0e3bd7
Refractored the directories in which each file lives. This seems more…
Mar 3, 2020
b0c0918
Refractored the directories in which each file lives. This seems more…
Mar 3, 2020
1e133f6
Changes the writeString(...) method's in BufferUtil.java to use Windo…
Mar 4, 2020
b4a3a62
Login to World complete.
Mar 11, 2020
3ef4250
InterfaceSet.java is updated to support osrs functionality.
Mar 15, 2020
4362b4f
Reduces the move-toplevel code.
Mar 15, 2020
db9a443
Experience and Weight Encoder messages.
Mar 15, 2020
ccc7e0f
Added the run-energy message.
Mar 15, 2020
9fcb2fd
Organized imports.
Mar 15, 2020
3ac6b6b
Added the plugins for shops back with proper npc ids.
Mar 15, 2020
7fe0272
Added the plugins for shops back with proper npc ids.
Mar 15, 2020
f972fd1
Fixes spawns with modern names.
Mar 15, 2020
a0d9869
Gets rid of leak from the ondemand response encoder.
Mar 15, 2020
060053e
Added SetPlayerActionMessageEncoder message.
Mar 22, 2020
948fad1
Inventory messages are complete.
Mar 22, 2020
ac27c8e
Item-interface interactions complete.
Mar 24, 2020
ef75cda
Ground items interactions complete.
Mar 25, 2020
62bd614
Moved around some decoder messages.
Mar 25, 2020
48e3fc4
Did a ton of encoder messages for interfaces.
Mar 26, 2020
a9ea8d2
Standard field names.
Mar 26, 2020
0f7a35e
Added logout message and set flag message.
Mar 26, 2020
8d3c198
Added logout message and set flag message.
Mar 26, 2020
677e994
Action support for clicks.
Mar 27, 2020
8a3db74
Moved a ton of messages.
Mar 27, 2020
1cd9a17
GPI nearly complete. Still need masks. Going to clean up the code more.
Apr 5, 2020
0a1ef20
GPI nearly complete. Still need masks. Going to clean up the code more.
Apr 10, 2020
f96ef85
Gpi done.
Apr 12, 2020
d00c6b4
Fixes compiler error on chat (somehow didn't get versioned)
Apr 12, 2020
028663d
Teleport happens post-tick.
Apr 12, 2020
65309ab
Added tutorial island wood and oak tree identifiers.
Apr 12, 2020
15833bf
Fixes title mask flag.
Apr 12, 2020
bbc0e13
Keyboard event added.
Apr 12, 2020
ac00bc2
ChatFilterSettingsMessage added.
Apr 12, 2020
c858ac4
Removed item option, we should have one consistent message for that.
Apr 13, 2020
5037fff
Fixes issue with inventory and component id being swapped.
Apr 13, 2020
88928e9
Removed some debug statements from GPI.
Apr 13, 2020
deb1a17
Zone packets, add and remove object messages.
Apr 13, 2020
c9f5e73
Added proper priorities and the UpdateZonePartialEnclosedEncoder.
Apr 13, 2020
0c92c9f
Finished supported map zone packets.
Apr 14, 2020
a15165b
Added unsupported map zone packets.
Apr 15, 2020
d56d375
Fixes issue with crash when changing regions.
Apr 15, 2020
4cbe700
Adds more packets to queue, previous limit was 25 packets. Osrs can h…
Apr 15, 2020
7b5b158
Adds huffman codec class to properly compress/decompress mesasges.
Apr 20, 2020
4af53e9
Fixes problem that broke pub chat. Still need to fix compression for …
Apr 20, 2020
4bddfe2
Fixes issue with HuffmanCodec
Apr 22, 2020
04ab087
Fixes codec issues.
Apr 22, 2020
79ac1a8
Fixes issue with HuffmanCodec
Apr 22, 2020
ba28a23
Friends list interactions complete.
Apr 22, 2020
e393743
Ignores list complete.
Apr 22, 2020
bfb2619
All the changes that sfix has asked for.
Apr 26, 2020
ba35a57
Code review pass #2 osrs-proposal
May 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions game/src/main/java/org/apollo/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

/**
Expand All @@ -48,6 +49,8 @@ public final class Server {
* @param args The command-line arguments passed to the application.
*/
public static void main(String[] args) {
Arrays.stream(LogManager.getLogManager().getLogger("").getHandlers()).forEach(h -> h.setLevel(Level.ALL));

Stopwatch stopwatch = Stopwatch.createStarted();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@ public WalkMessageHandler(World world) {
@Override
public void handle(Player player, WalkMessage message) {
WalkingQueue queue = player.getWalkingQueue();
queue.setRunning(message.isRunning() || player.isRunning());

Position[] steps = message.getSteps();
for (int index = 0; index < steps.length; index++) {
Position step = steps[index];
if (index == 0) {
queue.addFirstStep(step);
} else {
queue.addStep(step);
}
}
player.teleport(new Position(message.getX(), message.getY(), player.getPosition().getHeight()));
//queue.addFirstStep(new Position(message.getX(), message.getY(), player.getPosition().getHeight()));

queue.setRunning(message.isRunning() || player.isRunning());
player.getInterfaceSet().close();

if (queue.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,119 +1,19 @@
package org.apollo.game.message.impl;

import org.apollo.game.model.Position;
import org.apollo.game.sync.seg.SynchronizationSegment;
import org.apollo.game.model.entity.PlayerUpdateInfo;
import org.apollo.net.codec.game.GamePacketBuilder;
import org.apollo.net.message.Message;

import java.util.List;

/**
* A {@link Message} sent to the client to synchronize players.
*
* @author Graham
*/
public final class PlayerSynchronizationMessage extends Message {

/**
* The Position in the last known region.
*/
private final Position lastKnownRegion;

/**
* The number of local players.
*/
private final int localPlayers;

/**
* The player's position.
*/
private final Position position;

/**
* A flag indicating if the region has changed.
*/
private final boolean regionChanged;

/**
* The current player's synchronization segment.
*/
private final SynchronizationSegment segment;

/**
* A list of segments.
*/
private final List<SynchronizationSegment> segments;

/**
* Creates the player synchronization message.
*
* @param lastKnownRegion The last known region.
* @param position The player's current position.
* @param regionChanged A flag indicating if the region has changed.
* @param segment The current player's synchronization segment.
* @param localPlayers The number of local players.
* @param segments A list of segments.
*/
public PlayerSynchronizationMessage(Position lastKnownRegion, Position position, boolean regionChanged, SynchronizationSegment segment, int localPlayers, List<SynchronizationSegment> segments) {
this.lastKnownRegion = lastKnownRegion;
this.position = position;
this.regionChanged = regionChanged;
this.segment = segment;
this.localPlayers = localPlayers;
this.segments = segments;
}

/**
* Gets the last known region.
*
* @return The last known region.
*/
public Position getLastKnownRegion() {
return lastKnownRegion;
}

/**
* Gets the number of local players.
*
* @return The number of local players.
*/
public int getLocalPlayers() {
return localPlayers;
}

/**
* Gets the player's position.
*
* @return The player's position.
*/
public Position getPosition() {
return position;
}

/**
* Gets the current player's segment.
*
* @return The current player's segment.
*/
public SynchronizationSegment getSegment() {
return segment;
}
private final GamePacketBuilder info;

/**
* Gets the synchronization segments.
*
* @return The segments.
*/
public List<SynchronizationSegment> getSegments() {
return segments;
public PlayerSynchronizationMessage(GamePacketBuilder info) {
this.info = info;
}

/**
* Checks if the region has changed.
*
* @return {@code true} if so, {@code false} if not.
*/
public boolean hasRegionChanged() {
return regionChanged;
public GamePacketBuilder getInfo() {
return info;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
*/
public final class PublicChatMessage extends ChatMessage {

public enum PublicChatType {
NONE, QUICKCHAT, CLANCHAT
}

/**
* The text color.
*/
Expand All @@ -19,18 +23,25 @@ public final class PublicChatMessage extends ChatMessage {
*/
private final int effects;

/**
* The type of public chat.
*/
private final PublicChatType type;

/**
* Creates a new chat message.
*
* @param message The message.
* @param message The message.
* @param compressedMessage The compressed message.
* @param color The text color.
* @param effects The text effects.
* @param color The text color.
* @param effects The text effects.
* @param type The chat type.
*/
public PublicChatMessage(String message, byte[] compressedMessage, int color, int effects) {
public PublicChatMessage(String message, byte[] compressedMessage, int color, int effects, PublicChatType type) {
super(message, compressedMessage);
this.color = color;
this.effects = effects;
this.type = type;
}

/**
Expand All @@ -51,4 +62,12 @@ public int getTextEffects() {
return effects;
}

/**
* Gets the chat type.
*
* @return the type of public chat.
*/
public PublicChatType getType() {
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,38 @@ public final class WalkMessage extends Message {
/**
* The steps.
*/
private final Position[] steps;
private int x, y;

/**
* Creates the message.
*
* @param steps The steps array.
* @param x The absolute x-axis position.
* @param y The absolute y-axis position.
* @param run The run flag.
*/
public WalkMessage(Position[] steps, boolean run) {
Preconditions.checkArgument(steps.length >= 0, "Number of steps cannot be negative.");
this.steps = steps;
public WalkMessage(int x, int y, boolean run) {
this.x = x;
this.y = y;
this.run = run;
}


/**
* Gets x.
*
* @return the x
*/
public int getX() {
return x;
}

/**
* Gets the steps array.
* Gets y.
*
* @return An array of steps.
* @return the y
*/
public Position[] getSteps() {
return steps;
public int getY() {
return y;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import org.apollo.cache.map.XteaRepository;
import org.apollo.game.model.Position;
import org.apollo.game.model.entity.MobRepository;
import org.apollo.game.model.entity.Player;
import org.apollo.game.model.entity.PlayerUpdateInfo;
import org.apollo.net.message.Message;

/**
Expand All @@ -21,10 +24,20 @@ public final class RebuildNormalMessage extends Message {
*/
private final int index;

/**
* The update information of the player.
*/
private PlayerUpdateInfo info;

/**
* The repository containing xteas.
*/
private final XteaRepository repository;
private final XteaRepository xteaRepository;

/**
* The repository containing players.
*/
private final MobRepository<Player> playerRepository;

/**
* If the player has a last known region.
Expand All @@ -35,13 +48,15 @@ public final class RebuildNormalMessage extends Message {
* Creates the region changed message.
*
* @param position The position of the region.
* @param repository the repository
* @param xteaRepository the repository
* @param hasLastKnownRegion if the player has been in a region.
*/
public RebuildNormalMessage(Position position, int index, XteaRepository repository, boolean hasLastKnownRegion) {
public RebuildNormalMessage(Position position, int index, PlayerUpdateInfo info, MobRepository<Player> playerRepository, XteaRepository xteaRepository, boolean hasLastKnownRegion) {
this.position = position;
this.index = index;
this.repository = repository;
this.info = info;
this.xteaRepository = xteaRepository;
this.playerRepository = playerRepository;
this.hasLastKnownRegion = hasLastKnownRegion;
}

Expand All @@ -64,13 +79,17 @@ public int getIndex() {
return index;
}

public PlayerUpdateInfo getInfo() {
return info;
}

/**
* Gets repository.
*
* @return the repository
*/
public XteaRepository getRepository() {
return repository;
public XteaRepository getXteaRepository() {
return xteaRepository;
}

/**
Expand All @@ -81,4 +100,8 @@ public XteaRepository getRepository() {
public boolean isHasLastKnownRegion() {
return hasLastKnownRegion;
}

public MobRepository<Player> getPlayerRepository() {
return playerRepository;
}
}
4 changes: 4 additions & 0 deletions game/src/main/java/org/apollo/game/model/Position.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,8 @@ public String toString() {
return MoreObjects.toStringHelper(this).add("x", getX()).add("y", getY()).add("height", getHeight())
.add("map", getRegionCoordinates()).toString();
}

public int get18BitHash() {
return (getY() >> 13) + ((getX() >> 13) << 8) + (getHeight() << 16);
}
}
4 changes: 2 additions & 2 deletions game/src/main/java/org/apollo/game/model/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void register(Player player) {
playerRepository.add(player);
players.put(NameUtil.encodeBase37(username), player);

logger.finest("Registered player: " + player + " [count=" + playerRepository.size() + "]");
System.out.println("Registered player: " + player + " [count=" + playerRepository.size() + "]");
}

/**
Expand Down Expand Up @@ -360,7 +360,7 @@ public void unregister(final Player player) {
region.removeEntity(player);

playerRepository.remove(player);
logger.finest("Unregistered player: " + player + " [count=" + playerRepository.size() + "]");
System.out.println("Unregistered player: " + player + " [count=" + playerRepository.size() + "]");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public final class WorldConstants {
/**
* The maximum number of players.
*/
public static final int MAXIMUM_PLAYERS = 2000;
public static final int MAXIMUM_PLAYERS = 2048;

/**
* Default private constructor to prevent instantiation by other classes.
Expand Down
Loading