mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +00:00
SCUMM HE: Send version to lobby server.
This commit is contained in:
parent
8a17fc4ebf
commit
446f95d26c
@ -55,6 +55,7 @@
|
||||
* to properly work in exports (i.e. release tar balls etc.).
|
||||
*/
|
||||
const char gScummVMVersion[] = SCUMMVM_VERSION SCUMMVM_REVISION;
|
||||
const char gScummVMVersionLite[] = SCUMMVM_VERSION;
|
||||
#if defined(__amigaos4__) || defined(__MORPHOS__)
|
||||
static const char *version_cookie __attribute__((used)) = "$VER: ScummVM " SCUMMVM_VERSION SCUMMVM_REVISION " (" AMIGA_DATE ")";
|
||||
#endif
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define BASE_VERSION_H
|
||||
|
||||
extern const char gScummVMVersion[]; // e.g. "0.4.1"
|
||||
extern const char gScummVMVersionLite[]; // e.g. "0.4.1" (without version control revisions)
|
||||
extern const char gScummVMBuildDate[]; // e.g. "2003-06-24"
|
||||
extern const char gScummVMVersionDate[]; // e.g. "0.4.1 (2003-06-24)"
|
||||
extern const char gScummVMCompiler[]; // e.g. "GCC 11.2.0"
|
||||
|
@ -229,6 +229,10 @@ int32 LogicHEfootball::dispatch(int op, int numArgs, int32 *args) {
|
||||
case OP_NET_GET_PROFILE:
|
||||
_vm->_lobby->getUserProfile(args[0]);
|
||||
break;
|
||||
|
||||
case OP_NET_CHANGE_ICON:
|
||||
_vm->_lobby->setIcon(args[0]);
|
||||
break;
|
||||
|
||||
#endif // USE_LIBCURL
|
||||
#endif // USE_ENET
|
||||
@ -266,7 +270,7 @@ int32 LogicHEfootball::dispatch(int op, int numArgs, int32 *args) {
|
||||
case 2203: case 2204:
|
||||
case 2205: case 2206: case 2207: case 2208: case 2209:
|
||||
case 2210: case 2211: case 2212: case 2213:
|
||||
case 2215: case 2216: case 2217: case 2218: case 2219:
|
||||
case 2215: case 2216: case 2217: case 2219:
|
||||
case 2220: case 2221: case 2222: case 2223: case 2224:
|
||||
case 2225: case 2226: case 2227: case 2228:
|
||||
// Boneyards-related
|
||||
|
@ -19,6 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "base/version.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
#include "scumm/he/intern_he.h"
|
||||
@ -28,6 +29,8 @@ namespace Scumm {
|
||||
|
||||
Lobby::Lobby(ScummEngine_v90he *vm) : _vm(vm) {
|
||||
_gameName = _vm->_game.gameid;
|
||||
if (_gameName == "baseball2001")
|
||||
_gameName == "baseball";
|
||||
_socket = nullptr;
|
||||
|
||||
_userId = 0;
|
||||
@ -76,7 +79,8 @@ void Lobby::receiveData() {
|
||||
char data[1024];
|
||||
size_t len = _socket->recv(data, 1024);
|
||||
if (!len) {
|
||||
// Assume disconnection.
|
||||
// We have been disconnected.
|
||||
disconnect(true);
|
||||
}
|
||||
|
||||
Common::String data_str(data, len);
|
||||
@ -157,28 +161,64 @@ bool Lobby::connect() {
|
||||
debug(1, "LOBBY: Successfully connected to %s", url.c_str());
|
||||
return true;
|
||||
} else {
|
||||
disconnect();
|
||||
delete _socket;
|
||||
_socket = nullptr;
|
||||
writeStringArray(109, "Unable to contact server");
|
||||
_vm->writeVar(108, -99);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Lobby::disconnect() {
|
||||
void Lobby::disconnect(bool lost) {
|
||||
if (!_socket)
|
||||
return;
|
||||
|
||||
if (!lost) {
|
||||
debug(1, "LOBBY: Disconnecting connection to server.");
|
||||
Common::JSONObject disconnectObject;
|
||||
disconnectObject.setVal("cmd", new Common::JSONValue("disconnect"));
|
||||
send(disconnectObject);
|
||||
} else {
|
||||
systemAlert(901, "You have been disconnected from our server. Returning to login screen.");
|
||||
}
|
||||
|
||||
debug(1, "LOBBY: Disconnecting connection to server.");
|
||||
delete _socket;
|
||||
_socket = nullptr;
|
||||
}
|
||||
|
||||
void Lobby::runRemoteStartScript(int *args) {
|
||||
if (!_vm->VAR(_vm->VAR_REMOTE_START_SCRIPT)) {
|
||||
warning("LOBBY: VAR_REMOTE_START_SCRIPT not defined!");
|
||||
return;
|
||||
}
|
||||
_vm->runScript(_vm->VAR(_vm->VAR_REMOTE_START_SCRIPT), 1, 0, args);
|
||||
// These scripts always returns a 1 into the stack. Let's pop it out.
|
||||
_vm->pop();
|
||||
}
|
||||
|
||||
void Lobby::systemAlert(int type, Common::String message) {
|
||||
int args[25];
|
||||
memset(args, 0, sizeof(args));
|
||||
|
||||
// Write the message as a string array.
|
||||
writeStringArray(0, message);
|
||||
|
||||
// Setup the arguments
|
||||
args[0] = OP_REMOTE_SYSTEM_ALERT;
|
||||
args[1] = type;
|
||||
args[2] = _vm->VAR(0);
|
||||
|
||||
// Run the script
|
||||
runRemoteStartScript(args);
|
||||
}
|
||||
|
||||
void Lobby::login(const char *userName, const char *password) {
|
||||
Common::JSONObject loginRequestParameters;
|
||||
loginRequestParameters.setVal("cmd", new Common::JSONValue("login"));
|
||||
loginRequestParameters.setVal("user", new Common::JSONValue((Common::String)userName));
|
||||
loginRequestParameters.setVal("pass", new Common::JSONValue((Common::String)password));
|
||||
loginRequestParameters.setVal("game", new Common::JSONValue((Common::String)_gameName));
|
||||
loginRequestParameters.setVal("version", new Common::JSONValue(gScummVMVersionLite));
|
||||
|
||||
send(loginRequestParameters);
|
||||
}
|
||||
@ -214,12 +254,22 @@ void Lobby::handleProfileInfo(Common::JSONArray profile) {
|
||||
if (profile[i]->isIntegerNumber()) {
|
||||
_vm->writeArray(108, 0, i, profile[i]->asIntegerNumber());
|
||||
} else {
|
||||
warning("BYOnline: Value for profile index %d is not an integer!", i);
|
||||
warning("LOBBY: Value for profile index %d is not an integer!", i);
|
||||
}
|
||||
}
|
||||
_vm->writeVar(111, 1);
|
||||
}
|
||||
|
||||
void Lobby::setIcon(int icon) {
|
||||
if (!_socket)
|
||||
return;
|
||||
|
||||
Common::JSONObject setIconRequest;
|
||||
setIconRequest.setVal("cmd", new Common::JSONValue("set_icon"));
|
||||
setIconRequest.setVal("icon", new Common::JSONValue((long long int)icon));
|
||||
send(setIconRequest);
|
||||
}
|
||||
|
||||
} // End of namespace Scumm
|
||||
|
||||
|
||||
|
@ -51,9 +51,11 @@ public:
|
||||
void openUrl(const char *url);
|
||||
|
||||
bool connect();
|
||||
void disconnect();
|
||||
void disconnect(bool lost = false);
|
||||
void login(const char *userName, const char *password);
|
||||
|
||||
void getUserProfile(int userId);
|
||||
void setIcon(int icon);
|
||||
protected:
|
||||
ScummEngine_v90he *_vm;
|
||||
Common::String _gameName;
|
||||
@ -62,6 +64,8 @@ protected:
|
||||
Common::String _buffer;
|
||||
|
||||
void writeStringArray(int array, Common::String string);
|
||||
void runRemoteStartScript(int *args);
|
||||
void systemAlert(int type, Common::String message);
|
||||
|
||||
void receiveData();
|
||||
void processLine(Common::String line);
|
||||
|
Loading…
x
Reference in New Issue
Block a user