{"action":"created","comment":{"url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/comments/47912754","id":47912754,"diff_hunk":"@@ -0,0 +1,62 @@\n+#include \"Network/Package.h\"\n+\n+Package::Package(MessageType type, unsigned int& packageID)\n+{\n+    m_Data = new char[128];\n+    // Create message header\n+    // Add message type\n+    int messageType = static_cast<int>(type);\n+    Package::AddPrimitive<int>(messageType);\n+    packageID = packageID % 1000; // Packet id modulos\n+    Package::AddPrimitive<int>(packageID);\n+    packageID++;\n+}\n+\n+\n+Package::Package(char* data, const int sizeOfPackage)\n+{\n+    // Create message\n+    m_Data = new char[sizeOfPackage];\n+    memcpy(m_Data, data, sizeOfPackage);\n+    m_Offset = sizeOfPackage;\n+}\n+\n+Package::~Package()\n+{\n+    delete[] m_Data;\n+}\n+\n+void Package::AddString(std::string str)\n+{\n+    // Message, add one extra byte for null terminator\n+    memcpy(m_Data + m_Offset, str.data(), (str.size() + 1) * sizeof(char));\n+    m_Offset += (str.size() + 1) * sizeof(char);\n+}\n+\n+void Package::AddData(char * data, int sizeOfData)\n+{ \n+    if (m_Offset + sizeOfData > 128) {\n+        LOG_WARNING(\"Package::AddData(): Data size in package exceeded maximum package size.\\n\");\n+    }\n+    memcpy(m_Data + m_Offset, data, sizeOfData);\n+    m_Offset += sizeOfData;\n+}\n+\n+std::string Package::PopFrontString()\n+{\n+    std::string returnValue(m_Data + m_ReturnDataOffset);\n+    if (m_Offset < m_ReturnDataOffset + returnValue.size()){\n+        LOG_WARNING(\"Package PopFrontString(): Oh no! You are trying to remove things outside my memory kingdom\");","path":"src/Engine/Network/Package.cpp","position":49,"original_position":49,"commit_id":"000adb198fe2147dfa674e97ef04604396481f91","original_commit_id":"000adb198fe2147dfa674e97ef04604396481f91","user":{"login":"sippeangelo","id":262378,"avatar_url":"https://avatars.githubusercontent.com/u/262378?v=3","gravatar_id":"","url":"https://api.github.com/users/sippeangelo","html_url":"https://github.com/sippeangelo","followers_url":"https://api.github.com/users/sippeangelo/followers","following_url":"https://api.github.com/users/sippeangelo/following{/other_user}","gists_url":"https://api.github.com/users/sippeangelo/gists{/gist_id}","starred_url":"https://api.github.com/users/sippeangelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sippeangelo/subscriptions","organizations_url":"https://api.github.com/users/sippeangelo/orgs","repos_url":"https://api.github.com/users/sippeangelo/repos","events_url":"https://api.github.com/users/sippeangelo/events{/privacy}","received_events_url":"https://api.github.com/users/sippeangelo/received_events","type":"User","site_admin":false},"body":"lol","created_at":"2015-12-17T14:45:15Z","updated_at":"2015-12-17T14:45:15Z","html_url":"https://github.com/teamfisk/TacticalZ/pull/19#discussion_r47912754","pull_request_url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/comments/47912754"},"html":{"href":"https://github.com/teamfisk/TacticalZ/pull/19#discussion_r47912754"},"pull_request":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19","id":53981095,"html_url":"https://github.com/teamfisk/TacticalZ/pull/19","diff_url":"https://github.com/teamfisk/TacticalZ/pull/19.diff","patch_url":"https://github.com/teamfisk/TacticalZ/pull/19.patch","issue_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues/19","number":19,"state":"open","locked":false,"title":"Networking","user":{"login":"Stiffly","id":6529014,"avatar_url":"https://avatars.githubusercontent.com/u/6529014?v=3","gravatar_id":"","url":"https://api.github.com/users/Stiffly","html_url":"https://github.com/Stiffly","followers_url":"https://api.github.com/users/Stiffly/followers","following_url":"https://api.github.com/users/Stiffly/following{/other_user}","gists_url":"https://api.github.com/users/Stiffly/gists{/gist_id}","starred_url":"https://api.github.com/users/Stiffly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stiffly/subscriptions","organizations_url":"https://api.github.com/users/Stiffly/orgs","repos_url":"https://api.github.com/users/Stiffly/repos","events_url":"https://api.github.com/users/Stiffly/events{/privacy}","received_events_url":"https://api.github.com/users/Stiffly/received_events","type":"User","site_admin":false},"body":"<b>PlayerSystem</b>\r\nPlayerSystem does not read any input anymore, now updates movement. (with temporary implemented player component)\r\n<b>Rectangle class</b>\r\nEngines Rectangle class conflicted with Asio's rectangle class in Game.cpp for instance. Now using Rectangle::Rectangle(...) to refer to the correct implementation.\r\n<b>Package class</b>\r\nImplemented a Package class to abstract the message passing process with:\r\n### Package.h\r\n```h\r\nclass Package {\r\n    AddPrimitive<type>() { ... } // Adds a primitive type to a package\r\n    AddString();\r\n    AddData();\r\n    PopFrontPrimitive<type>() { ... } // Reads a primitive type from a package\r\n    PopFrontString();\r\n    PopFrontData();\r\n}\r\n```\r\n### Example:\r\n```cpp\r\nPackage package(MessageType::Connect, m_PacketID);\r\npackage.AddPrimitive<int>(5); // Player ID\r\nint playerID = package.PopFrontPrimitive<int>(); // playerID will get value of 5\r\n```\r\n\r\n<b>Logic:</b>\r\nThe network runs on a different thread than the rest of game but has an update function where critical logic can be placed as this will run on the game thread .\r\nClient sends input to server.\r\nServer does movement logic and return transform component.\r\nClient updates its own movement but is forced to the transform component received from the server.\r\n\r\n<b>How to use:</b>\r\nMake sure your Networking variable in Config.ini is set to true.\r\nIn console write 'C' and press enter for Client and 'S' for Server.\r\nWhen a server is running and you want to connect with a Client, press 'C' in game.\r\n","created_at":"2015-12-17T14:18:42Z","updated_at":"2015-12-17T14:45:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3842558ad21008cbfe613c698af661ddf2e2db7","assignee":{"login":"wima12","id":6561086,"avatar_url":"https://avatars.githubusercontent.com/u/6561086?v=3","gravatar_id":"","url":"https://api.github.com/users/wima12","html_url":"https://github.com/wima12","followers_url":"https://api.github.com/users/wima12/followers","following_url":"https://api.github.com/users/wima12/following{/other_user}","gists_url":"https://api.github.com/users/wima12/gists{/gist_id}","starred_url":"https://api.github.com/users/wima12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wima12/subscriptions","organizations_url":"https://api.github.com/users/wima12/orgs","repos_url":"https://api.github.com/users/wima12/repos","events_url":"https://api.github.com/users/wima12/events{/privacy}","received_events_url":"https://api.github.com/users/wima12/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19/commits","review_comments_url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19/comments","review_comment_url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/comments{/number}","comments_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues/19/comments","statuses_url":"https://api.github.com/repos/teamfisk/TacticalZ/statuses/000adb198fe2147dfa674e97ef04604396481f91","head":{"label":"teamfisk:Networking","ref":"Networking","sha":"000adb198fe2147dfa674e97ef04604396481f91","user":{"login":"teamfisk","id":8938624,"avatar_url":"https://avatars.githubusercontent.com/u/8938624?v=3","gravatar_id":"","url":"https://api.github.com/users/teamfisk","html_url":"https://github.com/teamfisk","followers_url":"https://api.github.com/users/teamfisk/followers","following_url":"https://api.github.com/users/teamfisk/following{/other_user}","gists_url":"https://api.github.com/users/teamfisk/gists{/gist_id}","starred_url":"https://api.github.com/users/teamfisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamfisk/subscriptions","organizations_url":"https://api.github.com/users/teamfisk/orgs","repos_url":"https://api.github.com/users/teamfisk/repos","events_url":"https://api.github.com/users/teamfisk/events{/privacy}","received_events_url":"https://api.github.com/users/teamfisk/received_events","type":"Organization","site_admin":false},"repo":{"id":46560418,"name":"TacticalZ","full_name":"teamfisk/TacticalZ","owner":{"login":"teamfisk","id":8938624,"avatar_url":"https://avatars.githubusercontent.com/u/8938624?v=3","gravatar_id":"","url":"https://api.github.com/users/teamfisk","html_url":"https://github.com/teamfisk","followers_url":"https://api.github.com/users/teamfisk/followers","following_url":"https://api.github.com/users/teamfisk/following{/other_user}","gists_url":"https://api.github.com/users/teamfisk/gists{/gist_id}","starred_url":"https://api.github.com/users/teamfisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamfisk/subscriptions","organizations_url":"https://api.github.com/users/teamfisk/orgs","repos_url":"https://api.github.com/users/teamfisk/repos","events_url":"https://api.github.com/users/teamfisk/events{/privacy}","received_events_url":"https://api.github.com/users/teamfisk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teamfisk/TacticalZ","description":"","fork":false,"url":"https://api.github.com/repos/teamfisk/TacticalZ","forks_url":"https://api.github.com/repos/teamfisk/TacticalZ/forks","keys_url":"https://api.github.com/repos/teamfisk/TacticalZ/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teamfisk/TacticalZ/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teamfisk/TacticalZ/teams","hooks_url":"https://api.github.com/repos/teamfisk/TacticalZ/hooks","issue_events_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues/events{/number}","events_url":"https://api.github.com/repos/teamfisk/TacticalZ/events","assignees_url":"https://api.github.com/repos/teamfisk/TacticalZ/assignees{/user}","branches_url":"https://api.github.com/repos/teamfisk/TacticalZ/branches{/branch}","tags_url":"https://api.github.com/repos/teamfisk/TacticalZ/tags","blobs_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/refs{/sha}","trees_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teamfisk/TacticalZ/statuses/{sha}","languages_url":"https://api.github.com/repos/teamfisk/TacticalZ/languages","stargazers_url":"https://api.github.com/repos/teamfisk/TacticalZ/stargazers","contributors_url":"https://api.github.com/repos/teamfisk/TacticalZ/contributors","subscribers_url":"https://api.github.com/repos/teamfisk/TacticalZ/subscribers","subscription_url":"https://api.github.com/repos/teamfisk/TacticalZ/subscription","commits_url":"https://api.github.com/repos/teamfisk/TacticalZ/commits{/sha}","git_commits_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/commits{/sha}","comments_url":"https://api.github.com/repos/teamfisk/TacticalZ/comments{/number}","issue_comment_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues/comments{/number}","contents_url":"https://api.github.com/repos/teamfisk/TacticalZ/contents/{+path}","compare_url":"https://api.github.com/repos/teamfisk/TacticalZ/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teamfisk/TacticalZ/merges","archive_url":"https://api.github.com/repos/teamfisk/TacticalZ/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teamfisk/TacticalZ/downloads","issues_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues{/number}","pulls_url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls{/number}","milestones_url":"https://api.github.com/repos/teamfisk/TacticalZ/milestones{/number}","notifications_url":"https://api.github.com/repos/teamfisk/TacticalZ/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teamfisk/TacticalZ/labels{/name}","releases_url":"https://api.github.com/repos/teamfisk/TacticalZ/releases{/id}","created_at":"2015-11-20T12:23:41Z","updated_at":"2015-12-10T09:46:16Z","pushed_at":"2015-12-17T14:31:50Z","git_url":"git://github.com/teamfisk/TacticalZ.git","ssh_url":"git@github.com:teamfisk/TacticalZ.git","clone_url":"https://github.com/teamfisk/TacticalZ.git","svn_url":"https://github.com/teamfisk/TacticalZ","homepage":null,"size":31310,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"teamfisk:master","ref":"master","sha":"1a9b765d4711a6f9d1c5ac9218c4e6622179e71f","user":{"login":"teamfisk","id":8938624,"avatar_url":"https://avatars.githubusercontent.com/u/8938624?v=3","gravatar_id":"","url":"https://api.github.com/users/teamfisk","html_url":"https://github.com/teamfisk","followers_url":"https://api.github.com/users/teamfisk/followers","following_url":"https://api.github.com/users/teamfisk/following{/other_user}","gists_url":"https://api.github.com/users/teamfisk/gists{/gist_id}","starred_url":"https://api.github.com/users/teamfisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamfisk/subscriptions","organizations_url":"https://api.github.com/users/teamfisk/orgs","repos_url":"https://api.github.com/users/teamfisk/repos","events_url":"https://api.github.com/users/teamfisk/events{/privacy}","received_events_url":"https://api.github.com/users/teamfisk/received_events","type":"Organization","site_admin":false},"repo":{"id":46560418,"name":"TacticalZ","full_name":"teamfisk/TacticalZ","owner":{"login":"teamfisk","id":8938624,"avatar_url":"https://avatars.githubusercontent.com/u/8938624?v=3","gravatar_id":"","url":"https://api.github.com/users/teamfisk","html_url":"https://github.com/teamfisk","followers_url":"https://api.github.com/users/teamfisk/followers","following_url":"https://api.github.com/users/teamfisk/following{/other_user}","gists_url":"https://api.github.com/users/teamfisk/gists{/gist_id}","starred_url":"https://api.github.com/users/teamfisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teamfisk/subscriptions","organizations_url":"https://api.github.com/users/teamfisk/orgs","repos_url":"https://api.github.com/users/teamfisk/repos","events_url":"https://api.github.com/users/teamfisk/events{/privacy}","received_events_url":"https://api.github.com/users/teamfisk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teamfisk/TacticalZ","description":"","fork":false,"url":"https://api.github.com/repos/teamfisk/TacticalZ","forks_url":"https://api.github.com/repos/teamfisk/TacticalZ/forks","keys_url":"https://api.github.com/repos/teamfisk/TacticalZ/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teamfisk/TacticalZ/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teamfisk/TacticalZ/teams","hooks_url":"https://api.github.com/repos/teamfisk/TacticalZ/hooks","issue_events_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues/events{/number}","events_url":"https://api.github.com/repos/teamfisk/TacticalZ/events","assignees_url":"https://api.github.com/repos/teamfisk/TacticalZ/assignees{/user}","branches_url":"https://api.github.com/repos/teamfisk/TacticalZ/branches{/branch}","tags_url":"https://api.github.com/repos/teamfisk/TacticalZ/tags","blobs_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/refs{/sha}","trees_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teamfisk/TacticalZ/statuses/{sha}","languages_url":"https://api.github.com/repos/teamfisk/TacticalZ/languages","stargazers_url":"https://api.github.com/repos/teamfisk/TacticalZ/stargazers","contributors_url":"https://api.github.com/repos/teamfisk/TacticalZ/contributors","subscribers_url":"https://api.github.com/repos/teamfisk/TacticalZ/subscribers","subscription_url":"https://api.github.com/repos/teamfisk/TacticalZ/subscription","commits_url":"https://api.github.com/repos/teamfisk/TacticalZ/commits{/sha}","git_commits_url":"https://api.github.com/repos/teamfisk/TacticalZ/git/commits{/sha}","comments_url":"https://api.github.com/repos/teamfisk/TacticalZ/comments{/number}","issue_comment_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues/comments{/number}","contents_url":"https://api.github.com/repos/teamfisk/TacticalZ/contents/{+path}","compare_url":"https://api.github.com/repos/teamfisk/TacticalZ/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teamfisk/TacticalZ/merges","archive_url":"https://api.github.com/repos/teamfisk/TacticalZ/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teamfisk/TacticalZ/downloads","issues_url":"https://api.github.com/repos/teamfisk/TacticalZ/issues{/number}","pulls_url":"https://api.github.com/repos/teamfisk/TacticalZ/pulls{/number}","milestones_url":"https://api.github.com/repos/teamfisk/TacticalZ/milestones{/number}","notifications_url":"https://api.github.com/repos/teamfisk/TacticalZ/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teamfisk/TacticalZ/labels{/name}","releases_url":"https://api.github.com/repos/teamfisk/TacticalZ/releases{/id}","created_at":"2015-11-20T12:23:41Z","updated_at":"2015-12-10T09:46:16Z","pushed_at":"2015-12-17T14:31:50Z","git_url":"git://github.com/teamfisk/TacticalZ.git","ssh_url":"git@github.com:teamfisk/TacticalZ.git","clone_url":"https://github.com/teamfisk/TacticalZ.git","svn_url":"https://github.com/teamfisk/TacticalZ","homepage":null,"size":31310,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19"},"html":{"href":"https://github.com/teamfisk/TacticalZ/pull/19"},"issue":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/issues/19"},"comments":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/teamfisk/TacticalZ/statuses/000adb198fe2147dfa674e97ef04604396481f91"}}}}