aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-27 21:46:30 +0000
committerEugene Sandulenko2019-10-27 21:46:30 +0000
commite2c7434aa8c5ae3e4ed390c63bd0207ee1d29765 (patch)
treedc2ad53ffa3a1365c2b56b280cf8721ab03d25c4 /engines/scumm/he
parenta43381cf991fde13f7e190dd7cdd6fd235fb2af2 (diff)
downloadscummvm-rg350-e2c7434aa8c5ae3e4ed390c63bd0207ee1d29765.tar.gz
scummvm-rg350-e2c7434aa8c5ae3e4ed390c63bd0207ee1d29765.tar.bz2
scummvm-rg350-e2c7434aa8c5ae3e4ed390c63bd0207ee1d29765.zip
SCUMM HE: Replace binary packet with JSON
Diffstat (limited to 'engines/scumm/he')
-rw-r--r--engines/scumm/he/moonbase/net_main.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp
index cef39c6ad1..ae143ee540 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();