mirror of
https://github.com/moparisthebest/rswiki-book
synced 2024-11-22 00:52:15 -05:00
370 lines
8.3 KiB
Plaintext
370 lines
8.3 KiB
Plaintext
[[Category RSC]]
|
|
This page refers to the RSC #135 client revision.
|
|
|
|
|
|
== '''Packet structure''' ==
|
|
?
|
|
|
|
== '''Login''' ==
|
|
?
|
|
|
|
== '''Reference''' ==
|
|
Player usernames are encoded and decoded as a long with the following methods:
|
|
<pre>
|
|
public static long encode_37(String s) {
|
|
String s1 = "";
|
|
for (int i = 0; i < s.length(); i++) {
|
|
char c = s.charAt(i);
|
|
if (c >= 'a' && c <= 'z')
|
|
s1 = s1 + c;
|
|
else if (c >= 'A' && c <= 'Z')
|
|
s1 = s1 + (char) ((c + 97) - 65);
|
|
else if (c >= '0' && c <= '9')
|
|
s1 = s1 + c;
|
|
else
|
|
s1 = s1 + ' ';
|
|
}
|
|
s1 = s1.trim();
|
|
if (s1.length() > 12)
|
|
s1 = s1.substring(0, 12);
|
|
long l = 0L;
|
|
for (int j = 0; j < s1.length(); j++) {
|
|
char c1 = s1.charAt(j);
|
|
l *= 37L;
|
|
if (c1 >= 'a' && c1 <= 'z')
|
|
l += (1 + c1) - 97;
|
|
else if (c1 >= '0' && c1 <= '9')
|
|
l += (27 + c1) - 48;
|
|
}
|
|
return l;
|
|
}
|
|
|
|
public static String decode_37(long l) {
|
|
String s = "";
|
|
while (l != 0L) {
|
|
int i = (int) (l % 37L);
|
|
l /= 37L;
|
|
if (i == 0) {
|
|
s = " " + s;
|
|
} else if (i < 27) {
|
|
if (l % 37L == 0L)
|
|
s = (char) ((i + 65) - 1) + s;
|
|
else
|
|
s = (char) ((i + 97) - 1) + s;
|
|
} else {
|
|
s = (char) ((i + 48) - 27) + s;
|
|
}
|
|
}
|
|
return s;
|
|
}
|
|
</pre>
|
|
|
|
== '''Packets''' ==
|
|
The packet opcodes are unchanged from previous revisions, presumably this was before the protocol was being regularly modified to deter the developers of bots such as [[AutoRune]]. The payload/structure is quite similar to most other RSC revisions. Some 135 packets are documented ahead. First you will find the packets' body, then you will find a table (for easier reading)
|
|
|
|
=== '''Incoming Data''' ===
|
|
'''TODO:'''
|
|
<pre>
|
|
</pre>
|
|
|
|
=== '''Outgoing Data''' ===
|
|
<pre>
|
|
(ns rsc.rsc135.packets
|
|
(:require [jagex.Util])
|
|
(:use [jagex.client.SocketStream]))
|
|
|
|
;; Opcode: 1
|
|
(defn disconnect [stream]
|
|
(doto stream
|
|
(.begin-packet1)
|
|
(.flush)))
|
|
|
|
;; Opcode: 2
|
|
(defn newplayer [stream]
|
|
(doto stream
|
|
(.begin-packet 2)
|
|
(.put-int16 revisionid)
|
|
(.put-int64 (Util/long-for-name username))
|
|
(.put-int16 referrerid)
|
|
(.putline-rsa password server-session-id key-a key-b) ; keys for RSA?
|
|
(.flush)
|
|
(.read) ; newplayer response
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 6
|
|
(defn logout [stream]
|
|
(doto stream
|
|
(.begin-packet 6)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 7
|
|
(defn send-command [stream command] ; sends command to server e.g ::home, command arg is (.substring command 2)
|
|
(doto stream
|
|
(.begin-packet 7)
|
|
(.putline command)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 10
|
|
(defn report-abuse [stream username]
|
|
(let [name (.substring username 12)
|
|
l5 (Util/long-for-name name)]
|
|
(doto stream
|
|
(.begin-packet 10)
|
|
(.put-int64 l5)
|
|
(.end-packet))))
|
|
|
|
;; Opcode: 26
|
|
(defn add-friend [stream name] ; name is string represenation of username
|
|
(doto stream
|
|
(.begin-packet 26)
|
|
(.put-int64 (Util/long-for-name name)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 27
|
|
(defn remove-friend [stream name] ; name is long represenation of username (i.e Util/long-for-name username)
|
|
(doto stream
|
|
(.begin-packet 27)
|
|
(.put-int64 name)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 28
|
|
;; name is long representation of username, message is byte representation of message (.getBytes message), length is length of message (maximum length is 200)
|
|
(defn send-message [stream name message length]
|
|
(doto stream
|
|
(.begin-packet 28)
|
|
(.put-int64 username)
|
|
(.read-bytes message 0 length)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 29
|
|
(defn add-ignore [stream username] ; username is string representation of username
|
|
(let [name (Util/long-for-name username)]
|
|
(doto stream
|
|
(.begin-packet 29)
|
|
(.put-int64 name)
|
|
(.end-packet))))
|
|
|
|
;; Opcode: 251
|
|
(defn drop-item [stream slot]
|
|
(doto stream
|
|
(.begin-packet 251)
|
|
(.put-int16 slot)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 220
|
|
(defn cast-inv [stream slot spell]
|
|
(doto stream
|
|
(.begin-packet 220)
|
|
(.put-int16 slot)
|
|
(.put-int16 spell)
|
|
(.end-packet)))
|
|
|
|
|
|
;; Opcode: 240
|
|
(defn use2-items [stream slot1 slot2]
|
|
(doto stream
|
|
(.begin-packet 240)
|
|
(.put-int16 slot1)
|
|
(.put-int16 slot2)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 248
|
|
(defn remove-item [stream slot]
|
|
(doto stream
|
|
(.begin-packet 248)
|
|
(.put-int16 slot)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 249
|
|
(defn equip-item [stream slot]
|
|
(doto stream
|
|
(.begin-packet 249)
|
|
(.put-int16 slot)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 246
|
|
(defn item-cmd [stream slot]
|
|
(doto stream
|
|
(.begin-packet 246)
|
|
(.put-int16 slot)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 237
|
|
(defn dialog-select [stream index]
|
|
(doto stream
|
|
(.begin-packet 237)
|
|
(.put-int8 index)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 231
|
|
(defn combat-select [stream index]
|
|
(doto stream
|
|
(.begin-packet 231)
|
|
(.put-int8 index)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 207
|
|
(defn closebank [stream]
|
|
(doto stream
|
|
(.begin-packet 207)
|
|
(.end-packet)))
|
|
|
|
|
|
;; Opcode: 206
|
|
(defn withdraw [stream id amount]
|
|
(doto stream
|
|
(.begin-packet 206)
|
|
(.put-int16 id)
|
|
(.put-int16 amount)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 205
|
|
(defn deposit [stream id amount]
|
|
(doto stream
|
|
(.begin-packet 205)
|
|
(.put-int16 id)
|
|
(.put-int16 amount)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 211
|
|
(defn prayer-off [stream id]
|
|
(doto stream
|
|
(.begin-packet 211)
|
|
(.put-int8 id)
|
|
(.end-packet)))
|
|
|
|
;; Opcode: 212
|
|
(defn prayer-on [stream id]
|
|
(doto stream
|
|
(.begin-packet 212)
|
|
(.put-int8 id)
|
|
(.end-packet)))
|
|
</pre>
|
|
|
|
{| class="wikitable"
|
|
|+ Outgoing Packets
|
|
|-
|
|
! Name
|
|
! Opcode
|
|
! Payload
|
|
! Description
|
|
|-
|
|
! Disconnect
|
|
| 1 ||
|
|
* None
|
|
| Sends the disconnect packet
|
|
|-
|
|
! Newplayer (Registration)
|
|
| 2 ||
|
|
* Short - The client revision number (135)
|
|
* Long - Long represenation of username
|
|
* Short - Referrer ID
|
|
** Integer.parseInt(getParameter("referrerid"));
|
|
* Line-RSA - Password, server session ID, bigintegers
|
|
| Registers a new user (probably not used in private servers)
|
|
|-
|
|
! Logout
|
|
| 6 ||
|
|
* None
|
|
| Sends the logout packet to the server
|
|
|-
|
|
! Execute Command
|
|
| 7 ||
|
|
* String - The command
|
|
| Sends a command to the server to be executed
|
|
|-
|
|
! Report Abuse
|
|
| 10 ||
|
|
* Long - The long representation of the username of the user to report
|
|
| Sends an abuse report to the server
|
|
|-
|
|
! Add Friend
|
|
| 26 ||
|
|
* Long - long represenation of username
|
|
| Adds a user to your friends list
|
|
|-
|
|
! Remove Friend
|
|
| 27 ||
|
|
* Long - The long representation of the username of the user to report
|
|
| Removes a user from your friends list
|
|
|-
|
|
! Send Message
|
|
| 28 ||
|
|
* Long - The long representation of the username of the user to send the message to
|
|
* Byte[] - A byte array containing the bytes of the message to send to the user
|
|
| Sends a message to the specified user
|
|
|-
|
|
! Ignore User
|
|
| 29 ||
|
|
* Long - The long representation of the username of the user to ignore
|
|
| Adds a user to your ignore list
|
|
|-
|
|
! Drop Item
|
|
| 251 ||
|
|
* Short - The slot of the item to drop
|
|
| Drops the specified item on the ground
|
|
|-
|
|
! Cast on Inventory
|
|
| 220 ||
|
|
* Short - The slot of the item to cast a spell on
|
|
* Short - The id of the spell to cast
|
|
| Casts a spell (such as High Alchemy) on the specified item
|
|
|-
|
|
! Use Two Inventory Items
|
|
| 240 ||
|
|
* Short - The slot of the first item to use
|
|
* Short - The slot of the second item to use
|
|
| Uses an item in the player's inventory with another item in the player's inventory
|
|
|-
|
|
! Remove Item
|
|
| 248 ||
|
|
* Short - The slot of the item to unequip
|
|
| Unequips the specified item
|
|
|-
|
|
! Wear Item
|
|
| 249 ||
|
|
* Short - The slot of the item to equip
|
|
| Equips the specified item
|
|
|-
|
|
! Inventory Command
|
|
| 246 ||
|
|
* Short - The slot of the item to use
|
|
| Burys, eats, etc the specified item
|
|
|-
|
|
! Select Option
|
|
| 237 ||
|
|
* Byte - The position of the option in the dialog_options array
|
|
| Selects an option in a dialog (dialog referring to, for example, the menu displayed when certing)
|
|
|-
|
|
! Select Combat Style
|
|
| 231 ||
|
|
* Byte - The position of the combat style in the list
|
|
| Selects the player's combat style. * 0 - Controlled * 1 - Aggressive * 2 - Accurate * 3 - Defensive
|
|
|-
|
|
! Close Bank
|
|
| 207 ||
|
|
* None
|
|
| Informs the server that the player has closed the banking interface.
|
|
|-
|
|
! Withdraw Item
|
|
| 206 ||
|
|
* Short - The ID of the item to withdraw
|
|
* Short - The amount of the specified item to withdraw
|
|
| Withdraws a single type of item from the player's bank.
|
|
|-
|
|
! Deposit Item
|
|
| 205 ||
|
|
* Short - The ID of the item to deposit
|
|
* Short - The amount of the specified item to deposit
|
|
| Deposits a single type of item into the player's bank.
|
|
|-
|
|
! Disable Prayer
|
|
| 211 ||
|
|
* Byte - The ID of the prayer to disable
|
|
| Disables a prayer.
|
|
|-
|
|
! Enable Prayer
|
|
| 212 ||
|
|
* Byte - The ID of the prayer to enable
|
|
| Enables a prayer.
|
|
|} |