node-insim
Version:
An InSim library for NodeJS with TypeScript support
177 lines (176 loc) • 7.28 kB
JavaScript
;
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.INFO_REQUEST_TINY_TYPES = exports.SENDABLE_TINY_TYPES = exports.TinyType = exports.IS_TINY = void 0;
var decorators_1 = require("../decorators");
var base_1 = require("./base");
var enums_1 = require("./enums");
/**
* General purpose 4 byte packet
*/
var IS_TINY = /** @class */ (function (_super) {
__extends(IS_TINY, _super);
function IS_TINY(data) {
var _this = _super.call(this) || this;
_this.Size = 4;
_this.Type = enums_1.PacketType.ISP_TINY;
/** 0 unless it is an info request or a reply to an info request */
_this.ReqI = 0;
/** Subtype */
_this.SubT = TinyType.TINY_NONE;
_this.initialize(data);
return _this;
}
__decorate([
(0, decorators_1.byte)()
], IS_TINY.prototype, "Size", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_TINY.prototype, "Type", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_TINY.prototype, "ReqI", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_TINY.prototype, "SubT", void 0);
return IS_TINY;
}(base_1.SendablePacket));
exports.IS_TINY = IS_TINY;
var TinyType;
(function (TinyType) {
/** Keep alive - maintain connection */
TinyType[TinyType["TINY_NONE"] = 0] = "TINY_NONE";
/** Info request: get version */
TinyType[TinyType["TINY_VER"] = 1] = "TINY_VER";
/** Instruction: close insim */
TinyType[TinyType["TINY_CLOSE"] = 2] = "TINY_CLOSE";
/** Ping request: external program requesting a reply */
TinyType[TinyType["TINY_PING"] = 3] = "TINY_PING";
/** Ping reply: reply to a ping request */
TinyType[TinyType["TINY_REPLY"] = 4] = "TINY_REPLY";
/** Both ways: game vote cancel (info or request) */
TinyType[TinyType["TINY_VTC"] = 5] = "TINY_VTC";
/** Info request: send camera position */
TinyType[TinyType["TINY_SCP"] = 6] = "TINY_SCP";
/** Info request: send state info */
TinyType[TinyType["TINY_SST"] = 7] = "TINY_SST";
/** Info request: get time in milliseconds (i.e. {@link SMALL_RTP}) */
TinyType[TinyType["TINY_GTM"] = 8] = "TINY_GTM";
/** Info: multi player end */
TinyType[TinyType["TINY_MPE"] = 9] = "TINY_MPE";
/** Info request: get multiplayer info (i.e. {@link IS_ISM}) */
TinyType[TinyType["TINY_ISM"] = 10] = "TINY_ISM";
/** Info: race end (return to race setup screen) */
TinyType[TinyType["TINY_REN"] = 11] = "TINY_REN";
/** Info: all players cleared from race */
TinyType[TinyType["TINY_CLR"] = 12] = "TINY_CLR";
/** Info request: get {@link IS_NCN} for all connections */
TinyType[TinyType["TINY_NCN"] = 13] = "TINY_NCN";
/** Info request: get all players */
TinyType[TinyType["TINY_NPL"] = 14] = "TINY_NPL";
/** Info request: get all results */
TinyType[TinyType["TINY_RES"] = 15] = "TINY_RES";
/** Info request: send an {@link IS_NLP} */
TinyType[TinyType["TINY_NLP"] = 16] = "TINY_NLP";
/** Info request: send an {@link IS_MCI} */
TinyType[TinyType["TINY_MCI"] = 17] = "TINY_MCI";
/** Info request: send an {@link IS_REO} */
TinyType[TinyType["TINY_REO"] = 18] = "TINY_REO";
/** Info request: send an {@link IS_RST} */
TinyType[TinyType["TINY_RST"] = 19] = "TINY_RST";
/** Info request: send an {@link IS_AXI} - AutoX Info */
TinyType[TinyType["TINY_AXI"] = 20] = "TINY_AXI";
/** Info: autocross cleared */
TinyType[TinyType["TINY_AXC"] = 21] = "TINY_AXC";
/** Info request: send an {@link IS_RIP} - Replay Information Packet */
TinyType[TinyType["TINY_RIP"] = 22] = "TINY_RIP";
/** Info request: get {@link IS_NCI} for all guests (on host only) */
TinyType[TinyType["TINY_NCI"] = 23] = "TINY_NCI";
/** Info request: send a {@link SMALL_ALC} (allowed cars) */
TinyType[TinyType["TINY_ALC"] = 24] = "TINY_ALC";
/** Info request: send {@link IS_AXM} packets for the entire layout */
TinyType[TinyType["TINY_AXM"] = 25] = "TINY_AXM";
/** Info request: send {@link IS_SLC} packets for all connections */
TinyType[TinyType["TINY_SLC"] = 26] = "TINY_SLC";
/** Info request: send {@link IS_MAL} listing the currently allowed mods */
TinyType[TinyType["TINY_MAL"] = 27] = "TINY_MAL";
/** Info request: send {@link IS_PLH} listing player handicaps */
TinyType[TinyType["TINY_PLH"] = 28] = "TINY_PLH";
/** Info request: send {@link IS_IPB} listing the IP bans */
TinyType[TinyType["TINY_IPB"] = 29] = "TINY_IPB";
/** Info request: send a {@link SMALL_LCL} for local car's lights */
TinyType[TinyType["TINY_LCL"] = 30] = "TINY_LCL";
})(TinyType || (exports.TinyType = TinyType = {}));
exports.SENDABLE_TINY_TYPES = [
TinyType.TINY_NONE,
TinyType.TINY_VER,
TinyType.TINY_CLOSE,
TinyType.TINY_PING,
TinyType.TINY_VTC,
TinyType.TINY_SCP,
TinyType.TINY_SST,
TinyType.TINY_GTM,
TinyType.TINY_ISM,
TinyType.TINY_NCN,
TinyType.TINY_NPL,
TinyType.TINY_RES,
TinyType.TINY_NLP,
TinyType.TINY_MCI,
TinyType.TINY_REO,
TinyType.TINY_RST,
TinyType.TINY_AXI,
TinyType.TINY_RIP,
TinyType.TINY_NCI,
TinyType.TINY_ALC,
TinyType.TINY_AXM,
TinyType.TINY_SLC,
TinyType.TINY_MAL,
TinyType.TINY_PLH,
TinyType.TINY_IPB,
TinyType.TINY_LCL,
];
exports.INFO_REQUEST_TINY_TYPES = [
TinyType.TINY_VER,
TinyType.TINY_PING,
TinyType.TINY_SCP,
TinyType.TINY_SST,
TinyType.TINY_GTM,
TinyType.TINY_ISM,
TinyType.TINY_NCN,
TinyType.TINY_NPL,
TinyType.TINY_RES,
TinyType.TINY_NLP,
TinyType.TINY_MCI,
TinyType.TINY_REO,
TinyType.TINY_RST,
TinyType.TINY_AXI,
TinyType.TINY_RIP,
TinyType.TINY_NCI,
TinyType.TINY_ALC,
TinyType.TINY_AXM,
TinyType.TINY_SLC,
TinyType.TINY_MAL,
TinyType.TINY_PLH,
TinyType.TINY_IPB,
TinyType.TINY_LCL,
];