Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rs-runec"
version = "0.7.5"
version = "0.7.6"
edition = "2024"
rust-version = "1.95.0"
authors = ["Tyler Telis <xlitersps@gmail.com>", "RustCityRS <https://github.com/RustCityRS>"]
Expand Down
21 changes: 21 additions & 0 deletions src/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@ opcodes! {
GETSOFTTIMER = 2190 => "getsofttimer";
CAM_FORCEANGLE = 2191 => "cam_forceangle";
SOUND_VORBIS = 2192 => "sound_vorbis";
// 647 (2011): the Grand Exchange. The reads take the client's own names
// (its clientscript commands 3903-3913); buy, sell, abort, the guide
// price and the history are this compiler's, as no source names them.
STOCKMARKET_BUY = 2193 => "stockmarket_buy";
STOCKMARKET_SELL = 2194 => "stockmarket_sell";
STOCKMARKET_ABORT = 2195 => "stockmarket_abort";
STOCKMARKET_GETOFFERTYPE = 2196 => "stockmarket_getoffertype";
STOCKMARKET_GETOFFERITEM = 2197 => "stockmarket_getofferitem";
STOCKMARKET_GETOFFERPRICE = 2198 => "stockmarket_getofferprice";
STOCKMARKET_GETOFFERCOUNT = 2199 => "stockmarket_getoffercount";
STOCKMARKET_GETOFFERCOMPLETEDCOUNT = 2200 => "stockmarket_getoffercompletedcount";
STOCKMARKET_GETOFFERCOMPLETEDGOLD = 2201 => "stockmarket_getoffercompletedgold";
STOCKMARKET_ISOFFEREMPTY = 2202 => "stockmarket_isofferempty";
STOCKMARKET_ISOFFERSTABLE = 2203 => "stockmarket_isofferstable";
STOCKMARKET_ISOFFERADDING = 2204 => "stockmarket_isofferadding";
STOCKMARKET_ISOFFERFINISHED = 2205 => "stockmarket_isofferfinished";
STOCKMARKET_GUIDEPRICE = 2206 => "stockmarket_guideprice";
STOCKMARKET_GETHISTORYTYPE = 2207 => "stockmarket_gethistorytype";
STOCKMARKET_GETHISTORYITEM = 2208 => "stockmarket_gethistoryitem";
STOCKMARKET_GETHISTORYCOUNT = 2209 => "stockmarket_gethistorycount";
STOCKMARKET_GETHISTORYGOLD = 2210 => "stockmarket_gethistorygold";

// Npc
NPC_ADD = 2500 => "npc_add";
Expand Down
17 changes: 17 additions & 0 deletions src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,23 @@ fn build_command_pointers() -> HashMap<String, PointerHolder> {
"sound_speech_volume",
"sound_speech_stop",
"stat_total",
"stockmarket_buy",
"stockmarket_sell",
"stockmarket_abort",
"stockmarket_getoffertype",
"stockmarket_getofferitem",
"stockmarket_getofferprice",
"stockmarket_getoffercount",
"stockmarket_getoffercompletedcount",
"stockmarket_getoffercompletedgold",
"stockmarket_isofferempty",
"stockmarket_isofferstable",
"stockmarket_isofferadding",
"stockmarket_isofferfinished",
"stockmarket_gethistorytype",
"stockmarket_gethistoryitem",
"stockmarket_gethistorycount",
"stockmarket_gethistorygold",
"wealth_event",
] {
add(name, &[ActivePlayer], &[], &[], &[], &[], &[], false);
Expand Down
31 changes: 31 additions & 0 deletions tests/server_pointer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ fn project(check_pointers: bool) -> Project {
("p_objdialog", vec![], vec![]),
("p_hsldialog", vec![], vec![]),
("last_coord", vec![], vec![Coord]),
("stockmarket_buy", vec![Int, Obj, Int, Int], vec![]),
("stockmarket_abort", vec![Int], vec![]),
("stockmarket_isofferstable", vec![Int], vec![Boolean]),
("stockmarket_gethistorygold", vec![Int], vec![Int]),
("stockmarket_guideprice", vec![Obj], vec![Int]),
];
for (opcode, (name, params, returns)) in commands.into_iter().enumerate() {
registry.register_command(name.into(), 1000 + opcode as i32, params, returns);
Expand Down Expand Up @@ -140,6 +145,32 @@ fn entity_commands_require_the_selected_player() {
}
}

/// The Grand Exchange's commands act on a player's own offers and history; its
/// guide price is the world's.
#[test]
fn stockmarket_commands_require_the_selected_player_but_not_the_guide_price() {
for command in [
"stockmarket_buy(0, weapon, 1, 100)",
"stockmarket_abort(0)",
"def_boolean $b = stockmarket_isofferstable(0)",
"def_int $i = stockmarket_gethistorygold(0)",
] {
for dot in ["", "."] {
let command = command.replacen("stockmarket", &format!("{dot}stockmarket"), 1);
let text = format!("[ai_timer,_]\n{command};\n");
let warnings = pointer_warnings(&text);
assert!(
warnings
.iter()
.any(|warning| warning.contains(&format!("{dot}active_player"))),
"{text}: {warnings:?}"
);
}
}
let warnings = pointer_warnings("[ai_timer,_]\ndef_int $i = stockmarket_guideprice(weapon);\n");
assert!(warnings.is_empty(), "{warnings:?}");
}

#[test]
fn load_delay_requires_protected_player_access() {
let warnings = pointer_warnings("[ai_timer,_]\np_loaddelay;\n");
Expand Down