mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 13:43:49 +01:00
BUGFIX: Prevent renaming servers to hacknet. (#1112)
* Add hacknet check to renaming * Handle manual server purchases * Handle automated server purchases * Remove unnecessary parenthesis fixes #1111
This commit is contained in:
parent
ac05135f59
commit
1577467fe1
@ -1167,6 +1167,10 @@ export const ns: InternalAPI<NSFull> = {
|
||||
helpers.log(ctx, () => `Invalid argument: hostname='${hostnameStr}'`);
|
||||
return "";
|
||||
}
|
||||
if (hostnameStr.startsWith("hacknet-node-") || hostnameStr.startsWith("hacknet-server-")) {
|
||||
helpers.log(ctx, () => `Invalid argument: hostname='${hostnameStr}' is a reserved hostname.`);
|
||||
return "";
|
||||
}
|
||||
|
||||
if (Player.purchasedServers.length >= getPurchaseServerLimit()) {
|
||||
helpers.log(
|
||||
|
@ -65,6 +65,9 @@ export const renamePurchasedServer = (hostname: string, newName: string): void =
|
||||
if (!server) throw new Error(`Server '${hostname}' doesn't exists.`);
|
||||
if (GetServer(newName)) throw new Error(`Server '${newName}' already exists.`);
|
||||
if (!Player.purchasedServers.includes(hostname)) throw new Error(`Server '${hostname}' is not a player server.`);
|
||||
if (newName.startsWith("hacknet-node-") || newName.startsWith("hacknet-server-")) {
|
||||
throw new Error(`'${newName}' is a reserved hostname.`);
|
||||
}
|
||||
const replace = (arr: string[], old: string, next: string): string[] => {
|
||||
return arr.map((v) => (v === old ? next : v));
|
||||
};
|
||||
@ -122,6 +125,11 @@ export function purchaseServer(hostname: string, ram: number, cost: number): voi
|
||||
return;
|
||||
}
|
||||
|
||||
if (hostname.startsWith("hacknet-node-") || hostname.startsWith("hacknet-server-")) {
|
||||
dialogBoxCreate(`'${hostname}' is a reserved hostname, please try again.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create server
|
||||
const newServ = safelyCreateUniqueServer({
|
||||
adminRights: true,
|
||||
|
Loading…
Reference in New Issue
Block a user