RAWOLAPI.H (11463B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 #ifdef WOLAPI_INTEGRATION 17 18 #ifndef WIN32 19 #error WOLAPI_INTEGRATION can't be specified for non WIN32 version! 20 #endif 21 22 // rawolapi.h - WOLAPI sinks declarations. 23 // ajw 07/10/98 24 25 // Based somewhat on Neal's Borlandized version, "chatapi.h". 26 27 #ifndef RAWOLAPI_H 28 #define RAWOLAPI_H 29 30 #include "function.h" 31 32 //#include "cominit.h" 33 #include <stdio.h> 34 35 // From OBJBASE.H 36 #define interface struct 37 38 // From RPCNDR.H 39 #define DECLSPEC_UUID(x) 40 41 #include <commctrl.h> 42 43 //namespace WOL // namespace is workaround due to the use of "Server" as a global in Red Alert. 44 // ajw - Can't use namespaces in Watcom 10.5 it seems... 45 //{ 46 #include "wolapi\wolapi.h" 47 #define IID_DEFINED 48 //#include "wlib/wdebug.h" 49 #include "wolapi\chatdefs.h" 50 #include "wolapi\downloaddefs.h" 51 #include "wolapi\ftpdefs.h" 52 //}; 53 //using namespace WOL; 54 #include <winerror.h> 55 //#include <ocidl.h> 56 #include <olectl.h> 57 58 //*********************************************************************************************** 59 // For debugging chat defined hresults... 60 void ChatDefAsText( char* szDesc, HRESULT hRes ); 61 void DebugChatDef( HRESULT hRes ); 62 63 int iChannelLobbyNumber( const unsigned char* szChannelName ); 64 #define REASONABLELOBBYINTERPRETEDNAMELEN 50 65 void InterpretLobbyNumber( char* szLobbyNameToSet, int iLobby ); 66 67 class WolapiObject; 68 69 #define MAXCHATSENDLENGTH 71 // Mainly aesthetic, and because of the length of edit line. 70 71 enum CHANNELFILTER 72 { 73 CHANNELFILTER_NO, 74 CHANNELFILTER_OFFICIAL, 75 CHANNELFILTER_UNOFFICIAL, 76 CHANNELFILTER_LOBBIES, 77 CHANNELFILTER_LOCALLOBBYGAMES, 78 }; 79 80 #define WOLCOLORREMAP_ACTION PCOLOR_GREY 81 #define WOLCOLORREMAP_SELFSPEAKING PCOLOR_RED 82 #define WOLCOLORREMAP_LOCALMACHINEMESS PCOLOR_REALLY_BLUE // Color of system messages that originate locally. 83 #define WOLCOLORREMAP_PAGE PCOLOR_GOLD 84 #define WOLCOLORREMAP_KICKORBAN PCOLOR_GREEN //LTBLUE 85 #define WOLCOLORREMAP_PUBLICMESSAGE PCOLOR_NONE 86 #define WOLCOLORREMAP_PRIVATEMESSAGE PCOLOR_ORANGE 87 88 #define WOLSOUND_ERROR VOC_SYS_ERROR 89 #define WOLSOUND_LOGIN VOC_RADAR_ON 90 #define WOLSOUND_LOGOUT VOC_RADAR_OFF 91 #define WOLSOUND_ENTERCHAN VOC_PLAYER_JOINED 92 #define WOLSOUND_EXITCHAN VOC_PLAYER_LEFT 93 #define WOLSOUND_ONPAGE VOC_INCOMING_MESSAGE 94 #define WOLSOUND_KICKORBAN VOC_TANYA_KISS 95 #define WOLSOUND_ENTERGAME VOC_INVULNERABLE 96 #define WOLSOUND_EXITGAME VOC_DOOR 97 98 enum DISCONNECT_PING_STATUS 99 { 100 PING_UNSTARTED, 101 PING_WAITING, 102 PING_GOOD, 103 PING_BAD, 104 }; 105 #define DISCONNECT_PING_COUNT 5 106 107 //*********************************************************************************************** 108 class RAChatEventSink : /////public CComObjectRoot, /////public IConnectionPoint, 109 public IChatEvent 110 { 111 public: 112 RAChatEventSink( WolapiObject* pOwner ); 113 virtual ~RAChatEventSink(); 114 115 // BEGIN_COM_MAP(RAChatEventSink) 116 // COM_INTERFACE_ENTRY(IChatEvent) 117 // END_COM_MAP() 118 119 // IUnknown 120 STDMETHOD(QueryInterface)(const IID& iid, void **ppv); 121 STDMETHOD_(ULONG,AddRef)(); 122 STDMETHOD_(ULONG,Release)(); 123 124 // IChatEvent 125 STDMETHOD(OnServerList)(HRESULT res, Server* servers); 126 STDMETHOD(OnLogout)(HRESULT r, User *user); 127 STDMETHOD(OnBusy)(HRESULT r); 128 STDMETHOD(OnIdle)(HRESULT r); 129 STDMETHOD(OnPageSend)(HRESULT r); 130 STDMETHOD(OnPaged)(HRESULT r, User *, LPCSTR); 131 STDMETHOD(OnFind)(HRESULT r, Channel *); 132 STDMETHOD(OnConnection)(HRESULT r,LPCSTR motd); 133 STDMETHOD(OnChannelCreate)(HRESULT r, Channel *channel); 134 STDMETHOD(OnChannelModify)(HRESULT r, Channel *channel); 135 STDMETHOD(OnChannelJoin)(HRESULT r, Channel *channel, User *user); 136 STDMETHOD(OnChannelLeave)(HRESULT r, Channel *channel, User *user); 137 STDMETHOD(OnChannelTopic)(HRESULT r, Channel *channel, LPCSTR topic); 138 STDMETHOD(OnGroupList)(HRESULT r, Group *); 139 STDMETHOD(OnPublicMessage)(HRESULT r, Channel *channel, User *user, LPCSTR text); 140 STDMETHOD(OnPrivateMessage)(HRESULT r, User *user,LPCSTR text); 141 STDMETHOD(OnSystemMessage)(HRESULT r, LPCSTR); 142 STDMETHOD(OnNetStatus)(HRESULT r); 143 STDMETHOD(OnChannelList)(HRESULT r, Channel* channels); 144 STDMETHOD(OnUserList)(HRESULT r, Channel* channel, User* users); 145 STDMETHOD(OnUpdateList)(HRESULT res, Update *); 146 STDMETHOD(OnServerError)(HRESULT res); 147 STDMETHOD(OnMessageOfTheDay)(HRESULT res, LPCSTR); 148 STDMETHOD(OnPrivateAction)(HRESULT r, User *, LPCSTR); 149 STDMETHOD(OnPublicAction)(HRESULT r, Channel *, User *, LPCSTR); 150 STDMETHOD(OnPrivateGameOptions)(HRESULT r, User *, LPCSTR); 151 STDMETHOD(OnPublicGameOptions)(HRESULT r, Channel *, User *, LPCSTR); 152 STDMETHOD(OnGameStart)(HRESULT r, Channel *, User *, int); 153 STDMETHOD(OnUserKick)(HRESULT r, Channel *, User *, User *); 154 STDMETHOD(OnUserIP)(HRESULT r, User *); 155 STDMETHOD(OnServerError)(HRESULT res, LPCSTR ircmsg); 156 STDMETHOD(OnServerBannedYou)(HRESULT r, time_t bannedTill); 157 STDMETHOD(OnUserFlags)(HRESULT r, LPCSTR name, unsigned int flags, unsigned int mask); 158 STDMETHOD(OnChannelBan)(HRESULT r, LPCSTR name, int banned); 159 160 unsigned long GetPlayerGameIP( const char* szPlayerName ) const; 161 void DeleteUserList(); // Deletes from heap all users pointed to through pUserList. 162 void DeleteUserIPList(); 163 unsigned long GetUserIP( const char* szName ) const; 164 165 void ActionEggSound( const char* szMessage ); 166 167 public: 168 // These vars are rather hackish. Basically, they are set before a callback is expected to be fired, and 169 // then checked immediately afterwards. The rest of the time, their values are meaningless. 170 // The idea is to force wolapi act in a modal way. In many places I "block" until a callback response to a 171 // wolapi request has been received. 172 bool bRequestServerListWait; 173 bool bRequestConnectionWait; 174 bool bRequestLogoutWait; 175 // bool bRequestChannelListWait; 176 bool bRequestChannelJoinWait; 177 bool bRequestChannelLeaveWait; 178 bool bRequestUserListWait; 179 bool bRequestChannelCreateWait; 180 bool bRequestFindWait; 181 bool bRequestPageWait; 182 183 bool bRequestChannelListForLobbiesWait; 184 185 bool bIgnoreChannelLists; // Used to temporarily turn off response to channel lists, when we are in the midst 186 // of some processing that depends on pChannelList remaining constant. 187 188 bool bRequestGameStartWait; 189 190 Server* pServer; // Server to connect to, acquired from OnServerList. 191 bool bConnected; // True when user is logged in to chat server. 192 bool bJoined; // True when user has joined a channel. 193 194 Channel* pChannelList; // First element of channel list, or null. 195 CHANNELFILTER ChannelFilter; // Affects what channels are included in channel list when built. 196 197 User* pUserList; // First element of user list, or null. 198 User* pUserTail; // Last element of user list, or null. 199 200 char* szMotd; // Message of the day. 201 HRESULT hresRequestConnectionError; // Used to pass error hresult. 202 203 HRESULT hresRequestFindResult; // Used to pass hresult. 204 Channel OnFindChannel; 205 206 HRESULT hresRequestPageResult; // Used to pass hresult. 207 208 HRESULT hresRequestJoinResult; // Used to pass hresult. 209 210 bool bGotKickedTrigger; // Special flag meaning do some more processing after callback has exited. 211 212 User* pGameUserList; // First element of start game user list, or null. 213 int iGameID; // WW Online game id received from OnGameStart. 214 // Is also a flag indicating "OnGameStart() called, TriggerGameStart() not yet called". 215 216 User* pUserIPList; // List that holds user IP's, used for pinging in game channel. 217 User* pUserIPListTail; 218 219 protected: 220 WolapiObject* pOwner; // Link back to the object that contains me. 221 222 void DeleteChannelList(); // Deletes from heap all channels pointed to through pChannelList. 223 bool DownloadUpdates( Update* pUpdateList, int iUpdates ); 224 bool bSpecialMessage( const char* szMessage ); 225 void InsertUserSorted( User* pUserNew ); 226 227 private: 228 long m_cRef; // Reference Count 229 230 }; 231 232 //*********************************************************************************************** 233 class RADownloadEventSink : 234 /////////// public CComObjectRoot, 235 public IDownloadEvent 236 { 237 public: 238 RADownloadEventSink(); 239 virtual ~RADownloadEventSink() {}; 240 241 // BEGIN_COM_MAP(RADownloadEventSink) 242 // COM_INTERFACE_ENTRY(IDownloadEvent) 243 // END_COM_MAP() 244 245 // IUnknown 246 STDMETHOD(QueryInterface)(const IID& iid, void **ppv); 247 STDMETHOD_(ULONG,AddRef)(); 248 STDMETHOD_(ULONG,Release)(); 249 250 // IDownloadEvent 251 STDMETHOD(OnEnd)(void); 252 STDMETHOD(OnError)(int error); 253 STDMETHOD(OnProgressUpdate)(int bytesread, int totalsize, int timetaken, int timeleft); 254 STDMETHOD(OnStatusUpdate)(int status); 255 STDMETHOD(OnQueryResume)(void); 256 257 public: 258 bool bFlagEnd; 259 bool bFlagError; 260 bool bFlagProgressUpdate; 261 bool bFlagStatusUpdate; 262 bool bFlagQueryResume; 263 int iBytesRead; 264 int iTotalSize; 265 int iTimeTaken; 266 int iTimeLeft; 267 int iStatus; 268 bool bResumed; 269 270 private: 271 long m_cRef; // Ref count 272 }; 273 274 //*********************************************************************************************** 275 class RANetUtilEventSink : 276 // public CComObjectRoot, 277 public INetUtilEvent 278 { 279 public: 280 RANetUtilEventSink( WolapiObject* pOwner ); 281 virtual ~RANetUtilEventSink(); 282 283 //BEGIN_COM_MAP(CNetUtilEventSink) 284 // COM_INTERFACE_ENTRY(INetUtilEvent) 285 //END_COM_MAP() 286 287 // IUnknown 288 STDMETHOD(QueryInterface)(const IID& iid, void **ppv); 289 STDMETHOD_(ULONG,AddRef)(); 290 STDMETHOD_(ULONG,Release)(); 291 292 // INetUtilEvent 293 294 STDMETHOD(OnGameresSent)(HRESULT res); 295 STDMETHOD(OnLadderList)(HRESULT res, Ladder *list, int totalCount, long timeStamp, int keyRung); 296 STDMETHOD(OnPing)(HRESULT res, int time, unsigned long ip, int handle); 297 298 299 void DeleteLadderList(); // Deletes from heap all users pointed to through pUserList. 300 unsigned int GetUserRank( const char* szName, bool bRankRA ); 301 302 Ladder* pLadderList; // First element of Ladder list, or null. 303 Ladder* pLadderTail; // Last element of Ladder list, or null. 304 Ladder* pLadderListAM; // First element of Aftermath Ladder list, or null. 305 Ladder* pLadderTailAM; // Last element of Aftermath Ladder list, or null. 306 307 protected: 308 WolapiObject* pOwner; // Link back to the object that contains me. 309 310 private: 311 long m_cRef; // Reference Count 312 }; 313 314 //*********************************************************************************************** 315 316 // SKU, reported to WOLAPI for the purpose of finding patches. 317 #ifdef ENGLISH 318 #define GAME_SKU 0x1500 319 #else 320 #ifdef GERMAN 321 #define GAME_SKU 0x1502 322 #else 323 #define GAME_SKU 0x1503 324 #endif 325 #endif 326 327 #define GAME_VERSION 0x00030003 328 #define GAME_TYPE 21 329 #define LOB_PREFIX "Lob_21_" 330 331 // Sent to gameres server in order to receive Red Alert or Aftermath ladder rankings. (Sent in RequestLadderList.) 332 #define LADDER_CODE_RA 1005 333 #define LADDER_CODE_AM 500 334 335 #endif 336 337 #endif