From 4a97e694099e7ab586a2dc57804ac37b6ed74b94 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 28 Nov 2024 17:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AxibugEmuOnline.Server/Manager/RoomManager.cs | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/AxibugEmuOnline.Server/Manager/RoomManager.cs b/AxibugEmuOnline.Server/Manager/RoomManager.cs index c63e7e1..d49fb49 100644 --- a/AxibugEmuOnline.Server/Manager/RoomManager.cs +++ b/AxibugEmuOnline.Server/Manager/RoomManager.cs @@ -2,8 +2,10 @@ using AxibugEmuOnline.Server.Manager; using AxibugEmuOnline.Server.NetWork; using AxibugProtobuf; +using MySql.Data.MySqlClient; using System.Net.Sockets; using System.Runtime.InteropServices; +using System.Security.Policy; namespace AxibugEmuOnline.Server { @@ -93,6 +95,48 @@ namespace AxibugEmuOnline.Server #endregion + #region + + public enum RoomLogType + { + Create = 0, + Join = 1, + Leave = 2 + } + public void RoomLog(long uid, int platform, int RoomID, int RomID, RoomLogType state) + { + MySqlConnection conn = Haoyue_SQLPoolManager.DequeueSQLConn("ModifyNikeName"); + try + { + string query = "INSERT INTO `haoyue_emu`.`room_log` (`uid`, `platform`, `romid`,`roomid`, `state`) VALUES ( ?uid, ?platform, ?romid, ?roomid, ?state);"; + using (var command = new MySqlCommand(query, conn)) + { + // 设置参数值 + command.Parameters.AddWithValue("?uid", uid); + command.Parameters.AddWithValue("?platform", platform); + command.Parameters.AddWithValue("?romid", RomID); + command.Parameters.AddWithValue("?roomid", RoomID); + command.Parameters.AddWithValue("?state", state); + command.ExecuteNonQuery(); + } + + if (state == RoomLogType.Join) + { + query = "update romlist_nes set playcount = playcount + 1 where id = ?romid"; + using (var command = new MySqlCommand(query, conn)) + { + command.Parameters.AddWithValue("?romid", RomID); + command.ExecuteNonQuery(); + } + } + } + catch (Exception e) + { + } + Haoyue_SQLPoolManager.EnqueueSQLConn(conn); + } + #endregion + private Protobuf_Room_MiniInfo GetProtoDataRoom(Data_RoomData room) { Protobuf_Room_MiniInfo result = new Protobuf_Room_MiniInfo() @@ -202,6 +246,8 @@ namespace AxibugEmuOnline.Server SendRoomStepChange(newRoom); SendRoomUpdateToAll(newRoom.RoomID, 0); + + RoomLog(_c.UID, 1, newRoom.RoomID, newRoom.GameRomID, RoomLogType.Create); } public void OnCmdRoomJoin(Socket sk, byte[] reqData) @@ -240,6 +286,7 @@ namespace AxibugEmuOnline.Server SendRoomUpdateToAll(room.RoomID, 0); } } + RoomLog(_c.UID, 1, room.RoomID, room.GameRomID, RoomLogType.Join); } public void OnCmdRoomLeave(Socket sk, byte[] reqData) { @@ -304,6 +351,8 @@ namespace AxibugEmuOnline.Server } else SendRoomUpdateToAll(room.RoomID, 0); + + RoomLog(_c.UID,1,room.RoomID,room.GameRomID,RoomLogType.Leave); } public void OnHostPlayerUpdateStateRaw(Socket sk, byte[] reqData) @@ -910,7 +959,7 @@ namespace AxibugEmuOnline.Server this.ScreenRaw = NextStateRaw; } - public bool GetNeedForwardTick(uint clientFrame,out long forwaFrame) + public bool GetNeedForwardTick(uint clientFrame, out long forwaFrame) { forwaFrame = 0; //目标帧,客户端+服务器提前量