Skip to content

Commit

Permalink
[v6.0.3] Release
Browse files Browse the repository at this point in the history
  • Loading branch information
evolutionleo committed Oct 8, 2024
1 parent 6c1cebd commit 94815ec
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 51 deletions.
33 changes: 16 additions & 17 deletions JavascriptServer/concepts/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EventEmitter } from "events";
import { CircleCollider, BoxCollider, PolygonCollider } from '#concepts/collider';

import { v4 as uuidv4 } from 'uuid';
import { isDeepStrictEqual } from 'util';

// a thing
class Entity extends EventEmitter {
Expand All @@ -21,7 +22,7 @@ class Entity extends EventEmitter {
angle = 0;

prev_pos;
prev_serialized; // json of serialized entity
serialized; // save the last serialized version of this entity (to compare changes)

base_size = { x: 64, y: 64 };
scale = { x: 1, y: 1 };
Expand Down Expand Up @@ -112,10 +113,10 @@ class Entity extends EventEmitter {
this.emit('update');

// if something changed - send again (add to the room's bundle)
const serialized = JSON.stringify(this.serialize());
if (serialized != this.prev_serialized || this.sendEveryTick) {
this.prev_serialized = serialized;
this.send(); // add to the bundle
const new_serialized = this.serialize();
if (this.sendEveryTick || !isDeepStrictEqual(new_serialized, this.serialized)) {
this.serialized = new_serialized;
this.send(true); // add to the bundle
}
}

Expand Down Expand Up @@ -187,10 +188,6 @@ class Entity extends EventEmitter {
this.regenerateCollider(x, y);
}

// if (this.size.x != this.prev_size.x || this.size.y != this.prev_size.y) {
// // change the collider scale by the same ratio as the entity scale
// this.collider.setScale(this.collider.scaleX * this.size.x / this.prev_size.x, this.collider.scaleY * this.size.y / this.prev_size.y);
// }
this.collider.setAngle(this.angle);
this.collider.setPosition(x, y);
this.tree.updateBody(this.collider);
Expand Down Expand Up @@ -278,8 +275,9 @@ class Entity extends EventEmitter {
y: this.roundedPos(this.y),
xs: this.xscale,
ys: this.yscale,
a: this.angle,
spd: this.spd,
p: this.props,
p: this.props, // uses a getter for props
st: this.state
};
}
Expand All @@ -288,8 +286,14 @@ class Entity extends EventEmitter {
return this.serialize();
}

send() {
const data = this.bundle();
send(cached = false) {
let data;

if (!cached)
data = this.bundle();
else
data = this.serialized;

this.room.bundle.push(data);
}

Expand All @@ -299,11 +303,6 @@ class Entity extends EventEmitter {
let w = this.width, h = this.height;

return {
// left: x - w/2,
// top: y - h/2,
// right: x + w/2,
// bottom: y + h/2,

left: x,
top: y,
right: x + w,
Expand Down
66 changes: 33 additions & 33 deletions JavascriptServer/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ const common_config = {

// some fundamental lobby settings
lobby: {
max_players: 100,
add_into_play_on_full: true,
add_into_play_on_join: false,
max_players: 100, // used when creating a lobby with no map/game mode
add_into_play_on_full: true, // true - add all the players into play at the same time once the lobby is filled,
add_into_play_on_join: false, // true - add players one by one immediately as they join a lobby
allow_join_by_id: false,
close_on_leave: true // close the lobby if a player leaves
},

room: {
// .yy room loading
rooms_path: '../Client/rooms',
rooms_path: '../Client/rooms', // (overriden in prod config)
warn_on_unknown_entity: false,

use_starting_room: true,
use_last_profile_room: false,
use_persistent_position: false,
use_starting_room: true, // join config.room.starting_room on start
use_last_profile_room: false, // join client.profile.state.room on start if logged in
use_persistent_position: false, // load the last x/y from the profile on room join and save them on room leave

starting_room: 'Test Room',
rest_timeout: 5,
rest_timeout: 5, // (seconds) - prevents rooms from processing entities
// when no players are present for a certain amount of time
// set to -1 to disable this feature
// (!!! setting to 0 might cause problems and unexpected behaviour !!!)
Expand All @@ -116,42 +116,42 @@ const common_config = {
},

party: {
max_members: 5,
max_members: 5, // max party size
leader_only_mm: false // true - only party leader can start matchmaking
},

matchmaking: {
mmr_starting: 1000,
mmr_min: 1,
mmr_starting: 1000, // the starting mmr given to new players
mmr_min: 1, // can't go below this

mmr_scale: 1000,
mmr_scale: 1000, // lower number = less effect opponent's mmr has on mmr change
// (chess uses 400, meaning a player with 400 mmr more is on average 10x more likely to win)
mmr_max_gain: 50,
mmr_max_difference: 500,
mmr_max_gain: 50, // the maximum possible amount of mmr that a player can gain after a single game, winning against an equal opponent will give half of this
mmr_max_difference: 500, // can't ever register a ranked match with players' mmr difference more than this

process_interval: 1 * 1000 // matchmaking: attempt to create new matches every X ms
},

tps: 20,
tps: 20, // tickrate

// Disable some of the features that you don't need in your game
// true = enabled, false = disabled
timestamps_enabled: true,
ws_enabled: true,
db_enabled: true,
shell_enabled: false,
rooms_enabled: true,
entities_enabled: true,
dt_enabled: true,
ssl_enabled: false,
logging_enabled: true,
validation_enabled: true,
middleware_enabled: true,
matchmaking_enabled: true,

verbose_lag: false,

necessary_login: false,
timestamps_enabled: true, // send timestamps with each packet (there is a client-side config as well)
ws_enabled: true, // websocket server?
db_enabled: true, // MongoDB support
shell_enabled: false, // toggles a console that allows code execution while running the game (better to change this in prod/dev configs rather than here)
rooms_enabled: true, // toggles lobbies being split into rooms (sub-lobbies with entities)
entities_enabled: true, // toggles loading/spawning entities
dt_enabled: true, // toggles delta time for entity physics
ssl_enabled: false, // SSL support. false by default (best set in the prod/dev configs)
logging_enabled: true, // whether or not to log trace()'d messages to server_log.txt
validation_enabled: true, // validate the incoming commands using ValidatorJS's validators
middleware_enabled: true, // middleware to execute before some packets are handled
matchmaking_enabled: true, // use the matchmaking system with queues and tickets

verbose_lag: false, // logs warning messages to chat when a game tick is taking longer than expected

necessary_login: false, // if true, won't allow a client to join any lobby before logging in

ping_interval: 5 * 1000
};
Expand All @@ -161,7 +161,7 @@ const prod_config = {
server: 'production'
},
env_name: 'prod',
ip: '0.0.0.0',
ip: '0.0.0.0', // you need to replace this with your domain if using ssl for it to work
port: parseInt(args.port) || 1337,
ws_port: parseInt(args.ws_port) || 3000,

Expand All @@ -174,7 +174,7 @@ const prod_config = {
ssl_cert_path: '/etc/letsencrypt/live/example.com/cert.pem',
ssl_key_path: '/etc/letsencrypt/live/example.com/privkey.pem',

db: args.db || 'mongodb://127.0.0.1:27017/warp-game',
db: args.db || 'mongodb://127.0.0.1:27017/warp-game', // by default it uses the same db name for dev/prod, but
// you can add a postfix at the end of the name to separate them
shell_enabled: false,
verbose_lag: false,
Expand Down
2 changes: 1 addition & 1 deletion JavascriptServer/schemas/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const profileSchema = new Schema({
last_online: { type: Date, default: Date.now },

friends: [{ type: Schema.Types.ObjectId, ref: 'Profile' }],
mmr: { type: Number, required: false },
mmr: { type: Number, required: false }, // matchmaking rating


state: {
Expand Down
1 change: 1 addition & 0 deletions JavascriptServer/util/load_room.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default function LoadRoom(room_name) {
y: inst.y,
xs: inst.scaleX,
ys: inst.scaleY,
a: inst.rotation,
t: type,
spd: { x: 0, y: 0 },
p: props,
Expand Down
Binary file modified Release/GMClient.zip
Binary file not shown.
Binary file modified Release/JSServer.zip
Binary file not shown.
Binary file modified Release/TSServer.zip
Binary file not shown.
Binary file modified Release/Warp.yymps
Binary file not shown.
Binary file modified Release/WebClient.zip
Binary file not shown.
1 change: 1 addition & 0 deletions TypescriptServer/src/util/load_room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default function LoadRoom(room_name:string):LoadedRoom {
y: inst.y,
xs: inst.scaleX,
ys: inst.scaleY,
a: inst.rotation,
t: type,
spd: {x: 0, y: 0},
p: props,
Expand Down

0 comments on commit 94815ec

Please sign in to comment.