[Scummvm-git-logs] scummvm master -> 77ee206cd7fc5cf98861a3aa1a579e40ad3c872d
sev-
sev at scummvm.org
Tue Nov 5 00:32:43 CET 2019
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e94e85a1ed SCUMM HE: MBC: Implemented function return from remote client
5268e582bf SCUMM HE: MBC: Properly thread async requests
77ee206cd7 SCUMM HE: MBC: Implement Net::disableSessionJoining()
Commit: e94e85a1eda3110cc709905429f804ab4bad478c
https://github.com/scummvm/scummvm/commit/e94e85a1eda3110cc709905429f804ab4bad478c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-11-05T00:31:46+01:00
Commit Message:
SCUMM HE: MBC: Implemented function return from remote client
Changed paths:
engines/scumm/he/moonbase/net_main.cpp
engines/scumm/he/moonbase/net_main.h
diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp
index 303697b..28f865f 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -256,7 +256,7 @@ int32 Net::setProviderByName(int32 parameter1, int32 parameter2) {
void Net::setFakeLatency(int time) {
_latencyTime = time;
- debug("NETWORK: Setting Fake Latency to %d ms \n", _latencyTime); // TODO: is it OK to use debug instead of SPUTM_xprintf?
+ debug("NETWORK: Setting Fake Latency to %d ms", _latencyTime);
_fakeLatency = true;
}
@@ -304,13 +304,14 @@ void Net::startQuerySessionsErrorCallback(Networking::ErrorResponse error) {
}
int32 Net::updateQuerySessions() {
- warning("STUB: Net::updateQuerySessions()"); // UpdateQuerySessions
+ debug(1, "Net::updateQuerySessions()"); // UpdateQuerySessions
return startQuerySessions();
}
void Net::stopQuerySessions() {
debug(1, "Net::stopQuerySessions()"); // StopQuerySessions
+ _sessionsBeingQueried = false;
// No op
}
@@ -374,7 +375,7 @@ void Net::remoteStartScript(int typeOfSend, int sendTypeParam, int priority, int
remoteSendData(typeOfSend, sendTypeParam, PACKETTYPE_REMOTESTARTSCRIPT, res);
}
-int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, Common::String data, int defaultRes, bool wait) {
+int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, Common::String data, int defaultRes, bool wait, int callid) {
// Since I am lazy, instead of constructing the JSON object manually
// I'd rather parse it
Common::String res = Common::String::format(
@@ -399,8 +400,18 @@ int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, Common::Str
if (!wait)
return 0;
- while(rq.state() == Networking::PROCESSING) {
- g_system->delayMillis(5);
+ int timeout = g_system->getMillis() + 1000;
+
+ while (g_system->getMillis() < timeout) {
+ if (remoteReceiveData()) {
+ if (_packetdata->child("data")->hasChild("callid")) {
+ if (_packetdata->child("data")->child("callid")->asIntegerNumber() == callid) {
+ return _packetdata->child("data")->child("result")->asIntegerNumber();
+ }
+ }
+
+ warning("Net::remoteSendData(): Received wrong package: %s", _packetdata->stringify().c_str());
+ }
_vm->parseEvents();
}
@@ -413,8 +424,6 @@ int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, Common::Str
void Net::remoteSendDataCallback(Common::JSONValue *response) {
debug(1, "remoteSendData: Got: '%s'", response->stringify().c_str());
-
- _sessions = new Common::JSONValue(*response);
}
void Net::remoteSendDataErrorCallback(Networking::ErrorResponse error) {
@@ -466,7 +475,9 @@ void Net::remoteSendArray(int typeOfSend, int sendTypeParam, int priority, int a
}
int Net::remoteStartScriptFunction(int typeOfSend, int sendTypeParam, int priority, int defaultReturnValue, int argsCount, int32 *args) {
- Common::String res = "\"params\": [";
+ int callid = _vm->_rnd.getRandomNumber(1000000);
+
+ Common::String res = Common::String::format("\"callid\":%d, \"params\": [", callid);
if (argsCount > 2)
for (int i = 0; i < argsCount - 1; i++)
@@ -479,7 +490,7 @@ int Net::remoteStartScriptFunction(int typeOfSend, int sendTypeParam, int priori
debug(1, "Net::remoteStartScriptFunction(%d, %d, %d, %d, %d, ...)", typeOfSend, sendTypeParam, priority, defaultReturnValue, argsCount); // PN_RemoteStartScriptFunction
- return remoteSendData(typeOfSend, sendTypeParam, PACKETTYPE_REMOTESTARTSCRIPTRETURN, res, defaultReturnValue, true);
+ return remoteSendData(typeOfSend, sendTypeParam, PACKETTYPE_REMOTESTARTSCRIPTRETURN, res, defaultReturnValue, true, callid);
}
bool Net::getHostName(char *hostname, int length) {
@@ -590,7 +601,8 @@ bool Net::remoteReceiveData() {
_vm->runScript(_vm->VAR(_vm->VAR_REMOTE_START_SCRIPT), 1, 0, (int *)_tmpbuffer);
int result = _vm->pop();
- Common::String res = Common::String::format("\"result\": %d", result);
+ Common::String res = Common::String::format("\"result\": %d, \"callid\": %d", result,
+ (int)_packetdata->child("data")->child("callid")->asIntegerNumber());
remoteSendData(PN_SENDTYPE_INDIVIDUAL, from, PACKETTYPE_REMOTESTARTSCRIPTRESULT, res);
}
diff --git a/engines/scumm/he/moonbase/net_main.h b/engines/scumm/he/moonbase/net_main.h
index 54b5496..c23a0b0 100644
--- a/engines/scumm/he/moonbase/net_main.h
+++ b/engines/scumm/he/moonbase/net_main.h
@@ -61,7 +61,7 @@ public:
bool initSession();
bool initUser();
void remoteStartScript(int typeOfSend, int sendTypeParam, int priority, int argsCount, int32 *args);
- int remoteSendData(int typeOfSend, int sendTypeParam, int type, Common::String data, int defaultRes = 0, bool wait = false);
+ int remoteSendData(int typeOfSend, int sendTypeParam, int type, Common::String data, int defaultRes = 0, bool wait = false, int callid = 0);
void remoteSendArray(int typeOfSend, int sendTypeParam, int priority, int arrayIndex);
int remoteStartScriptFunction(int typeOfSend, int sendTypeParam, int priority, int defaultReturnValue, int argsCount, int32 *args);
void doNetworkOnceAFrame(int msecs);
Commit: 5268e582bf68aef3089a23de88e793f4d3292144
https://github.com/scummvm/scummvm/commit/5268e582bf68aef3089a23de88e793f4d3292144
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-11-05T00:31:46+01:00
Commit Message:
SCUMM HE: MBC: Properly thread async requests
Changed paths:
engines/scumm/he/moonbase/net_main.cpp
diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp
index 28f865f..f93f018 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "backends/networking/curl/connectionmanager.h"
+
#include "scumm/he/intern_he.h"
#include "scumm/he/moonbase/moonbase.h"
#include "scumm/he/moonbase/net_main.h"
@@ -270,13 +272,15 @@ int32 Net::startQuerySessions() {
if (!_sessionsBeingQueried) { // Do not run parallel queries
debug(1, "Net::startQuerySessions()"); // StartQuerySessions
- Networking::PostRequest rq(_serverprefix + "/lobbies",
+ Networking::PostRequest *rq = new Networking::PostRequest(_serverprefix + "/lobbies",
new Common::Callback<Net, Common::JSONValue *>(this, &Net::startQuerySessionsCallback),
new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::startQuerySessionsErrorCallback));
_sessionsBeingQueried = true;
- rq.start();
+ rq->start();
+
+ ConnMan.addRequest(rq);
}
if (!_sessions)
@@ -388,14 +392,16 @@ int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, Common::Str
debug("Package to send: %s", res.c_str());
- Networking::PostRequest rq(_serverprefix + "/packet",
+ Networking::PostRequest *rq = new Networking::PostRequest(_serverprefix + "/packet",
new Common::Callback<Net, Common::JSONValue *>(this, &Net::remoteSendDataCallback),
new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::remoteSendDataErrorCallback));
- rq.setPostData(buf, res.size());
- rq.setContentType("application/json");
+ rq->setPostData(buf, res.size());
+ rq->setContentType("application/json");
- rq.start();
+ rq->start();
+
+ ConnMan.addRequest(rq);
if (!wait)
return 0;
Commit: 77ee206cd7fc5cf98861a3aa1a579e40ad3c872d
https://github.com/scummvm/scummvm/commit/77ee206cd7fc5cf98861a3aa1a579e40ad3c872d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-11-05T00:31:46+01:00
Commit Message:
SCUMM HE: MBC: Implement Net::disableSessionJoining()
Changed paths:
engines/scumm/he/moonbase/net_main.cpp
engines/scumm/he/moonbase/net_main.h
diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp
index f93f018..4645f30 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -228,7 +228,27 @@ void Net::endSessionErrorCallback(Networking::ErrorResponse error) {
void Net::disableSessionJoining() {
- warning("STUB: Net::disableSessionJoining()"); // PN_DisableSessionPlayerJoin
+ debug(1, "Net::disableSessionJoining()"); // PN_DisableSessionPlayerJoin
+
+ Networking::PostRequest *rq = new Networking::PostRequest(_serverprefix + "/disablesession",
+ new Common::Callback<Net, Common::JSONValue *>(this, &Net::disableSessionJoiningCallback),
+ new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::disableSessionJoiningErrorCallback));
+
+ char *buf = (char *)malloc(MAX_PACKET_SIZE);
+ snprintf(buf, MAX_PACKET_SIZE, "{\"sessionid\":%d}", _sessionid);
+ rq->setPostData((byte *)buf, strlen(buf));
+ rq->setContentType("application/json");
+
+ rq->start();
+
+ ConnMan.addRequest(rq);
+}
+
+void Net::disableSessionJoiningCallback(Common::JSONValue *response) {
+}
+
+void Net::disableSessionJoiningErrorCallback(Networking::ErrorResponse error) {
+ warning("Error in disableSessionJoining(): %ld %s", error.httpResponseCode, error.response.c_str());
}
void Net::enableSessionJoining() {
diff --git a/engines/scumm/he/moonbase/net_main.h b/engines/scumm/he/moonbase/net_main.h
index c23a0b0..31dba67 100644
--- a/engines/scumm/he/moonbase/net_main.h
+++ b/engines/scumm/he/moonbase/net_main.h
@@ -78,6 +78,9 @@ private:
void addUserCallback(Common::JSONValue *response);
void addUserErrorCallback(Networking::ErrorResponse error);
+ void disableSessionJoiningCallback(Common::JSONValue *response);
+ void disableSessionJoiningErrorCallback(Networking::ErrorResponse error);
+
void endSessionCallback(Common::JSONValue *response);
void endSessionErrorCallback(Networking::ErrorResponse error);
More information about the Scummvm-git-logs
mailing list