@@ -74,15 +74,6 @@ export class GameClient {
7474
7575 await this.ws.connect();
7676 this.isRunning = true;
77-
78- const activeUsername = this.db.getActiveUsername();
79- if (activeUsername) {
80- console.log(`[${this.config.instanceId}] Auto-login as ${activeUsername.username}`);
81- this.ws.send({
82- type: "login",
83- payload: { username: activeUsername.username, token: activeUsername.token },
84- });
85- }
8677 }
8778
8879 stop(): void {
@@ -160,13 +151,22 @@ export class GameClient {
160151 this.startWatchdog();
161152
162153 if (this.isRunning) {
163- await this.processTick().catch((error) => {
164- console.error(`[${this.config.instanceId}] Initial tick processing error:`, error);
165- this.db.saveMessage(this.currentTick, "client", {
166- error: "Initial tick processing failed",
167- code: "TICK_PROCESSING_ERROR",
154+ const activeUsername = this.db.getActiveUsername();
155+ if (activeUsername) {
156+ console.log(`[${this.config.instanceId}] Auto-login as ${activeUsername.username}`);
157+ this.ws.send({
158+ type: "login",
159+ payload: { username: activeUsername.username, token: activeUsername.token },
168160 });
169- });
161+ } else {
162+ await this.processTick().catch((error) => {
163+ console.error(`[${this.config.instanceId}] Initial tick processing error:`, error);
164+ this.db.saveMessage(this.currentTick, "client", {
165+ error: "Initial tick processing failed",
166+ code: "TICK_PROCESSING_ERROR",
167+ });
168+ });
169+ }
170170 }
171171 }