aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2019-10-25 13:04:03 +0100
committerEugene Sandulenko2019-10-26 21:05:46 +0100
commited5901c36ddc770e6d651bdd5df21b73d36fe188 (patch)
tree1757ea438fed6708b8f5a53a9293ce777d6cae5d /engines
parentd7a296544ca6a896bdaed5480ad3004dc3131f44 (diff)
downloadscummvm-rg350-ed5901c36ddc770e6d651bdd5df21b73d36fe188.tar.gz
scummvm-rg350-ed5901c36ddc770e6d651bdd5df21b73d36fe188.tar.bz2
scummvm-rg350-ed5901c36ddc770e6d651bdd5df21b73d36fe188.zip
SCUMM HE: Implement data packet sending in Moonbase Commander
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/he/moonbase/net_defines.h2
-rw-r--r--engines/scumm/he/moonbase/net_main.cpp32
-rw-r--r--engines/scumm/he/moonbase/net_main.h3
3 files changed, 33 insertions, 4 deletions
diff --git a/engines/scumm/he/moonbase/net_defines.h b/engines/scumm/he/moonbase/net_defines.h
index fc4827fb60..79d1651f58 100644
--- a/engines/scumm/he/moonbase/net_defines.h
+++ b/engines/scumm/he/moonbase/net_defines.h
@@ -59,7 +59,7 @@ const int MAX_HOSTNAME_SIZE = 256;
const int MAX_IP_SIZE = 32;
const char LOCAL_HOST[] = "127.0.0.1"; //localhost
-const int DATA_HEADER_SIZE = 16;
+const int DATA_HEADER_SIZE = 24;
#define NULL_IP ""; //no IP address (causes enumsessions to search local subnet)
diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp
index d5ce756c75..bb371ff75b 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -333,7 +333,8 @@ 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) {
- Common::MemoryWriteStream pack(_packbuffer, MAX_PACKET_SIZE + DATA_HEADER_SIZE);
+ byte *buf = (byte *)malloc(MAX_PACKET_SIZE + DATA_HEADER_SIZE);
+ Common::MemoryWriteStream pack(buf, MAX_PACKET_SIZE + DATA_HEADER_SIZE);
pack.writeUint32LE(_sessionid);
pack.writeUint32LE(_myUserId);
@@ -343,13 +344,38 @@ int Net::remoteSendData(int typeOfSend, int sendTypeParam, int type, byte *data,
pack.writeUint32LE(g_system->getMillis());
pack.write(data, len);
- debug("Package to send, to: %d (%d), %d bytes", typeOfSend, sendTypeParam, len + DATA_HEADER_SIZE);
+ debug("Package to send, to: %d (%d), %d(%x) bytes", typeOfSend, sendTypeParam, len + DATA_HEADER_SIZE, len);
- Common::hexdump(_packbuffer, len + DATA_HEADER_SIZE);
+ Common::hexdump(buf, len + DATA_HEADER_SIZE);
+
+ 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.start();
+
+ while(rq.state() == Networking::PROCESSING) {
+ g_system->delayMillis(5);
+ }
+
+ if (!_sessions)
+ return 0;
return defaultRes;
}
+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) {
+ warning("Error in remoteSendData(): %ld %s", error.httpResponseCode, error.response.c_str());
+}
+
void Net::remoteSendArray(int typeOfSend, int sendTypeParam, int priority, int arrayIndex) {
byte *arr = _vm->getResourceAddress(rtString, arrayIndex & ~0x33539000);
int len = _vm->getResourceSize(rtString, arrayIndex & ~0x33539000);
diff --git a/engines/scumm/he/moonbase/net_main.h b/engines/scumm/he/moonbase/net_main.h
index 02988858c4..74fc021d82 100644
--- a/engines/scumm/he/moonbase/net_main.h
+++ b/engines/scumm/he/moonbase/net_main.h
@@ -80,6 +80,9 @@ private:
void addUserCallback(Common::JSONValue *response);
void addUserErrorCallback(Networking::ErrorResponse error);
+ void remoteSendDataCallback(Common::JSONValue *response);
+ void remoteSendDataErrorCallback(Networking::ErrorResponse error);
+
public:
//getters
bool getHostName(char *hostname, int length);