Skip to content

Commit

Permalink
DBViewer work and README improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
paulov-t committed Jun 15, 2022
1 parent 431f721 commit 043892d
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 15 deletions.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
- Press F5 to Debug

## Compiling to Windows EXE, Linux or MacOS
- Open GitBash
- Open VS Code Terminal or Open GitBash on Directory
- Execute pkg .
- Wait until JustEmuTarkov-win.exe, JustEmuTarkov-linux, JustEmuTarkov-macos appear
- Wait until Server.exe appears / Process completes

## Distribution
Zip the following folders & files

- core (this is likely unwanted but pkg is not handling this correctly yet)
- db
- docs
- dbViewer
- express
- node_modules
- out
- public
- res
- src
- user
Expand All @@ -38,7 +41,30 @@ Zip the following folders & files
- Run the Server
- Provide your friends with your external IP address and port

## Features
- A modified Tarkov experience where you can host your own server and play alone or with others (working Client also required see [SIT.Tarkov.Launcher](https://github.com/paulov-t/SIT.Tarkov.Launcher) for details)
- A set of configurations to tailor your gameplay
- Airdrops (must have accompanying BepInEx plugin)
- AI PMCs
- Listens to extra Client Events
- JET Mod Support
- SPT-Aki Mod Support - *In Progress*
- Client sends more events to the Server - *In Progress*

## Known working Server mods
- [SIT M4](https://github.com/paulov-t/SIT-Mod-M4) - Makes the M4 actually useful and good mod to show how to make changes of your own.
- [SIT AI](https://github.com/paulov-t/SIT.ServerMod.AI) - Makes all AI move around, be more aggressive and generally make the game much harder.
- [SamSwat Benelli M4-Super-90 (m1014) - New Weapon](https://hub.sp-tarkov.com/files/file/261-l85-sa80-a2-british-assault-rifle/)
- [SamSwat L85 SA80 AR - New Weapon](https://hub.sp-tarkov.com/files/file/181-benelli-m4-super-90-m1014/)
- [Nehax MagazineManiac](https://github.com/Nehaxfr/Nehax-MagazineManiac)

## Documentation
*This is Work in Progress*
- Documentation can be auto generated using ``npm run generate-docs .``
- You can run the server and discover the generated docs at https://localhost:443/out or https://localhost:443/docs

## DB Viewer
*This is Work in Progress*
- You can find the DBViewer at https://localhost:443/db


4 changes: 3 additions & 1 deletion core/server/tarkovSend.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ class TarkovSend {
const _split = file.split(".");
let type = TarkovSend.mimeTypes[_split[_split.length - 1]] || TarkovSend.mimeTypes["txt"];

// console.log(process.cwd() + "/" + file);
// console.log(file);
// Post 0.12.12.15.17975, it now gets stuff from files not res
if(file.indexOf("/files/") !== -1 && !fs.existsSync(process.cwd() + file))
if(file.indexOf("/files/") !== -1 && !fs.existsSync(process.cwd() + "/" + file))
file = file.replace("/files/", "/res/");

let fileStream = fs.createReadStream(file);
Expand Down
32 changes: 31 additions & 1 deletion core/util/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,34 @@ exports.splitStack = (item) => {
return stacks;
}

exports.clamp = (value, min, max) => Math.min(Math.max(value, min), max);
exports.clamp = (value, min, max) => Math.min(Math.max(value, min), max);

/**
* This ES6(ECMAScript) function getQueryStringParameters takes url
* as parmater and returns
* parameters name and value in JSON key value format
* @parameter {String} url
* (if url is not passed it takes the current url
* from window.location.href)
*
**/
exports.getQueryStringParameters = url => {

var query = "";
if (url){
if(url.split("?").length>0){
query = url.split("?")[1];
}
}else{
url = window.location.href;
query = window.location.search.substring(1);
}
return (/^[?#]/.test(query) ? query.slice(1) : query)
.split('&')
.reduce((params, param) =>
{
let [ key, value ] = param.split('=');
params[key] = value?decodeURIComponent(value.replace(/\+/g, ' ')):'';
return params;
}, { });
};
2 changes: 1 addition & 1 deletion dbViewer/traders.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ <h4>{{ item.base.nickname }}</h4>
, methods: {
updateAssort(traderId) {
$.ajax( {
url : `/db/getTradingAssort/${traderId}`,
url : `/db/getTradingAssort?tid=${traderId}`,
type: 'POST',
async: false,
dataType : "json",
Expand Down
4 changes: 3 additions & 1 deletion src/Controllers/ItemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const utility = require('../../core/util/utility');
class ItemController
{
static getDatabaseItems() {
return DatabaseController.getDatabase().items;
const dbItems = DatabaseController.getDatabase().items;

return dbItems;
}

/**
Expand Down
36 changes: 28 additions & 8 deletions src/Controllers/ResponseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,12 @@ class ResponseDbViewer {

constructor() {
// Items ----------------
var listOfItems = ItemController.getDatabaseItems();
for(const itemId in listOfItems) {
ResponseController.addRoute(`/db/getItemInfo/${itemId}`, (url, info, sessionID) => { return JSON.stringify(listOfItems[itemId]); });
};
ResponseController.addRoute(`/db/getItemInfo`, (url, info, sessionID) => {
const qsParams = utility.getQueryStringParameters(url);
var listOfItems = ItemController.getDatabaseItems();
return JSON.stringify(listOfItems(qsParams.itemId));

});
ResponseController.addRoute(`/db/searchItemsByName/`, (url, info, sessionID) => {
if (info.searchParams !== undefined) {
for(const itemId in listOfItems) {
Expand All @@ -460,19 +462,37 @@ class ResponseDbViewer {

// Traders ----------------
var listOfTraders = TradingController.getAllTraders();
ResponseController.addRoute(`/db/getTraders/`, (url, info, sessionID) => { return JSON.stringify(listOfTraders); })
ResponseController.addRoute(`/db/getTraders/`, (url, info, sessionID) => {
// always get the database current list of traders, so recall getAllTraders here
return JSON.stringify(TradingController.getAllTraders());
});
for(const t of listOfTraders) {
ResponseController.addRoute(`/db/getTraderInfo/${t.base._id}`, (url, info, sessionID) => {
return JSON.stringify(t);
})
return JSON.stringify(TradingController.getTrader(t.base._id));
});
ResponseController.addRoute(`/db/getTradingAssort/${t.base._id}`, (url, info, sessionID) => {
const assort = TradingController.getTraderAssort(t.base._id);
assort.items.forEach(element => {
element["itemInfo"] = ItemController.getDatabaseItems()[element._tpl];
});
return JSON.stringify(assort);
})
});
};
ResponseController.addRoute(`/db/getTraderInfo`, (url, info, sessionID) => {
const qsParams = utility.getQueryStringParameters(url);

return JSON.stringify(TradingController.getTrader(qsParams.tid));

});
ResponseController.addRoute(`/db/getTradingAssort`, (url, info, sessionID) => {
const qsParams = utility.getQueryStringParameters(url);

const assort = TradingController.getTraderAssort(qsParams.tid);
assort.items.forEach(element => {
element["itemInfo"] = ItemController.getDatabaseItems()[element._tpl];
});
return JSON.stringify(assort);
});

// Users ----------------
// var listOfTraders = TradingController.getAllTraders();
Expand Down
9 changes: 9 additions & 0 deletions src/Controllers/TradingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@ class TradingController {
DatabaseController.getDatabase().traders[traderId] = assort;
}

/**
*
* @param {*} traderId
* @returns
*/
static getTrader(traderId) {
return DatabaseController.getDatabase().traders[traderId];
}

/**
*
* @param {*} traderId
Expand Down

0 comments on commit 043892d

Please sign in to comment.