Skip to content

Commit 70581cc

Browse files
committed
fixed provider ID used by bedrock
1 parent 55a9b95 commit 70581cc

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ option (ENABLE_PYTHON "Enable Python support" OFF)
1717
# library version set here (e.g. for shared libs).
1818
set (BEDROCK_VERSION_MAJOR 0)
1919
set (BEDROCK_VERSION_MINOR 15)
20-
set (BEDROCK_VERSION_PATCH 0)
20+
set (BEDROCK_VERSION_PATCH 1)
2121
set (BEDROCK_VERSION
2222
"${BEDROCK_VERSION_MAJOR}.${BEDROCK_VERSION_MINOR}.${BEDROCK_VERSION_PATCH}")
2323
add_definitions ("-DBEDROCK_VERSION=${BEDROCK_VERSION}")

src/ProviderManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ ProviderManager::addProviderFromJSON(const json& description) {
148148
for(auto& tag : description.value("tags", json::array()))
149149
args.tags.push_back(tag.get<std::string>());
150150

151+
if(args.provider_id == self->get_provider_id()) {
152+
throw BEDROCK_DETAILED_EXCEPTION(
153+
"Bedrock already uses provider ID {}", args.provider_id);
154+
}
155+
151156
auto deps_from_config = description.value("dependencies", json::object());
152157
auto requested_dependencies = ModuleManager::getDependencies(type, args);
153158
auto& resolved_dependency_map = args.dependencies;

src/ProviderManagerImpl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class ProviderManagerImpl
121121

122122
uint16_t getAvailableProviderID() const {
123123
std::unordered_set<uint16_t> used_provider_ids;
124+
used_provider_ids.insert(get_provider_id());
124125
for(auto& p : m_providers) {
125126
used_provider_ids.insert(p->getProviderID());
126127
}

tests/Client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ TEST_CASE("Tests various object creation and removal via a ServiceHandle", "[ser
158158
auto it = std::find_if(providers.begin(), providers.end(),
159159
[](auto& p) { return p["name"] == "my_provider_a3"; });
160160
REQUIRE(it != providers.end());
161-
REQUIRE((*it)["provider_id"] == 0);
161+
REQUIRE((*it)["provider_id"] == 1);
162162
// create a provider of type module_a but let Bedrock choose the provider ID again
163163
REQUIRE_NOTHROW(serviceHandle.addProvider(
164164
R"({"name":"my_provider_a4", "type":"module_a", "provider_id":65535})"));
@@ -167,7 +167,7 @@ TEST_CASE("Tests various object creation and removal via a ServiceHandle", "[ser
167167
it = std::find_if(providers.begin(), providers.end(),
168168
[](auto& p) { return p["name"] == "my_provider_a4"; });
169169
REQUIRE(it != providers.end());
170-
REQUIRE((*it)["provider_id"] == 1);
170+
REQUIRE((*it)["provider_id"] == 2);
171171

172172

173173
// create a provider of an invalid type

0 commit comments

Comments
 (0)