Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix several observed issues #248

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/common/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CALCULATE_PP=true
ENABLE_KEY_OVERLAY=true
ENABLE_AUTOUPDATE=true

ALLOWED_IPS=127.0.0.1,localhost
ALLOWED_IPS=127.0.0.1,localhost,absolute

# Reference: 1 second = 1000 milliseconds
# Once in what value, the programme should read the game values (in milliseconds)
Expand Down Expand Up @@ -78,7 +78,7 @@ export const config = {
staticFolderPath: process.env.STATIC_FOLDER_PATH || './static',
enableGosuOverlay: (process.env.ENABLE_GOSU_OVERLAY || '') === 'true',
enableIngameOverlay: (process.env.ENABLE_INGAME_OVERLAY || '') === 'true',
allowedIPs: process.env.ALLOWED_IPS || '',
allowedIPs: process.env.ALLOWED_IPS || '127.0.0.1,localhost,absolute',
timestamp: 0,
currentVersion: '',
updateVersion: '',
Expand Down Expand Up @@ -156,7 +156,7 @@ export const updateConfigFile = () => {
newOptions += 'ALLOWED_IPS, ';
fs.appendFileSync(
configPath,
'\nALLOWED_IPS=127.0.0.1,localhost',
'\nALLOWED_IPS=127.0.0.1,localhost,absolute',
'utf8'
);
}
Expand Down Expand Up @@ -220,7 +220,7 @@ export const refreshConfig = (httpServer: any, refresh: boolean) => {
const staticFolderPath = parsed.STATIC_FOLDER_PATH || './static';
const enableGosuOverlay = (parsed.ENABLE_GOSU_OVERLAY || '') === 'true';
const enableIngameOverlay = (parsed.ENABLE_INGAME_OVERLAY || '') === 'true';
const allowedIPs = parsed.ALLOWED_IPS || '';
const allowedIPs = parsed.ALLOWED_IPS || '127.0.0.1,localhost,absolute';

// determine whether config actually was updated or not
updated =
Expand Down
27 changes: 26 additions & 1 deletion packages/tosu/src/api/utils/buildResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,32 @@ const buildTourneyData = (
instanceManager.osuInstances
).filter((instance) => instance.isTourneyManager);
if (osuTourneyManager.length < 1) {
return undefined;
return {
manager: {
ipcState: 0,
bestOF: 0,
teamName: {
left: '',
right: ''
},
stars: {
left: 0,
right: 0
},
bools: {
scoreVisible: false,
starsVisible: false
},
chat: [],
gameplay: {
score: {
left: 0,
right: 0
}
}
},
ipcClients: []
};
}

const osuTourneyClients = Object.values(
Expand Down
25 changes: 24 additions & 1 deletion packages/tosu/src/api/utils/buildResultV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,30 @@ const buildTourneyData = (
instanceManager.osuInstances
).filter((instance) => instance.isTourneyManager);
if (osuTourneyManager.length < 1) {
return undefined;
return {
scoreVisible: false,
starsVisible: false,

ipcState: 0,
bestOF: 0,
team: {
left: '',
right: ''
},

points: {
left: 0,
right: 0
},

chat: [],

totalScore: {
left: 0,
right: 0
},
clients: []
};
}

const osuTourneyClients = Object.values(
Expand Down
4 changes: 2 additions & 2 deletions packages/tosu/src/memory/lazer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export class LazerMemory extends AbstractMemory<LazerPatternData> {

const modAcronyms = JSON.parse(jsonString) as Mod[];

let mods = calculateMods(modAcronyms);
let mods = calculateMods(modAcronyms, true);
if (mods instanceof Error)
mods = Object.assign({}, defaultCalculatedMods);

Expand Down Expand Up @@ -1774,7 +1774,7 @@ export class LazerMemory extends AbstractMemory<LazerPatternData> {
}
}

let mods = calculateMods(modList);
let mods = calculateMods(modList, true);
if (mods instanceof Error)
mods = Object.assign({}, defaultCalculatedMods);

Expand Down
8 changes: 4 additions & 4 deletions packages/tosu/src/memory/stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export class StableMemory extends AbstractMemory<OsuPatternData> {
this.process.readInt(resultScreenBase + 0xa0)
).toISOString();

let mods = calculateMods(modsInt);
let mods = calculateMods(modsInt, true);
if (mods instanceof Error)
mods = Object.assign({}, defaultCalculatedMods);

Expand Down Expand Up @@ -529,7 +529,7 @@ export class StableMemory extends AbstractMemory<OsuPatternData> {
maxCombo = this.process.readShort(scoreBase + 0x68);
}

let mods = calculateMods(modsInt);
let mods = calculateMods(modsInt, true);
if (mods instanceof Error)
mods = Object.assign({}, defaultCalculatedMods);

Expand Down Expand Up @@ -738,7 +738,7 @@ export class StableMemory extends AbstractMemory<OsuPatternData> {
);
}

let mods = calculateMods(menuMods);
let mods = calculateMods(menuMods, true);
if (mods instanceof Error)
mods = Object.assign({}, defaultCalculatedMods);

Expand Down Expand Up @@ -1140,7 +1140,7 @@ export class StableMemory extends AbstractMemory<OsuPatternData> {

const modsInt = modsXor1 ^ modsXor2;

let mods = calculateMods(modsInt);
let mods = calculateMods(modsInt, true);
if (mods instanceof Error)
mods = Object.assign({}, defaultCalculatedMods);

Expand Down
10 changes: 8 additions & 2 deletions packages/tosu/src/utils/osuMods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ export const modsName = (modsNumber: number, order?: boolean): string => {
if (bit === 0) break;
}

// 99 - put at the end
convertedParts.sort(
(a, b) => ModsOrder[a.toLowerCase()] - ModsOrder[b.toLowerCase()]
(a, b) =>
cyperdark marked this conversation as resolved.
Show resolved Hide resolved
(ModsOrder[a.toLowerCase()] || 99) -
(ModsOrder[b.toLowerCase()] || 99)
);

const converted = convertedParts
Expand Down Expand Up @@ -252,8 +255,11 @@ export const calculateMods = (
}
}

// 99 - put at the end
convertedParts.sort(
(a, b) => ModsOrder[a.toLowerCase()] - ModsOrder[b.toLowerCase()]
(a, b) =>
(ModsOrder[a.toLowerCase()] || 99) -
(ModsOrder[b.toLowerCase()] || 99)
);

const ModsLazer = Array.isArray(mods)
Expand Down
Loading