Skip to content

Commit 94815ec

Browse files
committed
[v6.0.3] Release
1 parent 6c1cebd commit 94815ec

File tree

10 files changed

+52
-51
lines changed

10 files changed

+52
-51
lines changed

JavascriptServer/concepts/entity.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { EventEmitter } from "events";
22
import { CircleCollider, BoxCollider, PolygonCollider } from '#concepts/collider';
33

44
import { v4 as uuidv4 } from 'uuid';
5+
import { isDeepStrictEqual } from 'util';
56

67
// a thing
78
class Entity extends EventEmitter {
@@ -21,7 +22,7 @@ class Entity extends EventEmitter {
2122
angle = 0;
2223

2324
prev_pos;
24-
prev_serialized; // json of serialized entity
25+
serialized; // save the last serialized version of this entity (to compare changes)
2526

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

114115
// if something changed - send again (add to the room's bundle)
115-
const serialized = JSON.stringify(this.serialize());
116-
if (serialized != this.prev_serialized || this.sendEveryTick) {
117-
this.prev_serialized = serialized;
118-
this.send(); // add to the bundle
116+
const new_serialized = this.serialize();
117+
if (this.sendEveryTick || !isDeepStrictEqual(new_serialized, this.serialized)) {
118+
this.serialized = new_serialized;
119+
this.send(true); // add to the bundle
119120
}
120121
}
121122

@@ -187,10 +188,6 @@ class Entity extends EventEmitter {
187188
this.regenerateCollider(x, y);
188189
}
189190

190-
// if (this.size.x != this.prev_size.x || this.size.y != this.prev_size.y) {
191-
// // change the collider scale by the same ratio as the entity scale
192-
// this.collider.setScale(this.collider.scaleX * this.size.x / this.prev_size.x, this.collider.scaleY * this.size.y / this.prev_size.y);
193-
// }
194191
this.collider.setAngle(this.angle);
195192
this.collider.setPosition(x, y);
196193
this.tree.updateBody(this.collider);
@@ -278,8 +275,9 @@ class Entity extends EventEmitter {
278275
y: this.roundedPos(this.y),
279276
xs: this.xscale,
280277
ys: this.yscale,
278+
a: this.angle,
281279
spd: this.spd,
282-
p: this.props,
280+
p: this.props, // uses a getter for props
283281
st: this.state
284282
};
285283
}
@@ -288,8 +286,14 @@ class Entity extends EventEmitter {
288286
return this.serialize();
289287
}
290288

291-
send() {
292-
const data = this.bundle();
289+
send(cached = false) {
290+
let data;
291+
292+
if (!cached)
293+
data = this.bundle();
294+
else
295+
data = this.serialized;
296+
293297
this.room.bundle.push(data);
294298
}
295299

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

301305
return {
302-
// left: x - w/2,
303-
// top: y - h/2,
304-
// right: x + w/2,
305-
// bottom: y + h/2,
306-
307306
left: x,
308307
top: y,
309308
right: x + w,

JavascriptServer/config.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,24 @@ const common_config = {
9090

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

100100
room: {
101101
// .yy room loading
102-
rooms_path: '../Client/rooms',
102+
rooms_path: '../Client/rooms', // (overriden in prod config)
103103
warn_on_unknown_entity: false,
104104

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

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

118118
party: {
119-
max_members: 5,
119+
max_members: 5, // max party size
120120
leader_only_mm: false // true - only party leader can start matchmaking
121121
},
122122

123123
matchmaking: {
124-
mmr_starting: 1000,
125-
mmr_min: 1,
124+
mmr_starting: 1000, // the starting mmr given to new players
125+
mmr_min: 1, // can't go below this
126126

127-
mmr_scale: 1000,
127+
mmr_scale: 1000, // lower number = less effect opponent's mmr has on mmr change
128128
// (chess uses 400, meaning a player with 400 mmr more is on average 10x more likely to win)
129-
mmr_max_gain: 50,
130-
mmr_max_difference: 500,
129+
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
130+
mmr_max_difference: 500, // can't ever register a ranked match with players' mmr difference more than this
131131

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

135-
tps: 20,
135+
tps: 20, // tickrate
136136

137137
// Disable some of the features that you don't need in your game
138138
// true = enabled, false = disabled
139-
timestamps_enabled: true,
140-
ws_enabled: true,
141-
db_enabled: true,
142-
shell_enabled: false,
143-
rooms_enabled: true,
144-
entities_enabled: true,
145-
dt_enabled: true,
146-
ssl_enabled: false,
147-
logging_enabled: true,
148-
validation_enabled: true,
149-
middleware_enabled: true,
150-
matchmaking_enabled: true,
151-
152-
verbose_lag: false,
153-
154-
necessary_login: false,
139+
timestamps_enabled: true, // send timestamps with each packet (there is a client-side config as well)
140+
ws_enabled: true, // websocket server?
141+
db_enabled: true, // MongoDB support
142+
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)
143+
rooms_enabled: true, // toggles lobbies being split into rooms (sub-lobbies with entities)
144+
entities_enabled: true, // toggles loading/spawning entities
145+
dt_enabled: true, // toggles delta time for entity physics
146+
ssl_enabled: false, // SSL support. false by default (best set in the prod/dev configs)
147+
logging_enabled: true, // whether or not to log trace()'d messages to server_log.txt
148+
validation_enabled: true, // validate the incoming commands using ValidatorJS's validators
149+
middleware_enabled: true, // middleware to execute before some packets are handled
150+
matchmaking_enabled: true, // use the matchmaking system with queues and tickets
151+
152+
verbose_lag: false, // logs warning messages to chat when a game tick is taking longer than expected
153+
154+
necessary_login: false, // if true, won't allow a client to join any lobby before logging in
155155

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

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

177-
db: args.db || 'mongodb://127.0.0.1:27017/warp-game',
177+
db: args.db || 'mongodb://127.0.0.1:27017/warp-game', // by default it uses the same db name for dev/prod, but
178178
// you can add a postfix at the end of the name to separate them
179179
shell_enabled: false,
180180
verbose_lag: false,

JavascriptServer/schemas/profile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const profileSchema = new Schema({
1212
last_online: { type: Date, default: Date.now },
1313

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

1717

1818
state: {

JavascriptServer/util/load_room.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default function LoadRoom(room_name) {
6565
y: inst.y,
6666
xs: inst.scaleX,
6767
ys: inst.scaleY,
68+
a: inst.rotation,
6869
t: type,
6970
spd: { x: 0, y: 0 },
7071
p: props,

Release/GMClient.zip

3 Bytes
Binary file not shown.

Release/JSServer.zip

-14 Bytes
Binary file not shown.

Release/TSServer.zip

-45.5 KB
Binary file not shown.

Release/Warp.yymps

3 Bytes
Binary file not shown.

Release/WebClient.zip

0 Bytes
Binary file not shown.

TypescriptServer/src/util/load_room.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default function LoadRoom(room_name:string):LoadedRoom {
7272
y: inst.y,
7373
xs: inst.scaleX,
7474
ys: inst.scaleY,
75+
a: inst.rotation,
7576
t: type,
7677
spd: {x: 0, y: 0},
7778
p: props,

0 commit comments

Comments
 (0)