Skip to content

Commit

Permalink
Merge pull request runejs#360 from Kikorono/develop
Browse files Browse the repository at this point in the history
Fix item on item interaction pipeline and adding a variable to disable XTEA checks.
  • Loading branch information
SchauweM authored Nov 26, 2021
2 parents bb4f096 + 6293d3a commit 4f7fc38
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
1 change: 1 addition & 0 deletions config/server-config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"loginServerPort": 43591,
"rsaMod": "119568088839203297999728368933573315070738693395974011872885408638642676871679245723887367232256427712869170521351089799352546294030059890127723509653145359924771433131004387212857375068629466435244653901851504845054452735390701003613803443469723435116497545687393297329052988014281948392136928774011011998343",
"rsaExp": "12747337179295870166838611986189126026507945904720545965726999254744592875817063488911622974072289858092633084100280214658532446654378876853112046049506789703022033047774294965255097838909779899992870910011426403494610880634275141204442441976355383839981584149269550057129306515912021704593400378690444280161",
"encryptionEnabled": true,
"playerSavePath": "./data/saves",

"showWelcome": true,
Expand Down
18 changes: 13 additions & 5 deletions src/engine/action/pipe/item-on-item.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,19 @@ const itemOnItemActionPipe = (player: Player, usedItem: Item, usedSlot: number,
}

// Find all item on item action plugins that match this action
let matchingHooks = getActionHooks<ItemOnItemActionHook>('item_on_item').filter(plugin =>
questHookFilter(player, plugin) &&
(plugin.items.findIndex(i => i.item1 === usedItem.itemId && i.item2 === usedWithItem.itemId) !== -1 ||
plugin.items.findIndex(i => i.item2 === usedItem.itemId && i.item1 === usedWithItem.itemId) !== -1 ||
plugin.items.findIndex(i => i.item1 === usedItem.itemId && !i.item2 || i.item1 === usedWithItem.itemId && !i.item2 ) !== -1));
let matchingHooks = getActionHooks<ItemOnItemActionHook>('item_on_item', plugin => {
if(questHookFilter(player, plugin)) {
const used = usedItem.itemId;
const usedWith = usedWithItem.itemId;

return (plugin.items.some(({ item1, item2 }) => {
const items = [ item1, item2 ];
return items.includes(used) && items.includes(usedWith);
}));
}

return false;
});

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

Expand Down
3 changes: 2 additions & 1 deletion src/engine/net/inbound-packets/item-on-item.packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const itemOnItemPacket = (player: Player, packet: PacketData) => {
return;
}

player.actionPipeline.call('item_on_item', player, usedItem, usedSlot, usedWidgetId, usedWithItem, usedWithSlot, usedWithWidgetId);
player.actionPipeline.call('item_on_item',
player, usedItem, usedSlot, usedWidgetId, usedWithItem, usedWithSlot, usedWithWidgetId);
} else {
logger.warn(`Unhandled item on item case using widgets ${usedWidgetId}:${usedContainerId} => ${usedWithWidgetId}:${usedWithContainerId}`);
}
Expand Down
30 changes: 16 additions & 14 deletions src/engine/net/outbound-packet-handler.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { Player, SidebarTab } from '../world/actor/player/player';
import { Socket } from 'net';
import { Packet, PacketType } from '@engine/net/packet';
import { ItemContainer } from '@engine/world/items/item-container';
import { Item } from '@engine/world/items/item';
import { Position } from '@engine/world/position';
import { Chunk, ChunkUpdateItem } from '@engine/world/map/chunk';
import { WorldItem } from '@engine/world/items/world-item';
import { ByteBuffer } from '@runejs/core/buffer';
import { Npc } from '@engine/world/actor/npc';
import { stringToLong } from '@engine/util/strings';
import { LandscapeObject } from '@runejs/filestore';
import { xteaRegions } from '@engine/config/config-handler';
import { ConstructedChunk, ConstructedRegion } from '@engine/world/map/region';
import { ByteBuffer } from '@runejs/core/buffer';

import { serverConfig } from '@server/game';
import { Packet, PacketType } from '@engine/net';
import { xteaRegions } from '@engine/config';
import { activeWorld } from '@engine/world';
import { stringToLong } from '@engine/util';
import { ChunkUpdateItem, Position } from '@engine/world';
import { Player, SidebarTab, Npc } from '@engine/world/actor';
import { ItemContainer, Item, WorldItem } from '@engine/world/items';
import { Chunk, ConstructedChunk, ConstructedRegion } from '@engine/world/map';



Expand Down Expand Up @@ -643,12 +641,14 @@ export class OutboundPacketHandler {

packet.closeBitBuffer();

const encryptionEnabled = serverConfig.encryptionEnabled === undefined ? true : serverConfig.encryptionEnabled;

// Put the xtea keys for the two construction room template maps
// Map coords: 29,79 && 30,79
for(let mapX = 29; mapX <= 30; mapX++) {
const xteaRegion = xteaRegions[`l${mapX}_79`];
for(let seeds = 0; seeds < 4; seeds++) {
packet.put(xteaRegion?.key[seeds] || 0, 'int');
packet.put(encryptionEnabled ? (xteaRegion?.key[seeds] ?? 0) : 0, 'int');
}
}

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

const encryptionEnabled = serverConfig.encryptionEnabled === undefined ? true : serverConfig.encryptionEnabled;

for(let mapX = startX; mapX <= endX; mapX++) {
for(let mapY = startY; mapY <= endY; mapY++) {
const xteaRegion = xteaRegions[`l${mapX}_${mapY}`];
for(let seeds = 0; seeds < 4; seeds++) {
packet.put(xteaRegion?.key[seeds] || 0, 'int');
packet.put(encryptionEnabled ? (xteaRegion?.key[seeds] ?? 0) : 0, 'int');
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/server/game/game-server-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface GameServerConfig {
rsaExp: string;
host: string;
port: number;
encryptionEnabled: boolean;
loginServerHost: string;
loginServerPort: number;
updateServerHost: string;
Expand Down

0 comments on commit 4f7fc38

Please sign in to comment.