Skip to content
Permalink
Browse files

CRemoteCall tweaks. Incremented NET_MODULE_VERSION

  • Loading branch information...
ccw808 committed Jul 7, 2019
1 parent 764664d commit e77c8cd0af4eb1accce74c843f89dc793f4287c4
@@ -235,6 +235,11 @@ void CRemoteCall::DownloadFinishedCallback(const SHttpDownloadResult& result)
CRemoteCall* pCall = (CRemoteCall*)result.pObj;
if (!g_pClientGame->GetRemoteCalls()->CallExists(pCall))
return;

// Save final download status
pCall->m_lastDownloadStatus.uiAttemptNumber = result.uiAttemptNumber;
pCall->m_lastDownloadStatus.uiContentLength = result.uiContentLength;
pCall->m_lastDownloadStatus.uiBytesReceived = result.dataSize;
pCall->m_downloadMode = EDownloadModeType::NONE;

CLuaArguments arguments;
@@ -306,13 +311,15 @@ bool CRemoteCall::CancelDownload()
return false;
}

// Return true if outDownloadStatus contains valid data
bool CRemoteCall::GetDownloadStatus(SDownloadStatus& outDownloadStatus)
const SDownloadStatus& CRemoteCall::GetDownloadStatus()
{
if (m_downloadMode != EDownloadModeType::NONE)
{
return g_pNet->GetHTTPDownloadManager(m_downloadMode)->GetDownloadStatus(this, DownloadFinishedCallback, outDownloadStatus);
SDownloadStatus newDownloadStatus;
if (g_pNet->GetHTTPDownloadManager(m_downloadMode)->GetDownloadStatus(this, DownloadFinishedCallback, newDownloadStatus))
{
m_lastDownloadStatus = newDownloadStatus;
}
}
outDownloadStatus = {0};
return false;
return m_lastDownloadStatus;
}
@@ -28,6 +28,7 @@ class CRemoteCall
CLuaArguments m_FetchArguments;
SHttpRequestOptions m_options;
EDownloadModeType m_downloadMode = EDownloadModeType::NONE;
SDownloadStatus m_lastDownloadStatus;

public:
CRemoteCall(const char* szServerHost, const char* szResourceName, const char* szFunctionName, CLuaArguments* arguments, CLuaMain* luaMain,
@@ -42,7 +43,7 @@ class CRemoteCall
void MakeCall();
static void DownloadFinishedCallback(const SHttpDownloadResult& result);
bool CancelDownload();
bool GetDownloadStatus(SDownloadStatus& outDownloadStatus);
const SDownloadStatus& GetDownloadStatus();
CLuaMain* GetVM() { return m_VM; };
bool IsFetch() { return m_bIsFetch; }
bool IsLegacy() { return m_options.bIsLegacy; }
@@ -72,7 +72,7 @@

#define _ASE_VERSION QUOTE_DEFINE(MTASA_VERSION_MAJOR) "." QUOTE_DEFINE(MTASA_VERSION_MINOR)
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
#define _CLIENT_NET_MODULE_VERSION 0x0AA // (0x000 - 0xfff) Lvl9 wizards only
#define _CLIENT_NET_MODULE_VERSION 0x0AB // (0x000 - 0xfff) Lvl9 wizards only
#define _NETCODE_VERSION 0x1DA // (0x000 - 0xfff) Increment when net messages change (pre-release)
#define MTA_DM_BITSTREAM_VERSION 0x06C // (0x000 - 0xfff) Increment when net messages change (post-release). (Changing will also require additional backward compatibility code).

@@ -230,6 +230,11 @@ void CRemoteCall::DownloadFinishedCallback(const SHttpDownloadResult& result)
CRemoteCall* pCall = (CRemoteCall*)result.pObj;
if (!g_pGame->GetRemoteCalls()->CallExists(pCall))
return;

// Save final download status
pCall->m_lastDownloadStatus.uiAttemptNumber = result.uiAttemptNumber;
pCall->m_lastDownloadStatus.uiContentLength = result.uiContentLength;
pCall->m_lastDownloadStatus.uiBytesReceived = result.dataSize;
pCall->m_downloadMode = EDownloadModeType::NONE;

CLuaArguments arguments;
@@ -301,13 +306,15 @@ bool CRemoteCall::CancelDownload()
return false;
}

// Return true if outDownloadStatus contains valid data
bool CRemoteCall::GetDownloadStatus(SDownloadStatus& outDownloadStatus)
const SDownloadStatus& CRemoteCall::GetDownloadStatus()
{
if (m_downloadMode != EDownloadModeType::NONE)
{
return g_pNetServer->GetHTTPDownloadManager(m_downloadMode)->GetDownloadStatus(this, DownloadFinishedCallback, outDownloadStatus);
SDownloadStatus newDownloadStatus;
if (g_pNetServer->GetHTTPDownloadManager(m_downloadMode)->GetDownloadStatus(this, DownloadFinishedCallback, newDownloadStatus))
{
m_lastDownloadStatus = newDownloadStatus;
}
}
outDownloadStatus = {0};
return false;
return m_lastDownloadStatus;
}
@@ -28,6 +28,7 @@ class CRemoteCall
CLuaArguments m_FetchArguments;
SHttpRequestOptions m_options;
EDownloadModeType m_downloadMode = EDownloadModeType::NONE;
SDownloadStatus m_lastDownloadStatus;

public:
CRemoteCall(const char* szServerHost, const char* szResourceName, const char* szFunctionName, CLuaArguments* arguments, CLuaMain* luaMain,
@@ -42,7 +43,7 @@ class CRemoteCall
void MakeCall();
static void DownloadFinishedCallback(const SHttpDownloadResult& result);
bool CancelDownload();
bool GetDownloadStatus(SDownloadStatus& outDownloadStatus);
const SDownloadStatus& GetDownloadStatus();
CLuaMain* GetVM() { return m_VM; };
bool IsFetch() { return m_bIsFetch; }
bool IsLegacy() { return m_options.bIsLegacy; }
@@ -75,7 +75,7 @@

#define _ASE_VERSION QUOTE_DEFINE(MTASA_VERSION_MAJOR) "." QUOTE_DEFINE(MTASA_VERSION_MINOR)
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
#define _SERVER_NET_MODULE_VERSION 0x0AA // (0x000 - 0xfff) Lvl9 wizards only
#define _SERVER_NET_MODULE_VERSION 0x0AB // (0x000 - 0xfff) Lvl9 wizards only
#define _NETCODE_VERSION 0x1DA // (0x000 - 0xfff) Increment when net messages change (pre-release)
#define MTA_DM_BITSTREAM_VERSION 0x06C // (0x000 - 0xfff) Increment when net messages change (post-release). (Changing will also require additional backward compatibility code).

@@ -40,6 +40,8 @@ struct SHttpDownloadResult
bool bSuccess;
int iErrorCode;
const char* szHeaders;
uint uiAttemptNumber;
uint uiContentLength;
};

// For transferring SString to net module
@@ -145,9 +147,9 @@ inline SHttpRequestOptionsTx::SHttpRequestOptionsTx(const SHttpRequestOptions& i

struct SDownloadStatus
{
uint uiAttemptNumber; // 0=Queued 1+=Downloading
uint uiContentLength; // Item total size. Will be 0 if http header 'Content-Length' is missing
uint uiBytesReceived; // Download progress
uint uiAttemptNumber = 0; // 0=Queued 1+=Downloading
uint uiContentLength = 0; // Item total size. Will be 0 if http header 'Content-Length' is missing
uint uiBytesReceived = 0; // Download progress
};

// PFN_DOWNLOAD_FINISHED_CALLBACK is called once at the end of the download.

0 comments on commit e77c8cd

Please sign in to comment.
You can’t perform that action at this time.