mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 08:36:52 +00:00
Minor updates.
This commit is contained in:
@@ -29,23 +29,6 @@ var constants = {
|
||||
BGM: "BGM"
|
||||
}
|
||||
},
|
||||
PLAYER_NAME: {
|
||||
1: "Merdan",
|
||||
2: "Monroe",
|
||||
},
|
||||
SOCKET_EVENT: {
|
||||
CONTROL: "control",
|
||||
SYNC: "sync",
|
||||
LOGIN: "login",
|
||||
CREATE: "create"
|
||||
},
|
||||
WECHAT: {
|
||||
AUTHORIZE_PATH: "/connect/oauth2/authorize",
|
||||
REDIRECT_RUI_KEY: "redirect_uri=",
|
||||
RESPONSE_TYPE: "response_type=code",
|
||||
SCOPE: "scope=snsapi_userinfo",
|
||||
FIN: "#wechat_redirect"
|
||||
},
|
||||
ROUTE_PATH: (_ROUTE_PATH = {
|
||||
PLAYER: "/player",
|
||||
JSCONFIG: "/jsconfig",
|
||||
@@ -61,8 +44,6 @@ var constants = {
|
||||
LIST: "/list",
|
||||
READ: "/read",
|
||||
PROFILE: "/profile",
|
||||
WECHAT: "/wechat",
|
||||
WECHATGAME: "/wechatGame",
|
||||
FETCH: "/fetch",
|
||||
}, _defineProperty(_ROUTE_PATH, "LOGIN", "/login"), _defineProperty(_ROUTE_PATH, "RET_CODE", "/retCode"), _defineProperty(_ROUTE_PATH, "REGEX", "/regex"), _defineProperty(_ROUTE_PATH, "SMS_CAPTCHA", "/SmsCaptcha"), _defineProperty(_ROUTE_PATH, "GET", "/get"), _ROUTE_PATH),
|
||||
REQUEST_QUERY: {
|
||||
@@ -138,7 +119,6 @@ var constants = {
|
||||
INCORRECT_PHONE_NUMBER: '手机号不正确',
|
||||
LOG_OUT: '您已在其他地方登陆',
|
||||
GAME_OVER: '游戏结束,您的得分是',
|
||||
WECHAT_LOGIN_FAILS: "微信登录失败",
|
||||
},
|
||||
CONFIRM_BUTTON_LABEL: {
|
||||
RESTART: '重新开始'
|
||||
|
@@ -78,11 +78,9 @@ message HeartbeatUpsync {
|
||||
|
||||
message RoomDownsyncFrame {
|
||||
int32 id = 1;
|
||||
int32 refFrameId = 2;
|
||||
map<int32, Player> players = 3;
|
||||
int64 sentAt = 4;
|
||||
int64 countdownNanos = 5;
|
||||
map<int32, PlayerMeta> playerMetas = 6;
|
||||
map<int32, Player> players = 2;
|
||||
int64 countdownNanos = 3;
|
||||
map<int32, PlayerMeta> playerMetas = 4;
|
||||
}
|
||||
|
||||
message WsReq {
|
||||
|
@@ -440,7 +440,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
209.73151519075364,
|
||||
210.43837950571782,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@@ -18,11 +18,8 @@ window.ALL_BATTLE_STATES = {
|
||||
};
|
||||
|
||||
window.MAGIC_ROOM_DOWNSYNC_FRAME_ID = {
|
||||
PLAYER_ADDED_AND_ACKED: -98,
|
||||
PLAYER_READDED_AND_ACKED: -97,
|
||||
|
||||
BATTLE_READY_TO_START: -1,
|
||||
BATTLE_START: 0,
|
||||
BATTLE_START: 0
|
||||
};
|
||||
|
||||
cc.Class({
|
||||
@@ -124,9 +121,13 @@ cc.Class({
|
||||
type: cc.Float,
|
||||
default: 1.0/60
|
||||
},
|
||||
perFrameDtMaxTolerance: {
|
||||
rollbackEstimatedDtMillis: {
|
||||
type: cc.Float,
|
||||
default: 1.0/600
|
||||
default: 1000.0/60
|
||||
},
|
||||
rollbackEstimatedDtToleranceMillis: {
|
||||
type: cc.Float,
|
||||
default: 1.0/60
|
||||
},
|
||||
maxChasingRenderFramesPerUpdate: {
|
||||
type: cc.Integer,
|
||||
@@ -353,7 +354,7 @@ cc.Class({
|
||||
self.lastAllConfirmedInputFrameId = -1;
|
||||
self.chaserRenderFrameId = -1; // at any moment, "lastAllConfirmedRenderFrameId <= chaserRenderFrameId <= renderFrameId", but "chaserRenderFrameId" would fluctuate according to "handleInputFrameDownsyncBatch"
|
||||
|
||||
self.inputDelayFrames = 8;
|
||||
self.inputDelayFrames = 4;
|
||||
self.inputScaleFrames = 2;
|
||||
self.lastUpsyncInputFrameId = -1;
|
||||
self.inputFrameUpsyncDelayTolerance = 2;
|
||||
@@ -547,34 +548,24 @@ cc.Class({
|
||||
self._inputControlEnabled = false;
|
||||
|
||||
let findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer");
|
||||
window.handleRoomDownsyncFrame = function(rdf) {
|
||||
if (ALL_BATTLE_STATES.WAITING != self.battleState
|
||||
&& ALL_BATTLE_STATES.IN_BATTLE != self.battleState
|
||||
&& ALL_BATTLE_STATES.IN_SETTLEMENT != self.battleState) {
|
||||
return;
|
||||
window.handlePlayerAdded = function(rdf) {
|
||||
// Update the "finding player" GUI and show it if not previously present
|
||||
if (!self.findingPlayerNode.parent) {
|
||||
self.showPopupInCanvas(self.findingPlayerNode);
|
||||
}
|
||||
findingPlayerScriptIns.updatePlayersInfo(rdf.playerMetas);
|
||||
};
|
||||
|
||||
window.handleRoomDownsyncFrame = function(rdf) {
|
||||
const frameId = rdf.id;
|
||||
// Right upon establishment of the "PersistentSessionClient", we should receive an initial signal "BattleColliderInfo" earlier than any "RoomDownsyncFrame" containing "PlayerMeta" data.
|
||||
const refFrameId = rdf.refFrameId;
|
||||
switch (refFrameId) {
|
||||
case window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.PLAYER_ADDED_AND_ACKED:
|
||||
// Update the "finding player" GUI and show it if not previously present
|
||||
if (!self.findingPlayerNode.parent) {
|
||||
self.showPopupInCanvas(self.findingPlayerNode);
|
||||
}
|
||||
findingPlayerScriptIns.updatePlayersInfo(rdf.playerMetas);
|
||||
return;
|
||||
switch (frameId) {
|
||||
case window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_READY_TO_START:
|
||||
self.onBattleReadyToStart(rdf.playerMetas, false);
|
||||
return;
|
||||
case window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START:
|
||||
self.onBattleStartedOrResynced(rdf);
|
||||
return;
|
||||
case window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.PLAYER_READDED_AND_ACKED:
|
||||
self.onBattleReadyToStart(rdf.playerMetas, true);
|
||||
self.onBattleStartedOrResynced(rdf);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Inject a NetworkDoctor as introduced in https://app.yinxiang.com/shard/s61/nl/13267014/5c575124-01db-419b-9c02-ec81f78c6ddc/.
|
||||
@@ -728,6 +719,7 @@ cc.Class({
|
||||
self.applyRoomDownsyncFrameDynamics(rdf);
|
||||
self._dumpToRenderCache(rdf);
|
||||
self.battleState = ALL_BATTLE_STATES.IN_BATTLE; // Starts the increment of "self.renderFrameId" in "self.update(dt)"
|
||||
self.lastRenderFrameIdTriggeredAt = performance.now();
|
||||
if (null != window.boundRoomId) {
|
||||
self.boundRoomIdLabel.string = window.boundRoomId;
|
||||
}
|
||||
@@ -791,8 +783,9 @@ cc.Class({
|
||||
update(dt) {
|
||||
const self = this;
|
||||
if (ALL_BATTLE_STATES.IN_BATTLE == self.battleState) {
|
||||
if (dt < self.rollbackEstimatedDt-self.perFrameDtMaxTolerance) {
|
||||
console.warn("Avoiding too fast frame@renderFrameId=", self.renderFrameId, ": dt=", dt);
|
||||
const elapsedMillisSinceLastFrameIdTriggered = performance.now() - self.lastRenderFrameIdTriggeredAt;
|
||||
if (elapsedMillisSinceLastFrameIdTriggered < (self.rollbackEstimatedDtMillis)) {
|
||||
// console.debug("Avoiding too fast frame@renderFrameId=", self.renderFrameId, ": elapsedMillisSinceLastFrameIdTriggered=", elapsedMillisSinceLastFrameIdTriggered);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -842,6 +835,7 @@ cc.Class({
|
||||
self.countdownLabel.string = countdownSeconds;
|
||||
}
|
||||
++self.renderFrameId; // [WARNING] It's important to increment the renderFrameId AFTER all the operations above!!!
|
||||
self.lastRenderFrameIdTriggeredAt = performance.now();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@@ -2,11 +2,16 @@ window.UPSYNC_MSG_ACT_HB_PING = 1;
|
||||
window.UPSYNC_MSG_ACT_PLAYER_CMD = 2;
|
||||
window.UPSYNC_MSG_ACT_PLAYER_COLLIDER_ACK = 3;
|
||||
|
||||
window.DOWNSYNC_MSG_ACT_PLAYER_ADDED_AND_ACKED = -98;
|
||||
window.DOWNSYNC_MSG_ACT_PLAYER_READDED_AND_ACKED = -97;
|
||||
window.DOWNSYNC_MSG_ACT_BATTLE_READY_TO_START = -1;
|
||||
window.DOWNSYNC_MSG_ACT_BATTLE_START = 0;
|
||||
window.DOWNSYNC_MSG_ACT_HB_REQ = 1;
|
||||
window.DOWNSYNC_MSG_ACT_INPUT_BATCH = 2;
|
||||
window.DOWNSYNC_MSG_ACT_ROOM_FRAME = 3;
|
||||
window.DOWNSYNC_MSG_ACT_FORCED_RESYNC = 4;
|
||||
|
||||
|
||||
window.sendSafely = function(msgStr) {
|
||||
/**
|
||||
* - "If the data can't be sent (for example, because it needs to be buffered but the buffer is full), the socket is closed automatically."
|
||||
@@ -154,6 +159,14 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
case window.DOWNSYNC_MSG_ACT_HB_REQ:
|
||||
window.handleHbRequirements(resp); // 获取boundRoomId并存储到localStorage
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_PLAYER_ADDED_AND_ACKED:
|
||||
window.handlePlayerAdded(resp.rdf);
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_PLAYER_READDED_AND_ACKED:
|
||||
// Deliberately left blank for now
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_BATTLE_READY_TO_START:
|
||||
case window.DOWNSYNC_MSG_ACT_BATTLE_START:
|
||||
case window.DOWNSYNC_MSG_ACT_ROOM_FRAME:
|
||||
if (window.handleRoomDownsyncFrame) {
|
||||
window.handleRoomDownsyncFrame(resp.rdf);
|
||||
@@ -166,7 +179,7 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
break;
|
||||
case window.DOWNSYNC_MSG_ACT_FORCED_RESYNC:
|
||||
if (window.handleInputFrameDownsyncBatch && window.handleRoomDownsyncFrame) {
|
||||
console.warn("GOT forced resync:", resp);
|
||||
console.warn("Got forced resync:", resp.toString(), " @localRenderFrameId=", mapIns.renderFrameId, ", @localRecentInputCache=", mapIns._stringifyRecentInputCache(false));
|
||||
// The following order of execution is important, because "handleInputFrameDownsyncBatch" is only available when state is IN_BATTLE
|
||||
window.handleRoomDownsyncFrame(resp.rdf);
|
||||
window.handleInputFrameDownsyncBatch(resp.inputFrameDownsyncBatch);
|
||||
|
@@ -3131,9 +3131,7 @@ $root.treasurehunterx = (function() {
|
||||
* @memberof treasurehunterx
|
||||
* @interface IRoomDownsyncFrame
|
||||
* @property {number|null} [id] RoomDownsyncFrame id
|
||||
* @property {number|null} [refFrameId] RoomDownsyncFrame refFrameId
|
||||
* @property {Object.<string,treasurehunterx.Player>|null} [players] RoomDownsyncFrame players
|
||||
* @property {number|Long|null} [sentAt] RoomDownsyncFrame sentAt
|
||||
* @property {number|Long|null} [countdownNanos] RoomDownsyncFrame countdownNanos
|
||||
* @property {Object.<string,treasurehunterx.PlayerMeta>|null} [playerMetas] RoomDownsyncFrame playerMetas
|
||||
*/
|
||||
@@ -3163,14 +3161,6 @@ $root.treasurehunterx = (function() {
|
||||
*/
|
||||
RoomDownsyncFrame.prototype.id = 0;
|
||||
|
||||
/**
|
||||
* RoomDownsyncFrame refFrameId.
|
||||
* @member {number} refFrameId
|
||||
* @memberof treasurehunterx.RoomDownsyncFrame
|
||||
* @instance
|
||||
*/
|
||||
RoomDownsyncFrame.prototype.refFrameId = 0;
|
||||
|
||||
/**
|
||||
* RoomDownsyncFrame players.
|
||||
* @member {Object.<string,treasurehunterx.Player>} players
|
||||
@@ -3179,14 +3169,6 @@ $root.treasurehunterx = (function() {
|
||||
*/
|
||||
RoomDownsyncFrame.prototype.players = $util.emptyObject;
|
||||
|
||||
/**
|
||||
* RoomDownsyncFrame sentAt.
|
||||
* @member {number|Long} sentAt
|
||||
* @memberof treasurehunterx.RoomDownsyncFrame
|
||||
* @instance
|
||||
*/
|
||||
RoomDownsyncFrame.prototype.sentAt = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
|
||||
|
||||
/**
|
||||
* RoomDownsyncFrame countdownNanos.
|
||||
* @member {number|Long} countdownNanos
|
||||
@@ -3229,20 +3211,16 @@ $root.treasurehunterx = (function() {
|
||||
writer = $Writer.create();
|
||||
if (message.id != null && Object.hasOwnProperty.call(message, "id"))
|
||||
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.id);
|
||||
if (message.refFrameId != null && Object.hasOwnProperty.call(message, "refFrameId"))
|
||||
writer.uint32(/* id 2, wireType 0 =*/16).int32(message.refFrameId);
|
||||
if (message.players != null && Object.hasOwnProperty.call(message, "players"))
|
||||
for (var keys = Object.keys(message.players), i = 0; i < keys.length; ++i) {
|
||||
writer.uint32(/* id 3, wireType 2 =*/26).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]);
|
||||
writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]);
|
||||
$root.treasurehunterx.Player.encode(message.players[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim();
|
||||
}
|
||||
if (message.sentAt != null && Object.hasOwnProperty.call(message, "sentAt"))
|
||||
writer.uint32(/* id 4, wireType 0 =*/32).int64(message.sentAt);
|
||||
if (message.countdownNanos != null && Object.hasOwnProperty.call(message, "countdownNanos"))
|
||||
writer.uint32(/* id 5, wireType 0 =*/40).int64(message.countdownNanos);
|
||||
writer.uint32(/* id 3, wireType 0 =*/24).int64(message.countdownNanos);
|
||||
if (message.playerMetas != null && Object.hasOwnProperty.call(message, "playerMetas"))
|
||||
for (var keys = Object.keys(message.playerMetas), i = 0; i < keys.length; ++i) {
|
||||
writer.uint32(/* id 6, wireType 2 =*/50).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]);
|
||||
writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 0 =*/8).int32(keys[i]);
|
||||
$root.treasurehunterx.PlayerMeta.encode(message.playerMetas[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim();
|
||||
}
|
||||
return writer;
|
||||
@@ -3284,10 +3262,6 @@ $root.treasurehunterx = (function() {
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
message.refFrameId = reader.int32();
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (message.players === $util.emptyObject)
|
||||
message.players = {};
|
||||
var end2 = reader.uint32() + reader.pos;
|
||||
@@ -3310,15 +3284,11 @@ $root.treasurehunterx = (function() {
|
||||
message.players[key] = value;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
message.sentAt = reader.int64();
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
case 3: {
|
||||
message.countdownNanos = reader.int64();
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
case 4: {
|
||||
if (message.playerMetas === $util.emptyObject)
|
||||
message.playerMetas = {};
|
||||
var end2 = reader.uint32() + reader.pos;
|
||||
@@ -3379,9 +3349,6 @@ $root.treasurehunterx = (function() {
|
||||
if (message.id != null && message.hasOwnProperty("id"))
|
||||
if (!$util.isInteger(message.id))
|
||||
return "id: integer expected";
|
||||
if (message.refFrameId != null && message.hasOwnProperty("refFrameId"))
|
||||
if (!$util.isInteger(message.refFrameId))
|
||||
return "refFrameId: integer expected";
|
||||
if (message.players != null && message.hasOwnProperty("players")) {
|
||||
if (!$util.isObject(message.players))
|
||||
return "players: object expected";
|
||||
@@ -3396,9 +3363,6 @@ $root.treasurehunterx = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (message.sentAt != null && message.hasOwnProperty("sentAt"))
|
||||
if (!$util.isInteger(message.sentAt) && !(message.sentAt && $util.isInteger(message.sentAt.low) && $util.isInteger(message.sentAt.high)))
|
||||
return "sentAt: integer|Long expected";
|
||||
if (message.countdownNanos != null && message.hasOwnProperty("countdownNanos"))
|
||||
if (!$util.isInteger(message.countdownNanos) && !(message.countdownNanos && $util.isInteger(message.countdownNanos.low) && $util.isInteger(message.countdownNanos.high)))
|
||||
return "countdownNanos: integer|Long expected";
|
||||
@@ -3433,8 +3397,6 @@ $root.treasurehunterx = (function() {
|
||||
var message = new $root.treasurehunterx.RoomDownsyncFrame();
|
||||
if (object.id != null)
|
||||
message.id = object.id | 0;
|
||||
if (object.refFrameId != null)
|
||||
message.refFrameId = object.refFrameId | 0;
|
||||
if (object.players) {
|
||||
if (typeof object.players !== "object")
|
||||
throw TypeError(".treasurehunterx.RoomDownsyncFrame.players: object expected");
|
||||
@@ -3445,15 +3407,6 @@ $root.treasurehunterx = (function() {
|
||||
message.players[keys[i]] = $root.treasurehunterx.Player.fromObject(object.players[keys[i]]);
|
||||
}
|
||||
}
|
||||
if (object.sentAt != null)
|
||||
if ($util.Long)
|
||||
(message.sentAt = $util.Long.fromValue(object.sentAt)).unsigned = false;
|
||||
else if (typeof object.sentAt === "string")
|
||||
message.sentAt = parseInt(object.sentAt, 10);
|
||||
else if (typeof object.sentAt === "number")
|
||||
message.sentAt = object.sentAt;
|
||||
else if (typeof object.sentAt === "object")
|
||||
message.sentAt = new $util.LongBits(object.sentAt.low >>> 0, object.sentAt.high >>> 0).toNumber();
|
||||
if (object.countdownNanos != null)
|
||||
if ($util.Long)
|
||||
(message.countdownNanos = $util.Long.fromValue(object.countdownNanos)).unsigned = false;
|
||||
@@ -3495,12 +3448,6 @@ $root.treasurehunterx = (function() {
|
||||
}
|
||||
if (options.defaults) {
|
||||
object.id = 0;
|
||||
object.refFrameId = 0;
|
||||
if ($util.Long) {
|
||||
var long = new $util.Long(0, 0, false);
|
||||
object.sentAt = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
||||
} else
|
||||
object.sentAt = options.longs === String ? "0" : 0;
|
||||
if ($util.Long) {
|
||||
var long = new $util.Long(0, 0, false);
|
||||
object.countdownNanos = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
|
||||
@@ -3509,19 +3456,12 @@ $root.treasurehunterx = (function() {
|
||||
}
|
||||
if (message.id != null && message.hasOwnProperty("id"))
|
||||
object.id = message.id;
|
||||
if (message.refFrameId != null && message.hasOwnProperty("refFrameId"))
|
||||
object.refFrameId = message.refFrameId;
|
||||
var keys2;
|
||||
if (message.players && (keys2 = Object.keys(message.players)).length) {
|
||||
object.players = {};
|
||||
for (var j = 0; j < keys2.length; ++j)
|
||||
object.players[keys2[j]] = $root.treasurehunterx.Player.toObject(message.players[keys2[j]], options);
|
||||
}
|
||||
if (message.sentAt != null && message.hasOwnProperty("sentAt"))
|
||||
if (typeof message.sentAt === "number")
|
||||
object.sentAt = options.longs === String ? String(message.sentAt) : message.sentAt;
|
||||
else
|
||||
object.sentAt = options.longs === String ? $util.Long.prototype.toString.call(message.sentAt) : options.longs === Number ? new $util.LongBits(message.sentAt.low >>> 0, message.sentAt.high >>> 0).toNumber() : message.sentAt;
|
||||
if (message.countdownNanos != null && message.hasOwnProperty("countdownNanos"))
|
||||
if (typeof message.countdownNanos === "number")
|
||||
object.countdownNanos = options.longs === String ? String(message.countdownNanos) : message.countdownNanos;
|
||||
|
Reference in New Issue
Block a user