Restructure project directories and update includes

Moved source files to src/, header files to include/, and documentation to docs/. Updated Visual Studio project files (.vcxproj, .vcxproj.filters) to reference new file locations and added include/ to the compiler's include path. Added .gitignore and docs/STRUCTURE.md to document the new repository structure. Removed build artifacts and user-specific files from version control.
This commit is contained in:
xixu-me committed 2025-10-09 19:31:33 +08:00
1 parent 7e72ef5f44
commit 4ba86f109d
34 files changed
+5575 -5427

No files matched your search

+98
View File
@@ -0,0 +1,98 @@
# Visual Studio Build Results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio Cache/Options
.vs/
*.suo
*.user
*.userosscache
*.sln.docstates
*.vcxproj.user
# Visual Studio Profiler
*.psess
*.vsp
*.vspx
*.sap
# ReSharper
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# Build Results
[Bb]uild[Ll]og.*
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Visual C++ Cache Files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio Code
.vscode/
*.code-workspace
# Old Visual Studio Files
*.dsp
*.dsw
*.clw
# Windows Image File Caches
Thumbs.db
ehthumbs.db
# Folder Config File
Desktop.ini
# Recycle Bin
$RECYCLE.BIN/
# Mac
.DS_Store
# Temporary Files
*.swp
*~
BIN
View File
Binary file not shown.
-154
View File
@@ -1,154 +0,0 @@
; CLW file contains information for the MFC ClassWizard
[General Info]
Version=1
LastClass=CMicroClientDoc
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "MicroClient.h"
LastPage=0
ClassCount=6
Class1=CMicroClientApp
Class2=CMicroClientDoc
Class3=CMicroClientView
Class4=CMainFrame
ResourceCount=5
Resource1=IDD_DIALOG1
Resource2=IDD_ABOUTBOX
Class5=CAboutDlg
Class6=DSetupDlg
Resource3=IDD_DIALOG1 (Chinese (P.R.C.))
Resource4=IDD_ABOUTBOX (Chinese (P.R.C.))
Resource5=IDR_MAINFRAME (English (U.S.))
[CLS:CMicroClientApp]
Type=0
HeaderFile=MicroClient.h
ImplementationFile=MicroClient.cpp
Filter=N
[CLS:CMicroClientDoc]
Type=0
HeaderFile=MicroClientDoc.h
ImplementationFile=MicroClientDoc.cpp
Filter=N
BaseClass=CDocument
VirtualFilter=DC
LastObject=ID_CONNECT
[CLS:CMicroClientView]
Type=0
HeaderFile=MicroClientView.h
ImplementationFile=MicroClientView.cpp
Filter=C
[CLS:CMainFrame]
Type=0
HeaderFile=MainFrm.h
ImplementationFile=MainFrm.cpp
Filter=T
LastObject=ID_DISCONNECT
[CLS:CAboutDlg]
Type=0
HeaderFile=MicroClient.cpp
ImplementationFile=MicroClient.cpp
Filter=D
LastObject=CAboutDlg
[DLG:IDD_ABOUTBOX]
Type=1
Class=CAboutDlg
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
[DLG:IDD_DIALOG1]
Type=1
Class=DSetupDlg
ControlCount=8
Control1=IDOK,button,1342242817
Control2=IDCANCEL,button,1342242816
Control3=IDC_STATIC,static,1342308352
Control4=IDC_TEAM,edit,1350631552
Control5=IDC_STATIC,static,1342308352
Control6=IDC_SERVER,edit,1350631552
Control7=IDC_STATIC,static,1342308352
Control8=IDC_CHANNEL,edit,1350631552
[CLS:DSetupDlg]
Type=0
HeaderFile=DSetupDlg.h
ImplementationFile=DSetupDlg.cpp
BaseClass=CDialog
Filter=D
LastObject=DSetupDlg
VirtualFilter=dWC
[MNU:IDR_MAINFRAME (English (U.S.))]
Type=1
Class=CMainFrame
Command1=ID_FILE_NEW
Command2=ID_FILE_OPEN
Command3=ID_FILE_SAVE
Command4=ID_FILE_SAVE_AS
Command5=ID_APP_EXIT
Command6=ID_APP_ABOUT
CommandCount=6
[TB:IDR_MAINFRAME (English (U.S.))]
Type=1
Class=CMainFrame
Command1=ID_CONNECT
Command2=ID_DISCONNECT
Command3=ID_APP_ABOUT
CommandCount=3
[ACL:IDR_MAINFRAME (English (U.S.))]
Type=1
Class=CMainFrame
Command1=ID_FILE_NEW
Command2=ID_FILE_OPEN
Command3=ID_FILE_SAVE
Command4=ID_EDIT_UNDO
Command5=ID_EDIT_CUT
Command6=ID_EDIT_COPY
Command7=ID_EDIT_PASTE
Command8=ID_EDIT_UNDO
Command9=ID_EDIT_CUT
Command10=ID_EDIT_COPY
Command11=ID_EDIT_PASTE
Command12=ID_NEXT_PANE
Command13=ID_PREV_PANE
CommandCount=13
[DLG:IDD_DIALOG1 (Chinese (P.R.C.))]
Type=1
Class=?
ControlCount=8
Control1=IDOK,button,1342242817
Control2=IDCANCEL,button,1342242816
Control3=IDC_STATIC,static,1342308352
Control4=IDC_TEAM,edit,1350631552
Control5=IDC_STATIC,static,1342308352
Control6=IDC_SERVER,edit,1350631552
Control7=IDC_STATIC,static,1342308352
Control8=IDC_CHANNEL,edit,1350631552
[DLG:IDD_ABOUTBOX (Chinese (P.R.C.))]
Type=1
Class=?
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+49 -49
View File
@@ -9,7 +9,7 @@
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
Name="Win32" />
</Platforms>
<Configurations>
<Configuration
@@ -34,9 +34,9 @@
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
DebugInformationFormat="4" />
<Tool
Name="VCCustomBuildTool"/>
Name="VCCustomBuildTool" />
<Tool
Name="VCLinkerTool"
OutputFile=".\Debug/Trump.exe"
@@ -45,7 +45,7 @@
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/MicroClient.pdb"
SubSystem="2"
TargetMachine="1"/>
TargetMachine="1" />
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
@@ -53,27 +53,27 @@
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/MicroClient.tlb"
HeaderFileName=""/>
HeaderFileName="" />
<Tool
Name="VCPostBuildEventTool"/>
Name="VCPostBuildEventTool" />
<Tool
Name="VCPreBuildEventTool"/>
Name="VCPreBuildEventTool" />
<Tool
Name="VCPreLinkEventTool"/>
Name="VCPreLinkEventTool" />
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="2052"/>
Culture="2052" />
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
Name="VCWebServiceProxyGeneratorTool" />
<Tool
Name="VCXMLDataGeneratorTool"/>
Name="VCXMLDataGeneratorTool" />
<Tool
Name="VCWebDeploymentTool"/>
Name="VCWebDeploymentTool" />
<Tool
Name="VCManagedWrapperGeneratorTool"/>
Name="VCManagedWrapperGeneratorTool" />
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
Name="VCAuxiliaryManagedWrapperGeneratorTool" />
</Configuration>
<Configuration
Name="Release|Win32"
@@ -99,9 +99,9 @@
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
SuppressStartupBanner="TRUE" />
<Tool
Name="VCCustomBuildTool"/>
Name="VCCustomBuildTool" />
<Tool
Name="VCLinkerTool"
OutputFile=".\Release/MicroClient.exe"
@@ -109,7 +109,7 @@
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\Release/MicroClient.pdb"
SubSystem="2"
TargetMachine="1"/>
TargetMachine="1" />
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
@@ -117,27 +117,27 @@
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/MicroClient.tlb"
HeaderFileName=""/>
HeaderFileName="" />
<Tool
Name="VCPostBuildEventTool"/>
Name="VCPostBuildEventTool" />
<Tool
Name="VCPreBuildEventTool"/>
Name="VCPreBuildEventTool" />
<Tool
Name="VCPreLinkEventTool"/>
Name="VCPreLinkEventTool" />
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="2052"/>
Culture="2052" />
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
Name="VCWebServiceProxyGeneratorTool" />
<Tool
Name="VCXMLDataGeneratorTool"/>
Name="VCXMLDataGeneratorTool" />
<Tool
Name="VCWebDeploymentTool"/>
Name="VCWebDeploymentTool" />
<Tool
Name="VCManagedWrapperGeneratorTool"/>
Name="VCManagedWrapperGeneratorTool" />
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
Name="VCAuxiliaryManagedWrapperGeneratorTool" />
</Configuration>
</Configurations>
<References>
@@ -154,7 +154,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -162,7 +162,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -173,7 +173,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -181,7 +181,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -192,7 +192,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -200,7 +200,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -211,7 +211,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -219,7 +219,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -230,7 +230,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -238,7 +238,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -252,7 +252,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -260,7 +260,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -271,7 +271,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -279,7 +279,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -291,7 +291,7 @@
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
UsePrecompiledHeader="1"/>
UsePrecompiledHeader="1" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -300,7 +300,7 @@
Optimization="2"
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -311,7 +311,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -319,7 +319,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
<File
@@ -330,7 +330,7 @@
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
BasicRuntimeChecks="3" />
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
@@ -338,7 +338,7 @@
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
BrowseInformation="1" />
</FileConfiguration>
</File>
</Filter>
@@ -405,6 +405,6 @@
<Globals>
<Global
Name="RESOURCE_FILE"
Value="MicroClient.rc"/>
Value="MicroClient.rc" />
</Globals>
</VisualStudioProject>
</VisualStudioProject>
+76 -47
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -41,10 +42,14 @@
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
@@ -58,16 +63,19 @@
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">
AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Template|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Template|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -107,6 +115,7 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(ProjectDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@@ -144,86 +153,106 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Agentsock.cpp">
<ClCompile Include="src\Agentsock.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="BaseAgent.cpp">
<ClCompile Include="src\BaseAgent.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="DSetupDlg.cpp">
<ClCompile Include="src\DSetupDlg.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="MainFrm.cpp">
<ClCompile Include="src\MainFrm.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="MicroClient.cpp">
<ClCompile Include="src\MicroClient.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="MicroClientDoc.cpp">
<ClCompile Include="src\MicroClientDoc.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="MicroClientView.cpp">
<ClCompile Include="src\MicroClientView.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="StdAfx.cpp">
<ClCompile Include="src\StdAfx.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="StrategySystem.cpp">
<ClCompile Include="src\StrategySystem.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
<ClCompile Include="TParseString.cpp">
<ClCompile Include="src\TParseString.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</BrowseInformation>
</ClCompile>
</ItemGroup>
@@ -231,18 +260,18 @@
<ResourceCompile Include="MicroClient.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Agentsock.h" />
<ClInclude Include="BaseAgent.h" />
<ClInclude Include="DSetupDlg.h" />
<ClInclude Include="general.h" />
<ClInclude Include="MainFrm.h" />
<ClInclude Include="MicroClient.h" />
<ClInclude Include="MicroClientDoc.h" />
<ClInclude Include="MicroClientView.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="StrategySystem.h" />
<ClInclude Include="TParseString.h" />
<ClInclude Include="include\Agentsock.h" />
<ClInclude Include="include\BaseAgent.h" />
<ClInclude Include="include\DSetupDlg.h" />
<ClInclude Include="include\general.h" />
<ClInclude Include="include\MainFrm.h" />
<ClInclude Include="include\MicroClient.h" />
<ClInclude Include="include\MicroClientDoc.h" />
<ClInclude Include="include\MicroClientView.h" />
<ClInclude Include="include\Resource.h" />
<ClInclude Include="include\StdAfx.h" />
<ClInclude Include="include\StrategySystem.h" />
<ClInclude Include="include\TParseString.h" />
</ItemGroup>
<ItemGroup>
<None Include=".clang-format" />
+22 -22
View File
@@ -15,34 +15,34 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Agentsock.cpp">
<ClCompile Include="src\Agentsock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BaseAgent.cpp">
<ClCompile Include="src\BaseAgent.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DSetupDlg.cpp">
<ClCompile Include="src\DSetupDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MainFrm.cpp">
<ClCompile Include="src\MainFrm.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MicroClient.cpp">
<ClCompile Include="src\MicroClient.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MicroClientDoc.cpp">
<ClCompile Include="src\MicroClientDoc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MicroClientView.cpp">
<ClCompile Include="src\MicroClientView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StdAfx.cpp">
<ClCompile Include="src\StdAfx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StrategySystem.cpp">
<ClCompile Include="src\StrategySystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TParseString.cpp">
<ClCompile Include="src\TParseString.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -52,40 +52,40 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Agentsock.h">
<ClInclude Include="include\Agentsock.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BaseAgent.h">
<ClInclude Include="include\BaseAgent.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DSetupDlg.h">
<ClInclude Include="include\DSetupDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="general.h">
<ClInclude Include="include\general.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MainFrm.h">
<ClInclude Include="include\MainFrm.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MicroClient.h">
<ClInclude Include="include\MicroClient.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MicroClientDoc.h">
<ClInclude Include="include\MicroClientDoc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MicroClientView.h">
<ClInclude Include="include\MicroClientView.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<ClInclude Include="include\Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StdAfx.h">
<ClInclude Include="include\StdAfx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StrategySystem.h">
<ClInclude Include="include\StrategySystem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TParseString.h">
<ClInclude Include="include\TParseString.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
File renamed without changes.
File renamed without changes.
+178
View File
@@ -0,0 +1,178 @@
# ATRI-2024 Repository Structure
This document describes the reorganized file structure for the ATRI-2024 FIRA SimuroSot 11vs11 client repository.
## Directory Structure
```
ATRI-2024/
├── src/ # Source code files (.cpp)
│ ├── Agentsock.cpp # Socket communication implementation
│ ├── BaseAgent.cpp # Base agent class implementation
│ ├── DSetupDlg.cpp # Setup dialog implementation
│ ├── MainFrm.cpp # Main frame window implementation
│ ├── MicroClient.cpp # Main application implementation
│ ├── MicroClientDoc.cpp # Document class implementation
│ ├── MicroClientView.cpp # View class implementation
│ ├── StdAfx.cpp # Precompiled header source
│ ├── StrategySystem.cpp # Core strategy system implementation
│ └── TParseString.cpp # String parsing utilities
│
├── include/ # Header files (.h)
│ ├── Agentsock.h # Socket communication interface
│ ├── BaseAgent.h # Base agent class interface
│ ├── DSetupDlg.h # Setup dialog interface
│ ├── General.h # General definitions and structures
│ ├── MainFrm.h # Main frame window interface
│ ├── MicroClient.h # Main application interface
│ ├── MicroClientDoc.h # Document class interface
│ ├── MicroClientView.h # View class interface
│ ├── Resource.h # Resource IDs
│ ├── StdAfx.h # Precompiled header
│ ├── StrategySystem.h # Strategy system interface
│ └── TParseString.h # String parsing utilities interface
│
├── res/ # Resource files
│ ├── MicroClient.ico # Application icon
│ ├── MicroClient.rc2 # Additional resources
│ ├── MicroClientDoc.ico # Document icon
│ └── Toolbar.bmp # Toolbar bitmap
│
├── docs/ # Documentation
│ ├── Contest-Rules-2024.pdf # Competition rules
│ └── Field Coordinates.jpg # Field coordinate system reference
│
├── MicroClient.sln # Visual Studio solution file
├── MicroClient.vcxproj # Visual Studio project file (VS 2010+)
├── MicroClient.vcxproj.filters # Project filters
├── MicroClient.rc # Resource script
├── MicroClient.dsp # Legacy project file (VS 6.0)
├── MicroClient.dsw # Legacy workspace file (VS 6.0)
├── MicroClient.vcproj # Legacy project file (VS 2008)
├── .gitignore # Git ignore rules
├── README.md # Main documentation (English)
└── LICENSE # License file
```
## Key Changes from Original Structure
### Organization
- **Source files** moved from root to `src/` directory
- **Header files** moved from root to `include/` directory
- **Documentation** moved to `docs/` directory
- **Resources** reorganized in `res/` directory (lowercase)
### Project Configuration
- Updated `MicroClient.vcxproj` to reference new file locations
- Added `include` directory to Additional Include Directories
- Updated `MicroClient.vcxproj.filters` to match new structure
### New Files
- **README.md**: Comprehensive English documentation
- **.gitignore**: Excludes build artifacts and temporary files
- **docs/STRUCTURE.md**: This file - documents repository organization
### Removed from Git
Build artifacts and temporary files (via .gitignore):
- `*.suo`, `*.user` - User-specific Visual Studio files
- `*.aps`, `*.clw`, `*.ncb` - Build cache files
- `Debug/`, `Release/` - Build output directories
## Building the Project
The project can still be built using:
- **Visual Studio 2010 or later**: Open `MicroClient.sln`
- **Visual Studio 6.0** (legacy): Open `MicroClient.dsw`
The project files have been updated to automatically find source and header files in their new locations.
## Core Components
### Strategy System (`StrategySystem.cpp/h`)
Main decision-making logic for the robot team:
- Penalty kicks handling
- Free ball (争球) strategy
- Ball possession/offensive play
- Goalkeeper logic
- Dynamic formation management
### Agent System (`BaseAgent.cpp/h`, `Agentsock.cpp/h`)
Robot agent framework:
- Base agent class for robot behavior
- Socket communication with simulation server
- Real-time data exchange
### User Interface (`MicroClientView.cpp/h`, `MainFrm.cpp/h`)
MFC-based graphical interface:
- Game visualization
- Real-time monitoring
- Control panel
### Configuration (`DSetupDlg.cpp/h`)
Setup and configuration:
- Connection settings
- Team configuration
- Strategy parameters
## Development Guidelines
### Adding New Files
**Source files (.cpp)**:
- Place in `src/` directory
- Add to `MicroClient.vcxproj` under `<ItemGroup><ClCompile>`
- Add to `MicroClient.vcxproj.filters` under Source Files filter
**Header files (.h)**:
- Place in `include/` directory
- Add to `MicroClient.vcxproj` under `<ItemGroup><ClInclude>`
- Add to `MicroClient.vcxproj.filters` under Header Files filter
- Include in source files as: `#include "filename.h"` (include directory is in path)
**Resources**:
- Place in `res/` directory
- Reference in `MicroClient.rc` as needed
### Include Path
The `include/` directory is automatically added to the compiler's include path, so headers can be included directly:
```cpp
#include "StrategySystem.h" // Not #include "include/StrategySystem.h"
```
## License
This project uses a custom Noncommercial No-Derivatives Software License (NCND-Software-1.0).
- ✅ Free for non-commercial use (education, research, personal)
- ✅ Can use and distribute unmodified code
- ❌ No commercial use allowed
- ❌ No distribution of modified versions
See [LICENSE](../LICENSE) file for complete terms.
## Team
Developed by ATRI (Ace Team of Robotics Intelligence) for the 2024 China Robot Competition & RoboCup China Open.
- Team Leader: @xixu-me
- Members: @XIAOLingQ, @Wx-debug, @moxun333, @song-yaya, @huaxiaoshi, @biqianq, @isWorldEdit
+27 -27
View File
@@ -1,27 +1,27 @@
#ifndef __AGENTSOCK_H__
#define __AGENTSOCK_H__
class CAgentSocket : public CAsyncSocket {
DECLARE_DYNAMIC(CAgentSocket);
public:
CAgentSocket();
BOOL Create(UINT nSocketPort, LPCTSTR lpszSocketAddress);
BOOL Bind(UINT nSocketPort, LPCTSTR lpszSocketAddress);
BOOL Connect(LPCTSTR lpszHostAddress, UINT nHostPort);
int ReceiveFrom(void *lpBuf, int nBufLen, CString &rSocketAddress, UINT &rSocketPort, int nFlags);
int SendTo(const void *lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags);
void SetPort(UINT port) { m_uiPort = port; };
UINT GetPort(void) { return m_uiPort; };
CString GetAddress(void) { return m_sSocketAddress; };
protected:
virtual void OnReceive(int nErrorCode);
private:
SOCKADDR_IN sockAddr;
UINT m_uiPort;
CString m_sSocketAddress;
};
#endif // __AGENTSOCK_H__
#ifndef __AGENTSOCK_H__
#define __AGENTSOCK_H__
class CAgentSocket : public CAsyncSocket {
DECLARE_DYNAMIC(CAgentSocket);
public:
CAgentSocket();
BOOL Create(UINT nSocketPort, LPCTSTR lpszSocketAddress);
BOOL Bind(UINT nSocketPort, LPCTSTR lpszSocketAddress);
BOOL Connect(LPCTSTR lpszHostAddress, UINT nHostPort);
int ReceiveFrom(void *lpBuf, int nBufLen, CString &rSocketAddress, UINT &rSocketPort, int nFlags);
int SendTo(const void *lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags);
void SetPort(UINT port) { m_uiPort = port; };
UINT GetPort(void) { return m_uiPort; };
CString GetAddress(void) { return m_sSocketAddress; };
protected:
virtual void OnReceive(int nErrorCode);
private:
SOCKADDR_IN sockAddr;
UINT m_uiPort;
CString m_sSocketAddress;
};
#endif // __AGENTSOCK_H__
+59 -59
View File
@@ -1,59 +1,59 @@
// BaseAgent.h: interface for the CBaseAgent class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BASEAGENT_H__7FCEA561_5114_11D1_B242_0000C09B5CBE__INCLUDED_)
#define AFX_BASEAGENT_H__7FCEA561_5114_11D1_B242_0000C09B5CBE__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "Agentsock.h"
class CMicroClientDoc;
class CBaseAgent : public CAgentSocket {
public:
CBaseAgent();
CBaseAgent(CMicroClientDoc *m_pDoc);
virtual ~CBaseAgent();
BOOL ConnectAgent(LPCTSTR lpszTeam, LPCTSTR lpszServer, UINT nPort);
void DisconnectAgent(void);
// communication functions
virtual void OnReceive(int nErrorCode);
void SendMsg(CString &strText);
// overridables
virtual void OnCreatedSocket();
virtual void OnSentMessage(LPCTSTR message){};
virtual void OnReceivedMessage(LPCTSTR message){};
virtual void OnErrorCreatingSocket(){};
virtual void OnErrorSendingMessage(){};
virtual void OnErrorReceivingMessage(){};
// the agents actions
// attribute fuctions
BOOL IsConnected() { return m_bConnected; };
void SetSide(int side) { m_iSide = side; };
protected:
CString m_strTeam; // name of the team the player is in
int m_iSide; // side on which playing
int m_iNumber; // number of the player
BOOL m_bConnected; // true, if the agent is currently connected
public:
void SendCommand();
CString teamname;
BOOL ParseObject(LPCTSTR str);
int m_iTime;
void ParseSee(LPCTSTR str);
int m_iPlayMode;
void ParseInit(LPCTSTR str);
void ParseMessage(LPCTSTR str);
CMicroClientDoc *m_pDoc;
send_to_team teaminfo;
};
#endif // !defined(AFX_BASEAGENT_H__7FCEA561_5114_11D1_B242_0000C09B5CBE__INCLUDED_)
// BaseAgent.h: interface for the CBaseAgent class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BASEAGENT_H__7FCEA561_5114_11D1_B242_0000C09B5CBE__INCLUDED_)
#define AFX_BASEAGENT_H__7FCEA561_5114_11D1_B242_0000C09B5CBE__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "Agentsock.h"
class CMicroClientDoc;
class CBaseAgent : public CAgentSocket {
public:
CBaseAgent();
CBaseAgent(CMicroClientDoc *m_pDoc);
virtual ~CBaseAgent();
BOOL ConnectAgent(LPCTSTR lpszTeam, LPCTSTR lpszServer, UINT nPort);
void DisconnectAgent(void);
// communication functions
virtual void OnReceive(int nErrorCode);
void SendMsg(CString &strText);
// overridables
virtual void OnCreatedSocket();
virtual void OnSentMessage(LPCTSTR message) {};
virtual void OnReceivedMessage(LPCTSTR message) {};
virtual void OnErrorCreatingSocket() {};
virtual void OnErrorSendingMessage() {};
virtual void OnErrorReceivingMessage() {};
// the agents actions
// attribute fuctions
BOOL IsConnected() { return m_bConnected; };
void SetSide(int side) { m_iSide = side; };
protected:
CString m_strTeam; // name of the team the player is in
int m_iSide; // side on which playing
int m_iNumber; // number of the player
BOOL m_bConnected; // true, if the agent is currently connected
public:
void SendCommand();
CString teamname;
BOOL ParseObject(LPCTSTR str);
int m_iTime;
void ParseSee(LPCTSTR str);
int m_iPlayMode;
void ParseInit(LPCTSTR str);
void ParseMessage(LPCTSTR str);
CMicroClientDoc *m_pDoc;
send_to_team teaminfo;
};
#endif // !defined(AFX_BASEAGENT_H__7FCEA561_5114_11D1_B242_0000C09B5CBE__INCLUDED_)
+46 -46
View File
@@ -1,46 +1,46 @@
#if !defined(AFX_DSETUPDLG_H__AF3ADFE0_2D54_11D4_8C19_000021D262EF__INCLUDED_)
#define AFX_DSETUPDLG_H__AF3ADFE0_2D54_11D4_8C19_000021D262EF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DSetupDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// DSetupDlg dialog
class DSetupDlg : public CDialog {
// Construction
public:
DSetupDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(DSetupDlg)
enum { IDD = IDD_DIALOG1 };
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(DSetupDlg)
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
public:
CString m_TeamName;
CString m_ServerName;
UINT m_Channel;
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(DSetupDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DSETUPDLG_H__AF3ADFE0_2D54_11D4_8C19_000021D262EF__INCLUDED_)
#if !defined(AFX_DSETUPDLG_H__AF3ADFE0_2D54_11D4_8C19_000021D262EF__INCLUDED_)
#define AFX_DSETUPDLG_H__AF3ADFE0_2D54_11D4_8C19_000021D262EF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DSetupDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// DSetupDlg dialog
class DSetupDlg : public CDialog {
// Construction
public:
DSetupDlg(CWnd *pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(DSetupDlg)
enum { IDD = IDD_DIALOG1 };
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(DSetupDlg)
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
public:
CString m_TeamName;
CString m_ServerName;
UINT m_Channel;
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(DSetupDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DSETUPDLG_H__AF3ADFE0_2D54_11D4_8C19_000021D262EF__INCLUDED_)
+145 -145
View File
@@ -1,145 +1,145 @@
/////////////////////////////////////////////////////////////////
#define BORDERNUM 18
/////////////////////////////////////////////////////////////////
#define HIT_LEFTGOAL 0
#define HIT_RIGHTGOAL 1
#define HIT_UPBORDER 2
#define HIT_DOWNBORDER 3
#define HIT_LEFT_GOAL_UPBORDER 4
#define HIT_LEFT_GOAL_DOWNBORDER 5
#define HIT_RIGHT_GOAL_UPBORDER 6
#define HIT_RIGHT_GOAL_DOWNBORDER 7
#define HIT_LEFT_UPBORDER 8
#define HIT_LEFT_DOWNBORDER 9
#define HIT_RIGHT_UPBORDER 10
#define HIT_RIGHT_DOWNBORDER 11
#define HIT_LEFT_GOALBORDER 12
#define HIT_RIGHT_GOALBORDER 13
#define HIT_LEFTUPCORNER 14
#define HIT_LEFTDOWNCORNER 15
#define HIT_RIGHTDOWNCORNER 16
#define HIT_RIGHTUPCORNER 17
#define HIT_YH1 18
#define HIT_YH2 19
#define HIT_YHG 20
#define HIT_BH1 21
#define HIT_BH2 22
#define HIT_BHG 23
#define HIT_BALL 24
/////////////////////////////////////////////////////////////////
#define FRONT 0
#define RIGHT 1
#define BACK 2
#define LEFT 3
///////////////////////////////////////////////////////////////////
#define BALL 0
#define HOME1 1
#define HOME2 2
#define HOME3 3
#define HOME4 4
#define HOME5 5
#define HOME6 6
#define HOME7 7
#define HOME8 8
#define HOME9 9
#define HOME10 10
#define HGOALIE 11
#define C_GO 0xaa
#define C_STOP 0x55
#define G_OFFSET 20 // 15
#define G_ANGLE_BOUND 60
#define G_BOUND_BOUND 10
///////////////////////////////////////////////////////////////////
// 所在半场
#define GAME_RIGHT 0
#define GAME_LEFT 1
////////////////////////////////////////////////////////////////////
#define PI 3.14
#define M_PI PI
#define square(a) ((a) * (a))
#define leng(a, b, c, d) sqrt(square((a) - (c)) + square((b) - (d)))
#define pleng(a, b) sqrt(square((a.x) - (b.x)) + square((a.y) - (b.y)))
//////////////////////////////////////////
#define Atan(y, x) ((x == 0.0 && y == 0.0) ? (0.0) : atan2(y, x))
#define RAD2DEG (180.0 / PI)
#define DEG2RAD (PI / 180.0)
#define Rad2Deg(a) ((double)a * RAD2DEG)
#define Deg2Rad(a) ((double)a * DED2RAD)
#define ABS(a) ((a) < 0 ? -(a) : (a))
/////////////////////////////////////////////////////////////
union CCommand {
BYTE Stream[3];
struct tagData {
char Lv;
char Rv;
char Command;
} Data;
CCommand &operator=(CCommand &r) {
Data.Lv = r.Data.Lv;
Data.Rv = r.Data.Rv;
Data.Command = r.Data.Command;
return *this;
}
};
struct Robot1 {
int angle;
int sAngle;
CPoint angleRef;
CPoint sAngleRef;
CPoint position, oldPosition;
CPoint sPosition, sOldPosition;
int nMethod;
BYTE color[6];
BOOL bAlive;
Robot1(){};
BOOL find() { return TRUE; };
BOOL entireFind() { return TRUE; };
BOOL entireFind(BYTE *lpY, BYTE *lpU, BYTE *lpV) { return TRUE; };
};
struct Robot2 {
int angle;
int sAngle;
CPoint position, oldPosition;
CPoint sPosition, sOldPosition;
CPoint pos, oldPos, pos1, oldPos1;
int nMethod;
BYTE color[6];
BOOL bAlive;
BYTE teamColor[6];
Robot2(){};
BOOL find() { return TRUE; };
BOOL entireFind() { return TRUE; };
BOOL entireFind(BYTE *lpY, BYTE *lpU, BYTE *lpV) { return TRUE; };
};
struct Robot3 {
CPoint position1, oldPosition1;
CPoint sPosition1, sOldPosition1;
CPoint position2, oldPosition2;
CPoint sPosition2, sOldPosition2;
CPoint position3, oldPosition3;
CPoint position4, oldPosition4;
CPoint position5, oldPosition5;
CPoint sPosition3, sOldPosition3;
CPoint position6, oldPosition6;
CPoint position7, oldPosition7;
CPoint position8, oldPosition8;
CPoint position9, oldPosition9;
CPoint position10, oldPosition10;
CPoint position11, oldPosition11;
int nMethod;
BYTE color[6];
BOOL bAlive;
Robot3(){};
BOOL find1() { return TRUE; }
BOOL find2() { return TRUE; }
BOOL find3() { return TRUE; }
BOOL entireFind() { return TRUE; }
BOOL entireFind(BYTE *lpY, BYTE *lpU, BYTE *lpV) { return TRUE; }
};
/////////////////////////////////////////////////////////////////
#define BORDERNUM 18
/////////////////////////////////////////////////////////////////
#define HIT_LEFTGOAL 0
#define HIT_RIGHTGOAL 1
#define HIT_UPBORDER 2
#define HIT_DOWNBORDER 3
#define HIT_LEFT_GOAL_UPBORDER 4
#define HIT_LEFT_GOAL_DOWNBORDER 5
#define HIT_RIGHT_GOAL_UPBORDER 6
#define HIT_RIGHT_GOAL_DOWNBORDER 7
#define HIT_LEFT_UPBORDER 8
#define HIT_LEFT_DOWNBORDER 9
#define HIT_RIGHT_UPBORDER 10
#define HIT_RIGHT_DOWNBORDER 11
#define HIT_LEFT_GOALBORDER 12
#define HIT_RIGHT_GOALBORDER 13
#define HIT_LEFTUPCORNER 14
#define HIT_LEFTDOWNCORNER 15
#define HIT_RIGHTDOWNCORNER 16
#define HIT_RIGHTUPCORNER 17
#define HIT_YH1 18
#define HIT_YH2 19
#define HIT_YHG 20
#define HIT_BH1 21
#define HIT_BH2 22
#define HIT_BHG 23
#define HIT_BALL 24
/////////////////////////////////////////////////////////////////
#define FRONT 0
#define RIGHT 1
#define BACK 2
#define LEFT 3
///////////////////////////////////////////////////////////////////
#define BALL 0
#define HOME1 1
#define HOME2 2
#define HOME3 3
#define HOME4 4
#define HOME5 5
#define HOME6 6
#define HOME7 7
#define HOME8 8
#define HOME9 9
#define HOME10 10
#define HGOALIE 11
#define C_GO 0xaa
#define C_STOP 0x55
#define G_OFFSET 20 // 15
#define G_ANGLE_BOUND 60
#define G_BOUND_BOUND 10
///////////////////////////////////////////////////////////////////
// 所在半场
#define GAME_RIGHT 0
#define GAME_LEFT 1
////////////////////////////////////////////////////////////////////
#define PI 3.14
#define M_PI PI
#define square(a) ((a) * (a))
#define leng(a, b, c, d) sqrt(square((a) - (c)) + square((b) - (d)))
#define pleng(a, b) sqrt(square((a.x) - (b.x)) + square((a.y) - (b.y)))
//////////////////////////////////////////
#define Atan(y, x) ((x == 0.0 && y == 0.0) ? (0.0) : atan2(y, x))
#define RAD2DEG (180.0 / PI)
#define DEG2RAD (PI / 180.0)
#define Rad2Deg(a) ((double)a * RAD2DEG)
#define Deg2Rad(a) ((double)a * DED2RAD)
#define ABS(a) ((a) < 0 ? -(a) : (a))
/////////////////////////////////////////////////////////////
union CCommand {
BYTE Stream[3];
struct tagData {
char Lv;
char Rv;
char Command;
} Data;
CCommand &operator=(CCommand &r) {
Data.Lv = r.Data.Lv;
Data.Rv = r.Data.Rv;
Data.Command = r.Data.Command;
return *this;
}
};
struct Robot1 {
int angle;
int sAngle;
CPoint angleRef;
CPoint sAngleRef;
CPoint position, oldPosition;
CPoint sPosition, sOldPosition;
int nMethod;
BYTE color[6];
BOOL bAlive;
Robot1() {};
BOOL find() { return TRUE; };
BOOL entireFind() { return TRUE; };
BOOL entireFind(BYTE *lpY, BYTE *lpU, BYTE *lpV) { return TRUE; };
};
struct Robot2 {
int angle;
int sAngle;
CPoint position, oldPosition;
CPoint sPosition, sOldPosition;
CPoint pos, oldPos, pos1, oldPos1;
int nMethod;
BYTE color[6];
BOOL bAlive;
BYTE teamColor[6];
Robot2() {};
BOOL find() { return TRUE; };
BOOL entireFind() { return TRUE; };
BOOL entireFind(BYTE *lpY, BYTE *lpU, BYTE *lpV) { return TRUE; };
};
struct Robot3 {
CPoint position1, oldPosition1;
CPoint sPosition1, sOldPosition1;
CPoint position2, oldPosition2;
CPoint sPosition2, sOldPosition2;
CPoint position3, oldPosition3;
CPoint position4, oldPosition4;
CPoint position5, oldPosition5;
CPoint sPosition3, sOldPosition3;
CPoint position6, oldPosition6;
CPoint position7, oldPosition7;
CPoint position8, oldPosition8;
CPoint position9, oldPosition9;
CPoint position10, oldPosition10;
CPoint position11, oldPosition11;
int nMethod;
BYTE color[6];
BOOL bAlive;
Robot3() {};
BOOL find1() { return TRUE; }
BOOL find2() { return TRUE; }
BOOL find3() { return TRUE; }
BOOL entireFind() { return TRUE; }
BOOL entireFind(BYTE *lpY, BYTE *lpU, BYTE *lpV) { return TRUE; }
};
+55 -55
View File
@@ -1,55 +1,55 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__801AABE9_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MAINFRM_H__801AABE9_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CFrameWnd {
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__801AABE9_2D67_11D4_A201_00400564C758__INCLUDED_)
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__801AABE9_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MAINFRM_H__801AABE9_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CFrameWnd {
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__801AABE9_2D67_11D4_A201_00400564C758__INCLUDED_)
+47 -47
View File
@@ -1,47 +1,47 @@
// MicroClient.h : main header file for the MICROCLIENT application
//
#if !defined(AFX_MICROCLIENT_H__801AABE5_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MICROCLIENT_H__801AABE5_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp:
// See MicroClient.cpp for the implementation of this class
//
class CMicroClientApp : public CWinApp {
public:
CMicroClientApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMicroClientApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CMicroClientApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MICROCLIENT_H__801AABE5_2D67_11D4_A201_00400564C758__INCLUDED_)
// MicroClient.h : main header file for the MICROCLIENT application
//
#if !defined(AFX_MICROCLIENT_H__801AABE5_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MICROCLIENT_H__801AABE5_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp:
// See MicroClient.cpp for the implementation of this class
//
class CMicroClientApp : public CWinApp {
public:
CMicroClientApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMicroClientApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CMicroClientApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MICROCLIENT_H__801AABE5_2D67_11D4_A201_00400564C758__INCLUDED_)
+56 -56
View File
@@ -1,56 +1,56 @@
// MicroClientDoc.h : interface of the CMicroClientDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MICROCLIENTDOC_H__801AABEB_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MICROCLIENTDOC_H__801AABEB_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CBaseAgent;
class CMicroClientDoc : public CDocument {
protected: // create from serialization only
CMicroClientDoc();
DECLARE_DYNCREATE(CMicroClientDoc)
// Attributes
public:
CBaseAgent *m_pAgent;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMicroClientDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive &ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMicroClientDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMicroClientDoc)
afx_msg void OnConnect();
afx_msg void OnUpdateConnect(CCmdUI *pCmdUI);
afx_msg void OnDisconnect();
afx_msg void OnUpdateDisconnect(CCmdUI *pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MICROCLIENTDOC_H__801AABEB_2D67_11D4_A201_00400564C758__INCLUDED_)
// MicroClientDoc.h : interface of the CMicroClientDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MICROCLIENTDOC_H__801AABEB_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MICROCLIENTDOC_H__801AABEB_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CBaseAgent;
class CMicroClientDoc : public CDocument {
protected: // create from serialization only
CMicroClientDoc();
DECLARE_DYNCREATE(CMicroClientDoc)
// Attributes
public:
CBaseAgent *m_pAgent;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMicroClientDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive &ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMicroClientDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMicroClientDoc)
afx_msg void OnConnect();
afx_msg void OnUpdateConnect(CCmdUI *pCmdUI);
afx_msg void OnDisconnect();
afx_msg void OnUpdateDisconnect(CCmdUI *pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MICROCLIENTDOC_H__801AABEB_2D67_11D4_A201_00400564C758__INCLUDED_)
+60 -60
View File
@@ -1,60 +1,60 @@
// MicroClientView.h : interface of the CMicroClientView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MICROCLIENTVIEW_H__801AABED_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MICROCLIENTVIEW_H__801AABED_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMicroClientView : public CView {
protected: // create from serialization only
CMicroClientView();
DECLARE_DYNCREATE(CMicroClientView)
// Attributes
public:
CMicroClientDoc *GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMicroClientView)
public:
virtual void OnDraw(CDC *pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
protected:
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMicroClientView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMicroClientView)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in MicroClientView.cpp
inline CMicroClientDoc *CMicroClientView::GetDocument() { return (CMicroClientDoc *)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MICROCLIENTVIEW_H__801AABED_2D67_11D4_A201_00400564C758__INCLUDED_)
// MicroClientView.h : interface of the CMicroClientView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MICROCLIENTVIEW_H__801AABED_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_MICROCLIENTVIEW_H__801AABED_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMicroClientView : public CView {
protected: // create from serialization only
CMicroClientView();
DECLARE_DYNCREATE(CMicroClientView)
// Attributes
public:
CMicroClientDoc *GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMicroClientView)
public:
virtual void OnDraw(CDC *pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
protected:
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMicroClientView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMicroClientView)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in MicroClientView.cpp
inline CMicroClientDoc *CMicroClientView::GetDocument() { return (CMicroClientDoc *)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MICROCLIENTVIEW_H__801AABED_2D67_11D4_A201_00400564C758__INCLUDED_)
+26 -26
View File
@@ -1,26 +1,26 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by MicroClient.rc
//
#define IDD_ABOUTBOX 100
#define IDP_SOCKETS_INIT_FAILED 104
#define IDR_MAINFRAME 128
#define IDR_MICROCTYPE 129
#define IDD_DIALOG1 130
#define IDC_TEAM 1000
#define IDC_SERVER 1001
#define IDC_CHANNEL 1002
#define ID_CONNECT 32771
#define ID_DISCONNECT 32772
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32773
#define _APS_NEXT_CONTROL_VALUE 1003
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by MicroClient.rc
//
#define IDD_ABOUTBOX 100
#define IDP_SOCKETS_INIT_FAILED 104
#define IDR_MAINFRAME 128
#define IDR_MICROCTYPE 129
#define IDD_DIALOG1 130
#define IDC_TEAM 1000
#define IDC_SERVER 1001
#define IDC_CHANNEL 1002
#define ID_CONNECT 32771
#define ID_DISCONNECT 32772
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32773
#define _APS_NEXT_CONTROL_VALUE 1003
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
+49 -49
View File
@@ -1,49 +1,49 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__801AABE7_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_STDAFX_H__801AABE7_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h> // MFC socket extensions
#include <math.h>
#define LEFT_TO_RIGHT 0
#define RIGHT_TO_LEFT 1
#define MAX_PLAYER 3
#define OWN_TEAM 0
#define OTHER_TEAM 1
typedef struct pos_t {
short enable;
short side;
short unum;
short angle;
short x;
short y;
} pos_t;
typedef struct send_to_team {
pos_t pos[MAX_PLAYER * 2];
} send_to_team;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__801AABE7_2D67_11D4_A201_00400564C758__INCLUDED_)
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__801AABE7_2D67_11D4_A201_00400564C758__INCLUDED_)
#define AFX_STDAFX_H__801AABE7_2D67_11D4_A201_00400564C758__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h> // MFC socket extensions
#include <math.h>
#define LEFT_TO_RIGHT 0
#define RIGHT_TO_LEFT 1
#define MAX_PLAYER 3
#define OWN_TEAM 0
#define OTHER_TEAM 1
typedef struct pos_t {
short enable;
short side;
short unum;
short angle;
short x;
short y;
} pos_t;
typedef struct send_to_team {
pos_t pos[MAX_PLAYER * 2];
} send_to_team;
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__801AABE7_2D67_11D4_A201_00400564C758__INCLUDED_)
+109 -109
View File
@@ -1,109 +1,109 @@
#include "general.h"
#ifndef _INSIDE_VISUAL_CPP_STRATEGYSYSTEM
#define _INSIDE_VISUAL_CPP_STRATEGYSYSTEM
// 阵型球员相对中央球员的位置结构体
struct RelPos {
int id;
double dis;
double ang;
};
class CStrategySystem : public CObject {
DECLARE_DYNAMIC(CStrategySystem)
public:
void Action();
// ~CStrategySystem();
CStrategySystem(int id);
void ReceiveData(Robot1 bal, Robot2 ho1, Robot2 ho2, Robot2 ho3, Robot2 ho4,
Robot2 ho5, Robot2 ho6, Robot2 ho7, Robot2 ho8, Robot2 ho9,
Robot2 ho10, Robot2 hgo, Robot3 opp);
#ifdef _DEBUG
#endif // _DEBUG
private:
void Penalty(); // 罚球
void Freeball(); // 争球
void Possession(); // 控球
void Goalie(); // 守门
CPoint *pos; // 球员位置
RelPos *rp; // 阵型球员相对中央球员的位置
int cp_id(); // 中央球员 ID
void fp_sort(RelPos *rp, int h = 0, int t = 0); // 阵型球员排序,h 为该层前的球员数量,t 为包含该层后的球员数量
int fm_id(); // 阵型 ID
CPoint coor(int which); // 返回机器人的位置
// void spin(int which, bool isClockwise); // 自旋
void shot1(int which, double o, CPoint t); // 直射
bool canshot(); // 射?
int search1(); // 查找在大区里的机器人
int search2(); // 查找在小区里的机器人
//CPoint searchNear(int which); // 查找最近的机器人
// void control(int which);
// void ccd(int which, double d, double j); // 曲线行驶
double atwo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); // 两直线间夹角
// void navigate();
void shot(int which); // 射门;
void shot(int which,CPoint t); // 把球向 t 点射,de 向上还是向下射,de = 0从上向下射
CPoint shooter_pos(); // 对方射门者位置
double Distance(CPoint point1, CPoint point2); // 计算两点之间的距离
double Angle(CPoint point1, CPoint point2); // 计算两点之间的角度
void Direction(int which, CPoint point);
// void DirectionSE(int which, CPoint point); // 不进禁区版 Direction
void PositionSE(int which, CPoint point); // 不进禁区版 Position
void Rush(int which, CPoint point); // 冲向某点
int Status(); // 判断状态
void Stop(int which);
void Position(int which, CPoint point);
void Velocity(int which, int vL, int vR);
void Angle(int which, int desired_angle);
CRect boundRect;
int m_nStrategy;
int m_OurTeam;
int m_nGameArea;
double ShootLen;
int nShoot;
int nSweep;
int nKick2;
CPoint ShootVar;
CPoint KickVar;
double KickLen;
CCommand C_Home3;
CCommand C_Home2;
CCommand C_Home1;
CCommand C_Home4;
CCommand C_Home5;
CCommand C_Home6;
CCommand C_Home7;
CCommand C_Home8;
CCommand C_Home9;
CCommand C_Home10;
CCommand C_Home11;
Robot1 ball;
Robot2 home1, home2, home3, home4, home5, home6, home7, home8, home9, home10, hgoalie;
Robot3 opponent;
bool start; // 是否刚开始
int T; // 时间,即周期数
struct infor {
int num; // 球员编号
double dis; // 球员到球的距离
};
bool flag;
// std::vector<CPoint> Navigation;
// void Think();
public:
int command[35];
};
#endif // _INSIDE_VISUAL_CPP_STRATEGYSYSTEM
#include "general.h"
#ifndef _INSIDE_VISUAL_CPP_STRATEGYSYSTEM
#define _INSIDE_VISUAL_CPP_STRATEGYSYSTEM
// 阵型球员相对中央球员的位置结构体
struct RelPos {
int id;
double dis;
double ang;
};
class CStrategySystem : public CObject {
DECLARE_DYNAMIC(CStrategySystem)
public:
void Action();
// ~CStrategySystem();
CStrategySystem(int id);
void ReceiveData(Robot1 bal, Robot2 ho1, Robot2 ho2, Robot2 ho3, Robot2 ho4,
Robot2 ho5, Robot2 ho6, Robot2 ho7, Robot2 ho8, Robot2 ho9,
Robot2 ho10, Robot2 hgo, Robot3 opp);
#ifdef _DEBUG
#endif // _DEBUG
private:
void Penalty(); // 罚球
void Freeball(); // 争球
void Possession(); // 控球
void Goalie(); // 守门
CPoint *pos; // 球员位置
RelPos *rp; // 阵型球员相对中央球员的位置
int cp_id(); // 中央球员 ID
void fp_sort(RelPos *rp, int h = 0, int t = 0); // 阵型球员排序,h 为该层前的球员数量,t 为包含该层后的球员数量
int fm_id(); // 阵型 ID
CPoint coor(int which); // 返回机器人的位置
// void spin(int which, bool isClockwise); // 自旋
void shot1(int which, double o, CPoint t); // 直射
bool canshot(); // 射?
int search1(); // 查找在大区里的机器人
int search2(); // 查找在小区里的机器人
// CPoint searchNear(int which); // 查找最近的机器人
// void control(int which);
// void ccd(int which, double d, double j); // 曲线行驶
double atwo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); // 两直线间夹角
// void navigate();
void shot(int which); // 射门;
void shot(int which, CPoint t); // 把球向 t 点射,de 向上还是向下射,de = 0从上向下射
CPoint shooter_pos(); // 对方射门者位置
double Distance(CPoint point1, CPoint point2); // 计算两点之间的距离
double Angle(CPoint point1, CPoint point2); // 计算两点之间的角度
void Direction(int which, CPoint point);
// void DirectionSE(int which, CPoint point); // 不进禁区版 Direction
void PositionSE(int which, CPoint point); // 不进禁区版 Position
void Rush(int which, CPoint point); // 冲向某点
int Status(); // 判断状态
void Stop(int which);
void Position(int which, CPoint point);
void Velocity(int which, int vL, int vR);
void Angle(int which, int desired_angle);
CRect boundRect;
int m_nStrategy;
int m_OurTeam;
int m_nGameArea;
double ShootLen;
int nShoot;
int nSweep;
int nKick2;
CPoint ShootVar;
CPoint KickVar;
double KickLen;
CCommand C_Home3;
CCommand C_Home2;
CCommand C_Home1;
CCommand C_Home4;
CCommand C_Home5;
CCommand C_Home6;
CCommand C_Home7;
CCommand C_Home8;
CCommand C_Home9;
CCommand C_Home10;
CCommand C_Home11;
Robot1 ball;
Robot2 home1, home2, home3, home4, home5, home6, home7, home8, home9, home10, hgoalie;
Robot3 opponent;
bool start; // 是否刚开始
int T; // 时间,即周期数
struct infor {
int num; // 球员编号
double dis; // 球员到球的距离
};
bool flag;
// std::vector<CPoint> Navigation;
// void Think();
public:
int command[35];
};
#endif // _INSIDE_VISUAL_CPP_STRATEGYSYSTEM
+31 -31
View File
@@ -1,31 +1,31 @@
// TParseString.h: interface for the TParseString class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TPARSESTRING_H__B6B1C1C4_8CBF_11D1_B242_0000C09B5CBE__INCLUDED_)
#define AFX_TPARSESTRING_H__B6B1C1C4_8CBF_11D1_B242_0000C09B5CBE__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class TParseString : public CString {
public:
TParseString() { m_iPosition = 0; };
TParseString(LPCTSTR name) : CString(name) { m_iPosition = 0; };
BOOL ParseBracket(TParseString &str);
BOOL ParseString(CString &str);
int ParseInteger();
double ParseDouble();
void OverreadLeadingSpaces();
BOOL HasErrorOccured() const { return m_bErrorOccured; };
int GetPosition() const { return m_iPosition; };
void SetPosition(int pos);
private:
int m_iPosition;
BOOL m_bErrorOccured;
};
#endif // !defined(AFX_TPARSESTRING_H__B6B1C1C4_8CBF_11D1_B242_0000C09B5CBE__INCLUDED_)
// TParseString.h: interface for the TParseString class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TPARSESTRING_H__B6B1C1C4_8CBF_11D1_B242_0000C09B5CBE__INCLUDED_)
#define AFX_TPARSESTRING_H__B6B1C1C4_8CBF_11D1_B242_0000C09B5CBE__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class TParseString : public CString {
public:
TParseString() { m_iPosition = 0; };
TParseString(LPCTSTR name) : CString(name) { m_iPosition = 0; };
BOOL ParseBracket(TParseString &str);
BOOL ParseString(CString &str);
int ParseInteger();
double ParseDouble();
void OverreadLeadingSpaces();
BOOL HasErrorOccured() const { return m_bErrorOccured; };
int GetPosition() const { return m_iPosition; };
void SetPosition(int pos);
private:
int m_iPosition;
BOOL m_bErrorOccured;
};
#endif // !defined(AFX_TPARSESTRING_H__B6B1C1C4_8CBF_11D1_B242_0000C09B5CBE__INCLUDED_)
+87 -87
View File
@@ -1,87 +1,87 @@
#include "stdafx.h"
#include "Agentsock.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CAgentSocket, CAsyncSocket)
CAgentSocket::CAgentSocket() {
m_uiPort = 0;
m_sSocketAddress = _T("");
}
void CAgentSocket::OnReceive(int nErrorCode) {
CAsyncSocket::OnReceive(nErrorCode);
}
BOOL CAgentSocket::Create(UINT nSocketPort, LPCTSTR lpszSocketAddress) {
int nSocketType = SOCK_DGRAM;
long lEvent = FD_READ | FD_WRITE | FD_ACCEPT | FD_CONNECT | FD_CLOSE;
// create the socket
if (Socket(nSocketType, lEvent)) {
// try to bind the socket to any address
if (Bind(nSocketPort, lpszSocketAddress))
return TRUE;
// an error occured
int nResult = GetLastError();
Close();
WSASetLastError(nResult);
}
return FALSE;
}
BOOL CAgentSocket::Bind(UINT nSocketPort, LPCTSTR lpszSocketAddress) {
int result;
// bind to INADDR_ANY
memset(&sockAddr, 0, sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
sockAddr.sin_port = htons(0);
result = CAsyncSocket::Bind((SOCKADDR *)&sockAddr, sizeof(sockAddr));
// set the proper values of port and address for the following SendTo commands
memset(&sockAddr, 0, sizeof(sockAddr));
LPSTR lpszAscii = (LPTSTR)lpszSocketAddress;
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = inet_addr(lpszAscii);
if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
// get the address from a nameserver
LPHOSTENT lphost;
lphost = gethostbyname(lpszAscii);
if (lphost != NULL)
sockAddr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
else {
WSASetLastError(WSAEINVAL);
return FALSE;
}
}
sockAddr.sin_port = htons((u_short)nSocketPort);
// return the result of the Bind command
return result;
}
int CAgentSocket::ReceiveFrom(void *lpBuf, int nBufLen, CString &rSocketAddress, UINT &rSocketPort, int nFlags) {
// try to receive data
memset(&sockAddr, 0, sizeof(sockAddr));
int nSockAddrLen = sizeof(sockAddr);
int nResult = CAsyncSocket::ReceiveFrom(lpBuf, nBufLen, (SOCKADDR *)&sockAddr, &nSockAddrLen, nFlags);
if (nResult != SOCKET_ERROR) {
// succesfull
rSocketPort = ntohs(sockAddr.sin_port);
rSocketAddress = inet_ntoa(sockAddr.sin_addr);
}
return nResult;
}
int CAgentSocket::SendTo(const void *lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags) {
// send the buffer
return CAsyncSocket::SendTo(lpBuf, nBufLen, (SOCKADDR *)&sockAddr, sizeof(sockAddr), nFlags);
}
#include "stdafx.h"
#include "Agentsock.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CAgentSocket, CAsyncSocket)
CAgentSocket::CAgentSocket() {
m_uiPort = 0;
m_sSocketAddress = _T("");
}
void CAgentSocket::OnReceive(int nErrorCode) {
CAsyncSocket::OnReceive(nErrorCode);
}
BOOL CAgentSocket::Create(UINT nSocketPort, LPCTSTR lpszSocketAddress) {
int nSocketType = SOCK_DGRAM;
long lEvent = FD_READ | FD_WRITE | FD_ACCEPT | FD_CONNECT | FD_CLOSE;
// create the socket
if (Socket(nSocketType, lEvent)) {
// try to bind the socket to any address
if (Bind(nSocketPort, lpszSocketAddress))
return TRUE;
// an error occured
int nResult = GetLastError();
Close();
WSASetLastError(nResult);
}
return FALSE;
}
BOOL CAgentSocket::Bind(UINT nSocketPort, LPCTSTR lpszSocketAddress) {
int result;
// bind to INADDR_ANY
memset(&sockAddr, 0, sizeof(sockAddr));
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
sockAddr.sin_port = htons(0);
result = CAsyncSocket::Bind((SOCKADDR *)&sockAddr, sizeof(sockAddr));
// set the proper values of port and address for the following SendTo commands
memset(&sockAddr, 0, sizeof(sockAddr));
LPSTR lpszAscii = (LPTSTR)lpszSocketAddress;
sockAddr.sin_family = AF_INET;
sockAddr.sin_addr.s_addr = inet_addr(lpszAscii);
if (sockAddr.sin_addr.s_addr == INADDR_NONE) {
// get the address from a nameserver
LPHOSTENT lphost;
lphost = gethostbyname(lpszAscii);
if (lphost != NULL)
sockAddr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
else {
WSASetLastError(WSAEINVAL);
return FALSE;
}
}
sockAddr.sin_port = htons((u_short)nSocketPort);
// return the result of the Bind command
return result;
}
int CAgentSocket::ReceiveFrom(void *lpBuf, int nBufLen, CString &rSocketAddress, UINT &rSocketPort, int nFlags) {
// try to receive data
memset(&sockAddr, 0, sizeof(sockAddr));
int nSockAddrLen = sizeof(sockAddr);
int nResult = CAsyncSocket::ReceiveFrom(lpBuf, nBufLen, (SOCKADDR *)&sockAddr, &nSockAddrLen, nFlags);
if (nResult != SOCKET_ERROR) {
// succesfull
rSocketPort = ntohs(sockAddr.sin_port);
rSocketAddress = inet_ntoa(sockAddr.sin_addr);
}
return nResult;
}
int CAgentSocket::SendTo(const void *lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress, int nFlags) {
// send the buffer
return CAsyncSocket::SendTo(lpBuf, nBufLen, (SOCKADDR *)&sockAddr, sizeof(sockAddr), nFlags);
}
File diff suppressed because it is too large. Load diff
+44 -44
View File
@@ -1,44 +1,44 @@
// DSetupDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MicroClient.h"
#include "DSetupDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DSetupDlg dialog
DSetupDlg::DSetupDlg(CWnd *pParent /*=NULL*/)
: CDialog(DSetupDlg::IDD, pParent) {
//{{AFX_DATA_INIT(DSetupDlg)
//}}AFX_DATA_INIT
m_TeamName = _T("WTU-ATRI");
m_ServerName = _T("127.0.0.1");
m_Channel = 6000;
}
void DSetupDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DSetupDlg)
//}}AFX_DATA_MAP
// DDX_Text(pDX, IDC_TEAM, m_TeamName);
// DDX_Text(pDX, IDC_SERVER, m_ServerName);
// DDX_Text(pDX, IDC_CHANNEL, m_Channel);
}
BEGIN_MESSAGE_MAP(DSetupDlg, CDialog)
//{{AFX_MSG_MAP(DSetupDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DSetupDlg message handlers
// DSetupDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MicroClient.h"
#include "DSetupDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DSetupDlg dialog
DSetupDlg::DSetupDlg(CWnd *pParent /*=NULL*/)
: CDialog(DSetupDlg::IDD, pParent) {
//{{AFX_DATA_INIT(DSetupDlg)
//}}AFX_DATA_INIT
m_TeamName = _T("WTU-ATRI");
m_ServerName = _T("127.0.0.1");
m_Channel = 6000;
}
void DSetupDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DSetupDlg)
//}}AFX_DATA_MAP
// DDX_Text(pDX, IDC_TEAM, m_TeamName);
// DDX_Text(pDX, IDC_SERVER, m_ServerName);
// DDX_Text(pDX, IDC_CHANNEL, m_Channel);
}
BEGIN_MESSAGE_MAP(DSetupDlg, CDialog)
//{{AFX_MSG_MAP(DSetupDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DSetupDlg message handlers
+96 -96
View File
@@ -1,96 +1,96 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MicroClient.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] = {
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame() {
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame() {
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
/* if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}*/
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT &cs) {
if (!CFrameWnd::PreCreateWindow(cs))
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const {
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext &dc) const {
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MicroClient.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] = {
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame() {
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame() {
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
/* if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}*/
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT &cs) {
if (!CFrameWnd::PreCreateWindow(cs))
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const {
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext &dc) const {
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
+150 -150
View File
@@ -1,150 +1,150 @@
// MicroClient.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "MicroClient.h"
#include "MainFrm.h"
#include "MicroClientDoc.h"
#include "MicroClientView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp
BEGIN_MESSAGE_MAP(CMicroClientApp, CWinApp)
//{{AFX_MSG_MAP(CMicroClientApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp construction
CMicroClientApp::CMicroClientApp() {
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMicroClientApp object
CMicroClientApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp initialization
BOOL CMicroClientApp::InitInstance() {
if (!AfxSocketInit()) {
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate *pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMicroClientDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMicroClientView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->SetWindowText("WTU-ATRI");
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog {
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) {
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CMicroClientApp::OnAppAbout() {
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp message handlers
// MicroClient.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "MicroClient.h"
#include "MainFrm.h"
#include "MicroClientDoc.h"
#include "MicroClientView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp
BEGIN_MESSAGE_MAP(CMicroClientApp, CWinApp)
//{{AFX_MSG_MAP(CMicroClientApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp construction
CMicroClientApp::CMicroClientApp() {
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMicroClientApp object
CMicroClientApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp initialization
BOOL CMicroClientApp::InitInstance() {
if (!AfxSocketInit()) {
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate *pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMicroClientDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CMicroClientView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->SetWindowText("WTU-ATRI");
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog {
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) {
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange *pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CMicroClientApp::OnAppAbout() {
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientApp message handlers
+116 -116
View File
@@ -1,116 +1,116 @@
// MicroClientDoc.cpp : implementation of the CMicroClientDoc class
//
#include "stdafx.h"
#include "MicroClient.h"
#include "BaseAgent.h"
#include "DSetupDlg.h"
#include "MicroClientDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc
IMPLEMENT_DYNCREATE(CMicroClientDoc, CDocument)
BEGIN_MESSAGE_MAP(CMicroClientDoc, CDocument)
//{{AFX_MSG_MAP(CMicroClientDoc)
ON_COMMAND(ID_CONNECT, OnConnect)
ON_UPDATE_COMMAND_UI(ID_CONNECT, OnUpdateConnect)
ON_COMMAND(ID_DISCONNECT, OnDisconnect)
ON_UPDATE_COMMAND_UI(ID_DISCONNECT, OnUpdateDisconnect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc construction/destruction
CMicroClientDoc::CMicroClientDoc() {
// TODO: add one-time construction code here
}
CMicroClientDoc::~CMicroClientDoc() {
if (m_pAgent)
delete m_pAgent;
}
BOOL CMicroClientDoc::OnNewDocument() {
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
m_pAgent = new CBaseAgent(this);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc serialization
void CMicroClientDoc::Serialize(CArchive &ar) {
if (ar.IsStoring()) {
// TODO: add storing code here
}
else {
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc diagnostics
#ifdef _DEBUG
void CMicroClientDoc::AssertValid() const {
CDocument::AssertValid();
}
void CMicroClientDoc::Dump(CDumpContext &dc) const {
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc commands
void CMicroClientDoc::OnConnect() {
// TODO: Add your command handler code here
// m_pAgent->Connect();
DSetupDlg Dialog;
// ask the user for the name of the team and the server
Dialog.m_TeamName = _T("WTU-ATRI");
Dialog.m_ServerName = _T("127.0.0.1");
Dialog.m_Channel = 6000;
// user can repeat with a different address while(TRUE)
{
// try to connect
if (m_pAgent->ConnectAgent(Dialog.m_TeamName, Dialog.m_ServerName, Dialog.m_Channel))
return; // TRUE;
if (Dialog.DoModal() != IDOK)
return; // FALSE;
}
m_pAgent->teamname = Dialog.m_TeamName;
}
void CMicroClientDoc::OnUpdateConnect(CCmdUI *pCmdUI) {
// TODO: Add your command update UI handler code here
// pCmdUI->
}
void CMicroClientDoc::OnDisconnect() {
// TODO: Add your command handler code here
// fclose(fp);
}
void CMicroClientDoc::OnUpdateDisconnect(CCmdUI *pCmdUI) {
// TODO: Add your command update UI handler code here
// pCmdUI->
}
// MicroClientDoc.cpp : implementation of the CMicroClientDoc class
//
#include "stdafx.h"
#include "MicroClient.h"
#include "BaseAgent.h"
#include "DSetupDlg.h"
#include "MicroClientDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc
IMPLEMENT_DYNCREATE(CMicroClientDoc, CDocument)
BEGIN_MESSAGE_MAP(CMicroClientDoc, CDocument)
//{{AFX_MSG_MAP(CMicroClientDoc)
ON_COMMAND(ID_CONNECT, OnConnect)
ON_UPDATE_COMMAND_UI(ID_CONNECT, OnUpdateConnect)
ON_COMMAND(ID_DISCONNECT, OnDisconnect)
ON_UPDATE_COMMAND_UI(ID_DISCONNECT, OnUpdateDisconnect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc construction/destruction
CMicroClientDoc::CMicroClientDoc() {
// TODO: add one-time construction code here
}
CMicroClientDoc::~CMicroClientDoc() {
if (m_pAgent)
delete m_pAgent;
}
BOOL CMicroClientDoc::OnNewDocument() {
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
m_pAgent = new CBaseAgent(this);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc serialization
void CMicroClientDoc::Serialize(CArchive &ar) {
if (ar.IsStoring()) {
// TODO: add storing code here
}
else {
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc diagnostics
#ifdef _DEBUG
void CMicroClientDoc::AssertValid() const {
CDocument::AssertValid();
}
void CMicroClientDoc::Dump(CDumpContext &dc) const {
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMicroClientDoc commands
void CMicroClientDoc::OnConnect() {
// TODO: Add your command handler code here
// m_pAgent->Connect();
DSetupDlg Dialog;
// ask the user for the name of the team and the server
Dialog.m_TeamName = _T("WTU-ATRI");
Dialog.m_ServerName = _T("127.0.0.1");
Dialog.m_Channel = 6000;
// user can repeat with a different address while(TRUE)
{
// try to connect
if (m_pAgent->ConnectAgent(Dialog.m_TeamName, Dialog.m_ServerName, Dialog.m_Channel))
return; // TRUE;
if (Dialog.DoModal() != IDOK)
return; // FALSE;
}
m_pAgent->teamname = Dialog.m_TeamName;
}
void CMicroClientDoc::OnUpdateConnect(CCmdUI *pCmdUI) {
// TODO: Add your command update UI handler code here
// pCmdUI->
}
void CMicroClientDoc::OnDisconnect() {
// TODO: Add your command handler code here
// fclose(fp);
}
void CMicroClientDoc::OnUpdateDisconnect(CCmdUI *pCmdUI) {
// TODO: Add your command update UI handler code here
// pCmdUI->
}
+74 -74
View File
@@ -1,74 +1,74 @@
// MicroClientView.cpp : implementation of the CMicroClientView class
//
#include "stdafx.h"
#include "MicroClient.h"
#include "MicroClientDoc.h"
#include "MicroClientView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView
IMPLEMENT_DYNCREATE(CMicroClientView, CView)
BEGIN_MESSAGE_MAP(CMicroClientView, CView)
//{{AFX_MSG_MAP(CMicroClientView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView construction/destruction
CMicroClientView::CMicroClientView() {
// TODO: add construction code here
}
CMicroClientView::~CMicroClientView() {
}
BOOL CMicroClientView::PreCreateWindow(CREATESTRUCT &cs) {
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView drawing
void CMicroClientView::OnDraw(CDC *pDC) {
CMicroClientDoc *pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView diagnostics
#ifdef _DEBUG
void CMicroClientView::AssertValid() const {
CView::AssertValid();
}
void CMicroClientView::Dump(CDumpContext &dc) const {
CView::Dump(dc);
}
CMicroClientDoc *CMicroClientView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMicroClientDoc)));
return (CMicroClientDoc *)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView message handlers
// MicroClientView.cpp : implementation of the CMicroClientView class
//
#include "stdafx.h"
#include "MicroClient.h"
#include "MicroClientDoc.h"
#include "MicroClientView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView
IMPLEMENT_DYNCREATE(CMicroClientView, CView)
BEGIN_MESSAGE_MAP(CMicroClientView, CView)
//{{AFX_MSG_MAP(CMicroClientView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView construction/destruction
CMicroClientView::CMicroClientView() {
// TODO: add construction code here
}
CMicroClientView::~CMicroClientView() {
}
BOOL CMicroClientView::PreCreateWindow(CREATESTRUCT &cs) {
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView drawing
void CMicroClientView::OnDraw(CDC *pDC) {
CMicroClientDoc *pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView diagnostics
#ifdef _DEBUG
void CMicroClientView::AssertValid() const {
CView::AssertValid();
}
void CMicroClientView::Dump(CDumpContext &dc) const {
CView::Dump(dc);
}
CMicroClientDoc *CMicroClientView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMicroClientDoc)));
return (CMicroClientDoc *)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMicroClientView message handlers
+16 -16
View File
@@ -1,17 +1,17 @@
// stdafx.cpp : source file that includes just the standard includes
// MicroClient.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include "StrategySystem.h"
// 把接收到的队员的坐标和角度放入r[0][i]里面,对方队员的坐标
// 放入op里面
// 取每个队员的轮速,在Velocity函数计算里面已经获得了三
// 个队员的轮速
int nKick;
CStrategySystem *thePlannerR = new CStrategySystem(0);
CStrategySystem *thePlannerL = new CStrategySystem(1);
Robot2 r[2][11];
Robot3 op; // 存放对方队员的坐标数据
// stdafx.cpp : source file that includes just the standard includes
// MicroClient.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include "StrategySystem.h"
// 把接收到的队员的坐标和角度放入r[0][i]里面,对方队员的坐标
// 放入op里面
// 取每个队员的轮速,在Velocity函数计算里面已经获得了三
// 个队员的轮速
int nKick;
CStrategySystem *thePlannerR = new CStrategySystem(0);
CStrategySystem *thePlannerL = new CStrategySystem(1);
Robot2 r[2][11];
Robot3 op; // 存放对方队员的坐标数据
Robot1 theball; // 存放球的坐标数据.
File diff suppressed because it is too large. Load diff
+242 -242
View File
@@ -1,242 +1,242 @@
// TParseString.cpp: implementation of the TParseString class.
//
//////////////////////////////////////////////////////////////////////
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include "stdafx.h"
#include "TParseString.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
BOOL TParseString::ParseBracket(TParseString &retString) {
int iNoOfOpenBrackets = 1;
int iRightPosition = m_iPosition + 1;
int iLen = GetLength();
m_bErrorOccured = FALSE;
// iposition must index an opening bracket
if ((m_iPosition >= iLen) || GetAt(m_iPosition) != '(')
return FALSE;
while (iNoOfOpenBrackets > 0) {
// reached the end of the string ? error
if (iRightPosition >= iLen)
return FALSE;
// look at the next character
switch (GetAt(iRightPosition)) {
case '(':
iNoOfOpenBrackets++;
break;
case ')':
iNoOfOpenBrackets--;
break;
}
iRightPosition++;
}
retString.CString::operator=(Mid(m_iPosition + 1, iRightPosition - m_iPosition - 2));
m_iPosition = iRightPosition + 1;
return TRUE;
}
BOOL TParseString::ParseString(CString &str) {
int iRightPos;
BOOL bReady = FALSE;
int len = GetLength();
char tmp;
m_bErrorOccured = FALSE;
OverreadLeadingSpaces();
iRightPos = m_iPosition + 1;
// check, if there is a string
if (m_iPosition - 1 >= len) {
// the expected string is not there
m_iPosition++;
return FALSE;
}
// search for a ' ' or ')'
bReady = FALSE;
while (!bReady && (iRightPos < len)) {
tmp = GetAt(iRightPos);
switch (tmp) {
case ' ':
case ')':
case '\r':
case '\n':
bReady = TRUE;
break;
default:
iRightPos++;
}
}
// get the string
str = Mid(m_iPosition, iRightPos - m_iPosition);
m_iPosition = iRightPos + 1;
return TRUE;
}
int TParseString::ParseInteger() {
int iValue = 0;
BOOL bSign = FALSE;
BOOL bReady = FALSE;
char cChar;
int len = GetLength();
m_bErrorOccured = TRUE;
OverreadLeadingSpaces();
// read in the number
while (!bReady && (m_iPosition < len)) {
cChar = GetAt(m_iPosition);
switch (cChar) {
case '-':
// only one - sign expected
bSign = TRUE;
m_iPosition++;
break;
case '+':
m_iPosition++;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
iValue = 10 * iValue + cChar - '0';
m_bErrorOccured = FALSE;
m_iPosition++;
break;
case ')':
case ' ':
m_iPosition++;
// no break here
default:
bReady = TRUE;
}
}
// convert the number if neccessary
if (bSign)
iValue = -iValue;
return iValue;
}
double TParseString::ParseDouble() {
double dValue = 0.0;
double dNumber;
BOOL bSign = FALSE;
BOOL bReady = FALSE;
BOOL bDot = FALSE;
double dDivisor = 1.0;
char cChar;
int len = GetLength();
m_bErrorOccured = TRUE;
// read in the number
while (!bReady && (m_iPosition < len)) {
cChar = GetAt(m_iPosition);
switch (cChar) {
case '-':
// only one - sign expected
bSign = TRUE;
m_iPosition++;
break;
case '+':
m_iPosition++;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
dValue = 10.0 * dValue + (double)(cChar - '0');
dDivisor *= 10.0;
m_bErrorOccured = FALSE;
m_iPosition++;
break;
case '.':
case ',':
dDivisor = 1.0;
bDot = TRUE;
m_iPosition++;
break;
case ')':
case ' ':
m_iPosition++;
// no break here
default:
bReady = TRUE;
}
}
// convert the number if neccessary
if (bDot)
dNumber = dValue / dDivisor;
else
dNumber = dValue;
if (bSign)
dNumber = -dNumber;
return dNumber;
}
void TParseString::OverreadLeadingSpaces() {
char tmp;
// overread inital spaces, returns and new lines
while (m_iPosition < GetLength()) {
tmp = GetAt(m_iPosition);
switch (tmp) {
case ' ':
case '\r':
case '\n':
m_iPosition++;
break;
default:
return;
}
}
}
void TParseString::SetPosition(int pos) {
if (pos >= GetLength()) {
m_iPosition = GetLength() - 1;
if (m_iPosition < 0)
m_iPosition = 0;
}
else if (pos < 0)
m_iPosition = 0;
else
m_iPosition = pos;
}
// TParseString.cpp: implementation of the TParseString class.
//
//////////////////////////////////////////////////////////////////////
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include "stdafx.h"
#include "TParseString.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
BOOL TParseString::ParseBracket(TParseString &retString) {
int iNoOfOpenBrackets = 1;
int iRightPosition = m_iPosition + 1;
int iLen = GetLength();
m_bErrorOccured = FALSE;
// iposition must index an opening bracket
if ((m_iPosition >= iLen) || GetAt(m_iPosition) != '(')
return FALSE;
while (iNoOfOpenBrackets > 0) {
// reached the end of the string ? error
if (iRightPosition >= iLen)
return FALSE;
// look at the next character
switch (GetAt(iRightPosition)) {
case '(':
iNoOfOpenBrackets++;
break;
case ')':
iNoOfOpenBrackets--;
break;
}
iRightPosition++;
}
retString.CString::operator=(Mid(m_iPosition + 1, iRightPosition - m_iPosition - 2));
m_iPosition = iRightPosition + 1;
return TRUE;
}
BOOL TParseString::ParseString(CString &str) {
int iRightPos;
BOOL bReady = FALSE;
int len = GetLength();
char tmp;
m_bErrorOccured = FALSE;
OverreadLeadingSpaces();
iRightPos = m_iPosition + 1;
// check, if there is a string
if (m_iPosition - 1 >= len) {
// the expected string is not there
m_iPosition++;
return FALSE;
}
// search for a ' ' or ')'
bReady = FALSE;
while (!bReady && (iRightPos < len)) {
tmp = GetAt(iRightPos);
switch (tmp) {
case ' ':
case ')':
case '\r':
case '\n':
bReady = TRUE;
break;
default:
iRightPos++;
}
}
// get the string
str = Mid(m_iPosition, iRightPos - m_iPosition);
m_iPosition = iRightPos + 1;
return TRUE;
}
int TParseString::ParseInteger() {
int iValue = 0;
BOOL bSign = FALSE;
BOOL bReady = FALSE;
char cChar;
int len = GetLength();
m_bErrorOccured = TRUE;
OverreadLeadingSpaces();
// read in the number
while (!bReady && (m_iPosition < len)) {
cChar = GetAt(m_iPosition);
switch (cChar) {
case '-':
// only one - sign expected
bSign = TRUE;
m_iPosition++;
break;
case '+':
m_iPosition++;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
iValue = 10 * iValue + cChar - '0';
m_bErrorOccured = FALSE;
m_iPosition++;
break;
case ')':
case ' ':
m_iPosition++;
// no break here
default:
bReady = TRUE;
}
}
// convert the number if neccessary
if (bSign)
iValue = -iValue;
return iValue;
}
double TParseString::ParseDouble() {
double dValue = 0.0;
double dNumber;
BOOL bSign = FALSE;
BOOL bReady = FALSE;
BOOL bDot = FALSE;
double dDivisor = 1.0;
char cChar;
int len = GetLength();
m_bErrorOccured = TRUE;
// read in the number
while (!bReady && (m_iPosition < len)) {
cChar = GetAt(m_iPosition);
switch (cChar) {
case '-':
// only one - sign expected
bSign = TRUE;
m_iPosition++;
break;
case '+':
m_iPosition++;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
dValue = 10.0 * dValue + (double)(cChar - '0');
dDivisor *= 10.0;
m_bErrorOccured = FALSE;
m_iPosition++;
break;
case '.':
case ',':
dDivisor = 1.0;
bDot = TRUE;
m_iPosition++;
break;
case ')':
case ' ':
m_iPosition++;
// no break here
default:
bReady = TRUE;
}
}
// convert the number if neccessary
if (bDot)
dNumber = dValue / dDivisor;
else
dNumber = dValue;
if (bSign)
dNumber = -dNumber;
return dNumber;
}
void TParseString::OverreadLeadingSpaces() {
char tmp;
// overread inital spaces, returns and new lines
while (m_iPosition < GetLength()) {
tmp = GetAt(m_iPosition);
switch (tmp) {
case ' ':
case '\r':
case '\n':
m_iPosition++;
break;
default:
return;
}
}
}
void TParseString::SetPosition(int pos) {
if (pos >= GetLength()) {
m_iPosition = GetLength() - 1;
if (m_iPosition < 0)
m_iPosition = 0;
}
else if (pos < 0)
m_iPosition = 0;
else
m_iPosition = pos;
}