Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
STEAM_V2 Changes
Browse files Browse the repository at this point in the history
Just minor performance changes... now case sensitive, check Changelog
STEAM_V2.txt for info
  • Loading branch information
Torndeco committed Apr 15, 2015
1 parent 6586eb6 commit e014d72
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changelog STEAM_V2.txt
@@ -0,0 +1,3 @@
STEAM Protocol
GetFriends -> GET_FRIENDS (now case sensitive)
STEAMBanned -> VAC_BANNED (now case sensitive)
5 changes: 5 additions & 0 deletions src/ext.cpp
Expand Up @@ -67,6 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "protocols/misc.h"
#include "protocols/rcon.h"
#include "protocols/steam.h"
#include "protocols/steam_v2.h"


Ext::Ext(std::string dll_path, boost::program_options::parsed_options options, bool status)
Expand Down Expand Up @@ -683,6 +684,10 @@ void Ext::addProtocol(char *output, const int &output_size, const std::string &d
{
unordered_map_protocol[protocol_name] = std::unique_ptr<AbstractProtocol> (new STEAM());
}
else if (boost::iequals(protocol, std::string("STEAM_V2")) == 1)
{
unordered_map_protocol[protocol_name] = std::unique_ptr<AbstractProtocol> (new STEAM_V2());
}
else
{
status = false;
Expand Down
132 changes: 132 additions & 0 deletions src/protocols/steam_v2.cpp
@@ -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;
}
32 changes: 32 additions & 0 deletions src/protocols/steam_v2.h
@@ -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);
};

0 comments on commit e014d72

Please sign in to comment.