Skip to content

Commit

Permalink
合并dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mirbeta committed Feb 14, 2024
2 parents da0f667 + 47c6032 commit 0e7bde7
Show file tree
Hide file tree
Showing 1,418 changed files with 101,530 additions and 109,085 deletions.
Binary file modified .DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,49 @@ jobs:
- name: Publish & DBSvr
run: |
cd src/DBSvr/
dotnet build --configuration Release
dotnet build --configuration Release /p:Mode=Publish
dotnet publish -c Release -o ../Build/DBSvr
zip -qq -r ../Build/DBSvr.zip ../Build/DBSvr
- name: Publish & LoginSvr
run: |
cd src/LoginSvr/
dotnet build --configuration Release
dotnet build --configuration Release /p:Mode=Publish
dotnet publish -c Release -o ../Build/LoginSvr
zip -qq -r ../Build/LoginSvr.zip ../Build/LoginSvr
- name: Publish & SelGate
run: |
cd src/SelGate/
dotnet build --configuration Release
dotnet build --configuration Release /p:Mode=Publish
dotnet publish -c Release -o ../Build/SelGate
zip -qq -r ../Build/SelGate.zip ../Build/SelGate
- name: Publish & LoginGate
run: |
cd src/LoginGate/
dotnet build --configuration Release
dotnet build --configuration Release /p:Mode=Publish
dotnet publish -c Release -o ../Build/LoginGate
zip -qq -r ../Build/LoginGate.zip ../Build/LoginGate
- name: Publish & GameSvr
run: |
cd src/LoginGate/
dotnet build --configuration Release
dotnet build --configuration Release /p:Mode=Publish
dotnet publish -c Release -o ../Build/GameSvr
zip -qq -r ../Build/GameSvr.zip ../Build/GameSvr
- name: Publish & GameGate
run: |
cd src/GameGate/
dotnet build --configuration Release
dotnet build --configuration Release /p:Mode=Publish
dotnet publish -c Release -o ../Build/GameGate
zip -qq -r ../Build/GameGate.zip ../Build/GameGate
- name: Publish & MakePlayer
run: |
cd src/MakePlayer/
dotnet build --configuration Release
dotnet build --configuration Release /p:Mode=Publish
dotnet publish -c Release -o ../Build/MakePlayer
zip -qq -r ../Build/MakePlayer.zip ../Build/MakePlayer
Expand Down
4 changes: 1 addition & 3 deletions .idea/.idea.OpenMir2/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 92 additions & 43 deletions OpenMir2.sln

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions TestProject1/GameSrvTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0-preview-24080-01" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\OpenMir2\OpenMir2.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions TestProject1/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using NUnit.Framework;
56 changes: 56 additions & 0 deletions TestProject1/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using OpenMir2;
using OpenMir2.Packets.ClientPackets;
using System.Text;

namespace GameSrvTest
{
public class Tests
{
[SetUp]
public void Setup()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
//MemoryPackFormatterProvider.Register<Ability>(new AbilityFormatter());
}

[Test]
public void Test1()
{
Assert.Pass();
}

[Test]
public void EncodeAbility()
{
byte[] s = new byte[2] { 154, 1 };
BitConverter.ToUInt16(s);

Ability ability = new Ability();
ability.Level = 38;
ability.DC = 4167;
ability.SC = 6411;
ability.MC = 0;
ability.AC = 0;
ability.Exp = 16230;
ability.MaxExp = 2000000;
ability.ExpCount = 0;
ability.ExpMaxCount = 0;
ability.HP = 78;
ability.MP = 128;
ability.MaxHP = 350;
ability.MaxMP = 410;
ability.HandWeight = 46;
ability.MaxHandWeight = 46;
ability.MaxWearWeight = 44;
ability.MaxWeight = 411;
ability.Weight = 89;
ability.WearWeight = 7;
ability.MAC = 2051;
string strs = EDCode.EncodeMessage(ability);

//^dhgdg`kwhhgdgqivdh?dzihJehcddhknchddDdKjdqodKiig\>d^<
//^dhgdg`kwhhgdgqivdh?dzihJehcddhknchddDdKjdqodKiig\>d^<
Console.WriteLine(strs);
}
}
}
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.201",
"version": "8.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
}
Expand Down
28 changes: 15 additions & 13 deletions nlog.config
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- XSD manual extracted from package NLog.Schema: https://www.nuget.org/packages/NLog.Schema-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" throwExceptions="false" protectedLogLevel="Off" protectedLogFile="NlogRecords.log">
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" throwExceptions="false" protectedLogLevel="Off" protectedLogFile="NlogRecords.log">
<!--Nlog内部日志记录为Off关闭。除非纠错,不可以设为Trace否则速度很慢,起码Debug以上-->
<targets async="true">
<target name="fileTarget" xsi:type="File" fileName="${basedir}/log/${shortdate}.log"
<target name="fileTarget" xsi:type="File" fileName="${basedir}/log/${shortdate}.log"
layout="[${longdate}] | ${level:uppercase=false} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"
/>
<!--ColoredConsole彩色控制台 xsi:type="Console"是指定输出到普通控制台-->
<target name="consoleTarget" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="true" layout="[${time}] ${message} ${exception}" bufferSize="2048">
<highlight-row condition="level == LogLevel.Trace" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkMagenta" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="Green" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Magenta" backgroundColor="White" />
<target name="consoleTarget" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="true"
layout="[${time}] ${message} ${exception}" bufferSize="2048">
<highlight-row condition="level == LogLevel.Trace" foregroundColor="DarkGray"/>
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkMagenta"/>
<highlight-row condition="level == LogLevel.Info" foregroundColor="Green"/>
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow"/>
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red"/>
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Magenta" backgroundColor="White"/>
</target>
</targets>
<rules>
<!--跳过所有级别的Microsoft组件的日志记录-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<logger name="Microsoft.*" maxlevel="Info" final="true"/>
<!-- BlackHole without writeTo -->
<!--只通过数据库记录日志,这里的*,如果给了name名字,代码里用日志记录的时候,取logger需要把name当做参数-->
<logger name="*" minlevel="Trace" writeTo="fileTarget,consoleTarget" />
<!--<logger name="*" minlevel="Debug" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Trace" writeTo="fileTarget,consoleTarget"/>
<!--<logger name="*" minlevel="Debug" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Trace" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Warn" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Error" writeTo="fileTarget,consoleTarget" />-->
<!--记录致命错误到控制台-->
<logger name="*" minlevel="Fatal" writeTo="fileTarget,consoleTarget" />
<logger name="*" minlevel="Fatal" writeTo="fileTarget,consoleTarget"/>
</rules>
</nlog>
Binary file modified src/.DS_Store
Binary file not shown.
9 changes: 4 additions & 5 deletions src/BotSrv/AppServer.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using SystemModule.Hosts;
using System.Threading;
using System.Threading.Tasks;

namespace BotSrv
{
Expand All @@ -18,7 +17,7 @@ public AppServer()

public override void Initialize()
{

}

public void ConfigureServices(IServiceCollection services)
Expand Down
26 changes: 12 additions & 14 deletions src/BotSrv/AppService.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BotSrv.Player;
using BotSrv.Player;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using NLog;
using SystemModule;
using OpenMir2;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace BotSrv
{
public class AppService : IHostedService
{
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly RobotOptions _options;
/// <summary>
/// 登录序号
Expand All @@ -32,27 +30,27 @@ public AppService(IOptions<RobotOptions> options, ClientManager clientManager)
MShare.g_sGameIPaddr = _options.Address;
MShare.g_nGamePort = _options.Port;
runThread = new Thread(Run) { IsBackground = true };
_logger.Info("服务器名称:{0} 服务器IP:{1} 服务器端口:{2}", _options.ServerName, _options.Address, _options.Port);
_logger.Info("初始化机器人数量:{0} 登录机器人总数量:{1}", _options.ChrCount, _options.TotalChrCount);
LogService.Info("服务器名称:{0} 服务器IP:{1} 服务器端口:{2}", _options.ServerName, _options.Address, _options.Port);
LogService.Info("初始化机器人数量:{0} 登录机器人总数量:{1}", _options.ChrCount, _options.TotalChrCount);
}

public async Task StartAsync(CancellationToken stoppingToken)
{
_logger.Info("机器人服务启动...");
LogService.Info("机器人服务启动...");
runThread.Start();
await BotShare.ClientMgr.Start(stoppingToken);
}

public Task StopAsync(CancellationToken cancellationToken)
{
_logger.Info("机器人服务停止...");
LogService.Info("机器人服务停止...");
BotShare.ClientMgr.Stop(cancellationToken);
return Task.CompletedTask;
}

private void Run()
{
_logger.Debug("工作线程开始执行...");
LogService.Debug("工作线程开始执行...");
while (true)
{
if (_options.TotalChrCount > 0)
Expand All @@ -68,9 +66,9 @@ private void Run()
{
_options.TotalChrCount = 0;
}
for (var i = 0; i < _options.ChrCount; i++)
for (int i = 0; i < _options.ChrCount; i++)
{
var playClient = new RobotPlayer();
RobotPlayer playClient = new RobotPlayer();
playClient.NewAccount = _options.NewAccount;
playClient.LoginId = string.Concat(_options.LoginAccount, g_nLoginIndex);
playClient.LoginPasswd = playClient.LoginId;
Expand Down
Loading

0 comments on commit 0e7bde7

Please sign in to comment.