Get rid of MSVC's __int64

Use either int64_t, uint64_t or long long and unsigned long long, defined as per C++11 standard
This commit is contained in:
void_17
2026-03-02 15:53:32 +07:00
parent d6ec138710
commit d63f79325f
308 changed files with 5371 additions and 5379 deletions

View File

@@ -50,7 +50,7 @@ void CConsoleMinecraftApp::HandleDLCLicenseChange()
// Clear the DLC installed flag so the scenes will pick up the new dlc (could be a full pack install)
app.ClearDLCInstalled();
app.DebugPrintf(">>> HandleDLCLicenseChange - Updating license for DLC [%ls]\n",xOffer.wszOfferName);
pack->updateLicenseMask(1);
pack->updateLicenseMask(1);
}
else
{
@@ -100,7 +100,7 @@ void CConsoleMinecraftApp::ExitGame()
}
void CConsoleMinecraftApp::FatalLoadError()
{
// 4J-PB -
// 4J-PB -
//for(int i=0;i<10;i++)
{
#ifndef _CONTENT_PACKAGE
@@ -204,7 +204,7 @@ int CConsoleMinecraftApp::LoadLocalDLCImage(WCHAR *wchName,PBYTE *ppbImageData,D
// load the local file
WCHAR wchFilename[64];
// 4J-PB - Read the file containing the product codes. This will be different for the SCEE/SCEA/SCEJ builds
swprintf(wchFilename,L"DLCImages/%s",wchName);
HANDLE hFile = CreateFile(wchFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -269,7 +269,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
StorageManager.SetSaveTitle(wWorldName.c_str());
bool isFlat = false;
__int64 seedValue = BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal); // 4J - was (new Random())->nextLong() - now trying to actually find a seed to suit our requirements
int64_t seedValue = BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal); // 4J - was (new Random())->nextLong() - now trying to actually find a seed to suit our requirements
NetworkGameInitData *param = new NetworkGameInitData();
param->seed = seedValue;
@@ -308,7 +308,7 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
thread->Run();
}
typedef struct
typedef struct
{
eDLCContentType e_DLC_Type;
//WCHAR *wchDisplayName;
@@ -397,7 +397,7 @@ bool CConsoleMinecraftApp::UpdateProductId(XCONTENT_DATA &Data)
app.DebugPrintf("Couldn't find %ls\n",Data.wszDisplayName);
}
return false;
return false;
}
void CConsoleMinecraftApp::Shutdown()
@@ -455,7 +455,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadBannedList(void *pParam,int iPad, in
{
app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPReadBannedList\n");
C4JStorage::PTMSPP_FILEDATA pFileData=(C4JStorage::PTMSPP_FILEDATA)lpvData;
CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam;
if(pFileData)
@@ -471,7 +471,7 @@ int CConsoleMinecraftApp::Callback_TMSPPReadBannedList(void *pParam,int iPad, in
// mark the level as not checked against banned levels - it'll be checked once the level starts
app.SetBanListCheck(iPad,false);
// Xbox One will clear things within the DownloadBlob
// Xbox One will clear things within the DownloadBlob
#ifndef _XBOX_ONE
delete [] pFileData->pbData;
delete [] pFileData;
@@ -558,11 +558,11 @@ int CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList(void *pParam,int iPad,
CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam;
app.DebugPrintf("CConsoleMinecraftApp::Callback_TMSPPRetrieveFileList\n");
if(lpvData!=NULL)
{
{
vector<C4JStorage::PTMSPP_FILE_DETAILS> *pvTmsFileDetails=(vector<C4JStorage::PTMSPP_FILE_DETAILS> *)lpvData;
if(pvTmsFileDetails->size()>0)
{
{
#ifdef _DEBUG
// dump out the file list
app.DebugPrintf("TMSPP filecount - %d\nFiles - \n",pvTmsFileDetails->size());
@@ -707,7 +707,7 @@ void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage:
{
CConsoleMinecraftApp* pClass = (CConsoleMinecraftApp*)pParam;
if ( saveIncompleteType == C4JStorage::ESaveIncomplete_OutOfQuota
if ( saveIncompleteType == C4JStorage::ESaveIncomplete_OutOfQuota
|| saveIncompleteType == C4JStorage::ESaveIncomplete_OutOfLocalStorage )
{
StorageManager.SetSaveDisabled(true);
@@ -718,10 +718,10 @@ void CConsoleMinecraftApp::Callback_SaveGameIncomplete(void *pParam, C4JStorage:
else message = IDS_SAVE_INCOMPLETE_EXPLANATION_LOCAL_STORAGE;
UINT uiIDA[3] =
{
IDS_SAVE_INCOMPLETE_RETRY_SAVING,
IDS_SAVE_INCOMPLETE_DISABLE_SAVING,
IDS_SAVE_INCOMPLETE_DELETE_SAVES
{
IDS_SAVE_INCOMPLETE_RETRY_SAVING,
IDS_SAVE_INCOMPLETE_DISABLE_SAVING,
IDS_SAVE_INCOMPLETE_DELETE_SAVES
};
if ( ui.RequestMessageBox( IDS_SAVE_INCOMPLETE_TITLE, message, uiIDA,3,0,Callback_SaveGameIncompleteMessageBoxReturned,pClass, app.GetStringTable()) == C4JStorage::EMessage_Busy)

View File

@@ -114,8 +114,8 @@
#define __RADLITTLEENDIAN__
#ifdef __i386__
#define __RADX86__
#else
#define __RADARM__
#else
#define __RADARM__
#endif
#define RADINLINE inline
#define RADRESTRICT __restrict
@@ -132,7 +132,7 @@
#define __RADX86__
#else
#error Unknown processor
#endif
#endif
#define __RADLITTLEENDIAN__
#define RADINLINE inline
#define RADRESTRICT __restrict
@@ -155,7 +155,7 @@
#define __RADNACL__
#define __RAD32__
#define __RADLITTLEENDIAN__
#define __RADX86__
#define __RADX86__
#define RADINLINE inline
#define RADRESTRICT __restrict
@@ -196,7 +196,7 @@
#define __RAD64REGS__
#define __RADLITTLEENDIAN__
#define RADINLINE inline
#define RADRESTRICT __restrict
#define RADRESTRICT __restrict
#undef RADSTRUCT
#define RADSTRUCT struct __attribute__((__packed__))
@@ -265,7 +265,7 @@
#endif
#undef RADSTRUCT
#define RADSTRUCT struct __attribute__((__packed__))
#elif defined(CAFE) // has to be before HOLLYWOOD_REV since it also defines it
#define __RADWIIU__
@@ -480,7 +480,7 @@
#undef RADRESTRICT /* could have been defined above... */
#define RADRESTRICT __restrict
#undef RADSTRUCT
#define RADSTRUCT struct __attribute__((__packed__))
#endif
@@ -885,7 +885,7 @@
#define RAD_ALIGN(type,var,num) type __declspec(align(num)) var
#else
// NOTE: / / is a guaranteed parse error in C/C++.
#define RAD_ALIGN(type,var,num) RAD_ALIGN_USED_BUT_NOT_DEFINED / /
#define RAD_ALIGN(type,var,num) RAD_ALIGN_USED_BUT_NOT_DEFINED / /
#endif
// WARNING : RAD_TLS should really only be used for debug/tools stuff
@@ -917,8 +917,8 @@
#define RAD_S32 signed int
// But pointers are 64 bits.
#if (_MSC_VER >= 1300 && defined(_Wp64) && _Wp64 )
#define RAD_SINTa __w64 signed __int64
#define RAD_UINTa __w64 unsigned __int64
#define RAD_SINTa __w64 signed long long
#define RAD_UINTa __w64 unsigned long long
#else // non-vc.net compiler or /Wp64 turned off
#define RAD_UINTa unsigned long long
#define RAD_SINTa signed long long
@@ -976,8 +976,8 @@
#define RAD_U64 unsigned long long
#define RAD_S64 signed long long
#elif defined(__RADX64__) || defined(__RAD32__)
#define RAD_U64 unsigned __int64
#define RAD_S64 signed __int64
#define RAD_U64 unsigned long long
#define RAD_S64 signed long long
#else
// 16-bit
typedef RADSTRUCT RAD_U64 // do this so that we don't accidentally use U64s
@@ -1134,7 +1134,7 @@
// helpers for doing an if ( ) with expect :
// if ( RAD_LIKELY(expr) ) { ... }
#define RAD_LIKELY(expr) RAD_EXPECT(expr,1)
#define RAD_UNLIKELY(expr) RAD_EXPECT(expr,0)
@@ -1324,7 +1324,7 @@
__pragma(warning(push)) \
__pragma(warning(disable:4127)) \
} while(0) \
__pragma(warning(pop))
__pragma(warning(pop))
#define RAD_STATEMENT_END_TRUE \
__pragma(warning(push)) \
@@ -1333,10 +1333,10 @@
__pragma(warning(pop))
#else
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#endif
#else
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#endif
#ifdef RAD_USE_STANDARD_LOOP_CONSTRUCT
@@ -1345,7 +1345,7 @@
#define RAD_STATEMENT_END_FALSE \
} while ( (void)0,0 )
#define RAD_STATEMENT_END_TRUE \
} while ( (void)1,1 )
@@ -1355,7 +1355,7 @@
RAD_STATEMENT_START \
code \
RAD_STATEMENT_END_FALSE
#define RAD_INFINITE_LOOP( code ) \
RAD_STATEMENT_START \
code \
@@ -1363,7 +1363,7 @@
// Must be placed after variable declarations for code compiled as .c
#if defined(_MSC_VER) && _MSC_VER >= 1700 // in 2012 aka 11.0 and later
#if defined(_MSC_VER) && _MSC_VER >= 1700 // in 2012 aka 11.0 and later
# define RR_UNUSED_VARIABLE(x) (void) x
#else
# define RR_UNUSED_VARIABLE(x) (void)(sizeof(x))
@@ -1473,7 +1473,7 @@
// just to make gcc shut up about derefing null :
#define RR_MEMBER_OFFSET_PTR(type,member,ptr) ( (SINTa) &(((type *)(ptr))->member) - (SINTa)(ptr) )
#define RR_MEMBER_SIZE_PTR(type,member,ptr) ( sizeof( ((type *) (ptr))->member) )
// MEMBER_TO_OWNER takes a pointer to a member and gives you back the base of the object
// you should then RR_ASSERT( &(ret->member) == ptr );
#define RR_MEMBER_TO_OWNER(type,member,ptr) (type *)( ((char *)(ptr)) - RR_MEMBER_OFFSET_PTR(type,member,ptr) )
@@ -1482,7 +1482,7 @@
// Cache / prefetch macros :
// RR_PREFETCH for various platforms :
//
//
// RR_PREFETCH_SEQUENTIAL : prefetch memory for reading in a sequential scan
// platforms that automatically prefetch sequential (eg. PC) should be a no-op here
// RR_PREFETCH_WRITE_INVALIDATE : prefetch memory for writing - contents of memory are undefined
@@ -1707,7 +1707,7 @@ extern fp_rrDisplayAssertion * g_fp_rrDisplayAssertion;
#define rrDisplayAssertion(i,n,l,f,m) ( ( g_fp_rrDisplayAssertion ) ? (*g_fp_rrDisplayAssertion)(i,n,l,f,m) : 1 )
//-----------------------------------------------------------
// RAD_NO_BREAK : option if you don't like your assert to break
// CB : RR_BREAK is *always* a break ; RR_ASSERT_BREAK is optional
#ifdef RAD_NO_BREAK
@@ -1725,7 +1725,7 @@ extern fp_rrDisplayAssertion * g_fp_rrDisplayAssertion;
#define RR_ASSERT_LITE_ALWAYS(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) { RR_ASSERT_BREAK(); } )
//-----------------------------------
#ifdef RR_DO_ASSERTS
#ifdef RR_DO_ASSERTS
#define RR_ASSERT(exp) RR_ASSERT_ALWAYS(exp)
#define RR_ASSERT_LITE(exp) RR_ASSERT_LITE_ALWAYS(exp)
@@ -1883,7 +1883,7 @@ unsigned long __cdecl _byteswap_ulong (unsigned long _Long);
#define RR_BSWAP16 _byteswap_ushort
#define RR_BSWAP32 _byteswap_ulong
unsigned __int64 __cdecl _byteswap_uint64 (unsigned __int64 val);
unsigned long long __cdecl _byteswap_uint64 (unsigned long long val);
#pragma intrinsic(_byteswap_uint64)
#define RR_BSWAP64 _byteswap_uint64
@@ -1909,7 +1909,7 @@ RADFORCEINLINE unsigned long RR_BSWAP32 (unsigned long _Long)
return _Long;
}
RADFORCEINLINE unsigned __int64 RR_BSWAP64 (unsigned __int64 _Long)
RADFORCEINLINE unsigned long long RR_BSWAP64 (unsigned long long _Long)
{
__asm {
mov eax, DWORD PTR _Long
@@ -2250,10 +2250,10 @@ void __storewordbytereverse (unsigned int val, int offset, void *bas
#if ( defined(_MSC_VER) && _MSC_VER >= 1300)
unsigned __int64 __cdecl _rotl64(unsigned __int64 _Val, int _Shift);
unsigned long long __cdecl _rotl64(unsigned long long _Val, int _Shift);
#pragma intrinsic(_rotl64)
#define RR_ROTL64(x,k) _rotl64((unsigned __int64)(x),(int)(k))
#define RR_ROTL64(x,k) _rotl64((unsigned long long)(x),(int)(k))
#elif defined(__RADCELL__)
@@ -2262,7 +2262,7 @@ unsigned __int64 __cdecl _rotl64(unsigned __int64 _Val, int _Shift);
#elif defined(__RADLINUX__) || defined(__RADMACAPI__)
//APTODO: Just to compile linux. Should we be doing better than this? If not, combine with above.
//APTODO: Just to compile linux. Should we be doing better than this? If not, combine with above.
#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) )
#else

File diff suppressed because it is too large Load Diff

View File

@@ -114,8 +114,8 @@
#define __RADLITTLEENDIAN__
#ifdef __i386__
#define __RADX86__
#else
#define __RADARM__
#else
#define __RADARM__
#endif
#define RADINLINE inline
#define RADRESTRICT __restrict
@@ -132,7 +132,7 @@
#define __RADX86__
#else
#error Unknown processor
#endif
#endif
#define __RADLITTLEENDIAN__
#define RADINLINE inline
#define RADRESTRICT __restrict
@@ -155,7 +155,7 @@
#define __RADNACL__
#define __RAD32__
#define __RADLITTLEENDIAN__
#define __RADX86__
#define __RADX86__
#define RADINLINE inline
#define RADRESTRICT __restrict
@@ -196,7 +196,7 @@
#define __RAD64REGS__
#define __RADLITTLEENDIAN__
#define RADINLINE inline
#define RADRESTRICT __restrict
#define RADRESTRICT __restrict
#undef RADSTRUCT
#define RADSTRUCT struct __attribute__((__packed__))
@@ -265,7 +265,7 @@
#endif
#undef RADSTRUCT
#define RADSTRUCT struct __attribute__((__packed__))
#elif defined(CAFE) // has to be before HOLLYWOOD_REV since it also defines it
#define __RADWIIU__
@@ -480,7 +480,7 @@
#undef RADRESTRICT /* could have been defined above... */
#define RADRESTRICT __restrict
#undef RADSTRUCT
#define RADSTRUCT struct __attribute__((__packed__))
#endif
@@ -885,7 +885,7 @@
#define RAD_ALIGN(type,var,num) type __declspec(align(num)) var
#else
// NOTE: / / is a guaranteed parse error in C/C++.
#define RAD_ALIGN(type,var,num) RAD_ALIGN_USED_BUT_NOT_DEFINED / /
#define RAD_ALIGN(type,var,num) RAD_ALIGN_USED_BUT_NOT_DEFINED / /
#endif
// WARNING : RAD_TLS should really only be used for debug/tools stuff
@@ -917,8 +917,8 @@
#define RAD_S32 signed int
// But pointers are 64 bits.
#if (_MSC_VER >= 1300 && defined(_Wp64) && _Wp64 )
#define RAD_SINTa __w64 signed __int64
#define RAD_UINTa __w64 unsigned __int64
#define RAD_SINTa __w64 signed long long
#define RAD_UINTa __w64 unsigned long long
#else // non-vc.net compiler or /Wp64 turned off
#define RAD_UINTa unsigned long long
#define RAD_SINTa signed long long
@@ -976,8 +976,8 @@
#define RAD_U64 unsigned long long
#define RAD_S64 signed long long
#elif defined(__RADX64__) || defined(__RAD32__)
#define RAD_U64 unsigned __int64
#define RAD_S64 signed __int64
#define RAD_U64 unsigned long long
#define RAD_S64 signed long long
#else
// 16-bit
typedef RADSTRUCT RAD_U64 // do this so that we don't accidentally use U64s
@@ -1134,7 +1134,7 @@
// helpers for doing an if ( ) with expect :
// if ( RAD_LIKELY(expr) ) { ... }
#define RAD_LIKELY(expr) RAD_EXPECT(expr,1)
#define RAD_UNLIKELY(expr) RAD_EXPECT(expr,0)
@@ -1324,7 +1324,7 @@
__pragma(warning(push)) \
__pragma(warning(disable:4127)) \
} while(0) \
__pragma(warning(pop))
__pragma(warning(pop))
#define RAD_STATEMENT_END_TRUE \
__pragma(warning(push)) \
@@ -1333,10 +1333,10 @@
__pragma(warning(pop))
#else
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#endif
#else
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#define RAD_USE_STANDARD_LOOP_CONSTRUCT
#endif
#ifdef RAD_USE_STANDARD_LOOP_CONSTRUCT
@@ -1345,7 +1345,7 @@
#define RAD_STATEMENT_END_FALSE \
} while ( (void)0,0 )
#define RAD_STATEMENT_END_TRUE \
} while ( (void)1,1 )
@@ -1355,7 +1355,7 @@
RAD_STATEMENT_START \
code \
RAD_STATEMENT_END_FALSE
#define RAD_INFINITE_LOOP( code ) \
RAD_STATEMENT_START \
code \
@@ -1363,7 +1363,7 @@
// Must be placed after variable declarations for code compiled as .c
#if defined(_MSC_VER) && _MSC_VER >= 1700 // in 2012 aka 11.0 and later
#if defined(_MSC_VER) && _MSC_VER >= 1700 // in 2012 aka 11.0 and later
# define RR_UNUSED_VARIABLE(x) (void) x
#else
# define RR_UNUSED_VARIABLE(x) (void)(sizeof(x))
@@ -1473,7 +1473,7 @@
// just to make gcc shut up about derefing null :
#define RR_MEMBER_OFFSET_PTR(type,member,ptr) ( (SINTa) &(((type *)(ptr))->member) - (SINTa)(ptr) )
#define RR_MEMBER_SIZE_PTR(type,member,ptr) ( sizeof( ((type *) (ptr))->member) )
// MEMBER_TO_OWNER takes a pointer to a member and gives you back the base of the object
// you should then RR_ASSERT( &(ret->member) == ptr );
#define RR_MEMBER_TO_OWNER(type,member,ptr) (type *)( ((char *)(ptr)) - RR_MEMBER_OFFSET_PTR(type,member,ptr) )
@@ -1482,7 +1482,7 @@
// Cache / prefetch macros :
// RR_PREFETCH for various platforms :
//
//
// RR_PREFETCH_SEQUENTIAL : prefetch memory for reading in a sequential scan
// platforms that automatically prefetch sequential (eg. PC) should be a no-op here
// RR_PREFETCH_WRITE_INVALIDATE : prefetch memory for writing - contents of memory are undefined
@@ -1707,7 +1707,7 @@ extern fp_rrDisplayAssertion * g_fp_rrDisplayAssertion;
#define rrDisplayAssertion(i,n,l,f,m) ( ( g_fp_rrDisplayAssertion ) ? (*g_fp_rrDisplayAssertion)(i,n,l,f,m) : 1 )
//-----------------------------------------------------------
// RAD_NO_BREAK : option if you don't like your assert to break
// CB : RR_BREAK is *always* a break ; RR_ASSERT_BREAK is optional
#ifdef RAD_NO_BREAK
@@ -1725,7 +1725,7 @@ extern fp_rrDisplayAssertion * g_fp_rrDisplayAssertion;
#define RR_ASSERT_LITE_ALWAYS(exp) RAD_STATEMENT_WRAPPER( if ( ! (exp) ) { RR_ASSERT_BREAK(); } )
//-----------------------------------
#ifdef RR_DO_ASSERTS
#ifdef RR_DO_ASSERTS
#define RR_ASSERT(exp) RR_ASSERT_ALWAYS(exp)
#define RR_ASSERT_LITE(exp) RR_ASSERT_LITE_ALWAYS(exp)
@@ -1883,7 +1883,7 @@ unsigned long __cdecl _byteswap_ulong (unsigned long _Long);
#define RR_BSWAP16 _byteswap_ushort
#define RR_BSWAP32 _byteswap_ulong
unsigned __int64 __cdecl _byteswap_uint64 (unsigned __int64 val);
unsigned long long __cdecl _byteswap_uint64 (unsigned long long val);
#pragma intrinsic(_byteswap_uint64)
#define RR_BSWAP64 _byteswap_uint64
@@ -1909,7 +1909,7 @@ RADFORCEINLINE unsigned long RR_BSWAP32 (unsigned long _Long)
return _Long;
}
RADFORCEINLINE unsigned __int64 RR_BSWAP64 (unsigned __int64 _Long)
RADFORCEINLINE unsigned long long RR_BSWAP64 (unsigned long long _Long)
{
__asm {
mov eax, DWORD PTR _Long
@@ -2250,10 +2250,10 @@ void __storewordbytereverse (unsigned int val, int offset, void *bas
#if ( defined(_MSC_VER) && _MSC_VER >= 1300)
unsigned __int64 __cdecl _rotl64(unsigned __int64 _Val, int _Shift);
unsigned long long __cdecl _rotl64(unsigned long long _Val, int _Shift);
#pragma intrinsic(_rotl64)
#define RR_ROTL64(x,k) _rotl64((unsigned __int64)(x),(int)(k))
#define RR_ROTL64(x,k) _rotl64((unsigned long long)(x),(int)(k))
#elif defined(__RADCELL__)
@@ -2262,7 +2262,7 @@ unsigned __int64 __cdecl _rotl64(unsigned __int64 _Val, int _Shift);
#elif defined(__RADLINUX__) || defined(__RADMACAPI__)
//APTODO: Just to compile linux. Should we be doing better than this? If not, combine with above.
//APTODO: Just to compile linux. Should we be doing better than this? If not, combine with above.
#define RR_ROTL64(u64,num) ( ( (u64) << (num) ) | ( (u64) >> (64 - (num))) )
#else

View File

@@ -43,7 +43,7 @@ DQRNetworkManager::SessionInfo::SessionInfo()
}
// This maps internal to extern states, and needs to match element-by-element the eSQRNetworkManagerInternalState enumerated type
const DQRNetworkManager::eDQRNetworkManagerState DQRNetworkManager::m_INTtoEXTStateMappings[DQRNetworkManager::DNM_INT_STATE_COUNT] =
const DQRNetworkManager::eDQRNetworkManagerState DQRNetworkManager::m_INTtoEXTStateMappings[DQRNetworkManager::DNM_INT_STATE_COUNT] =
{
DNM_STATE_INITIALISING, // DNM_INT_STATE_INITIALISING
DNM_STATE_INITIALISE_FAILED, // DNM_INT_STATE_INITIALISE_FAILED
@@ -64,7 +64,7 @@ const DQRNetworkManager::eDQRNetworkManagerState DQRNetworkManager::m_INTtoEXTSt
DNM_STATE_PLAYING, // DNM_INT_STATE_PLAYING
DNM_STATE_LEAVING, // DNM_INT_STATE_LEAVING
DNM_STATE_LEAVING, // DNM_INT_STATE_LEAVING_FAILED
DNM_STATE_ENDING, // DNM_INT_STATE_ENDING
DNM_STATE_ENDING, // DNM_INT_STATE_ENDING
};
DQRNetworkManager::DQRNetworkManager(IDQRNetworkManagerListener *listener)
@@ -146,7 +146,7 @@ void DQRNetworkManager::EnableDebugXBLContext(MXS::XboxLiveContext^ XBLContext)
// Show service calls from Xbox Services on the UI for easy debugging
XBLContext->Settings->EnableServiceCallRoutedEvents = true;
XBLContext->Settings->ServiceCallRouted += ref new Windows::Foundation::EventHandler<Microsoft::Xbox::Services::XboxServiceCallRoutedEventArgs^>(
XBLContext->Settings->ServiceCallRouted += ref new Windows::Foundation::EventHandler<Microsoft::Xbox::Services::XboxServiceCallRoutedEventArgs^>(
[=]( Platform::Object^, Microsoft::Xbox::Services::XboxServiceCallRoutedEventArgs^ args )
{
//if( args->HttpStatus != 200 )
@@ -308,14 +308,14 @@ void DQRNetworkManager::JoinSession(int playerMask)
m_isHosting = false;
sockaddr_in6 localSocketAddressStorage;
ZeroMemory(&localSocketAddressStorage, sizeof(localSocketAddressStorage));
localSocketAddressStorage.sin6_family = AF_INET6;
localSocketAddressStorage.sin6_port = htons(m_associationTemplate->AcceptorSocketDescription->BoundPortRangeLower);
memcpy(&localSocketAddressStorage.sin6_addr, &in6addr_any, sizeof(in6addr_any));
m_localSocketAddress = Platform::ArrayReference<BYTE>(reinterpret_cast<BYTE*>(&localSocketAddressStorage), sizeof(localSocketAddressStorage));
m_joinCreateSessionAttempts = 0;
@@ -402,7 +402,7 @@ bool DQRNetworkManager::AddUsersToSession(int playerMask, MXSM::MultiplayerSessi
// We need to get a MultiplayerSession for each player that is joining
MXSM::MultiplayerSession^ session = nullptr;
WXS::User^ newUser = ProfileManager.GetUser(i);
if( newUser == nullptr )
{
@@ -451,12 +451,12 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
// We need to handle this differently for the host and other machines. As the procedure for adding a reserved slot for a local player whilst on the host doesn't seem to work
//
// On the host machine, we:
//
//
// (1) Get a MPSD for the player that is being added
// (2) Call the join method
// (3) Write the MPSD
// (4) Update the player sync data, and broadcast out to all clients
// On remote machines, we:
//
// (1) join the party
@@ -473,10 +473,10 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
{
return false;
}
if( !m_isOfflineGame )
{
// This is going to involve some async processing
// This is going to involve some async processing
MXS::XboxLiveContext^ newUserXBLContext = ref new MXS::XboxLiveContext(newUser);
if( newUserXBLContext == nullptr )
@@ -558,7 +558,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
SendRoomSyncInfo();
m_listener->HandlePlayerJoined(pPlayer); // This is for notifying of local players joining in an offline game
}
else
else
{
// Can fail (notably if m_roomSyncData contains players who've left)
assert(0);
@@ -571,7 +571,7 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
{
// Check if there's any available slots before attempting to add the player to the party. We can still fail joining later if
// the host can't add a reserved slot for us for some reason but better checking on the client side before even attempting.
WXS::User^ newUser = ProfileManager.GetUser(userIndex);
MXS::XboxLiveContext^ newUserXBLContext = ref new MXS::XboxLiveContext(newUser);
@@ -622,16 +622,16 @@ bool DQRNetworkManager::AddLocalPlayerByUserIndex(int userIndex)
bool DQRNetworkManager::RemoveLocalPlayerByUserIndex(int userIndex)
{
// We need to handle this differently for the host and other machines.
// We need to handle this differently for the host and other machines.
//
// On the host machine, we:
//
//
// (1) Get a MPSD for the player that is being removed
// (2) Call the leave method
// (3) Write the MPSD
// (4) Leave the party
// (5) Update the player sync data, and broadcast out to all clients
// On remote machines, we:
//
// (1) Get a MPSD for the player that is being removed
@@ -651,7 +651,7 @@ bool DQRNetworkManager::RemoveLocalPlayerByUserIndex(int userIndex)
{
return false;
}
if( !m_isOfflineGame )
{
if( m_chat )
@@ -714,7 +714,7 @@ bool DQRNetworkManager::IsHost()
}
// Consider as "in session" from the moment that a game is created or joined, until the point where the game itself has been told via state change that we are now idle. The
// game code requires IsInSession to return true as soon as it has asked to do one of these things (even if the state system hasn't really caught up with this request yet), and
// game code requires IsInSession to return true as soon as it has asked to do one of these things (even if the state system hasn't really caught up with this request yet), and
// it also requires that it is informed of the state changes leading up to not being in the session, before this should report false.
bool DQRNetworkManager::IsInSession()
{
@@ -788,7 +788,7 @@ wstring DQRNetworkManager::GetDisplayNameByGamertag(wstring gamertag)
{
return m_displayNames[gamertag];
}
else
else
{
return gamertag;
}
@@ -902,14 +902,14 @@ void DQRNetworkManager::Tick_VoiceChat()
{
m_chat->AddLocalUser(user);
}
}
}
}
m_vecChatPlayersJoined.clear();
LeaveCriticalSection(&m_csVecChatPlayers);
}
void DQRNetworkManager::Tick_Party()
{
{
// If the primary player has been flagged as having left the party, then we don't respond immediately as it is possible we are just transitioning from one party to another, and it would be much
// nicer to handle this kind of transition directly. If we do get a new party within this time period, then we'll handle by asking the user if they want to leave the game they are currently in etc.
if( m_playersLeftParty )
@@ -919,7 +919,7 @@ void DQRNetworkManager::Tick_Party()
// We've waited long enough. User must (hopefully) have just left the party
// Previously we'd switch to offline but that causes a world of pain with forced sign-outs
if( m_playersLeftParty & 1 )
{
{
// Before we switch to an offline game, check to see if there is currently a new party. If this is the case and
// we're here, then its because we were added to a party, but didn't receive a gamesessionready event. So if we have
// a party here that we've joined, and the number of players in the party (including us) is more than MAX_PLAYERS_IN_TEMPLATE,
@@ -955,7 +955,7 @@ void DQRNetworkManager::Tick_Party()
m_playersLeftParty = 0;
}
}
// Forced sign out
if (m_handleForcedSignOut)
{
@@ -1064,7 +1064,7 @@ void DQRNetworkManager::Tick_ResolveGamertags()
HostGamertagResolveDetails *details = m_hostGamertagResolveResults.front();
details->m_pPlayer->SetName(details->m_name.c_str());
LogComment("Adding a player");
if( AddRoomSyncPlayer(details->m_pPlayer, details->m_sessionAddress, details->m_channel ) )
{
@@ -1154,7 +1154,7 @@ void DQRNetworkManager::Tick_StateMachine()
break;
case DNM_INT_STATE_JOINING_SENDING_UNRELIABLE:
{
__int64 timeNow = System::currentTimeMillis();
int64_t timeNow = System::currentTimeMillis();
// m_firstUnreliableSendTime of 0 indicates that we haven't tried sending an unreliable packet yet so need to send one and initialise things
if( m_firstUnreliableSendTime == 0 )
{
@@ -1188,7 +1188,7 @@ void DQRNetworkManager::Tick_StateMachine()
{
// Timeout if we've been waiting for reserved slots for our joining players for too long. This is most likely because the host doesn't have room for all the slots we wanted, and we weren't able to determine this
// when we went to join the game (ie someone else was joining at the same time). At this point we need to remove any local players that did already join, from both the session and the party.
__int64 timeNow = System::currentTimeMillis();
int64_t timeNow = System::currentTimeMillis();
if( ( timeNow - m_startedWaitingForReservationsTime ) > JOIN_RESERVATION_WAIT_TIME )
{
SetState(DNM_INT_STATE_JOINING_FAILED_TIDY_UP);
@@ -1332,7 +1332,7 @@ void DQRNetworkManager::HandleSessionChange(MXSM::MultiplayerSession^ multiplaye
{
((DurangoStats*)GenericStats::getInstance())->setMultiplayerCorrelationId( nullptr );
}
m_multiplayerSession = multiplayerSession;
}
@@ -1362,7 +1362,7 @@ MXSM::MultiplayerSession^ DQRNetworkManager::WriteSessionHelper( MXS::XboxLiveCo
})
.wait();
if( outputMultiplayerSession != nullptr &&
if( outputMultiplayerSession != nullptr &&
outputMultiplayerSession->SessionReference != nullptr )
{
app.DebugPrintf( "Session written OK\n" );
@@ -1422,7 +1422,7 @@ WXM::MultiplayerSessionReference^ DQRNetworkManager::ConvertToWindowsXboxMultipl
{
return ref new WXM::MultiplayerSessionReference(
sessionRef->SessionName,
sessionRef->ServiceConfigurationId,
sessionRef->ServiceConfigurationId,
sessionRef->SessionTemplateName
);
}
@@ -1458,7 +1458,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
// And when we are done, anything left in the temporary vector must be a player that left
for( int i = 0; i < pNewSyncData->playerCount; i++ )
{
PlayerSyncData *pNewPlayer = &pNewSyncData->players[i];
PlayerSyncData *pNewPlayer = &pNewSyncData->players[i];
bool bAlreadyExisted = false;
for( AUTO_VAR(it, tempPlayers.begin()); it != tempPlayers.end(); it++ )
{
@@ -1491,7 +1491,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
}
LogCommentFormat(L"Adding new player, index %d - type %d, small Id %d, name %s, xuid %s\n",i,m_players[i]->m_type,pNewPlayer->m_smallId,pNewPlayer->m_name,pNewPlayer->m_XUID);
m_players[i]->SetSmallId(pNewPlayer->m_smallId);
m_players[i]->SetName(pNewPlayer->m_name);
m_players[i]->SetUID(PlayerUID(pNewPlayer->m_XUID));
@@ -1525,7 +1525,7 @@ void DQRNetworkManager::UpdateRoomSyncPlayers(RoomSyncData *pNewSyncData)
bool DQRNetworkManager::AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned int sessionAddress, int channel)
{
if( m_roomSyncData.playerCount == MAX_ONLINE_PLAYER_COUNT ) return false;
EnterCriticalSection(&m_csRoomSyncData);
// Find the first entry that isn't us, to decide what to sync before. Don't consider entry #0 as this is reserved to indicate the host.
int insertAtIdx = m_roomSyncData.playerCount;
@@ -1552,11 +1552,11 @@ bool DQRNetworkManager::AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned in
{
m_roomSyncData.players[i] = m_roomSyncData.players[i-1];
m_players[i] = m_players[i - 1];
}
}
m_roomSyncData.players[insertAtIdx].m_channel = channel;
m_roomSyncData.players[insertAtIdx].m_sessionAddress = sessionAddress;
int xuidLength = pPlayer->GetUID().toString().length() + 1; // +1 for terminator
m_roomSyncData.players[insertAtIdx].m_XUID = new wchar_t [xuidLength];
m_roomSyncData.players[insertAtIdx].m_XUID = new wchar_t [xuidLength];
wcsncpy(m_roomSyncData.players[insertAtIdx].m_XUID, pPlayer->GetUID().toString().c_str(), xuidLength);
m_roomSyncData.players[insertAtIdx].m_smallId = pPlayer->GetSmallId();
wcscpy_s(m_roomSyncData.players[insertAtIdx].m_name, pPlayer->GetName());
@@ -1587,7 +1587,7 @@ void DQRNetworkManager::RemoveRoomSyncPlayersWithSessionAddress(unsigned int ses
{
m_roomSyncData.players[iWriteIdx] = m_roomSyncData.players[i];
m_players[iWriteIdx] = m_players[i];
iWriteIdx++;
iWriteIdx++;
}
}
m_roomSyncData.playerCount = iWriteIdx;
@@ -1618,7 +1618,7 @@ void DQRNetworkManager::RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer)
{
m_roomSyncData.players[iWriteIdx] = m_roomSyncData.players[i];
m_players[iWriteIdx] = m_players[i];
iWriteIdx++;
iWriteIdx++;
}
}
m_roomSyncData.playerCount = iWriteIdx;
@@ -1659,13 +1659,13 @@ void DQRNetworkManager::SendRoomSyncInfo()
uint32_t sizeHigh = internalBytes >> 8;
uint32_t sizeLow = internalBytes & 0xff;
data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
data[1] = sizeLow; // Data following has the a single byte to say what it is, followed by the room sync data itself
data[2] = DQR_INTERNAL_PLAYER_TABLE;
memcpy(data + 3, &xuidBytes, 4);
memcpy(data + 7, &m_roomSyncData, sizeof(RoomSyncData));
unsigned char *pucCurr = data + 7 + sizeof(RoomSyncData);
unsigned char *pucCurr = data + 7 + sizeof(RoomSyncData);
for( int i = 0 ; i < m_roomSyncData.playerCount; i++ )
{
@@ -1701,12 +1701,12 @@ void DQRNetworkManager::SendAddPlayerFailed(Platform::String^ xuid)
uint32_t sizeHigh = internalBytes >> 8;
uint32_t sizeLow = internalBytes & 0xff;
data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
data[0] = 0x80 | sizeHigh; // Header - flag as internal data (0x80), sending
data[1] = sizeLow; // Data following has the a single byte to say what it is, followed by the room sync data itself
data[2] = DQR_INTERNAL_ADD_PLAYER_FAILED;
memcpy(data + 3, &xuidBytes, 4);
memcpy(data + 7, xuid->Data(), xuidBytes);
memcpy(data + 7, xuid->Data(), xuidBytes);
SendBytesRaw(-1, data, totalBytes, true);
@@ -1927,7 +1927,7 @@ int DQRNetworkManager::HostGameThreadProc()
// Actually create the session (locally), using the primary player's context
try
{
session = ref new MXSM::MultiplayerSession( primaryUserXBLContext,
session = ref new MXSM::MultiplayerSession( primaryUserXBLContext,
ref new MXSM::MultiplayerSessionReference( SERVICE_CONFIG_ID, MATCH_SESSION_TEMPLATE_NAME, sessionName ),
0, // this means that it will use the maxMembers specified in the session template.
false,
@@ -1972,7 +1972,7 @@ int DQRNetworkManager::HostGameThreadProc()
session->Join( GetNextSmallIdAsJsonString(), true );
session->SetCurrentUserStatus( MXSM::MultiplayerSessionMemberStatus::Active );
// Get device ID for current user & set in the session
Platform::String^ secureDeviceAddress = WXN::SecureDeviceAddress::GetLocal()->GetBase64String();
session->SetCurrentUserSecureDeviceAddressBase64( secureDeviceAddress );
@@ -1997,7 +1997,7 @@ int DQRNetworkManager::HostGameThreadProc()
return 0;
}
m_partyController->SetJoinability(m_listener->IsSessionJoinable());
// Add reservations for anyone in the party, who isn't the primary player. Just adding local players for now, but perhaps this should add
// other party members at this stage?
for ( WXM::PartyMember^ member : partyView->Members )
@@ -2029,8 +2029,8 @@ int DQRNetworkManager::HostGameThreadProc()
session->SetHostDeviceToken( hostMember->DeviceToken );
m_partyController->RegisterGamePlayersChangedEventHandler();
// Update session on the server
// Update session on the server
HRESULT hr = S_OK;
session = WriteSessionHelper( primaryUserXBLContext, session, MXSM::MultiplayerSessionWriteMode::UpdateExisting, hr );
@@ -2086,14 +2086,14 @@ int DQRNetworkManager::HostGameThreadProc()
if( m_state == DNM_INT_STATE_HOSTING_FAILED) return 0;
sockaddr_in6 localSocketAddressStorage;
ZeroMemory(&localSocketAddressStorage, sizeof(localSocketAddressStorage));
localSocketAddressStorage.sin6_family = AF_INET6;
localSocketAddressStorage.sin6_port = htons(m_associationTemplate->AcceptorSocketDescription->BoundPortRangeLower);
memcpy(&localSocketAddressStorage.sin6_addr, &in6addr_any, sizeof(in6addr_any));
m_localSocketAddress = Platform::ArrayReference<BYTE>(reinterpret_cast<BYTE*>(&localSocketAddressStorage), sizeof(localSocketAddressStorage));
// This shouldn't ever happen, but seems worth checking that we don't have a pre-existing session in case there's any way to get here with one already running
@@ -2184,7 +2184,7 @@ int DQRNetworkManager::HostGameThreadProc()
if( m_currentUserMask & ( 1 << i ) && ProfileManager.IsSignedIn(i))
{
auto user = ProfileManager.GetUser(i);
wstring displayName = ProfileManager.GetDisplayName(i);
wstring displayName = ProfileManager.GetDisplayName(i);
DQRNetworkPlayer* pPlayer = new DQRNetworkPlayer(this, ( ( smallId == m_hostSmallId ) ? DQRNetworkPlayer::DNP_TYPE_HOST : DQRNetworkPlayer::DNP_TYPE_LOCAL ), true, i, localSessionAddress);
pPlayer->SetSmallId(smallId);
@@ -2234,7 +2234,7 @@ int DQRNetworkManager::LeaveRoomThreadProc()
// Request RTS to be terminated
RTS_Terminate();
// Now leave the game session. We need to do this for each player in turn, writing each time
bool bError = false;
for( int i = 0; i < 4; i++ )
@@ -2339,7 +2339,7 @@ int DQRNetworkManager::TidyUpJoinThreadProc()
// We can fail to join at various points, and in at least one case (if it is down to RUDP unreliable packets timing out) then we don't have m_joinSessionUserMask bits set any more,
// but we Do have m_currentUserMask set. Any of these should be considered users we should be attempting to remove from the session.
int removeSessionMask = m_joinSessionUserMask | m_currentUserMask;
int removeSessionMask = m_joinSessionUserMask | m_currentUserMask;
for( int i = 0; i < 4; i++ )
{
if( removeSessionMask & ( 1 << i ) )
@@ -2428,7 +2428,7 @@ int DQRNetworkManager::UpdateCustomSessionDataThreadProc()
{
LogComment(L"Starting thread to update custom data");
WXS::User^ primaryUser = ProfileManager.GetUser(0);
if( primaryUser == nullptr )
{
return 0;
@@ -2550,7 +2550,7 @@ void DQRNetworkManager::HandlePlayerRemovedFromParty(int playerMask)
{
// As a client, we don't have any messy changing to offline game or saving etc. to do, so we can respond immediately to leaving the party
if( playerMask & 1 )
{
{
DQRNetworkManager::LogComment(L"Primary player on this system has left the party - leaving game\n");
app.SetDisconnectReason(DisconnectPacket::eDisconnect_ExitedGame);
LeaveRoom();
@@ -2725,7 +2725,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
m_joinSessionUserMask = playerMask;
m_isInSession = true;
m_isOfflineGame = false;
m_startedWaitingForReservationsTime = System::currentTimeMillis();
SetState(DNM_INT_STATE_JOINING_WAITING_FOR_RESERVATIONS);
@@ -2742,7 +2742,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
if( sessionRef != nullptr )
{
// Allow 2 seconds before we let the player cancel
__int64 allowCancelTime = System::currentTimeMillis() + (1000 * 2);
int64_t allowCancelTime = System::currentTimeMillis() + (1000 * 2);
// Now leave the game session. We need to do this for each player in turn, writing each time. Consider that any of the joining
// members *may* have a slot (reserved or active) depending on how far progressed the joining got.
@@ -2814,7 +2814,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
break;
}
__int64 currentTime = System::currentTimeMillis();
int64_t currentTime = System::currentTimeMillis();
if( currentTime > allowCancelTime)
{
shownCancelScreen = true;
@@ -2893,7 +2893,7 @@ bool DQRNetworkManager::JoinPartyFromSearchResult(SessionSearchResult *searchRes
SetState(DNM_INT_STATE_JOINING_FAILED);
}
});
while(!ccTask.is_done())
{
@@ -3013,7 +3013,7 @@ void DQRNetworkManager::RequestDisplayName(DQRNetworkPlayer *player)
{
if (player->IsLocal())
{
// Player is local so we can just ask profile manager
// Player is local so we can just ask profile manager
SetDisplayName(player->GetUID(), ProfileManager.GetDisplayName(player->GetLocalPlayerIndex()));
}
else

View File

@@ -131,7 +131,7 @@ public:
static const int MAX_ONLINE_PLAYER_COUNT = 8;
static const int MAX_ONLINE_PLAYER_NAME_LENGTH = 21;
// This class stores everything about a player that must be synchronised between machines.
// This class stores everything about a player that must be synchronised between machines.
class PlayerSyncData
{
public:
@@ -210,7 +210,7 @@ public:
DNM_STATE_JOINING,
DNM_STATE_STARTING,
DNM_STATE_PLAYING,
DNM_STATE_PLAYING,
DNM_STATE_LEAVING,
DNM_STATE_ENDING,
@@ -339,9 +339,9 @@ private:
static const eDQRNetworkManagerState m_INTtoEXTStateMappings[DNM_INT_STATE_COUNT];
eDQRNetworkManagerInternalState m_state;
eDQRNetworkManagerState m_stateExternal;
__int64 m_lastUnreliableSendTime;
__int64 m_firstUnreliableSendTime;
__int64 m_startedWaitingForReservationsTime;
int64_t m_lastUnreliableSendTime;
int64_t m_firstUnreliableSendTime;
int64_t m_startedWaitingForReservationsTime;
unsigned char *m_customSessionData;
unsigned int m_customSessionDataSize;
int m_customDataDirtyUpdateTicks;
@@ -361,7 +361,7 @@ private:
CRITICAL_SECTION m_csRoomSyncData;
RoomSyncData m_roomSyncData;
DQRNetworkPlayer *m_players[MAX_ONLINE_PLAYER_COUNT];
DQRNetworkPlayer *m_players[MAX_ONLINE_PLAYER_COUNT];
IDQRNetworkManagerListener *m_listener;
PartyController *m_partyController;
@@ -389,7 +389,7 @@ private:
int m_joinCreateSessionAttempts;
C4JThread *m_CreateSessionThread;
C4JThread *m_LeaveRoomThread;
C4JThread *m_LeaveRoomThread;
C4JThread *m_TidyUpJoinThread;
C4JThread *m_UpdateCustomSessionDataThread;
C4JThread *m_RTS_DoWorkThread;
@@ -426,7 +426,7 @@ private:
int GetQueueSizeMessages();
void SendBytesRaw(int smallId, BYTE *bytes, int byteCount, bool reliableAndSequential);
void SendBytesChat(unsigned int address, BYTE *bytes, int byteCount, bool reliable, bool sequential, bool broadcast);
bool AddRoomSyncPlayer(DQRNetworkPlayer *pPlayer, unsigned int sessionAddress, int channel);
void RemoveRoomSyncPlayersWithSessionAddress(unsigned int sessionAddress);
void RemoveRoomSyncPlayer(DQRNetworkPlayer *pPlayer);
@@ -438,7 +438,7 @@ private:
int GetSessionIndexForSmallId(unsigned char smallId);
int GetSessionIndexAndSmallIdForHost(unsigned char *smallId);
static void LogComment( Platform::String^ strText );
static void LogComment( Platform::String^ strText );
static void LogCommentFormat( LPCWSTR strMsg, ... );
static void LogCommentWithError( Platform::String^ strTest, HRESULT hr );
@@ -491,7 +491,7 @@ public:
void SetDisplayName(PlayerUID xuid, wstring displayName);
private:
__int64 m_playersLeftPartyTime;
int64_t m_playersLeftPartyTime;
int m_playersLeftParty;
bool GetBestPartyUserIndex();
@@ -502,7 +502,7 @@ private:
bool GetGameSessionData(MXSM::MultiplayerSession^ session, void *gameSessionData);
public:
static Platform::Collections::Vector<Platform::String^>^ GetFriends();
static Platform::Collections::Vector<Platform::String^>^ GetFriends();
private:
SessionSearchResult *m_sessionSearchResults;
@@ -551,7 +551,7 @@ private:
void Process_RTS_MESSAGE_STATUS_TERMINATED(RTS_Message &message);
// Outgoing messages - to be called from the RTS work thread, to process requests from the main thread
void ProcessRTSMessagesOutgoing();
void Process_RTS_MESSAGE_START_CLIENT(RTS_Message &message);
void Process_RTS_MESSAGE_START_HOST(RTS_Message &message);

View File

@@ -155,12 +155,12 @@ Routine Description:
Register the provider with ETW+.
Arguments:
None
Remarks:
ERROR_SUCCESS if success or if the provider was already registered.
ERROR_SUCCESS if success or if the provider was already registered.
Otherwise, an error code.
--*/
@@ -175,7 +175,7 @@ Routine Description:
Arguments:
None
Remarks:
ERROR_SUCCESS if success or if the provider was not registered.
ERROR_SUCCESS if success or if the provider was not registered.
Otherwise, an error code.
--*/
#define EventUnregisterXBLA_149E11AE() EtxUnregister(&XBLA_149E11AEProvider, &XBLA_149E11AEHandle)
@@ -265,7 +265,7 @@ EventWriteBanLevel(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in co
//
__inline
ULONG
EventWriteBlockBroken(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const signed int BlockId, __in const signed int BlockAux, __in const unsigned __int64 BlockCount)
EventWriteBlockBroken(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const signed int BlockId, __in const signed int BlockAux, __in const uint64_t BlockCount)
{
#define ARGUMENT_COUNT_XBLA_149E11AE_BlockBroken 7
@@ -289,7 +289,7 @@ EventWriteBlockBroken(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in
//
__inline
ULONG
EventWriteBlockPlaced(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const signed int BlockId, __in const signed int BlockAux, __in const unsigned __int64 BlockCount)
EventWriteBlockPlaced(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const signed int BlockId, __in const signed int BlockAux, __in const uint64_t BlockCount)
{
#define ARGUMENT_COUNT_XBLA_149E11AE_BlockPlaced 7
@@ -376,7 +376,7 @@ EventWriteGameProgress(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __i
//
__inline
ULONG
EventWriteIncDistanceTravelled(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const unsigned __int64 Distance, __in const signed int TravelMethodId)
EventWriteIncDistanceTravelled(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const uint64_t Distance, __in const signed int TravelMethodId)
{
#define ARGUMENT_COUNT_XBLA_149E11AE_IncDistanceTravelled 6
@@ -399,7 +399,7 @@ EventWriteIncDistanceTravelled(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessio
//
__inline
ULONG
EventWriteIncTimePlayed(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const unsigned __int64 TimePlayed)
EventWriteIncTimePlayed(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in const signed int DifficultyLevelId, __in const uint64_t TimePlayed)
{
#define ARGUMENT_COUNT_XBLA_149E11AE_IncTimePlayed 5
@@ -570,7 +570,7 @@ EventWriteLevelStart(__in_opt PCWSTR UserId, __in LPCGUID PlayerSessionId, __in
//
__inline
ULONG
EventWriteMcItemAcquired(__in_opt PCWSTR UserId, __in const signed int SectionId, __in LPCGUID PlayerSessionId, __in_opt PCWSTR MultiplayerCorrelationId, __in const signed int GameplayModeId, __in const signed int DifficultyLevelId, __in const signed int ItemId, __in const signed int AcquisitionMethodId, __in const float LocationX, __in const float LocationY, __in const float LocationZ, __in const signed int ItemAux, __in const unsigned __int64 ItemCount)
EventWriteMcItemAcquired(__in_opt PCWSTR UserId, __in const signed int SectionId, __in LPCGUID PlayerSessionId, __in_opt PCWSTR MultiplayerCorrelationId, __in const signed int GameplayModeId, __in const signed int DifficultyLevelId, __in const signed int ItemId, __in const signed int AcquisitionMethodId, __in const float LocationX, __in const float LocationY, __in const float LocationZ, __in const signed int ItemAux, __in const uint64_t ItemCount)
{
#define ARGUMENT_COUNT_XBLA_149E11AE_McItemAcquired 14
@@ -601,7 +601,7 @@ EventWriteMcItemAcquired(__in_opt PCWSTR UserId, __in const signed int SectionId
//
__inline
ULONG
EventWriteMcItemUsed(__in_opt PCWSTR UserId, __in const signed int SectionId, __in LPCGUID PlayerSessionId, __in_opt PCWSTR MultiplayerCorrelationId, __in const signed int GameplayModeId, __in const signed int DifficultyLevelId, __in const signed int ItemId, __in const float LocationX, __in const float LocationY, __in const float LocationZ, __in const signed int ItemAux, __in const unsigned __int64 ItemCount, __in const signed int Hunger)
EventWriteMcItemUsed(__in_opt PCWSTR UserId, __in const signed int SectionId, __in LPCGUID PlayerSessionId, __in_opt PCWSTR MultiplayerCorrelationId, __in const signed int GameplayModeId, __in const signed int DifficultyLevelId, __in const signed int ItemId, __in const float LocationX, __in const float LocationY, __in const float LocationZ, __in const signed int ItemAux, __in const uint64_t ItemCount, __in const signed int Hunger)
{
#define ARGUMENT_COUNT_XBLA_149E11AE_McItemUsed 14

View File

@@ -1,13 +1,13 @@
// 4J-PB -
// The ATG Framework is a common set of C++ class libraries that is used by the samples in the XDK, and was developed by the Advanced Technology Group (ATG).
// The ATG Framework offers a clean and consistent format for the samples. These classes define functions used by all the samples.
// The ATG Framework together with the samples demonstrates best practices and innovative techniques for Xbox 360. There are many useful sections of code in the samples.
// You are encouraged to incorporate this code into your titles.
// 4J-PB -
// The ATG Framework is a common set of C++ class libraries that is used by the samples in the XDK, and was developed by the Advanced Technology Group (ATG).
// The ATG Framework offers a clean and consistent format for the samples. These classes define functions used by all the samples.
// The ATG Framework together with the samples demonstrates best practices and innovative techniques for Xbox 360. There are many useful sections of code in the samples.
// You are encouraged to incorporate this code into your titles.
//-------------------------------------------------------------------------------------
// AtgXmlParser.cpp
//
//
// Simple callback non-validating XML parser implementation.
//
// Xbox Advanced Technology Group.
@@ -35,7 +35,7 @@ XMLParser::XMLParser()
// Name: XMLParser::~XMLParser
//-------------------------------------------------------------------------------------
XMLParser::~XMLParser()
{
{
}
@@ -51,11 +51,11 @@ VOID XMLParser::FillBuffer()
if( m_hFile == NULL )
{
if( m_uInXMLBufferCharsLeft > XML_READ_BUFFER_SIZE )
if( m_uInXMLBufferCharsLeft > XML_READ_BUFFER_SIZE )
NChars = XML_READ_BUFFER_SIZE;
else
NChars = m_uInXMLBufferCharsLeft;
CopyMemory( m_pReadBuf, m_pInXMLBuffer, NChars );
m_uInXMLBufferCharsLeft -= NChars;
m_pInXMLBuffer += NChars;
@@ -69,7 +69,7 @@ VOID XMLParser::FillBuffer()
}
m_dwCharsConsumed += NChars;
__int64 iProgress = m_dwCharsTotal ? (( (__int64)m_dwCharsConsumed * 1000 ) / (__int64)m_dwCharsTotal) : 0;
int64_t iProgress = m_dwCharsTotal ? (( (int64_t)m_dwCharsConsumed * 1000 ) / (int64_t)m_dwCharsTotal) : 0;
m_pISAXCallback->SetParseProgress( (DWORD)iProgress );
m_pReadBuf[ NChars ] = '\0';
@@ -89,7 +89,7 @@ VOID XMLParser::SkipNextAdvance()
//-------------------------------------------------------------------------------------
// Name: XMLParser::ConsumeSpace
// Desc: Skips spaces in the current stream
// Desc: Skips spaces in the current stream
//-------------------------------------------------------------------------------------
HRESULT XMLParser::ConsumeSpace()
{
@@ -104,29 +104,29 @@ HRESULT XMLParser::ConsumeSpace()
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
}
SkipNextAdvance();
}
SkipNextAdvance();
return S_OK;
}
//-------------------------------------------------------------------------------------
// Name: XMLParser::ConvertEscape
// Desc: Copies and converts an escape sequence into m_pWriteBuf
// Desc: Copies and converts an escape sequence into m_pWriteBuf
//-------------------------------------------------------------------------------------
HRESULT XMLParser::ConvertEscape()
{
{
HRESULT hr;
WCHAR wVal = 0;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
// all escape sequences start with &, so ignore the first character
// all escape sequences start with &, so ignore the first character
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if ( m_Ch == '#' ) // character as hex or decimal
{
if( FAILED( hr = AdvanceCharacter() ) )
@@ -135,9 +135,9 @@ HRESULT XMLParser::ConvertEscape()
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
while ( m_Ch != ';' )
{
{
wVal *= 16;
if ( ( m_Ch >= '0' ) && ( m_Ch <= '9' ) )
@@ -151,11 +151,11 @@ HRESULT XMLParser::ConvertEscape()
else if ( ( m_Ch >= 'A' ) && ( m_Ch <= 'F' ) )
{
wVal += m_Ch - 'A' + 10;
}
}
else
{
Error( E_INVALID_XML_SYNTAX, "Expected hex digit as part of &#x escape sequence" );
return E_INVALID_XML_SYNTAX;
Error( E_INVALID_XML_SYNTAX, "Expected hex digit as part of &#x escape sequence" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCharacter() ) )
@@ -165,7 +165,7 @@ HRESULT XMLParser::ConvertEscape()
else // decimal number
{
while ( m_Ch != ';' )
{
{
wVal *= 10;
if ( ( m_Ch >= '0' ) && ( m_Ch <= '9' ) )
@@ -174,7 +174,7 @@ HRESULT XMLParser::ConvertEscape()
}
else
{
Error( E_INVALID_XML_SYNTAX, "Expected decimal digit as part of &# escape sequence" );
Error( E_INVALID_XML_SYNTAX, "Expected decimal digit as part of &# escape sequence" );
return E_INVALID_XML_SYNTAX;
}
@@ -187,7 +187,7 @@ HRESULT XMLParser::ConvertEscape()
m_Ch = wVal;
return S_OK;
}
}
// must be an entity reference
@@ -197,13 +197,13 @@ HRESULT XMLParser::ConvertEscape()
SkipNextAdvance();
if( FAILED( hr = AdvanceName() ) )
return hr;
EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal );
m_pWritePtr = pEntityRefVal;
if ( EntityRefLen == 0 )
{
Error( E_INVALID_XML_SYNTAX, "Expecting entity name after &" );
Error( E_INVALID_XML_SYNTAX, "Expecting entity name after &" );
return E_INVALID_XML_SYNTAX;
}
@@ -219,7 +219,7 @@ HRESULT XMLParser::ConvertEscape()
wVal = '"';
else
{
Error( E_INVALID_XML_SYNTAX, "Unrecognized entity name after & - (should be lt, gt, amp, apos, or quot)" );
Error( E_INVALID_XML_SYNTAX, "Unrecognized entity name after & - (should be lt, gt, amp, apos, or quot)" );
return E_INVALID_XML_SYNTAX; // return false if unrecognized token sequence
}
@@ -228,10 +228,10 @@ HRESULT XMLParser::ConvertEscape()
if( m_Ch != ';' )
{
Error( E_INVALID_XML_SYNTAX, "Expected terminating ; for entity reference" );
Error( E_INVALID_XML_SYNTAX, "Expected terminating ; for entity reference" );
return E_INVALID_XML_SYNTAX; // malformed reference - needs terminating ;
}
m_Ch = wVal;
return S_OK;
}
@@ -250,41 +250,41 @@ HRESULT XMLParser::AdvanceAttrVal()
return hr;
if( ( m_Ch != '"' ) && ( m_Ch != '\'' ) )
{
Error( E_INVALID_XML_SYNTAX, "Attribute values must be enclosed in quotes" );
{
Error( E_INVALID_XML_SYNTAX, "Attribute values must be enclosed in quotes" );
return E_INVALID_XML_SYNTAX;
}
wQuoteChar = m_Ch;
for( ;; )
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
else if( m_Ch == wQuoteChar )
break;
return hr;
else if( m_Ch == wQuoteChar )
break;
else if( m_Ch == '&' )
{
SkipNextAdvance();
if( FAILED( hr = ConvertEscape() ) )
return hr;
return hr;
}
else if( m_Ch == '<' )
else if( m_Ch == '<' )
{
Error( E_INVALID_XML_SYNTAX, "Illegal character '<' in element tag" );
return E_INVALID_XML_SYNTAX;
Error( E_INVALID_XML_SYNTAX, "Illegal character '<' in element tag" );
return E_INVALID_XML_SYNTAX;
}
// copy character into the buffer
if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE )
if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE )
{
Error( E_INVALID_XML_SYNTAX, "Total element tag size may not be more than %d characters", XML_WRITE_BUFFER_SIZE );
return E_INVALID_XML_SYNTAX;
Error( E_INVALID_XML_SYNTAX, "Total element tag size may not be more than %d characters", XML_WRITE_BUFFER_SIZE );
return E_INVALID_XML_SYNTAX;
}
*m_pWritePtr = m_Ch;
m_pWritePtr++;
m_pWritePtr++;
}
return S_OK;
}
@@ -296,18 +296,18 @@ HRESULT XMLParser::AdvanceAttrVal()
// Ignores leading whitespace. Currently does not support unicode names
//-------------------------------------------------------------------------------------
HRESULT XMLParser::AdvanceName()
{
{
HRESULT hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
return hr;
if( ( ( m_Ch < 'A' ) || ( m_Ch > 'Z' ) ) &&
( ( m_Ch < 'a' ) || ( m_Ch > 'z' ) ) &&
( m_Ch != '_' ) && ( m_Ch != ':' ) )
{
Error( E_INVALID_XML_SYNTAX, "Names must start with an alphabetic character or _ or :" );
return E_INVALID_XML_SYNTAX;
Error( E_INVALID_XML_SYNTAX, "Names must start with an alphabetic character or _ or :" );
return E_INVALID_XML_SYNTAX;
}
while( ( ( m_Ch >= 'A' ) && ( m_Ch <= 'Z' ) ) ||
@@ -319,17 +319,17 @@ HRESULT XMLParser::AdvanceName()
if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE )
{
Error( E_INVALID_XML_SYNTAX, "Total element tag size may not be more than %d characters", XML_WRITE_BUFFER_SIZE );
Error( E_INVALID_XML_SYNTAX, "Total element tag size may not be more than %d characters", XML_WRITE_BUFFER_SIZE );
return E_INVALID_XML_SYNTAX;
}
}
*m_pWritePtr = m_Ch;
m_pWritePtr++;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
return hr;
}
SkipNextAdvance();
return S_OK;
}
@@ -343,7 +343,7 @@ HRESULT XMLParser::AdvanceName()
// Returns S_OK if there are more characters, E_ABORT for no characters to read
//-------------------------------------------------------------------------------------
HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail )
{
{
if( m_bSkipNextAdvance )
{
m_bSkipNextAdvance = FALSE;
@@ -351,20 +351,20 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail )
}
// If we hit EOF in the middle of a character,
// it's ok-- we'll just have a corrupt last character
// it's ok-- we'll just have a corrupt last character
// (the buffer is padded with double NULLs )
if ( ( m_pReadPtr[0] == '\0' ) && ( m_pReadPtr[1] == '\0' ) )
{
// Read more from the file
FillBuffer();
FillBuffer();
// We are at EOF if it is still NULL
if ( ( m_pReadPtr[0] == '\0' ) && ( m_pReadPtr[1] == '\0' ) )
{
if( !bOkToFail )
{
Error( E_INVALID_XML_SYNTAX, "Unexpected EOF while parsing XML file" );
Error( E_INVALID_XML_SYNTAX, "Unexpected EOF while parsing XML file" );
return E_INVALID_XML_SYNTAX;
}
else
@@ -372,7 +372,7 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail )
return E_FAIL;
}
}
}
}
if( m_bUnicode == FALSE )
{
@@ -382,13 +382,13 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail )
else // if( m_bUnicode == TRUE )
{
m_Ch = *((WCHAR *)m_pReadPtr);
if( m_bReverseBytes )
{
m_Ch = ( m_Ch << 8 ) + ( m_Ch >> 8 );
}
m_pReadPtr += 2;
m_pReadPtr += 2;
}
if( m_Ch == '\n' )
@@ -398,114 +398,114 @@ HRESULT XMLParser::AdvanceCharacter( BOOL bOkToFail )
}
else if( m_Ch != '\r' )
m_pISAXCallback->m_LinePos++;
return S_OK;
}
//-------------------------------------------------------------------------------------
// Name: XMLParser::AdvanceElement
// Desc: Builds <element> data, calls callback
// Desc: Builds <element> data, calls callback
//-------------------------------------------------------------------------------------
HRESULT XMLParser::AdvanceElement()
{
{
HRESULT hr;
// write ptr at the beginning of the buffer
m_pWritePtr = m_pWriteBuf;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
return hr;
// if first character wasn't '<', we wouldn't be here
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
return hr;
if( m_Ch == '!' )
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if ( m_Ch == '-' )
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != '-' )
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != '-' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '-' after '<!-'" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceComment() ) )
return hr;
if( FAILED( hr = AdvanceComment() ) )
return hr;
return S_OK;
}
if( m_Ch != '[' )
if( m_Ch != '[' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '<![CDATA['" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'C' )
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'C' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '<![CDATA['" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'D' )
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'D' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '<![CDATA['" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'A' )
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'A' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '<![CDATA['" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'T' )
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'T' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '<![CDATA['" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'A' )
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != 'A' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '<![CDATA['" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != '[' )
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != '[' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '<![CDATA['" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = AdvanceCDATA() ) )
if( FAILED( hr = AdvanceCDATA() ) )
return hr;
}
else if( m_Ch == '/' )
else if( m_Ch == '/' )
{
WCHAR *pEntityRefVal = m_pWritePtr;
if( FAILED( hr = AdvanceName() ) )
if( FAILED( hr = AdvanceName() ) )
return hr;
if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal,
if( FAILED( m_pISAXCallback->ElementEnd( pEntityRefVal,
(UINT) ( m_pWritePtr - pEntityRefVal ) ) ) )
return E_ABORT;
if( FAILED( hr = ConsumeSpace() ) )
if( FAILED( hr = ConsumeSpace() ) )
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != '>' )
{
@@ -513,42 +513,42 @@ HRESULT XMLParser::AdvanceElement()
return E_INVALID_XML_SYNTAX;
}
}
else if( m_Ch == '?' )
else if( m_Ch == '?' )
{
// just skip any xml header tag since not really important after identifying character set
for( ;; )
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if ( m_Ch == '>' )
return S_OK;
}
}
else
{
XMLAttribute Attributes[ XML_MAX_ATTRIBUTES_PER_ELEMENT ];
XMLAttribute Attributes[ XML_MAX_ATTRIBUTES_PER_ELEMENT ];
UINT NumAttrs;
WCHAR *pEntityRefVal = m_pWritePtr;
UINT EntityRefLen;
NumAttrs = 0;
SkipNextAdvance();
// Entity tag
if( FAILED( hr = AdvanceName() ) )
if( FAILED( hr = AdvanceName() ) )
return hr;
EntityRefLen = (UINT)( m_pWritePtr - pEntityRefVal );
if( FAILED( hr = ConsumeSpace() ) )
if( FAILED( hr = ConsumeSpace() ) )
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
return hr;
// read attributes
while( ( m_Ch != '>' ) && ( m_Ch != '/' ) )
{
@@ -556,31 +556,31 @@ HRESULT XMLParser::AdvanceElement()
if ( NumAttrs >= XML_MAX_ATTRIBUTES_PER_ELEMENT )
{
Error( E_INVALID_XML_SYNTAX, "Elements may not have more than %d attributes", XML_MAX_ATTRIBUTES_PER_ELEMENT );
return E_INVALID_XML_SYNTAX;
Error( E_INVALID_XML_SYNTAX, "Elements may not have more than %d attributes", XML_MAX_ATTRIBUTES_PER_ELEMENT );
return E_INVALID_XML_SYNTAX;
}
Attributes[ NumAttrs ].strName = m_pWritePtr;
// Attribute name
if( FAILED( hr = AdvanceName() ) )
return hr;
Attributes[ NumAttrs ].NameLen = (UINT)( m_pWritePtr - Attributes[ NumAttrs ].strName );
if( FAILED( hr = ConsumeSpace() ) )
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if( m_Ch != '=' )
if( m_Ch != '=' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '=' character after attribute name" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( hr = ConsumeSpace() ) )
if( FAILED( hr = ConsumeSpace() ) )
return hr;
Attributes[ NumAttrs ].strValue = m_pWritePtr;
@@ -588,29 +588,29 @@ HRESULT XMLParser::AdvanceElement()
if( FAILED( hr = AdvanceAttrVal() ) )
return hr;
Attributes[ NumAttrs ].ValueLen = (UINT)( m_pWritePtr -
Attributes[ NumAttrs ].ValueLen = (UINT)( m_pWritePtr -
Attributes[ NumAttrs ].strValue );
++NumAttrs;
if( FAILED( hr = ConsumeSpace() ) )
return hr;
return hr;
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
return hr;
}
if( m_Ch == '/' )
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
return hr;
if( m_Ch != '>' )
{
Error( E_INVALID_XML_SYNTAX, "Expecting '>' after '/' in element tag" );
return E_INVALID_XML_SYNTAX;
}
if( FAILED( m_pISAXCallback->ElementBegin( pEntityRefVal, EntityRefLen,
if( FAILED( m_pISAXCallback->ElementBegin( pEntityRefVal, EntityRefLen,
Attributes, NumAttrs ) ) )
return E_ABORT;
@@ -619,7 +619,7 @@ HRESULT XMLParser::AdvanceElement()
}
else
{
if( FAILED( m_pISAXCallback->ElementBegin( pEntityRefVal, EntityRefLen,
if( FAILED( m_pISAXCallback->ElementBegin( pEntityRefVal, EntityRefLen,
Attributes, NumAttrs ) ) )
return E_ABORT;
}
@@ -637,7 +637,7 @@ HRESULT XMLParser::AdvanceCDATA()
{
HRESULT hr;
WORD wStage = 0;
if( FAILED( m_pISAXCallback->CDATABegin() ) )
return E_ABORT;
@@ -645,10 +645,10 @@ HRESULT XMLParser::AdvanceCDATA()
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
*m_pWritePtr = m_Ch;
m_pWritePtr++;
if( ( m_Ch == ']' ) && ( wStage == 0 ) )
wStage = 1;
else if( ( m_Ch == ']' ) && ( wStage == 1 ) )
@@ -666,9 +666,9 @@ HRESULT XMLParser::AdvanceCDATA()
if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), TRUE ) ) )
return E_ABORT;
m_pWritePtr = m_pWriteBuf;
}
}
}
if( FAILED( m_pISAXCallback->CDATAData( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
return E_ABORT;
@@ -676,7 +676,7 @@ HRESULT XMLParser::AdvanceCDATA()
if( FAILED( m_pISAXCallback->CDATAEnd() ) )
return E_ABORT;
return S_OK;
}
@@ -694,24 +694,24 @@ HRESULT XMLParser::AdvanceComment()
{
if( FAILED( hr = AdvanceCharacter() ) )
return hr;
if (( m_Ch == '-' ) && ( wStage == 0 ))
wStage = 1;
else if (( m_Ch == '-' ) && ( wStage == 1 ))
wStage = 2;
else if (( m_Ch == '>' ) && ( wStage == 2 ))
break;
else if (( m_Ch == '>' ) && ( wStage == 2 ))
break;
else
wStage = 0;
wStage = 0;
}
return S_OK;
}
//-------------------------------------------------------------------------------------
// Name: XMLParser::RegisterSAXCallbackInterface
// Desc: Registers callback interface
// Desc: Registers callback interface
//-------------------------------------------------------------------------------------
VOID XMLParser::RegisterSAXCallbackInterface( ISAXCallback *pISAXCallback )
{
@@ -721,7 +721,7 @@ VOID XMLParser::RegisterSAXCallbackInterface( ISAXCallback *pISAXCallback )
//-------------------------------------------------------------------------------------
// Name: XMLParser::GetSAXCallbackInterface
// Desc: Returns current callback interface
// Desc: Returns current callback interface
//-------------------------------------------------------------------------------------
ISAXCallback* XMLParser::GetSAXCallbackInterface()
{
@@ -740,7 +740,7 @@ HRESULT XMLParser::MainParseLoop()
if( FAILED( m_pISAXCallback->StartDocument() ) )
return E_ABORT;
m_pWritePtr = m_pWriteBuf;
FillBuffer();
@@ -751,57 +751,57 @@ HRESULT XMLParser::MainParseLoop()
m_bReverseBytes = FALSE;
m_pReadPtr += 2;
}
else if ( *((WCHAR *) m_pReadBuf ) == 0xFFFE )
else if ( *((WCHAR *) m_pReadBuf ) == 0xFFFE )
{
m_bUnicode = TRUE;
m_bReverseBytes = TRUE;
m_pReadPtr += 2;
m_pReadPtr += 2;
}
else if ( *((WCHAR *) m_pReadBuf ) == 0x003C )
{
m_bUnicode = TRUE;
m_bReverseBytes = FALSE;
}
else if ( *((WCHAR *) m_pReadBuf ) == 0x3C00 )
else if ( *((WCHAR *) m_pReadBuf ) == 0x003C )
{
m_bUnicode = TRUE;
m_bReverseBytes = TRUE;
m_bReverseBytes = FALSE;
}
else if ( *((WCHAR *) m_pReadBuf ) == 0x3C00 )
{
m_bUnicode = TRUE;
m_bReverseBytes = TRUE;
}
else if ( m_pReadBuf[ 0 ] == 0x3C )
{
m_bUnicode = FALSE;
m_bReverseBytes = FALSE;
m_bUnicode = FALSE;
m_bReverseBytes = FALSE;
}
else
{
{
Error( E_INVALID_XML_SYNTAX, "Unrecognized encoding (parser does not support UTF-8 language encodings)" );
return E_INVALID_XML_SYNTAX;
return E_INVALID_XML_SYNTAX;
}
for( ;; )
{
if( FAILED( AdvanceCharacter( TRUE ) ) )
{
if ( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) )
{
if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
return E_ABORT;
{
if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
return E_ABORT;
bWhiteSpaceOnly = TRUE;
}
if( FAILED( m_pISAXCallback->EndDocument() ) )
return E_ABORT;
return S_OK;
return S_OK;
}
if( m_Ch == '<' )
{
if( ( (UINT) ( m_pWritePtr - m_pWriteBuf ) != 0 ) && ( !bWhiteSpaceOnly ) )
{
if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
return E_ABORT;
{
if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf, (UINT)( m_pWritePtr - m_pWriteBuf ), FALSE ) ) )
return E_ABORT;
bWhiteSpaceOnly = TRUE;
}
@@ -810,45 +810,45 @@ HRESULT XMLParser::MainParseLoop()
m_pWritePtr = m_pWriteBuf;
if( FAILED( hr = AdvanceElement() ) )
return hr;
if( FAILED( hr = AdvanceElement() ) )
return hr;
m_pWritePtr = m_pWriteBuf;
}
else
else
{
if( m_Ch == '&' )
{
SkipNextAdvance();
if( FAILED( hr = ConvertEscape() ) )
return hr;
if( FAILED( hr = ConvertEscape() ) )
return hr;
}
if( bWhiteSpaceOnly && ( m_Ch != ' ' ) && ( m_Ch != '\n' ) && ( m_Ch != '\r' ) &&
( m_Ch != '\t' ) )
if( bWhiteSpaceOnly && ( m_Ch != ' ' ) && ( m_Ch != '\n' ) && ( m_Ch != '\r' ) &&
( m_Ch != '\t' ) )
{
bWhiteSpaceOnly = FALSE;
}
*m_pWritePtr = m_Ch;
m_pWritePtr++;
if( m_pWritePtr - m_pWriteBuf >= XML_WRITE_BUFFER_SIZE )
{
if( !bWhiteSpaceOnly )
{
if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf,
( UINT ) ( m_pWritePtr - m_pWriteBuf ),
{
if( FAILED( m_pISAXCallback->ElementContent( m_pWriteBuf,
( UINT ) ( m_pWritePtr - m_pWriteBuf ),
TRUE ) ) )
{
return E_ABORT;
return E_ABORT;
}
}
m_pWritePtr = m_pWriteBuf;
bWhiteSpaceOnly = TRUE;
}
}
}
}
}
@@ -858,36 +858,36 @@ HRESULT XMLParser::MainParseLoop()
// Desc: Builds element data
//-------------------------------------------------------------------------------------
HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename )
{
{
HRESULT hr;
if( m_pISAXCallback == NULL )
return E_NOINTERFACE;
m_pISAXCallback->m_LineNum = 1;
m_pISAXCallback->m_LineNum = 1;
m_pISAXCallback->m_LinePos = 0;
m_pISAXCallback->m_strFilename = strFilename; // save this off only while we parse the file
m_bSkipNextAdvance = FALSE;
m_pReadPtr = m_pReadBuf;
m_pReadPtr = m_pReadBuf;
m_pReadBuf[ 0 ] = '\0';
m_pReadBuf[ 1 ] = '\0';
m_pReadBuf[ 1 ] = '\0';
m_pInXMLBuffer = NULL;
m_uInXMLBufferCharsLeft = 0;
WCHAR wchFilename[ 64 ];
swprintf_s(wchFilename,64,L"%s",strFilename);
m_hFile = CreateFile( wchFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL );
m_hFile = CreateFile( wchFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL );
if( m_hFile == INVALID_HANDLE_VALUE )
{
{
Error( E_COULD_NOT_OPEN_FILE, "Error opening file" );
hr = E_COULD_NOT_OPEN_FILE;
}
else
{
@@ -897,14 +897,14 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename )
m_dwCharsConsumed = 0;
hr = MainParseLoop();
}
// Close the file
if( m_hFile != INVALID_HANDLE_VALUE )
CloseHandle( m_hFile );
m_hFile = INVALID_HANDLE_VALUE;
// we no longer own strFilename, so un-set it
m_pISAXCallback->m_strFilename = NULL;
m_pISAXCallback->m_strFilename = NULL;
return hr;
}
@@ -914,38 +914,38 @@ HRESULT XMLParser::ParseXMLFile( CONST CHAR *strFilename )
// Desc: Builds element data
//-------------------------------------------------------------------------------------
HRESULT XMLParser::ParseXMLBuffer( CONST CHAR *strBuffer, UINT uBufferSize )
{
{
HRESULT hr;
if( m_pISAXCallback == NULL )
return E_NOINTERFACE;
m_pISAXCallback->m_LineNum = 1;
m_pISAXCallback->m_LineNum = 1;
m_pISAXCallback->m_LinePos = 0;
m_pISAXCallback->m_strFilename = ""; // save this off only while we parse the file
m_bSkipNextAdvance = FALSE;
m_pReadPtr = m_pReadBuf;
m_pReadBuf[ 0 ] = '\0';
m_pReadBuf[ 1 ] = '\0';
m_pReadBuf[ 1 ] = '\0';
m_hFile = NULL;
m_pInXMLBuffer = strBuffer;
m_uInXMLBufferCharsLeft = uBufferSize;
m_dwCharsTotal = uBufferSize;
m_dwCharsConsumed = 0;
hr = MainParseLoop();
// we no longer own strFilename, so un-set it
m_pISAXCallback->m_strFilename = NULL;
m_pISAXCallback->m_strFilename = NULL;
return hr;
}
//-------------------------------------------------------------------------------------
// XMLParser::Error()
// XMLParser::Error()
// Logs an error through the callback interface
//-------------------------------------------------------------------------------------
#ifdef _Printf_format_string_ // VC++ 2008 and later support this annotation
@@ -960,7 +960,7 @@ VOID XMLParser::Error( HRESULT hErr, CONST CHAR* strFormat, ... )
va_start( pArglist, strFormat );
vsprintf( strBuffer, strFormat, pArglist );
m_pISAXCallback->Error( hErr, strBuffer );
va_end( pArglist );
}