mirror of
https://github.com/moparisthebest/rswiki-book
synced 2024-12-22 07:28:50 -05:00
Add client functions section
This commit is contained in:
parent
193f6c119c
commit
fb2efe42f6
24
src/Censorship.md
Normal file
24
src/Censorship.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Censorship
|
||||||
|
|
||||||
|
Chat message censorship is applied client-side.
|
||||||
|
|
||||||
|
Traditionally, the use of bad words does not always result in a punishment,
|
||||||
|
unless if applied manually by a staff member.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
There are four related cache files which are loaded and used in censorship.
|
||||||
|
|
||||||
|
They are as follows:
|
||||||
|
|
||||||
|
| Cache file name | Purpose |
|
||||||
|
|---|---|
|
||||||
|
| `fragmentsenc.txt` | ? |
|
||||||
|
| `badenc.txt` | Contains bad words, including variations (e.g. `fuck`, `fok`, etc.). |
|
||||||
|
| `domainenc.txt` | Contains bad domain names. |
|
||||||
|
| `tldlist.txt` | Contains possible top-level domain names. |
|
||||||
|
|
||||||
|
When an input is received, if bad phrases are found they are replaced
|
||||||
|
with a sequence of astericks.
|
||||||
|
|
||||||
|
Bad phrases are either a bad word, or a combination of a bad domain name and a top-level domain name.
|
@ -1,85 +1,89 @@
|
|||||||
|
# Class check
|
||||||
|
|
||||||
The class check originated with the new Runescape engine update which
|
The class check originated with the new Runescape engine update which
|
||||||
took place around the 4xx revisions. It gives the Jagex servers the
|
took place around the 4xx revisions.
|
||||||
ability to check the modifiers, update, or fetch the value for a field.
|
It gives the Jagex servers the ability to check the modifiers, update,
|
||||||
|
or fetch the value for a field.
|
||||||
It also gives functionality to invoke a method with parameters and get
|
It also gives functionality to invoke a method with parameters and get
|
||||||
it's return value, or check it's modifiers. Each of these
|
it's return value, or check it's modifiers.
|
||||||
functionalities are described with a request type. A class check request
|
Each of these functionalities are described with a request type.
|
||||||
is built up with many of these request types. Each request is tagged
|
A class check request is built up with many of these request types.
|
||||||
with an unique id.
|
Each request is tagged with an unique id.
|
||||||
|
|
||||||
== Request Structure ==
|
## Request format
|
||||||
|
|
||||||
+-------------------------+ \| amount requests : ubyte \|
|
```
|
||||||
+-------------------------+ \| uid : dword \|
|
unsigned byte numberOfRequests;
|
||||||
+-------------------------+--------------+------------------------+ \|
|
int uid;
|
||||||
for each request \| type : ubyte \| type dependent data... \|
|
byte[] requests_block;
|
||||||
+-------------------------+--------------+------------------------+
|
```
|
||||||
|
|
||||||
== Response Structure ==
|
The `requests_block` is comprised of multiple requests, each with the following format:
|
||||||
|
|
||||||
+---------------------+ \| uid : dword \|
|
```
|
||||||
+---------------------+----------------------+------------------------+
|
unsigned byte type;
|
||||||
\| for each request \| response code : byte \| type dependent data... \|
|
type-dependent data;
|
||||||
+---------------------+----------------------+------------------------+
|
```
|
||||||
\| payload crc : dword \| +---------------------+
|
|
||||||
|
|
||||||
== Request Types ==
|
## Response format
|
||||||
|
|
||||||
|
```
|
||||||
|
int uid;
|
||||||
|
byte[] responses_block;
|
||||||
|
short payloadCrc;
|
||||||
|
```
|
||||||
|
|
||||||
|
The `responses_block` is comprised of multiple responses, each with the following format:
|
||||||
|
|
||||||
|
```
|
||||||
|
byte responseCode;
|
||||||
|
type-dependent data;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Request Types
|
||||||
|
|
||||||
For request types 0, 2, 4 there will only be one successful response
|
For request types 0, 2, 4 there will only be one successful response
|
||||||
code and a dword value of the value being requested will be sent. For
|
code and a short value of the value being requested will be sent.
|
||||||
request type 1, only the successful response code will be used but no
|
For request type 1, only the successful response code will be used but no
|
||||||
value will be sent back.
|
value will be sent back.
|
||||||
|
|
||||||
{\| border=2px ! Opcode ! Name ! Description \|- ! 0 ! Fetch Numeric
|
| Opcode | Name | Description |
|
||||||
Field ! Fetches the value of a numeric field. \|- ! 1 ! Update Numeric
|
|---|---|---|
|
||||||
Field ! Updates the value of a numeric field. \|- ! 2 ! Get Field
|
| 0 | Fetch fumeric field | Fetches the value of a numeric field. |
|
||||||
Modifiers ! Gets the modifiers of a field. \|- ! 3 ! Invoke Method !
|
| 1 | Update numeric field | Updates the value of a numeric field. |
|
||||||
Invokes a method and sends back its return object. \|- ! 4 ! Get Method
|
| 2 | Get field modifiers | Gets the modifiers of a field. |
|
||||||
Modifiers ! Gets the modifiers of a method. \|}
|
| 3 | Invoke method | Invokes a method and sends back its return object. |
|
||||||
|
| 4 | Get method modifiers | Gets the modifiers of a method. |
|
||||||
|
|
||||||
== Return Codes ==
|
## Return Codes
|
||||||
|
|
||||||
All the return codes are in descending priority by numerical order. For
|
For opcode 0, there are cases where a numeric value is sent to the server
|
||||||
opcode 0, there are cases where a numeric value is sent to the server on
|
on fetch requests.
|
||||||
fetch requests. This value is always a dword. For a method invoke
|
This value is always a short.
|
||||||
request, there isn't a value that is sent to the server. It is just
|
|
||||||
assumed that there wasn't a return object from the invoked method.
|
|
||||||
|
|
||||||
{\| border=2px ! Opcode ! Name ! On Receive/Response ! Description \|- !
|
For a method invoke request, there isn't a value that is sent to the server.
|
||||||
0 ! Successful ! Response ! Successfully executed the request. \|- ! 1 !
|
It is just assumed that there wasn't a return object from the invoked method.
|
||||||
Successful - Returned numeric value ! Response ! Successfully executed
|
|
||||||
the request, and returned a numeric value. \|- ! 2 ! Successful -
|
| Opcode | Name | On Receive/Response | Description |
|
||||||
Returned string value ! Response ! Successfully executed the request,
|
|---|---|---|---|
|
||||||
and returned a string value. \|- ! 4 ! Successful - Returned object
|
| 0 | Successful | Response | Successfully executed the request. |
|
||||||
value ! Response ! Successfully executed the request, and returned an
|
| 1 | Successful - Returned numeric value | Response | Successfully executed the request, and returned a numeric value. |
|
||||||
object value. \|- ! -1 ! ClassNotFoundException ! Receive ! A
|
| 2 | Successful - Returned string value | Response | Successfully executed the request, and returned a string value. |
|
||||||
ClassNotFoundException was thrown while receiving a request from the
|
| 4 | Successful - Returned object value | Response | Successfully executed the request, and returned an object value. |
|
||||||
server. \|- ! -2 ! SecurityException ! Receive ! A SecurityException was
|
| -1 | ClassNotFoundException | Receive | A ClassNotFoundException was thrown while receiving a request from the server. |
|
||||||
thrown while receiving a request from the server. \|- ! -3 !
|
| -2 | SecurityException | Receive | A SecurityException was thrown while receiving a request from the server. |
|
||||||
NullPointerException ! Receive ! A NullPointerException was thrown while
|
| -3 | NullPointerException | Receive | A NullPointerException was thrown while receiving a request from the server. |
|
||||||
receiving a request from the server. \|- ! -4 ! Exception ! Receive ! An
|
| -4 | Exception | Receive | An Exception was thrown while receiving a request from the server. |
|
||||||
Exception was thrown while receiving a request from the server. \|- ! -5
|
| -5 | Throwable | Receive | An error or exception was thrown while receiving a request from the server. |
|
||||||
! Throwable ! Receive ! An error or exception was thrown while receiving
|
| -10 | ClassNotFoundException | Response | A ClassNotFoundException was thrown while responding to a request from the server. |
|
||||||
a request from the server. \|- ! -10 ! ClassNotFoundException ! Response
|
| -11 | InvalidClassException | Response | An InvalidClassException was thrown while responding to a request from the server. |
|
||||||
! A ClassNotFoundException was thrown while responding to a request from
|
| -12 | StreamCorruptedException | Response | A StreamCorruptedException was thrown while responding to a request from the server. |
|
||||||
the server. \|- ! -11 ! InvalidClassException ! Response ! An
|
| -13 | OptionDataException | Response | An OptionDataException was thrown while responding to a request from the server. |
|
||||||
InvalidClassException was thrown while responding to a request from the
|
| -14 | IllegalAccessException | Response | An IllegalAccessException was thrown while responding to a request from the server. |
|
||||||
server. \|- ! -12 ! StreamCorruptedException ! Response ! A
|
| -15 | IllegalArgumentException | Response | An IllegalArgumentException was thrown while responding to a request from the server. |
|
||||||
StreamCorruptedException was thrown while responding to a request from
|
| -16 | InvocationTargetException | Response | An InvocationTargetException was thrown while responding to a request from the server. |
|
||||||
the server. \|- ! -13 ! OptionalDataException ! Response ! An
|
| -17 | SecurityException | Response | A SecurityException was thrown while responding to a request from the server. |
|
||||||
OptionDataException was thrown while responding to a request from the
|
| -18 | IOException | Response | An IOException was thrown while responding to a request from the server. |
|
||||||
server. \|- ! -14 ! IllegalAccessException ! Response ! An
|
| -19 | NullPointerException | Response | A NullPointerException was thrown while responding to a request from the server. |
|
||||||
IllegalAccessException was thrown while responding to a request from the
|
| -20 | Exception | Response | An Exception was thrown while responding to a request from the server. |
|
||||||
server. \|- ! -15 ! IllegalArgumentException ! Response ! An
|
| -21 | Throwable | Response | An error or exception was thrown while receiving a request from the server. |
|
||||||
IllegalArgumentException was thrown while responding to a request from
|
|
||||||
the server. \|- ! -16 ! InvocationTargetException ! Response ! An
|
|
||||||
InvocationTargetException was thrown while responding to a request from
|
|
||||||
the server. \|- ! -17 ! SecurityException ! Response ! A
|
|
||||||
SecurityException was thrown while responding to a request from the
|
|
||||||
server. ! \|- ! -18 ! IOException ! Response ! An IOException was thrown
|
|
||||||
while responding to a request from the server. \|- ! -19 !
|
|
||||||
NullPointerException ! Response ! A NullPointerException was thrown
|
|
||||||
while responding to a request from the server. \|- ! -20 ! Exception !
|
|
||||||
Response ! An Exception was thrown while responding to a request from
|
|
||||||
the server. \|- ! -21 ! Throwable ! Response ! An error or exception was
|
|
||||||
thrown while receiving a request from the server. \|}
|
|
||||||
|
7
src/Client-functions.md
Normal file
7
src/Client-functions.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Client functions
|
||||||
|
|
||||||
|
This section will describe the following:
|
||||||
|
- [Map region system](./Map-Region-System.html)
|
||||||
|
- [Censorship](./Censorship.html)
|
||||||
|
- [Mouse coordinate tracking](./Mouse-coordinate-tracking.html)
|
||||||
|
- [Class-Check](./Class-Check.html)
|
17
src/Home.md
17
src/Home.md
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
A source of documentation for the RSC/RS2/RS3 protocols and related systems.
|
A source of documentation for the RSC/RS2/RS3 protocols and related systems.
|
||||||
|
|
||||||
### Navigation
|
## Navigation
|
||||||
* [About](About.html)
|
* [About](About.html)
|
||||||
* [Rules](Rules.html)
|
* [Rules](Rules.html)
|
||||||
* [IRC](IRC.html)
|
* [IRC](IRC.html)
|
||||||
@ -10,17 +10,12 @@ A source of documentation for the RSC/RS2/RS3 protocols and related systems.
|
|||||||
* [DMCA Policy](DMCA-Policy.html)
|
* [DMCA Policy](DMCA-Policy.html)
|
||||||
* [Privacy Policy](Privacy-policy.html)
|
* [Privacy Policy](Privacy-policy.html)
|
||||||
|
|
||||||
### Game Protocol
|
## Game Protocol
|
||||||
* [[RSC|Category RSC]] (2001 - 2004)
|
* RSC (2001 - 2004)
|
||||||
* [[RS2|Category RS2]] (2004 - 2013)
|
* RS2 (2004 - 2013)
|
||||||
* [[RS3|Category RS3]] (2013 - present)
|
* RS3 (2013 - present)
|
||||||
|
|
||||||
### Cache
|
## Cache
|
||||||
* [JAGGRAB protocol](./JAGGRAB-Protocol.html)
|
* [JAGGRAB protocol](./JAGGRAB-Protocol.html)
|
||||||
* [Ondemand protocol](./Ondemand-Protocol.html)
|
* [Ondemand protocol](./Ondemand-Protocol.html)
|
||||||
* [Archive format](./Archive-Format.html)
|
* [Archive format](./Archive-Format.html)
|
||||||
|
|
||||||
|
|
||||||
### Miscellaneous
|
|
||||||
* [[Custom Data Types|Data Types]]
|
|
||||||
* [[Map Region System]]
|
|
@ -1,115 +1,145 @@
|
|||||||
== Intro == Everyone knows that a coordinate system is in place to
|
# Map region system
|
||||||
navigate through the Runescape world. That coordinate system is based
|
|
||||||
off upon three variables, the Absolute X, Y Z coordinates. Before we
|
|
||||||
continue to talk about how these three variables are used in
|
|
||||||
calculations lets set down some vocabulary:
|
|
||||||
|
|
||||||
== Definitions == ===Tile=== A tile is a representation of an absolute
|
A coordinate system is used to navigate through the RuneScape
|
||||||
coordinate.
|
world.
|
||||||
|
That coordinate system is based upon three variables, the absolute
|
||||||
|
X-, Y-, and Z-coordinates.
|
||||||
|
|
||||||
''Example: Varrock Coordinates 3211, 3424 represents one tile.''
|
## Definitions
|
||||||
|
|
||||||
===Tile Chunk=== A chunk of tiles, 8 x 8 in size. Also known as a region
|
A **tile** is the in-game representation of an absolute coordinate.
|
||||||
before the scope of a region was understood. The chunk is considered a
|
|
||||||
point so it has X and Y coordinates. There are two forms of a Chunk,
|
|
||||||
formatted and non; a formatted chunks equation is:
|
|
||||||
|
|
||||||
int chunkX = (getAbsoluteX() \>\> 3) - 6; int chunkY = (getAbsoluteY()
|
e.g. The coordinates `(3222, 3222)` represents one tile in the heart
|
||||||
\>\> 3) - 6;
|
of the Lumbridge castle.
|
||||||
|
|
||||||
|
A **chunk of tiles**, 8 x 8 in size.
|
||||||
|
Also known as a region before the scope of a region was understood.
|
||||||
|
The chunk is considered a point so it has X and Y coordinates.
|
||||||
|
There are two forms of a Chunk: formatted and non-formatted,
|
||||||
|
a formatted chunks equation is:
|
||||||
|
|
||||||
|
```java
|
||||||
|
int chunkX = (getAbsoluteX() >> 3) - 6;
|
||||||
|
int chunkY = (getAbsoluteY() >> 3) - 6;
|
||||||
|
```
|
||||||
|
|
||||||
This centers the chunk on the map, more on that later.
|
This centers the chunk on the map, more on that later.
|
||||||
|
|
||||||
The normal chunk equation is:
|
The normal chunk equation is:
|
||||||
|
|
||||||
int chunkX = (getAbsoluteX() \>\> 3); int chunkY = (getAbsoluteY() \>\>
|
```java
|
||||||
3);
|
int chunkX = (getAbsoluteX() >> 3);
|
||||||
|
int chunkY = (getAbsoluteY() >> 3);
|
||||||
|
```
|
||||||
|
|
||||||
''Example: The Coordinates \[3211, 3424\] Chunk X (formatted) is 395 and
|
e.g. For the coordinates `(3211, 3424)`, chunk X (formatted) is 395 and
|
||||||
the Chunk Y (un-formatted) is 428.''
|
the chunk Y (un-formatted) is 428.''
|
||||||
|
|
||||||
===Region=== A region is 64 x 64 in size, or 8 x 8 in chunks. The region
|
## Region
|
||||||
is considered a point so it has X and Y coordinates. The equation for
|
|
||||||
finding the region the coordinates is within is:
|
|
||||||
|
|
||||||
int regionx = (getUnformattedRegionX() \>\> 3);
|
A **region** is 64 x 64 in size, or 8 x 8 in chunks.
|
||||||
//getUnformatedRegionX()/8; int regiony = (getUnformattedRegionY() \>\>
|
The region is considered a point so it has X and Y coordinates.
|
||||||
3); //getUnformatedRegionY()/8;
|
|
||||||
|
|
||||||
''Example: The Coordinates \[3211, 3424\] Region X is 50 and the Region
|
The equation for finding the region the coordinates is within is:
|
||||||
Y is 53.''
|
|
||||||
|
```java
|
||||||
|
int regionX = (getUnformattedRegionX() >> 3); // getUnformatedRegionX() / 8;
|
||||||
|
int regionY = (getUnformattedRegionY() >> 3); // getUnformatedRegionY() / 8;
|
||||||
|
```
|
||||||
|
|
||||||
|
e.g. For the coordinates `(3211, 3424)`, region X is 50, and the
|
||||||
|
region Y is 53.
|
||||||
|
|
||||||
Note: The Region X and Region Y coordinates are traditionally not used
|
Note: The Region X and Region Y coordinates are traditionally not used
|
||||||
in server location calculations; but practical region systems should use
|
in server location calculations; but practical region systems should use
|
||||||
this calculation for many purposes.
|
this calculation for many purposes.
|
||||||
|
|
||||||
===Map=== There is no calculation for a map, and there is no Map X or
|
## Map
|
||||||
Map Y. A Map is, however, a 104 x 104 area made up of 13 x 13 chunks.
|
|
||||||
Why is the number not even you may ask? Because it has a center. The
|
|
||||||
\[7, 7\] map chunk of the map is the center, and is also the formatted
|
|
||||||
chunk. When a region update is called by the server, a new map is
|
|
||||||
called, but you must understand that the formatted chunk never changes;
|
|
||||||
the tiles in the map, however, are updated and trimmed. When the player
|
|
||||||
moves out of the formatted chunk, the map is re-positioned to make that
|
|
||||||
chunk the center yet again. As I said, a new update is not needed every
|
|
||||||
time the player enters a new region, but when the range of +- 32 from
|
|
||||||
the point in the center of the chunk is reached, an update is required
|
|
||||||
to update the map to the new objects so that the 'black space' or fog is
|
|
||||||
not reached. Confused?
|
|
||||||
|
|
||||||
===Diagram=== \[http://i.imgur.com/C3huO.png External Image\]
|
There is no calculation for a map, and there is no Map X or Map Y.
|
||||||
|
|
||||||
The active chunk is the chunk in which the player resides. The definite
|
A Map is, however, a 104 x 104 area made up of 13 x 13 chunks.
|
||||||
rendering chunks are the chunks in which will be rendered on the players
|
Why is the number not even you may ask?
|
||||||
screen no matter where they are in the active chunk. The indefinite
|
Because it has a center.
|
||||||
rendering chunks are the chunks in which depending on where the player
|
The `(7, 7)` map chunk of the map is the center, and is also the formatted
|
||||||
is within the active chunk they may be rendered or not. Remember this
|
chunk.
|
||||||
depends on the +- distance of 32 from the players absolute position. The
|
|
||||||
queue chunks are pre-loaded chunks in which after the active chunk is
|
|
||||||
moved may be disposed of or activated depending upon the direction in
|
|
||||||
which the active chunk changes.
|
|
||||||
|
|
||||||
==Loading==
|
When a region update is called by the server, a new map is called, but you
|
||||||
|
must understand that the formatted chunk never changes; the tiles in the
|
||||||
|
map, however, are updated and trimmed.
|
||||||
|
When the player moves out of the formatted chunk, the map is re-positioned
|
||||||
|
to make that chunk the center yet again.
|
||||||
|
As stated, a new update is not needed every time the player enters a
|
||||||
|
new region, but when the range of +- 32 from the point in the center of
|
||||||
|
the chunk is reached, an update is required to update the map to the
|
||||||
|
new objects so that the 'black space' or fog is not reached. Confused?
|
||||||
|
|
||||||
These were the regions loaded for the coordinates \[3183, 3217\]:
|
## Diagram
|
||||||
|
|
||||||
\[http://i.imgur.com/ydl78.png External Image\]
|
![Diagram](./img/map-region-system-diagram.png)
|
||||||
|
|
||||||
|
The active chunk is the chunk in which the player resides.
|
||||||
|
The definite rendering chunks are the chunks in which will be rendered
|
||||||
|
on the players screen no matter where they are in the active chunk.
|
||||||
|
The indefinite rendering chunks are the chunks in which depending on
|
||||||
|
where the player is within the active chunk they may be rendered or not.
|
||||||
|
Remember this depends on the +- distance of 32 from the players
|
||||||
|
absolute position. The queue chunks are pre-loaded chunks in whichafter the
|
||||||
|
active chunk is moved may be disposed of or activated depending upon the
|
||||||
|
direction in which the active chunk changes.
|
||||||
|
|
||||||
|
## Loading
|
||||||
|
|
||||||
|
The following were the regions loaded for the coordinates `(3183, 3217)`:
|
||||||
|
|
||||||
|
![Loading diagram](./img/map-region-system-loading.png)
|
||||||
|
|
||||||
If you can imagine a puzzle, a 64 x 64 piece does not fit equally within
|
If you can imagine a puzzle, a 64 x 64 piece does not fit equally within
|
||||||
the 104 x 104 area. So bits of each region are taken that are within the
|
the 104 x 104 area.
|
||||||
104 x 104 map area.
|
So, bits of each region are taken that are within the 104 x 104 map area.
|
||||||
|
|
||||||
The amount of regions that are to be loaded can be calculated this way:
|
The amount of regions that are to be loaded can be calculated this way:
|
||||||
|
|
||||||
Please note that Region X and Region Y are not formatted.
|
Please note that Region X and Region Y are not formatted.
|
||||||
|
|
||||||
int amt = 0; for(int i21 = (player.getLocation().getRegionX() - 6) / 8;
|
```java
|
||||||
i21 \<= (player.getLocation().getRegionX() + 6) / 8; i21++) { for(int
|
int amt = 0;
|
||||||
k23 = (player.getLocation().getRegionY() - 6) / 8; k23 \<=
|
|
||||||
(player.getLocation().getRegionY() + 6) / 8; k23++) amt++; }
|
for (int i21 = (player.getLocation().getRegionX() - 6) / 8; i21 <= (player.getLocation().getRegionX() + 6) / 8; i21++) {
|
||||||
|
for (int k23 = (player.getLocation().getRegionY() - 6) / 8; k23 <= (player.getLocation().getRegionY() + 6) / 8; k23++)
|
||||||
|
amt++;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Along with this, the base X and base Y of each of the region can be
|
Along with this, the base X and base Y of each of the region can be
|
||||||
calculated:
|
calculated:
|
||||||
|
|
||||||
for(int i21 = (player.getLocation().getRegionX() - 6) / 8; i21 \<=
|
```java
|
||||||
(player.getLocation().getRegionX() + 6) / 8; i21++) { for(int k23 =
|
for (int i21 = (player.getLocation().getRegionX() - 6) / 8; i21 <= (player.getLocation().getRegionX() + 6) / 8; i21++) {
|
||||||
(player.getLocation().getRegionY() - 6) / 8; k23 \<=
|
for (int k23 = (player.getLocation().getRegionY() - 6) / 8; k23 <= (player.getLocation().getRegionY() + 6) / 8; k23++)
|
||||||
(player.getLocation().getRegionY() + 6) / 8; k23++)
|
System.out.println(i21 + " X " + (i21 << 6) + "," + k23 + " Y " + (k23 << 6));;;
|
||||||
System.out.println(i21+\" X "+(i21 \<\< 6)+","+k23+" Y \"+(k23 \<\<
|
}
|
||||||
6));;; }
|
```
|
||||||
|
|
||||||
The 'X' and 'Y' coordinates represents the coordinates of the region as
|
The 'X' and 'Y' coordinates represents the coordinates of the region as
|
||||||
depicted in the diagram. After the regions are loaded they are trimmed
|
depicted in the diagram. After the regions are loaded they are trimmed
|
||||||
to the tiles that are necessary.
|
to the tiles that are necessary.
|
||||||
|
|
||||||
Well hope this gave you some idea of how regions are loaded and such,
|
## Example Location class
|
||||||
tell me if you need explanation on anything.
|
|
||||||
|
|
||||||
Heres an example of a location class that I wrote, sorry for the lack of
|
The following is an example Location class written by sinisoul.
|
||||||
comments. If you read everything then this should make sense:
|
It is not heavily commented due to it being a very simple class,
|
||||||
|
and it should be easy to follow if you read this section in full.
|
||||||
|
|
||||||
package net.forge.content.world.node; /\*\* \* RuneForge \| 317 \*
|
```java
|
||||||
Location.java \* @version 1.0.0 \* @author SiniSoul (SiniSoul\@live.com)
|
package net.forge.content.world.node;
|
||||||
\*/ public final class Location {
|
|
||||||
|
/**
|
||||||
|
* RuneForge (317)
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author SiniSoul (SiniSoul@live.com)
|
||||||
|
*/
|
||||||
|
public final class Location {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Tile X and Y coordinates.
|
* The Tile X and Y coordinates.
|
||||||
@ -128,174 +158,96 @@ Location.java \* @version 1.0.0 \* @author SiniSoul (SiniSoul\@live.com)
|
|||||||
private int chunkx = 0,
|
private int chunkx = 0,
|
||||||
chunky = 0;
|
chunky = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param tilex
|
|
||||||
*/
|
|
||||||
public void setTileX(int tilex) {
|
public void setTileX(int tilex) {
|
||||||
this.tilex = (tilex & 0xFFFF);
|
this.tilex = (tilex & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getTileX() {
|
public int getTileX() {
|
||||||
return tilex;
|
return tilex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param tilex
|
|
||||||
*/
|
|
||||||
public void setTileY(int tiley) {
|
public void setTileY(int tiley) {
|
||||||
this.tiley = (tiley & 0xFFFF);
|
this.tiley = (tiley & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getTileY() {
|
public int getTileY() {
|
||||||
return tiley;
|
return tiley;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param formatted If the chunk is formatted for map positioning or
|
||||||
* @param formated If the chunk is formatted for map positioning or
|
|
||||||
* other formatted chunk comparison.
|
* other formatted chunk comparison.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public int calculateChunkX(boolean formated) {
|
public int calculateChunkX(boolean formatted) {
|
||||||
return formated ? (getTileX() >> 3) - 6 : (getTileX() >> 3);
|
return formatted ? (getTileX() >> 3) - 6 : (getTileX() >> 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param formatted If the chunk is formatted for map positioning or
|
||||||
* @param formated If the chunk is formatted for map positioning or
|
|
||||||
* other formatted chunk comparison.
|
* other formatted chunk comparison.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public int calculateChunkY(boolean formated) {
|
public int calculateChunkY(boolean formatted) {
|
||||||
return formated ? (getTileY() >> 3) - 6 : (getTileY() >> 3);
|
return formatted ? (getTileY() >> 3) - 6 : (getTileY() >> 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void updateChunkX() {
|
public void updateChunkX() {
|
||||||
this.chunkx = calculateChunkX(true);
|
this.chunkx = calculateChunkX(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void updateChunkY() {
|
public void updateChunkY() {
|
||||||
this.chunkx = calculateChunkY(true);
|
this.chunkx = calculateChunkY(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getChunkX() {
|
public int getChunkX() {
|
||||||
return chunkx;
|
return chunkx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getMapLocalX() {
|
public int getMapLocalX() {
|
||||||
return getTileX() - (getChunkX() << 3);
|
return getTileX() - (getChunkX() << 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getChunkY() {
|
public int getChunkY() {
|
||||||
return chunky;
|
return chunky;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getMapLocalY() {
|
public int getMapLocalY() {
|
||||||
return getTileX() - (getChunkY() << 3);
|
return getTileX() - (getChunkY() << 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param height
|
|
||||||
*/
|
|
||||||
public void setHeight(int height) {
|
public void setHeight(int height) {
|
||||||
this.height = (height & 0x3);
|
this.height = (height & 0x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getRegionX() {
|
public int getRegionX() {
|
||||||
return calculateChunkX(false) >> 3;
|
return calculateChunkX(false) >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getRegionLocalX() {
|
public int getRegionLocalX() {
|
||||||
return getTileX() - (getRegionX() << 6);
|
return getTileX() - (getRegionX() << 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getRegionY() {
|
public int getRegionY() {
|
||||||
return calculateChunkY(false) >> 3;
|
return calculateChunkY(false) >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getRegionLocalY() {
|
public int getRegionLocalY() {
|
||||||
return getTileY() - (getRegionY() << 6);
|
return getTileY() - (getRegionY() << 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param tilex
|
|
||||||
* @param tiley
|
|
||||||
* @param height
|
|
||||||
*/
|
|
||||||
public void set(int tilex, int tiley, int height) {
|
public void set(int tilex, int tiley, int height) {
|
||||||
setTileX(tilex);
|
setTileX(tilex);
|
||||||
setTileY(tiley);
|
setTileY(tiley);
|
||||||
setHeight(height);
|
setHeight(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param tilex
|
|
||||||
* @param tiley
|
|
||||||
* @param height
|
|
||||||
*/
|
|
||||||
public Location(int tilex, int tiley, int height) {
|
public Location(int tilex, int tiley, int height) {
|
||||||
set(tilex, tiley, height);
|
set(tilex, tiley, height);
|
||||||
updateChunkX();
|
updateChunkX();
|
||||||
updateChunkY();
|
updateChunkY();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
16
src/Mouse-coordinate-tracking.md
Normal file
16
src/Mouse-coordinate-tracking.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Mouse coordinate tracking
|
||||||
|
|
||||||
|
There is a mechanicsm of mouse coordinate tracking within the client.
|
||||||
|
This records the `(x, y)` coordinates of the mouse, and sends them
|
||||||
|
back to the server each tick.
|
||||||
|
|
||||||
|
When the client connects with the server, after it receives
|
||||||
|
the player privilege, it receives a byte denoting whether or not
|
||||||
|
the client should send these coordinates to the server periodically.
|
||||||
|
|
||||||
|
## Packet structure
|
||||||
|
```
|
||||||
|
byte opcode = 45;
|
||||||
|
byte dummy = 0;
|
||||||
|
byte[] mouse_data;
|
||||||
|
```
|
@ -18,9 +18,11 @@
|
|||||||
- [Ondemand protocol](./Ondemand-Protocol.md)
|
- [Ondemand protocol](./Ondemand-Protocol.md)
|
||||||
- [Archive format](./Archive-Format.md)
|
- [Archive format](./Archive-Format.md)
|
||||||
- [OB3](./OB3.md)
|
- [OB3](./OB3.md)
|
||||||
- [Class-Check](./Class-Check.md)
|
- [Client functions](./Client-functions.md)
|
||||||
- [Map-Region-System](./Map-Region-System.md)
|
- [Map region system](./Map-Region-System.md)
|
||||||
- [RS-String](./RS-String.md)
|
- [Censorship](./Censorship.md)
|
||||||
|
- [Mouse coordinate tracking](./Mouse-coordinate-tracking.md)
|
||||||
|
- [Class-Check](./Class-Check.md)
|
||||||
- [Template-Packet](./Template-Packet.md)
|
- [Template-Packet](./Template-Packet.md)
|
||||||
- [135-Protocol](./135-Protocol.md)
|
- [135-Protocol](./135-Protocol.md)
|
||||||
- [194-Clear-screen](./194-Clear-screen.md)
|
- [194-Clear-screen](./194-Clear-screen.md)
|
||||||
|
BIN
src/img/map-region-system-diagram.png
Executable file
BIN
src/img/map-region-system-diagram.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
src/img/map-region-system-loading.png
Executable file
BIN
src/img/map-region-system-loading.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in New Issue
Block a user