Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update refactor with some commits from main #250

Merged
merged 6 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# For more info on `.editorconfig` file see https://EditorConfig.org

# top-most EditorConfig file
root = true

# Newline ending every file
[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# Format commit
75bf194b2fca06de805a7bc025c6dd8379250fa5

# Folder rename
f9bc3c9d1834cb8bd5f872b749b057c33e8b0102
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
WHEN OPENING A PULL REQUEST KEEP IN MIND:
-> If the changes you made can be summarised in a screenshot, add one (e.g. you changed the layout of an in-game menu)
-> If the changes you made can be summarised in a screenrecording, add one (e.g. proof that you fixed a certain bug)

-> For fixes, description on how to reproduce the bug are appreciated and help your PR get merged faster
-> For features, description on how to use the feature is appreciated and will help your PR get merged faster

-> Please use a sensible title for your pull request

-> Please describe the changes you made. The easier it is to understand what you changed, the higher the chances of your PR being merged (in a timely manner).

-> If you made multiple independent changes, please make a new PR for each one. This prevents your PR being blocked from merging by one of the changes you made.

Note that commit messages in PRs will generally be squashed to keep commit history clean.
-->

Replace this line with a description of your change (and screenshots/screenrecordings if applicable).
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.13
with:
source: 'NorthstarDedicatedTest LauncherInjector'
exclude: 'NorthstarDedicatedTest/include loader_launcher_proxy loader_wsock32_proxy'
source: 'NorthstarDLL NorthstarLauncher'
exclude: 'NorthstarDLL/include loader_launcher_proxy loader_wsock32_proxy'
extensions: 'h,cpp'
clangFormatVersion: 13
style: file
25 changes: 23 additions & 2 deletions NorthstarDLL/bansystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,24 @@ void ServerBanSystem::OpenBanlist()
banlistStream.close();
}

// open write stream for banlist
m_sBanlistStream.open(GetNorthstarPrefix() + "/banlist.txt", std::ofstream::out | std::ofstream::binary | std::ofstream::app);
// open write stream for banlist // dont do this to allow for all time access
// m_sBanlistStream.open(GetNorthstarPrefix() + "/banlist.txt", std::ofstream::out | std::ofstream::binary | std::ofstream::app);
}

void ServerBanSystem::ReloadBanlist()
{
std::ifstream fsBanlist(GetNorthstarPrefix() + "/banlist.txt");

if (!fsBanlist.fail())
{
std::string line;
// since we wanna use this as the reload func we need to clear the list
m_vBannedUids.clear();
while (std::getline(fsBanlist, line))
m_vBannedUids.push_back(strtoull(line.c_str(), nullptr, 10));

fsBanlist.close();
}
}

void ServerBanSystem::ClearBanlist()
Expand All @@ -57,6 +73,7 @@ void ServerBanSystem::ClearBanlist()
// reopen the file, don't provide std::ofstream::app so it clears on open
m_sBanlistStream.close();
m_sBanlistStream.open(GetNorthstarPrefix() + "/banlist.txt", std::ofstream::out | std::ofstream::binary);
m_sBanlistStream.close();
}

void ServerBanSystem::BanUID(uint64_t uid)
Expand All @@ -66,11 +83,13 @@ void ServerBanSystem::BanUID(uint64_t uid)
std::string content((std::istreambuf_iterator<char>(fsBanlist)), (std::istreambuf_iterator<char>()));
fsBanlist.close();

m_sBanlistStream.open(GetNorthstarPrefix() + "/banlist.txt", std::ofstream::out | std::ofstream::binary | std::ofstream::app);
if (content.back() != '\n')
m_sBanlistStream << std::endl;

m_vBannedUids.push_back(uid);
m_sBanlistStream << std::to_string(uid) << std::endl;
m_sBanlistStream.close();
spdlog::info("{} was banned", uid);
}

Expand Down Expand Up @@ -150,11 +169,13 @@ void ServerBanSystem::UnbanUID(uint64_t uid)
for (std::string updatedLine : banlistText)
m_sBanlistStream << updatedLine << std::endl;

m_sBanlistStream.close();
spdlog::info("{} was unbanned", uid);
}

bool ServerBanSystem::IsUIDAllowed(uint64_t uid)
{
ReloadBanlist(); // Reload to have up to date list on join
return std::find(m_vBannedUids.begin(), m_vBannedUids.end(), uid) == m_vBannedUids.end();
}

Expand Down
1 change: 1 addition & 0 deletions NorthstarDLL/bansystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ServerBanSystem

public:
void OpenBanlist();
void ReloadBanlist();
void ClearBanlist();
void BanUID(uint64_t uid);
void UnbanUID(uint64_t uid);
Expand Down
1 change: 0 additions & 1 deletion NorthstarDLL/ns_startup_args.txt

This file was deleted.

1 change: 0 additions & 1 deletion NorthstarDLL/ns_startup_args_dedi.txt

This file was deleted.

1 change: 0 additions & 1 deletion NorthstarLauncher/ns_startup_args.txt

This file was deleted.

1 change: 0 additions & 1 deletion NorthstarLauncher/ns_startup_args_dedi.txt

This file was deleted.