v1.0.0 migration guide

This commit is contained in:
Olivier Gagnon 2021-11-02 22:49:46 -04:00
parent b2bf3fc21f
commit 0bee743b47
11 changed files with 52 additions and 13 deletions

@ -2,7 +2,7 @@
# #
# You can set these variables from the command line. # You can set these variables from the command line.
SPHINXOPTS = -W SPHINXOPTS =
SPHINXBUILD = python2.7 -msphinx SPHINXBUILD = python2.7 -msphinx
SOURCEDIR = source SOURCEDIR = source
BUILDDIR = build BUILDDIR = build

@ -29,6 +29,7 @@ secrets that you've been searching for.
Guides & Tips <guidesandtips> Guides & Tips <guidesandtips>
Tools & Resources <toolsandresources> Tools & Resources <toolsandresources>
Changelog <changelog> Changelog <changelog>
v1.0.0 script migration guide <v1.0.0_migration.rst>
Donate <https://paypal.me/danielyxie> Donate <https://paypal.me/danielyxie>
Indices and tables Indices and tables

@ -0,0 +1,32 @@
v1.0.0 Migration Guide
======================
In v1.0.0 a few API have been broken.
migrated:
* bladeburner.getActionTime will return milliseconds instead of seconds.
* getHackTime will return milliseconds instead of seconds.
* getGrowTime will return milliseconds instead of seconds.
* getWeakenTime will return milliseconds instead of seconds.
* hackAnalyzePercent renamed to hackAnalyze
* hackAnalyzePercent will return decimal instead of percentage
* hackChance (not formulas.basic.hackChance) renamed to hackAnalyzeChance
not migrated (require manual changes sometimes):
* getPurchasedServers won't let you query for ips instead of hostnames.
* getStats is deprecated in favor getPlayer
* getCharacterInformation is deprecated in favor getPlayer
* getServerRam deprecated in favor of getServerMaxRam and getServerUsedRam
* getServerBaseSecurityLevel will be deprecated in favor of nothing, it's not really used.
* sleep can no longer be called simultenaously, a new function called asleep will let you.
* write returns promise (needs to be await ed).
* scp returns a promise (needs to be await ed).
* free port, write, read
* write, read does not support port anymore, writePort and readPort does.
Upon loading v1.0.0 the game will apply some rules to change everything.
The game never changes a file before making a backup called `BACKUP_filename.ext`, then,
in the script it will change whatever it thinks it should change.
But will prefix the modified line with the original line.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -4,7 +4,8 @@
* Constants for specific mechanics or features will NOT be here. * Constants for specific mechanics or features will NOT be here.
*/ */
export const CONSTANTS: { export const CONSTANTS: {
Version: string; VersionString: string;
VersionNumber: number;
_idleSpeed: number; _idleSpeed: number;
MaxSkillLevel: number; MaxSkillLevel: number;
MilliPerCycle: number; MilliPerCycle: number;
@ -114,7 +115,8 @@ export const CONSTANTS: {
TotalNumBitNodes: number; TotalNumBitNodes: number;
LatestUpdate: string; LatestUpdate: string;
} = { } = {
Version: "1.0.0", VersionString: "1.0.0",
VersionNumber: 1,
// Speed (in ms) at which the main loop is updated // Speed (in ms) at which the main loop is updated
_idleSpeed: 200, _idleSpeed: 200,

@ -48,7 +48,7 @@ class BitburnerSaveObject {
this.MessagesSave = JSON.stringify(Messages); this.MessagesSave = JSON.stringify(Messages);
this.StockMarketSave = JSON.stringify(StockMarket); this.StockMarketSave = JSON.stringify(StockMarket);
this.SettingsSave = JSON.stringify(Settings); this.SettingsSave = JSON.stringify(Settings);
this.VersionSave = JSON.stringify(CONSTANTS.Version); this.VersionSave = JSON.stringify(CONSTANTS.VersionNumber);
this.LastExportBonus = JSON.stringify(ExportBonus.LastExportBonus); this.LastExportBonus = JSON.stringify(ExportBonus.LastExportBonus);
if (Player.inGang()) { if (Player.inGang()) {
this.AllGangsSave = JSON.stringify(AllGangs); this.AllGangsSave = JSON.stringify(AllGangs);
@ -293,12 +293,13 @@ function loadGame(saveString: string): boolean {
if (saveObj.hasOwnProperty("VersionSave")) { if (saveObj.hasOwnProperty("VersionSave")) {
try { try {
const ver = JSON.parse(saveObj.VersionSave, Reviver); const ver = JSON.parse(saveObj.VersionSave, Reviver);
console.log(ver);
evaluateVersionCompatibility(ver); evaluateVersionCompatibility(ver);
if (window.location.href.toLowerCase().includes("bitburner-beta")) { if (window.location.href.toLowerCase().includes("bitburner-beta")) {
// Beta branch, always show changes // Beta branch, always show changes
createBetaUpdateText(); createBetaUpdateText();
} else if (ver != CONSTANTS.Version) { } else if (ver !== CONSTANTS.VersionNumber) {
createNewUpdateText(); createNewUpdateText();
} }
} catch (e) { } catch (e) {

@ -333,7 +333,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
<ListItemIcon> <ListItemIcon>
{!open ? <ChevronRightIcon color="primary" /> : <ChevronLeftIcon color="primary" />} {!open ? <ChevronRightIcon color="primary" /> : <ChevronLeftIcon color="primary" />}
</ListItemIcon> </ListItemIcon>
<ListItemText primary={<Typography>Bitburner v{CONSTANTS.Version}</Typography>} /> <ListItemText primary={<Typography>Bitburner v{CONSTANTS.VersionString}</Typography>} />
</ListItem> </ListItem>
<Divider /> <Divider />
<List> <List>

@ -77,7 +77,7 @@ export class Terminal implements ITerminal {
commandHistory: string[] = []; commandHistory: string[] = [];
commandHistoryIndex = 0; commandHistoryIndex = 0;
outputHistory: (Output | Link | RawOutput)[] = [new Output(`Bitburner v${CONSTANTS.Version}`, "primary")]; outputHistory: (Output | Link | RawOutput)[] = [new Output(`Bitburner v${CONSTANTS.VersionString}`, "primary")];
// True if a Coding Contract prompt is opened // True if a Coding Contract prompt is opened
contractOpen = false; contractOpen = false;
@ -546,7 +546,7 @@ export class Terminal implements ITerminal {
} }
clear(): void { clear(): void {
this.outputHistory = [new Output(`Bitburner v${CONSTANTS.Version}`, "primary")]; this.outputHistory = [new Output(`Bitburner v${CONSTANTS.VersionString}`, "primary")];
TerminalEvents.emit(); TerminalEvents.emit();
TerminalClearEvents.emit(); TerminalClearEvents.emit();
} }

@ -69,7 +69,7 @@ export function LoadingScreen(): React.ReactElement {
<CircularProgress size={150} color="primary" /> <CircularProgress size={150} color="primary" />
</Grid> </Grid>
<Grid item> <Grid item>
<Typography variant="h3">Loading Bitburner v{CONSTANTS.Version}</Typography> <Typography variant="h3">Loading Bitburner v{CONSTANTS.VersionString}</Typography>
</Grid> </Grid>
{show && ( {show && (
<Grid item> <Grid item>

@ -27,7 +27,9 @@ function convert(code: string): string {
} }
if (line != orig) { if (line != orig) {
out.push(`// =============================== original line ===============================`); out.push(`// =============================== original line ===============================`);
out.push(`// ${orig}`); out.push(`/**`);
out.push(` * ${orig}`);
out.push(" */");
out.push(`// =============================================================================`); out.push(`// =============================================================================`);
} }
out.push(line); out.push(line);
@ -36,6 +38,7 @@ function convert(code: string): string {
} }
export function v1APIBreak(): void { export function v1APIBreak(): void {
console.log("Running v1 api migration");
for (const server of GetAllServers()) { for (const server of GetAllServers()) {
const backups: Script[] = []; const backups: Script[] = [];
for (const script of server.scripts) { for (const script of server.scripts) {