From 3067703c63c0c132f6016aea7d53220324c278c4 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 18 Aug 2022 13:40:39 -0400 Subject: [PATCH 1/2] Trying to fix int bug --- src/Constants.ts | 4 +- .../Player/PlayerObjectGeneralMethods.ts | 2 +- src/SaveObject.tsx | 162 ++++++++++++++++++ 3 files changed, 165 insertions(+), 3 deletions(-) diff --git a/src/Constants.ts b/src/Constants.ts index f5715c92f..a473d9995 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -88,8 +88,8 @@ export const CONSTANTS: { Donations: number; // number of blood/plasma/palette donation the dev have verified., boosts NFG LatestUpdate: string; } = { - VersionString: "2.0.1", - VersionNumber: 24, + VersionString: "2.0.2", + VersionNumber: 25, // Speed (in ms) at which the main loop is updated _idleSpeed: 200, diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts index 1af8e7398..1f46cb368 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts @@ -410,7 +410,7 @@ export function gainIntelligenceExp(this: IPerson, exp: number): void { console.error("ERROR: NaN passed into Player.gainIntelligenceExp()"); return; } - if (Player.sourceFileLvl(5) > 0 || this.skills.intelligence > 0) { + if (Player.sourceFileLvl(5) > 0 || this.skills.intelligence > 0 || Player.bitNodeN === 5) { this.exp.intelligence += exp; this.skills.intelligence = Math.floor(this.calculateSkill(this.exp.intelligence, 1)); } diff --git a/src/SaveObject.tsx b/src/SaveObject.tsx index 8cabb475d..5113d210c 100755 --- a/src/SaveObject.tsx +++ b/src/SaveObject.tsx @@ -494,6 +494,168 @@ function evaluateVersionCompatibility(ver: string | number): void { if (ver < 24) { Player.getHomeComputer().scripts.forEach((s) => s.filename.endsWith(".ns") && (s.filename += ".js")); } + if (ver < 25) { + const removePlayerFields = [ + "hacking_chance_mult", + "hacking_speed_mult", + "hacking_money_mult", + "hacking_grow_mult", + "hacking_mult", + "strength_mult", + "defense_mult", + "dexterity_mult", + "agility_mult", + "charisma_mult", + "hacking_exp_mult", + "strength_exp_mult", + "defense_exp_mult", + "dexterity_exp_mult", + "agility_exp_mult", + "charisma_exp_mult", + "company_rep_mult", + "faction_rep_mult", + "crime_money_mult", + "crime_success_mult", + "work_money_mult", + "hacknet_node_money_mult", + "hacknet_node_purchase_cost_mult", + "hacknet_node_ram_cost_mult", + "hacknet_node_core_cost_mult", + "hacknet_node_level_cost_mult", + "bladeburner_max_stamina_mult", + "bladeburner_stamina_gain_mult", + "bladeburner_analysis_mult", + "bladeburner_success_chance_mult", + "hacking_exp", + "strength_exp", + "defense_exp", + "dexterity_exp", + "agility_exp", + "charisma_exp", + "intelligence_exp", + "companyName", + "isWorking", + "workType", + "workCostMult", + "workExpMult", + "currentWorkFactionName", + "currentWorkFactionDescription", + "workHackExpGainRate", + "workStrExpGainRate", + "workDefExpGainRate", + "workDexExpGainRate", + "workAgiExpGainRate", + "workChaExpGainRate", + "workRepGainRate", + "workMoneyGainRate", + "workMoneyLossRate", + "workHackExpGained", + "workStrExpGained", + "workDefExpGained", + "workDexExpGained", + "workAgiExpGained", + "workChaExpGained", + "workRepGained", + "workMoneyGained", + "createProgramName", + "createProgramReqLvl", + "graftAugmentationName", + "timeWorkedGraftAugmentation", + "className", + "crimeType", + "timeWorked", + "timeWorkedCreateProgram", + "timeNeededToCompleteWork", + "factionWorkType", + "committingCrimeThruSingFn", + "singFnCrimeWorkerScript", + "hacking", + "max_hp", + "strength", + "defense", + "dexterity", + "agility", + "charisma", + "intelligence", + ]; + const removeSleeveFields = [ + "gymStatType", + "bbAction", + "bbContract", + "hacking", + "strength", + "defense", + "dexterity", + "agility", + "charisma", + "intelligence", + "max_hp", + "hacking_exp", + "strength_exp", + "defense_exp", + "dexterity_exp", + "agility_exp", + "charisma_exp", + "intelligence_exp", + "hacking_mult", + "strength_mult", + "defense_mult", + "dexterity_mult", + "agility_mult", + "charisma_mult", + "hacking_exp_mult", + "strength_exp_mult", + "defense_exp_mult", + "dexterity_exp_mult", + "agility_exp_mult", + "charisma_exp_mult", + "hacking_chance_mult", + "hacking_speed_mult", + "hacking_money_mult", + "hacking_grow_mult", + "company_rep_mult", + "faction_rep_mult", + "crime_money_mult", + "crime_success_mult", + "work_money_mult", + "hacknet_node_money_mult", + "hacknet_node_purchase_cost_mult", + "hacknet_node_ram_cost_mult", + "hacknet_node_core_cost_mult", + "hacknet_node_level_cost_mult", + "bladeburner_max_stamina_mult", + "bladeburner_stamina_gain_mult", + "bladeburner_analysis_mult", + "bladeburner_success_chance_mult", + "className", + "crimeType", + "currentTask", + "currentTaskLocation", + "currentTaskMaxTime", + "currentTaskTime", + "earningsForSleeves", + "earningsForPlayer", + "earningsForTask", + "factionWorkType", + "gainRatesForTask", + "logs", + ]; + let intExp = Number(anyPlayer.intelligence_exp); + if (isNaN(intExp)) intExp = 0; + anyPlayer.exp.intelligence += intExp; + for (const field of removePlayerFields) { + delete anyPlayer[field]; + } + for (const sleeve of anyPlayer.sleeves) { + const anySleeve = sleeve as any; + let intExp = Number(anySleeve.intelligence_exp); + if (isNaN(intExp)) intExp = 0; + anySleeve.exp.intelligence += intExp; + for (const field of removeSleeveFields) { + delete sleeve[field]; + } + } + } } } From 9c579e294a343e5f3a0fb5b2d2905411bcccd5f0 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 18 Aug 2022 13:41:58 -0400 Subject: [PATCH 2/2] allbuild commit 3067703c --- dist/main.bundle.js | 2 +- dist/main.bundle.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/main.bundle.js b/dist/main.bundle.js index 3850e745c..712d1b88d 100644 --- a/dist/main.bundle.js +++ b/dist/main.bundle.js @@ -1,4 +1,4 @@ -!function(t){function e(e){for(var a,o,s=e[0],l=e[1],c=e[2],u=0,m=[];un)throw x(t.workerScript,`Too many threads requested by ${t.function}. Requested: ${e}. Has: ${n}.`);return a},checkEnvFlags:function(t){const e=t.workerScript;if(e.env.stopFlag)throw new i.a(e);if(e.env.runningFn&&"asleep"!==t.function)throw e.errorMessage=x(e,`Concurrent calls to Netscript functions are not allowed!\n Did you forget to await hack(), grow(), or some other\n promise-returning function?\n Currently running: ${e.env.runningFn} tried to run: ${t.function}`),e.delayReject&&e.delayReject(new i.a(e)),new i.a(e)},checkSingularityAccess:function(t){if(4!==r.a.bitNodeN&&0===r.a.sourceFileLvl(4))throw L(t,"This singularity function requires Source-File 4 to run. A power up you obtain later in the game.\n It will be very obvious when and how you can obtain it.")},netscriptDelay:function(t,e){const n=t.workerScript;return new Promise((function(a,r){n.delay=window.setTimeout(()=>{n.delay=null,n.delayReject=void 0,n.env.runningFn="",n.env.stopFlag?r(new i.a(n)):a()},e),n.delayReject=r,n.env.runningFn=t.function}))},updateDynamicRam:function(t,e){const n=t.workerScript,a=t.function;if(n.dynamicLoadedFns[a])return;n.dynamicLoadedFns[a]=!0;let r=n.scriptRef.threads;"number"!=typeof r&&(console.warn(`WorkerScript detected NaN for threadcount for ${n.name} on ${n.hostname}`),r=1);n.dynamicRamUsage+=e,n.dynamicRamUsage>1.01*n.ramUsage&&(n.errorMessage=x(n,`Dynamic RAM usage calculated to be greater than initial RAM usage on fn: ${a}.\n This is probably because you somehow circumvented the static RAM calculation.\n\n Threads: ${r}\n Dynamic RAM Usage: ${s.a.formatRAM(n.dynamicRamUsage)}\n Static RAM Usage: ${s.a.formatRAM(n.ramUsage)}\n\n One of these could be the reason:\n * Using eval() to get a reference to a ns function\n   const myScan = eval('ns.scan');\n\n * Using map access to do the same\n   const myScan = ns['scan'];\n\n Sorry :(`))},city:function(t,e,n){if("string"!=typeof n)throw L(t,e+" should be a city name.");const a=n;if(!Object.values(l.a).includes(a))throw L(t,e+" should be a city name.");return a},getServer:O,scriptIdentifier:function(t,e,n,a){const r=t.workerScript;if(void 0===e)return r.pid;if("number"==typeof e)return e;if("string"==typeof e){const r=void 0===n?t.workerScript.hostname:_(t,"hostname",n),i=void 0===a?[]:C(t,a);return{scriptname:e,hostname:r,args:i}}throw new Error("not implemented")},hack:async function(t,e,n,{threads:a,stock:i}={}){const o=t.workerScript,l=S.resolveNetscriptRequestedThreads(t,a),g=O(t,e);if(!(g instanceof c.a))throw L(t,"Cannot be executed on this server.");const y=Object(f.d)(g,r.a),b=Object(u.b)(g,r.a);if(!b.res)throw L(t,b.msg||"");return A(t,()=>`Executing on '${g.hostname}' in ${Object(m.b)(1e3*y,!0)} (t=${s.a.formatThreads(l)})`),S.netscriptDelay(t,1e3*y).then((function(){const e=Object(f.b)(g,r.a),a=Math.random();let c=Object(f.c)(g,r.a)*l;const u=c/4;if(ag.moneyAvailable&&(m=g.moneyAvailable),g.moneyAvailable-=m,g.moneyAvailable<0&&(g.moneyAvailable=0);let y=m*h.a.ScriptHackMoneyGain;return n&&(y=m*h.a.ManualHackMoney),r.a.gainMoney(y,"hacking"),o.scriptRef.onlineMoneyMade+=y,r.a.scriptProdSinceLastAug+=y,o.scriptRef.recordHack(g.hostname,y,l),r.a.gainHackingExp(c),n&&r.a.gainIntelligenceExp(.005),o.scriptRef.onlineExpGained+=c,A(t,()=>`Successfully hacked '${g.hostname}' for ${s.a.formatMoney(y)} and ${s.a.formatExp(c)} exp (t=${s.a.formatThreads(l)})`),g.fortify(d.a.ServerFortifyAmount*Math.min(l,a)),i&&Object(p.c)(g,m),n&&(g.backdoorInstalled=!0),Promise.resolve(y)}return r.a.gainHackingExp(u),o.scriptRef.onlineExpGained+=u,A(t,()=>`Failed to hack '${g.hostname}'. Gained ${s.a.formatExp(u)} exp (t=${s.a.formatThreads(l)})`),Promise.resolve(0)}))},getValidPort:function(t,e){if(isNaN(e))throw L(t,`Invalid argument. Must be a port number between 1 and ${d.a.NumNetscriptPorts}, is ${e}`);if((e=Math.round(e))<1||e>d.a.NumNetscriptPorts)throw L(t,`Trying to use an invalid port: ${e}. Only ports 1-${d.a.NumNetscriptPorts} are valid.`);const n=g.a[e-1];if(null==n||!(n instanceof Object))throw L(t,`Could not find port: ${e}. This is a bug. Report to dev.`);return n},player:function(t,e){if(!M({hp:void 0,mults:void 0,numPeopleKilled:void 0,money:void 0,city:void 0,location:void 0,bitNodeN:void 0,totalPlaytime:void 0,playtimeSinceLastAug:void 0,playtimeSinceLastBitnode:void 0,jobs:void 0,factions:void 0,tor:void 0,inBladeburner:void 0,hasCorporation:void 0,entropy:void 0},e))throw L(t,"player should be a Player.");return e},server:function(t,e){if(!M(new c.a,e))throw L(t,"server should be a Server.");return e},gang:function(t,e){if(!M({respect:0,territory:0,wantedLevel:0},e))throw L(t,"gang should be a Gang.");return e},gangMember:function(t,e){if(!M(new y.a,e))throw L(t,"member should be a GangMember.");return e},gangTask:function(t,e){if(!M(new b.a("","",!1,!1,{}),e))throw L(t,"task should be a GangMemberTask.");return e},log:A,getFunctionNames:function t(e,n){const a=[];for(const[r,i]of Object.entries(e))"args"!==r&&("function"==typeof i?a.push(n+r):"object"==typeof i&&a.push(...t(i,r+".")));return a},getRunningScript:function(t,e){return"number"==typeof e?function(t){for(const e of Object(a.c)()){const n=Object(v.b)(t,e);if(n)return n}return null}(e):T(t,e.scriptname,e.hostname,e.args)},getRunningScriptByArgs:T,getCannotFindRunningScriptErrorMessage:function(t){return"number"==typeof t?"Cannot find running script with pid: "+t:`Cannot find running script ${t.scriptname} on server ${t.hostname} with args: ${Object(k.a)(t.args)}`},createPublicRunningScript:function(t){return{args:t.args.slice(),filename:t.filename,logs:t.logs.slice(),offlineExpGained:t.offlineExpGained,offlineMoneyMade:t.offlineMoneyMade,offlineRunningTime:t.offlineRunningTime,onlineExpGained:t.onlineExpGained,onlineMoneyMade:t.onlineMoneyMade,onlineRunningTime:t.onlineRunningTime,pid:t.pid,ramUsage:t.ramUsage,server:t.server,threads:t.threads}},failOnHacknetServer:function(t,e,n=""){return e instanceof w.a&&(t.workerScript.log(n,()=>"Does not work on Hacknet Servers"),!0)}};function _(t,e,n){if("string"==typeof n)return n;if("number"==typeof n)return n+"";throw L(t,`'${e}' should be a string.`)}function C(t,e){if(!function(t){return Array.isArray(t)&&t.every(t=>"string"==typeof t||"number"==typeof t||"boolean"==typeof t)}(e))throw L(t,"'args' is not an array of script args");return e}function x(t,e){for(const n of t.scriptRef.dependencies)e=e.replace(new RegExp(n.url,"g"),n.filename);return"|DELIMITER|"+t.hostname+"|DELIMITER|"+t.name+"|DELIMITER|"+e}function L(t,e){const n=(new Error).stack;if(void 0===n)throw new Error("how did we not throw an error?");const a=n.split("\n").slice(1),r=t.workerScript,i=t.function,o=r.getServer().scripts,s=[];for(const t of a){let e;for(const n of o){n.url&&t.includes(n.url)&&(e=n.filename);for(const a of n.dependencies)t.includes(a.url)&&(e=a.filename)}if(!e)continue;function l(t){const e=t.match(/.*:(\d+):\d+.*/),n=t.match(/.*at (.+) \(.*/);return e&&n?{line:e[1],func:n[1]}:null}let n={line:"-1",func:"unknown"};const a=l(t);function c(t){const e=t.match(/.*:(\d+):\d+$/),n=t.lastIndexOf("@");return e&&-1!==n?{line:e[1],func:t.slice(0,n)}:null}a&&(n=a);const r=c(t);r&&(n=r),s.push(`${e}:L${n.line}@${n.func}`)}r.log(i,()=>e);let f=`${i}: ${e}`;return 0!==s.length&&(f+="

Stack:
"+s.join("
")),x(r,f)}function O(t,e){const n=Object(a.d)(e);if(null==n){throw L(t,"Invalid hostname: "+(""===e?"'' (empty string)":"'"+e+"'"))}return n}function M(t,e){if("object"!=typeof e||null==e)return!1;const n=Object.keys(t),a=Object.keys(e);for(const t of n)if(!a.includes(t))return!1;return!0}function A(t,e){t.workerScript.log(t.functionPath,e)}function T(t,e,n,a){if(!Array.isArray(a))throw S.makeRuntimeRejectMsg(t.workerScript,`Invalid scriptArgs argument passed into getRunningScript() from ${t.function}(). This is probably a bug. Please report to game developer`);if(null!=e&&"string"==typeof e){null==n&&(n=t.workerScript.hostname);const r=S.getServer(t,n);return Object(v.a)(e,a,r)}return t.workerScript.scriptRef}},,function(t,e,n){"use strict";let a;n.d(e,"a",(function(){return a})),function(t){t.Illuminati="Illuminati",t.Daedalus="Daedalus",t.TheCovenant="The Covenant",t.ECorp="ECorp",t.MegaCorp="MegaCorp",t.BachmanAssociates="Bachman & Associates",t.BladeIndustries="Blade Industries",t.NWO="NWO",t.ClarkeIncorporated="Clarke Incorporated",t.OmniTekIncorporated="OmniTek Incorporated",t.FourSigma="Four Sigma",t.KuaiGongInternational="KuaiGong International",t.FulcrumSecretTechnologies="Fulcrum Secret Technologies",t.BitRunners="BitRunners",t.TheBlackHand="The Black Hand",t.NiteSec="NiteSec",t.Aevum="Aevum",t.Chongqing="Chongqing",t.Ishima="Ishima",t.NewTokyo="New Tokyo",t.Sector12="Sector-12",t.Volhaven="Volhaven",t.SpeakersForTheDead="Speakers for the Dead",t.TheDarkArmy="The Dark Army",t.TheSyndicate="The Syndicate",t.Silhouette="Silhouette",t.Tetrads="Tetrads",t.SlumSnakes="Slum Snakes",t.Netburners="Netburners",t.TianDiHui="Tian Di Hui",t.CyberSec="CyberSec",t.Bladeburners="Bladeburners",t.ChurchOfTheMachineGod="Church of the Machine God",t.ShadowsOfAnarchy="Shadows of Anarchy"}(a||(a={}))},function(t,e,n){"use strict";n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return l}));var a=n(177),r=n(346),i=n(420),o=n(126);const s={ActiveScriptsServerPageSize:10,ActiveScriptsScriptPageSize:10,AutosaveInterval:60,CodeInstructionRunTime:50,DisableASCIIArt:!1,DisableHotkeys:!1,DisableTextEffects:!1,DisableOverviewProgressBars:!1,EnableBashHotkeys:!1,TimestampsFormat:"",Locale:"en",MaxRecentScriptsCapacity:50,MaxLogCapacity:50,MaxPortCapacity:50,MaxTerminalCapacity:500,SaveGameOnFileSave:!0,SuppressBuyAugmentationConfirmation:!1,SuppressFactionInvites:!1,SuppressMessages:!1,SuppressTravelConfirmation:!1,SuppressBladeburnerPopup:!1,SuppressTIXPopup:!1,SuppressSavedGameToast:!1,SuppressAutosaveDisabledWarnings:!1,UseIEC60027_2:!1,ExcludeRunningScriptsFromSave:!1,IsSidebarOpened:!0,theme:r.a,styles:i.a,overview:{x:0,y:0,opened:!0},EditorTheme:o.a},l={ActiveScriptsServerPageSize:s.ActiveScriptsServerPageSize,ActiveScriptsScriptPageSize:s.ActiveScriptsScriptPageSize,AutosaveInterval:s.AutosaveInterval,CodeInstructionRunTime:25,DisableASCIIArt:s.DisableASCIIArt,DisableHotkeys:s.DisableHotkeys,DisableTextEffects:s.DisableTextEffects,DisableOverviewProgressBars:s.DisableOverviewProgressBars,EnableBashHotkeys:s.EnableBashHotkeys,TimestampsFormat:s.TimestampsFormat,Locale:"en",MaxRecentScriptsCapacity:s.MaxRecentScriptsCapacity,MaxLogCapacity:s.MaxLogCapacity,MaxPortCapacity:s.MaxPortCapacity,MaxTerminalCapacity:s.MaxTerminalCapacity,OwnedAugmentationsOrder:a.a.AcquirementTime,PurchaseAugmentationsOrder:a.b.Default,SaveGameOnFileSave:s.SaveGameOnFileSave,SuppressBuyAugmentationConfirmation:s.SuppressBuyAugmentationConfirmation,SuppressFactionInvites:s.SuppressFactionInvites,SuppressMessages:s.SuppressMessages,SuppressTravelConfirmation:s.SuppressTravelConfirmation,SuppressBladeburnerPopup:s.SuppressBladeburnerPopup,SuppressTIXPopup:s.SuppressTIXPopup,SuppressSavedGameToast:s.SuppressSavedGameToast,SuppressAutosaveDisabledWarnings:s.SuppressAutosaveDisabledWarnings,UseIEC60027_2:s.UseIEC60027_2,ExcludeRunningScriptsFromSave:s.ExcludeRunningScriptsFromSave,IsSidebarOpened:s.IsSidebarOpened,MonacoTheme:"monokai",MonacoInsertSpaces:!1,MonacoFontSize:20,MonacoVim:!1,MonacoWordWrap:"off",theme:{...r.a},styles:{...i.a},overview:s.overview,EditorTheme:{...o.a},init(){Object.assign(l,s)},load(t){const e=JSON.parse(t);Object.assign(l.theme,e.theme),delete e.theme,Object.assign(l.styles,e.styles),delete e.styles,Object.assign(l.overview,e.overview),delete e.overview,Object.assign(l.EditorTheme,e.EditorTheme),delete e.EditorTheme,Object.assign(l,e)}}},function(t,e,n){"use strict";n.d(e,"a",(function(){return f}));var a=n(189),r=n.n(a),i=(n(1572),n(1573),n(1574),n(1575),n(1576),n(1577),n(1578),n(1579),n(1580),n(1581),n(1582),n(1583),n(1584),n(1585),n(6));const o=[1e15,1e18,1e21,1e24,1e27,1e30],s=["q","Q","s","S","o","n"],l=1e9,c=2**30;const f=new class{constructor(){var t,e,n;n="en",(e="defaultLocale")in(t=this)?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,this.defaultLocale="en"}updateLocale(t){return null!=r.a.locale(t)||(console.warn("Invalid locale for numeral: "+t),r.a.locale(this.defaultLocale),!1)}format(t,e){Math.abs(t)<1e-6&&(t=0);const n=r()(t).format(e);return"NaN"===n?""+t:n}formatBigNumber(t){return this.format(t,"0.000a")}formatReallyBigNumber(t,e=3){const n=Math.abs(t);if(t===1/0)return"∞";for(let a=0;a