node-insim
Version:
An InSim library for NodeJS with TypeScript support
88 lines (86 loc) • 3.1 kB
JavaScript
import { __decorate } from "tslib";
import { byte, struct } from '../decorators';
import { SendablePacket } from './base';
import { PacketType } from './enums';
import { ObjectInfo } from './structs';
/**
* Join Request Reply - send one of these back to LFS in response to a join request
*
* Set the {@link ISF_REQ_JOIN} flag in the {@link IS_ISI} to receive join requests
* A join request is seen as an {@link IS_NPL} packet with ZERO in the NumP field
* An immediate response (e.g. within 1 second) is required using an {@link IS_JRR} packet
*
* In this case, PLID must be zero and {@link JRRAction} must be {@link JRR_REJECT} or
* {@link JRR_SPAWN}.
* If you allow the join and it is successful you will then get a normal {@link IS_NPL} with
* NumP set.
* You can also specify the start position of the car using the StartPos structure.
*
* {@link IS_JRR} can also be used to move an existing car to a different location.
* In this case, {@link PLID} must be set, {@link JRRAction} must be {@link JRR_RESET} or
* higher and StartPos must be set.
*/
export class IS_JRR extends SendablePacket {
constructor(data) {
super();
this.Size = 16;
this.Type = PacketType.ISP_JRR;
this.ReqI = 0;
/** ZERO when this is a reply to a join request - SET to move a car */
this.PLID = 0;
/** Set when this is a reply to a join request - ignored when moving a car */
this.UCID = 0;
/** 1 - allow / 0 - reject (should send message to user) */
this.JRRAction = 0;
this.Sp2 = 0;
this.Sp3 = 0;
/**
* 0: use default start point / Flags = 0x80: set start point
*
* To use default start point, StartPos should be filled with zero values.
*
* To specify a start point, StartPos X, Y, Zbyte and Heading should be filled like
* an autocross start position, Flags should be 0x80 and Index should be zero
*/
this.StartPos = new ObjectInfo();
this.initialize(data);
}
}
__decorate([
byte()
], IS_JRR.prototype, "Size", void 0);
__decorate([
byte()
], IS_JRR.prototype, "Type", void 0);
__decorate([
byte()
], IS_JRR.prototype, "ReqI", void 0);
__decorate([
byte()
], IS_JRR.prototype, "PLID", void 0);
__decorate([
byte()
], IS_JRR.prototype, "UCID", void 0);
__decorate([
byte()
], IS_JRR.prototype, "JRRAction", void 0);
__decorate([
byte()
], IS_JRR.prototype, "Sp2", void 0);
__decorate([
byte()
], IS_JRR.prototype, "Sp3", void 0);
__decorate([
struct(ObjectInfo)
], IS_JRR.prototype, "StartPos", void 0);
export var JRRAction;
(function (JRRAction) {
/** Reject new player */
JRRAction[JRRAction["JRR_REJECT"] = 0] = "JRR_REJECT";
/** Allow new player */
JRRAction[JRRAction["JRR_SPAWN"] = 1] = "JRR_SPAWN";
/** Reset player's car */
JRRAction[JRRAction["JRR_RESET"] = 4] = "JRR_RESET";
/** Reset player's car without repairing damage */
JRRAction[JRRAction["JRR_RESET_NO_REPAIR"] = 5] = "JRR_RESET_NO_REPAIR";
})(JRRAction || (JRRAction = {}));