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

Strengthen checks to prevent missing workers #1128

Open
wants to merge 1 commit into
base: 1.3.12
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2710,7 +2710,7 @@ function fastLoop(){
if (total > global.resource[global.race.species].amount){
global.civic[job].workers -= total - global.resource[global.race.species].amount;
}
if (global.civic[job].workers < 0){
if (!global.civic[job].display || global.civic[job].workers < 0){
global.civic[job].workers = 0;
}
}
Expand Down Expand Up @@ -2749,7 +2749,7 @@ function fastLoop(){
}

Object.keys(job_desc).forEach(function (job){
if (job !== 'craftsman' && global.civic[job] && global.civic[job].workers < global.civic[job].assigned && global.civic[global.civic.d_job].workers > 0 && global.civic[job].workers < global.civic[job].max){
if (job !== 'craftsman' && global.civic[job] && global.civic[job].display && global.civic[job].workers < global.civic[job].assigned && global.civic[global.civic.d_job].workers > 0 && global.civic[job].workers < global.civic[job].max){
global.civic[job].workers++;
global.civic[global.civic.d_job].workers--;
}
Expand Down Expand Up @@ -9258,7 +9258,7 @@ function midLoop(){
if (global.civic[job].workers > global.civic[job].max && global.civic[job].max !== -1){
global.civic[job].workers = global.civic[job].max;
}
else if (global.civic[job].workers < 0){
else if (!global.civic[job].display || global.civic[job].workers < 0){
global.civic[job].workers = 0;
}

Expand Down Expand Up @@ -9714,6 +9714,7 @@ function midLoop(){

if (global.race['kindling_kindred'] || global.race['smoldering']){
global.civic.lumberjack.workers = 0;
global.civic.lumberjack.assigned = 0;
global.resource.Lumber.crates = 0;
global.resource.Lumber.containers = 0;
global.resource.Lumber.trade = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/races.js
Original file line number Diff line number Diff line change
Expand Up @@ -4822,6 +4822,7 @@ function purgeLumber(){
setPurgatory('tech','saw');
global.civic.lumberjack.display = false;
global.civic.lumberjack.workers = 0;
global.civic.lumberjack.assigned = 0;
if (global.civic.d_job === 'lumberjack') {
global.civic.d_job = global.race['carnivore'] || global.race['soul_eater'] ? 'hunter' : 'unemployed';
}
Expand Down Expand Up @@ -5010,6 +5011,7 @@ function adjustFood() {
}
global.civic[jobEnabled[0]].workers += global.civic[job].workers;
global.civic[job].workers = 0;
global.civic[job].assigned = 0;
global.civic[job].display = false;
}
});
Expand Down Expand Up @@ -5079,6 +5081,7 @@ export function cleanAddTrait(trait){
global.resource.Cement.display = false;
global.civic.cement_worker.display = false;
global.civic.cement_worker.workers = 0;
global.civic.cement_worker.assigned = 0;
setPurgatory('tech','cement');
setPurgatory('city','cement_plant');
break;
Expand All @@ -5088,6 +5091,7 @@ export function cleanAddTrait(trait){
}
global.civic.quarry_worker.display = false;
global.civic.quarry_worker.workers = 0;
global.civic.quarry_worker.assigned = 0;
setResourceName('Stone');
setPurgatory('tech','hammer');
setPurgatory('city','rock_quarry');
Expand Down
1 change: 1 addition & 0 deletions src/vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ if (convertVersion(global['version']) < 100023){
delete global.tech['axe']; delete global.tech['reclaimer']; delete global.tech['saw'];
global.civic.lumberjack.display = false;
global.civic.lumberjack.workers = 0;
global.civic.lumberjack.assigned = 0;
if (global.civic.d_job === 'lumberjack') { global.civic.d_job = 'unemployed'; }
if (global.race['casting']){
global.race.casting.total -= global.race.casting.lumberjack;
Expand Down