Merge branch 'master' into tadah
This commit is contained in:
commit
29bd85e426
|
|
@ -1,11 +1,10 @@
|
||||||
|
PORT=
|
||||||
RCCSERVICE=
|
RCCSERVICE=
|
||||||
ARBITER_TOKEN=
|
|
||||||
ARBITER_PASSWORD=
|
|
||||||
accessKey=
|
|
||||||
|
|
||||||
BASE_URL=https://kapish.fun
|
BASE_URL=https://kapish.fun
|
||||||
|
|
||||||
RENDER_FORMAT=PNG
|
ARBITER_TOKEN=
|
||||||
|
ARBITER_KEY=
|
||||||
|
|
||||||
RENDER_USER_WIDTH=420
|
RENDER_USER_WIDTH=420
|
||||||
RENDER_USER_HEIGHT=420
|
RENDER_USER_HEIGHT=420
|
||||||
|
|
|
||||||
30
src/index.js
30
src/index.js
|
|
@ -6,13 +6,11 @@ const logger = require("./lib/logger.js")
|
||||||
|
|
||||||
if (process.platform == "linux") logger.warn("Game hosting might not be fully compatible with Linux")
|
if (process.platform == "linux") logger.warn("Game hosting might not be fully compatible with Linux")
|
||||||
|
|
||||||
global.games = new Map()
|
app.use(({ query }, response, next) => {
|
||||||
|
if (!query.key) return response.status(400).json({ error: "Missing key in query" })
|
||||||
setInterval(() => {
|
if (query.key !== process.env.ARBITER_KEY) return response.status(403).json({ error: "Incorrect key in query" })
|
||||||
global.games.forEach(async (value, key) => {
|
next()
|
||||||
if (!(await value.Running())) value.Stop()
|
})
|
||||||
})
|
|
||||||
}, 15000)
|
|
||||||
|
|
||||||
const validateQueryParam = (req, res, next) => {
|
const validateQueryParam = (req, res, next) => {
|
||||||
const myQueryParam = process.env.accessKey;
|
const myQueryParam = process.env.accessKey;
|
||||||
|
|
@ -33,17 +31,19 @@ app.use("/game/status", require("./routes/game/status.js"))
|
||||||
app.use("/game/execute", require("./routes/game/execute.js"))
|
app.use("/game/execute", require("./routes/game/execute.js"))
|
||||||
|
|
||||||
app.use("/render/asset", require("./routes/render/asset.js"))
|
app.use("/render/asset", require("./routes/render/asset.js"))
|
||||||
//app.use("/render/game", require("./routes/render/game.js"))
|
app.use("/render/game", require("./routes/render/game.js"))
|
||||||
//app.use("/render/texture", require("./routes/render/texture.js"))
|
app.use("/render/texture", require("./routes/render/texture.js"))
|
||||||
app.use("/render/user", require("./routes/render/user.js"))
|
app.use("/render/user", require("./routes/render/user.js"))
|
||||||
app.use("/render/texture", require("./routes/render/texture.js"))
|
app.use("/render/texture", require("./routes/render/texture.js"))
|
||||||
|
|
||||||
app.use("*", require("./routes/index.js"))
|
app.use("*", require("./routes/index.js"))
|
||||||
|
|
||||||
app.listen(process.env.PORT || 64989, () => {
|
process.on("uncaughtException", (err) => logger.error(err.message))
|
||||||
logger.boot(`Listening on http://127.0.0.1:${process.env.PORT || 64989}/`)
|
global.games = new Map()
|
||||||
})
|
setInterval(() => {
|
||||||
|
global.games.forEach(async (value, key) => {
|
||||||
|
if (!(await value.Running())) value.Stop()
|
||||||
|
})
|
||||||
|
}, 15000)
|
||||||
|
|
||||||
process.on("uncaughtException", (err) => {
|
app.listen(process.env.PORT, () => logger.boot(`Listening on http://127.0.0.1:${process.env.PORT}/`))
|
||||||
logger.error(err.message)
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,7 @@ class GameJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: id },
|
{ type: "LUA_TNUMBER", value: id },
|
||||||
{ type: "LUA_TNUMBER", value: 0 },
|
{ type: "LUA_TNUMBER", value: 50001 },
|
||||||
{ type: "LUA_TNUMBER", value: 0 },
|
|
||||||
{ type: "LUA_TSTRING", value: process.env.ARBITER_TOKEN },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).catch((e) => reject(e))
|
}).catch((e) => reject(e))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const { readFile } = require("fs/promises")
|
const { readFile } = require("fs/promises")
|
||||||
const chalk = require('chalk')
|
const chalk = require("chalk")
|
||||||
|
|
||||||
const Job = require("./Job.js")
|
const Job = require("./Job.js")
|
||||||
const logger = require("../logger.js")
|
const logger = require("../logger.js")
|
||||||
|
|
@ -31,7 +31,7 @@ class RenderJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
{ type: "LUA_TSTRING", value: this.id },
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Headshot" },
|
{ type: "LUA_TSTRING", value: "Headshot" },
|
||||||
{ type: "LUA_TSTRING", value: process.env.RENDER_FORMAT },
|
{ type: "LUA_TSTRING", value: "PNG" },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
||||||
|
|
@ -70,7 +70,7 @@ class RenderJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
{ type: "LUA_TSTRING", value: this.id },
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Bodyshot" },
|
{ type: "LUA_TSTRING", value: "Bodyshot" },
|
||||||
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : process.env.RENDER_FORMAT },
|
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : "PNG" },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
||||||
|
|
@ -110,7 +110,7 @@ class RenderJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
{ type: "LUA_TSTRING", value: this.id },
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Asset" },
|
{ type: "LUA_TSTRING", value: "Asset" },
|
||||||
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : process.env.RENDER_FORMAT },
|
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : "PNG" },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_WIDTH },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_WIDTH },
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_HEIGHT },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_HEIGHT },
|
||||||
|
|
@ -153,7 +153,7 @@ class RenderJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
{ type: "LUA_TSTRING", value: this.id },
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Place" },
|
{ type: "LUA_TSTRING", value: "Place" },
|
||||||
{ type: "LUA_TSTRING", value: process.env.RENDER_FORMAT },
|
{ type: "LUA_TSTRING", value: "PNG" },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_PLACE_WIDTH },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_PLACE_WIDTH },
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_PLACE_HEIGHT },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_PLACE_HEIGHT },
|
||||||
|
|
@ -191,7 +191,7 @@ class RenderJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: this.id },
|
{ type: "LUA_TSTRING", value: this.id },
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: "Texture" },
|
{ type: "LUA_TSTRING", value: "Texture" },
|
||||||
{ type: "LUA_TSTRING", value: process.env.RENDER_FORMAT },
|
{ type: "LUA_TSTRING", value: "PNG" },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
||||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
local Player = game.Players:CreateLocalPlayer(0)
|
||||||
Player.CharacterAppearance = ("%s/users/%d/character"):format(baseUrl, assetId)
|
Player.CharacterAppearance = ("%s/Character?id=%d"):format(baseUrl, assetId)
|
||||||
Player:LoadCharacter(false)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
local jobId, type, baseUrl, placeId, port, owner, key = ...
|
local jobId, type, baseUrl, placeId, port = ...
|
||||||
|
|
||||||
------------------- UTILITY FUNCTIONS --------------------------
|
------------------- UTILITY FUNCTIONS --------------------------
|
||||||
|
|
||||||
|
|
||||||
function waitForChild(parent, childName)
|
function waitForChild(parent, childName)
|
||||||
while true do
|
while true do
|
||||||
local child = parent:findFirstChild(childName)
|
local child = parent:findFirstChild(childName)
|
||||||
if child then
|
if child then return child end
|
||||||
return child
|
parent.ChildAdded:wait()
|
||||||
end
|
end
|
||||||
parent.ChildAdded:wait()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
||||||
|
|
@ -38,7 +34,7 @@ local scriptContext = game:GetService('ScriptContext')
|
||||||
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
||||||
scriptContext.ScriptsDisabled = true
|
scriptContext.ScriptsDisabled = true
|
||||||
|
|
||||||
game:SetPlaceID(assetId, false)
|
game:SetPlaceID(placeId, false)
|
||||||
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
||||||
|
|
||||||
-- establish this peer as the Server
|
-- establish this peer as the Server
|
||||||
|
|
@ -160,5 +156,10 @@ end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
-- StartGame --
|
-- StartGame --
|
||||||
|
=======
|
||||||
|
------------------------------END START GAME SHARED SCRIPT--------------------------
|
||||||
|
|
||||||
|
>>>>>>> master
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue