From a4a59e2a0ee53c3ed8f1909a9c42ea181eed0b9f Mon Sep 17 00:00:00 2001 From: Big Bad Waffle Date: Sun, 22 Oct 2023 10:03:18 +0000 Subject: [PATCH] Revert "bug #2004: Fixed the thread finder check and announcement duration" This reverts commit b453ee373e5ece455f84870734192ffb3e86dcdd --- src/server/config/serverConfig.js | 2 +- src/server/mods/checkModRepos.js | 79 ------------------------------- src/server/world/atlas.js | 2 +- src/server/world/threadManager.js | 15 +----- 4 files changed, 3 insertions(+), 95 deletions(-) delete mode 100644 src/server/mods/checkModRepos.js diff --git a/src/server/config/serverConfig.js b/src/server/config/serverConfig.js index f8e99b51..ae549066 100644 --- a/src/server/config/serverConfig.js +++ b/src/server/config/serverConfig.js @@ -10,7 +10,7 @@ module.exports = { //Options: // sqlite // rethink - db: process.env.IWD_DB || 'rethink', + db: process.env.IWD_DB || 'sqlite', dbHost: process.env.IWD_DB_HOST || 'localhost', dbPort: process.env.IWD_DB_PORT || 28015, dbName: process.env.IWD_DB_NAME || 'live', diff --git a/src/server/mods/checkModRepos.js b/src/server/mods/checkModRepos.js deleted file mode 100644 index 1e0e012e..00000000 --- a/src/server/mods/checkModRepos.js +++ /dev/null @@ -1,79 +0,0 @@ -const fs = require('fs'); -const { execSync } = require('child_process'); -const path = require('path'); - -function getSubdirectories (directoryPath) { - return fs.readdirSync(directoryPath, { withFileTypes: true }) - .filter(dirent => dirent.isDirectory()) - .map(dirent => dirent.name); -} - -function isGitRepository (directoryPath) { - const gitFolderPath = path.join(directoryPath, '.git'); - return fs.existsSync(gitFolderPath) && fs.statSync(gitFolderPath).isDirectory(); -} - -function doesReleaseBranchExist (directoryPath) { - try { - const branches = execSync('git branch -r', { cwd: directoryPath, encoding: 'utf-8' }); - return branches.includes('origin/release'); - } catch (error) { - return false; - } -} - -function getCommitsInRange (directoryPath, range) { - const command = `git log --pretty=format:"%s" --abbrev-commit ${range}`; - try { - const result = execSync(command, { cwd: directoryPath, encoding: 'utf-8' }); - return result.trim().split('\n'); - } catch (error) { - return []; - } -} - -function getCommitCountBehind (directoryPath) { - if (doesReleaseBranchExist(directoryPath)) { - execSync('git fetch origin release', { cwd: directoryPath, encoding: 'utf-8' }); - - const command = 'origin/release..origin/master'; - const commitMessages = getCommitsInRange(directoryPath, command); - const commitCount = commitMessages.length; - - if (commitMessages.length === 1 && commitMessages[0] === '') - return { count: 0, messages: [] }; - - return { count: commitCount, messages: commitMessages }; - } - return { count: 0, messages: [] }; -} - -const greenColor = '\x1b[32m'; -const grayColor = '\x1b[90m'; -const resetColor = '\x1b[0m'; - -function displayCommitCountBehind (directoryPath) { - if (isGitRepository(directoryPath)) { - const { count, messages } = getCommitCountBehind(directoryPath); - if (count > 0) { - console.log(`${greenColor}${path.basename(directoryPath)}: ${count} commit(s)`); - messages.forEach((message, index) => { - console.log(`${grayColor}${index + 1}. ${message}`); - }); - console.log('\n'); - } - } -} - -function processSubdirectories (subdirectories) { - subdirectories.forEach(subdirectory => { - const fullPath = path.join(process.cwd(), subdirectory); - if (isGitRepository(fullPath)) - displayCommitCountBehind(fullPath); - }); -} - -console.log('\n'); -const subdirectories = getSubdirectories(process.cwd()); -processSubdirectories(subdirectories); -console.log(resetColor); diff --git a/src/server/world/atlas.js b/src/server/world/atlas.js index 7911c030..476be5b6 100644 --- a/src/server/world/atlas.js +++ b/src/server/world/atlas.js @@ -51,7 +51,7 @@ module.exports = { event: 'onGetAnnouncement', data: { msg: 'Generating a new map, please wait as this may take a few moments..', - ttl: 500 + ttl: 5000 } }); } diff --git a/src/server/world/threadManager.js b/src/server/world/threadManager.js index 170f3d24..9ad4e56e 100644 --- a/src/server/world/threadManager.js +++ b/src/server/world/threadManager.js @@ -174,22 +174,9 @@ const spawnThread = async ({ name, path, instanced }) => { }; const doesThreadExist = ({ zoneName, zoneId }) => { - let map = mapList.find(m => m.name === zoneName); - - if (!map) - map = mapList.find(m => m.name === clientConfig.config.defaultZone); - const exists = threads.some(t => t.id === zoneId && t.name === zoneName); - if (exists) - return true; - - if (map.instanced) - return false; - - const thread = getThreadFromName(map.name); - - return !!thread; + return exists; }; const getThread = async ({ zoneName, zoneId }) => {