-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from Jameskmonger/packet-impl-region-a
refactor: convert region-related inbound packets to message system
- Loading branch information
Showing
16 changed files
with
488 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/org/runejs/client/message/handler/rs435/region/ClearChunkMessageHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.runejs.client.message.handler.rs435.region; | ||
|
||
import org.runejs.client.Class40_Sub3; | ||
import org.runejs.client.LinkedList; | ||
import org.runejs.client.MovedStatics; | ||
import org.runejs.client.cache.def.FramemapDefinition; | ||
import org.runejs.client.cache.def.OverlayDefinition; | ||
import org.runejs.client.media.renderable.actor.Player; | ||
import org.runejs.client.message.handler.MessageHandler; | ||
import org.runejs.client.message.inbound.region.ClearChunkInboundMessage; | ||
import org.runejs.client.scene.tile.Wall; | ||
|
||
/** | ||
* Clears a chunk of the map. | ||
*/ | ||
public class ClearChunkMessageHandler implements MessageHandler<ClearChunkInboundMessage> { | ||
@Override | ||
public void handle(ClearChunkInboundMessage message) { | ||
MovedStatics.placementX = message.x; | ||
OverlayDefinition.placementY = message.y; | ||
for(int i_51_ = MovedStatics.placementX; i_51_ < 8 + MovedStatics.placementX; i_51_++) { | ||
for(int i_52_ = OverlayDefinition.placementY; 8 + OverlayDefinition.placementY > i_52_; i_52_++) { | ||
if(Wall.groundItems[Player.worldLevel][i_51_][i_52_] != null) { | ||
Wall.groundItems[Player.worldLevel][i_51_][i_52_] = null; | ||
FramemapDefinition.spawnGroundItem(i_52_, i_51_); | ||
} | ||
} | ||
} | ||
for(Class40_Sub3 class40_sub3 = (Class40_Sub3) LinkedList.aLinkedList_1064.peekFirst(); class40_sub3 != null; class40_sub3 = (Class40_Sub3) LinkedList.aLinkedList_1064.pollFirst()) { | ||
if(class40_sub3.anInt2039 >= MovedStatics.placementX && MovedStatics.placementX + 8 > class40_sub3.anInt2039 && class40_sub3.anInt2038 >= OverlayDefinition.placementY && OverlayDefinition.placementY + 8 > class40_sub3.anInt2038 && Player.worldLevel == class40_sub3.anInt2018) | ||
class40_sub3.anInt2031 = 0; | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...a/org/runejs/client/message/handler/rs435/region/LoadConstructedRegionMessageHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.runejs.client.message.handler.rs435.region; | ||
|
||
import org.runejs.client.Class13; | ||
import org.runejs.client.Class44; | ||
import org.runejs.client.LinkedList; | ||
import org.runejs.client.RSString; | ||
import org.runejs.client.cache.CacheArchive; | ||
import org.runejs.client.cache.def.OverlayDefinition; | ||
import org.runejs.client.language.Native; | ||
import org.runejs.client.media.renderable.actor.Actor; | ||
import org.runejs.client.message.handler.MessageHandler; | ||
import org.runejs.client.message.inbound.region.LoadConstructedRegionInboundMessage; | ||
import org.runejs.client.net.ISAAC; | ||
import org.runejs.client.scene.GroundItemTile; | ||
import org.runejs.client.scene.tile.GenericTile; | ||
|
||
/** | ||
* Loads a construction map region (i.e composed from chunks) | ||
*/ | ||
public class LoadConstructedRegionMessageHandler implements MessageHandler<LoadConstructedRegionInboundMessage> { | ||
@Override | ||
public void handle(LoadConstructedRegionInboundMessage message) { | ||
GroundItemTile.loadGeneratedMap = true; | ||
|
||
int chunkLocalY = message.chunkLocalY; | ||
int chunkX = message.chunkX; | ||
int chunkLocalX = message.chunkLocalX; | ||
int chunkY = message.chunkY; | ||
int level = message.level; | ||
int regionCount = message.regionCount; | ||
|
||
Class44.xteaKeys = message.xteaKeys; | ||
OverlayDefinition.constructMapTiles = message.mapTiles; | ||
|
||
LinkedList.terrainDataIds = new int[regionCount]; | ||
RSString.terrainData = new byte[regionCount][]; | ||
Class13.objectDataIds = new int[regionCount]; | ||
GenericTile.objectData = new byte[regionCount][]; | ||
ISAAC.mapCoordinates = new int[regionCount]; | ||
regionCount = 0; | ||
for(int i_11_ = 0; i_11_ < 4; i_11_++) { | ||
for(int i_12_ = 0; i_12_ < 13; i_12_++) { | ||
for(int i_13_ = 0; i_13_ < 13; i_13_++) { | ||
int i_14_ = OverlayDefinition.constructMapTiles[i_11_][i_12_][i_13_]; | ||
if(i_14_ != -1) { | ||
int i_15_ = i_14_ >> 14 & 0x3ff; | ||
int i_16_ = i_14_ >> 3 & 0x7ff; | ||
int i_17_ = i_16_ / 8 + (i_15_ / 8 << 8); | ||
for(int i_18_ = 0; regionCount > i_18_; i_18_++) { | ||
if(ISAAC.mapCoordinates[i_18_] == i_17_) { | ||
i_17_ = -1; | ||
break; | ||
} | ||
} | ||
if(i_17_ != -1) { | ||
ISAAC.mapCoordinates[regionCount] = i_17_; | ||
int i_19_ = i_17_ & 0xff; | ||
int i_20_ = (0xffbe & i_17_) >> 8; | ||
LinkedList.terrainDataIds[regionCount] = CacheArchive.gameWorldMapCacheArchive.getHash(Native.MAP_NAME_PREFIX_M +i_20_+ Native.MAP_NAME_UNDERSCORE +i_19_); | ||
Class13.objectDataIds[regionCount] = CacheArchive.gameWorldMapCacheArchive.getHash(Native.MAP_NAME_PREFIX_L +i_20_+ Native.MAP_NAME_UNDERSCORE +i_19_); | ||
regionCount++; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
Actor.method789(chunkLocalX, chunkY, chunkX, chunkLocalY, level); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...java/org/runejs/client/message/handler/rs435/region/LoadStandardRegionMessageHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.runejs.client.message.handler.rs435.region; | ||
|
||
import org.runejs.client.Class13; | ||
import org.runejs.client.Class44; | ||
import org.runejs.client.LinkedList; | ||
import org.runejs.client.RSString; | ||
import org.runejs.client.cache.CacheArchive; | ||
import org.runejs.client.language.Native; | ||
import org.runejs.client.media.renderable.actor.Actor; | ||
import org.runejs.client.message.handler.MessageHandler; | ||
import org.runejs.client.message.inbound.region.LoadStandardRegionInboundMessage; | ||
import org.runejs.client.net.ISAAC; | ||
import org.runejs.client.scene.GroundItemTile; | ||
import org.runejs.client.scene.tile.GenericTile; | ||
|
||
/** | ||
* Loads a standard map region (i.e from terrain files) | ||
*/ | ||
public class LoadStandardRegionMessageHandler implements MessageHandler<LoadStandardRegionInboundMessage> { | ||
@Override | ||
public void handle(LoadStandardRegionInboundMessage message) { | ||
GroundItemTile.loadGeneratedMap = false; | ||
|
||
int chunkLocalY = message.chunkLocalY; | ||
int chunkX = message.chunkX; | ||
int chunkLocalX = message.chunkLocalX; | ||
int chunkY = message.chunkY; | ||
int level = message.level; | ||
int regionCount = message.regionCount; | ||
Class44.xteaKeys = message.xteaKeys; | ||
ISAAC.mapCoordinates = new int[regionCount]; | ||
RSString.terrainData = new byte[regionCount][]; | ||
boolean inTutorialIsland_maybe = false; | ||
GenericTile.objectData = new byte[regionCount][]; | ||
if((chunkX / 8 == 48 || chunkX / 8 == 49) && chunkY / 8 == 48) { | ||
inTutorialIsland_maybe = true; | ||
} | ||
LinkedList.terrainDataIds = new int[regionCount]; | ||
if(chunkX / 8 == 48 && chunkY / 8 == 148) { | ||
inTutorialIsland_maybe = true; | ||
} | ||
Class13.objectDataIds = new int[regionCount]; | ||
regionCount = 0; | ||
for(int x = (-6 + chunkX) / 8; x <= (6 + chunkX) / 8; x++) { | ||
for(int y = (-6 + chunkY) / 8; (6 + chunkY) / 8 >= y; y++) { | ||
int coords = y + (x << 8); | ||
if(!inTutorialIsland_maybe || y != 49 && y != 149 && y != 147 && x != 50 && (x != 49 || y != 47)) { | ||
ISAAC.mapCoordinates[regionCount] = coords; | ||
|
||
String mapKey = x + Native.MAP_NAME_UNDERSCORE + y; | ||
String mapKeyM = Native.MAP_NAME_PREFIX_M + mapKey; | ||
String mapKeyL = Native.MAP_NAME_PREFIX_L + mapKey; | ||
|
||
LinkedList.terrainDataIds[regionCount] = CacheArchive.gameWorldMapCacheArchive.getHash(mapKeyM); | ||
Class13.objectDataIds[regionCount] = CacheArchive.gameWorldMapCacheArchive.getHash(mapKeyL); | ||
regionCount++; | ||
} | ||
} | ||
} | ||
|
||
Actor.method789(chunkLocalX, chunkY, chunkX, chunkLocalY, level); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...org/runejs/client/message/handler/rs435/region/UpdateReferencePositionMessageHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.runejs.client.message.handler.rs435.region; | ||
|
||
import org.runejs.client.MovedStatics; | ||
import org.runejs.client.cache.def.OverlayDefinition; | ||
import org.runejs.client.message.handler.MessageHandler; | ||
import org.runejs.client.message.inbound.region.UpdateReferencePositionInboundMessage; | ||
|
||
/** | ||
* Updates the reference position of the client. | ||
*/ | ||
public class UpdateReferencePositionMessageHandler implements MessageHandler<UpdateReferencePositionInboundMessage> { | ||
@Override | ||
public void handle(UpdateReferencePositionInboundMessage message) { | ||
MovedStatics.placementX = message.x; | ||
OverlayDefinition.placementY = message.y; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/runejs/client/message/inbound/region/ClearChunkInboundMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.runejs.client.message.inbound.region; | ||
|
||
import org.runejs.client.message.InboundMessage; | ||
|
||
/** | ||
* An {@link InboundMessage} sent to clear a chunk. | ||
*/ | ||
public class ClearChunkInboundMessage implements InboundMessage { | ||
/** | ||
* The chunk x offset. | ||
*/ | ||
public final int x; | ||
|
||
/** | ||
* The chunk y offset. | ||
*/ | ||
public final int y; | ||
|
||
/** | ||
* Creates a new {@link ClearChunkInboundMessage}. | ||
* @param x The chunk x offset. | ||
* @param y The chunk y offset. | ||
*/ | ||
public ClearChunkInboundMessage(int x, int y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...in/java/org/runejs/client/message/inbound/region/LoadConstructedRegionInboundMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.runejs.client.message.inbound.region; | ||
|
||
import org.runejs.client.message.InboundMessage; | ||
|
||
/** | ||
* An {@link InboundMessage} sent to load a region constructed from composite chunks. | ||
*/ | ||
public class LoadConstructedRegionInboundMessage implements InboundMessage { | ||
public final int chunkX; | ||
|
||
public final int chunkY; | ||
|
||
public final int chunkLocalX; | ||
|
||
public final int chunkLocalY; | ||
|
||
/** | ||
* The level of the region. | ||
*/ | ||
public final int level; | ||
|
||
public final int[][][] mapTiles; | ||
|
||
/** | ||
* The number of regions being loaded. | ||
*/ | ||
public final int regionCount; | ||
|
||
/** | ||
* The xtea keys of the region. | ||
*/ | ||
public final int[][] xteaKeys; | ||
|
||
/** | ||
* Creates a new {@link LoadConstructedRegionInboundMessage}. | ||
* | ||
* @param chunkX | ||
* @param chunkY | ||
* @param chunkLocalX | ||
* @param chunkLocalY | ||
* @param level The level of the region. | ||
* @param mapTiles | ||
* @param regionCount The number of regions being loaded. | ||
* @param xteaKeys The xtea keys of the regions. | ||
*/ | ||
public LoadConstructedRegionInboundMessage(int chunkX, int chunkY, int chunkLocalX, int chunkLocalY, int level, int[][][] mapTiles, int regionCount, int[][] xteaKeys) { | ||
this.chunkX = chunkX; | ||
this.chunkY = chunkY; | ||
this.chunkLocalX = chunkLocalX; | ||
this.chunkLocalY = chunkLocalY; | ||
this.level = level; | ||
this.mapTiles = mapTiles; | ||
this.regionCount = regionCount; | ||
this.xteaKeys = xteaKeys; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/org/runejs/client/message/inbound/region/LoadStandardRegionInboundMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.runejs.client.message.inbound.region; | ||
|
||
import org.runejs.client.message.InboundMessage; | ||
|
||
/** | ||
* An {@link InboundMessage} sent to load a standard region. | ||
*/ | ||
public class LoadStandardRegionInboundMessage implements InboundMessage { | ||
public final int chunkX; | ||
|
||
public final int chunkY; | ||
|
||
public final int chunkLocalX; | ||
|
||
public final int chunkLocalY; | ||
|
||
/** | ||
* The level of the region. | ||
*/ | ||
public final int level; | ||
|
||
/** | ||
* The number of regions being loaded. | ||
*/ | ||
public final int regionCount; | ||
|
||
/** | ||
* The xtea keys of the region. | ||
*/ | ||
public final int[][] xteaKeys; | ||
|
||
/** | ||
* Creates a new {@link LoadStandardRegionInboundMessage}. | ||
* @param chunkX | ||
* @param chunkY | ||
* @param chunkLocalX | ||
* @param chunkLocalY | ||
* @param level The level of the region. | ||
* @param regionCount The number of regions being loaded. | ||
* @param xteaKeys The xtea keys of the regions. | ||
*/ | ||
public LoadStandardRegionInboundMessage(int chunkX, int chunkY, int chunkLocalX, int chunkLocalY, int level, int regionCount, int[][] xteaKeys) { | ||
this.chunkX = chunkX; | ||
this.chunkY = chunkY; | ||
this.chunkLocalX = chunkLocalX; | ||
this.chunkLocalY = chunkLocalY; | ||
this.level = level; | ||
this.regionCount = regionCount; | ||
this.xteaKeys = xteaKeys; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../java/org/runejs/client/message/inbound/region/UpdateReferencePositionInboundMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.runejs.client.message.inbound.region; | ||
|
||
import org.runejs.client.message.InboundMessage; | ||
|
||
/** | ||
* An {@link InboundMessage} sent to update the reference position of the client. | ||
*/ | ||
public class UpdateReferencePositionInboundMessage implements InboundMessage { | ||
/** | ||
* The new x coordinate of the reference position. | ||
*/ | ||
public final int x; | ||
|
||
/** | ||
* The new y coordinate of the reference position. | ||
*/ | ||
public final int y; | ||
|
||
/** | ||
* Creates a new {@link UpdateReferencePositionInboundMessage}. | ||
* @param x The new x coordinate of the reference position. | ||
* @param y The new y coordinate of the reference position. | ||
*/ | ||
public UpdateReferencePositionInboundMessage(int x, int y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
} |
Oops, something went wrong.