Skip to content

Commit 14011bd

Browse files
authoredJul 28, 2018
Add protocol_version and supported package types to ContentDB urls
1 parent 2b83af7 commit 14011bd

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed
 

‎src/content/packages.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2525
#include "content/mods.h"
2626
#include "content/subgames.h"
2727

28+
std::string Package::getDownloadURL(const std::string &baseURL) const
29+
{
30+
return baseURL + "/packages/" + author + "/" + name + "/releases/" +
31+
std::to_string(release) + "/download/";
32+
}
33+
2834
#if USE_CURL
2935
std::vector<Package> getPackagesFromURL(const std::string &url)
3036
{
@@ -60,5 +66,4 @@ std::vector<Package> getPackagesFromURL(const std::string &url)
6066

6167
return packages;
6268
}
63-
6469
#endif

‎src/content/packages.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ struct Package
3939
type.empty() || release <= 0);
4040
}
4141

42-
std::string getDownloadURL(const std::string &baseURL) const
43-
{
44-
return baseURL + "/packages/" + author + "/" + name + "/download/";
45-
}
42+
std::string getDownloadURL(const std::string &baseURL) const;
4643
};
4744

4845
#if USE_CURL

‎src/network/networkprotocol.h

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
191191
*/
192192

193193
#define LATEST_PROTOCOL_VERSION 36
194+
#define LATEST_PROTOCOL_VERSION_STRING TOSTRING(LATEST_PROTOCOL_VERSION)
194195

195196
// Server's supported network protocol range
196197
#define SERVER_PROTOCOL_VERSION_MIN 36

‎src/script/lua_api/l_mainmenu.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3939
#include <IFileArchive.h>
4040
#include <IFileSystem.h>
4141
#include "client/renderingengine.h"
42+
#include "network/networkprotocol.h"
4243

4344

4445
/******************************************************************************/
@@ -993,7 +994,9 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
993994
int ModApiMainMenu::l_get_package_list(lua_State *L)
994995
{
995996
std::string url = g_settings->get("contentdb_url");
996-
std::vector<Package> packages = getPackagesFromURL(url + "/api/packages/");
997+
std::vector<Package> packages = getPackagesFromURL(url +
998+
"/api/packages/?type=mod&type=game&type=txp&protocol_version="
999+
LATEST_PROTOCOL_VERSION_STRING);
9971000

9981001
// Make table
9991002
lua_newtable(L);

0 commit comments

Comments
 (0)