diff --git a/library/include/df/custom/job_handler.methods.inc b/library/include/df/custom/job_handler.methods.inc new file mode 100644 index 000000000..c160f5470 --- /dev/null +++ b/library/include/df/custom/job_handler.methods.inc @@ -0,0 +1 @@ +friend struct df::world; diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 759e3acd4..e3d8e1d69 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -138,7 +138,7 @@ void buildings_onUpdate(color_ostream &out) { buildings_do_onupdate = false; - df::job_list_link *link = world->job_list.next; + df::job_list_link *link = world->jobs.list.next; for (; link; link = link->next) { df::job *job = link->item; diff --git a/library/modules/Designations.cpp b/library/modules/Designations.cpp index 3fb325096..1d41cfb49 100644 --- a/library/modules/Designations.cpp +++ b/library/modules/Designations.cpp @@ -66,7 +66,7 @@ bool Designations::isPlantMarked(const df::plant *plant) if (block->designation[des_pos.x % 16][des_pos.y % 16].bits.dig == tile_dig_designation::Default) return true; - for (auto *link = world->job_list.next; link; link = link->next) + for (auto *link = world->jobs.list.next; link; link = link->next) { df::job *job = link->item; if (!job) @@ -128,7 +128,7 @@ bool Designations::unmarkPlant(const df::plant *plant) block->designation[des_pos.x % 16][des_pos.y % 16].bits.dig = tile_dig_designation::No; block->flags.bits.designated = true; - auto *link = world->job_list.next; + auto *link = world->jobs.list.next; while (link) { auto *next = link->next; diff --git a/library/modules/EventManager.cpp b/library/modules/EventManager.cpp index e2baf9bfb..8ce2c97f4 100644 --- a/library/modules/EventManager.cpp +++ b/library/modules/EventManager.cpp @@ -381,7 +381,7 @@ static void manageJobInitiatedEvent(color_ostream& out) { } multimap copy(handlers[EventType::JOB_INITIATED].begin(), handlers[EventType::JOB_INITIATED].end()); - for ( df::job_list_link* link = &df::global::world->job_list; link != NULL; link = link->next ) { + for ( df::job_list_link* link = &df::global::world->jobs.list; link != NULL; link = link->next ) { if ( link->item == NULL ) continue; if ( link->item->id <= lastJobId ) @@ -411,7 +411,7 @@ static void manageJobCompletedEvent(color_ostream& out) { multimap copy(handlers[EventType::JOB_COMPLETED].begin(), handlers[EventType::JOB_COMPLETED].end()); map nowJobs; - for ( df::job_list_link* link = &df::global::world->job_list; link != NULL; link = link->next ) { + for ( df::job_list_link* link = &df::global::world->jobs.list; link != NULL; link = link->next ) { if ( link->item == NULL ) continue; nowJobs[link->item->id] = link->item; diff --git a/library/modules/Job.cpp b/library/modules/Job.cpp index 3f12ea2c2..132dcfc4b 100644 --- a/library/modules/Job.cpp +++ b/library/modules/Job.cpp @@ -490,10 +490,10 @@ bool DFHack::Job::linkIntoWorld(df::job *job, bool new_id) job->list_link = new df::job_list_link(); job->list_link->item = job; - linked_list_append(&world->job_list, job->list_link); + linked_list_append(&world->jobs.list, job->list_link); return true; } else { - df::job_list_link *ins_pos = &world->job_list; + df::job_list_link *ins_pos = &world->jobs.list; while (ins_pos->next && ins_pos->next->item->id < job->id) ins_pos = ins_pos->next; @@ -514,15 +514,15 @@ bool DFHack::Job::removePostings(df::job *job, bool remove_all) bool removed = false; if (!remove_all) { - if (job->posting_index >= 0 && job->posting_index < world->job_postings.size()) + if (job->posting_index >= 0 && job->posting_index < world->jobs.postings.size()) { - world->job_postings[job->posting_index]->flags.bits.dead = true; + world->jobs.postings[job->posting_index]->flags.bits.dead = true; removed = true; } } else { - for (auto it = world->job_postings.begin(); it != world->job_postings.end(); ++it) + for (auto it = world->jobs.postings.begin(); it != world->jobs.postings.end(); ++it) { if ((**it).job == job) { @@ -553,7 +553,7 @@ bool DFHack::Job::listNewlyCreated(std::vector *pvec, int *id_var) pvec->reserve(std::min(20,cur_id - old_id)); - df::job_list_link *link = world->job_list.next; + df::job_list_link *link = world->jobs.list.next; for (; link; link = link->next) { int id = link->item->id; diff --git a/library/xml b/library/xml index 860a9041a..fd6e70de5 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 860a9041a75305609643d465123a4b598140dd7f +Subproject commit fd6e70de5047a48b163ced482c8a925b6a021891 diff --git a/plugins/digFlood.cpp b/plugins/digFlood.cpp index 6668f9994..ada6213a6 100644 --- a/plugins/digFlood.cpp +++ b/plugins/digFlood.cpp @@ -89,7 +89,7 @@ void onDig(color_ostream& out, void* ptr) { return; set jobLocations; - for ( df::job_list_link* link = &world->job_list; link != NULL; link = link->next ) { + for ( df::job_list_link* link = &world->jobs.list; link != NULL; link = link->next ) { if ( link->item == NULL ) continue; diff --git a/plugins/diggingInvaders/diggingInvaders.cpp b/plugins/diggingInvaders/diggingInvaders.cpp index 4892c5e1d..9bbc5191e 100644 --- a/plugins/diggingInvaders/diggingInvaders.cpp +++ b/plugins/diggingInvaders/diggingInvaders.cpp @@ -598,7 +598,7 @@ void findAndAssignInvasionJob(color_ostream& out, void* tickTime) { lastInvasionDigger = firstInvader->id; lastInvasionJob = firstInvader->job.current_job ? firstInvader->job.current_job->id : -1; invaderJobs.erase(lastInvasionJob); - for ( df::job_list_link* link = &world->job_list; link != NULL; link = link->next ) { + for ( df::job_list_link* link = &world->jobs.list; link != NULL; link = link->next ) { if ( link->item == NULL ) continue; df::job* job = link->item; diff --git a/plugins/labormanager/labormanager.cpp b/plugins/labormanager/labormanager.cpp index 1a5323d8a..3a026d1ea 100644 --- a/plugins/labormanager/labormanager.cpp +++ b/plugins/labormanager/labormanager.cpp @@ -1155,7 +1155,7 @@ private: void collect_job_list() { - for (df::job_list_link* jll = world->job_list.next; jll; jll = jll->next) + for (df::job_list_link* jll = world->jobs.list.next; jll; jll = jll->next) { df::job* j = jll->item; if (!j) @@ -1163,7 +1163,7 @@ private: process_job(j); } - for (auto jp = world->job_postings.begin(); jp != world->job_postings.end(); jp++) + for (auto jp = world->jobs.postings.begin(); jp != world->jobs.postings.end(); jp++) { if ((*jp)->flags.bits.dead) continue; diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index a07668778..b543a2ab3 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1127,9 +1127,9 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N } } #if DF_VERSION_INT > 34011 - for (int i = 0; i < world->job_postings.size(); i++) + for (int i = 0; i < world->jobs.postings.size(); i++) { - auto job = world->job_postings[i]->job; + auto job = world->jobs.postings[i]->job; if (job == nullptr) continue; if ( @@ -1616,7 +1616,7 @@ static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in, send_style->set_style((HairStyle)unit->appearance.tissue_style[j]); } } - + for (int j = 0; j < unit->inventory.size(); j++) { auto inventory_item = unit->inventory[j]; @@ -2738,7 +2738,7 @@ static command_result SendDigCommand(color_ostream &stream, const DigCommand *in #if DF_VERSION_INT >= 43005 //remove and job postings related. - for (df::job_list_link * listing = &(world->job_list); listing != NULL; listing = listing->next) + for (df::job_list_link * listing = &(world->jobs.list); listing != NULL; listing = listing->next) { if (listing->item == NULL) continue; diff --git a/plugins/ruby/job.rb b/plugins/ruby/job.rb index e489dcc91..bf033fbb3 100644 --- a/plugins/ruby/job.rb +++ b/plugins/ruby/job.rb @@ -1,9 +1,9 @@ module DFHack class << self # link a job to the world - # allocate & set job.id, allocate a JobListLink, link to job & world.job_list + # allocate & set job.id, allocate a JobListLink, link to job & world.jobs.list def job_link(job) - lastjob = world.job_list + lastjob = world.jobs.list lastjob = lastjob.next while lastjob.next joblink = JobListLink.cpp_new joblink.prev = lastjob diff --git a/plugins/ruby/map.rb b/plugins/ruby/map.rb index f6f69de75..5c6295946 100644 --- a/plugins/ruby/map.rb +++ b/plugins/ruby/map.rb @@ -269,7 +269,7 @@ module DFHack def dig(mode=:Default) if mode == :Smooth if (tilemat == :STONE or tilemat == :MINERAL) and caption !~ /smooth|pillar|fortification/i and # XXX caption.. - designation.smooth == 0 and (designation.hidden or not df.world.job_list.find { |j| + designation.smooth == 0 and (designation.hidden or not df.world.jobs.list.find { |j| # the game removes 'smooth' designation as soon as it assigns a job, if we # re-set it the game may queue another :DetailWall that will carve a fortification (j.job_type == :DetailWall or j.job_type == :DetailFloor) and df.same_pos?(j, self) @@ -279,7 +279,7 @@ module DFHack mapblock.flags.designated = true end else - return if mode != :No and designation.dig == :No and not designation.hidden and df.world.job_list.find { |j| + return if mode != :No and designation.dig == :No and not designation.hidden and df.world.jobs.list.find { |j| # someone already enroute to dig here, avoid 'Inappropriate dig square' spam JobType::Type[j.job_type] == :Digging and df.same_pos?(j, self) } diff --git a/plugins/showmood.cpp b/plugins/showmood.cpp index 05e9a67ad..d2ae73f08 100644 --- a/plugins/showmood.cpp +++ b/plugins/showmood.cpp @@ -43,7 +43,7 @@ command_result df_showmood (color_ostream &out, vector & parameters) CoreSuspender suspend; bool found = false; - for (df::job_list_link *cur = world->job_list.next; cur != NULL; cur = cur->next) + for (df::job_list_link *cur = world->jobs.list.next; cur != NULL; cur = cur->next) { df::job *job = cur->item; if ((job->job_type < job_type::StrangeMoodCrafter) || (job->job_type > job_type::StrangeMoodMechanics)) diff --git a/plugins/stockflow.cpp b/plugins/stockflow.cpp index ff87bdddc..7cfc8ce0d 100644 --- a/plugins/stockflow.cpp +++ b/plugins/stockflow.cpp @@ -69,7 +69,7 @@ public: } else { // Gather orders when the bookkeeper starts updating stockpile records, // and enqueue them when the job is done. - for (df::job_list_link* link = &world->job_list; link != NULL; link = link->next) { + for (df::job_list_link* link = &world->jobs.list; link != NULL; link = link->next) { if (link->item == NULL) continue; if (link->item->job_type == job_type::UpdateStockpileRecords) { found = true; diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index f8f9e8231..cc3ac8cd7 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -429,15 +429,15 @@ public: static int fix_job_postings (color_ostream *out, bool dry_run) { int count = 0; - df::job_list_link *link = &world->job_list; + df::job_list_link *link = &world->jobs.list; while (link) { df::job *job = link->item; if (job) { - for (size_t i = 0; i < world->job_postings.size(); ++i) + for (size_t i = 0; i < world->jobs.postings.size(); ++i) { - df::world::T_job_postings *posting = world->job_postings[i]; + df::job_handler::T_postings *posting = world->jobs.postings[i]; if (posting->job == job && i != job->posting_index && !posting->flags.bits.dead) { ++count; @@ -673,7 +673,7 @@ static void check_lost_jobs(color_ostream &out, int ticks) ProtectedJob::cur_tick_idx++; if (ticks < 0) ticks = 0; - df::job_list_link *p = world->job_list.next; + df::job_list_link *p = world->jobs.list.next; for (; p; p = p->next) { df::job *job = p->item; @@ -707,7 +707,7 @@ static void check_lost_jobs(color_ostream &out, int ticks) static void update_job_data(color_ostream &out) { - df::job_list_link *p = world->job_list.next; + df::job_list_link *p = world->jobs.list.next; for (; p; p = p->next) { ProtectedJob *pj = get_known(p->item->id);