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

markup_text_boxst.unk_v50_2 vector contains entries similar to general_ref #569

Closed
Bumber64 opened this issue Feb 21, 2023 · 5 comments
Closed

Comments

@Bumber64
Copy link
Contributor

Bumber64 commented Feb 21, 2023

Some code I've reverse engineered starting at loc_14096F9A2 in v50.05:

int32_t unk_0 = -1;

if (string_D90 == "HF") //HISTORICAL_FIGURE
    unk_0 = 0;
if (string_D90 == "SITE")
    unk_0 = 1;
if (string_D90 == "ARTIFACT")
    unk_0 = 2;
if (string_D90 == "BOOK")
    unk_0 = 3;
if (string_D90 == "SR") //SUBREGION?
    unk_0 = 4;
if (string_D90 == "FL") //FEATURE_LAYER?
    unk_0 = 5;
if (string_D90 == "ENT") //ENTITY
    unk_0 = 6;
if (string_D90 == "AB") //ABSTRACT_BUILDING?
    unk_0 = 7;
if (string_D90 == "EPOP") //ENTITY_POP
    unk_0 = 8;
if (string_D90 == "ART_IMAGE")
    unk_0 = 9;
if (string_D90 == "ERA")
    unk_0 = 10;
if (string_D90 == "HEC")
    unk_0 = 11;

int32_t unk_4 = atoi(string_DB0);
int32_t unk_8 = -1;

if (unk_0 == 7 || unk_0 == 9)
{
    //some parsing
    unk_8 = atoi(string_D50);
}

if (unk_0 != -1)
{
    df::ref_thing *ptr = new df::ref_thing();
    ptr->unk_0 = unk_0;
    ptr->unk_4 = unk_4;
    ptr->unk_8 = unk_8;

    *world.status.unk_v50_1.unk_v50_2.push_back(ptr);
}

It looks similar to a general_ref. IDK if we're just misaligned, or it's a separate struct.

@ab9rf
Copy link
Member

ab9rf commented Feb 27, 2023

for reference, the corresponding location in v50.07-steam is 1409af072; the function begins at 14096e700

I don't understand what you mean when you say this structure "looks like" a general_refst. general_refst has no structure; this abstract base class has no data members, only a vtable pointer, and thus either looks like everything or like nothing.

Also my own analysis image has the structure I think you're talking about as (string, int16_t, int32_t, int32_t, int32_t, int32_t) although the first two int32_ts might instead be a pointer. This doesn't seem to me to match well with any of the general_refst subtypes, none of which contains a string member as far as I am aware.

@Bumber64
Copy link
Contributor Author

It ("ref_thing") looked like a general_ref in that the tokens here that define unk_0 are similar to the enum values of general_ref_type. Structurally it's closer to specific_ref, however unk_4 and unk_8 are ids instead pointers.

It's since been determined that this struct is likely used by hyperlinks in the markup_text_box. (See the issue that mentions this one.) I guess I'll close this issue and use the other one for research instead.

@ab9rf ab9rf reopened this Nov 19, 2023
@ab9rf
Copy link
Member

ab9rf commented Nov 19, 2023

i'm reopening this because we can get ground truth on this from the bay12 header dump and so we might as well do so

@Bumber64
Copy link
Contributor Author

Bumber64 commented Nov 21, 2023

Looks like there won't be any need for that. I just confirmed that these are refs to legends pages by messing around with the text_boxes found in the entries in gview.view.child.page via the gm-editor in legends mode. Changing unk_0 changes the text color and the page it links to (provided unk_4 is still a valid ref, otherwise clicking does nothing.)

The enum is similar to legend_pagest.T_mode, but doesn't quite line up (no MAIN or MAPS,) so we need to create a separate one like:

<enum-type type-name='legends_page_ref_type'>
    <enum-item name='NONE' value='-1'/>
    <enum-item name='HF'/> HFS
    <enum-item name='SITE'/> SITES
    <enum-item name='ARTIFACT'/> ARTIFACTS
    <enum-item name='BOOK'/> BOOKS
    <enum-item name='SR'/> SUBREGIONS
    <enum-item name='FL'/> FEATURE_LAYERS
    <enum-item name='ENT'/> ENTITIES
    <enum-item name='AB'/> ABS
    <enum-item name='EPOP'/> POPULATIONS
    <enum-item name='ART_IMAGE'/> ART
    <enum-item name='ERA'/>
    <enum-item name='HEC'/>
</enum-type>

<struct-type type-name='legends_page_ref'>
    <enum name='type' base-type='int32_t' type-name='legends_page_ref_type'/>
    <int32_t name='ref1' init-value='-1'/>
    <int32_t name='ref2' init-value='-1'/> only used when type is AB or ART_IMAGE
</struct-type>

@ab9rf
Copy link
Member

ab9rf commented Nov 21, 2023

i've found that enum in bay12 headers (it's MarkupTextLinkType)

and the structure is called markup_text_linkst

these are both defined in markup_text_box.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants