mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-13 01:24:46 -07:00
Merge branch 'master' into mod_notify_onbanwarn
This commit is contained in:
commit
3ed3919349
60 changed files with 2474 additions and 1644 deletions
|
|
@ -83,6 +83,28 @@ endif()
|
|||
|
||||
SET(QT_DONT_USE_QTGUI TRUE)
|
||||
|
||||
# Mysql connector
|
||||
if(UNIX)
|
||||
if(APPLE)
|
||||
SET(MYSQLCLIENT_DEFAULT_PATHS "/usr/local/lib" "/opt/local/lib/mysql55/mysql/" "/opt/local/lib/mysql56/mysql/")
|
||||
else()
|
||||
SET(MYSQLCLIENT_DEFAULT_PATHS "/usr/lib" "/usr/local/lib")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
SET(MYSQLCLIENT_DEFAULT_PATHS "C:\\Program Files\\MySQL\\MySQL Server 5.5\\lib" "C:\\Program Files\\MySQL\\MySQL Server 5.6\\lib")
|
||||
endif()
|
||||
|
||||
find_library(MYSQLCLIENT_LIBRARIES NAMES mysqlclient PATHS ${MYSQLCLIENT_DEFAULT_PATHS} PATH_SUFFIXES mysql mariadb)
|
||||
if(${MYSQLCLIENT_LIBRARIES} MATCHES "NOTFOUND")
|
||||
set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "")
|
||||
MESSAGE(STATUS "Mysql connector NOT FOUND: servatrice won't be able to connect to a mysql server")
|
||||
unset(MYSQLCLIENT_LIBRARIES)
|
||||
else()
|
||||
set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "")
|
||||
get_filename_component(MYSQLCLIENT_LIBRARY_DIR ${MYSQLCLIENT_LIBRARIES} PATH)
|
||||
MESSAGE(STATUS "Mysql connector found at: ${MYSQLCLIENT_LIBRARY_DIR}")
|
||||
endif()
|
||||
|
||||
# Declare path variables
|
||||
set(ICONDIR share/icons CACHE STRING "icon dir")
|
||||
set(DESKTOPDIR share/applications CACHE STRING "desktop file destination")
|
||||
|
|
@ -146,12 +168,13 @@ if(APPLE)
|
|||
# these needs to be relative to CMAKE_INSTALL_PREFIX
|
||||
set(plugin_dest_dir servatrice.app/Contents/Plugins)
|
||||
set(qtconf_dest_dir servatrice.app/Contents/Resources)
|
||||
get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE)
|
||||
|
||||
# qt4: codecs, sqldrivers
|
||||
# qt5: platforms, sqldrivers
|
||||
|
||||
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime
|
||||
FILES_MATCHING REGEX "(codecs|platforms|sqldrivers)/.*\\.dylib"
|
||||
FILES_MATCHING REGEX "(codecs/.*|platforms/.*|sqldrivers/libqsqlmysql)\\.dylib"
|
||||
REGEX ".*_debug\\.dylib" EXCLUDE)
|
||||
|
||||
install(CODE "
|
||||
|
|
@ -165,7 +188,7 @@ Translations = Resources/translations\")
|
|||
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
|
||||
set(BU_CHMOD_BUNDLE_ITEMS ON)
|
||||
include(BundleUtilities)
|
||||
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
|
||||
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\")
|
||||
" COMPONENT Runtime)
|
||||
endif()
|
||||
|
||||
|
|
@ -178,7 +201,8 @@ if(WIN32)
|
|||
# qt5: platforms, sqldrivers
|
||||
|
||||
install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime
|
||||
FILES_MATCHING REGEX "(codecs|platforms|sqldrivers)/.*[^d]\\.dll")
|
||||
FILES_MATCHING REGEX "(codecs/.*|platforms/.*|sqldrivers/libqsqlmysql)\\.dll"
|
||||
REGEX ".*d\\.dll" EXCLUDE)
|
||||
|
||||
install(CODE "
|
||||
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
|
||||
|
|
@ -191,7 +215,7 @@ Translations = Resources/translations\")
|
|||
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\")
|
||||
set(BU_CHMOD_BUNDLE_ITEMS ON)
|
||||
include(BundleUtilities)
|
||||
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
|
||||
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR};${MYSQLCLIENT_LIBRARY_DIR}\")
|
||||
" COMPONENT Runtime)
|
||||
endif()
|
||||
#Compile a portable version, default off
|
||||
|
|
|
|||
33
servatrice/check_schema_version.sh
Executable file
33
servatrice/check_schema_version.sh
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
schema_ver="$(grep 'INSERT INTO cockatrice_schema_version' servatrice/servatrice.sql | sed 's/.*VALUES(//' | sed 's/).*//')"
|
||||
|
||||
latest_migration="$(ls -1 servatrice/migrations/ | tail -n1)"
|
||||
xtoysql="${latest_migration#servatrice_}"
|
||||
xtoy="${xtoysql%.sql}"
|
||||
old_ver="$(echo ${xtoy%%_to_*} | bc)"
|
||||
new_ver="$(echo ${xtoy##*_to_} | bc)"
|
||||
|
||||
if ((old_ver >= new_ver)); then
|
||||
echo "New version $new_ver is not newer than $old_ver"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ((schema_ver != new_ver)); then
|
||||
echo "Schema version $schema_ver does not equal new version $new_ver"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
expected_sql="^UPDATE cockatrice_schema_version SET version=${new_ver} WHERE version=${old_ver};$"
|
||||
if ! grep -q "$expected_sql" servatrice/migrations/$latest_migration; then
|
||||
echo "$latest_migration does not contain expected sql: $expected_sql"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
expected_define="^#define DATABASE_SCHEMA_VERSION $new_ver$"
|
||||
if ! grep -q "$expected_define" servatrice/src/servatrice_database_interface.h; then
|
||||
echo "servatrice_database_interface.h does not contain expected #define: $expected_define"
|
||||
exit 1
|
||||
fi
|
||||
5
servatrice/migrations/servatrice_0011_to_0012.sql
Normal file
5
servatrice/migrations/servatrice_0011_to_0012.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- Servatrice db migration from version 11 to version 12
|
||||
|
||||
alter table cockatrice_users modify token binary(16) NULL;
|
||||
|
||||
UPDATE cockatrice_schema_version SET version=12 WHERE version=11;
|
||||
|
|
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
|
|||
PRIMARY KEY (`version`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO cockatrice_schema_version VALUES(11);
|
||||
INSERT INTO cockatrice_schema_version VALUES(12);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` (
|
||||
`id` int(7) unsigned zerofill NOT NULL auto_increment,
|
||||
|
|
@ -82,7 +82,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` (
|
|||
`avatar_bmp` blob NOT NULL,
|
||||
`registrationDate` datetime NOT NULL,
|
||||
`active` tinyint(1) NOT NULL,
|
||||
`token` binary(16) NOT NULL,
|
||||
`token` binary(16),
|
||||
`clientid` varchar(15) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`),
|
||||
|
|
|
|||
|
|
@ -176,7 +176,8 @@ bool Servatrice::initServer()
|
|||
bool registrationEnabled = settingsCache->value("registration/enabled", false).toBool();
|
||||
bool requireEmailForRegistration = settingsCache->value("registration/requireemail", true).toBool();
|
||||
|
||||
qDebug() << "Registration enabled: " << regServerOnly;
|
||||
qDebug() << "Accept registered users only: " << regServerOnly;
|
||||
qDebug() << "Registration enabled: " << registrationEnabled;
|
||||
if (registrationEnabled)
|
||||
qDebug() << "Require email address to register: " << requireEmailForRegistration;
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ bool Servatrice_DatabaseInterface::execSqlQuery(QSqlQuery *query)
|
|||
bool Servatrice_DatabaseInterface::usernameIsValid(const QString &user, QString & error)
|
||||
{
|
||||
int minNameLength = settingsCache->value("users/minnamelength", 6).toInt();
|
||||
if(minNameLength < 1)
|
||||
minNameLength = 1;
|
||||
int maxNameLength = settingsCache->value("users/maxnamelength", 12).toInt();
|
||||
bool allowLowercase = settingsCache->value("users/allowlowercase", true).toBool();
|
||||
bool allowUppercase = settingsCache->value("users/allowuppercase", true).toBool();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "server.h"
|
||||
#include "server_database_interface.h"
|
||||
|
||||
#define DATABASE_SCHEMA_VERSION 11
|
||||
#define DATABASE_SCHEMA_VERSION 12
|
||||
|
||||
class Servatrice;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue