Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add protocol_version and supported package types to ContentDB urls
  • Loading branch information
rubenwardy committed Jul 28, 2018
1 parent 2b83af7 commit 14011bd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/content/packages.cpp
Expand Up @@ -25,6 +25,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content/mods.h"
#include "content/subgames.h"

std::string Package::getDownloadURL(const std::string &baseURL) const
{
return baseURL + "/packages/" + author + "/" + name + "/releases/" +
std::to_string(release) + "/download/";
}

#if USE_CURL
std::vector<Package> getPackagesFromURL(const std::string &url)
{
Expand Down Expand Up @@ -60,5 +66,4 @@ std::vector<Package> getPackagesFromURL(const std::string &url)

return packages;
}

#endif
5 changes: 1 addition & 4 deletions src/content/packages.h
Expand Up @@ -39,10 +39,7 @@ struct Package
type.empty() || release <= 0);
}

std::string getDownloadURL(const std::string &baseURL) const
{
return baseURL + "/packages/" + author + "/" + name + "/download/";
}
std::string getDownloadURL(const std::string &baseURL) const;
};

#if USE_CURL
Expand Down
1 change: 1 addition & 0 deletions src/network/networkprotocol.h
Expand Up @@ -191,6 +191,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/

#define LATEST_PROTOCOL_VERSION 36
#define LATEST_PROTOCOL_VERSION_STRING TOSTRING(LATEST_PROTOCOL_VERSION)

// Server's supported network protocol range
#define SERVER_PROTOCOL_VERSION_MIN 36
Expand Down
5 changes: 4 additions & 1 deletion src/script/lua_api/l_mainmenu.cpp
Expand Up @@ -39,6 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IFileArchive.h>
#include <IFileSystem.h>
#include "client/renderingengine.h"
#include "network/networkprotocol.h"


/******************************************************************************/
Expand Down Expand Up @@ -993,7 +994,9 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
int ModApiMainMenu::l_get_package_list(lua_State *L)
{
std::string url = g_settings->get("contentdb_url");
std::vector<Package> packages = getPackagesFromURL(url + "/api/packages/");
std::vector<Package> packages = getPackagesFromURL(url +
"/api/packages/?type=mod&type=game&type=txp&protocol_version="
LATEST_PROTOCOL_VERSION_STRING);

// Make table
lua_newtable(L);
Expand Down

0 comments on commit 14011bd

Please sign in to comment.