OnlineDatabase.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Mono.Data.Sqlite;
  5. using System.Data;
  6. using System;
  7. using UnityEngine.Networking;
  8. using System.IO;
  9. using System.Text;
  10. public class OnlineDatabase : MonoBehaviour {
  11. private const string onlineQuestionsUrl = "narkampen.nordh.xyz/narKampen/dbFiles/Question.php";
  12. private const string serverUrl = "narkampen.nordh.xyz/narKampen/dbFiles/";
  13. string gameMode;
  14. int winAmount = -1;
  15. public GameObject questionCardPrefab;
  16. private static OnlineDatabase instance;
  17. public static OnlineDatabase Instance { get { return instance; } }
  18. private void Awake() {
  19. if (instance == null) {
  20. instance = this;
  21. }
  22. }
  23. internal List<CategoryPanel.Category> GetCategories(List<CategoryPanel.Category> list, int gameId) {
  24. WWWForm form = new WWWForm();
  25. form.AddField("gameId", gameId);
  26. string response = CallOnlineDatabaseWithResponse("Categories.php", form);
  27. response = "{\"categoryList\" : " + response + " }";
  28. Categories categories = new Categories();
  29. JsonUtility.FromJsonOverwrite(response, categories);
  30. foreach (Category c in categories.categoryList) {
  31. CategoryPanel.Category cat = new CategoryPanel.Category();
  32. cat.color = new Color32((byte)c.r, (byte)c.g, (byte)c.b, (byte)c.a);
  33. cat.name = c.name;
  34. cat.id = c.id;
  35. cat.questionCount = c.count;
  36. list.Add(cat);
  37. }
  38. return list;
  39. }
  40. internal int SetupNewOnlineGame(int limitPerQuestion, int limitPerPlayer, int toWin, List<InviteSearchResult> inviteUsers, List<int> selectedCategories) {
  41. List<int> playerIds = new List<int>();
  42. inviteUsers.ForEach(i => playerIds.Add(i.GetId()));
  43. int currentUser = Database.Instance.GetSignedInUser().Key;
  44. playerIds.Add(currentUser);
  45. var form = new WWWForm();
  46. form.AddField("currentUser", currentUser);
  47. form.AddField("winNumber", toWin);
  48. form.AddField("limitPerQuestion", limitPerQuestion);
  49. form.AddField("limitPerPlayer", limitPerPlayer);
  50. form.AddField("playerIds", String.Join(",", playerIds));
  51. form.AddField("categoryIds", String.Join(",", selectedCategories));
  52. string response = CallOnlineDatabaseWithResponse("NewOnlineGame.php", form);
  53. if (response.Equals("")) {
  54. Debug.Log("Expected gameId in response for creating new game but did not get one");
  55. }
  56. if (Int32.TryParse(response, out int newGameId)) {
  57. return newGameId;
  58. } else {
  59. Debug.Log("Failed to get new game id with response " + response);
  60. return -1;
  61. }
  62. }
  63. [Serializable]
  64. public class Question {
  65. public string question;
  66. public string answer;
  67. public string id;
  68. public string category;
  69. public string categoryName;
  70. public int r;
  71. public int g;
  72. public int b;
  73. public int a;
  74. }
  75. [Serializable]
  76. public class Questions {
  77. public List<Question> questionsList = new List<Question>();
  78. }
  79. [Serializable]
  80. public class PlayerInfo {
  81. public string username;
  82. public string status;
  83. }
  84. [Serializable]
  85. public class PlayerInfos {
  86. public List<PlayerInfo> playerInfoList = new List<PlayerInfo>();
  87. }
  88. [Serializable]
  89. public class GamePlayerInfo {
  90. public string username;
  91. public string userLockedQuestions;
  92. }
  93. [Serializable]
  94. public class GamePlayerInfos {
  95. public List<GamePlayerInfo> gamePlayerInfoList = new List<GamePlayerInfo>();
  96. }
  97. [Serializable]
  98. public class Category {
  99. public int r;
  100. public int g;
  101. public int b;
  102. public int a;
  103. public int id;
  104. public string name;
  105. public int count;
  106. }
  107. [Serializable]
  108. public class Categories {
  109. public List<Category> categoryList = new List<Category>();
  110. }
  111. [Serializable]
  112. public class OnlineGame {
  113. public string id;
  114. public string winNumber;
  115. public string answerTimer;
  116. public string roundTimeLimit;
  117. public string currentPlayer;
  118. public string round;
  119. public string startDate;
  120. public string lastPlayedDate;
  121. public string finishedDate;
  122. public string status;
  123. public string playerToAct;
  124. }
  125. [Serializable]
  126. public class OnlineGames {
  127. public List<OnlineGame> onlineGamesList = new List<OnlineGame>();
  128. }
  129. [Serializable]
  130. public class UserName {
  131. public string id;
  132. public string username;
  133. }
  134. [Serializable]
  135. public class UserNames {
  136. public List<UserName> usernamesList = new List<UserName>();
  137. }
  138. private void CallDatabase(string filename, WWWForm formData) {
  139. string postUrl = serverUrl + filename;
  140. UnityWebRequest www = UnityWebRequest.Post(postUrl, formData);
  141. www.SendWebRequest();
  142. if (www.isNetworkError || www.isHttpError) {
  143. Debug.Log(www.error);
  144. } else {
  145. while (!www.isDone) {
  146. }
  147. }
  148. }
  149. private string CallOnlineDatabaseWithResponse(string filename, WWWForm formData) {
  150. string postUrl = serverUrl + filename;
  151. UnityWebRequest www = UnityWebRequest.Post(postUrl, formData);
  152. www.SendWebRequest();
  153. if (www.isNetworkError || www.isHttpError) {
  154. Debug.Log(www.error);
  155. } else {
  156. while (!www.isDone) {
  157. }
  158. }
  159. return www.downloadHandler.text;
  160. }
  161. string questionString = "";
  162. string answerString = "";
  163. string idString = "";
  164. string categoryString = "";
  165. public string QuestionString { get => questionString; set => questionString = value; }
  166. private void Start() {
  167. if (instance == null) {
  168. instance = this;
  169. }
  170. }
  171. internal void SetLastPlayedDate(int gameId) {
  172. WWWForm form = new WWWForm();
  173. form.AddField("gameId", gameId);
  174. form.AddField("f", "SetLastPlayed");
  175. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  176. if (!response.Equals("")) {
  177. Debug.Log(response);
  178. }
  179. }
  180. internal void DeclineOnlineGame(string userName, int gameId) {
  181. WWWForm formData = new WWWForm();
  182. formData.AddField("userId", -1);
  183. formData.AddField("f", "decline");
  184. formData.AddField("gameId", gameId);
  185. formData.AddField("userName", userName);
  186. CallDatabase("OnlineGames.php", formData);
  187. }
  188. internal void AcceptOnlineGame(string userName, int gameId) {
  189. WWWForm formData = new WWWForm();
  190. formData.AddField("userId", -1);
  191. formData.AddField("f", "accept");
  192. formData.AddField("gameId", gameId);
  193. formData.AddField("userName", userName);
  194. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", formData);
  195. if (!response.Equals("")) {
  196. Debug.Log(response);
  197. }
  198. }
  199. internal List<OnlineGameScript> GetOnlineGames(int userId, string userName, GameObject prefab) {
  200. WWWForm formData = new WWWForm();
  201. formData.AddField("userId", userId);
  202. formData.AddField("f", "list");
  203. formData.AddField("gameId", -1);
  204. formData.AddField("userName", userName);
  205. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", formData);
  206. if (response.Equals("No games found for user") || response.Equals("")) {
  207. return null;
  208. }
  209. response = "{\"onlineGamesList\" : " + response + " }";
  210. OnlineGames og = new OnlineGames();
  211. JsonUtility.FromJsonOverwrite(response, og);
  212. GameObject onlineGameObject;
  213. OnlineGameScript ogs = null;
  214. List<OnlineGameScript> games = new List<OnlineGameScript>();
  215. foreach (OnlineGame game in og.onlineGamesList) {
  216. onlineGameObject = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
  217. ogs = onlineGameObject.GetComponent<OnlineGameScript>();
  218. ogs.CurrentPlayer = game.currentPlayer;
  219. ogs.SetGameStatus(game.status);
  220. Int32.TryParse(game.id, out int gameId);
  221. List<KeyValuePair<string, string>> playerInfos = GetGameInfo(gameId);
  222. if (game.status.Equals("PENDING")) {
  223. string extraInfo = "";
  224. foreach (KeyValuePair<string, string> s in playerInfos) {
  225. if (s.Value.Equals("WAITING") && s.Key.Equals(userName, StringComparison.InvariantCultureIgnoreCase)) {
  226. ogs.SetGameStatus("INVITED");
  227. extraInfo += s.Key + ",";
  228. } else if (s.Value.EndsWith("WAITING")) {
  229. extraInfo += s.Key + ",";
  230. }
  231. }
  232. extraInfo = extraInfo.TrimEnd(',');
  233. ogs.SetGameStatusText(extraInfo);
  234. } else if (game.status.Equals("OTHERS_TURN")) {
  235. ogs.SetGameStatusText(game.playerToAct);
  236. } else if (game.status.Equals("ACTIVE")) {
  237. ogs.SetGameStatusText(game.playerToAct);
  238. } else {
  239. ogs.SetGameStatusText();
  240. }
  241. ogs.SetId(game.id);
  242. ogs.SetWinNumber(game.winNumber);
  243. ogs.SetAnswerTimer(game.answerTimer);
  244. ogs.SetRoundTimeLimit(game.roundTimeLimit);
  245. ogs.SetRound(game.round);
  246. ogs.StartDate = game.startDate;
  247. ogs.LastPlayedDate = game.lastPlayedDate;
  248. games.Add(ogs);
  249. ogs.PlayerInfos = playerInfos;
  250. }
  251. return games;
  252. }
  253. internal List<KeyValuePair<string, string>> GetGameInfo(int gameId) {
  254. List<KeyValuePair<string, string>> returnList = new List<KeyValuePair<string, string>>();
  255. WWWForm form = new WWWForm();
  256. form.AddField("f", "GetGameInfo");
  257. form.AddField("gameId", gameId);
  258. string response = CallOnlineDatabaseWithResponse("OnlineGameInfo.php", form);
  259. response = "{\"playerInfoList\" : " + response + " }";
  260. PlayerInfos pi = new PlayerInfos();
  261. JsonUtility.FromJsonOverwrite(response, pi);
  262. foreach (PlayerInfo p in pi.playerInfoList) {
  263. KeyValuePair<string, string> player = new KeyValuePair<string, string>(p.username, p.status);
  264. returnList.Add(player);
  265. }
  266. return returnList;
  267. }
  268. internal void SetQuestionsLost(int gameId, string playerName, int questionsLost) {
  269. WWWForm form = new WWWForm();
  270. form.AddField("f", "SetQuestionsLost");
  271. form.AddField("questionsLost", questionsLost);
  272. form.AddField("userName", playerName);
  273. form.AddField("gameId", gameId);
  274. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  275. if (!response.Equals("")) {
  276. Debug.Log(response);
  277. }
  278. }
  279. internal void RemoveGame(int gameId) {
  280. WWWForm form = new WWWForm();
  281. form.AddField("f", "DeleteGame");
  282. form.AddField("gameId", gameId);
  283. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  284. if (!response.Equals("")) {
  285. Debug.Log(response);
  286. }
  287. }
  288. public string GetCurrentPlayer(int gameId) {
  289. WWWForm form = new WWWForm();
  290. form.AddField("f", "CurrentPlayer");
  291. form.AddField("gameId", gameId);
  292. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  293. if (response.Equals("")) {
  294. Debug.Log("Something wrong with current player for game with id: " + gameId);
  295. }
  296. return response;
  297. }
  298. public void SetCurrentPlayer(int gameId, string currentPlayer) {
  299. WWWForm form = new WWWForm();
  300. form.AddField("f", "SetCurrentPlayer");
  301. form.AddField("gameId", gameId);
  302. form.AddField("userName", currentPlayer);
  303. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  304. if (!response.Equals("")) {
  305. Debug.Log(response);
  306. }
  307. }
  308. internal int GetPlayerPoints(int gameId, string playerName) {
  309. WWWForm form = new WWWForm();
  310. form.AddField("f", "GetPlayerPoints");
  311. form.AddField("gameId", gameId);
  312. form.AddField("userName", playerName);
  313. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  314. if (response.Equals("")) {
  315. Debug.Log("Something wrong with current player for game with id: " + gameId);
  316. }
  317. Int32.TryParse(response, out int playerPoints);
  318. return playerPoints;
  319. }
  320. internal void SetFinishedDate(int gameId, string finishedDate) {
  321. WWWForm form = new WWWForm();
  322. form.AddField("f", "SetFinishedDate");
  323. form.AddField("gameId", gameId);
  324. form.AddField("finishedDate", finishedDate);
  325. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  326. if (!response.Equals("")) {
  327. Debug.Log(response);
  328. }
  329. }
  330. internal void SetRoundValue(int gameId, int round) {
  331. WWWForm form = new WWWForm();
  332. form.AddField("f", "SetRound");
  333. form.AddField("gameId", gameId);
  334. form.AddField("round", round);
  335. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  336. if (!response.Equals("")) {
  337. Debug.Log(response);
  338. }
  339. }
  340. internal int GetRoundValue(int gameId) {
  341. WWWForm form = new WWWForm();
  342. form.AddField("f", "GetRound");
  343. form.AddField("gameId", gameId);
  344. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  345. if (response.Equals("")) {
  346. Debug.Log("Something wrong with getting round for game with id: " + gameId);
  347. }
  348. Int32.TryParse(response, out int round);
  349. return round;
  350. }
  351. internal List<KeyValuePair<string, int>> GetPlayersForGame(int gameId) {
  352. WWWForm form = new WWWForm();
  353. form.AddField("f", "GetPlayers");
  354. form.AddField("gameId", gameId);
  355. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  356. if (response.Equals("")) {
  357. Debug.Log("Something wrong with getting players from game with id: " + gameId);
  358. }
  359. response = response = "{\"gamePlayerInfoList\" : " + response + " }";
  360. GamePlayerInfos gpi = new GamePlayerInfos();
  361. JsonUtility.FromJsonOverwrite(response, gpi);
  362. List<KeyValuePair<string, int>> returnList = new List<KeyValuePair<string, int>>();
  363. foreach (GamePlayerInfo p in gpi.gamePlayerInfoList) {
  364. Int32.TryParse(p.userLockedQuestions, out int points);
  365. KeyValuePair<string, int> player = new KeyValuePair<string, int>(p.username, points);
  366. returnList.Add(player);
  367. }
  368. return returnList;
  369. }
  370. public string AnswerString { get => answerString; set => answerString = value; }
  371. public string IdString { get => idString; set => idString = value; }
  372. public string CategoryString { get => categoryString; set => categoryString = value; }
  373. internal int GetQuestionsLost(int gameId, string playerName) {
  374. WWWForm form = new WWWForm();
  375. form.AddField("f", "GetQuestionsLost");
  376. form.AddField("userName", playerName);
  377. form.AddField("gameId", gameId);
  378. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  379. if (response.Equals("")) {
  380. Debug.Log("Something wrong with getting questions lost from game with id: " + gameId + " and playername " + playerName);
  381. }
  382. Int32.TryParse(response, out int questionsLost);
  383. return questionsLost;
  384. }
  385. internal int GetWinCondition(int gameId) {
  386. if (winAmount == -1) {
  387. WWWForm form = new WWWForm();
  388. form.AddField("gameId", gameId);
  389. form.AddField("f", "GetWinCondition");
  390. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  391. Int32.TryParse(response, out this.winAmount);
  392. }
  393. return this.winAmount;
  394. }
  395. public NewQuestionData newQuestionData;
  396. public NewQuestionData GetNewQuestion(List<int> userAnsweredQuestions, string userName) {
  397. int gameId = GameObject.Find("GameManager").GetComponent<GameManagerScript>().GameId;
  398. Question q = GetQuestionData(gameId);
  399. Color32 categoryColor = new Color32((byte)q.r, (byte)q.g, (byte)q.b, (byte)q.a);
  400. // Color32 questionCategoryColor = new Color32((byte)q.r, (byte)q.g, (byte)q.b, (byte)q.a);
  401. Int32.TryParse(q.category, out int categoryId);
  402. Int32.TryParse(q.id, out int questionId);
  403. NewQuestionData questionData = new NewQuestionData(q.answer, q.question, q.categoryName, categoryId, questionId, categoryColor);
  404. return questionData;
  405. }
  406. public void SavePlayersQuestion(List<int> questionsToSave, string playerNameValue, int gameId) {
  407. WWWForm form = new WWWForm();
  408. form.AddField("f", "SavePlayerQuestions");
  409. form.AddField("gameId", gameId);
  410. form.AddField("questionsToSave", String.Join(",",questionsToSave));
  411. form.AddField("userName", playerNameValue);
  412. string response = CallOnlineDatabaseWithResponse("OnlineGames.php", form);
  413. if (!response.Equals("")) {
  414. Debug.Log(response);
  415. }
  416. }
  417. public List<NewQuestionData> GetPlayerQuestions(int gameId, string playerName) {
  418. List<NewQuestionData> questions = new List<NewQuestionData>();
  419. WWWForm form = new WWWForm();
  420. form.AddField("f", "PlayerQuestions");
  421. form.AddField("gameId", gameId);
  422. form.AddField("userName", playerName);
  423. string response = CallOnlineDatabaseWithResponse("OnlineGameInfo.php", form);
  424. response = "{\"questionsList\" : " + response + "}";
  425. Questions ql = new Questions();
  426. JsonUtility.FromJsonOverwrite(response, ql);
  427. foreach (Question q in ql.questionsList) {
  428. /*GameObject question = Instantiate(questionCardPrefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
  429. NewQuestionData qc = question.GetComponent<NewQuestionData>();
  430. */
  431. Color categoryColor = new Color(q.r, q.g, q.b, q.a);
  432. // Color32 questionCategoryColor = new Color32((byte)q.r, (byte)q.g, (byte)q.b, (byte)q.a);
  433. Int32.TryParse(q.category, out int categoryId);
  434. Int32.TryParse(q.id, out int questionId);
  435. NewQuestionData questionData = new NewQuestionData(q.answer, q.question, q.categoryName, categoryId, questionId, categoryColor);
  436. questions.Add(questionData);
  437. }
  438. return questions;
  439. }
  440. private Question GetQuestionData(int gameId) {
  441. WWWForm form = new WWWForm();
  442. form.AddField("gameId", gameId);
  443. string response = CallOnlineDatabaseWithResponse("Question.php", form);
  444. // Show result
  445. response = "{\"questionsList\" : [ " + response + " ]}";
  446. Questions qe = new Questions();
  447. JsonUtility.FromJsonOverwrite(response, qe);
  448. return qe.questionsList[0];
  449. }
  450. public List<UserName> GetUsersToInvite(string searchString) {
  451. string postUrl = "narkampen.nordh.xyz/narKampen/dbFiles/PlayerSearch.php?";
  452. postUrl += "search=" + UnityWebRequest.EscapeURL(searchString);
  453. UserNames uNames = new UserNames();
  454. UnityWebRequest www = UnityWebRequest.Get(postUrl);
  455. www.SendWebRequest();
  456. if (www.isNetworkError || www.isHttpError) {
  457. Debug.Log(www.error);
  458. } else {
  459. while (!www.isDone) {
  460. }
  461. // Show result
  462. string jsonData = www.downloadHandler.text;
  463. if (!jsonData.Equals("")) {
  464. jsonData = "{\"usernamesList\" : " + jsonData + " }";
  465. JsonUtility.FromJsonOverwrite(jsonData, uNames);
  466. }
  467. }
  468. // TODO handle empty
  469. return uNames.usernamesList;
  470. }
  471. internal void SendNextPlayerMessage(int gameId, String nextPlayer)
  472. {
  473. WWWForm form = new WWWForm();
  474. form.AddField("gameId", gameId);
  475. form.AddField("playerName", nextPlayer);
  476. form.AddField("title", LocalizationManager.Instance.GetText("FCM_NEXT_PLAYER_TITLE"));
  477. List<KeyValuePair<string, int>> players = OnlineDatabase.Instance.GetPlayersForGame(gameId);
  478. StringBuilder sb = new StringBuilder();
  479. foreach (KeyValuePair<String, int> player in players)
  480. {
  481. sb.AppendLine(player.Key + " (" + player.Value + ")");
  482. }
  483. String message = String.Format(LocalizationManager.Instance.GetText("FCM_NEXT_PLAYER_MESSAGE"),sb.ToString());
  484. form.AddField("message", message);
  485. form.AddField("type", "FCMNextPlayer");
  486. //string response = CallOnlineDatabaseWithResponse("FCMNextPlayer.php", form);
  487. CallDatabase("FCMMessageing.php", form);
  488. }
  489. internal void SendInviteForNewGame(int gameId, List<String> Players, String inviter) {
  490. WWWForm form = new WWWForm();
  491. form.AddField("gameId", gameId);
  492. int index = 0;
  493. foreach(String player in Players) {
  494. form.AddField("player" + index++, player);
  495. }
  496. form.AddField("title", LocalizationManager.Instance.GetText("FCM_NEW_GAME_TITLE"));
  497. form.AddField("message", String.Format(LocalizationManager.Instance.GetText("FCM_NEW_GAME_MESSAGE"), inviter));
  498. form.AddField("type", "InviteMessage");
  499. CallDatabase("FCMMessageing.php", form);
  500. }
  501. internal void UpdatePlayerToken(int userId, string myToken)
  502. {
  503. WWWForm form = new WWWForm();
  504. form.AddField("userId", userId);
  505. form.AddField("token", myToken);
  506. form.AddField("f", "UpdatePlayerToken");
  507. CallDatabase("OnlineGames.php", form);
  508. }
  509. internal List<string> FindRandomPlayer() {
  510. List<string> returnValue = new List<string>();
  511. WWWForm form = new WWWForm();
  512. form.AddField("f", "FindRandomPlayer");
  513. String response = CallOnlineDatabaseWithResponse("", form);
  514. //TODO FIX ME
  515. return returnValue;
  516. }
  517. }