[Scummvm-git-logs] scummvm master -> e15428c43fc62f3e139d6b97e61624941f7e08ba
sev-
sev at scummvm.org
Thu Oct 24 00:15:45 CEST 2019
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0ad210a5a4 NETWORKING: Added simple request handler
a0c58a53b3 NETWORKING: Changed PostRequest to accept JSONValue
22ba110e82 SCUMM HE: Set up networking variable later during execution
2c5ae96356 SCUMM HE: Hook in PostRequest to Moonbase Commander
e15428c43f SCUMM HE: Fix libcurl compilation checks
Commit: 0ad210a5a477c4d4241e03a54c7007ac669a3a3c
https://github.com/scummvm/scummvm/commit/0ad210a5a477c4d4241e03a54c7007ac669a3a3c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-24T00:15:33+02:00
Commit Message:
NETWORKING: Added simple request handler
Changed paths:
A backends/networking/curl/postrequest.cpp
A backends/networking/curl/postrequest.h
backends/module.mk
diff --git a/backends/module.mk b/backends/module.mk
index 2201e65..886947e 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -65,6 +65,7 @@ MODULE_OBJS += \
networking/curl/networkreadstream.o \
networking/curl/curlrequest.o \
networking/curl/curljsonrequest.o \
+ networking/curl/postrequest.o \
networking/curl/request.o
endif
diff --git a/backends/networking/curl/postrequest.cpp b/backends/networking/curl/postrequest.cpp
new file mode 100644
index 0000000..0becc8e
--- /dev/null
+++ b/backends/networking/curl/postrequest.cpp
@@ -0,0 +1,110 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "backends/networking/curl/postrequest.h"
+#include "backends/networking/curl/connectionmanager.h"
+#include "backends/networking/curl/curljsonrequest.h"
+#include "backends/networking/curl/networkreadstream.h"
+#include "common/json.h"
+
+namespace Networking {
+
+PostRequest::PostRequest(Common::String url, byte *postData, int postLen, Networking::JsonCallback cb, Networking::ErrorCallback ecb):
+ Networking::Request(nullptr, ecb), _url(url), _jsonCallback(cb),
+ _workingRequest(nullptr), _ignoreCallback(false), _postData(postData), _postLen(postLen) {
+ start();
+}
+
+PostRequest::~PostRequest() {
+ _ignoreCallback = true;
+ if (_workingRequest)
+ _workingRequest->finish();
+ delete _jsonCallback;
+}
+
+void PostRequest::start() {
+ _ignoreCallback = true;
+ if (_workingRequest)
+ _workingRequest->finish();
+ _ignoreCallback = false;
+
+ Networking::JsonCallback innerCallback = new Common::Callback<PostRequest, Networking::JsonResponse>(this, &PostRequest::responseCallback);
+ Networking::ErrorCallback errorResponseCallback = new Common::Callback<PostRequest, Networking::ErrorResponse>(this, &PostRequest::errorCallback);
+ Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(innerCallback, errorResponseCallback, _url);
+ request->addHeader("Content-Type: application/json");
+
+ request->setBuffer(_postData, _postLen);
+
+ _workingRequest = ConnMan.addRequest(request);
+}
+
+void PostRequest::responseCallback(Networking::JsonResponse response) {
+ Common::JSONValue *json = response.value;
+ _workingRequest = nullptr;
+ if (_ignoreCallback) {
+ delete json;
+ return;
+ }
+ if (response.request) _date = response.request->date();
+
+ Networking::ErrorResponse error(this, "PostRequest::responseCallback: unknown error");
+ Networking::CurlJsonRequest *rq = (Networking::CurlJsonRequest *)response.request;
+ if (rq && rq->getNetworkReadStream())
+ error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode();
+
+ if (json == nullptr) {
+ error.response = "Failed to parse JSON, null passed!";
+ finishError(error);
+ return;
+ }
+
+ if (!json->isObject()) {
+ error.response = "Passed JSON is not an object!";
+ finishError(error);
+ delete json;
+ return;
+ }
+
+ finishSuccess();
+
+ if (_jsonCallback)
+ (*_jsonCallback)(Networking::JsonResponse(this, json));
+
+ delete json;
+}
+
+void PostRequest::errorCallback(Networking::ErrorResponse error) {
+ _workingRequest = nullptr;
+ if (_ignoreCallback)
+ return;
+ if (error.request)
+ _date = error.request->date();
+ finishError(error);
+}
+
+void PostRequest::handle() {}
+
+void PostRequest::restart() { start(); }
+
+Common::String PostRequest::date() const { return _date; }
+
+} // End of namespace Networking
diff --git a/backends/networking/curl/postrequest.h b/backends/networking/curl/postrequest.h
new file mode 100644
index 0000000..775af31
--- /dev/null
+++ b/backends/networking/curl/postrequest.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef BACKENDS_NETWORKING_CURL_POSTREQUEST_H
+#define BACKENDS_NETWORKING_CURL_POSTREQUEST_H
+
+#include "backends/networking/curl/request.h"
+#include "backends/networking/curl/curljsonrequest.h"
+
+namespace Networking {
+
+class PostRequest: public Networking::Request {
+ Common::String _url;
+ Networking::JsonCallback _jsonCallback;
+ Request *_workingRequest;
+ bool _ignoreCallback;
+ Common::String _date;
+
+ byte *_postData;
+ int _postLen;
+
+ void start();
+ void responseCallback(Networking::JsonResponse response);
+ void errorCallback(Networking::ErrorResponse error);
+
+public:
+ PostRequest(Common::String url, byte *postData, int postLen, Networking::JsonCallback cb, Networking::ErrorCallback ecb);
+ virtual ~PostRequest();
+
+ virtual void handle();
+ virtual void restart();
+ virtual Common::String date() const;
+};
+
+} // End of namespace Networking
+
+#endif
Commit: a0c58a53b3db7710c333da66cde3125ea74559b8
https://github.com/scummvm/scummvm/commit/a0c58a53b3db7710c333da66cde3125ea74559b8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-24T00:15:33+02:00
Commit Message:
NETWORKING: Changed PostRequest to accept JSONValue
Changed paths:
backends/networking/curl/curljsonrequest.h
backends/networking/curl/postrequest.cpp
backends/networking/curl/postrequest.h
diff --git a/backends/networking/curl/curljsonrequest.h b/backends/networking/curl/curljsonrequest.h
index 11c6bc8..e462d58 100644
--- a/backends/networking/curl/curljsonrequest.h
+++ b/backends/networking/curl/curljsonrequest.h
@@ -31,6 +31,7 @@ namespace Networking {
typedef Response<Common::JSONValue *> JsonResponse;
typedef Common::BaseCallback<JsonResponse> *JsonCallback;
+typedef Common::BaseCallback<Common::JSONValue *> *JSONValueCallback;
#define CURL_JSON_REQUEST_BUFFER_SIZE 512 * 1024
diff --git a/backends/networking/curl/postrequest.cpp b/backends/networking/curl/postrequest.cpp
index 0becc8e..1dec36b 100644
--- a/backends/networking/curl/postrequest.cpp
+++ b/backends/networking/curl/postrequest.cpp
@@ -28,7 +28,7 @@
namespace Networking {
-PostRequest::PostRequest(Common::String url, byte *postData, int postLen, Networking::JsonCallback cb, Networking::ErrorCallback ecb):
+PostRequest::PostRequest(Common::String url, byte *postData, int postLen, Networking::JSONValueCallback cb, Networking::ErrorCallback ecb):
Networking::Request(nullptr, ecb), _url(url), _jsonCallback(cb),
_workingRequest(nullptr), _ignoreCallback(false), _postData(postData), _postLen(postLen) {
start();
@@ -87,7 +87,7 @@ void PostRequest::responseCallback(Networking::JsonResponse response) {
finishSuccess();
if (_jsonCallback)
- (*_jsonCallback)(Networking::JsonResponse(this, json));
+ (*_jsonCallback)(json);
delete json;
}
diff --git a/backends/networking/curl/postrequest.h b/backends/networking/curl/postrequest.h
index 775af31..5689794 100644
--- a/backends/networking/curl/postrequest.h
+++ b/backends/networking/curl/postrequest.h
@@ -30,7 +30,7 @@ namespace Networking {
class PostRequest: public Networking::Request {
Common::String _url;
- Networking::JsonCallback _jsonCallback;
+ Networking::JSONValueCallback _jsonCallback;
Request *_workingRequest;
bool _ignoreCallback;
Common::String _date;
@@ -43,7 +43,7 @@ class PostRequest: public Networking::Request {
void errorCallback(Networking::ErrorResponse error);
public:
- PostRequest(Common::String url, byte *postData, int postLen, Networking::JsonCallback cb, Networking::ErrorCallback ecb);
+ PostRequest(Common::String url, byte *postData, int postLen, Networking::JSONValueCallback cb, Networking::ErrorCallback ecb);
virtual ~PostRequest();
virtual void handle();
Commit: 22ba110e829d62af3e014b0a73a7155aa6bbbe3c
https://github.com/scummvm/scummvm/commit/22ba110e829d62af3e014b0a73a7155aa6bbbe3c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-24T00:15:33+02:00
Commit Message:
SCUMM HE: Set up networking variable later during execution
Changed paths:
engines/scumm/he/intern_he.h
engines/scumm/he/moonbase/moonbase.cpp
engines/scumm/vars.cpp
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index bd0ab76..d1487c7 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -611,6 +611,7 @@ public:
virtual void resetScumm();
virtual void setupScummVars();
+ virtual void resetScummVars();
protected:
virtual void setupOpcodes();
diff --git a/engines/scumm/he/moonbase/moonbase.cpp b/engines/scumm/he/moonbase/moonbase.cpp
index 1c03fc7..cfdfde6 100644
--- a/engines/scumm/he/moonbase/moonbase.cpp
+++ b/engines/scumm/he/moonbase/moonbase.cpp
@@ -35,9 +35,6 @@ Moonbase::Moonbase(ScummEngine_v100he *vm) : _vm(vm) {
_ai = new AI(_vm);
#ifdef USE_CURL
_net = new Net(_vm);
- _vm->VAR(_vm->VAR_NETWORK_AVAILABLE) = 1;
-#else
- _vm->VAR(_vm->VAR_NETWORK_AVAILABLE) = 0;
#endif
}
diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp
index 4f00e71..6fa5409 100644
--- a/engines/scumm/vars.cpp
+++ b/engines/scumm/vars.cpp
@@ -740,6 +740,18 @@ void ScummEngine_v99he::resetScummVars() {
}
#endif
+void ScummEngine_v100he::resetScummVars() {
+ ScummEngine_v99he::resetScummVars();
+
+ if (_game.id == GID_MOONBASE) {
+#ifdef USE_CURL
+ VAR(VAR_NETWORK_AVAILABLE) = 1;
+#else
+ VAR(VAR_NETWORK_AVAILABLE) = 0;
+#endif
+ }
+}
+
void ScummEngine::resetScummVars() {
if (_game.heversion < 70 && _game.version <= 6) {
// VAR_SOUNDCARD modes
Commit: 2c5ae963561eead1dcfdd5885e1f1ebc8d9293eb
https://github.com/scummvm/scummvm/commit/2c5ae963561eead1dcfdd5885e1f1ebc8d9293eb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-24T00:15:33+02:00
Commit Message:
SCUMM HE: Hook in PostRequest to Moonbase Commander
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 c0b4b4c..48fb044 100644
--- a/engines/scumm/he/moonbase/net_main.cpp
+++ b/engines/scumm/he/moonbase/net_main.cpp
@@ -151,10 +151,26 @@ bool Net::destroyPlayer(int32 playerDPID) {
int32 Net::startQuerySessions() {
warning("STUB: Net::startQuerySessions()"); // StartQuerySessions
+ Networking::PostRequest rq("http://localhost/lobbies", NULL, 0,
+ new Common::Callback<Net, Common::JSONValue *>(this, &Net::startQuerySessionsCallback),
+ new Common::Callback<Net, Networking::ErrorResponse>(this, &Net::startQuerySessionsErrorCallback));
+
+ while(rq.state() == Networking::PROCESSING) {
+ g_system->delayMillis(5);
+ }
+
// FAKE 1 session. FIXME
return 1;
}
+void Net::startQuerySessionsCallback(Common::JSONValue *response) {
+ warning("Got: '%s'", response->stringify().c_str());
+}
+
+void Net::startQuerySessionsErrorCallback(Networking::ErrorResponse error) {
+ warning("Error in startQuerySessions()");
+}
+
int32 Net::updateQuerySessions() {
warning("STUB: Net::updateQuerySessions()"); // UpdateQuerySessions
return startQuerySessions();
diff --git a/engines/scumm/he/moonbase/net_main.h b/engines/scumm/he/moonbase/net_main.h
index 1d6af49..54d1298 100644
--- a/engines/scumm/he/moonbase/net_main.h
+++ b/engines/scumm/he/moonbase/net_main.h
@@ -23,6 +23,8 @@
#ifndef SCUMM_HE_MOONBASE_NET_MAIN_H
#define SCUMM_HE_MOONBASE_NET_MAIN_H
+#include "backends/networking/curl/postrequest.h"
+
namespace Scumm {
class ScummEngine_v100he;
@@ -69,6 +71,9 @@ private:
int getMessageCount();
void remoteReceiveData();
+ void startQuerySessionsCallback(Common::JSONValue *response);
+ void startQuerySessionsErrorCallback(Networking::ErrorResponse error);
+
public:
//getters
bool getHostName(char *hostname, int length);
Commit: e15428c43fc62f3e139d6b97e61624941f7e08ba
https://github.com/scummvm/scummvm/commit/e15428c43fc62f3e139d6b97e61624941f7e08ba
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2019-10-24T00:15:33+02:00
Commit Message:
SCUMM HE: Fix libcurl compilation checks
Changed paths:
engines/scumm/he/logic/moonbase_logic.cpp
engines/scumm/he/moonbase/moonbase.cpp
engines/scumm/he/moonbase/moonbase.h
engines/scumm/vars.cpp
diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp
index 8b288d4..880d86d 100644
--- a/engines/scumm/he/logic/moonbase_logic.cpp
+++ b/engines/scumm/he/logic/moonbase_logic.cpp
@@ -24,7 +24,7 @@
#include "scumm/he/logic_he.h"
#include "scumm/he/moonbase/moonbase.h"
#include "scumm/he/moonbase/ai_main.h"
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
#include "scumm/he/moonbase/net_main.h"
#include "scumm/he/moonbase/net_defines.h"
#endif
@@ -60,7 +60,7 @@ private:
void op_ai_set_type(int op, int numArgs, int32 *args);
void op_ai_clean_up(int op, int numArgs, int32 *args);
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
void op_net_remote_start_script(int op, int numArgs, int32 *args);
void op_net_remote_send_array(int op, int numArgs, int32 *args);
int op_net_remote_start_function(int op, int numArgs, int32 *args);
@@ -165,7 +165,7 @@ int LogicHEmoonbase::versionID() {
#define OP_NET_SET_AI_PLAYER_COUNT 1565
int LogicHEmoonbase::startOfFrame() {
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
_vm1->_moonbase->_net->doNetworkOnceAFrame(15); // Value should be passed in...
#endif
@@ -210,7 +210,7 @@ int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
op_ai_clean_up(op, numArgs, args);
break;
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
case OP_NET_REMOTE_START_SCRIPT:
op_net_remote_start_script(op, numArgs, args);
break;
@@ -381,7 +381,7 @@ void LogicHEmoonbase::op_ai_clean_up(int op, int numArgs, int32 *args) {
_vm1->_moonbase->_ai->cleanUpAI();
}
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
void LogicHEmoonbase::op_net_remote_start_script(int op, int numArgs, int32 *args) {
_vm1->_moonbase->_net->remoteStartScript(args[0], args[1], args[2], numArgs - 3, &args[3]);
}
diff --git a/engines/scumm/he/moonbase/moonbase.cpp b/engines/scumm/he/moonbase/moonbase.cpp
index cfdfde6..cb76c3f 100644
--- a/engines/scumm/he/moonbase/moonbase.cpp
+++ b/engines/scumm/he/moonbase/moonbase.cpp
@@ -23,7 +23,7 @@
#include "scumm/he/intern_he.h"
#include "scumm/he/moonbase/moonbase.h"
#include "scumm/he/moonbase/ai_main.h"
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
#include "scumm/he/moonbase/net_main.h"
#endif
@@ -33,14 +33,14 @@ Moonbase::Moonbase(ScummEngine_v100he *vm) : _vm(vm) {
initFOW();
_ai = new AI(_vm);
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
_net = new Net(_vm);
#endif
}
Moonbase::~Moonbase() {
delete _ai;
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
delete _net;
#endif
}
diff --git a/engines/scumm/he/moonbase/moonbase.h b/engines/scumm/he/moonbase/moonbase.h
index 61efd42..d5fa455 100644
--- a/engines/scumm/he/moonbase/moonbase.h
+++ b/engines/scumm/he/moonbase/moonbase.h
@@ -72,7 +72,7 @@ public:
uint32 _fowSentinelConditionBits;
AI *_ai;
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
Net *_net;
#endif
diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp
index 6fa5409..67416b4 100644
--- a/engines/scumm/vars.cpp
+++ b/engines/scumm/vars.cpp
@@ -744,7 +744,7 @@ void ScummEngine_v100he::resetScummVars() {
ScummEngine_v99he::resetScummVars();
if (_game.id == GID_MOONBASE) {
-#ifdef USE_CURL
+#ifdef USE_LIBCURL
VAR(VAR_NETWORK_AVAILABLE) = 1;
#else
VAR(VAR_NETWORK_AVAILABLE) = 0;
More information about the Scummvm-git-logs
mailing list