This repository has been archived by the owner on May 22, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just minor performance changes... now case sensitive, check Changelog STEAM_V2.txt for info
- Loading branch information
Showing
4 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
STEAM Protocol | ||
GetFriends -> GET_FRIENDS (now case sensitive) | ||
STEAMBanned -> VAC_BANNED (now case sensitive) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
Copyright (C) 2014 Declan Ireland <http://github.com/torndeco/extDB> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
Code to Convert SteamID -> BEGUID | ||
From Frank https://gist.github.com/Fank/11127158 | ||
*/ | ||
|
||
|
||
#include "steam_v2.h" | ||
|
||
#include <string> | ||
|
||
#include <boost/property_tree/ptree.hpp> | ||
#include <boost/property_tree/json_parser.hpp> | ||
|
||
#include <Poco/StringTokenizer.h> | ||
|
||
#include "../steamworker.h" | ||
|
||
|
||
bool STEAM_V2::init(AbstractExt *extension, const std::string &database_id, const std::string init_str) | ||
{ | ||
extension_ptr = extension; | ||
return true; | ||
} | ||
|
||
|
||
bool STEAM_V2::isNumber(const std::string &input_str) | ||
{ | ||
bool status = true; | ||
for (unsigned int index=0; index < input_str.length(); index++) | ||
{ | ||
if (!std::isdigit(input_str[index])) | ||
{ | ||
status = false; | ||
break; | ||
} | ||
} | ||
return status; | ||
} | ||
|
||
|
||
bool STEAM_V2::callProtocol(std::string input_str, std::string &result, const int unique_id) | ||
{ | ||
#ifdef DEBUG_TESTING | ||
extension_ptr->console->info("extDB2: STEAM_V2: Trace: Input: {0}", input_str); | ||
#endif | ||
#ifdef DEBUG_LOGGING | ||
extension_ptr->logger->info("extDB2: STEAM_V2: Trace: Input: {0}", input_str); | ||
#endif | ||
|
||
bool status = true; | ||
if (unique_id == -1) | ||
{ | ||
#ifdef DEBUG_TESTING | ||
extension_ptr->console->warn("extDB2: STEAM_V2: SYNC MODE NOT SUPPORTED"); | ||
#endif | ||
extension_ptr->logger->warn("extDB2: STEAM_V2: SYNC MODE NOT SUPPORTED"); | ||
result = "[0, \"STEAM_V2: SYNC MODE NOT SUPPORTED\"]"; | ||
status = false; | ||
} | ||
else | ||
{ | ||
const std::string::size_type found = input_str.find(":", 0); | ||
if ((found==std::string::npos) || (found == (input_str.size() - 1))) | ||
{ | ||
#ifdef DEBUG_TESTING | ||
extension_ptr->console->warn("extDB2: STEAM_V2: Invalid Query: {0}", input_str); | ||
#endif | ||
extension_ptr->logger->warn("extDB2: STEAM_V2: Invalid Query: {0}", input_str); | ||
} | ||
else | ||
{ | ||
Poco::StringTokenizer tokens(input_str.substr(found+1), ":"); | ||
std::vector<std::string> steamIDs; | ||
for (auto &token : tokens) | ||
{ | ||
if (isNumber(token)) | ||
{ | ||
steamIDs.push_back(token); | ||
} | ||
else | ||
{ | ||
#ifdef DEBUG_TESTING | ||
extension_ptr->console->warn("extDB2: STEAM_V2: Invalid SteamID: {0}", token); | ||
#endif | ||
extension_ptr->logger->warn("extDB2: STEAM_V2: Invalid SteamID: {0}", token); | ||
result = "[0, \"STEAM_V2: Invalid SteamID\"]"; | ||
status = false; | ||
break; | ||
} | ||
} | ||
|
||
if (status) | ||
{ | ||
std::string steam_query = input_str.substr(0, found); | ||
if (steam_query == "GET_FRIENDS") | ||
{ | ||
extension_ptr->steamQuery(unique_id, true, false, steamIDs, true); | ||
} | ||
else if (steam_query == "VAC_BANNED") | ||
{ | ||
extension_ptr->steamQuery(unique_id, false, true, steamIDs, true); | ||
} | ||
else | ||
{ | ||
#ifdef DEBUG_TESTING | ||
extension_ptr->console->warn("extDB2: STEAM_V2: Invalid Query Type: {0}", steam_query); | ||
#endif | ||
extension_ptr->logger->warn("extDB2: STEAM_V2: Invalid Query Type: {0}", steam_query); | ||
result = "[0, \"STEAM_V2: Invalid Query Type\"]"; | ||
status = false; | ||
} | ||
} | ||
} | ||
} | ||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Copyright (C) 2014 Declan Ireland <http://github.com/torndeco/extDB> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#pragma once | ||
|
||
#include "abstract_protocol.h" | ||
|
||
|
||
class STEAM_V2: public AbstractProtocol | ||
{ | ||
public: | ||
bool init(AbstractExt *extension, const std::string &database_id, const std::string init_str); | ||
bool callProtocol(std::string input_str, std::string &result, const int unique_id=-1); | ||
|
||
private: | ||
bool isNumber(const std::string &input_str); | ||
}; |