Forums WoW Modding Support Archives WoWModding Support Archives [DiscordArchive] ```cpp

[DiscordArchive] ```cpp

[DiscordArchive] ```cpp

rektbyfaith
Administrator
0
10-16-2022, 08:28 PM
#1
Archived author: Azarchius • Posted: 2023-08-06T18:42:18.029000+00:00
Original source

```cpp

// POC - foreign key lookup

auto sub_377BE0 = reinterpret_cast<struct_376E90 * (__fastcall*)(struct_376E90 * a1, struct_376E90 * a2)>(Storage::baseAddr + 0x377BE0);

auto get_foreign_record = *reinterpret_cast<DBRecord * (__fastcall**)(uintptr_t, struct_376E90*)>(*(uintptr_t*)sDBMgr->p_LightDataDB->field_98 + 0x28);
auto sub_0x98_0x38 = *reinterpret_cast<DBRecord * (__fastcall**)(uintptr_t, struct_376E90*)>(*(uintptr_t*)sDBMgr->p_LightDataDB->field_98 + 0x38);
// foreign key lookup end


....

// get LightData rows of param
struct_376E90 lookup_query;
struct_376E90 lookup_result_chain;

lookup_query.result_index = -1;
lookup_query.qword8 = (uintptr_t)&lookup_query.qword20;
lookup_query.WoWDB_field_98 = sDBMgr->p_LightDataDB->field_98;
lookup_query.lookup_key = param.second;
lookup_query.someCounter = 0;
lookup_query.qword18 = 0x8000000000000400ui64;
lookup_query.lookup_key_again = param.second;
sub_377BE0(&lookup_query, &lookup_result_chain);
while (true)
{
DBRecord* some_record = get_foreign_record(lookup_result_chain.WoWDB_field_98, &lookup_result_chain);
sub_0x98_0x38(lookup_result_chain.WoWDB_field_98, &lookup_result_chain);

if (!some_record)
break;

if (lookup_result_chain.result_index == -1)
break;

Utils::hexprint("some_record", some_record);
printf("id?: %i\n", lookup_result_chain.result_index);
}```

I have managed to stitch together some code that somehow manages to lookup `LightData.db2` records using `LightParamId`

The problem: I have no idea how this works? Does anyone know? How in the world does it know which foreign key to look for?
rektbyfaith
10-16-2022, 08:28 PM #1

Archived author: Azarchius • Posted: 2023-08-06T18:42:18.029000+00:00
Original source

```cpp

// POC - foreign key lookup

auto sub_377BE0 = reinterpret_cast<struct_376E90 * (__fastcall*)(struct_376E90 * a1, struct_376E90 * a2)>(Storage::baseAddr + 0x377BE0);

auto get_foreign_record = *reinterpret_cast<DBRecord * (__fastcall**)(uintptr_t, struct_376E90*)>(*(uintptr_t*)sDBMgr->p_LightDataDB->field_98 + 0x28);
auto sub_0x98_0x38 = *reinterpret_cast<DBRecord * (__fastcall**)(uintptr_t, struct_376E90*)>(*(uintptr_t*)sDBMgr->p_LightDataDB->field_98 + 0x38);
// foreign key lookup end


....

// get LightData rows of param
struct_376E90 lookup_query;
struct_376E90 lookup_result_chain;

lookup_query.result_index = -1;
lookup_query.qword8 = (uintptr_t)&lookup_query.qword20;
lookup_query.WoWDB_field_98 = sDBMgr->p_LightDataDB->field_98;
lookup_query.lookup_key = param.second;
lookup_query.someCounter = 0;
lookup_query.qword18 = 0x8000000000000400ui64;
lookup_query.lookup_key_again = param.second;
sub_377BE0(&lookup_query, &lookup_result_chain);
while (true)
{
DBRecord* some_record = get_foreign_record(lookup_result_chain.WoWDB_field_98, &lookup_result_chain);
sub_0x98_0x38(lookup_result_chain.WoWDB_field_98, &lookup_result_chain);

if (!some_record)
break;

if (lookup_result_chain.result_index == -1)
break;

Utils::hexprint("some_record", some_record);
printf("id?: %i\n", lookup_result_chain.result_index);
}```

I have managed to stitch together some code that somehow manages to lookup `LightData.db2` records using `LightParamId`

The problem: I have no idea how this works? Does anyone know? How in the world does it know which foreign key to look for?

rektbyfaith
Administrator
0
10-16-2022, 11:06 PM
#2
Archived author: Valaryon • Posted: 2022-10-16T23:06:44.613000+00:00
Original source

Vlad is completely right here. I made the comparison to Archerax yesterday. "..basically - with retroports you're hiring someone's services. Think of it like repairing a car. You own the car, but you're paying someone with the knowledge of the car to modify it to your specifications. It's the same for retroports. There are resources on how to do it yourself in the wowdev.wiki, the same way there's books if you want to repair your own car - but people pay for convenience and so they can put their personal time elsewhere."
rektbyfaith
10-16-2022, 11:06 PM #2

Archived author: Valaryon • Posted: 2022-10-16T23:06:44.613000+00:00
Original source

Vlad is completely right here. I made the comparison to Archerax yesterday. "..basically - with retroports you're hiring someone's services. Think of it like repairing a car. You own the car, but you're paying someone with the knowledge of the car to modify it to your specifications. It's the same for retroports. There are resources on how to do it yourself in the wowdev.wiki, the same way there's books if you want to repair your own car - but people pay for convenience and so they can put their personal time elsewhere."

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)