2 Commits

Author SHA1 Message Date
qornwh1
b4ad85e452 fix : 닉네임 hashkey로 임시 대체 2026-03-06 17:11:44 +09:00
qornwh1
d36de75534 feat : 채널 접속시 내 정보도 전달 2026-03-06 16:10:35 +09:00

View File

@@ -72,6 +72,7 @@ public class GameServer : ServerBase
{
HashKey = hashKey,
PlayerId = (int)(hashKey & 0x7FFFFFFF),
Nickname = (hashKey & 0x7FFFFFFF).ToString()
};
cm.AddUser(1, hashKey, newPlayer, peer);
@@ -265,6 +266,34 @@ public class GameServer : ServerBase
}
}
// 채널 입장 시 패킷 전송
// - 자신 유저에게 : 내 정보 (LOAD_GAME)
private void SendLoadGame(NetPeer peer, long hashKey)
{
ChannelManager cm = ChannelManager.Instance;
int channelId = cm.HasUser(hashKey);
Player? player = channelId >= 0 ? cm.GetChannel(channelId).GetPlayer(hashKey) : null;
if (player == null)
{
Log.Warning("[GameServer] LOAD_GAME 플레이어 없음 HashKey={Key}", hashKey);
byte[] denied = PacketSerializer.Serialize<LoadGamePacket>((ushort)PacketCode.LOAD_GAME, new LoadGamePacket { IsAccepted = false });
SendTo(peer, denied);
return;
}
LoadGamePacket packet = new LoadGamePacket
{
IsAccepted = true,
Player = ToPlayerInfo(player),
MaplId = channelId,
};
byte[] data = PacketSerializer.Serialize<LoadGamePacket>((ushort)PacketCode.LOAD_GAME, packet);
SendTo(peer, data);
Log.Debug("[GameServer] LOAD_GAME HashKey={Key} PlayerId={PlayerId} ChannelId={ChannelId}", hashKey, player.PlayerId, channelId);
}
// ============================================================
// 채널 브로드캐스트 헬퍼
// ============================================================
@@ -331,6 +360,7 @@ public class GameServer : ServerBase
{
HashKey = hashKey,
PlayerId = (int)(hashKey & 0x7FFFFFFF),
Nickname = (hashKey & 0x7FFFFFFF).ToString()
};
cm.AddUser(packet.ChannelId, hashKey, newPlayer, peer);
@@ -338,6 +368,9 @@ public class GameServer : ServerBase
// 접속된 모든 유저 정보 전달
SendIntoChannelPacket(peer, hashKey);
// 내 정보 전달
SendLoadGame(peer, hashKey);
}
private void OnExitChannel(NetPeer peer, long hashKey, byte[] payload)