mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Fix issues detected by lgtm.com
This commit is contained in:
1 parent
1ff1e3e5f8
commit
61cd5bd76c
40 files changed
+46
-62
No files matched your search
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
const child_process = require("child_process");
|
const child_process = require("child_process");
|
||||||
const events = require("events");
|
|
||||||
const fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
const inquirer = require("inquirer");
|
const inquirer = require("inquirer");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
@@ -94,7 +93,6 @@ async function safeOutputFile(file, data, options={}) {
|
|||||||
|
|
||||||
async function execFile(cmd, args) {
|
async function execFile(cmd, args) {
|
||||||
logger.verbose(`executing ${cmd} ${args.join(" ")}`);
|
logger.verbose(`executing ${cmd} ${args.join(" ")}`);
|
||||||
const asyncExec = util.promisify(child_process.execFile);
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let child = child_process.execFile(cmd, args, (err, stdout, stderr) => {
|
let child = child_process.execFile(cmd, args, (err, stdout, stderr) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
+8
-8
@@ -327,7 +327,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
}
|
}
|
||||||
instanceConfig.set("instance.name", args.name);
|
instanceConfig.set("instance.name", args.name);
|
||||||
let serialized_config = instanceConfig.serialize("master");
|
let serialized_config = instanceConfig.serialize("master");
|
||||||
let response = await libLink.messages.createInstance.send(control, { serialized_config });
|
await libLink.messages.createInstance.send(control, { serialized_config });
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -563,7 +563,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
||||||
let { seed, mapGenSettings, mapSettings } = await loadMapSettings(args);
|
let { seed, mapGenSettings, mapSettings } = await loadMapSettings(args);
|
||||||
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
||||||
let response = await libLink.messages.createSave.send(control, {
|
await libLink.messages.createSave.send(control, {
|
||||||
instance_id: instanceId,
|
instance_id: instanceId,
|
||||||
name: args.name,
|
name: args.name,
|
||||||
seed,
|
seed,
|
||||||
@@ -611,7 +611,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let requestError of result.body.request_errors || []) {
|
for (let requestError of result.body.request_errors || []) {
|
||||||
logger.error(error);
|
logger.error(requestError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.body.saves && result.body.saves.length) {
|
if (result.body.saves && result.body.saves.length) {
|
||||||
@@ -690,7 +690,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
handler: async function(args, control) {
|
handler: async function(args, control) {
|
||||||
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
||||||
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
||||||
let response = await libLink.messages.exportData.send(control, {
|
await libLink.messages.exportData.send(control, {
|
||||||
instance_id: instanceId,
|
instance_id: instanceId,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -707,7 +707,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
handler: async function(args, control) {
|
handler: async function(args, control) {
|
||||||
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
||||||
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
||||||
let response = await libLink.messages.startInstance.send(control, {
|
await libLink.messages.startInstance.send(control, {
|
||||||
instance_id: instanceId,
|
instance_id: instanceId,
|
||||||
save: args.save || null,
|
save: args.save || null,
|
||||||
});
|
});
|
||||||
@@ -731,7 +731,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
||||||
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
||||||
let { seed, mapGenSettings, mapSettings } = await loadMapSettings(args);
|
let { seed, mapGenSettings, mapSettings } = await loadMapSettings(args);
|
||||||
let response = await libLink.messages.loadScenario.send(control, {
|
await libLink.messages.loadScenario.send(control, {
|
||||||
instance_id: instanceId,
|
instance_id: instanceId,
|
||||||
scenario: args.scenario,
|
scenario: args.scenario,
|
||||||
seed,
|
seed,
|
||||||
@@ -749,7 +749,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
handler: async function(args, control) {
|
handler: async function(args, control) {
|
||||||
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
let instanceId = await libCommand.resolveInstance(control, args.instance);
|
||||||
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
await control.setLogSubscriptions({ instance_ids: [instanceId] });
|
||||||
let response = await libLink.messages.stopInstance.send(control, {
|
await libLink.messages.stopInstance.send(control, {
|
||||||
instance_id: instanceId,
|
instance_id: instanceId,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -760,7 +760,7 @@ instanceCommands.add(new libCommand.Command({
|
|||||||
yargs.positional("instance", { describe: "Instance to delete", type: "string" });
|
yargs.positional("instance", { describe: "Instance to delete", type: "string" });
|
||||||
}],
|
}],
|
||||||
handler: async function(args, control) {
|
handler: async function(args, control) {
|
||||||
let response = await libLink.messages.deleteInstance.send(control, {
|
await libLink.messages.deleteInstance.send(control, {
|
||||||
instance_id: await libCommand.resolveInstance(control, args.instance),
|
instance_id: await libCommand.resolveInstance(control, args.instance),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ async function build(args) {
|
|||||||
for (let entry of await fs.readdir(args.outputDir)) {
|
for (let entry of await fs.readdir(args.outputDir)) {
|
||||||
let match = splitter.exec(entry);
|
let match = splitter.exec(entry);
|
||||||
if (match) {
|
if (match) {
|
||||||
let [, name, version] = match;
|
let name = match[1];
|
||||||
if (name === info.name) {
|
if (name === info.name) {
|
||||||
let modPath = path.join(args.outputDir, entry);
|
let modPath = path.join(args.outputDir, entry);
|
||||||
console.log(`Removing ${modPath}`);
|
console.log(`Removing ${modPath}`);
|
||||||
@@ -94,7 +94,7 @@ async function build(args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (info.variants) {
|
if (info.variants) {
|
||||||
for (let [variant, variantOverrides] of Object.entries(info.variants)) {
|
for (let variantOverrides of info.variants) {
|
||||||
let variantInfo = {
|
let variantInfo = {
|
||||||
...info,
|
...info,
|
||||||
...variantOverrides,
|
...variantOverrides,
|
||||||
|
|||||||
@@ -376,9 +376,9 @@ ControlConfig.registerGroup(ControlGroup);
|
|||||||
|
|
||||||
|
|
||||||
function validateGroup(pluginInfo, groupName) {
|
function validateGroup(pluginInfo, groupName) {
|
||||||
if (!pluginInfo[groupName] instanceof classes.PluginConfigGroup) {
|
if (!(pluginInfo[groupName].prototype instanceof classes.PluginConfigGroup)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Expected ${groupName} for ${pluginInfo.name} to be an instance of PluginConfigGroup`
|
`Expected ${groupName} for ${pluginInfo.name} to be a subclass of PluginConfigGroup`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -791,6 +791,7 @@ class FactorioServer extends events.EventEmitter {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let [code, signal] = await events.once(this._server, "exit");
|
let [code, signal] = await events.once(this._server, "exit");
|
||||||
|
void signal;
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
throw new Error(`Factorio exited with status ${code}`);
|
throw new Error(`Factorio exited with status ${code}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { seq, type, data } = message;
|
let { type, data } = message;
|
||||||
if (type === "hello") {
|
if (type === "hello") {
|
||||||
logger.verbose(`Connector | received hello from master version ${data.version}`);
|
logger.verbose(`Connector | received hello from master version ${data.version}`);
|
||||||
this.emit("hello", data);
|
this.emit("hello", data);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
const libSchema = require("../schema");
|
const libSchema = require("../schema");
|
||||||
const libErrors = require("../errors");
|
const libErrors = require("../errors");
|
||||||
const { logger } = require("../logging");
|
const { logger } = require("../logging");
|
||||||
const messages = require("./messages");
|
|
||||||
|
|
||||||
// Some definitions for the terminology used here:
|
// Some definitions for the terminology used here:
|
||||||
// link: Either side of a master - client connection
|
// link: Either side of a master - client connection
|
||||||
@@ -135,7 +134,7 @@ class Link {
|
|||||||
* @returns {Boolean} true if a waiter was triggered.
|
* @returns {Boolean} true if a waiter was triggered.
|
||||||
*/
|
*/
|
||||||
_processWaiters(message) {
|
_processWaiters(message) {
|
||||||
let { seq, type, data } = message;
|
let { type, data } = message;
|
||||||
let waiters = this._waiters.get(type);
|
let waiters = this._waiters.get(type);
|
||||||
if (!waiters || !waiters.length) {
|
if (!waiters || !waiters.length) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* @module lib/shared_commands
|
* @module lib/shared_commands
|
||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
const fs = require("fs-extra");
|
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const libConfig = require("./config");
|
const libConfig = require("./config");
|
||||||
|
|||||||
@@ -89,12 +89,14 @@ const wsActiveConnectionsGauge = new libPrometheus.Gauge(
|
|||||||
"How many WebSocket connections are currently open to the master server",
|
"How many WebSocket connections are currently open to the master server",
|
||||||
{ callback: function(gauge) { gauge.set(master.wsServer.activeConnectors.size); }}
|
{ callback: function(gauge) { gauge.set(master.wsServer.activeConnectors.size); }}
|
||||||
);
|
);
|
||||||
|
void wsActiveConnectionsGauge;
|
||||||
|
|
||||||
const wsActiveSlavesGauge = new libPrometheus.Gauge(
|
const wsActiveSlavesGauge = new libPrometheus.Gauge(
|
||||||
"clusterio_master_active_slaves",
|
"clusterio_master_active_slaves",
|
||||||
"How many slaves are currently connected to the master",
|
"How many slaves are currently connected to the master",
|
||||||
{ callback: function(gauge) { gauge.set(master.wsServer.slaveConnections.size); }}
|
{ callback: function(gauge) { gauge.set(master.wsServer.slaveConnections.size); }}
|
||||||
);
|
);
|
||||||
|
void wsActiveSlavesGauge;
|
||||||
|
|
||||||
const masterConnectedClientsCount = new libPrometheus.Gauge(
|
const masterConnectedClientsCount = new libPrometheus.Gauge(
|
||||||
"clusterio_master_connected_clients_count", "How many clients are currently connected to this master server",
|
"clusterio_master_connected_clients_count", "How many clients are currently connected to this master server",
|
||||||
@@ -105,6 +107,7 @@ const masterConnectedClientsCount = new libPrometheus.Gauge(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
void masterConnectedClientsCount;
|
||||||
|
|
||||||
|
|
||||||
async function handleBootstrapCommand(args, masterConfig) {
|
async function handleBootstrapCommand(args, masterConfig) {
|
||||||
@@ -356,7 +359,7 @@ async function startup() {
|
|||||||
// add better stack traces on promise rejection
|
// add better stack traces on promise rejection
|
||||||
process.on("unhandledRejection", err => logger.error(`Unhandled rejection:\n${err.stack}`));
|
process.on("unhandledRejection", err => logger.error(`Unhandled rejection:\n${err.stack}`));
|
||||||
|
|
||||||
let { args, shouldRun, clusterLogger, pluginInfos, masterConfigPath, masterConfig } = await initialize(master);
|
let { args, shouldRun, clusterLogger, pluginInfos, masterConfigPath, masterConfig } = await initialize();
|
||||||
if (!shouldRun) {
|
if (!shouldRun) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ class ControlConnection extends BaseConnection {
|
|||||||
});
|
});
|
||||||
ready.catch(() => {});
|
ready.catch(() => {});
|
||||||
|
|
||||||
let result = await this._master.forwardRequestToInstance(libLink.messages.pushSave, {
|
await this._master.forwardRequestToInstance(libLink.messages.pushSave, {
|
||||||
instance_id,
|
instance_id,
|
||||||
stream_id: stream.id,
|
stream_id: stream.id,
|
||||||
save,
|
save,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const http = require("http");
|
const http = require("http");
|
||||||
const https = require("https");
|
const https = require("https");
|
||||||
const util = require("util");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gracefully close a Node.js HTTP(S) server
|
* Gracefully close a Node.js HTTP(S) server
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class Master {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async start(args) {
|
async start(args) {
|
||||||
if (!this._state === "new") {
|
if (this._state !== "new") {
|
||||||
throw new Error(`Cannot start in state ${this._state}`);
|
throw new Error(`Cannot start in state ${this._state}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ ${err.stack}`
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { seq, type, data } = message;
|
let { type, data } = message;
|
||||||
|
|
||||||
if (type === "resume") {
|
if (type === "resume") {
|
||||||
let connector;
|
let connector;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import events from "events";
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { BrowserRouter } from "react-router-dom";
|
import { BrowserRouter } from "react-router-dom";
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useContext, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Button, Card, Checkbox, Form, Input, InputNumber, Space, Spin, Tree, Typography } from "antd";
|
import { Button, Card, Checkbox, Form, Input, InputNumber, Space, Spin, Tree, Typography } from "antd";
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useContext, useState } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { Button, Col, Form, Input, Modal, Row, Typography } from "antd";
|
import { Button, Form, Input, Modal } from "antd";
|
||||||
|
|
||||||
import { libFactorio, libLink } from "@clusterio/lib";
|
import { libFactorio, libLink } from "@clusterio/lib";
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import React, { useContext } from "react";
|
import React from "react";
|
||||||
import { Typography } from "antd";
|
import { Typography } from "antd";
|
||||||
|
|
||||||
import { libLink } from "@clusterio/lib";
|
|
||||||
|
|
||||||
import PageLayout from "./PageLayout";
|
import PageLayout from "./PageLayout";
|
||||||
|
|
||||||
const { Paragraph } = Typography;
|
const { Paragraph } = Typography;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React, { useContext } from "react";
|
import React, { useContext } from "react";
|
||||||
import { Typography } from "antd";
|
|
||||||
|
|
||||||
import { libConfig, libLink } from "@clusterio/lib";
|
import { libConfig, libLink } from "@clusterio/lib";
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { useInstance } from "../model/instance";
|
|||||||
import { useSlave } from "../model/slave";
|
import { useSlave } from "../model/slave";
|
||||||
import InstanceStatusTag from "./InstanceStatusTag";
|
import InstanceStatusTag from "./InstanceStatusTag";
|
||||||
|
|
||||||
const { Title, Paragraph } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
|
|
||||||
export default function InstanceViewPage(props) {
|
export default function InstanceViewPage(props) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function CreateInstanceButton(props) {
|
|||||||
await instanceConfig.init();
|
await instanceConfig.init();
|
||||||
instanceConfig.set("instance.name", values.instanceName);
|
instanceConfig.set("instance.name", values.instanceName);
|
||||||
let serialized_config = instanceConfig.serialize("master");
|
let serialized_config = instanceConfig.serialize("master");
|
||||||
let result = await libLink.messages.createInstance.send(control, { serialized_config });
|
await libLink.messages.createInstance.send(control, { serialized_config });
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
history.push(`/instances/${instanceConfig.get("instance.id")}/view`);
|
history.push(`/instances/${instanceConfig.get("instance.id")}/view`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useContext, useState } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { Button, Col, Form, Input, Modal, Row, Typography } from "antd";
|
import { Button, Form, Input, Modal } from "antd";
|
||||||
|
|
||||||
import { libFactorio, libLink } from "@clusterio/lib";
|
import { libFactorio, libLink } from "@clusterio/lib";
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import React, { Fragment, useContext } from "react";
|
import React, { Fragment, useContext } from "react";
|
||||||
import { Button, Card, Divider, Form, Image, Input, List, Space, Spin, Typography } from "antd";
|
import { Button, Card, Divider, Form, Image, Input, Space, Typography } from "antd";
|
||||||
import LockOutlined from "@ant-design/icons/LockOutlined";
|
import LockOutlined from "@ant-design/icons/LockOutlined";
|
||||||
|
|
||||||
import logo from "../images/logo.png";
|
import logo from "../images/logo.png";
|
||||||
import ControlContext from "./ControlContext";
|
import ControlContext from "./ControlContext";
|
||||||
|
|
||||||
const { Paragraph, Text } = Typography;
|
const { Paragraph } = Typography;
|
||||||
|
|
||||||
|
|
||||||
function TokenAuth(props) {
|
function TokenAuth(props) {
|
||||||
@@ -22,7 +22,7 @@ function TokenAuth(props) {
|
|||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
style={{ width: "14em" }}
|
style={{ width: "14em" }}
|
||||||
prefix=<LockOutlined className="site-form-item-icon" />
|
prefix={<LockOutlined className="site-form-item-icon" />}
|
||||||
type="password"
|
type="password"
|
||||||
placeholder="Authentication Token"
|
placeholder="Authentication Token"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React, { useContext } from "react";
|
import React, { useContext } from "react";
|
||||||
import { Typography } from "antd";
|
|
||||||
|
|
||||||
import { libConfig, libLink } from "@clusterio/lib";
|
import { libConfig, libLink } from "@clusterio/lib";
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useContext } from "react";
|
import React from "react";
|
||||||
import { Typography } from "antd";
|
import { Typography } from "antd";
|
||||||
|
|
||||||
import LogConsole from "./LogConsole";
|
import LogConsole from "./LogConsole";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { Layout, Menu, Breadcrumb, Typography } from "antd";
|
import { Layout, Breadcrumb } from "antd";
|
||||||
|
|
||||||
const { Content } = Layout;
|
const { Content } = Layout;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import React, { useEffect, useContext, useState } from "react";
|
import React, { useEffect, useContext, useState } from "react";
|
||||||
import { useHistory, useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { Alert, Descriptions, Spin } from "antd";
|
import { Alert, Descriptions, Spin } from "antd";
|
||||||
|
|
||||||
import ControlContext from "./ControlContext";
|
import ControlContext from "./ControlContext";
|
||||||
import PageLayout from "./PageLayout";
|
import PageLayout from "./PageLayout";
|
||||||
import { notifyErrorHandler } from "../util/notify";
|
|
||||||
|
|
||||||
|
|
||||||
export default function PluginViewPage() {
|
export default function PluginViewPage() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useState } from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function SectionHeader(props) {
|
export default function SectionHeader(props) {
|
||||||
return <div className="section-header">
|
return <div className="section-header">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useContext, useState } from "react";
|
import React from "react";
|
||||||
import { Descriptions, PageHeader, Spin, Tag, Typography } from "antd";
|
import { Descriptions, PageHeader, Spin, Tag, Typography } from "antd";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useContext, useState } from "react";
|
import { useEffect, useContext, useState } from "react";
|
||||||
import ControlContext from "../components/ControlContext";
|
import ControlContext from "../components/ControlContext";
|
||||||
|
|
||||||
import { libLink, libLogging } from "@clusterio/lib";
|
import { libLink, libLogging } from "@clusterio/lib";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
|
||||||
let itemMetadataCache = null;
|
let itemMetadataCache = null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useContext, useState } from "react";
|
import { useEffect, useContext, useState } from "react";
|
||||||
import ControlContext from "../components/ControlContext";
|
import ControlContext from "../components/ControlContext";
|
||||||
|
|
||||||
import { libLink, libLogging } from "@clusterio/lib";
|
import { libLink, libLogging } from "@clusterio/lib";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useContext, useState } from "react";
|
import { useEffect, useContext, useState } from "react";
|
||||||
import ControlContext from "../components/ControlContext";
|
import ControlContext from "../components/ControlContext";
|
||||||
|
|
||||||
import { libLink } from "@clusterio/lib";
|
import { libLink } from "@clusterio/lib";
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ const path = require("path");
|
|||||||
|
|
||||||
const libFileOps = require("@clusterio/lib/file_ops");
|
const libFileOps = require("@clusterio/lib/file_ops");
|
||||||
const libPlugin = require("@clusterio/lib/plugin");
|
const libPlugin = require("@clusterio/lib/plugin");
|
||||||
const libErrors = require("@clusterio/lib/errors");
|
|
||||||
|
|
||||||
async function loadDatabase(config, logger) {
|
async function loadDatabase(config, logger) {
|
||||||
let itemsPath = path.resolve(config.get("master.database_directory"), "inventories.json");
|
let itemsPath = path.resolve(config.get("master.database_directory"), "inventories.json");
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
"use strict";
|
"use strict";
|
||||||
const libPlugin = require("@clusterio/lib/plugin");
|
const libPlugin = require("@clusterio/lib/plugin");
|
||||||
const libLuaTools = require("@clusterio/lib/lua_tools");
|
|
||||||
|
|
||||||
|
|
||||||
class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let [player, entry] of this.players) {
|
for (let entry of this.players.values()) {
|
||||||
if (entry.playerCode === playerCode && entry.expires > Date.now()) {
|
if (entry.playerCode === playerCode && entry.expires > Date.now()) {
|
||||||
let verifyCode = await generateCode(this.master.config.get("player_auth.code_length"));
|
let verifyCode = await generateCode(this.master.config.get("player_auth.code_length"));
|
||||||
let secret = Buffer.from(this.master.config.get("master.auth_secret"), "base64");
|
let secret = Buffer.from(this.master.config.get("master.auth_secret"), "base64");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { libPlugin } from "@clusterio/lib";
|
import { libPlugin } from "@clusterio/lib";
|
||||||
import { notify, notifyErrorHandler } from "@clusterio/web_ui";
|
import { notifyErrorHandler } from "@clusterio/web_ui";
|
||||||
import { Button, Form, Input, Spin, Typography } from "antd";
|
import { Button, Form, Input, Spin, Typography } from "antd";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
|||||||
if (!this.syncStarted || !["starting", "running"].includes(this.instance.status)) {
|
if (!this.syncStarted || !["starting", "running"].includes(this.instance.status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let { name, level, researched } = message.data;
|
let { name, level } = message.data;
|
||||||
await this.sendOrderedRcon(
|
await this.sendOrderedRcon(
|
||||||
`/sc research_sync.research_technology("${libLuaTools.escapeString(name)}", ${level})`, true
|
`/sc research_sync.research_technology("${libLuaTools.escapeString(name)}", ${level})`, true
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ function dose(numreq, instore, store_last_tick, dole, carry, prev_req, numreq_to
|
|||||||
debt,
|
debt,
|
||||||
]; // 5..12
|
]; // 5..12
|
||||||
let inputs = inp1.concat(inp2);
|
let inputs = inp1.concat(inp2);
|
||||||
let internal = new Array(20).fill(0);
|
|
||||||
let outputs = [0, 0, 0, 0];
|
let outputs = [0, 0, 0, 0];
|
||||||
// NN: Please don't touch :), code is generated
|
// NN: Please don't touch :), code is generated
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ function dose(numreq, instore, store_last_tick, dole, carry, prev_req, numreq_to
|
|||||||
outputs[0]=1.0;
|
outputs[0]=1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res1 = Number(outputs[0]) * numreq+outputs[3] + debt;
|
let res1 = Number(outputs[0]) * numreq + outputs[3] + debt;
|
||||||
let res_capped = Math.round(res1);
|
let res_capped = Math.round(res1);
|
||||||
|
|
||||||
if (res_capped > numreq) { res_capped = numreq; }
|
if (res_capped > numreq) { res_capped = numreq; }
|
||||||
@@ -88,7 +87,7 @@ function dose(numreq, instore, store_last_tick, dole, carry, prev_req, numreq_to
|
|||||||
res1 = res1 || 0;
|
res1 = res1 || 0;
|
||||||
res_capped = res_capped || 0; // Safeguard against wrong values
|
res_capped = res_capped || 0; // Safeguard against wrong values
|
||||||
debt = res1 - res_capped;
|
debt = res1 - res_capped;
|
||||||
debt_cap = Math.round(numreq * 1.5) + 5;
|
let debt_cap = Math.round(numreq * 1.5) + 5;
|
||||||
if (debt > debt_cap) {
|
if (debt > debt_cap) {
|
||||||
debt = debt_cap;
|
debt = debt_cap;
|
||||||
}
|
}
|
||||||
@@ -129,7 +128,6 @@ function tick(instore, dole, store_last_tick, numreq_total_adj) {
|
|||||||
store_last_tick,
|
store_last_tick,
|
||||||
numreq_total_adj,
|
numreq_total_adj,
|
||||||
];
|
];
|
||||||
let internal = new Array(10).fill(0);
|
|
||||||
let outputs = [0, 0];
|
let outputs = [0, 0];
|
||||||
// NN: Please don't touch :), code is generated
|
// NN: Please don't touch :), code is generated
|
||||||
|
|
||||||
@@ -139,7 +137,7 @@ function tick(instore, dole, store_last_tick, numreq_total_adj) {
|
|||||||
outputs[1] = outputs[0] * 1.828422785;
|
outputs[1] = outputs[0] * 1.828422785;
|
||||||
outputs[1] = sigmoid3(outputs[1]);
|
outputs[1] = sigmoid3(outputs[1]);
|
||||||
|
|
||||||
avg = outputs[1];
|
let avg = outputs[1];
|
||||||
if (numreq_total_adj < 0.11) {
|
if (numreq_total_adj < 0.11) {
|
||||||
// When no item's are requested, result is 0.1; In that case there is
|
// When no item's are requested, result is 0.1; In that case there is
|
||||||
// no deficit, so return 1 = 100% demand fulfilled
|
// no deficit, so return 1 = 100% demand fulfilled
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const fs = require("fs-extra");
|
|
||||||
|
|
||||||
const libPlugin = require("@clusterio/lib/plugin");
|
const libPlugin = require("@clusterio/lib/plugin");
|
||||||
const libLuaTools = require("@clusterio/lib/lua_tools");
|
const libLuaTools = require("@clusterio/lib/lua_tools");
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
|
|
||||||
function addApiRoutes(app, items, endpointHitCounter) {
|
function addApiRoutes(app, items, endpointHitCounter) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user