[Scummvm-git-logs] scummvm master -> ed5901c36ddc770e6d651bdd5df21b73d36fe188

sev- sev at scummvm.org
Sat Oct 26 22:06:33 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ed5901c36d SCUMM HE: Implement data packet sending in Moonbase Commander


Commit: ed5901c36ddc770e6d651bdd5df21b73d36fe188
    https://github.com/scummvm/scummvm/commit/ed5901c36ddc770e6d651bdd5df21b73d36fe188
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-26T21:05:46+01:00

Commit Message:
SCUMM HE: Implement data packet sending in Moonbase Commander

Changed paths:
    engines/scumm/he/moonbase/net_defines.h
    engines/scumm/he/moonbase/net_main.cpp
    engines/scumm/he/moonbase/net_main.h


diff --git a/engines/scumm/he/moonbase/net_defines.h b/engines/scumm/he/moonbase/net_defines.h
index fc4827f..79d1651 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 d5ce756..bb371ff 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 0298885..74fc021 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);





More information about the Scummvm-git-logs mailing list