Merge branch 'dev_basemynes' of http://git.axibug.com/sin365/AxibugEmuOnline into dev_basemynes

This commit is contained in:
ALIENJACK\alien 2024-07-05 11:25:16 +08:00
commit e8152500fd
2 changed files with 78 additions and 14 deletions

View File

@ -3,6 +3,7 @@ using AxibugEmuOnline.Client.Common;
using AxibugEmuOnline.Client.Network;
using AxibugProtobuf;
using Google.Protobuf;
using MyNes.Core;
using System.IO;
using System.IO.Compression;
using System.Linq;
@ -11,15 +12,20 @@ namespace AxibugEmuOnline.Client.Manager
{
public class AppNetGame
{
int CurrRoomID;
int[] _palette;
public int[] _renderbuffer { private set; get; }
public AppNetGame()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdScreen, OnScreen);
_palette = NTSCPaletteGenerator.GeneratePalette();
}
Protobuf_Screnn_Frame _Protobuf_Screnn_Frame = new Protobuf_Screnn_Frame();
public void SendScreen(byte[] ScreenData)
public void SendScreen(byte[] RenderBuffer)
{
byte[] comData = CompressByteArray(ScreenData);
byte[] comData = CompressByteArray(RenderBuffer);
_Protobuf_Screnn_Frame.FrameID = 0;
_Protobuf_Screnn_Frame.RawBitmap = ByteString.CopyFrom(comData);
AppAxibugEmuOnline.networkHelper.SendToServer((int)CommandID.CmdScreen, ProtoBufHelper.Serizlize(_Protobuf_Screnn_Frame));
@ -28,14 +34,14 @@ namespace AxibugEmuOnline.Client.Manager
public void OnScreen(byte[] reqData)
{
Protobuf_Screnn_Frame msg = ProtoBufHelper.DeSerizlize<Protobuf_Screnn_Frame>(reqData);
//lock (RawBitmap)
//{
// byte[] data = DecompressByteArray(msg.RawBitmap.ToArray());
// for (int i = 0; i < data.Length; i++)
// {
// RawBitmap[i] = _palette[data[i]];
// }
//}
lock (_renderbuffer)
{
byte[] data = DecompressByteArray(msg.RawBitmap.ToArray());
for (int i = 0; i < data.Length; i++)
{
_renderbuffer[i] = _palette[data[i]];
}
}
}
public static byte[] CompressByteArray(byte[] bytesToCompress)

View File

@ -8,9 +8,21 @@ enum CommandID
CMD_LOGIN = 2001; // | Protobuf_Login | Protobuf_Login_RESP
CMD_CHATMSG = 4001; //广 | Protobuf_ChatMsg | Protobuf_ChatMsg_RESP
CMD_CHATMSG = 4001; //广 | Protobuf_ChatMsg | Protobuf_ChatMsg_RESP
CMD_Screen = 5001; // | 广 Protobuf_Screnn_Frame
//
CMD_Room_List = 5001; // | Protobuf_Room_List | Protobuf_Room_List_RESP
CMD_Room_List_Update = 5002; // Protobuf_Room_Update_RESP
CMD_Room_Create = 5003; // Protobuf_Room_Create
CMD_Room_Leave = 5004; // Protobuf_Room_Leave
CMD_Room_Join = 5005; // Protobuf_Room_Join
//
CMD_Screen = 6001; // | 广 Protobuf_Screnn_Frame
}
enum ErrorCode
@ -33,6 +45,22 @@ enum DeviceType
PSV = 4;
}
enum RoomPlayerState
{
None = 0;//
OnlyP1 = 1; //P1
OnlyP2 = 2; //P2
BothOnline = 3; //
}
enum RoomGameState
{
None = 0;//
InGame = 1;//
Pause = 2;//
}
enum LoginResultStatus
{
LoginResultStatus_BaseDefault = 0;//使
@ -74,8 +102,38 @@ message Protobuf_Login_RESP
int64 UID = 5;
}
message Protobuf_Room_List
{
}
message Protobuf_Room_List_RESP
{
repeated Protobuf_Room_MiniInfo RoomMiniInfoList = 1;//
}
message Protobuf_Room_MiniInfo
{
int32 RoomID = 1;//ID
int32 GameID = 2;//ID
RoomPlayerState PlayerState = 3;//
RoomGameState GameState = 4;//
int32 ObsUserCount = 5;//
int64 Player1_UID = 6;//1 UID
string Player1_NickName = 7;//1
int64 Player2_UID = 8;//2 UID
string Player2_NickName = 9;//2
}
message Protobuf_Room_Update_RESP
{
Protobuf_Room_MiniInfo RoomMiniInfo = 1;//
}
message Protobuf_Screnn_Frame
{
int32 FrameID = 1;//
bytes RawBitmap = 2;//
int32 RoomID = 1;//ID
int32 FrameID = 2;//
bytes RawBitmap = 3;//
}