mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-24 21:55:52 +02:00
Lint code
This commit is contained in:
+2
-1
@@ -7,7 +7,8 @@
|
|||||||
"start": "node pony-town.js --login --admin --game",
|
"start": "node pony-town.js --login --admin --game",
|
||||||
"startlocal": "node pony-town.js --login --admin --game --local",
|
"startlocal": "node pony-town.js --login --admin --game --local",
|
||||||
"start-inspect": "node --inspect pony-town.js --login --admin --game --local",
|
"start-inspect": "node --inspect pony-town.js --login --admin --game --local",
|
||||||
"lint": "tslint -c tslint.json src/ts/**/*.ts",
|
"lint": "eslint \"src/ts/**/*.ts\"",
|
||||||
|
"lint-fix": "eslint \"src/ts/**/*.ts\" --fix",
|
||||||
"dev": "gulp dev",
|
"dev": "gulp dev",
|
||||||
"dev-sprites": "gulp dev --sprites",
|
"dev-sprites": "gulp dev --sprites",
|
||||||
"sw-generate": "workbox generateSW workbox-config.js && gulp patchWebWorker",
|
"sw-generate": "workbox generateSW workbox-config.js && gulp patchWebWorker",
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ if (document.body.getAttribute('data-debug') !== 'true' || localStorage.producti
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (typeof module !== 'undefined' && (module as any).hot) {
|
if (typeof module !== 'undefined' && (module as any).hot) {
|
||||||
(module as any).hot.accept();
|
(module as any).hot.accept();
|
||||||
}
|
}
|
||||||
@@ -338,7 +338,7 @@ export class PonyTownGame implements Game {
|
|||||||
}
|
}
|
||||||
apply = (func: () => void) => {
|
apply = (func: () => void) => {
|
||||||
return this.zone.run(func);
|
return this.zone.run(func);
|
||||||
}
|
};
|
||||||
applyChanges = () => this.zone.run(() => { });
|
applyChanges = () => this.zone.run(() => { });
|
||||||
private getScale() {
|
private getScale() {
|
||||||
const defaultScale = pixelRatio() > 1 ? 3 : 2;
|
const defaultScale = pixelRatio() > 1 ? 3 : 2;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isError } from "../common/utils";
|
import { isError } from '../common/utils';
|
||||||
|
|
||||||
export interface Game {
|
export interface Game {
|
||||||
fps: number;
|
fps: number;
|
||||||
|
|||||||
@@ -133,12 +133,12 @@ export class GamePadController implements InputController {
|
|||||||
}
|
}
|
||||||
private gamepadconnected = (e: Event) => {
|
private gamepadconnected = (e: Event) => {
|
||||||
this.gamepadIndex = (e as GamepadEvent).gamepad.index;
|
this.gamepadIndex = (e as GamepadEvent).gamepad.index;
|
||||||
}
|
};
|
||||||
private gamepaddisconnected = (e: Event) => {
|
private gamepaddisconnected = (e: Event) => {
|
||||||
if (this.gamepadIndex === (e as GamepadEvent).gamepad.index) {
|
if (this.gamepadIndex === (e as GamepadEvent).gamepad.index) {
|
||||||
this.scanGamepads();
|
this.scanGamepads();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function readAxis(manager: InputManager, keyX: Key, keyY: Key, axisX: number, axisY: number, zeroed: boolean): boolean {
|
function readAxis(manager: InputManager, keyX: Key, keyY: Key, axisX: number, axisY: number, zeroed: boolean): boolean {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export class KeyboardController implements InputController {
|
|||||||
this.stack.push(code);
|
this.stack.push(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private keyup = (e: KeyboardEvent) => {
|
private keyup = (e: KeyboardEvent) => {
|
||||||
let code = fixKeyCode(e.keyCode);
|
let code = fixKeyCode(e.keyCode);
|
||||||
|
|
||||||
@@ -89,8 +89,8 @@ export class KeyboardController implements InputController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeItem(this.stack, code);
|
removeItem(this.stack, code);
|
||||||
}
|
};
|
||||||
private blur = () => {
|
private blur = () => {
|
||||||
this.manager.clear();
|
this.manager.clear();
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export class MouseController implements InputController {
|
|||||||
this.manager.setValue(Key.MOUSE_X, Math.floor(e.clientX - rect.left));
|
this.manager.setValue(Key.MOUSE_X, Math.floor(e.clientX - rect.left));
|
||||||
this.manager.setValue(Key.MOUSE_Y, Math.floor(e.clientY - rect.top));
|
this.manager.setValue(Key.MOUSE_Y, Math.floor(e.clientY - rect.top));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private mousedown = (e: MouseEvent) => {
|
private mousedown = (e: MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -61,29 +61,29 @@ export class MouseController implements InputController {
|
|||||||
if (button) {
|
if (button) {
|
||||||
this.manager.setValue(button, 1);
|
this.manager.setValue(button, 1);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private mouseup = (e: MouseEvent) => {
|
private mouseup = (e: MouseEvent) => {
|
||||||
const button = MOUSE_BUTTONS[e.button];
|
const button = MOUSE_BUTTONS[e.button];
|
||||||
|
|
||||||
if (button) {
|
if (button) {
|
||||||
this.manager.setValue(button, 0);
|
this.manager.setValue(button, 0);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private mousewheel: any = (e: WheelEvent) => {
|
private mousewheel: any = (e: WheelEvent) => {
|
||||||
this.manager.addValue(Key.MOUSE_WHEEL_X, clamp(e.deltaX, -1, 1));
|
this.manager.addValue(Key.MOUSE_WHEEL_X, clamp(e.deltaX, -1, 1));
|
||||||
this.manager.addValue(Key.MOUSE_WHEEL_Y, clamp(e.deltaY, -1, 1));
|
this.manager.addValue(Key.MOUSE_WHEEL_Y, clamp(e.deltaY, -1, 1));
|
||||||
}
|
};
|
||||||
private contextmenu = (e: Event) => {
|
private contextmenu = (e: Event) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
};
|
||||||
private click = (e: Event) => {
|
private click = (e: Event) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
};
|
||||||
private blur = () => {
|
private blur = () => {
|
||||||
for (const button of MOUSE_BUTTONS) {
|
for (const button of MOUSE_BUTTONS) {
|
||||||
this.manager.setValue(button, 0);
|
this.manager.setValue(button, 0);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export class TouchController implements InputController {
|
|||||||
this.touch2Id = touch.identifier;
|
this.touch2Id = touch.identifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private touchmove = (e: any) => {
|
private touchmove = (e: any) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -165,7 +165,7 @@ export class TouchController implements InputController {
|
|||||||
this.manager.setValue(Key.MOUSE_Y, this.touchCurrent.y);
|
this.manager.setValue(Key.MOUSE_Y, this.touchCurrent.y);
|
||||||
this.updateInput();
|
this.updateInput();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private touchend = (e: any) => {
|
private touchend = (e: any) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -188,10 +188,10 @@ export class TouchController implements InputController {
|
|||||||
this.manager.setValue(Key.TOUCH_SECOND_CLICK, 1);
|
this.manager.setValue(Key.TOUCH_SECOND_CLICK, 1);
|
||||||
this.touch2Id = -1;
|
this.touch2Id = -1;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private blur = () => {
|
private blur = () => {
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
};
|
||||||
private getTouchXY(touch: Touch) {
|
private getTouchXY(touch: Touch) {
|
||||||
const { left, top } = this.element!.getBoundingClientRect();
|
const { left, top } = this.element!.getBoundingClientRect();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { noop, once } from "lodash";
|
import { noop, once } from 'lodash';
|
||||||
import { getUrl } from "./rev";
|
import { getUrl } from './rev';
|
||||||
import { spriteSheets } from "../generated/sprites";
|
import { spriteSheets } from '../generated/sprites';
|
||||||
import { createCanvas, loadImage } from "../common/canvasUtils";
|
import { createCanvas, loadImage } from '../common/canvasUtils';
|
||||||
import { createFonts } from "../common/fonts";
|
import { createFonts } from '../common/fonts';
|
||||||
import { SpriteSheet } from "../common/interfaces";
|
import { SpriteSheet } from '../common/interfaces';
|
||||||
|
|
||||||
export function createSpriteUtils() {
|
export function createSpriteUtils() {
|
||||||
createFonts();
|
createFonts();
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ export class AdminAccountDetails implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
highlighCharacter = (char: Character | undefined): boolean => {
|
highlighCharacter = (char: Character | undefined): boolean => {
|
||||||
return !!char && includes(this.ponyNames, char.name.toLowerCase());
|
return !!char && includes(this.ponyNames, char.name.toLowerCase());
|
||||||
}
|
};
|
||||||
clearSessions() {
|
clearSessions() {
|
||||||
if (this.account) {
|
if (this.account) {
|
||||||
this.clearingSessions = true;
|
this.clearingSessions = true;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { transliterate } from 'transliteration';
|
|||||||
})
|
})
|
||||||
export class TranslitPipe implements PipeTransform {
|
export class TranslitPipe implements PipeTransform {
|
||||||
transform(value: string) {
|
transform(value: string) {
|
||||||
if (!value || /^[a-z0-9-_.,\[\]!@#$%^&*{}|\/\\ ]+$/i.test(value))
|
if (!value || /^[a-z0-9-_.,[]!@#$%^&*{}|\/\\ ]+$/i.test(value))
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
const translit = transliterate(value);
|
const translit = transliterate(value);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function icon(value: string | undefined, defaultValue: any): any {
|
|||||||
|
|
||||||
const extensions = {
|
const extensions = {
|
||||||
browser: [
|
browser: [
|
||||||
[/(Amigo|YaBrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]
|
[/(Amigo|YaBrowser)\/([\w.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export class Help {
|
|||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.route.fragment.subscribe(f => {
|
this.route.fragment.subscribe(f => {
|
||||||
const element = document.querySelector("#" + f);
|
const element = document.querySelector('#' + f);
|
||||||
if (element) setTimeout(() => element.scrollIntoView(), 10);
|
if (element) setTimeout(() => element.scrollIntoView(), 10);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export class AdminModel {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
this.error = error.message;
|
this.error = error.message;
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
};
|
||||||
private checkError = <T>(promise: Promise<T>) => promise.catch(this.handleError) as Promise<T | undefined>;
|
private checkError = <T>(promise: Promise<T>) => promise.catch(this.handleError) as Promise<T | undefined>;
|
||||||
private running = true;
|
private running = true;
|
||||||
private initializedLive = false;
|
private initializedLive = false;
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ export class Model {
|
|||||||
|
|
||||||
this.pending = true;
|
this.pending = true;
|
||||||
|
|
||||||
const alert = !!this.accountAlert ? 'y' : '';
|
const alert = this.accountAlert ? 'y' : '';
|
||||||
|
|
||||||
return this.post<JoinResponse>('/api/game/join', { version, ponyId, serverId, alert, url: location.href })
|
return this.post<JoinResponse>('/api/game/join', { version, ponyId, serverId, alert, url: location.href })
|
||||||
.finally(() => this.pending = false);
|
.finally(() => this.pending = false);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export class CharacterPreview implements OnDestroy, OnChanges, AfterViewInit {
|
|||||||
this.lastFrame = now;
|
this.lastFrame = now;
|
||||||
this.tryDraw();
|
this.tryDraw();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private tryDraw() {
|
private tryDraw() {
|
||||||
try {
|
try {
|
||||||
this.draw();
|
this.draw();
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
|||||||
private say(message: string, chatType: ChatType, entityId: number): boolean {
|
private say(message: string, chatType: ChatType, entityId: number): boolean {
|
||||||
this.game.lastChatMessageType = chatType;
|
this.game.lastChatMessageType = chatType;
|
||||||
if (message.toLowerCase().startsWith('/shrug')) {
|
if (message.toLowerCase().startsWith('/shrug')) {
|
||||||
var rawMessage = message.substring(6);
|
let rawMessage = message.substring(6);
|
||||||
return !!this.game.send(server =>
|
return !!this.game.send(server =>
|
||||||
server.say(entityId, ((rawMessage !== '') ? rawMessage + ' ' : '') + `¯\\_(ツ)_/¯`,
|
server.say(entityId, ((rawMessage !== '') ? rawMessage + ' ' : '') + `¯\\_(ツ)_/¯`,
|
||||||
chatType));
|
chatType));
|
||||||
|
|||||||
@@ -694,17 +694,17 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
scrollHandler = () => {
|
scrollHandler = () => {
|
||||||
this.scrollingToEnd = true;
|
this.scrollingToEnd = true;
|
||||||
this.scroll.nativeElement.scrollTop = 99999;
|
this.scroll.nativeElement.scrollTop = 99999;
|
||||||
}
|
};
|
||||||
clickNameHandler = (message: ChatLogMessage) => {
|
clickNameHandler = (message: ChatLogMessage) => {
|
||||||
this.zone.run(() => this.nameClick.emit(message));
|
this.zone.run(() => this.nameClick.emit(message));
|
||||||
}
|
};
|
||||||
clickLabel = (message: ChatLogMessage) => {
|
clickLabel = (message: ChatLogMessage) => {
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
if (message.label) {
|
if (message.label) {
|
||||||
this.toggleType.emit(message.label);
|
this.toggleType.emit(message.label);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
private clearList() {
|
private clearList() {
|
||||||
removeAllNodes(this.linesElement);
|
removeAllNodes(this.linesElement);
|
||||||
}
|
}
|
||||||
@@ -772,12 +772,12 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
return findEntityFromMessages(id, this.whisper) ||
|
return findEntityFromMessages(id, this.whisper) ||
|
||||||
findEntityFromMessages(id, this.party) ||
|
findEntityFromMessages(id, this.party) ||
|
||||||
findEntityFromMessages(id, this.local);
|
findEntityFromMessages(id, this.local);
|
||||||
}
|
};
|
||||||
private findEntityFromMessagesByName = (name: string): FakeEntity | undefined => {
|
private findEntityFromMessagesByName = (name: string): FakeEntity | undefined => {
|
||||||
return findEntityFromMessagesByName(name, this.game.playerId, this.whisper) ||
|
return findEntityFromMessagesByName(name, this.game.playerId, this.whisper) ||
|
||||||
findEntityFromMessagesByName(name, this.game.playerId, this.party) ||
|
findEntityFromMessagesByName(name, this.game.playerId, this.party) ||
|
||||||
findEntityFromMessagesByName(name, this.game.playerId, this.local);
|
findEntityFromMessagesByName(name, this.game.playerId, this.local);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function findEntityFromMessages(id: number, messages: ChatLogMessage[]): FakeEntity | undefined {
|
function findEntityFromMessages(id: number, messages: ChatLogMessage[]): FakeEntity | undefined {
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ export class Dropdown {
|
|||||||
} else if (this.autoClose && e.keyCode === 27) { // esc
|
} else if (this.autoClose && e.keyCode === 27) { // esc
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
private canvasCloseHandler: any = () => this.close();
|
private canvasCloseHandler: any = () => this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,5 +54,5 @@ export class FocusTrap implements OnInit, OnDestroy {
|
|||||||
this.lastActiveElement.focus();
|
this.lastActiveElement.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class SignInBox implements OnInit {
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
this.mocks = data;
|
this.mocks = data;
|
||||||
})
|
})
|
||||||
.catch(noop)
|
.catch(noop);
|
||||||
}
|
}
|
||||||
async createNew() {
|
async createNew() {
|
||||||
const name = prompt('Account name');
|
const name = prompt('Account name');
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class ToolsFrame {
|
|||||||
if (this.popoverIsOpen) {
|
if (this.popoverIsOpen) {
|
||||||
this.togglePopover();
|
this.togglePopover();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
togglePopover() {
|
togglePopover() {
|
||||||
const rect = (this.element.nativeElement as HTMLElement).getBoundingClientRect();
|
const rect = (this.element.nativeElement as HTMLElement).getBoundingClientRect();
|
||||||
this.placement = (rect.left < (window.innerWidth / 2)) ? 'right' : 'left';
|
this.placement = (rect.left < (window.innerWidth / 2)) ? 'right' : 'left';
|
||||||
|
|||||||
@@ -170,5 +170,5 @@ export class ToolsRegions implements OnInit, OnDestroy {
|
|||||||
this.player.y += dy * delta * PONY_SPEED_TROT;
|
this.player.y += dy * delta * PONY_SPEED_TROT;
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export class Shader {
|
|||||||
|
|
||||||
const attribs = vertexCode.match(/^attribute [a-zA-Z0-9_]+ ([a-zA-Z0-9_]+)/mg)!;
|
const attribs = vertexCode.match(/^attribute [a-zA-Z0-9_]+ ([a-zA-Z0-9_]+)/mg)!;
|
||||||
|
|
||||||
for (var i = 0; i < attribs.length; ++i) {
|
for (let i = 0; i < attribs.length; ++i) {
|
||||||
const [, name] = /attribute [a-zA-Z0-9_]+ ([a-zA-Z0-9_]+)/.exec(attribs[i])!;
|
const [, name] = /attribute [a-zA-Z0-9_]+ ([a-zA-Z0-9_]+)/.exec(attribs[i])!;
|
||||||
gl.bindAttribLocation(program, i, name);
|
gl.bindAttribLocation(program, i, name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export async function getChat(search: string, date: string, caseInsensitive: boo
|
|||||||
const options = { maxBuffer: 1 * 1024 * 1024 }; // 1MB
|
const options = { maxBuffer: 1 * 1024 * 1024 }; // 1MB
|
||||||
|
|
||||||
async function fetchChatlog(lines: number) {
|
async function fetchChatlog(lines: number) {
|
||||||
const logFile = paths.pathTo('logs', `info.${format(date, 'yyyyMMdd')}.log`)
|
const logFile = paths.pathTo('logs', `info.${format(date, 'yyyyMMdd')}.log`);
|
||||||
const { stdout } = await execAsync(`grep ${flags}"${query}" "${logFile}" | tail -n ${lines}`, options);
|
const { stdout } = await execAsync(`grep ${flags}"${query}" "${logFile}" | tail -n ${lines}`, options);
|
||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ if (!DEVELOPMENT && !TESTS &&
|
|||||||
|| INSECURE_RANDOM_VALUES.includes(config.secret)
|
|| INSECURE_RANDOM_VALUES.includes(config.secret)
|
||||||
|| INSECURE_RANDOM_VALUES.includes(config.token))) {
|
|| INSECURE_RANDOM_VALUES.includes(config.token))) {
|
||||||
console.error(
|
console.error(
|
||||||
`
|
`
|
||||||
================================================================================
|
================================================================================
|
||||||
WARNING! WARNING! WARNING!
|
WARNING! WARNING! WARNING!
|
||||||
|
|
||||||
|
|||||||
@@ -68,5 +68,5 @@ export class CollectableController implements Controller {
|
|||||||
this.pick(client, entity);
|
this.pick(client, entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ export class PlantController implements Controller {
|
|||||||
private interact: Interact = (entity, client) => {
|
private interact: Interact = (entity, client) => {
|
||||||
this.world.removeEntity(entity, this.map);
|
this.world.removeEntity(entity, this.map);
|
||||||
removeItem(this.plants, entity);
|
removeItem(this.plants, entity);
|
||||||
this.config.onPick && this.config.onPick(entity, client);
|
this.config?.onPick?.(entity, client);
|
||||||
}
|
};
|
||||||
private nextSpawn = 0;
|
private nextSpawn = 0;
|
||||||
constructor(private world: World, private map: ServerMap, private config: PlantConfig) {
|
constructor(private world: World, private map: ServerMap, private config: PlantConfig) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,19 +84,19 @@ export class StatsTracker {
|
|||||||
this.logStat(
|
this.logStat(
|
||||||
url || (req.baseUrl + req.path), typeof result === 'string' ? result.length : JSON.stringify(result).length);
|
url || (req.baseUrl + req.path), typeof result === 'string' ? result.length : JSON.stringify(result).length);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
logSwearing = () => {
|
logSwearing = () => {
|
||||||
this.dailySwearing++;
|
this.dailySwearing++;
|
||||||
}
|
};
|
||||||
logSpamming = () => {
|
logSpamming = () => {
|
||||||
this.dailySpamming++;
|
this.dailySpamming++;
|
||||||
}
|
};
|
||||||
logRecvStats = (id: number, name: string, binary: boolean, size: number) => {
|
logRecvStats = (id: number, name: string, binary: boolean, size: number) => {
|
||||||
this.logSocketStats(this.recvStats, id, name, binary, size);
|
this.logSocketStats(this.recvStats, id, name, binary, size);
|
||||||
}
|
};
|
||||||
logSendStats = (id: number, name: string, binary: boolean, size: number) => {
|
logSendStats = (id: number, name: string, binary: boolean, size: number) => {
|
||||||
this.logSocketStats(this.sendStats, id, name, binary, size);
|
this.logSocketStats(this.sendStats, id, name, binary, size);
|
||||||
}
|
};
|
||||||
private logSocketStats(stats: (SocketStats | undefined)[], id: number, name: string, binary: boolean, size: number) {
|
private logSocketStats(stats: (SocketStats | undefined)[], id: number, name: string, binary: boolean, size: number) {
|
||||||
const entry = stats[id] || (stats[id] = {
|
const entry = stats[id] || (stats[id] = {
|
||||||
id,
|
id,
|
||||||
@@ -112,7 +112,7 @@ export class StatsTracker {
|
|||||||
lastHourSize: new ByteSize(),
|
lastHourSize: new ByteSize(),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!!binary) {
|
if (binary) {
|
||||||
entry.countBin++;
|
entry.countBin++;
|
||||||
} else {
|
} else {
|
||||||
entry.countStr++;
|
entry.countStr++;
|
||||||
|
|||||||
Reference in New Issue
Block a user