UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

129 lines (128 loc) 4.82 kB
import { __decorate } from "tslib"; import { byte, stringNull, unsigned } from '../decorators'; import { SendablePacket } from './base'; import { PacketType } from './enums'; const RNAME_MAX_LENGTH = 64; /** * Replay Information Packet * * You can load a replay or set the position in a replay with an IS_RIP packet. Replay positions and lengths are * specified in milliseconds. LFS will reply with another IS_RIP packet when the request is completed. * * You can request an IS_RIP packet at any time with this {@link IS_TINY}: * * - ReqI: non-zero (returned in the reply) * - SubT: {@link TINY_RIP} (Replay Information Packet) */ export class IS_RIP extends SendablePacket { constructor(data) { super(); this.Size = 80; this.Type = PacketType.ISP_RIP; /** Request: non-zero / reply: same value returned */ this.ReqI = 0; /** 0 or 1 = OK / for other values see {@link ReplayError} */ this.Error = 0; /** 0 = SPR / 1 = MPR */ this.MPR = 0; /** Request: pause on arrival / reply: paused state */ this.Paused = 0; /** * Various options. * * NOTE: {@link RIPOPT_FULL_PHYS} makes MPR searching much slower so should not normally be used. This flag was added * to allow high accuracy {@link IS_MCI} packets to be output when fast forwarding. * */ this.Options = 0; this.Sp3 = 0; /** (milliseconds) request: destination / reply: position */ this.CTime = 0; /** (milliseconds) request: zero / reply: replay length */ this.TTime = 0; /** Zero or replay name - last byte must be zero */ this.RName = ''; this.initialize(data); } pack() { if (this.ReqI === 0) { throw new RangeError('IS_RIP - ReqI must be greater than 0'); } return super.pack(); } } __decorate([ byte() ], IS_RIP.prototype, "Size", void 0); __decorate([ byte() ], IS_RIP.prototype, "Type", void 0); __decorate([ byte() ], IS_RIP.prototype, "ReqI", void 0); __decorate([ byte() ], IS_RIP.prototype, "Error", void 0); __decorate([ byte() ], IS_RIP.prototype, "MPR", void 0); __decorate([ byte() ], IS_RIP.prototype, "Paused", void 0); __decorate([ byte() ], IS_RIP.prototype, "Options", void 0); __decorate([ byte() ], IS_RIP.prototype, "Sp3", void 0); __decorate([ unsigned() ], IS_RIP.prototype, "CTime", void 0); __decorate([ unsigned() ], IS_RIP.prototype, "TTime", void 0); __decorate([ stringNull(RNAME_MAX_LENGTH) ], IS_RIP.prototype, "RName", void 0); export var ReplayError; (function (ReplayError) { /** OK: completed instruction */ ReplayError[ReplayError["RIP_OK"] = 0] = "RIP_OK"; /** OK: already at the destination */ ReplayError[ReplayError["RIP_ALREADY"] = 1] = "RIP_ALREADY"; /** Can't run a replay - dedicated host */ ReplayError[ReplayError["RIP_DEDICATED"] = 2] = "RIP_DEDICATED"; /** Can't start a replay - not in a suitable mode */ ReplayError[ReplayError["RIP_WRONG_MODE"] = 3] = "RIP_WRONG_MODE"; /** RName is zero but no replay is currently loaded */ ReplayError[ReplayError["RIP_NOT_REPLAY"] = 4] = "RIP_NOT_REPLAY"; /** {@link IS_RIP} corrupted (e.g. RName does not end with zero) */ ReplayError[ReplayError["RIP_CORRUPTED"] = 5] = "RIP_CORRUPTED"; /** The replay file was not found */ ReplayError[ReplayError["RIP_NOT_FOUND"] = 6] = "RIP_NOT_FOUND"; /** Obsolete / future / corrupted */ ReplayError[ReplayError["RIP_UNLOADABLE"] = 7] = "RIP_UNLOADABLE"; /** Destination is beyond replay length */ ReplayError[ReplayError["RIP_DEST_OOB"] = 8] = "RIP_DEST_OOB"; /** Unknown error found starting replay */ ReplayError[ReplayError["RIP_UNKNOWN"] = 9] = "RIP_UNKNOWN"; /** Replay search was terminated by user */ ReplayError[ReplayError["RIP_USER"] = 10] = "RIP_USER"; /** Can't reach destination - SPR is out of sync */ ReplayError[ReplayError["RIP_OOS"] = 11] = "RIP_OOS"; })(ReplayError || (ReplayError = {})); export var ReplayMode; (function (ReplayMode) { /** Single player replay */ ReplayMode[ReplayMode["SPR"] = 0] = "SPR"; /** Multiplayer replay */ ReplayMode[ReplayMode["MPR"] = 1] = "MPR"; })(ReplayMode || (ReplayMode = {})); export var ReplayOptions; (function (ReplayOptions) { /** Replay will loop if this bit is set */ ReplayOptions[ReplayOptions["RIPOPT_LOOP"] = 1] = "RIPOPT_LOOP"; /** Set this bit to download missing skins */ ReplayOptions[ReplayOptions["RIPOPT_SKINS"] = 2] = "RIPOPT_SKINS"; /** Use full physics when searching an MPR */ ReplayOptions[ReplayOptions["RIPOPT_FULL_PHYS"] = 4] = "RIPOPT_FULL_PHYS"; })(ReplayOptions || (ReplayOptions = {}));