node-insim
Version:
An InSim library for NodeJS with TypeScript support
172 lines (171 loc) • 6.47 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;
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RaceFlags = exports.IS_RST = void 0;
var decorators_1 = require("../decorators");
var base_1 = require("./base");
var enums_1 = require("./enums");
/**
* Race STart
*/
var IS_RST = /** @class */ (function (_super) {
__extends(IS_RST, _super);
function IS_RST() {
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
_this.Size = 28;
_this.Type = enums_1.PacketType.ISP_RST;
/** 0 unless this is a reply to an {@link TINY_RST} request */
_this.ReqI = 0;
_this.Zero = 0;
/** 0 if qualifying */
_this.RaceLaps = 0;
/** 0 if race */
_this.QualMins = 0;
/** Number of players in race */
_this.NumP = 0;
/**
* Lap timing
*
* Bits 6 and 7 (Timing & 0xc0):
*
* - 0x40: standard lap timing is being used
* - 0x80: custom timing - user checkpoints have been placed
* - 0xc0: no lap timing - e.g. open config with no user checkpoints
*
* Bits 0 and 1 (Timing & 0x03): number of checkpoints if lap timing is enabled
*/
_this.Timing = 0;
/** Short track name */
_this.Track = '';
_this.Weather = 0;
_this.Wind = 0;
/** Race flags (must pit, can reset, etc.) */
_this.Flags = 0;
/** Total number of nodes in the path */
_this.NumNodes = 0;
/** Node index - finish line */
_this.Finish = 0;
/** Node index - split 1 */
_this.Split1 = 0;
/** Node index - split 2 */
_this.Split2 = 0;
/** Node index - split 3 */
_this.Split3 = 0;
return _this;
}
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "Size", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "Type", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "ReqI", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "Zero", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "RaceLaps", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "QualMins", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "NumP", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "Timing", void 0);
__decorate([
(0, decorators_1.stringNull)(6)
], IS_RST.prototype, "Track", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "Weather", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_RST.prototype, "Wind", void 0);
__decorate([
(0, decorators_1.word)()
], IS_RST.prototype, "Flags", void 0);
__decorate([
(0, decorators_1.word)()
], IS_RST.prototype, "NumNodes", void 0);
__decorate([
(0, decorators_1.word)()
], IS_RST.prototype, "Finish", void 0);
__decorate([
(0, decorators_1.word)()
], IS_RST.prototype, "Split1", void 0);
__decorate([
(0, decorators_1.word)()
], IS_RST.prototype, "Split2", void 0);
__decorate([
(0, decorators_1.word)()
], IS_RST.prototype, "Split3", void 0);
return IS_RST;
}(base_1.Packet));
exports.IS_RST = IS_RST;
var RaceFlags;
(function (RaceFlags) {
/** Vote kick/ban allowed */
RaceFlags[RaceFlags["HOSTF_CAN_VOTE"] = 1] = "HOSTF_CAN_VOTE";
/** Guest are allowed to select tracks */
RaceFlags[RaceFlags["HOSTF_CAN_SELECT"] = 2] = "HOSTF_CAN_SELECT";
/** Mid-race join allowed */
RaceFlags[RaceFlags["HOSTF_MID_RACE"] = 32] = "HOSTF_MID_RACE";
/** Pit stop required */
RaceFlags[RaceFlags["HOSTF_MUST_PIT"] = 64] = "HOSTF_MUST_PIT";
/** Car reset allowed */
RaceFlags[RaceFlags["HOSTF_CAN_RESET"] = 128] = "HOSTF_CAN_RESET";
/** Forced cockpit view */
RaceFlags[RaceFlags["HOSTF_FCV"] = 256] = "HOSTF_FCV";
/** Cruise mode (wrong way allowed) */
RaceFlags[RaceFlags["HOSTF_CRUISE"] = 512] = "HOSTF_CRUISE";
})(RaceFlags || (exports.RaceFlags = RaceFlags = {}));