optimize flow

This commit is contained in:
2026-05-26 08:33:40 +00:00
parent 4f21d296ba
commit 39395e173e
10 changed files with 18734 additions and 5 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-1
View File
@@ -171,7 +171,6 @@
name: name,
isPrivate: isPrivate,
maxPlayers: maxPlayersForSlot(selectedSlot),
botSlotCount: botCountForSlot(selectedSlot),
};
fetch(SERVER + '/api/spaces', {
method: 'POST',
+26
View File
@@ -1760,6 +1760,27 @@
return img;
}
/** อุ่น cache เลเยอร์สีของตัวละคร (ทุกทิศ + เดิน 0-3 + idle) ก่อนเข้าเกม กันกระตุกตอนโหลดสีกลางเกม */
const _playPreloadedChars = new Set();
function preloadPlayCharacterLayers(charId) {
if (!charId || _playPreloadedChars.has(charId)) return;
_playPreloadedChars.add(charId);
try { ensurePlayCharLayerListFetch(); } catch (e) { /* ignore */ }
try { ensurePlayLayerProbesAllDirections(charId); } catch (e) { /* ignore */ }
const dirs = ['down', 'up', 'left', 'right'];
const warm = function (urls) { if (urls && urls.length) ensurePlayLayerImage(urls[0]); };
dirs.forEach(function (dir) {
for (let fi = 0; fi < CHARACTER_ANIM_FRAMES; fi++) {
PLAY_LAYER_ORDER.forEach(function (ln) {
warm(ln === 'shadow' ? shadowUrlCandidates(charId, dir, fi) : layerUrlCandidates(charId, dir, ln, fi));
});
}
PLAY_LAYER_ORDER.forEach(function (ln) {
warm(ln === 'shadow' ? shadowUrlCandidatesIdle(charId, dir, 0) : layerUrlCandidatesIdle(charId, dir, ln, 0));
});
});
}
/** ลำดับลอง URL: เฟรมปัจจุบันแบบ multi → เฟรม 0 → แบบ single (ไม่มี _0_) เพื่อกันชื่อไฟล์ไม่ตรงกับที่เซิร์ฟเวอร์เขียน */
function layerUrlCandidates(id, dir, layerName, frameIndex) {
const enc = encodeURIComponent(id);
@@ -14169,6 +14190,11 @@
gauntletObsRenderNext = [];
gauntletObsBlendT0 = 0;
me.playTint = playTintFromPeerId(String((myId != null && myId !== '') ? myId : (nick || 'local')));
// อุ่น cache เลเยอร์สีตัวละครก่อนเข้าเกม (ตัวเรา + เพื่อนร่วมห้อง) กันกระตุกตอนโหลดสีกลางเกม
try {
preloadPlayCharacterLayers(me.characterId || getPlayCharacterId());
(Array.isArray(plist) ? plist : []).forEach(function (p) { if (p && p.characterId) preloadPlayCharacterLayers(p.characterId); });
} catch (e) { /* ignore */ }
{
const jo = Number(myPeer && myPeer.spawnJoinOrder);
me.spawnJoinOrder = Number.isFinite(jo) ? Math.max(0, Math.floor(jo)) : Math.max(0, plist.findIndex((q) => q && q.id === myId));
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -5,7 +5,7 @@
var linkPrivacy = document.getElementById('link-privacy');
function loadOauthPublic() {
return fetch('/Admin/api/oauth-public.php', { credentials: 'omit' })
return fetch((typeof appPath === 'function' ? appPath('/Admin/api/oauth-public.php') : '/Admin/api/oauth-public.php'), { credentials: 'omit' })
.then(function (r) { return r.json(); })
.then(function (j) {
if (!j || !j.ok) return null;
@@ -18,7 +18,7 @@
// ไปหน้า Main Lobby แบบ Guest
localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('loginType', 'guest');
window.location.href = '/Main-Lobby/';
window.location.href = typeof appPath === 'function' ? appPath('/Main-Lobby/') : '/Main-Lobby/';
}
if (btnFacebook) {
@@ -28,7 +28,7 @@
alert('ยังไม่ได้ตั้งค่า Facebook App ในหน้า /Admin/');
return;
}
var ru = cfg.facebookRedirectUri || (location.origin + '/Login/facebook-callback.html');
var ru = cfg.facebookRedirectUri || (location.origin + (typeof appPath === 'function' ? appPath('/Login/facebook-callback.html') : '/Login/facebook-callback.html'));
var state = encodeURIComponent('fb-' + Date.now());
var url = 'https://www.facebook.com/v18.0/dialog/oauth?client_id=' + encodeURIComponent(cfg.facebookAppId) +
'&redirect_uri=' + encodeURIComponent(ru) + '&state=' + state + '&scope=email,public_profile';
@@ -44,7 +44,7 @@
alert('ยังไม่ได้ตั้งค่า Google Client ในหน้า /Admin/');
return;
}
var ru = cfg.googleRedirectUri || (location.origin + '/Login/google-callback.html');
var ru = cfg.googleRedirectUri || (location.origin + (typeof appPath === 'function' ? appPath('/Login/google-callback.html') : '/Login/google-callback.html'));
var state = encodeURIComponent('go-' + Date.now());
var url = 'https://accounts.google.com/o/oauth2/v2/auth?client_id=' + encodeURIComponent(cfg.googleClientId) +
'&redirect_uri=' + encodeURIComponent(ru) + '&response_type=code&scope=' +