UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

156 lines (155 loc) 6.86 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReplayOptions = exports.ReplayMode = exports.ReplayError = exports.IS_RIP = void 0; var decorators_1 = require("../decorators"); var base_1 = require("./base"); var enums_1 = require("./enums"); var 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) */ var IS_RIP = /** @class */ (function (_super) { __extends(IS_RIP, _super); function IS_RIP(data) { var _this = _super.call(this) || this; _this.Size = 80; _this.Type = enums_1.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); return _this; } IS_RIP.prototype.pack = function () { if (this.ReqI === 0) { throw new RangeError('IS_RIP - ReqI must be greater than 0'); } return _super.prototype.pack.call(this); }; __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "Error", void 0); __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "MPR", void 0); __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "Paused", void 0); __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "Options", void 0); __decorate([ (0, decorators_1.byte)() ], IS_RIP.prototype, "Sp3", void 0); __decorate([ (0, decorators_1.unsigned)() ], IS_RIP.prototype, "CTime", void 0); __decorate([ (0, decorators_1.unsigned)() ], IS_RIP.prototype, "TTime", void 0); __decorate([ (0, decorators_1.stringNull)(RNAME_MAX_LENGTH) ], IS_RIP.prototype, "RName", void 0); return IS_RIP; }(base_1.SendablePacket)); exports.IS_RIP = IS_RIP; 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 || (exports.ReplayError = ReplayError = {})); var ReplayMode; (function (ReplayMode) { /** Single player replay */ ReplayMode[ReplayMode["SPR"] = 0] = "SPR"; /** Multiplayer replay */ ReplayMode[ReplayMode["MPR"] = 1] = "MPR"; })(ReplayMode || (exports.ReplayMode = ReplayMode = {})); 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 || (exports.ReplayOptions = ReplayOptions = {}));