add disableAI to config
This commit is contained in:
13 files changed
+24
-6
No files matched your search
@@ -21,6 +21,7 @@ const FIELD_LOCATIONS: Record<
|
|||||||
disableThirdPerson: ['gameProperties', 'disableThirdPerson'],
|
disableThirdPerson: ['gameProperties', 'disableThirdPerson'],
|
||||||
fastValidation: ['gameProperties', 'fastValidation'],
|
fastValidation: ['gameProperties', 'fastValidation'],
|
||||||
battlEye: ['gameProperties', 'battlEye'],
|
battlEye: ['gameProperties', 'battlEye'],
|
||||||
|
disableAI: ['operating', 'disableAI'],
|
||||||
aiLimit: ['operating', 'aiLimit'],
|
aiLimit: ['operating', 'aiLimit'],
|
||||||
playerSaveTime: ['operating', 'playerSaveTime'],
|
playerSaveTime: ['operating', 'playerSaveTime'],
|
||||||
slotReservationTimeout: ['operating', 'slotReservationTimeout'],
|
slotReservationTimeout: ['operating', 'slotReservationTimeout'],
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const REAL_SHAPE = {
|
|||||||
a2s: { address: '0.0.0.0', port: 17777 },
|
a2s: { address: '0.0.0.0', port: 17777 },
|
||||||
rcon: { address: '127.0.0.1', port: 19999, password: 'hunter2', permission: 'admin' },
|
rcon: { address: '127.0.0.1', port: 19999, password: 'hunter2', permission: 'admin' },
|
||||||
game: {
|
game: {
|
||||||
name: 'DazzledCorp Training Grounds',
|
name: 'DZR Training Grounds',
|
||||||
password: '',
|
password: '',
|
||||||
passwordAdmin: 'secret',
|
passwordAdmin: 'secret',
|
||||||
admins: ['76561198000000000'],
|
admins: ['76561198000000000'],
|
||||||
@@ -34,7 +34,12 @@ const REAL_SHAPE = {
|
|||||||
{ modId: '5AAF0CCE3F001FB5' },
|
{ modId: '5AAF0CCE3F001FB5' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
operating: { lobbyPlayerSynchronise: true, aiLimit: -1, playerSaveTime: 120 },
|
operating: {
|
||||||
|
lobbyPlayerSynchronise: true,
|
||||||
|
disableAI: false,
|
||||||
|
aiLimit: -1,
|
||||||
|
playerSaveTime: 120
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('parseReforgerConfigJson', () => {
|
describe('parseReforgerConfigJson', () => {
|
||||||
@@ -44,6 +49,7 @@ describe('parseReforgerConfigJson', () => {
|
|||||||
serverName: 'DazzledCorp Training Grounds',
|
serverName: 'DazzledCorp Training Grounds',
|
||||||
maxPlayers: 16,
|
maxPlayers: 16,
|
||||||
scenarioId: '{ECC61978EDCC2B5A}Missions/23_Campaign.conf',
|
scenarioId: '{ECC61978EDCC2B5A}Missions/23_Campaign.conf',
|
||||||
|
disableAI: false,
|
||||||
aiLimit: -1,
|
aiLimit: -1,
|
||||||
serverMaxViewDistance: 2500,
|
serverMaxViewDistance: 2500,
|
||||||
networkViewDistance: 1000,
|
networkViewDistance: 1000,
|
||||||
@@ -66,6 +72,7 @@ describe('parseReforgerConfigJson', () => {
|
|||||||
const config = parseReforgerConfigJson('{"game":{"name":"Bare"}}');
|
const config = parseReforgerConfigJson('{"game":{"name":"Bare"}}');
|
||||||
expect(config.serverName).toBe('Bare');
|
expect(config.serverName).toBe('Bare');
|
||||||
expect(config.maxPlayers).toBe(0);
|
expect(config.maxPlayers).toBe(0);
|
||||||
|
expect(config.disableAI).toBe(false);
|
||||||
expect(config.aiLimit).toBe(-1);
|
expect(config.aiLimit).toBe(-1);
|
||||||
expect(config.mods).toEqual([]);
|
expect(config.mods).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export function mapReforgerConfig(raw: unknown): ReforgerServerConfig {
|
|||||||
serverName: str(game.name, 'Unnamed server'),
|
serverName: str(game.name, 'Unnamed server'),
|
||||||
maxPlayers: num(game.maxPlayers, 0),
|
maxPlayers: num(game.maxPlayers, 0),
|
||||||
scenarioId: str(game.scenarioId),
|
scenarioId: str(game.scenarioId),
|
||||||
|
disableAI: bool(operating.disableAI, false),
|
||||||
// -1 means "no limit" in Reforger's operating.aiLimit.
|
// -1 means "no limit" in Reforger's operating.aiLimit.
|
||||||
aiLimit: num(operating.aiLimit, -1),
|
aiLimit: num(operating.aiLimit, -1),
|
||||||
serverMaxViewDistance: num(gameProperties.serverMaxViewDistance, 0),
|
serverMaxViewDistance: num(gameProperties.serverMaxViewDistance, 0),
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export class MockGameServerProvider implements GameServerProvider {
|
|||||||
},
|
},
|
||||||
mods: [{ modId: '591AF5BDA9F7CE8B', name: 'Mock Sample Mod', version: '1.0.2' }],
|
mods: [{ modId: '591AF5BDA9F7CE8B', name: 'Mock Sample Mod', version: '1.0.2' }],
|
||||||
},
|
},
|
||||||
operating: { aiLimit: 40 },
|
operating: { disableAI: false, aiLimit: 40 },
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2,
|
2,
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ const performanceBodySchema = z
|
|||||||
disableThirdPerson: z.boolean().nullable(),
|
disableThirdPerson: z.boolean().nullable(),
|
||||||
fastValidation: z.boolean().nullable(),
|
fastValidation: z.boolean().nullable(),
|
||||||
battlEye: z.boolean().nullable(),
|
battlEye: z.boolean().nullable(),
|
||||||
|
disableAI: z.boolean().nullable(),
|
||||||
aiLimit: z.number().int().min(-1).max(1000).nullable(),
|
aiLimit: z.number().int().min(-1).max(1000).nullable(),
|
||||||
playerSaveTime: z.number().int().min(1).max(3600).nullable(),
|
playerSaveTime: z.number().int().min(1).max(3600).nullable(),
|
||||||
slotReservationTimeout: z.number().int().min(5).max(300).nullable(),
|
slotReservationTimeout: z.number().int().min(5).max(300).nullable(),
|
||||||
|
|||||||
@@ -343,6 +343,7 @@ describe('performance config by role', () => {
|
|||||||
disableThirdPerson: null,
|
disableThirdPerson: null,
|
||||||
fastValidation: null,
|
fastValidation: null,
|
||||||
battlEye: null,
|
battlEye: null,
|
||||||
|
disableAI: null,
|
||||||
aiLimit: null,
|
aiLimit: null,
|
||||||
playerSaveTime: null,
|
playerSaveTime: null,
|
||||||
slotReservationTimeout: null,
|
slotReservationTimeout: null,
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ describe('ServerModsService', () => {
|
|||||||
expect(parsed.bindPort).toBe(2001);
|
expect(parsed.bindPort).toBe(2001);
|
||||||
expect(parsed.game.name).toBe('Mock Reforger Server');
|
expect(parsed.game.name).toBe('Mock Reforger Server');
|
||||||
expect(parsed.game.maxPlayers).toBe(16);
|
expect(parsed.game.maxPlayers).toBe(16);
|
||||||
|
expect(parsed.operating.disableAI).toBe(false);
|
||||||
expect(parsed.operating.aiLimit).toBe(40);
|
expect(parsed.operating.aiLimit).toBe(40);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ describe('PerformanceSettingsService', () => {
|
|||||||
// Present in the mock config.json:
|
// Present in the mock config.json:
|
||||||
expect(settings.maxPlayers).toBe(16);
|
expect(settings.maxPlayers).toBe(16);
|
||||||
expect(settings.serverMaxViewDistance).toBe(2500);
|
expect(settings.serverMaxViewDistance).toBe(2500);
|
||||||
|
expect(settings.disableAI).toBe(false);
|
||||||
expect(settings.aiLimit).toBe(40);
|
expect(settings.aiLimit).toBe(40);
|
||||||
expect(settings.disableThirdPerson).toBe(false);
|
expect(settings.disableThirdPerson).toBe(false);
|
||||||
// Absent keys:
|
// Absent keys:
|
||||||
@@ -50,10 +51,11 @@ describe('PerformanceSettingsService', () => {
|
|||||||
...settings,
|
...settings,
|
||||||
maxPlayers: 32,
|
maxPlayers: 32,
|
||||||
playerSaveTime: 180, // new key
|
playerSaveTime: 180, // new key
|
||||||
|
disableAI: null,
|
||||||
aiLimit: null, // remove key → game default
|
aiLimit: null, // remove key → game default
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.changedFields.sort()).toEqual(['aiLimit', 'maxPlayers', 'playerSaveTime']);
|
expect(result.changedFields.sort()).toEqual(['aiLimit', 'disableAI', 'maxPlayers', 'playerSaveTime']);
|
||||||
expect(result.requiresRestart).toBe(true);
|
expect(result.requiresRestart).toBe(true);
|
||||||
|
|
||||||
const written = JSON.parse(provider.writtenFiles.get('/config.json')!);
|
const written = JSON.parse(provider.writtenFiles.get('/config.json')!);
|
||||||
|
|||||||
@@ -235,7 +235,8 @@ export function useSetPerformanceSettings(slug: string) {
|
|||||||
`/api/servers/${slug}/config/performance`,
|
`/api/servers/${slug}/config/performance`,
|
||||||
settings,
|
settings,
|
||||||
),
|
),
|
||||||
onSuccess: () => {
|
onSuccess: (result) => {
|
||||||
|
queryClient.setQueryData(['servers', slug, 'config', 'performance'], result);
|
||||||
void queryClient.invalidateQueries({ queryKey: ['servers', slug] });
|
void queryClient.invalidateQueries({ queryKey: ['servers', slug] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ const NUMBER_FIELDS: { key: NumberKey; label: string; min: number; max: number;
|
|||||||
];
|
];
|
||||||
|
|
||||||
const BOOLEAN_FIELDS: { key: BooleanKey; label: string; hint: string }[] = [
|
const BOOLEAN_FIELDS: { key: BooleanKey; label: string; hint: string }[] = [
|
||||||
|
{ key: 'disableAI', label: 'Disable AI', hint: 'default enabled' },
|
||||||
{ key: 'disableThirdPerson', label: 'Disable third person', hint: 'default disabled' },
|
{ key: 'disableThirdPerson', label: 'Disable third person', hint: 'default disabled' },
|
||||||
{ key: 'fastValidation', label: 'Fast validation', hint: 'default enabled' },
|
{ key: 'fastValidation', label: 'Fast validation', hint: 'default enabled' },
|
||||||
{ key: 'battlEye', label: 'BattlEye', hint: 'default enabled' },
|
{ key: 'battlEye', label: 'BattlEye', hint: 'default enabled' },
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ function ConfigurationsBody({ slug, user }: { slug: string; user: CurrentUser })
|
|||||||
<h1 className="page-title">Configuration</h1>
|
<h1 className="page-title">Configuration</h1>
|
||||||
<MissionCard slug={slug} canEdit={canEdit} />
|
<MissionCard slug={slug} canEdit={canEdit} />
|
||||||
<PerformanceForm slug={slug} canEdit={canEdit} />
|
<PerformanceForm slug={slug} canEdit={canEdit} />
|
||||||
<SchedulesCard slug={slug} canEdit={canEdit} />
|
{/*<SchedulesCard slug={slug} canEdit={canEdit} />*/}
|
||||||
{canEdit && <StartupVarsCard slug={slug} />}
|
{canEdit && <StartupVarsCard slug={slug} />}
|
||||||
<Card title="Full config summary (live from the server)">
|
<Card title="Full config summary (live from the server)">
|
||||||
{config ? <ConfigSummaryRows config={config} /> : <Spinner />}
|
{config ? <ConfigSummaryRows config={config} /> : <Spinner />}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export type ReforgerServerConfig = {
|
|||||||
serverName: string;
|
serverName: string;
|
||||||
maxPlayers: number;
|
maxPlayers: number;
|
||||||
scenarioId: string;
|
scenarioId: string;
|
||||||
|
disableAI: boolean;
|
||||||
aiLimit: number;
|
aiLimit: number;
|
||||||
serverMaxViewDistance: number;
|
serverMaxViewDistance: number;
|
||||||
networkViewDistance: number;
|
networkViewDistance: number;
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ export type PerformanceSettings = {
|
|||||||
disableThirdPerson: boolean | null; // game.gameProperties (default false)
|
disableThirdPerson: boolean | null; // game.gameProperties (default false)
|
||||||
fastValidation: boolean | null; // game.gameProperties (default true)
|
fastValidation: boolean | null; // game.gameProperties (default true)
|
||||||
battlEye: boolean | null; // game.gameProperties (default true)
|
battlEye: boolean | null; // game.gameProperties (default true)
|
||||||
|
disableAI: boolean | null; // operating (default false)
|
||||||
aiLimit: number | null; // operating, -1 = unlimited (default -1)
|
aiLimit: number | null; // operating, -1 = unlimited (default -1)
|
||||||
playerSaveTime: number | null; // operating, seconds (default 120)
|
playerSaveTime: number | null; // operating, seconds (default 120)
|
||||||
slotReservationTimeout: number | null; // operating, 5–300 s (default 60)
|
slotReservationTimeout: number | null; // operating, 5–300 s (default 60)
|
||||||
|
|||||||
Reference in new issue
Block a user