mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 03:39:00 +00:00
Updated logs in frontend.
This commit is contained in:
parent
c69aa25353
commit
fe826b393b
@ -1159,11 +1159,11 @@ func (pR *Room) applyInputFrameDownsyncDynamics(fromRenderFrameId int32, toRende
|
||||
playerShape := playerCollider.Shape.(*resolv.ConvexPolygon)
|
||||
barrierShape := collision.Objects[0].Shape.(*resolv.ConvexPolygon)
|
||||
if overlapped, pushbackX, pushbackY := CalcPushbacks(oldDx, oldDy, playerShape, barrierShape); overlapped {
|
||||
Logger.Info(fmt.Sprintf("Collided & overlapped: player.X=%v, player.Y=%v, oldDx=%v, oldDy=%v, playerShape=%v, toCheckBarrier=%v, pushbackX=%v, pushbackY=%v", playerCollider.X, playerCollider.Y, oldDx, oldDy, ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape), pushbackX, pushbackY))
|
||||
Logger.Debug(fmt.Sprintf("Collided & overlapped: player.X=%v, player.Y=%v, oldDx=%v, oldDy=%v, playerShape=%v, toCheckBarrier=%v, pushbackX=%v, pushbackY=%v", playerCollider.X, playerCollider.Y, oldDx, oldDy, ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape), pushbackX, pushbackY))
|
||||
dx -= pushbackX
|
||||
dy -= pushbackY
|
||||
} else {
|
||||
Logger.Info(fmt.Sprintf("Collider BUT not overlapped: player.X=%v, player.Y=%v, oldDx=%v, oldDy=%v, playerShape=%v, toCheckBarrier=%v", playerCollider.X, playerCollider.Y, oldDx, oldDy, ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape)))
|
||||
Logger.Debug(fmt.Sprintf("Collider BUT not overlapped: player.X=%v, player.Y=%v, oldDx=%v, oldDy=%v, playerShape=%v, toCheckBarrier=%v", playerCollider.X, playerCollider.Y, oldDx, oldDy, ConvexPolygonStr(playerShape), ConvexPolygonStr(barrierShape)))
|
||||
}
|
||||
}
|
||||
playerCollider.X += dx
|
||||
|
@ -440,7 +440,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
344.6781107062066,
|
||||
344.75930058781137,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -67,19 +67,6 @@ cc.Class({
|
||||
|
||||
onLoad() {
|
||||
|
||||
//kobako: 腾讯统计代码
|
||||
//WARN: 打包到微信小游戏的时候会导致出错
|
||||
/*
|
||||
(function() {
|
||||
var mta = document.createElement("script");
|
||||
mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
|
||||
mta.setAttribute("name", "MTAH5");
|
||||
mta.setAttribute("sid", "500674632");
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(mta, s);
|
||||
})();
|
||||
*/
|
||||
|
||||
window.atFirstLocationHref = window.location.href.split('#')[0];
|
||||
const self = this;
|
||||
self.getRetCodeList();
|
||||
@ -97,10 +84,8 @@ cc.Class({
|
||||
self.smsLoginCaptchaLabel.active = true;
|
||||
|
||||
self.loginButton.active = true;
|
||||
self.checkPhoneNumber = self.checkPhoneNumber.bind(self);
|
||||
self.checkIntAuthTokenExpire = self.checkIntAuthTokenExpire.bind(self);
|
||||
self.checkCaptcha = self.checkCaptcha.bind(self);
|
||||
self.onSMSCaptchaGetButtonClicked = self.onSMSCaptchaGetButtonClicked.bind(self);
|
||||
self.onLoginButtonClicked = self.onLoginButtonClicked.bind(self);
|
||||
self.onSMSCaptchaGetButtonClicked = self.onSMSCaptchaGetButtonClicked.bind(self);
|
||||
self.smsLoginCaptchaButton.on('click', self.onSMSCaptchaGetButtonClicked);
|
||||
|
||||
self.loadingNode = cc.instantiate(this.loadingPrefab);
|
||||
@ -125,11 +110,12 @@ cc.Class({
|
||||
window.WsReq = protoRoot.lookupType("treasurehunterx.WsReq");
|
||||
window.WsResp = protoRoot.lookupType("treasurehunterx.WsResp");
|
||||
self.checkIntAuthTokenExpire().then(
|
||||
() => {
|
||||
const intAuthToken = JSON.parse(cc.sys.localStorage.getItem('selfPlayer')).intAuthToken;
|
||||
(intAuthToken) => {
|
||||
console.log("Successfully found `intAuthToken` in local cache");
|
||||
self.useTokenLogin(intAuthToken);
|
||||
},
|
||||
() => {
|
||||
console.warn("Failed to find `intAuthToken` in local cache");
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
}
|
||||
);
|
||||
@ -221,11 +207,28 @@ cc.Class({
|
||||
checkIntAuthTokenExpire() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!cc.sys.localStorage.getItem('selfPlayer')) {
|
||||
console.warn("Couldn't find selfPlayer key in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
const selfPlayer = JSON.parse(cc.sys.localStorage.getItem('selfPlayer'));
|
||||
(selfPlayer.intAuthToken && new Date().getTime() < selfPlayer.expiresAt) ? resolve() : reject();
|
||||
if (null == selfPlayer) {
|
||||
console.warn("Couldn't find selfPlayer object in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
if (null == selfPlayer.intAuthToken) {
|
||||
console.warn("Couldn't find selfPlayer object with key `intAuthToken` in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
if (new Date().getTime() > selfPlayer.expiresAt) {
|
||||
console.warn("Couldn't find unexpired selfPlayer `intAuthToken` in local cache");
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
resolve(selfPlayer.intAuthToken);
|
||||
})
|
||||
},
|
||||
|
||||
@ -278,13 +281,15 @@ cc.Class({
|
||||
intAuthToken: _intAuthToken
|
||||
},
|
||||
success: function(resp) {
|
||||
console.log("Login attempt `useTokenLogin` succeeded.");
|
||||
self.onLoggedIn(resp);
|
||||
},
|
||||
error: function(xhr, status, errMsg) {
|
||||
console.log("Login attempt `useTokenLogin` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`.");
|
||||
console.warn("Login attempt `useTokenLogin` failed, about to execute `clearBoundRoomIdInBothVolatileAndPersistentStorage`.");
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage()
|
||||
},
|
||||
timeout: function() {
|
||||
console.warn("Login attempt `useTokenLogin` timed out, about to enable interactive controls.");
|
||||
self.enableInteractiveControls(true);
|
||||
},
|
||||
});
|
||||
@ -335,7 +340,7 @@ cc.Class({
|
||||
|
||||
onLoggedIn(res) {
|
||||
const self = this;
|
||||
cc.log(`OnLoggedIn ${JSON.stringify(res)}.`)
|
||||
console.log("OnLoggedIn ", JSON.stringify(res))
|
||||
if (res.ret === self.retCodeDict.OK) {
|
||||
self.enableInteractiveControls(false);
|
||||
const date = Number(res.expiresAt);
|
||||
@ -360,6 +365,7 @@ cc.Class({
|
||||
);
|
||||
cc.director.loadScene('default_map');
|
||||
} else {
|
||||
console.log("OnLoggedIn failed, about to remove `selfPlayer` in local cache.")
|
||||
cc.sys.localStorage.removeItem("selfPlayer");
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
self.enableInteractiveControls(true);
|
||||
|
@ -104,18 +104,6 @@ window.getExpectedRoomIdSync = function() {
|
||||
return null;
|
||||
};
|
||||
|
||||
window.unsetClientSessionCloseOrErrorFlag = function() {
|
||||
cc.sys.localStorage.removeItem("ClientSessionCloseOrErrorFlag");
|
||||
return;
|
||||
}
|
||||
|
||||
window.setClientSessionCloseOrErrorFlag = function() {
|
||||
const oldVal = cc.sys.localStorage.getItem("ClientSessionCloseOrErrorFlag");
|
||||
if (true == oldVal) return false;
|
||||
cc.sys.localStorage.setItem("ClientSessionCloseOrErrorFlag", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
if (window.clientSession && window.clientSession.readyState == WebSocket.OPEN) {
|
||||
if (null != onopenCb) {
|
||||
@ -123,8 +111,10 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const intAuthToken = cc.sys.localStorage.getItem("selfPlayer") ? JSON.parse(cc.sys.localStorage.getItem('selfPlayer')).intAuthToken : "";
|
||||
|
||||
const selfPlayerStr = cc.sys.localStorage.getItem("selfPlayer");
|
||||
const selfPlayer = null == selfPlayerStr ? null : JSON.parse(selfPlayerStr);
|
||||
const intAuthToken = null == selfPlayer ? "" : selfPlayer.intAuthToken;
|
||||
|
||||
let urlToConnect = backendAddress.PROTOCOL.replace('http', 'ws') + '://' + backendAddress.HOST + ":" + backendAddress.PORT + backendAddress.WS_PATH_PREFIX + "?intAuthToken=" + intAuthToken;
|
||||
|
||||
@ -141,11 +131,12 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
|
||||
const currentHistoryState = window.history && window.history.state ? window.history.state : {};
|
||||
|
||||
window.clientSession = null; // Important for checking whether the "onclose" event is still relevant!
|
||||
const clientSession = new WebSocket(urlToConnect);
|
||||
clientSession.binaryType = 'arraybuffer'; // Make 'event.data' of 'onmessage' an "ArrayBuffer" instead of a "Blob"
|
||||
|
||||
clientSession.onopen = function(event) {
|
||||
console.log("The WS clientSession is opened.");
|
||||
console.log("The WS clientSession is opened. clientSession.id=", clientSession.id);
|
||||
window.clientSession = clientSession;
|
||||
if (null == onopenCb) return;
|
||||
onopenCb();
|
||||
@ -208,9 +199,6 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
};
|
||||
|
||||
clientSession.onerror = function(event) {
|
||||
if (!window.setClientSessionCloseOrErrorFlag()) {
|
||||
return;
|
||||
}
|
||||
console.error("Error caught on the WS clientSession: ", event);
|
||||
if (window.clientSessionPingInterval) {
|
||||
clearInterval(window.clientSessionPingInterval);
|
||||
@ -218,14 +206,14 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
if (window.handleClientSessionCloseOrError) {
|
||||
window.handleClientSessionCloseOrError();
|
||||
}
|
||||
window.unsetClientSessionCloseOrErrorFlag();
|
||||
};
|
||||
|
||||
clientSession.onclose = function(event) {
|
||||
if (!window.setClientSessionCloseOrErrorFlag()) {
|
||||
return;
|
||||
}
|
||||
console.warn("The WS clientSession is closed: ", event);
|
||||
if (null == window.clientSession) {
|
||||
console.log("Received an outdated WS clientSession onclose event: ", event, clientSession);
|
||||
return;
|
||||
}
|
||||
console.warn("The WS clientSession is closed: ", event, clientSession);
|
||||
if (window.clientSessionPingInterval) {
|
||||
clearInterval(window.clientSessionPingInterval);
|
||||
}
|
||||
@ -248,7 +236,6 @@ window.initPersistentSessionClient = function(onopenCb, expectedRoomId) {
|
||||
window.handleClientSessionCloseOrError();
|
||||
}
|
||||
}
|
||||
window.unsetClientSessionCloseOrErrorFlag();
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user