Added chat history to a room that is displayed on join.

With this update a new chat history definition is added on a per
room bases which allows operators to specify the number of chat
messages to store and present to the user on join.  Please see
the sample ini for room definitions.
This commit is contained in:
woogerboy21
2015-09-12 13:46:22 -04:00
parent f97a7e8370
commit 87a64da1bc
23 changed files with 141 additions and 16 deletions

View File

@@ -0,0 +1,6 @@
-- Servatrice db migration from version 8 to version 9
alter table cockatrice_rooms add chat_history_size int(4) not null after join_message;
update cockatrice_rooms set chat_history_size = 100;
UPDATE cockatrice_schema_version SET version=9 WHERE version=8;

View File

@@ -188,6 +188,9 @@ roomlist\1\autojoin=true
; Message displayed to each user when he joins room number 1
roomlist\1\joinmessage="This message is only here to show that rooms can have a join message."
; The number of chat history messages to save that gets presented to a user joining the room
roomlist\1\chathistorysize=100
; Number of game types allowed (defined) in the room number 1
roomlist\1\game_types\size=3

View File

@@ -185,6 +185,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_rooms` (
`permissionlevel` varchar(20) NOT NULL,
`auto_join` tinyint(1) default 0,
`join_message` varchar(255) NOT NULL,
`chat_history_size` int(4) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@@ -222,7 +222,7 @@ bool Servatrice::initServer()
const QString roomMethod = settingsCache->value("rooms/method").toString();
if (roomMethod == "sql") {
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery("select id, name, descr, permissionlevel, auto_join, join_message from {prefix}_rooms order by id asc");
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery("select id, name, descr, permissionlevel, auto_join, join_message, chat_history_size from {prefix}_rooms order by id asc");
servatriceDatabaseInterface->execSqlQuery(query);
while (query->next()) {
QSqlQuery *query2 = servatriceDatabaseInterface->prepareQuery("select name from {prefix}_rooms_gametypes where id_room = :id_room");
@@ -233,6 +233,7 @@ bool Servatrice::initServer()
gameTypes.append(query2->value(0).toString());
addRoom(new Server_Room(query->value(0).toInt(),
query->value(6).toInt(),
query->value(1).toString(),
query->value(2).toString(),
query->value(3).toString().toLower(),
@@ -257,6 +258,7 @@ bool Servatrice::initServer()
Server_Room *newRoom = new Server_Room(
i,
settingsCache->value("chathistorysize").toInt(),
settingsCache->value("name").toString(),
settingsCache->value("description").toString(),
settingsCache->value("permissionlevel").toString().toLower(),
@@ -273,6 +275,7 @@ bool Servatrice::initServer()
// no room defined in config, add a dummy one
Server_Room *newRoom = new Server_Room(
0,
100,
"General room",
"Play anything here.",
"none",

View File

@@ -9,7 +9,7 @@
#include "server.h"
#include "server_database_interface.h"
#define DATABASE_SCHEMA_VERSION 8
#define DATABASE_SCHEMA_VERSION 9
class Servatrice;