Skip to content

Commit

Permalink
Merge pull request #666 from tiltedphoques/tweak/modPolicyDefault
Browse files Browse the repository at this point in the history
Warn about mods
  • Loading branch information
RobbeBryssinck authored May 5, 2024
2 parents 1f039df + 9b54fb7 commit 22b943d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Code/client/Games/Primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ template <class T> struct GameList
Entry entry;

inline bool Empty() const noexcept { return entry.data == nullptr; }
inline size_t Size() const noexcept
{
if (entry.data == nullptr)
return 0ULL;

size_t size = 0;
for (const Entry* current = &entry; current; current = current->next)
size++;

return size;
}

// Range for loop compatibility
struct Iterator
Expand Down
33 changes: 33 additions & 0 deletions Code/client/Services/Generic/DiscoveryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <Events/CellChangeEvent.h>
#include <Events/LocationChangeEvent.h>
#include <Events/ConnectedEvent.h>
#include <Events/ConnectionErrorEvent.h>

#include <World.h>

Expand Down Expand Up @@ -256,6 +257,38 @@ void DiscoveryService::OnConnected(const ConnectedEvent& acEvent) noexcept
BSTEventResult DiscoveryService::OnEvent(const TESLoadGameEvent*, const EventDispatcher<TESLoadGameEvent>*)
{
spdlog::info("Finished loading, triggering visit cell");

const TiltedPhoques::String defaultModlist[7] = {"Skyrim.esm", "Update.esm", "Dawnguard.esm",
"HearthFires.esm", "Dragonborn.esm", "_ResourcePack.esl",
"SkyrimTogether.esp"};

auto& currentModlist = ModManager::Get()->mods;

bool isModlistEqual = currentModlist.Size() == 7;

if (isModlistEqual)
{
int i = 0;
for (const auto& currentMod : currentModlist)
{
if (currentMod->filename != defaultModlist[i])
{
isModlistEqual = false;
break;
}

i++;
}
}

if (!isModlistEqual)
{
ConnectionErrorEvent errorEvent{};
errorEvent.ErrorDetail = "{\"error\": \"non_default_install\"}";

m_world.GetRunner().Trigger(errorEvent);
}

VisitCell(true);

return BSTEventResult::kOk;
Expand Down
3 changes: 2 additions & 1 deletion Code/skyrim_ui/src/app/services/error.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export interface ErrorEvent {
| 'client_mods_disallowed'
| 'wrong_password'
| 'server_full'
| 'no_reason';
| 'no_reason'
| 'non_default_install';
data?: Record<any, any>;
}

Expand Down
3 changes: 2 additions & 1 deletion Code/skyrim_ui/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
"CLIENT_MODS_DISALLOWED": "This server disallows {{mods}}. Please remove them to join.",
"WRONG_PASSWORD": "The password you entered is incorrect.",
"NO_REASON": "The server refused connection without reason.",
"SERVER_FULL": "This server is full."
"SERVER_FULL": "This server is full.",
"NON_DEFAULT_INSTALL": "It seems that your installation is not purely vanilla, i.e. it has Creation Club content (Anniversary Update or otherwise) or other mods.\nWe do NOT recommend playing with mods.\nWe recommend that you uninstall and disable these mods (instructions can be found on the wiki).\n\nFor the best experience, you should have the following mod list:<strong>\nSkyrim.esm\nUpdate.esm\nDawnguard.esm\nHearthFires.esm\nDragonborn.esm\n_ResourcePack.esl\nSkyrimTogether.esp</strong>"
}
},
"PLAYER_LIST": {
Expand Down

0 comments on commit 22b943d

Please sign in to comment.