Advertisement
momo5502

PatchMW2NewsTicker.cpp

May 20th, 2013
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 KB | None | 0 0
  1.  
  2. // ==========================================================
  3. // IW4M project
  4. //
  5. // Component: clientdll
  6. // Sub-component: steam_api
  7. // Purpose: support code for the main menu news ticker
  8. //
  9. // Initial author: NTAuthority
  10. // Started: 2012-04-19
  11. // ==========================================================
  12.  
  13. #include "StdInc.h"
  14.  
  15. #define CURL_STATICLIB
  16. #include <curl/curl.h>
  17. #include <curl/types.h>
  18. #include <curl/easy.h>
  19.  
  20. CallHook newsTickerGetTextHook;
  21. DWORD newsTickerGetTextHookLoc = 0x6388C1;
  22. size_t AuthDataReceived(void *ptr, size_t size, size_t nmemb, void *data);
  23.  
  24. char* Auth_GetUsername();
  25. char ticker[8192];
  26.  
  27.  
  28. const char* NewsTicker_GetText(const char* garbage)
  29. {
  30.         if (!ticker[0])
  31.         {
  32.                 char buf[8192] = {0};
  33.  
  34.                 curl_global_init(CURL_GLOBAL_ALL);
  35.                 CURL* curl = curl_easy_init();
  36.  
  37.                 curl_easy_setopt(curl, CURLOPT_URL, "http://yoursite.com/pathtoyourfile/news.txt" );
  38.                 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, AuthDataReceived);
  39.                 curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&buf);
  40.                 curl_easy_setopt(curl, CURLOPT_USERAGENT, "IW4M");
  41.                 curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
  42.                
  43.                 CURLcode code = curl_easy_perform(curl);
  44.  
  45.                 curl_easy_cleanup(curl);
  46.                 curl_global_cleanup();
  47.  
  48.                 if( code == CURLE_OK )
  49.                     strcpy(ticker, va("%s", buf));
  50.                 else
  51.                     strcpy(ticker, va("^1Failed to retrieve news! Error: %s", code));
  52.         }
  53.         return ticker;
  54. }
  55.  
  56. void PatchMW2_NewsTicker()
  57. {
  58.         // hook for getting the news ticker string
  59.         *(WORD*)0x6388BB = 0x9090; // skip the "if (item->text[0] == '@')" localize check
  60.  
  61.         // replace the localize function
  62.         newsTickerGetTextHook.initialize(newsTickerGetTextHookLoc, NewsTicker_GetText);
  63.         newsTickerGetTextHook.installHook();
  64.  
  65.         // make newsfeed (ticker) menu items not cut off based on safe area
  66.         memset((void*)0x63892D, 0x90, 5);
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement