@rpgjs/server 5.0.0-alpha.13 → 5.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,21 @@ import { MockConnection, RoomOnJoin } from '@signe/room';
2
2
  import { Hooks, RpgCommonMap, ZoneData, WorldMapsManager, WorldMapConfig } from '@rpgjs/common';
3
3
  import { RpgPlayer, RpgEvent } from '../Player/Player';
4
4
  import { BehaviorSubject } from 'rxjs';
5
+ /**
6
+ * Interface for input controls configuration
7
+ *
8
+ * Defines the structure for input validation and anti-cheat controls
9
+ */
10
+ export interface Controls {
11
+ /** Maximum allowed time delta between inputs in milliseconds */
12
+ maxTimeDelta?: number;
13
+ /** Maximum allowed frame delta between inputs */
14
+ maxFrameDelta?: number;
15
+ /** Minimum time between inputs in milliseconds */
16
+ minTimeBetweenInputs?: number;
17
+ /** Whether to enable anti-cheat validation */
18
+ enableAntiCheat?: boolean;
19
+ }
5
20
  /**
6
21
  * Interface representing hook methods available for map events
7
22
  *
@@ -48,7 +63,10 @@ export declare class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoi
48
63
  dataIsReady$: BehaviorSubject<void>;
49
64
  globalConfig: any;
50
65
  damageFormulas: any;
66
+ constructor();
67
+ interceptorPacket(player: RpgPlayer, packet: any, conn: MockConnection): any;
51
68
  onJoin(player: RpgPlayer, conn: MockConnection): void;
69
+ onLeave(player: RpgPlayer, conn: MockConnection): void;
52
70
  get hooks(): Hooks;
53
71
  get widthPx(): number;
54
72
  get heightPx(): number;
@@ -74,6 +92,39 @@ export declare class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoi
74
92
  * - WorldMapConfig[]
75
93
  */
76
94
  updateWorld(request: Request): Promise<any>;
95
+ /**
96
+ * Process pending inputs for a player with anti-cheat validation
97
+ *
98
+ * This method processes all pending inputs for a player while performing
99
+ * anti-cheat validation to prevent time manipulation and frame skipping.
100
+ * It validates the time deltas between inputs and ensures they are within
101
+ * acceptable ranges. After processing, it saves the last frame position
102
+ * for use in packet interception.
103
+ *
104
+ * @param playerId - The ID of the player to process inputs for
105
+ * @param controls - Optional anti-cheat configuration
106
+ * @returns Promise containing the player and processed input strings
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * // Process inputs with default anti-cheat settings
111
+ * const result = await map.processInput('player1');
112
+ * console.log('Processed inputs:', result.inputs);
113
+ *
114
+ * // Process inputs with custom anti-cheat configuration
115
+ * const result = await map.processInput('player1', {
116
+ * maxTimeDelta: 100,
117
+ * maxFrameDelta: 5,
118
+ * minTimeBetweenInputs: 16,
119
+ * enableAntiCheat: true
120
+ * });
121
+ * ```
122
+ */
123
+ processInput(playerId: string, controls?: Controls): Promise<{
124
+ player: RpgPlayer;
125
+ inputs: string[];
126
+ }>;
127
+ private loop;
77
128
  /**
78
129
  * Get a world manager by id (if multiple supported in future)
79
130
  */
@@ -135,6 +186,7 @@ export declare class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoi
135
186
  createDynamicEvent(eventObj: EventPosOption): Promise<void>;
136
187
  getEvent<T extends RpgPlayer>(eventId: string): T | undefined;
137
188
  getPlayer(playerId: string): RpgPlayer | undefined;
189
+ getPlayers(): RpgPlayer[];
138
190
  getEvents(): RpgEvent[];
139
191
  getEventBy(cb: (event: RpgEvent) => boolean): RpgEvent | undefined;
140
192
  getEventsBy(cb: (event: RpgEvent) => boolean): RpgEvent[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpgjs/server",
3
- "version": "5.0.0-alpha.13",
3
+ "version": "5.0.0-alpha.15",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "publishConfig": {
@@ -11,16 +11,18 @@
11
11
  "license": "MIT",
12
12
  "description": "",
13
13
  "dependencies": {
14
- "@rpgjs/common": "5.0.0-alpha.13",
14
+ "@rpgjs/common": "5.0.0-alpha.15",
15
+ "@rpgjs/physic": "5.0.0-alpha.15",
15
16
  "@rpgjs/database": "^4.3.0",
16
- "@signe/di": "^2.4.5",
17
- "@signe/reactive": "^2.4.5",
18
- "@signe/room": "^2.4.5",
19
- "@signe/sync": "^2.4.5",
20
- "rxjs": "^7.8.2"
17
+ "@signe/di": "^2.4.6",
18
+ "@signe/reactive": "^2.4.6",
19
+ "@signe/room": "^2.4.6",
20
+ "@signe/sync": "^2.4.6",
21
+ "rxjs": "^7.8.2",
22
+ "zod": "^4.0.17"
21
23
  },
22
24
  "devDependencies": {
23
- "vite": "^7.1.1",
25
+ "vite": "^7.1.2",
24
26
  "vite-plugin-dts": "^4.5.4"
25
27
  },
26
28
  "type": "module",