Skip to content

Commit

Permalink
Merge pull request #11 from msdigital/v1.22.5
Browse files Browse the repository at this point in the history
Add support for different map sizes
  • Loading branch information
msdigital authored Feb 28, 2022
2 parents 05a7a92 + 1222f9b commit 2187c22
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
8 changes: 7 additions & 1 deletion config.server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//////////////////////////////////////////////////////
// DO NOT CHANGE THIS FILE IT MAY BREAK THE APP!
//////////////////////////////////////////////////////
// AENDERUNGEN AN DIESER DATEI KOENNEN DAZU FUEHREN
// DASS DIE APP NICHT MEHR KORREKT FUNKTIONIERT!
//////////////////////////////////////////////////////
const { exitOnError } = require('./server/lib/logger');
var logger = require('./server/lib/logger');

Expand All @@ -20,6 +26,6 @@ for (const [k,v] of Object.entries(config)){

if (errored) process.exit();

config.VERSION = process.env.npm_package_version;
config.VERSION = process.env.npm_package_version | 'V1.22.5';

module.exports = config;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oasis",
"version": "1.22.4",
"version": "1.22.5",
"description": "Live Map for Farming Simulator 22",
"main": "server/app.js",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports.getEntities = function (cb) {
server: new Server(result.Server._attributes),
slots: new Slots(result.Server.Slots._attributes),
players: Player.getPlayers(result.Server.Slots.Player),
vehicles: Vehicle.getVehicles(result.Server.Vehicles.Vehicle)
vehicles: Vehicle.getVehicles(result.Server.Vehicles.Vehicle, result.Server._attributes.mapSize)
})
})
}
Expand Down
6 changes: 3 additions & 3 deletions server/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ var filterFloat = function (value) {
return NaN;
}

module.exports.calcCoords = function(x,y){
module.exports.calcCoords = function(size, x,y){
var newX = null
var newY = null

if(x!=null && y!=null) {
newX = (x/1024)*375
newY = ((y/1024)*375)*(-1)
newX = (x / (size / 2))*375
newY = ((y / (size / 2))*375)*(-1)
}

return {x: newX, y: newY}
Expand Down
12 changes: 10 additions & 2 deletions server/model/vehicle.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
var lodash = require('lodash')
, util = require('../lib/util')

module.exports.getVehicles = function(vehicles){
var mapSize

module.exports.getVehicles = function(vehicles, map){
var results = []
mapSize = map;

if (!Array.isArray(vehicles)){
vehicles = [vehicles];
}

vehicles.forEach(vehicle => {
if(!lodash.isEmpty(vehicle)){
results.push(new this.Vehicle(vehicle))
Expand All @@ -12,7 +20,7 @@ module.exports.getVehicles = function(vehicles){
}

module.exports.Vehicle = function(vehicle){
var coords = util.calcCoords(vehicle._attributes.x, vehicle._attributes.z)
var coords = util.calcCoords(mapSize, vehicle._attributes.x, vehicle._attributes.z)

this.name = vehicle._attributes.name
this.posx = coords.x
Expand Down

0 comments on commit 2187c22

Please sign in to comment.