Skip to content

Commit

Permalink
cleanup (safe)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove committed Nov 13, 2023
1 parent f03368f commit 7cafaeb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 61 deletions.
49 changes: 4 additions & 45 deletions skymp5-client/src/features/authSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ export const addAuthListener = (callback: AuthCallback): void => {
authListeners.push(callback);
}

export const main = (lobbyLocation: Transform): void => {
export const main = (): void => {
const settingsGameData = sp.settings["skymp5-client"]["gameData"] as any;
const isOfflineMode = Number.isInteger(settingsGameData?.profileId);
if (isOfflineMode) {
onAuthListeners({ local: { profileId: settingsGameData.profileId } });
} else {
startListenBrowserMessage();
browser.addOnWindowLoadListener(() => {
if (isListenBrowserMessage) loadLobby(lobbyLocation);
if (isListenBrowserMessage) loadLobby();
});
}
}
Expand Down Expand Up @@ -197,58 +197,17 @@ const checkLoginState = () => {
browserState.comment = `Server returned ${response.status.toString() || "???"} "${response.body || response.error}"`;
setTimeout(() => checkLoginState(), 1.5 + Math.random() * 2);
}
})
// .catch(reason => {
// ++browserState.failCount;
// if (typeof reason === "string") {
// browserState.comment = (`Skyrim platform error (http): ${reason}`)
// } else {
// browserState.comment = (`Skyrim platform error (http): request rejected`);
// }
// })
// .finally(() => {
// refreshWidgets();
// });
});
};

const loadLobby = (location: Transform): void => {
// sp.once("tick", () => {
// defaultAutoVanityModeDelay = sp.Utility.getINIFloat("fAutoVanityModeDelay:Camera");
// // setPlayerAuthMode(true);
// authData = browser.getAuthData();
// refreshWidgets();
// sp.browser.setVisible(true);
// });

// sp.once("tick", () => {
// sp.browser.setFocused(true);
// // browser.keepCursorMenuOpenedWhenBrowserFocused();
// checkLoginState();
// });

// const loadGameService = SpApiInteractor.makeController().lookupListener(LoadGameService);
// loadGameService.loadGame(
// location.pos,
// location.rot,
// location.worldOrCell
// );

const loadLobby = (): void => {
authData = browser.getAuthData();
refreshWidgets();
sp.browser.setVisible(true);
sp.browser.setFocused(true);

// Launch checkLoginState loop
checkLoginState();

// sp.printConsole("TEST1")
// new sp.HttpClient(authUrl).post("/", {body: "", contentType: ""}, (result) => {
// sp.printConsole("TEST", result)
// });
// sp.printConsole("TEST1")
// setTimeout(() => {
// sp.printConsole("TEST")
// }, 1);
}

declare const window: any;
Expand Down
22 changes: 6 additions & 16 deletions skymp5-client/src/services/services/skympClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as sp from 'skyrimPlatform';
import {
on,
once,
Expand All @@ -9,7 +8,6 @@ import {
import * as netInfo from '../../debug/netInfoSystem';
import * as updateOwner from '../../gamemodeApi/updateOwner';
import * as networking from './networkingService';
import { ModelSource } from '../../modelSource/modelSource';
import { RemoteServer } from './remoteServer';
import { setupHooks } from '../../sync/animation';
import * as animDebugSystem from '../../debug/animDebugSystem';
Expand All @@ -18,20 +16,11 @@ import { SinglePlayerService } from './singlePlayerService';
import * as authSystem from "../../features/authSystem";
import * as playerCombatSystem from "../../sweetpie/playerCombatSystem";
import { AuthGameData } from '../../features/authModel';
import { Transform } from '../../sync/movement';
import * as browser from "../../features/browser";
import { ClientListener, CombinedController, Sp } from './clientListener';
import { SpApiInteractor } from '../spApiInteractor';
import { ConnectionFailed } from '../events/connectionFailed';
import { ConnectionDenied } from '../events/connectionDenied';
import { ConnectionAccepted } from '../events/connectionAccepted';
import { ConnectionDisconnect } from '../events/connectionDisconnect';
import { ConnectionMessage } from '../events/connectionMessage';

interface AnyMessage {
type?: string;
t?: number;
}

printConsole('Hello Multiplayer!');
printConsole('settings:', settings['skymp5-client']);
Expand Down Expand Up @@ -65,7 +54,7 @@ export class SkympClient extends ClientListener {
this.startClient();
});

authSystem.main(settings["skymp5-client"]["lobbyLocation"] as Transform);
authSystem.main();
} else {
this.startClient();
}
Expand All @@ -80,19 +69,20 @@ export class SkympClient extends ClientListener {
}

private startClient() {
// TODO: subscribe to events in constructor, not here
// TODO: refactor netInfo into service
netInfo.start();

// TODO: refactor animDebugSystem into service
animDebugSystem.init(settings["skymp5-client"]["animDebug"] as animDebugSystem.AnimDebugSettings);

// TODO: refactor playerCombatSystem into service
playerCombatSystem.start();
// once("update", () => authSystem.setPlayerAuthMode(false));

this.establishConnectionConditional();
this.ctor();
}

private ctor() {
printConsole("CTOR")

// TODO: subscribe to events in constructor, not here
this.resetView();
setupHooks();
Expand Down

0 comments on commit 7cafaeb

Please sign in to comment.