GitHub PullRequestReviewCommentEvent at 2014-12-12 07:44:37
Repository: Bermuda-TheGame
Actor: PimV
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/comments/21731516","id":21731516,"diff_hunk":"@@ -0,0 +1,182 @@\n+#include \"GameSaver.h\"\n+#include \"header_loader.h\"\n+#include \"PlayState.h\"\n+#include \"Item.h\"\n+#include \"Items.h\"\n+#include \"Achievement.h\"\n+#include \"ItemFactory.h\"\n+#include <vector>\n+#include <Windows.h>\n+#include <fstream>\n+#include <sstream>\n+#include <iostream>\n+#include <rapidjson/document.h>\n+#include <rapidjson/writer.h>\n+#include <rapidjson/stringbuffer.h>\n+\n+using namespace rapidjson;\n+\n+\n+GameSaver::GameSaver()\n+{\n+\tthis->init();\n+}\n+\n+void GameSaver::init()\n+{\n+\tthis->currentSaveFile = \"\";\n+\n+\t//Create save-game directory if it does not exist.\n+\tif (!CreateDirectory(SAVEPATH.c_str(), NULL) &&\n+\t\tERROR_ALREADY_EXISTS != GetLastError())\n+\t{\n+\t\t// Failed to create directory.\n+\t\tstd::cout << \"Could not create save file directory. (\"+SAVEPATH+\")\" << std::endl;\n+\t\treturn;\n+\t}\n+\n+\t//Set current save file name to the first new available name.\n+\tint saveNumber = 0;\n+\tstd::ifstream f;\n+\twhile (f.good()) \n+\t{\n+\t\tf.close();\n+\t\tthis->currentSaveFile = \"Game\" + std::to_string(saveNumber) + \".json\";\n+\t\tf.open(SAVEPATH + this->currentSaveFile);\n+\t\tsaveNumber++;\n+\t}\n+\tf.close();\n+}\n+\n+void GameSaver::changeCurrentSaveFile(std::string fileName)\n+{\n+\tthis->currentSaveFile = fileName;\n+}\n+\n+void GameSaver::loadGame()\n+{\n+\tthis->loadGame(this->currentSaveFile);\n+}\n+\n+void GameSaver::loadGame(std::string fileName)\n+{\n+\tthis->currentSaveFile = fileName;\n+\n+\t//Create file stream.\n+\tstd::ifstream stream(SAVEPATH + this->currentSaveFile);\n+\tif (!stream.is_open())\n+\t{\n+\t\tstd::cout << \"Could not load save file. File \" + this->currentSaveFile + \" could not be found!\" << std::endl;\n+\t\treturn;\n+\t}\n+\n+\t//Read entire file into a string.\n+\tstd::string json;\n+\tstd::string line;\n+\twhile (getline(stream, line))\n+\t{\n+\t\tjson += line;\n+\t}\n+\tstream.close();\n+\n+\t//Parse JSON string into DOM.\n+\tDocument d;\n+\td.Parse(json.c_str());\n+\n+\t//Gametime\n+\tGameTimer::Instance()->setGameTime(d[\"gametime\"].GetDouble());\n+\n+\t//Player stats\n+\tPlayState::Instance()->getPlayer()->setPosition(d[\"player\"][\"x\"].GetDouble(), d[\"player\"][\"y\"].GetDouble());\n+\tPlayState::Instance()->getPlayer()->setHealth(d[\"player\"][\"health\"].GetInt());\n+\tPlayState::Instance()->getPlayer()->setThirst(d[\"player\"][\"thirst\"].GetInt());\n+\tPlayState::Instance()->getPlayer()->setHunger(d[\"player\"][\"hunger\"].GetInt());\n+","path":"Bermuda/Bermuda/GameSaver.cpp","position":94,"original_position":94,"commit_id":"5fbac9c115ca553da7f9504683098b2c116ed67a","original_commit_id":"5fbac9c115ca553da7f9504683098b2c116ed67a","user":{"login":"PimV","id":4227060,"avatar_url":"https://avatars.githubusercontent.com/u/4227060?v=3","gravatar_id":"","url":"https://api.github.com/users/PimV","html_url":"https://github.com/PimV","followers_url":"https://api.github.com/users/PimV/followers","following_url":"https://api.github.com/users/PimV/following{/other_user}","gists_url":"https://api.github.com/users/PimV/gists{/gist_id}","starred_url":"https://api.github.com/users/PimV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PimV/subscriptions","organizations_url":"https://api.github.com/users/PimV/orgs","repos_url":"https://api.github.com/users/PimV/repos","events_url":"https://api.github.com/users/PimV/events{/privacy}","received_events_url":"https://api.github.com/users/PimV/received_events","type":"User","site_admin":false},"body":"Ik zou in deze klasse/methode niet alles direct over pakken van het JSON bestand. Weet namelijk niet wat er gebeurt, maar als je nou bijvoorbeeld de savegame aan zou passen dat Health geen 80 is, maar 120 (of \"abc\"), dan wordt er geen foutmelding gegeven?","created_at":"2014-12-12T07:44:37Z","updated_at":"2014-12-12T07:44:37Z","html_url":"https://github.com/PimV/Bermuda-TheGame/pull/116#discussion_r21731516","pull_request_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/comments/21731516"},"html":{"href":"https://github.com/PimV/Bermuda-TheGame/pull/116#discussion_r21731516"},"pull_request":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116","id":25849794,"html_url":"https://github.com/PimV/Bermuda-TheGame/pull/116","diff_url":"https://github.com/PimV/Bermuda-TheGame/pull/116.diff","patch_url":"https://github.com/PimV/Bermuda-TheGame/pull/116.patch","issue_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/116","number":116,"state":"open","locked":false,"title":"Save & load game","user":{"login":"JohanBeekers","id":3511550,"avatar_url":"https://avatars.githubusercontent.com/u/3511550?v=3","gravatar_id":"","url":"https://api.github.com/users/JohanBeekers","html_url":"https://github.com/JohanBeekers","followers_url":"https://api.github.com/users/JohanBeekers/followers","following_url":"https://api.github.com/users/JohanBeekers/following{/other_user}","gists_url":"https://api.github.com/users/JohanBeekers/gists{/gist_id}","starred_url":"https://api.github.com/users/JohanBeekers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohanBeekers/subscriptions","organizations_url":"https://api.github.com/users/JohanBeekers/orgs","repos_url":"https://api.github.com/users/JohanBeekers/repos","events_url":"https://api.github.com/users/JohanBeekers/events{/privacy}","received_events_url":"https://api.github.com/users/JohanBeekers/received_events","type":"User","site_admin":false},"body":"Werkende save & load functionaliteit. \r\nSlaat alleen de positie, stats, achievements, inventory & gametime op. \r\n\r\nOm het LADEN van je vorige game te testen kun je ``` //gameSaver->loadGame(); ``` aanzetten. (bovenin de playstate)\r\nWanneer je het spel pauzeert met escape, word het spel opgeslagen onder Game0.json","created_at":"2014-12-10T19:49:35Z","updated_at":"2014-12-12T07:44:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e89fbff9bd1391ba7c24a43e89253fa728ea209","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116/commits","review_comments_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116/comments","review_comment_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/comments/{number}","comments_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/116/comments","statuses_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/statuses/5fbac9c115ca553da7f9504683098b2c116ed67a","head":{"label":"PimV:Savegame","ref":"Savegame","sha":"5fbac9c115ca553da7f9504683098b2c116ed67a","user":{"login":"PimV","id":4227060,"avatar_url":"https://avatars.githubusercontent.com/u/4227060?v=3","gravatar_id":"","url":"https://api.github.com/users/PimV","html_url":"https://github.com/PimV","followers_url":"https://api.github.com/users/PimV/followers","following_url":"https://api.github.com/users/PimV/following{/other_user}","gists_url":"https://api.github.com/users/PimV/gists{/gist_id}","starred_url":"https://api.github.com/users/PimV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PimV/subscriptions","organizations_url":"https://api.github.com/users/PimV/orgs","repos_url":"https://api.github.com/users/PimV/repos","events_url":"https://api.github.com/users/PimV/events{/privacy}","received_events_url":"https://api.github.com/users/PimV/received_events","type":"User","site_admin":false},"repo":{"id":24408829,"name":"Bermuda-TheGame","full_name":"PimV/Bermuda-TheGame","owner":{"login":"PimV","id":4227060,"avatar_url":"https://avatars.githubusercontent.com/u/4227060?v=3","gravatar_id":"","url":"https://api.github.com/users/PimV","html_url":"https://github.com/PimV","followers_url":"https://api.github.com/users/PimV/followers","following_url":"https://api.github.com/users/PimV/following{/other_user}","gists_url":"https://api.github.com/users/PimV/gists{/gist_id}","starred_url":"https://api.github.com/users/PimV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PimV/subscriptions","organizations_url":"https://api.github.com/users/PimV/orgs","repos_url":"https://api.github.com/users/PimV/repos","events_url":"https://api.github.com/users/PimV/events{/privacy}","received_events_url":"https://api.github.com/users/PimV/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PimV/Bermuda-TheGame","description":"","fork":false,"url":"https://api.github.com/repos/PimV/Bermuda-TheGame","forks_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/forks","keys_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/teams","hooks_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/hooks","issue_events_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/events{/number}","events_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/events","assignees_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/assignees{/user}","branches_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/branches{/branch}","tags_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/tags","blobs_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/refs{/sha}","trees_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/statuses/{sha}","languages_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/languages","stargazers_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/stargazers","contributors_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/contributors","subscribers_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/subscribers","subscription_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/subscription","commits_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/commits{/sha}","git_commits_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/commits{/sha}","comments_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/comments{/number}","issue_comment_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/comments/{number}","contents_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/contents/{+path}","compare_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/merges","archive_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/downloads","issues_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues{/number}","pulls_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls{/number}","milestones_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/milestones{/number}","notifications_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/labels{/name}","releases_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/releases{/id}","created_at":"2014-09-24T09:26:04Z","updated_at":"2014-11-30T17:55:33Z","pushed_at":"2014-12-11T21:51:52Z","git_url":"git://github.com/PimV/Bermuda-TheGame.git","ssh_url":"git@github.com:PimV/Bermuda-TheGame.git","clone_url":"https://github.com/PimV/Bermuda-TheGame.git","svn_url":"https://github.com/PimV/Bermuda-TheGame","homepage":null,"size":105971,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"PimV:Develop","ref":"Develop","sha":"70c9fe4aa06acf65a8a2473917f7bdfdf9642e69","user":{"login":"PimV","id":4227060,"avatar_url":"https://avatars.githubusercontent.com/u/4227060?v=3","gravatar_id":"","url":"https://api.github.com/users/PimV","html_url":"https://github.com/PimV","followers_url":"https://api.github.com/users/PimV/followers","following_url":"https://api.github.com/users/PimV/following{/other_user}","gists_url":"https://api.github.com/users/PimV/gists{/gist_id}","starred_url":"https://api.github.com/users/PimV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PimV/subscriptions","organizations_url":"https://api.github.com/users/PimV/orgs","repos_url":"https://api.github.com/users/PimV/repos","events_url":"https://api.github.com/users/PimV/events{/privacy}","received_events_url":"https://api.github.com/users/PimV/received_events","type":"User","site_admin":false},"repo":{"id":24408829,"name":"Bermuda-TheGame","full_name":"PimV/Bermuda-TheGame","owner":{"login":"PimV","id":4227060,"avatar_url":"https://avatars.githubusercontent.com/u/4227060?v=3","gravatar_id":"","url":"https://api.github.com/users/PimV","html_url":"https://github.com/PimV","followers_url":"https://api.github.com/users/PimV/followers","following_url":"https://api.github.com/users/PimV/following{/other_user}","gists_url":"https://api.github.com/users/PimV/gists{/gist_id}","starred_url":"https://api.github.com/users/PimV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PimV/subscriptions","organizations_url":"https://api.github.com/users/PimV/orgs","repos_url":"https://api.github.com/users/PimV/repos","events_url":"https://api.github.com/users/PimV/events{/privacy}","received_events_url":"https://api.github.com/users/PimV/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PimV/Bermuda-TheGame","description":"","fork":false,"url":"https://api.github.com/repos/PimV/Bermuda-TheGame","forks_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/forks","keys_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/teams","hooks_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/hooks","issue_events_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/events{/number}","events_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/events","assignees_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/assignees{/user}","branches_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/branches{/branch}","tags_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/tags","blobs_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/refs{/sha}","trees_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/statuses/{sha}","languages_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/languages","stargazers_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/stargazers","contributors_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/contributors","subscribers_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/subscribers","subscription_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/subscription","commits_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/commits{/sha}","git_commits_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/git/commits{/sha}","comments_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/comments{/number}","issue_comment_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/comments/{number}","contents_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/contents/{+path}","compare_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/merges","archive_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/downloads","issues_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues{/number}","pulls_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls{/number}","milestones_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/milestones{/number}","notifications_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/labels{/name}","releases_url":"https://api.github.com/repos/PimV/Bermuda-TheGame/releases{/id}","created_at":"2014-09-24T09:26:04Z","updated_at":"2014-11-30T17:55:33Z","pushed_at":"2014-12-11T21:51:52Z","git_url":"git://github.com/PimV/Bermuda-TheGame.git","ssh_url":"git@github.com:PimV/Bermuda-TheGame.git","clone_url":"https://github.com/PimV/Bermuda-TheGame.git","svn_url":"https://github.com/PimV/Bermuda-TheGame","homepage":null,"size":105971,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116"},"html":{"href":"https://github.com/PimV/Bermuda-TheGame/pull/116"},"issue":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/116"},"comments":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/PimV/Bermuda-TheGame/statuses/5fbac9c115ca553da7f9504683098b2c116ed67a"}}}}