mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-02-03 03:40:02 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
79add84ecc
|
|||
|
5cf3434679
|
|||
|
|
0078be8e9a | ||
|
b617456aa1
|
|||
|
935ee1bf6f
|
14
.github/workflows/check-builds.yaml
vendored
14
.github/workflows/check-builds.yaml
vendored
@@ -8,6 +8,7 @@ on:
|
|||||||
- .github/workflows/check-builds.yaml
|
- .github/workflows/check-builds.yaml
|
||||||
- CMakeLists.txt
|
- CMakeLists.txt
|
||||||
- Makefile
|
- Makefile
|
||||||
|
- tdata
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, reopened, synchronize, ready_for_review]
|
types: [opened, reopened, synchronize, ready_for_review]
|
||||||
paths:
|
paths:
|
||||||
@@ -19,7 +20,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Set environment
|
- name: Set environment
|
||||||
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
||||||
@@ -48,6 +49,7 @@ jobs:
|
|||||||
Rename-Item -Path "bin/fusion" -newName "$version-fusion"
|
Rename-Item -Path "bin/fusion" -newName "$version-fusion"
|
||||||
Write-Output "Built version $version"
|
Write-Output "Built version $version"
|
||||||
}
|
}
|
||||||
|
Copy-Item -Path "tdata" -Destination "bin/tdata" -Recurse
|
||||||
Copy-Item -Path "sql" -Destination "bin/sql" -Recurse
|
Copy-Item -Path "sql" -Destination "bin/sql" -Recurse
|
||||||
Copy-Item -Path "config.ini" -Destination "bin"
|
Copy-Item -Path "config.ini" -Destination "bin"
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
@@ -58,7 +60,7 @@ jobs:
|
|||||||
path: bin
|
path: bin
|
||||||
|
|
||||||
windows-build:
|
windows-build:
|
||||||
runs-on: windows-2019
|
runs-on: windows-2022
|
||||||
steps:
|
steps:
|
||||||
- name: Set environment
|
- name: Set environment
|
||||||
run: $s = $env:GITHUB_SHA.subString(0, 7); echo "SHORT_SHA=$s" >> $env:GITHUB_ENV
|
run: $s = $env:GITHUB_SHA.subString(0, 7); echo "SHORT_SHA=$s" >> $env:GITHUB_ENV
|
||||||
@@ -73,7 +75,7 @@ jobs:
|
|||||||
$configurations = "Release"
|
$configurations = "Release"
|
||||||
# "Debug" builds are disabled, since we don't really need them
|
# "Debug" builds are disabled, since we don't really need them
|
||||||
|
|
||||||
$vsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"
|
$vsPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
||||||
|
|
||||||
Import-Module "$vsPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
Import-Module "$vsPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
||||||
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation
|
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation
|
||||||
@@ -100,6 +102,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
Rename-Item -Path "bin/$configuration" -newName "$version-$configuration"
|
Rename-Item -Path "bin/$configuration" -newName "$version-$configuration"
|
||||||
Write-Output "Built version $version $configuration"
|
Write-Output "Built version $version $configuration"
|
||||||
|
Copy-Item -Path "tdata" -Destination "bin/$version-$configuration/tdata" -Recurse
|
||||||
Copy-Item -Path "sql" -Destination "bin/$version-$configuration/sql" -Recurse
|
Copy-Item -Path "sql" -Destination "bin/$version-$configuration/sql" -Recurse
|
||||||
Copy-Item -Path "config.ini" -Destination "bin/$version-$configuration"
|
Copy-Item -Path "config.ini" -Destination "bin/$version-$configuration"
|
||||||
}
|
}
|
||||||
@@ -108,11 +111,11 @@ jobs:
|
|||||||
- name: Upload build artifact
|
- name: Upload build artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: 'windows-vs2019-bin-x64-${{ env.SHORT_SHA }}'
|
name: 'windows-vs2022-bin-x64-${{ env.SHORT_SHA }}'
|
||||||
path: bin
|
path: bin
|
||||||
|
|
||||||
copy-artifacts:
|
copy-artifacts:
|
||||||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
|
if: github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'master')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [windows-build, ubuntu-build]
|
needs: [windows-build, ubuntu-build]
|
||||||
env:
|
env:
|
||||||
@@ -121,7 +124,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- run: |
|
- run: |
|
||||||
GITDESC=$(git describe --tags)
|
GITDESC=$(git describe --tags)
|
||||||
|
|||||||
@@ -196,18 +196,16 @@ void Database::updateEmailContent(EmailData* data) {
|
|||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::deleteEmailAttachments(int playerID, int index, int slot) {
|
static void _deleteEmailAttachments(int playerID, int index, int slot) {
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
|
||||||
|
|
||||||
sqlite3_stmt* stmt;
|
sqlite3_stmt* stmt;
|
||||||
|
|
||||||
std::string sql(R"(
|
std::string sql(R"(
|
||||||
DELETE FROM EmailItems
|
DELETE FROM EmailItems
|
||||||
WHERE PlayerID = ? AND MsgIndex = ?;
|
WHERE PlayerID = ? AND MsgIndex = ?
|
||||||
)");
|
)");
|
||||||
|
|
||||||
if (slot != -1)
|
if (slot != -1)
|
||||||
sql += " AND \"Slot\" = ? ";
|
sql += " AND \"Slot\" = ?";
|
||||||
sql += ";";
|
sql += ";";
|
||||||
|
|
||||||
sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, NULL);
|
sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, NULL);
|
||||||
@@ -221,6 +219,11 @@ void Database::deleteEmailAttachments(int playerID, int index, int slot) {
|
|||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Database::deleteEmailAttachments(int playerID, int index, int slot) {
|
||||||
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
_deleteEmailAttachments(playerID, index, slot);
|
||||||
|
}
|
||||||
|
|
||||||
void Database::deleteEmails(int playerID, int64_t* indices) {
|
void Database::deleteEmails(int playerID, int64_t* indices) {
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
@@ -234,12 +237,15 @@ void Database::deleteEmails(int playerID, int64_t* indices) {
|
|||||||
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
int64_t msgIndex = indices[i];
|
||||||
sqlite3_bind_int(stmt, 1, playerID);
|
sqlite3_bind_int(stmt, 1, playerID);
|
||||||
sqlite3_bind_int64(stmt, 2, indices[i]);
|
sqlite3_bind_int64(stmt, 2, msgIndex);
|
||||||
if (sqlite3_step(stmt) != SQLITE_DONE) {
|
if (sqlite3_step(stmt) != SQLITE_DONE) {
|
||||||
std::cout << "[WARN] Database: Failed to delete an email: " << sqlite3_errmsg(db) << std::endl;
|
std::cout << "[WARN] Database: Failed to delete an email: " << sqlite3_errmsg(db) << std::endl;
|
||||||
}
|
}
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
// delete all attachments
|
||||||
|
_deleteEmailAttachments(playerID, msgIndex, -1);
|
||||||
}
|
}
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
@@ -323,12 +329,23 @@ bool Database::sendEmail(EmailData* data, std::vector<sItemBase> attachments, Pl
|
|||||||
sqlite3_bind_int(stmt, 7, item.iTimeLimit);
|
sqlite3_bind_int(stmt, 7, item.iTimeLimit);
|
||||||
|
|
||||||
if (sqlite3_step(stmt) != SQLITE_DONE) {
|
if (sqlite3_step(stmt) != SQLITE_DONE) {
|
||||||
|
// very likely the UNIQUE constraint failing due to
|
||||||
|
// orphaned attachments from an old email.
|
||||||
|
// try deleting them first
|
||||||
|
_deleteEmailAttachments(data->PlayerId, data->MsgIndex, -1);
|
||||||
|
|
||||||
|
// try again
|
||||||
|
sqlite3_reset(stmt);
|
||||||
|
if (sqlite3_step(stmt) != SQLITE_DONE) {
|
||||||
|
// different error, give up
|
||||||
std::cout << "[WARN] Database: Failed to send email: " << sqlite3_errmsg(db) << std::endl;
|
std::cout << "[WARN] Database: Failed to send email: " << sqlite3_errmsg(db) << std::endl;
|
||||||
sqlite3_exec(db, "ROLLBACK TRANSACTION;", NULL, NULL, NULL);
|
sqlite3_exec(db, "ROLLBACK TRANSACTION;", NULL, NULL, NULL);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sqlite3_reset(stmt);
|
sqlite3_reset(stmt);
|
||||||
|
sqlite3_clear_bindings(stmt);
|
||||||
}
|
}
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user