[Scummvm-git-logs] scummvm master -> e2c7434aa8c5ae3e4ed390c63bd0207ee1d29765
sev-
sev at scummvm.org
Sun Oct 27 22:47:07 CET 2019
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a43381cf99 SCUMM HE: Fix network start at the game start
e2c7434aa8 SCUMM HE: Replace binary packet with JSON
Commit: a43381cf991fde13f7e190dd7cdd6fd235fb2af2
https://github.com/scummvm/scummvm/commit/a43381cf991fde13f7e190dd7cdd6fd235fb2af2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-27T21:42:07Z
Commit Message:
SCUMM HE: Fix network start at the game start
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 cd25a22..cef39c6 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -547,6 +547,11 @@ bool Net::remoteReceiveData() {
void Net::remoteReceiveDataCallback(Common::JSONValue *response) {
debug(1, "remoteReceiveData: Got: '%s'", response->stringify().c_str());
+ if (!response->hasChild("size")) {
+ warning("Net::remoteReceiveDataCallback(): invalid response");
+ return;
+ }
+
_packetsize = response->child("size")->asIntegerNumber();
if (!_packetsize)
@@ -565,6 +570,9 @@ void Net::unpackageArray(int arrayId, byte *data, int len) {
void Net::doNetworkOnceAFrame(int msecs) {
+ if (_sessionid == -1 || _myUserId == -1)
+ return;
+
uint32 tickCount = g_system->getMillis() + msecs;
while (remoteReceiveData()) {
Commit: e2c7434aa8c5ae3e4ed390c63bd0207ee1d29765
https://github.com/scummvm/scummvm/commit/e2c7434aa8c5ae3e4ed390c63bd0207ee1d29765
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-27T21:46:30Z
Commit Message:
SCUMM HE: Replace binary packet with JSON
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 cef39c6..ae143ee 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -333,27 +333,26 @@ void Net::remoteStartScript(int typeOfSend, int sendTypeParam, int priority, int
}
int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, byte *data, int len, int defaultRes) {
- byte *buf = (byte *)malloc(MAX_PACKET_SIZE + DATA_HEADER_SIZE);
- Common::MemoryWriteStream pack(buf, MAX_PACKET_SIZE + DATA_HEADER_SIZE);
+ // Since I am lazy, instead of constructing the JSON object manually
+ // I'd rather parse it
+ Common::String res = Common::String::format(
+ "{\"sessionid\":%d, \"userid\":%d, \"to\":%d, \"toparam\": %d, "
+ "\"type\":%d, \"timestamp\": %d, \"data\": [", _sessionid, _myUserId,
+ typeOfSend, sendTypeParam, type, g_system->getMillis());
- pack.writeUint32LE(_sessionid);
- pack.writeUint32LE(_myUserId);
- pack.writeUint32LE(typeOfSend);
- pack.writeUint32LE(sendTypeParam);
- pack.writeUint32LE(type);
- pack.writeUint32LE(len);
- pack.writeUint32LE(g_system->getMillis());
- pack.write(data, len);
+ for (int i = 0; i < len - 1; i++)
+ res += Common::String::format("%d, ", data[i]);
- debug("Package to send, to: %d (%d), %d(%x) bytes", typeOfSend, sendTypeParam, len + DATA_HEADER_SIZE, len);
+ res += Common::String::format("%d] }", data[len - 1]);
- Common::hexdump(buf, len + DATA_HEADER_SIZE);
+ debug("Package to send: %s", res.c_str());
Networking::PostRequest rq(_serverprefix + "/packet",
new Common::Callback<Net, Common::JSONValue *>(this, &Net::remoteSendDataCallback),
new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::remoteSendDataErrorCallback));
- rq.setPostData(buf, len + DATA_HEADER_SIZE);
+ rq.setPostData((byte *)res.c_str(), res.size());
+ rq.setContentType("application/json");
rq.start();
More information about the Scummvm-git-logs
mailing list