Initial commit.

This commit is contained in:
Jim Gray
2013-04-04 14:32:05 -07:00
parent ba5c81da32
commit d71d53e8ec
2180 changed files with 1393544 additions and 1 deletions

View File

View File

202
tools/jawa/jawa.cpp Normal file
View File

@@ -0,0 +1,202 @@
// jawa.cpp : Defines the entry point for the application.
#include "stdafx.h"
#ifndef _DEBUG
#error Jawa should only be used in debug mode!
#endif
// Our (many) game sessions
#define MAX_SESSIONS 10
CSession sessions[MAX_SESSIONS];
// Handle the logon task
XONLINETASK_HANDLE g_hLogonTask;
//-----------------------------------------------------------------------------
// Name: Print()
//-----------------------------------------------------------------------------
VOID __cdecl Print( const WCHAR* strFormat, ... )
{
const int MAX_OUTPUT_STR = 80;
WCHAR strBuffer[ MAX_OUTPUT_STR ];
va_list pArglist;
va_start( pArglist, strFormat );
INT iChars = wvsprintfW( strBuffer, strFormat, pArglist );
assert( iChars < MAX_OUTPUT_STR );
OutputDebugStringW( L"\n*** SimpleAuth: " );
OutputDebugStringW( strBuffer );
OutputDebugStringW( L"\n\n" );
(VOID)iChars; // avoid compiler warning
va_end( pArglist );
}
//-----------------------------------------------------------------------------
// Name: SignIn()
//-----------------------------------------------------------------------------
BOOL SignIn()
{
XONLINE_USER StoredUsers[ XONLINE_MAX_STORED_ONLINE_USERS ];
DWORD dwNumStoredUsers;
HRESULT hr = XOnlineGetUsers( StoredUsers, &dwNumStoredUsers );
assert( SUCCEEDED( hr ) );
assert( dwNumStoredUsers );
XONLINE_USER LogonUsers[ XONLINE_MAX_LOGON_USERS ] = { 0 }; // Initially zeroed
LogonUsers[0] = StoredUsers[0];
const DWORD Services[] = { XONLINE_MATCHMAKING_SERVICE };
const DWORD dwNumServices = sizeof( Services ) / sizeof( Services[0] );
hr = XOnlineLogon( LogonUsers, Services, dwNumServices, NULL, &g_hLogonTask );
assert( hr == S_OK );
// 1. Check for system authentication errors.
do { hr = XOnlineTaskContinue( g_hLogonTask ); } while ( hr == XONLINETASK_S_RUNNING );
assert( hr == XONLINE_S_LOGON_CONNECTION_ESTABLISHED );
// 2. Check for user authentication errors.
PXONLINE_USER Users = XOnlineGetLogonUsers();
assert( Users );
for( DWORD i = 0; i < XONLINE_MAX_LOGON_USERS; ++i )
{
if( Users[i].xuid.qwUserID != 0 ) // A valid user
assert( Users[i].hr == S_OK || Users[i].hr == XONLINE_S_LOGON_USER_HAS_MESSAGE );
}
// 3. Finally check the requested services
for( DWORD i = 0; i < dwNumServices; ++i )
{
hr = XOnlineGetServiceInfo( Services[i], NULL );
assert( hr == S_OK );
}
return TRUE;
}
//-----------------------------------------------------------------------------
// Name: main()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
void __cdecl main()
{
XInitDevices( 0, NULL );
while ( XGetDeviceEnumerationStatus() == XDEVICE_ENUMERATION_BUSY ) {}
// We need MANY keys registered!
XNetStartupParams xnsp;
ZeroMemory( &xnsp, sizeof(xnsp) );
xnsp.cfgSizeOfStruct = sizeof(xnsp);
xnsp.cfgKeyRegMax = 255; // 4
xnsp.cfgSecRegMax = 255; // 32
XNetStartup( &xnsp );
HRESULT hr = XOnlineStartup( NULL );
assert( SUCCEEDED( hr ) );
// Need to log in first.
if( !SignIn() )
return;
char sessionName[16] = { 0 };
{
// Always generate worst case display
CSession *sess = &sessions[0];
sess->PrivateFilled = 0;
sess->PrivateOpen = 0;
sess->PublicFilled = 5;
sess->PublicOpen = 3;
sess->TotalPlayers = 5;
sess->GameType = 4; // PowerDuel
sess->CurrentMap = 8; // Imperial Control Room
strcpy( sessionName, "WWWWWWWWWWWWWWQ" );
WCHAR wSessionName[16];
wsprintfW( wSessionName, L"%hs", sessionName );
sess->SetSessionName( wSessionName );
sess->FriendlyFire = 0;
sess->SaberOnly = 0;
sess->JediMastery = 0;
sess->Dedicated = 0;
HRESULT hr = sess->Create();
if (hr != S_OK)
{
OutputDebugString( "Session creation failed" );
}
do
{
hr = XOnlineTaskContinue( g_hLogonTask );
if ( FAILED( hr ) )
{
OutputDebugString( "Logon task failed" );
}
hr = sess->Process();
} while ( sess->IsCreating() );
}
for( int i = 1; i < MAX_SESSIONS; ++i )
{
CSession *sess = &sessions[i];
int totalSlots = (rand() % 5) + 4; // 4 - 8
int publicSlots = (rand() % totalSlots); // 0 - (total-1)
int privateSlots = totalSlots - publicSlots; // 1 - total
int privateTaken = (rand() % privateSlots) + 1; // 1 - private
int publicTaken = (rand() % (publicSlots+1)); // 0 - public
sess->PrivateFilled = 1; //privateTaken;
sess->PrivateOpen = 2; //privateSlots - privateTaken;
sess->PublicFilled = 3; //publicTaken;
sess->PublicOpen = 4; //publicSlots - publicTaken;
sess->TotalPlayers = 4; //privateTaken + publicTaken;
sess->GameType = rand() % 10;
sess->CurrentMap = rand() % 23;
XNetRandom( (BYTE *)&sessionName[0], 10 );
for( int j = 0; j < 10; ++j )
sessionName[j] = (((unsigned char)sessionName[j]) % 26) + 'A';
WCHAR wSessionName[11];
wsprintfW( wSessionName, L"%hs", sessionName );
wSessionName[10] = 0;
sess->SetSessionName( wSessionName );
sess->FriendlyFire = rand() % 2;
sess->SaberOnly = rand() % 2;
sess->JediMastery = rand() % 7;
sess->Dedicated = rand() % 2;
HRESULT hr = sess->Create();
if (hr != S_OK)
{
OutputDebugString( "Session creation failed" );
}
do
{
hr = XOnlineTaskContinue( g_hLogonTask );
if ( FAILED( hr ) )
{
OutputDebugString( "Logon task failed" );
}
hr = sess->Process();
} while ( sess->IsCreating() );
}
while( TRUE )
{
// Service things
hr = XOnlineTaskContinue( g_hLogonTask );
assert( SUCCEEDED( hr ) );
for( int j = 0; j < MAX_SESSIONS; ++j )
{
hr = sessions[j].Process();
assert( SUCCEEDED( hr ) );
}
}
}

30
tools/jawa/jawa.sln Normal file
View File

@@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jawa", "jawa.vcproj", "{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Profile = Profile
Profile_FastCap = Profile_FastCap
Release = Release
Release_LTCG = Release_LTCG
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Debug.ActiveCfg = Debug|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Debug.Build.0 = Debug|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile.ActiveCfg = Profile|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile.Build.0 = Profile|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release.ActiveCfg = Release|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release.Build.0 = Release|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release_LTCG.Build.0 = Release_LTCG|Xbox
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

30
tools/jawa/jawa.sln.old Normal file
View File

@@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jawa", "jawa.vcproj", "{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Profile
ConfigName.2 = Profile_FastCap
ConfigName.3 = Release
ConfigName.4 = Release_LTCG
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Debug.ActiveCfg = Debug|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Debug.Build.0 = Debug|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile.ActiveCfg = Profile|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile.Build.0 = Profile|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release.ActiveCfg = Release|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release.Build.0 = Release|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox
{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}.Release_LTCG.Build.0 = Release_LTCG|Xbox
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

BIN
tools/jawa/jawa.suo Normal file

Binary file not shown.

290
tools/jawa/jawa.vcproj Normal file
View File

@@ -0,0 +1,290 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="jawa"
ProjectGUID="{506050AA-D8F3-4B9B-9E2D-5F9E3C2CFC60}"
Keyword="XboxProj">
<Platforms>
<Platform
Name="Xbox"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Xbox"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
OptimizeForProcessor="2"
PreprocessorDefinitions="_DEBUG;_XBOX"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="$(OutDir)/$(ProjectName).pch"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="xapilibd.lib d3d8d.lib d3dx8d.lib xgraphicsd.lib dsoundd.lib dmusicd.lib xactengd.lib xsndtrkd.lib xvoiced.lib xonline.lib xboxkrnl.lib xbdm.lib"
OutputFile="$(OutDir)/$(ProjectName).exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
SubSystem="2"
OptimizeForWindows98="1"
TargetMachine="1"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"
StackSize="65536"
IncludeDebugInfo="TRUE"
NoLibWarn="TRUE"
TitleID="0x4c41000b"/>
</Configuration>
<Configuration
Name="Profile|Xbox"
OutputDirectory="Profile"
IntermediateDirectory="Profile"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
OmitFramePointers="TRUE"
OptimizeForProcessor="2"
PreprocessorDefinitions="NDEBUG;_XBOX;PROFILE"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="$(OutDir)/$(ProjectName).pch"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="xapilib.lib d3d8i.lib d3dx8.lib xgraphics.lib dsound.lib dmusici.lib xactengi.lib xsndtrk.lib xvoice.lib xonlines.lib xboxkrnl.lib xbdm.lib xperf.lib"
OutputFile="$(OutDir)/$(ProjectName).exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
SetChecksum="TRUE"
TargetMachine="1"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"
StackSize="65536"
IncludeDebugInfo="TRUE"
NoLibWarn="TRUE"/>
</Configuration>
<Configuration
Name="Profile_FastCap|Xbox"
OutputDirectory="Profile_FastCap"
IntermediateDirectory="Profile_FastCap"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
OmitFramePointers="TRUE"
OptimizeForProcessor="2"
PreprocessorDefinitions="NDEBUG;_XBOX;PROFILE;FASTCAP"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="$(OutDir)/$(ProjectName).pch"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"
FastCAP="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="xapilib.lib d3d8i.lib d3dx8.lib xgraphics.lib dsound.lib dmusici.lib xactengi.lib xsndtrk.lib xvoice.lib xonlines.lib xboxkrnl.lib xbdm.lib xperf.lib"
OutputFile="$(OutDir)/$(ProjectName).exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
SetChecksum="TRUE"
TargetMachine="1"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"
StackSize="65536"
IncludeDebugInfo="TRUE"
NoLibWarn="TRUE"/>
</Configuration>
<Configuration
Name="Release|Xbox"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
OmitFramePointers="TRUE"
OptimizeForProcessor="2"
PreprocessorDefinitions="NDEBUG;_XBOX"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="$(OutDir)/$(ProjectName).pch"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="xapilib.lib d3d8.lib d3dx8.lib xgraphics.lib dsound.lib dmusic.lib xacteng.lib xsndtrk.lib xvoice.lib xonlines.lib xboxkrnl.lib"
OutputFile="$(OutDir)/$(ProjectName).exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
SetChecksum="TRUE"
TargetMachine="1"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"
StackSize="65536"
TitleID="0x4c41000b"/>
</Configuration>
<Configuration
Name="Release_LTCG|Xbox"
OutputDirectory="Release_LTCG"
IntermediateDirectory="Release_LTCG"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
OmitFramePointers="TRUE"
OptimizeForProcessor="2"
PreprocessorDefinitions="NDEBUG;_XBOX;LTCG"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
EnableEnhancedInstructionSet="1"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="$(OutDir)/$(ProjectName).pch"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="xapilib.lib d3d8ltcg.lib d3dx8.lib xgraphicsltcg.lib dsound.lib dmusicltcg.lib xactengltcg.lib xsndtrk.lib xvoice.lib xonlines.lib xboxkrnl.lib"
OutputFile="$(OutDir)/$(ProjectName).exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
SetChecksum="TRUE"
TargetMachine="1"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"
StackSize="65536"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="jawa.cpp">
</File>
<File
RelativePath="match.cpp">
</File>
<File
RelativePath="stdafx.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="match.h">
</File>
<File
RelativePath="stdafx.h">
</File>
</Filter>
<File
RelativePath="ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

1469
tools/jawa/match.cpp Normal file

File diff suppressed because it is too large Load Diff

439
tools/jawa/match.h Normal file
View File

@@ -0,0 +1,439 @@
//-----------------------------------------------------------------------------
//
// Xbox Matchmaking Definitions for Title: Jedi Academy [0x4C41000B]
// Generated by MatchSim
//
//-----------------------------------------------------------------------------
#pragma once
#include <xtl.h>
#include <xonline.h>
#include <assert.h>
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
//
// Attribute IDs ID num Data Type
// ------ ----------------------------
const DWORD XATTRIB_GAME_TYPE = 0x0001 | X_ATTRIBUTE_DATATYPE_INTEGER;
const DWORD XATTRIB_CURRENT_MAP = 0x0002 | X_ATTRIBUTE_DATATYPE_INTEGER;
const DWORD XATTRIB_SESSION_NAME = 0x0003 | X_ATTRIBUTE_DATATYPE_STRING;
const DWORD XATTRIB_FRIENDLY_FIRE = 0x0004 | X_ATTRIBUTE_DATATYPE_INTEGER;
const DWORD XATTRIB_JEDI_MASTERY = 0x0005 | X_ATTRIBUTE_DATATYPE_INTEGER;
const DWORD XATTRIB_TOTAL_PLAYERS = 0x0007 | X_ATTRIBUTE_DATATYPE_INTEGER;
const DWORD XATTRIB_SABER_ONLY = 0x0008 | X_ATTRIBUTE_DATATYPE_INTEGER;
const DWORD XATTRIB_DEDICATED = 0x0009 | X_ATTRIBUTE_DATATYPE_INTEGER;
//
// Attribute Maximum Lengths
// (for strings, this doesn't include the terminating NULL)
//
const DWORD XATTRIB_SESSION_NAME_MAX_LEN = 16; // SessionName attribute
// Specify X_MATCH_NULL_INTEGER for optional integer query arguments
const ULONGLONG X_MATCH_NULL_INTEGER = 0x7FFFFFFFFFFFFFFFui64;
// Maximum number of sessions returned by OptiMatch query
const DWORD MAX_OPTI_MATCH_RESULTS = 25;
// Maximum number of sessions returned by JoinSessionByID query
const DWORD MAX_JOIN_SESSION_BY_ID_RESULTS = 1;
// Number of QoS probes
const DWORD NUM_QOS_PROBES = 8;
// Maximum bandwidth to consume for QoS probes
const DWORD QOS_BITS_PER_SEC = 16000;
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Helper class for getting/setting blob attributes
class CBlob
{
public:
CBlob() : m_wLength( 0 ), m_pvData( NULL ) {}
CBlob( WORD wLength, const PVOID pvData ) : m_wLength( wLength), m_pvData( pvData) {}
CBlob( const CBlob & b ) { *this = b; }
CBlob & operator=( const CBlob & b )
{ m_wLength = b.Length; m_pvData = b.Data; return *this; }
BOOL operator==( const CBlob & b ) const
{ return m_wLength == b.Length && memcmp( m_pvData, b.Data, b.Length ) == 0; }
BOOL IsNull() { return m_pvData == NULL; }
__declspec( property( put = SetData, get=GetData ) ) const PVOID Data;
const PVOID GetData() const { return m_pvData; }
VOID SetData( const PVOID pvData ) { m_pvData = pvData; }
__declspec( property( put = SetLength, get=GetLength ) ) WORD Length;
WORD GetLength() const { return m_wLength; }
VOID SetLength( WORD wLength ) { m_wLength = wLength; }
private:
WORD m_wLength;
PVOID m_pvData;
};
// A null blob is defined as having a NULL pointer
#define NULL_BLOB CBlob( 0, NULL )
// Macro for declaring "blob literals" (much like the _T() macro does for strings)
#define B( length, ptr ) CBlob( length, (const PVOID) ptr )
class CSession
{
public:
CSession();
~CSession();
HRESULT Create();
HRESULT Update();
HRESULT Delete();
HRESULT Process();
VOID Reset();
DWORD PublicFilled;
DWORD PublicOpen;
DWORD PrivateFilled;
DWORD PrivateOpen;
XNKEY KeyExchangeKey;
XNKID SessionID;
BOOL IsUpdating() const { return m_State == STATE_UPDATING; }
BOOL IsDeleting() const { return m_State == STATE_DELETING; }
BOOL IsCreating() const { return m_State == STATE_CREATING; }
BOOL Exists() const { return m_State == STATE_ACTIVE || IsUpdating(); }
// Attribute Accessors
BOOL IsListening() const { return m_bListening; }
__declspec( property( put = SetQosResponse, get = GetQosResponse ) ) CBlob QosResponse;
CBlob GetQosResponse();
VOID SetQosResponse( CBlob Value );
VOID Listen( BOOL bEnable = TRUE, DWORD dwBitsPerSec = 0 );
static const DWORD NO_WAIT = 1;
__declspec( property( put = SetGameType, get=GetGameType ) ) ULONGLONG GameType;
ULONGLONG GetGameType();
VOID SetGameType( ULONGLONG Value );
__declspec( property( put = SetCurrentMap, get=GetCurrentMap ) ) ULONGLONG CurrentMap;
ULONGLONG GetCurrentMap();
VOID SetCurrentMap( ULONGLONG Value );
__declspec( property( put = SetSessionName, get=GetSessionName ) ) const WCHAR * SessionName;
const WCHAR * GetSessionName();
VOID SetSessionName( const WCHAR * Value );
__declspec( property( put = SetFriendlyFire, get=GetFriendlyFire ) ) ULONGLONG FriendlyFire;
ULONGLONG GetFriendlyFire();
VOID SetFriendlyFire( ULONGLONG Value );
__declspec( property( put = SetJediMastery, get=GetJediMastery ) ) ULONGLONG JediMastery;
ULONGLONG GetJediMastery();
VOID SetJediMastery( ULONGLONG Value );
__declspec( property( put = SetTotalPlayers, get=GetTotalPlayers ) ) ULONGLONG TotalPlayers;
ULONGLONG GetTotalPlayers();
VOID SetTotalPlayers( ULONGLONG Value );
__declspec( property( put = SetSaberOnly, get=GetSaberOnly ) ) ULONGLONG SaberOnly;
ULONGLONG GetSaberOnly();
VOID SetSaberOnly( ULONGLONG Value );
__declspec( property( put = SetDedicated, get=GetDedicated ) ) ULONGLONG Dedicated;
ULONGLONG GetDedicated();
VOID SetDedicated( ULONGLONG Value );
private:
// The m_Attributes array is accessed using predefined constants:
enum
{
GAME_TYPE_INDEX,
CURRENT_MAP_INDEX,
SESSION_NAME_INDEX,
FRIENDLY_FIRE_INDEX,
JEDI_MASTERY_INDEX,
TOTAL_PLAYERS_INDEX,
SABER_ONLY_INDEX,
DEDICATED_INDEX,
NUM_ATTRIBUTES
};
XONLINE_ATTRIBUTE m_Attributes[NUM_ATTRIBUTES];
// Storage for the SessionName string attribute
WCHAR m_strSessionName[XATTRIB_SESSION_NAME_MAX_LEN+1];
// Qos listening
struct QosQEntry
{
XNKID SessionID; // Session to unregister
DWORD dwStartTick; // Time entry was added
struct QosQEntry *pNext; // Next item in the queue
};
class CSessionQosQ
{
public:
CSessionQosQ();
VOID Add( XNKID & SessionID, DWORD dwStartTick );
VOID Remove( XNKID &SessionID );
VOID Dequeue();
const QosQEntry *Head() const { return m_pHead; }
const QosQEntry *Tail() const { return m_pTail; }
private:
QosQEntry *m_pHead;
QosQEntry *m_pTail;
};
CSessionQosQ m_SessionQosQ;
BOOL m_bListening; // Listening for Qos probes
CBlob m_QosResponse;
VOID PurgeSessionQ( BOOL fRemoveAll = FALSE );
VOID PurgeSessionQHead();
HRESULT ProcessStateCreateSession();
HRESULT ProcessStateUpdateSession();
HRESULT ProcessStateDeleteSession();
HRESULT ProcessStateActiveSession();
VOID Close();
VOID SetupAttributes();
XONLINETASK_HANDLE m_hSessionTask;
enum STATE
{
STATE_IDLE,
STATE_CREATING,
STATE_UPDATING,
STATE_DELETING,
STATE_ACTIVE
};
STATE m_State;
BOOL m_bKeyRegistered;
BOOL m_bUpdate;
};
//
// COptiMatchResult represents a single return result from the
// OptiMatch query
//
#pragma pack(push, 1)
class COptiMatchResult
{
public:
// The query return attributes must come first, and in the order
// returned by the query
ULONGLONG GameType;
ULONGLONG CurrentMap;
WCHAR SessionName[XATTRIB_SESSION_NAME_MAX_LEN+1];
ULONGLONG FriendlyFire;
ULONGLONG JediMastery;
ULONGLONG SaberOnly;
ULONGLONG Dedicated;
XNKID SessionID;
XNKEY KeyExchangeKey;
XNADDR HostAddress;
DWORD PublicOpen;
DWORD PrivateOpen;
DWORD PublicFilled;
DWORD PrivateFilled;
XNQOSINFO* pQosInfo;
};
#pragma pack(pop)
// Collection of results for the OptiMatch query
class COptiMatchQueryResults
{
public:
COptiMatchQueryResults() { m_dwSize = 0; }
DWORD Size() { return m_dwSize; }
COptiMatchResult &operator[]( DWORD i ) { return v[i]; }
private:
void Clear() { m_dwSize = 0; }
void Remove( DWORD i )
{
assert( i < m_dwSize );
if( i < m_dwSize )
{
m_dwSize--;
memcpy( &v[i], &v[i+1], sizeof( v[0] ) * ( m_dwSize - i ) );
}
}
void SetSize( DWORD dwSize ) { m_dwSize = dwSize; }
friend class COptiMatchQuery;
COptiMatchResult v[MAX_OPTI_MATCH_RESULTS];
DWORD m_dwSize;
};
//
// Query object for OptiMatch query (id 0x1)
//
class COptiMatchQuery
{
public:
COptiMatchQuery();
~COptiMatchQuery();
COptiMatchQueryResults Results;
HRESULT Process();
void Cancel();
void Clear();
BOOL Done() const { return m_State == STATE_DONE; }
BOOL Succeeded() const { return SUCCEEDED( m_hrQuery ); }
HRESULT Query(
ULONGLONG GameType, // Optional: X_MATCH_NULL_INTEGER to omit
ULONGLONG CurrentMap, // Optional: X_MATCH_NULL_INTEGER to omit
ULONGLONG MinimumPlayers,
ULONGLONG MaximumPlayers,
ULONGLONG FriendlyFire, // Optional: X_MATCH_NULL_INTEGER to omit
ULONGLONG JediMastery, // Optional: X_MATCH_NULL_INTEGER to omit
ULONGLONG SaberOnly, // Optional: X_MATCH_NULL_INTEGER to omit
ULONGLONG Dedicated // Optional: X_MATCH_NULL_INTEGER to omit
);
BOOL IsRunning() const { return m_State == STATE_RUNNING || m_State == STATE_PROBING_CONNECTIVITY; }
BOOL IsProbing() const { return m_State == STATE_PROBING_BANDWIDTH; }
HRESULT Probe();
private:
// Quality of Service
const XNADDR *m_rgpXnAddr[ MAX_OPTI_MATCH_RESULTS ];
const XNKID *m_rgpXnKid [ MAX_OPTI_MATCH_RESULTS ];
const XNKEY *m_rgpXnKey [ MAX_OPTI_MATCH_RESULTS ];
XNQOS *m_pXnQos;
enum STATE
{
STATE_IDLE,
STATE_RUNNING,
STATE_PROBING_CONNECTIVITY,
STATE_PROBING_BANDWIDTH,
STATE_DONE
};
STATE m_State;
HRESULT m_hrQuery;
XONLINETASK_HANDLE m_hSearchTask;
};
//
// CJoinSessionByIDResult represents a single return result from the
// JoinSessionByID query
//
#pragma pack(push, 1)
class CJoinSessionByIDResult
{
public:
XNKID SessionID;
XNKEY KeyExchangeKey;
XNADDR HostAddress;
DWORD PublicOpen;
DWORD PrivateOpen;
DWORD PublicFilled;
DWORD PrivateFilled;
XNQOSINFO* pQosInfo;
};
#pragma pack(pop)
// Collection of results for the JoinSessionByID query
class CJoinSessionByIDQueryResults
{
public:
CJoinSessionByIDQueryResults() { m_dwSize = 0; }
DWORD Size() { return m_dwSize; }
CJoinSessionByIDResult &operator[]( DWORD i ) { return v[i]; }
private:
void Clear() { m_dwSize = 0; }
void Remove( DWORD i )
{
assert( i < m_dwSize );
if( i < m_dwSize )
{
m_dwSize--;
memcpy( &v[i], &v[i+1], sizeof( v[0] ) * ( m_dwSize - i ) );
}
}
void SetSize( DWORD dwSize ) { m_dwSize = dwSize; }
friend class CJoinSessionByIDQuery;
CJoinSessionByIDResult v[MAX_JOIN_SESSION_BY_ID_RESULTS];
DWORD m_dwSize;
};
//
// Query object for JoinSessionByID query (id 0x2)
//
class CJoinSessionByIDQuery
{
public:
CJoinSessionByIDQuery();
~CJoinSessionByIDQuery();
CJoinSessionByIDQueryResults Results;
HRESULT Process();
void Cancel();
void Clear();
BOOL Done() const { return m_State == STATE_DONE; }
BOOL Succeeded() const { return SUCCEEDED( m_hrQuery ); }
HRESULT Query(
ULONGLONG SessionID
);
BOOL IsRunning() const { return m_State == STATE_RUNNING || m_State == STATE_PROBING_CONNECTIVITY; }
BOOL IsProbing() const { return m_State == STATE_PROBING_BANDWIDTH; }
HRESULT Probe();
private:
// Quality of Service
const XNADDR *m_rgpXnAddr[ MAX_JOIN_SESSION_BY_ID_RESULTS ];
const XNKID *m_rgpXnKid [ MAX_JOIN_SESSION_BY_ID_RESULTS ];
const XNKEY *m_rgpXnKey [ MAX_JOIN_SESSION_BY_ID_RESULTS ];
XNQOS *m_pXnQos;
enum STATE
{
STATE_IDLE,
STATE_RUNNING,
STATE_PROBING_CONNECTIVITY,
STATE_PROBING_BANDWIDTH,
STATE_DONE
};
STATE m_State;
HRESULT m_hrQuery;
XONLINETASK_HANDLE m_hSearchTask;
};

8
tools/jawa/stdafx.cpp Normal file
View File

@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// jawa.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

12
tools/jawa/stdafx.h Normal file
View File

@@ -0,0 +1,12 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include <xtl.h>
#include <vector>
#include "match.h"
// TODO: reference additional headers your program requires here