Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

378 lines
13 KiB

  1. 
  2. //========= Copyright � 1996-2012, Valve Corporation, All rights reserved. ============//
  3. //
  4. // Purpose:
  5. //
  6. //=============================================================================//
  7. #include "engine_helper_ps3.h"
  8. #if defined( _PS3 )
  9. #include <np.h>
  10. #endif
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include <tier0/memdbgon.h>
  13. #if defined( _PS3 )
  14. #define ESRB_TEEN_RATING_AGE 13
  15. #define AGE_RESTRICTION_DEFAULT ESRB_TEEN_RATING_AGE
  16. #define AGE_RESTRICTION_MAX ESRB_TEEN_RATING_AGE
  17. #define AGE_RESTRICTION_UAE AGE_RESTRICTION_DEFAULT// age for UAE
  18. #define AGE_RESTRICTION_ARGENTINIA AGE_RESTRICTION_DEFAULT// age for Argentina
  19. #define AGE_RESTRICTION_AUSTRIA AGE_RESTRICTION_DEFAULT// age for Austria
  20. #define AGE_RESTRICTION_AUSTRALIA AGE_RESTRICTION_DEFAULT// age for Australia
  21. #define AGE_RESTRICTION_BELGIUM AGE_RESTRICTION_DEFAULT// age for Belgium
  22. #define AGE_RESTRICTION_BULGARIA AGE_RESTRICTION_DEFAULT// age for Bulgaria
  23. #define AGE_RESTRICTION_BAHRAIN AGE_RESTRICTION_DEFAULT// age for Bahrain
  24. #define AGE_RESTRICTION_BRAZIL AGE_RESTRICTION_DEFAULT// age for Brazil
  25. #define AGE_RESTRICTION_CANADA AGE_RESTRICTION_DEFAULT// age for Canada
  26. #define AGE_RESTRICTION_SWISS AGE_RESTRICTION_DEFAULT// age for Switzerland
  27. #define AGE_RESTRICTION_CHILE AGE_RESTRICTION_DEFAULT// age for Chile
  28. #define AGE_RESTRICTION_COLOMBIA AGE_RESTRICTION_DEFAULT// age for Colombia
  29. #define AGE_RESTRICTION_CYPRUS AGE_RESTRICTION_DEFAULT// age for Cyprus
  30. #define AGE_RESTRICTION_CZECH_REP AGE_RESTRICTION_DEFAULT// age for Czech Republic
  31. #define AGE_RESTRICTION_GERMANY AGE_RESTRICTION_DEFAULT// age for Germany
  32. #define AGE_RESTRICTION_DENMARK AGE_RESTRICTION_DEFAULT// age for Denmark
  33. #define AGE_RESTRICTION_SPAIN AGE_RESTRICTION_DEFAULT// age for Spain
  34. #define AGE_RESTRICTION_FINLAND AGE_RESTRICTION_DEFAULT// age for Finland
  35. #define AGE_RESTRICTION_FRANCE AGE_RESTRICTION_DEFAULT// age for France
  36. #define AGE_RESTRICTION_UK AGE_RESTRICTION_DEFAULT// age for UK
  37. #define AGE_RESTRICTION_GREECE AGE_RESTRICTION_DEFAULT// age for Greece
  38. #define AGE_RESTRICTION_HONG_KONG AGE_RESTRICTION_DEFAULT// age for Hong Kong
  39. #define AGE_RESTRICTION_CROATIA AGE_RESTRICTION_DEFAULT// age for Croatia
  40. #define AGE_RESTRICTION_HUNGARY AGE_RESTRICTION_DEFAULT// age for Hungary
  41. #define AGE_RESTRICTION_INDONESIA AGE_RESTRICTION_DEFAULT// age for Indonesia
  42. #define AGE_RESTRICTION_IRELAND AGE_RESTRICTION_DEFAULT// age for Ireland
  43. #define AGE_RESTRICTION_ISREAL AGE_RESTRICTION_DEFAULT// age for Isreal
  44. #define AGE_RESTRICTION_INDIA AGE_RESTRICTION_DEFAULT// age for India
  45. #define AGE_RESTRICTION_ICELAND AGE_RESTRICTION_DEFAULT// age for Iceland
  46. #define AGE_RESTRICTION_ITALY AGE_RESTRICTION_DEFAULT// age for Italy
  47. #define AGE_RESTRICTION_JAPAN AGE_RESTRICTION_DEFAULT// age for Japan
  48. #define AGE_RESTRICTION_KOREA AGE_RESTRICTION_DEFAULT// age for Korea
  49. #define AGE_RESTRICTION_KUWAIT AGE_RESTRICTION_DEFAULT// age for Kuwait
  50. #define AGE_RESTRICTION_LEBANON AGE_RESTRICTION_DEFAULT// age for Lebanon
  51. #define AGE_RESTRICTION_LUXEMBOURG AGE_RESTRICTION_DEFAULT// age for Luxembourg
  52. #define AGE_RESTRICTION_MALTA AGE_RESTRICTION_DEFAULT// age for Malta
  53. #define AGE_RESTRICTION_MEXICO AGE_RESTRICTION_DEFAULT// age for Mexico
  54. #define AGE_RESTRICTION_MALAYSIA AGE_RESTRICTION_DEFAULT// age for Malaysia
  55. #define AGE_RESTRICTION_NETHERLANDS AGE_RESTRICTION_DEFAULT// age for Netherlands
  56. #define AGE_RESTRICTION_NORWAY AGE_RESTRICTION_DEFAULT// age for Norway
  57. #define AGE_RESTRICTION_NEW_ZEALAND AGE_RESTRICTION_DEFAULT// age for New Zealand
  58. #define AGE_RESTRICTION_OMAN AGE_RESTRICTION_DEFAULT// age for Oman
  59. #define AGE_RESTRICTION_PERU AGE_RESTRICTION_DEFAULT// age for Peru
  60. #define AGE_RESTRICTION_POLAND AGE_RESTRICTION_DEFAULT// age for Poland
  61. #define AGE_RESTRICTION_PORTUGAL AGE_RESTRICTION_DEFAULT// age for Portugal
  62. #define AGE_RESTRICTION_QATAR AGE_RESTRICTION_DEFAULT// age for Qatar
  63. #define AGE_RESTRICTION_ROMAINIA AGE_RESTRICTION_DEFAULT// age for Romania
  64. #define AGE_RESTRICTION_RUSSIA AGE_RESTRICTION_DEFAULT// age for Russia
  65. #define AGE_RESTRICTION_SAUDI_ARABIA AGE_RESTRICTION_DEFAULT// age for Saudi Arabia
  66. #define AGE_RESTRICTION_SWEDEN AGE_RESTRICTION_DEFAULT// age for Sweden
  67. #define AGE_RESTRICTION_SINGAPORE AGE_RESTRICTION_DEFAULT// age for Singapore
  68. #define AGE_RESTRICTION_SLOVENIA AGE_RESTRICTION_DEFAULT// age for Slovenia
  69. #define AGE_RESTRICTION_SLOVAKIA AGE_RESTRICTION_DEFAULT// age for Slovakia
  70. #define AGE_RESTRICTION_THAILAND AGE_RESTRICTION_DEFAULT// age for Thailand
  71. #define AGE_RESTRICTION_TURKEY AGE_RESTRICTION_DEFAULT// age for Turkey
  72. #define AGE_RESTRICTION_TAIWAN AGE_RESTRICTION_DEFAULT// age for Taiwan
  73. #define AGE_RESTRICTION_UKRAINE AGE_RESTRICTION_DEFAULT// age for Ukraine
  74. #define AGE_RESTRICTION_UNITED_STATES AGE_RESTRICTION_DEFAULT// age for United States
  75. #define AGE_RESTRICTION_SOUTH_AFRICA AGE_RESTRICTION_DEFAULT// age for South Africa
  76. int EngineHelperPS3::GetAgeRestrictionByRegion( void )
  77. {
  78. SceNpCountryCode countryCode;
  79. int langCode;
  80. int ret = sceNpManagerGetAccountRegion( &countryCode, &langCode );
  81. if ( ret < 0 )
  82. {
  83. return AGE_RESTRICTION_MAX;
  84. }
  85. if ( strcmp( countryCode.data, "ae" ) == 0 )
  86. return AGE_RESTRICTION_UAE;// age for UAE
  87. if ( strcmp( countryCode.data, "ar" ) == 0 )
  88. return AGE_RESTRICTION_ARGENTINIA;// age for Argentina
  89. if ( strcmp( countryCode.data, "at" ) == 0 )
  90. return AGE_RESTRICTION_AUSTRIA;// age for Austria
  91. if ( strcmp( countryCode.data, "au" ) == 0 )
  92. return AGE_RESTRICTION_AUSTRALIA;// age for Australia
  93. if ( strcmp( countryCode.data, "be" ) == 0 )
  94. return AGE_RESTRICTION_BELGIUM;// age for Belgium
  95. if ( strcmp( countryCode.data, "bg" ) == 0 )
  96. return AGE_RESTRICTION_BULGARIA;// age for Bulgaria
  97. if ( strcmp( countryCode.data, "bh" ) == 0 )
  98. return AGE_RESTRICTION_BAHRAIN;// age for Bahrain
  99. if ( strcmp( countryCode.data, "br" ) == 0 )
  100. return AGE_RESTRICTION_BRAZIL;// age for Brazil
  101. if ( strcmp( countryCode.data, "ca" ) == 0 )
  102. return AGE_RESTRICTION_CANADA;// age for Canada
  103. if ( strcmp( countryCode.data, "ch" ) == 0 )
  104. return AGE_RESTRICTION_SWISS;// age for Switzerland
  105. if ( strcmp( countryCode.data, "cl" ) == 0 )
  106. return AGE_RESTRICTION_CHILE;// age for Chile
  107. if ( strcmp( countryCode.data, "co" ) == 0 )
  108. return AGE_RESTRICTION_COLOMBIA;// age for Colombia
  109. if ( strcmp( countryCode.data, "cy" ) == 0 )
  110. return AGE_RESTRICTION_CYPRUS;// age for Cyprus
  111. if ( strcmp( countryCode.data, "cz" ) == 0 )
  112. return AGE_RESTRICTION_CZECH_REP;// age for Czech Republic
  113. if ( strcmp( countryCode.data, "de" ) == 0 )
  114. return AGE_RESTRICTION_GERMANY;// age for Germany
  115. if ( strcmp( countryCode.data, "dk" ) == 0 )
  116. return AGE_RESTRICTION_DENMARK;// age for Denmark
  117. if ( strcmp( countryCode.data, "es" ) == 0 )
  118. return AGE_RESTRICTION_SPAIN;// age for Spain
  119. if ( strcmp( countryCode.data, "fi" ) == 0 )
  120. return AGE_RESTRICTION_FINLAND;// age for Finland
  121. if ( strcmp( countryCode.data, "fr" ) == 0 )
  122. return AGE_RESTRICTION_FRANCE;// age for France
  123. if ( strcmp( countryCode.data, "gb" ) == 0 )
  124. return AGE_RESTRICTION_UK;// age for UK
  125. if ( strcmp( countryCode.data, "gr" ) == 0 )
  126. return AGE_RESTRICTION_GREECE;// age for Greece
  127. if ( strcmp( countryCode.data, "hk" ) == 0 )
  128. return AGE_RESTRICTION_HONG_KONG;// age for Hong Kong
  129. if ( strcmp( countryCode.data, "hr" ) == 0 )
  130. return AGE_RESTRICTION_CROATIA;// age for Croatia
  131. if ( strcmp( countryCode.data, "hu" ) == 0 )
  132. return AGE_RESTRICTION_HUNGARY;// age for Hungary
  133. if ( strcmp( countryCode.data, "id" ) == 0 )
  134. return AGE_RESTRICTION_INDONESIA;// age for Indonesia
  135. if ( strcmp( countryCode.data, "ie" ) == 0 )
  136. return AGE_RESTRICTION_IRELAND;// age for Ireland
  137. if ( strcmp( countryCode.data, "il" ) == 0 )
  138. return AGE_RESTRICTION_ISREAL;// age for Isreal
  139. if ( strcmp( countryCode.data, "in" ) == 0 )
  140. return AGE_RESTRICTION_INDIA;// age for India
  141. if ( strcmp( countryCode.data, "is" ) == 0 )
  142. return AGE_RESTRICTION_ICELAND;// age for Iceland
  143. if ( strcmp( countryCode.data, "it" ) == 0 )
  144. return AGE_RESTRICTION_ITALY;// age for Italy
  145. if ( strcmp( countryCode.data, "jp" ) == 0 )
  146. return AGE_RESTRICTION_JAPAN;// age for Japan
  147. if ( strcmp( countryCode.data, "kr" ) == 0 )
  148. return AGE_RESTRICTION_KOREA;// age for Korea
  149. if ( strcmp( countryCode.data, "kw" ) == 0 )
  150. return AGE_RESTRICTION_KUWAIT;// age for Kuwait
  151. if ( strcmp( countryCode.data, "lb" ) == 0 )
  152. return AGE_RESTRICTION_LEBANON;// age for Lebanon
  153. if ( strcmp( countryCode.data, "lu" ) == 0 )
  154. return AGE_RESTRICTION_LUXEMBOURG;// age for Luxembourg
  155. if ( strcmp( countryCode.data, "mt" ) == 0 )
  156. return AGE_RESTRICTION_MALTA;// age for Malta
  157. if ( strcmp( countryCode.data, "mx" ) == 0 )
  158. return AGE_RESTRICTION_MEXICO;// age for Mexico
  159. if ( strcmp( countryCode.data, "my" ) == 0 )
  160. return AGE_RESTRICTION_MALAYSIA;// age for Malaysia
  161. if ( strcmp( countryCode.data, "nl" ) == 0 )
  162. return AGE_RESTRICTION_NETHERLANDS;// age for Netherlands
  163. if ( strcmp( countryCode.data, "no" ) == 0 )
  164. return AGE_RESTRICTION_NORWAY;// age for Norway
  165. if ( strcmp( countryCode.data, "nz" ) == 0 )
  166. return AGE_RESTRICTION_NEW_ZEALAND;// age for New Zealand
  167. if ( strcmp( countryCode.data, "om" ) == 0 )
  168. return AGE_RESTRICTION_OMAN;// age for Oman
  169. if ( strcmp( countryCode.data, "pe" ) == 0 )
  170. return AGE_RESTRICTION_PERU;// age for Peru
  171. if ( strcmp( countryCode.data, "pl" ) == 0 )
  172. return AGE_RESTRICTION_POLAND;// age for Poland
  173. if ( strcmp( countryCode.data, "pt" ) == 0 )
  174. return AGE_RESTRICTION_PORTUGAL;// age for Portugal
  175. if ( strcmp( countryCode.data, "qa" ) == 0 )
  176. return AGE_RESTRICTION_QATAR;// age for Qatar
  177. if ( strcmp( countryCode.data, "ro" ) == 0 )
  178. return AGE_RESTRICTION_ROMAINIA;// age for Romania
  179. if ( strcmp( countryCode.data, "ru" ) == 0 )
  180. return AGE_RESTRICTION_RUSSIA;// age for Russia
  181. if ( strcmp( countryCode.data, "sa" ) == 0 )
  182. return AGE_RESTRICTION_SAUDI_ARABIA;// age for Saudi Arabia
  183. if ( strcmp( countryCode.data, "se" ) == 0 )
  184. return AGE_RESTRICTION_SWEDEN;// age for Sweden
  185. if ( strcmp( countryCode.data, "sg" ) == 0 )
  186. return AGE_RESTRICTION_SINGAPORE;// age for Singapore
  187. if ( strcmp( countryCode.data, "si" ) == 0 )
  188. return AGE_RESTRICTION_SLOVENIA;// age for Slovenia
  189. if ( strcmp( countryCode.data, "sk" ) == 0 )
  190. return AGE_RESTRICTION_SLOVAKIA;// age for Slovakia
  191. if ( strcmp( countryCode.data, "th" ) == 0 )
  192. return AGE_RESTRICTION_THAILAND;// age for Thailand
  193. if ( strcmp( countryCode.data, "tr" ) == 0 )
  194. return AGE_RESTRICTION_TURKEY;// age for Turkey
  195. if ( strcmp( countryCode.data, "tw" ) == 0 )
  196. return AGE_RESTRICTION_TAIWAN;// age for Taiwan
  197. if ( strcmp( countryCode.data, "ua" ) == 0 )
  198. return AGE_RESTRICTION_UKRAINE;// age for Ukraine
  199. if ( strcmp( countryCode.data, "us" ) == 0 )
  200. return AGE_RESTRICTION_UNITED_STATES;// age for United States
  201. if ( strcmp( countryCode.data, "za" ) == 0 )
  202. return AGE_RESTRICTION_SOUTH_AFRICA;// age for South Africa
  203. return AGE_RESTRICTION_DEFAULT;
  204. }
  205. // note: We assume if we aren't connected or initialized, that the chat is NOT restricted
  206. bool EngineHelperPS3::PS3_IsUserRestrictedFromChat( void )
  207. {
  208. int isRestricted;
  209. int ret = sceNpManagerGetChatRestrictionFlag( &isRestricted );
  210. if (ret < 0)
  211. {
  212. // handle the error
  213. if ( ret == SCE_NP_ERROR_NOT_INITIALIZED )
  214. {
  215. // not yet initialized... check back in a bit
  216. return false;
  217. }
  218. if ( ret == SCE_NP_ERROR_INVALID_STATE )
  219. {
  220. // invalid state... sign in procedure hasn't been completed yet
  221. return false;
  222. }
  223. if ( ret == SCE_NP_ERROR_OFFLINE )
  224. {
  225. // we're offline, no account info available
  226. return false;
  227. }
  228. return false;
  229. }
  230. if ( isRestricted )
  231. {
  232. return true;
  233. }
  234. else
  235. {
  236. return false;
  237. }
  238. }
  239. // NOTE: If we're not signed in yet, or not initialized, we consider this as not restricted from online
  240. bool EngineHelperPS3::PS3_IsUserRestrictedFromOnline( void )
  241. {
  242. int age;
  243. int isRestricted;
  244. int ret;
  245. ret = sceNpManagerGetAccountAge( &age );
  246. if ( ret < 0 )
  247. {
  248. if ( ret == SCE_NP_ERROR_NOT_INITIALIZED )
  249. {
  250. // not yet initialized... check back in a bit
  251. return false;
  252. }
  253. if ( ret == SCE_NP_ERROR_INVALID_STATE )
  254. {
  255. // invalid state... sign in procedure hasn't been completed yet
  256. return false;
  257. }
  258. if ( ret == SCE_NP_ERROR_OFFLINE )
  259. {
  260. // we're offline, no account info available
  261. return false;
  262. }
  263. return false;
  264. }
  265. ret = sceNpManagerGetContentRatingFlag( &isRestricted, &age );
  266. if ( isRestricted && age < GetAgeRestrictionByRegion() )
  267. {
  268. return true;
  269. }
  270. else
  271. {
  272. return false;
  273. }
  274. }
  275. bool EngineHelperPS3::PS3_PendingInvitesFound( void )
  276. {
  277. uint32_t count = 0;
  278. if ( sceNpBasicGetMessageEntryCount( SCE_NP_BASIC_MESSAGE_INFO_TYPE_BOOTABLE_INVITATION, &count ) == 0 )
  279. {
  280. if ( count > 0 )
  281. {
  282. return true;
  283. }
  284. }
  285. return false;
  286. }
  287. void EngineHelperPS3::PS3_ShowInviteOverlay( void )
  288. {
  289. sceNpBasicRecvMessageCustom( SCE_NP_BASIC_MESSAGE_MAIN_TYPE_INVITE,
  290. SCE_NP_BASIC_RECV_MESSAGE_OPTIONS_INCLUDE_BOOTABLE,
  291. SYS_MEMORY_CONTAINER_ID_INVALID );
  292. }
  293. #endif // _PS3