mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-28 11:53:11 -07:00
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:
6
servatrice/migrations/servatrice_0008_to_0009.sql
Normal file
6
servatrice/migrations/servatrice_0008_to_0009.sql
Normal 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;
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "server.h"
|
||||
#include "server_database_interface.h"
|
||||
|
||||
#define DATABASE_SCHEMA_VERSION 8
|
||||
#define DATABASE_SCHEMA_VERSION 9
|
||||
|
||||
class Servatrice;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user