Merge branch 'master' into crapblox
This commit is contained in:
commit
3204aede8a
|
|
@ -25,6 +25,9 @@ app.use("/render/game", require("./routes/render/game.js"))
|
|||
app.use("/render/headshot", require("./routes/render/headshot.js"))
|
||||
app.use("/render/bodyshot", require("./routes/render/bodyshot.js"))
|
||||
|
||||
app.use("/render/3d/asset", require("./routes/render/3d/asset.js"))
|
||||
app.use("/render/3d/user", require("./routes/render/3d/user.js"))
|
||||
|
||||
app.use("*", require("./routes/index.js"))
|
||||
|
||||
app.listen(process.env.PORT || 64989, () => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const axios = require("axios")
|
||||
const { readFileSync } = require("fs")
|
||||
const { readFile } = require("fs/promises")
|
||||
|
||||
const Job = require("./Job.js")
|
||||
const logger = require("../logger.js")
|
||||
|
|
@ -25,7 +25,7 @@ class GameJob extends Job {
|
|||
|
||||
this.OpenJobEx({
|
||||
name: this.id,
|
||||
script: readFileSync(__dirname + "/../../lua/gameserver.lua", { encoding: "utf-8" }),
|
||||
script: await readFile(__dirname + "/../../lua/gameserver.lua", { encoding: "utf-8" }),
|
||||
arguments: {
|
||||
LuaValue: [
|
||||
{ type: "LUA_TSTRING", value: this.id },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const { readFileSync } = require("fs")
|
||||
const { readFile } = require("fs/promises")
|
||||
|
||||
const Job = require("./Job.js")
|
||||
const logger = require("../logger.js")
|
||||
|
|
@ -17,7 +17,7 @@ class RenderJob extends Job {
|
|||
|
||||
const result = await this.OpenJobEx({
|
||||
name: this.id,
|
||||
script: readFileSync(__dirname + "/../../lua/headshot.lua", { encoding: "utf-8" }),
|
||||
script: await readFile(__dirname + "/../../lua/headshot.lua", { encoding: "utf-8" }),
|
||||
arguments: {
|
||||
LuaValue: [
|
||||
{ type: "LUA_TSTRING", value: this.id },
|
||||
|
|
@ -43,22 +43,23 @@ class RenderJob extends Job {
|
|||
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
||||
}
|
||||
|
||||
async RenderBodyshot(id, base64 = false) {
|
||||
async RenderBodyshot(id, base64 = false, three_d = false) {
|
||||
const started = await this.Start()
|
||||
if (!started) throw new Error("RCCService failed to start")
|
||||
if (!this.client) await this.CreateClient()
|
||||
|
||||
logger.info(`[${this.id}] Bodyshot RenderJob started for ${id}`)
|
||||
if (three_d) logger.info(`[${this.id}] 3D Bodyshot RenderJob started for ${id}`)
|
||||
else logger.info(`[${this.id}] Bodyshot RenderJob started for ${id}`)
|
||||
|
||||
const result = await this.OpenJobEx({
|
||||
name: this.id,
|
||||
script: readFileSync(__dirname + "/../../lua/bodyshot.lua", { encoding: "utf-8" }),
|
||||
script: await readFile(__dirname + "/../../lua/bodyshot.lua", { encoding: "utf-8" }),
|
||||
arguments: {
|
||||
LuaValue: [
|
||||
{ type: "LUA_TSTRING", value: this.id },
|
||||
|
||||
{ type: "LUA_TSTRING", value: "Bodyshot" },
|
||||
{ type: "LUA_TSTRING", value: process.env.RENDER_FORMAT },
|
||||
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : process.env.RENDER_FORMAT },
|
||||
|
||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_WIDTH },
|
||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_USER_HEIGHT },
|
||||
|
|
@ -69,31 +70,33 @@ class RenderJob extends Job {
|
|||
},
|
||||
}).catch((e) => false)
|
||||
|
||||
logger.info(`[${this.id}] Bodyshot RenderJob finished for ${id}`)
|
||||
if (three_d) logger.info(`[${this.id}] 3D Bodyshot RenderJob finished for ${id}`)
|
||||
else logger.info(`[${this.id}] Bodyshot RenderJob finished for ${id}`)
|
||||
|
||||
await this.Stop()
|
||||
|
||||
if (!result) return false
|
||||
if (base64) return result[0].OpenJobExResult.LuaValue[0].value
|
||||
if (base64 || three_d) return result[0].OpenJobExResult.LuaValue[0].value
|
||||
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
||||
}
|
||||
|
||||
async RenderAsset(id, base64 = false) {
|
||||
async RenderAsset(id, base64 = false, three_d = false) {
|
||||
const started = await this.Start()
|
||||
if (!started) throw new Error("RCCService failed to start")
|
||||
if (!this.client) await this.CreateClient()
|
||||
|
||||
logger.info(`[${this.id}] Asset RenderJob started for ${id}`)
|
||||
if (three_d) logger.info(`[${this.id}] 3D Asset RenderJob started for ${id}`)
|
||||
else logger.info(`[${this.id}] Asset RenderJob started for ${id}`)
|
||||
|
||||
const result = await this.OpenJobEx({
|
||||
name: this.id,
|
||||
script: readFileSync(__dirname + "/../../lua/xml.lua", { encoding: "utf-8" }),
|
||||
script: await readFile(__dirname + "/../../lua/xml.lua", { encoding: "utf-8" }),
|
||||
arguments: {
|
||||
LuaValue: [
|
||||
{ type: "LUA_TSTRING", value: this.id },
|
||||
|
||||
{ type: "LUA_TSTRING", value: "Asset" },
|
||||
{ type: "LUA_TSTRING", value: process.env.RENDER_FORMAT },
|
||||
{ type: "LUA_TSTRING", value: three_d ? "OBJ" : process.env.RENDER_FORMAT },
|
||||
|
||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_WIDTH },
|
||||
{ type: "LUA_TNUMBER", value: process.env.RENDER_ASSET_HEIGHT },
|
||||
|
|
@ -105,12 +108,13 @@ class RenderJob extends Job {
|
|||
},
|
||||
}).catch((e) => false)
|
||||
|
||||
logger.info(`[${this.id}] Asset RenderJob finished for ${id}`)
|
||||
if (three_d) logger.info(`[${this.id}] 3D Asset RenderJob finished for ${id}`)
|
||||
else logger.info(`[${this.id}] Asset RenderJob finished for ${id}`)
|
||||
|
||||
await this.Stop()
|
||||
|
||||
if (!result) return false
|
||||
if (base64) return result[0].OpenJobExResult.LuaValue[0].value
|
||||
if (base64 || three_d) return result[0].OpenJobExResult.LuaValue[0].value
|
||||
return Buffer.from(result[0]?.OpenJobExResult?.LuaValue[0]?.value, "base64")
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +132,7 @@ class RenderJob extends Job {
|
|||
|
||||
const result = await this.OpenJobEx({
|
||||
name: this.id,
|
||||
script: readFileSync(__dirname + "/../../lua/place.lua", { encoding: "utf-8" }),
|
||||
script: await readFile(__dirname + "/../../lua/place.lua", { encoding: "utf-8" }),
|
||||
arguments: {
|
||||
LuaValue: [
|
||||
{ type: "LUA_TSTRING", value: this.id },
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
const express = require("express")
|
||||
const app = express.Router()
|
||||
|
||||
const RenderJob = require("../../../lib/classes/RenderJob.js")
|
||||
|
||||
app.get("/:id", async (request, response) => {
|
||||
const job = new RenderJob()
|
||||
const result = await job.RenderAsset(request.params.id, process.env.RENDER_BASE64, true).catch((_) => _)
|
||||
|
||||
if (result?.message) return response.status(500).json({ error: result.message })
|
||||
else return response.end(result)
|
||||
})
|
||||
|
||||
module.exports = app
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
const express = require("express")
|
||||
const app = express.Router()
|
||||
|
||||
const RenderJob = require("../../../lib/classes/RenderJob.js")
|
||||
|
||||
app.get("/:id", async (request, response) => {
|
||||
const job = new RenderJob()
|
||||
const result = await job.RenderBodyshot(request.params.id, process.env.RENDER_BASE64, true).catch((_) => _)
|
||||
|
||||
if (result?.message) return response.status(500).json({ error: result.message })
|
||||
else return response.end(result)
|
||||
})
|
||||
|
||||
module.exports = app
|
||||
Loading…
Reference in New Issue