Add platform string for game session

This commit is contained in:
Melledy
2025-12-13 00:14:07 -08:00
parent 968880c320
commit 1aa2129bba
3 changed files with 17 additions and 2 deletions

View File

@@ -2,13 +2,11 @@ package emu.nebula.game.ban;
import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import emu.nebula.Nebula;
import emu.nebula.database.GameDatabaseObject;
import emu.nebula.game.player.PlayerErrorCode;
import emu.nebula.proto.Public.Error;
import emu.nebula.util.Utils;
import lombok.Getter;
import java.util.Date;
@Getter
@Entity(value = "bans", useDiscriminator = false)

View File

@@ -10,6 +10,7 @@ import emu.nebula.Nebula;
import emu.nebula.game.account.Account;
import emu.nebula.game.account.AccountHelper;
import emu.nebula.game.player.Player;
import emu.nebula.proto.Pb.Platform;
import emu.nebula.proto.Public.MailState;
import emu.nebula.proto.Public.Nil;
import emu.nebula.util.AeadHelper;
@@ -24,7 +25,10 @@ public class GameSession {
private String token;
private Account account;
private Player player;
// Details
private String ipAddress;
private int platform;
// Crypto
private int encryptMethod; // 0 = gcm, 1 = chacha20
@@ -38,6 +42,7 @@ public class GameSession {
private long lastActiveTime;
public GameSession() {
this.platform = -1;
this.updateLastActiveTime();
}
@@ -74,6 +79,15 @@ public class GameSession {
return this.player != null;
}
public void setPlatform(int platform) {
this.platform = platform;
}
public String getPlatformName() {
var platform = Platform.forNumber(this.getPlatform());
return platform != null ? platform.getName() : "Unknown";
}
// Encryption
public void setClientKey(RepeatedByte key) {

View File

@@ -50,6 +50,9 @@ public class HandlerPlayerLoginReq extends NetHandler {
var banInfo = banModule.getPlayerBanInfo(session.getPlayer().getUid());
return session.encodeMsg(NetMsgId.player_login_failed_ack, banInfo.toProto());
}
// Set platform
session.setPlatform(req.getPlatformValue());
// Regenerate session token because we are switching encrpytion method
Nebula.getGameContext().generateSessionToken(session);