Skip to content

Commit 4f7fc38

Browse files
authored
Merge pull request #360 from Kikorono/develop
Fix item on item interaction pipeline and adding a variable to disable XTEA checks.
2 parents bb4f096 + 6293d3a commit 4f7fc38

File tree

5 files changed

+33
-20
lines changed

5 files changed

+33
-20
lines changed

config/server-config.example.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"loginServerPort": 43591,
1313
"rsaMod": "119568088839203297999728368933573315070738693395974011872885408638642676871679245723887367232256427712869170521351089799352546294030059890127723509653145359924771433131004387212857375068629466435244653901851504845054452735390701003613803443469723435116497545687393297329052988014281948392136928774011011998343",
1414
"rsaExp": "12747337179295870166838611986189126026507945904720545965726999254744592875817063488911622974072289858092633084100280214658532446654378876853112046049506789703022033047774294965255097838909779899992870910011426403494610880634275141204442441976355383839981584149269550057129306515912021704593400378690444280161",
15+
"encryptionEnabled": true,
1516
"playerSavePath": "./data/saves",
1617

1718
"showWelcome": true,

src/engine/action/pipe/item-on-item.action.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ const itemOnItemActionPipe = (player: Player, usedItem: Item, usedSlot: number,
5656
}
5757

5858
// Find all item on item action plugins that match this action
59-
let matchingHooks = getActionHooks<ItemOnItemActionHook>('item_on_item').filter(plugin =>
60-
questHookFilter(player, plugin) &&
61-
(plugin.items.findIndex(i => i.item1 === usedItem.itemId && i.item2 === usedWithItem.itemId) !== -1 ||
62-
plugin.items.findIndex(i => i.item2 === usedItem.itemId && i.item1 === usedWithItem.itemId) !== -1 ||
63-
plugin.items.findIndex(i => i.item1 === usedItem.itemId && !i.item2 || i.item1 === usedWithItem.itemId && !i.item2 ) !== -1));
59+
let matchingHooks = getActionHooks<ItemOnItemActionHook>('item_on_item', plugin => {
60+
if(questHookFilter(player, plugin)) {
61+
const used = usedItem.itemId;
62+
const usedWith = usedWithItem.itemId;
63+
64+
return (plugin.items.some(({ item1, item2 }) => {
65+
const items = [ item1, item2 ];
66+
return items.includes(used) && items.includes(usedWith);
67+
}));
68+
}
69+
70+
return false;
71+
});
6472

6573
const questActions = matchingHooks.filter(plugin => plugin.questRequirement !== undefined);
6674

src/engine/net/inbound-packets/item-on-item.packet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const itemOnItemPacket = (player: Player, packet: PacketData) => {
3030
return;
3131
}
3232

33-
player.actionPipeline.call('item_on_item', player, usedItem, usedSlot, usedWidgetId, usedWithItem, usedWithSlot, usedWithWidgetId);
33+
player.actionPipeline.call('item_on_item',
34+
player, usedItem, usedSlot, usedWidgetId, usedWithItem, usedWithSlot, usedWithWidgetId);
3435
} else {
3536
logger.warn(`Unhandled item on item case using widgets ${usedWidgetId}:${usedContainerId} => ${usedWithWidgetId}:${usedWithContainerId}`);
3637
}

src/engine/net/outbound-packet-handler.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { Player, SidebarTab } from '../world/actor/player/player';
21
import { Socket } from 'net';
3-
import { Packet, PacketType } from '@engine/net/packet';
4-
import { ItemContainer } from '@engine/world/items/item-container';
5-
import { Item } from '@engine/world/items/item';
6-
import { Position } from '@engine/world/position';
7-
import { Chunk, ChunkUpdateItem } from '@engine/world/map/chunk';
8-
import { WorldItem } from '@engine/world/items/world-item';
9-
import { ByteBuffer } from '@runejs/core/buffer';
10-
import { Npc } from '@engine/world/actor/npc';
11-
import { stringToLong } from '@engine/util/strings';
122
import { LandscapeObject } from '@runejs/filestore';
13-
import { xteaRegions } from '@engine/config/config-handler';
14-
import { ConstructedChunk, ConstructedRegion } from '@engine/world/map/region';
3+
import { ByteBuffer } from '@runejs/core/buffer';
4+
5+
import { serverConfig } from '@server/game';
6+
import { Packet, PacketType } from '@engine/net';
7+
import { xteaRegions } from '@engine/config';
158
import { activeWorld } from '@engine/world';
9+
import { stringToLong } from '@engine/util';
10+
import { ChunkUpdateItem, Position } from '@engine/world';
11+
import { Player, SidebarTab, Npc } from '@engine/world/actor';
12+
import { ItemContainer, Item, WorldItem } from '@engine/world/items';
13+
import { Chunk, ConstructedChunk, ConstructedRegion } from '@engine/world/map';
1614

1715

1816

@@ -643,12 +641,14 @@ export class OutboundPacketHandler {
643641

644642
packet.closeBitBuffer();
645643

644+
const encryptionEnabled = serverConfig.encryptionEnabled === undefined ? true : serverConfig.encryptionEnabled;
645+
646646
// Put the xtea keys for the two construction room template maps
647647
// Map coords: 29,79 && 30,79
648648
for(let mapX = 29; mapX <= 30; mapX++) {
649649
const xteaRegion = xteaRegions[`l${mapX}_79`];
650650
for(let seeds = 0; seeds < 4; seeds++) {
651-
packet.put(xteaRegion?.key[seeds] || 0, 'int');
651+
packet.put(encryptionEnabled ? (xteaRegion?.key[seeds] ?? 0) : 0, 'int');
652652
}
653653
}
654654

@@ -668,11 +668,13 @@ export class OutboundPacketHandler {
668668
const startY = Math.floor(this.player.position.chunkY / 8);
669669
const endY = Math.floor((this.player.position.chunkY + 12) / 8);
670670

671+
const encryptionEnabled = serverConfig.encryptionEnabled === undefined ? true : serverConfig.encryptionEnabled;
672+
671673
for(let mapX = startX; mapX <= endX; mapX++) {
672674
for(let mapY = startY; mapY <= endY; mapY++) {
673675
const xteaRegion = xteaRegions[`l${mapX}_${mapY}`];
674676
for(let seeds = 0; seeds < 4; seeds++) {
675-
packet.put(xteaRegion?.key[seeds] || 0, 'int');
677+
packet.put(encryptionEnabled ? (xteaRegion?.key[seeds] ?? 0) : 0, 'int');
676678
}
677679
}
678680
}

src/server/game/game-server-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export interface GameServerConfig {
33
rsaExp: string;
44
host: string;
55
port: number;
6+
encryptionEnabled: boolean;
67
loginServerHost: string;
78
loginServerPort: number;
89
updateServerHost: string;

0 commit comments

Comments
 (0)