mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Compare commits
4 Commits
44560a46b7
...
837f109752
Author | SHA1 | Date | |
---|---|---|---|
837f109752 | |||
c11cfebdb1 | |||
20367d77f0 | |||
8d04f31c61 |
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020-2023 OpenFusion Contributors
|
Copyright (c) 2020-2024 OpenFusion Contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -50,13 +50,15 @@ time_t getTime();
|
|||||||
time_t getTimestamp();
|
time_t getTimestamp();
|
||||||
void terminate(int);
|
void terminate(int);
|
||||||
|
|
||||||
// The PROTOCOL_VERSION definition is defined by the build system.
|
// The PROTOCOL_VERSION definition can be defined by the build system.
|
||||||
#if !defined(PROTOCOL_VERSION)
|
#if !defined(PROTOCOL_VERSION)
|
||||||
|
#define PROTOCOL_VERSION 104
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PROTOCOL_VERSION == 104
|
||||||
#include "structs/0104.hpp"
|
#include "structs/0104.hpp"
|
||||||
#elif PROTOCOL_VERSION == 728
|
#elif PROTOCOL_VERSION == 728
|
||||||
#include "structs/0728.hpp"
|
#include "structs/0728.hpp"
|
||||||
#elif PROTOCOL_VERSION == 104
|
|
||||||
#include "structs/0104.hpp"
|
|
||||||
#elif PROTOCOL_VERSION == 1013
|
#elif PROTOCOL_VERSION == 1013
|
||||||
#include "structs/1013.hpp"
|
#include "structs/1013.hpp"
|
||||||
#else
|
#else
|
||||||
|
@ -226,10 +226,11 @@ static void createTables() {
|
|||||||
static int getTableSize(std::string tableName) {
|
static int getTableSize(std::string tableName) {
|
||||||
std::lock_guard<std::mutex> lock(dbCrit); // XXX
|
std::lock_guard<std::mutex> lock(dbCrit); // XXX
|
||||||
|
|
||||||
const char* sql = "SELECT COUNT(*) FROM ?";
|
// you aren't allowed to bind the table name
|
||||||
|
const char* sql = "SELECT COUNT(*) FROM ";
|
||||||
|
tableName.insert(0, sql);
|
||||||
sqlite3_stmt* stmt;
|
sqlite3_stmt* stmt;
|
||||||
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
sqlite3_prepare_v2(db, tableName.c_str(), -1, &stmt, NULL);
|
||||||
sqlite3_bind_text(stmt, 1, tableName.c_str(), -1, NULL);
|
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
int result = sqlite3_column_int(stmt, 0);
|
int result = sqlite3_column_int(stmt, 0);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
@ -271,12 +272,12 @@ void Database::open() {
|
|||||||
int players = getTableSize("Players");
|
int players = getTableSize("Players");
|
||||||
std::string message = "";
|
std::string message = "";
|
||||||
if (accounts > 0) {
|
if (accounts > 0) {
|
||||||
message += ": Found " + std::to_string(accounts) + " Account";
|
message += ": Found " + std::to_string(accounts) + " account(s)";
|
||||||
if (accounts > 1)
|
if (accounts > 1)
|
||||||
message += "s";
|
message += "s";
|
||||||
}
|
}
|
||||||
if (players > 0) {
|
if (players > 0) {
|
||||||
message += " and " + std::to_string(players) + " Player Character";
|
message += " and " + std::to_string(players) + " player(s)";
|
||||||
if (players > 1)
|
if (players > 1)
|
||||||
message += "s";
|
message += "s";
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,8 @@ void Database::addBlock(int playerId, int blockedPlayerId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::removeBlock(int playerId, int blockedPlayerId) {
|
void Database::removeBlock(int playerId, int blockedPlayerId) {
|
||||||
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
const char* sql = R"(
|
const char* sql = R"(
|
||||||
DELETE FROM Blocks
|
DELETE FROM Blocks
|
||||||
WHERE PlayerID = ? AND BlockedPlayerID = ?;
|
WHERE PlayerID = ? AND BlockedPlayerID = ?;
|
||||||
|
Loading…
Reference in New Issue
Block a user