Skip to content

Commit 52fda61

Browse files
committed
db_enabled fix for chats
1 parent 6f466cd commit 52fda61

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

TypescriptServer/src/config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ const common_config = {
141141
kick_other_sessions: true
142142
},
143143

144+
chat: {
145+
create_global_chat: true
146+
},
147+
144148
tps: 20, // tickrate
145149

146150
// Disable some of the features that you don't need in your game

TypescriptServer/src/initializers/15_chats.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import Chat, { chatCreate } from "#concepts/chat";
22
import ChatLog from "#schemas/chat";
33

44
// create instances of every chat from the DB
5-
const chatLogs = await ChatLog.find({});
6-
chatLogs.forEach(chatlog => {
7-
let chat = new Chat(chatlog);
8-
global.chats[chat.chat_id] = chat;
9-
});
5+
if (global.config.db_enabled) {
6+
const chatLogs = await ChatLog.find({});
7+
chatLogs.forEach(chatlog => {
8+
let chat = new Chat(chatlog);
9+
global.chats[chat.chat_id] = chat;
10+
});
11+
}
1012

1113

1214
// create a new id=0 "global" chat if it doesn't exist already
13-
if (global.chats['0'] === undefined) {
15+
if (global.chats['0'] === undefined && global.config.chat.create_global_chat) {
1416
let chatlog = new ChatLog();
1517
chatlog._id = '0';
1618

0 commit comments

Comments
 (0)