1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SCUMM_HE_NET_LOBBY_H
#define SCUMM_HE_NET_LOBBY_H
#include "backends/networking/curl/socket.h"
#include "backends/networking/curl/url.h"
#include "common/formats/json.h"
#include "scumm/he/net/net_main.h"
#define MAX_USER_NAME 16
// Boneyards (Lobby) opcodes.
#define OP_NET_OPEN_WEB_URL 2121
#define OP_NET_DOWNLOAD_PLAYBOOK 2122
#define OP_NET_CONNECT 2200
#define OP_NET_DISCONNECT 2201
#define OP_NET_LOGIN 2202
#define OP_NET_ENTER_AREA 2204
#define OP_NET_GET_NUM_PLAYERS_IN_AREA 2205
#define OP_NET_FETCH_PLAYERS_INFO_IN_AREA 2206
#define OP_NET_GET_PLAYERS_INFO 2207
#define OP_NET_START_HOSTING_GAME 2208
#define OP_NET_CALL_PLAYER 2209
#define OP_NET_PING_OPPONENT 2211
#define OP_NET_RECEIVER_BUSY 2212
#define OP_NET_COUNTER_CHALLENGE 2213
#define OP_NET_GET_PROFILE 2214
#define OP_NET_DECLINE_CHALLENGE 2215
#define OP_NET_ACCEPT_CHALLENGE 2216
#define OP_NET_STOP_CALLING 2217
#define OP_NET_CHANGE_ICON 2218
#define OP_NET_SET_PHONE_STATUS 2220
#define OP_NET_ANSWER_PHONE 2221
#define OP_NET_LEAVE_AREA 2222
#define OP_NET_GAME_FINISHED 2223
#define OP_NET_GAME_STARTED 2224
#define OP_NET_UPDATE_PROFILE_ARRAY 2225
#define OP_NET_LOCATE_PLAYER 2226
#define OP_NET_GET_POPULATION 2227
#define OP_NET_SET_POLL_ANSWER 2228
#define OP_NET_UNKNOWN_2229 2229
// Used in baseball to get news, poll and banner.
#define OP_NET_DOWNLOAD_FILE 2238
// MAIA (Updater) opcodes.
#define OP_NET_UPDATE_INIT 3000
#define OP_NET_FETCH_UPDATES 3002
// Commands for VAR_REMOTE_START_SCRIPT. (55 in football; 324 in baseball)
#define OP_REMOTE_SYSTEM_ALERT 9911
#define OP_REMOTE_START_CONNECTION 9919
#define OP_REMOTE_RECEIVE_CHALLENGE 9920
#define OP_REMOTE_OPPONENT_ANSWERS 9921
#define OP_REMOTE_OPPONENT_BUSY 9922
#define OP_REMOTE_COUNTER_CHALLENGE 9923
#define OP_REMOTE_OPPONENT_DECLINES 9924
#define OP_REMOTE_OPPONENT_ACCEPTS 9925
#define OP_REMOTE_PING_TEST_RESULT 9927
namespace Scumm {
class ScummEngine_v90he;
class Lobby {
public:
Lobby(ScummEngine_v90he *vm);
~Lobby();
void doNetworkOnceAFrame();
void send(Common::JSONObject &data);
int32 dispatch(int op, int numArgs, int32 *args);
int _sessionId;
protected:
ScummEngine_v90he *_vm;
Common::String _gameName;
Networking::CurlSocket *_socket;
Common::String _buffer;
Common::JSONArray _playersList;
int _userId;
Common::String _userName;
int _playerId; // Opponent's user ID.
int _areaIdForPopulation; // The area id we're waiting for population for (to prevent getting population for one area while wanting another).
bool _inArea;
int _gamesPlaying;
bool _inGame;
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);
void handleHeartbeat();
void openUrl(const char *url);
bool connect();
void disconnect(bool lost = false);
void login(const char *userName, const char *password);
void handleLoginResp(int errorCode, int userId, Common::String sessionServer, Common::String response);
void getUserProfile(int userId);
void handleProfileInfo(Common::JSONArray profile);
void handleTeams(Common::JSONArray userTeam, Common::JSONArray opponentTeam, int error, Common::String message);
void downloadFile(const char *downloadPath, const char *filename);
void handleFileData(Common::String filename, Common::String data);
void setIcon(int icon);
void setPollAnswer(int pollAnswer);
void sendGameResults(int userId, int arrayIndex, int lastFlag);
void getPopulation(int areaId, int unknown);
void handlePopulation(int areaId, int population);
void locatePlayer(int userNameArray);
void handleLocateResp(int code, int areaId, Common::String area);
void enterArea(int32 areaId);
void leaveArea();
void getPlayersList(int start, int end);
bool _checkPlayersLists(Common::JSONArray other);
void handlePlayersList(Common::JSONArray playersList);
void getPlayerInfo(int32 idx);
void handleGamesPlaying(int games);
void setPhoneStatus(int status);
void sendBusy(int playerId);
void handleReceiverBusy();
void pingPlayer(int playerId);
void handlePingResult(int ping);
void challengePlayer(int32 playerId, int32 stadium);
void handleReceiveChallenge(int playerId, int stadium, Common::String name);
void challengeTimeout(int playerId);
int32 answerPhone(int playerId);
void handleConsideringChallenge();
void counterChallenge(int stadium);
void handleCounterChallenge(int stadium);
void declineChallenge(int playerId);
void handleDeclineChallenge(int notResponding);
void acceptChallenge(int playerId);
void handleAcceptChallenge();
void startHostingGame(int playerId);
void handleGameSession(int sessionId);
void gameStarted(int hoster, int player, int playerNameArray);
void gameFinished();
};
} // End of namespace Scumm
#endif
|