Browse Source

Revert "bug #2004: Fixed the thread finder check and announcement duration"

This reverts commit b453ee373e
tags/v0.14.0^2
Big Bad Waffle 6 months ago
parent
commit
a4a59e2a0e
4 changed files with 3 additions and 95 deletions
  1. +1
    -1
      src/server/config/serverConfig.js
  2. +0
    -79
      src/server/mods/checkModRepos.js
  3. +1
    -1
      src/server/world/atlas.js
  4. +1
    -14
      src/server/world/threadManager.js

+ 1
- 1
src/server/config/serverConfig.js View File

@@ -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',


+ 0
- 79
src/server/mods/checkModRepos.js View File

@@ -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);

+ 1
- 1
src/server/world/atlas.js View File

@@ -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
}
});
}


+ 1
- 14
src/server/world/threadManager.js View File

@@ -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 }) => {


Loading…
Cancel
Save