Last active
August 12, 2023 04:43
-
-
Save lethosor/fb748a008cc6714f51525789e775f6f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GLOBALS_DF = { | |
| "point" : "selection_rect", | |
| "menuposition" : "ui_menu_width", | |
| "itemmade" : "created_item_type", | |
| "itemmade_subtype" : "created_item_subtype", | |
| "itemmade_subcat1" : "created_item_mattype", | |
| "itemmade_subcat2" : "created_item_matindex", | |
| "itemmade_number" : "created_item_count", | |
| "mainview" : "map_renderer", | |
| "title2" : "title_spaced", | |
| "event_flow" : "flows", | |
| "plot_event" : "timed_events", | |
| "buildjob_type" : "ui_building_assign_type", | |
| "buildjob_selected" : "ui_building_assign_is_marked", | |
| "buildjob_unit" : "ui_building_assign_units", | |
| "buildjob_item" : "ui_building_assign_items", | |
| "looklist" : "ui_look_list", | |
| "year" : "cur_year", | |
| "season_count" : "cur_year_tick", | |
| "precise_phase" : "cur_year_tick_advmode", | |
| "season_timer" : "cur_season_tick", | |
| "season" : "cur_season", | |
| "cur_weather" : "current_weather", | |
| "assignbuildingjobs" : "process_jobs", | |
| "assigndesjobs" : "process_dig", | |
| "paused" : "pause_state", | |
| "modeunit" : "ui_selected_unit", | |
| "modeview" : "ui_unit_view_mode", | |
| "modepage" : "ui_look_cursor", | |
| "modeitem" : "ui_building_item_cursor", | |
| "addingtask" : "ui_workshop_in_add", | |
| "modejob" : "ui_workshop_job_cursor", | |
| "buildjob_assignroom" : "ui_building_in_assign", | |
| "buildjob_sizeroom" : "ui_building_in_resize", | |
| "addingtask_sub" : "ui_lever_target_type", | |
| "buildjob_sizerad" : "ui_building_resize_radius", | |
| "scrollx" : "window_x", | |
| "scrolly" : "window_y", | |
| "scrollz" : "window_z", | |
| "DEBUG_CONTINUOUS" : "debug_nopause", | |
| "DEBUG_NOMOOD" : "debug_nomoods", | |
| "DEBUG_SAFEDWARVES" : "debug_combat", | |
| "DEBUG_NOANIMALS" : "debug_wildlife", | |
| "DEBUG_NOTHIRST" : "debug_nodrink", | |
| "DEBUG_NOHUNGER" : "debug_noeat", | |
| "DEBUG_NOSLEEP" : "debug_nosleep", | |
| "DEBUG_VISIBLEAMBUSHERS" : "debug_showambush", | |
| "DEBUG_QUICKMODE_MINING" : "debug_fastmining", | |
| "DEBUG_NEVERBERSERK" : "debug_noberserk", | |
| "DEBUG_MEGAFAST" : "debug_turbospeed", | |
| "gamemode_cansave" : "save_on_exit", | |
| "standingorder_butcher" : "standing_orders_auto_butcher", | |
| "standingorder_collect_web" : "standing_orders_auto_collect_webs", | |
| "standingorder_fishery" : "standing_orders_auto_fishery", | |
| "standingorder_kiln" : "standing_orders_auto_kiln", | |
| "standingorder_kitchen" : "standing_orders_auto_kitchen", | |
| "standingorder_loom" : "standing_orders_auto_loom", | |
| "standingorder_other" : "standing_orders_auto_other", | |
| "standingorder_slaughter" : "standing_orders_auto_slaughter", | |
| "standingorder_smelter" : "standing_orders_auto_smelter", | |
| "standingorder_tan" : "standing_orders_auto_tan", | |
| "standingorder_gatherrefuse_chasm_bones" : "standing_orders_dump_bones", | |
| "standingorder_gatherrefuse_chasm_corpses" : "standing_orders_dump_corpses", | |
| "standingorder_gatherrefuse_chasm_strand_tissue" : "standing_orders_dump_hair", | |
| "standingorder_gatherrefuse_chasm_othernonmetal" : "standing_orders_dump_other", | |
| "standingorder_gatherrefuse_chasm_shell" : "standing_orders_dump_shells", | |
| "standingorder_gatherrefuse_chasm_skins" : "standing_orders_dump_skins", | |
| "standingorder_gatherrefuse_chasm_skulls" : "standing_orders_dump_skulls", | |
| "standingorder_allharvest" : "standing_orders_farmer_harvest", | |
| "standingorder_autoforbid_other_items" : "standing_orders_forbid_other_dead_items", | |
| "standingorder_autoforbid_other_corpse" : "standing_orders_forbid_other_nohunt", | |
| "standingorder_autoforbid_your_corpse" : "standing_orders_forbid_own_dead", | |
| "standingorder_autoforbid_your_items" : "standing_orders_forbid_own_dead_items", | |
| "standingorder_autoforbid_projectile" : "standing_orders_forbid_used_ammo", | |
| "standingorder_gatheranimals" : "standing_orders_gather_animals", | |
| "standingorder_gatherbodies" : "standing_orders_gather_bodies", | |
| "standingorder_gatherfood" : "standing_orders_gather_food", | |
| "standingorder_gatherfurniture" : "standing_orders_gather_furniture", | |
| "standingorder_gatherstone" : "standing_orders_gather_minerals", | |
| "standingorder_gatherrefuse" : "standing_orders_gather_refuse", | |
| "standingorder_gatherrefuse_outside" : "standing_orders_gather_refuse_outside", | |
| "standingorder_gatherrefuse_outside_vermin" : "standing_orders_gather_vermin_remains", | |
| "standingorder_gatherwood" : "standing_orders_gather_wood", | |
| "standingorder_mixfoods" : "standing_orders_mix_food", | |
| "standingorder_dyed_clothes" : "standing_orders_use_dyed_cloth", | |
| "standingorder_zone_drinking" : "standing_orders_zoneonly_drink", | |
| "standingorder_zone_fishing" : "standing_orders_zoneonly_fish", | |
| "option_exceptions" : "standing_orders_job_cancel_announce", | |
| "next_art_imagechunk_global_id" : "art_image_chunk_next_id", | |
| "next_civ_global_id" : "entity_next_id", | |
| "next_histeventcol_global_id" : "hist_event_collection_next_id", | |
| "next_histevent_global_id" : "hist_event_next_id", | |
| "next_histfig_global_id" : "hist_figure_next_id", | |
| "next_nem_global_id" : "nemesis_next_id", | |
| "next_unitchunk_global_id" : "unit_chunk_next_id", | |
| } | |
| GLOBALS = { | |
| "activity_next_id" : "next_activity_global_id", | |
| "job_next_id" : "next_job_global_id", | |
| "ui_look_cursor" : "modepage", | |
| "standing_orders_auto_butcher" : "standingorder_butcher", | |
| "occupation_next_id" : "next_occupation_global_id", | |
| "window_x" : "scrollx", | |
| "identity_next_id" : "next_identity_global_id", | |
| "standing_orders_auto_smelter" : "standingorder_smelter", | |
| "debug_fastmining" : "DEBUG_QUICKMODE_MINING", | |
| "standing_orders_gather_bodies" : "standingorder_gatherbodies", | |
| "ui_building_assign_is_marked" : "buildjob_selected", | |
| "cultural_identity_next_id" : "next_cultural_identity_global_id", | |
| "standing_orders_job_cancel_announce" : "option_exceptions", | |
| "standing_orders_dump_hair" : "standingorder_gatherrefuse_chasm_strand_tissue", | |
| "selection_rect" : "point", | |
| "standing_orders_gather_animals" : "standingorder_gatheranimals", | |
| "standing_orders_gather_food" : "standingorder_gatherfood", | |
| "debug_wildlife" : "DEBUG_NOANIMALS", | |
| "ui_selected_unit" : "modeunit", | |
| "ui_lever_target_type" : "addingtask_sub", | |
| "poetic_form_next_id" : "next_poetic_form_global_id", | |
| "standing_orders_auto_collect_webs" : "standingorder_collect_web", | |
| "army_controller_next_id" : "next_army_controller_global_id", | |
| "cur_year_tick_advmode" : "precise_phase", | |
| "standing_orders_zoneonly_drink" : "standingorder_zone_drinking", | |
| "army_next_id" : "next_army_global_id", | |
| "standing_orders_dump_skins" : "standingorder_gatherrefuse_chasm_skins", | |
| "cur_season_tick" : "season_timer", | |
| "created_item_mattype" : "itemmade_subcat1", | |
| "ui_building_assign_units" : "buildjob_unit", | |
| "vehicle_next_id" : "next_vehicle_global_id", | |
| "created_item_matindex" : "itemmade_subcat2", | |
| "process_jobs" : "assignbuildingjobs", | |
| "debug_combat" : "DEBUG_SAFEDWARVES", | |
| "pause_state" : "paused", | |
| "standing_orders_forbid_other_nohunt" : "standingorder_autoforbid_other_corpse", | |
| "save_on_exit" : "gamemode_cansave", | |
| "artifact_next_id" : "next_artifact_global_id", | |
| "ui_building_in_assign" : "buildjob_assignroom", | |
| "standing_orders_auto_kitchen" : "standingorder_kitchen", | |
| "cur_season" : "season", | |
| "standing_orders_dump_corpses" : "standingorder_gatherrefuse_chasm_corpses", | |
| "crime_next_id" : "next_crime_global_id", | |
| "standing_orders_mix_food" : "standingorder_mixfoods", | |
| "flows" : "event_flow", | |
| "rhythm_next_id" : "next_rhythm_global_id", | |
| "ui_building_resize_radius" : "buildjob_sizerad", | |
| "written_content_next_id" : "next_written_content_global_id", | |
| "ui_workshop_job_cursor" : "modejob", | |
| "hist_event_collection_next_id" : "next_histeventcol_global_id", | |
| "standing_orders_gather_refuse" : "standingorder_gatherrefuse", | |
| "debug_turbospeed" : "DEBUG_MEGAFAST", | |
| "ui_building_assign_items" : "buildjob_item", | |
| "debug_noberserk" : "DEBUG_NEVERBERSERK", | |
| "formation_next_id" : "next_formation_global_id", | |
| "debug_nosleep" : "DEBUG_NOSLEEP", | |
| "standing_orders_gather_minerals" : "standingorder_gatherstone", | |
| "debug_showambush" : "DEBUG_VISIBLEAMBUSHERS", | |
| "debug_nodrink" : "DEBUG_NOTHIRST", | |
| "debug_nomoods" : "DEBUG_NOMOOD", | |
| "standing_orders_auto_fishery" : "standingorder_fishery", | |
| "standing_orders_forbid_own_dead_items" : "standingorder_autoforbid_your_items", | |
| "army_tracking_info_next_id" : "next_army_tracking_info_global_id", | |
| "belief_system_next_id" : "next_belief_system_global_id", | |
| "dance_form_next_id" : "next_dance_form_global_id", | |
| "musical_form_next_id" : "next_musical_form_global_id", | |
| "window_z" : "scrollz", | |
| "incident_next_id" : "next_incident_global_id", | |
| "interaction_instance_next_id" : "next_interaction_instance_global_id", | |
| "building_next_id" : "next_building_global_id", | |
| "squad_next_id" : "next_squad_global_id", | |
| "created_item_type" : "itemmade", | |
| "task_next_id" : "next_task_global_id", | |
| "ui_workshop_in_add" : "addingtask", | |
| "art_image_chunk_next_id" : "next_art_imagechunk_global_id", | |
| "standing_orders_farmer_harvest" : "standingorder_allharvest", | |
| "hist_event_next_id" : "next_histevent_global_id", | |
| "hist_figure_next_id" : "next_histfig_global_id", | |
| "flow_guide_next_id" : "next_flow_guide_global_id", | |
| "machine_next_id" : "next_machine_global_id", | |
| "proj_next_id" : "next_proj_global_id", | |
| "schedule_next_id" : "next_schedule_global_id", | |
| "nemesis_next_id" : "next_nem_global_id", | |
| "standing_orders_use_dyed_cloth" : "standingorder_dyed_clothes", | |
| "timed_events" : "plot_event", | |
| "entity_next_id" : "next_civ_global_id", | |
| "soul_next_id" : "next_soul_global_id", | |
| "standing_orders_auto_tan" : "standingorder_tan", | |
| "standing_orders_forbid_used_ammo" : "standingorder_autoforbid_projectile", | |
| "process_dig" : "assigndesjobs", | |
| "item_next_id" : "next_item_global_id", | |
| "standing_orders_auto_other" : "standingorder_other", | |
| "standing_orders_forbid_other_dead_items" : "standingorder_autoforbid_other_items", | |
| "ui_look_list" : "looklist", | |
| "ui_building_in_resize" : "buildjob_sizeroom", | |
| "cur_year_tick" : "season_count", | |
| "map_renderer" : "mainview", | |
| "created_item_count" : "itemmade_number", | |
| "created_item_subtype" : "itemmade_subtype", | |
| "agreement_next_id" : "next_agreement_global_id", | |
| "ui_building_item_cursor" : "modeitem", | |
| "standing_orders_auto_kiln" : "standingorder_kiln", | |
| "standing_orders_gather_wood" : "standingorder_gatherwood", | |
| "standing_orders_auto_slaughter" : "standingorder_slaughter", | |
| "standing_orders_forbid_own_dead" : "standingorder_autoforbid_your_corpse", | |
| "unit_next_id" : "next_unit_global_id", | |
| "standing_orders_dump_other" : "standingorder_gatherrefuse_chasm_othernonmetal", | |
| "standing_orders_dump_skulls" : "standingorder_gatherrefuse_chasm_skulls", | |
| "standing_orders_gather_vermin_remains" : "standingorder_gatherrefuse_outside_vermin", | |
| "current_weather" : "cur_weather", | |
| "standing_orders_zoneonly_fish" : "standingorder_zone_fishing", | |
| "window_y" : "scrolly", | |
| "standing_orders_auto_loom" : "standingorder_loom", | |
| "standing_orders_gather_furniture" : "standingorder_gatherfurniture", | |
| "standing_orders_gather_refuse_outside" : "standingorder_gatherrefuse_outside", | |
| "cur_year" : "year", | |
| "ui_unit_view_mode" : "modeview", | |
| "ui_menu_width" : "menuposition", | |
| "debug_nopause" : "DEBUG_CONTINUOUS", | |
| "scale_next_id" : "next_scale_global_id", | |
| "debug_noeat" : "DEBUG_NOHUNGER", | |
| "standing_orders_dump_shells" : "standingorder_gatherrefuse_chasm_shell", | |
| "standing_orders_dump_bones" : "standingorder_gatherrefuse_chasm_bones", | |
| "unit_chunk_next_id" : "next_unitchunk_global_id", | |
| "ui_building_assign_type" : "buildjob_type", | |
| } | |
| # GLOBALS = {v: k for k, v in GLOBALS_DF.items()} | |
| # assert len(GLOBALS) == len(GLOBALS_DF) | |
| import re | |
| with open('df.globals.xml') as f: | |
| content = f.read() | |
| def fail(msg, match): | |
| lineno = content[:match.start()].count('\n') | |
| raise RuntimeError(f'line {lineno}: {msg}: {match.group(0)!r}') | |
| def replace_tag(tag_match): | |
| def replace_name(name_match): | |
| quote = name_match.group(1) | |
| name = name_match.group(2) | |
| suffix = '' | |
| if name in GLOBALS: | |
| suffix = f' original-name={quote}{GLOBALS[name]}{quote}' | |
| else: | |
| print('skipping (no rename):', name) | |
| return name_match.group(0) + suffix | |
| return re.sub(r'\sname=([\'"])(.+?)\1', replace_name, tag_match.group(0)) | |
| new_content = re.sub('<global-object.+?>', replace_tag, content, flags=re.DOTALL) | |
| with open('df.globals2.xml', 'w') as f: | |
| f.write(new_content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local flagged = {} | |
| for df_name, df_entry in pairs(require('memscan').read_global_table()) do | |
| local df_address = df.reinterpret_cast('uintptr_t', df_entry:_field('address'))[0] | |
| local found = false | |
| for dfhack_name in pairs(df.global) do | |
| if dfhack.internal.getAddress(dfhack_name) == df_address and df_name ~= dfhack_name then | |
| print((' "%s" : "%s",'):format(dfhack_name, df_name)) | |
| found = true | |
| end | |
| end | |
| if not found and df_name:find('next_.*_global_id') then | |
| table.insert(flagged, df_name) | |
| end | |
| end | |
| for _, name in pairs(flagged) do | |
| dfhack.printerr('missing:', name) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment