[CardTitles] Refactored CardTitle code.
This commit is contained in:
parent
f6b855e3c1
commit
e55f807003
@ -61,103 +61,81 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(naked) CardTitles::LocalizationSkipHookStub()
|
const char* CardTitles::TableLookupByRowHook(Game::Operand* operand, tablelookuprequest_s* request)
|
||||||
{
|
{
|
||||||
__asm
|
std::uint8_t prefix = (request->tableRow >> (8 * 3)) & 0xFF;
|
||||||
{
|
std::uint8_t data = (request->tableRow >> (8 * 2)) & 0xFF;
|
||||||
cmp byte ptr[edi + 01h], 0FFh; // Check if skip prefix exists (edi + 0x00 = @)
|
const char* title = nullptr;
|
||||||
jne back;
|
|
||||||
add edi, 2; // Ignore the 0x40 and 0xFF prefix (Localize and Skip prefix)
|
|
||||||
jmp jumpback;
|
|
||||||
|
|
||||||
back:
|
if (request->tablename == "mp/cardTitleTable.csv"s)
|
||||||
add edi, 1;
|
|
||||||
push edi;
|
|
||||||
|
|
||||||
mov eax, 4F1700h;
|
|
||||||
call eax;
|
|
||||||
|
|
||||||
add esp, 4;
|
|
||||||
mov edi, eax;
|
|
||||||
|
|
||||||
jumpback:
|
|
||||||
push 63A2E3h;
|
|
||||||
retn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void __declspec(naked) CardTitles::TableLookupByRowHookStub()
|
|
||||||
{
|
|
||||||
static tablelookuprequest_s* currentLookupRequest;
|
|
||||||
static tablelookupresult_s* currentLookupResult;
|
|
||||||
static std::int32_t prefix;
|
|
||||||
static std::int32_t data;
|
|
||||||
static const char* title;
|
|
||||||
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
mov currentLookupRequest, esi;
|
|
||||||
mov currentLookupResult, ebx;
|
|
||||||
}
|
|
||||||
|
|
||||||
prefix = (currentLookupRequest->tableRow >> (8 * 3)) & 0xff;
|
|
||||||
data = (currentLookupRequest->tableRow >> (8 * 2)) & 0xff;
|
|
||||||
|
|
||||||
//So we don't accidentally mess up other tables that might have a ridiculous amount of rows. Who knows.
|
|
||||||
if (!strcmp(currentLookupRequest->tablename, "mp/cardTitleTable.csv"))
|
|
||||||
{
|
{
|
||||||
if (prefix != 0x00)
|
if (prefix != 0x00)
|
||||||
{
|
{
|
||||||
// Column 1 = CardTitle
|
// Column 1 = CardTitle
|
||||||
if (currentLookupRequest->tableColumn == 1)
|
if (request->tableColumn == 1)
|
||||||
{
|
{
|
||||||
if (prefix == 0xFE)
|
if (prefix == 0xFE)
|
||||||
{
|
{
|
||||||
// 0xFF in front of the title to skip localization. Or else it will wait for a couple of seconds for the asset of type localize
|
// 0xFF in front of the title to skip localization. Or else it will wait for a couple of seconds for the asset of type localize
|
||||||
if ((BYTE)*CustomTitleDvar->current.string)
|
if (*CustomTitleDvar->current.string)
|
||||||
{
|
{
|
||||||
title = Utils::String::VA("\xFF%s", CustomTitleDvar->current.string);
|
title = Utils::String::VA("\x15%s", CustomTitleDvar->current.string);
|
||||||
currentLookupResult->result = title;
|
|
||||||
currentLookupResult->dunno = 2; // Seems to be nessecary. Don't ask me why.
|
|
||||||
|
|
||||||
__asm
|
// prepare return value
|
||||||
{
|
operand->internals.stringVal.string = title;
|
||||||
mov eax, title;
|
operand->dataType = Game::VAL_STRING;
|
||||||
pop ecx;
|
|
||||||
mov ecx, currentLookupRequest;
|
return title;
|
||||||
mov ecx, DWORD ptr[ecx + 4];
|
|
||||||
retn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (prefix == 0xFF)
|
else if (prefix == 0xFF)
|
||||||
{
|
{
|
||||||
if (!CustomTitles[data].empty())
|
if (!CustomTitles[data].empty())
|
||||||
{
|
{
|
||||||
title = Utils::String::VA("\xFF%s", CustomTitles[data].data());
|
title = Utils::String::VA("\x15%s", CustomTitles[data].data());
|
||||||
currentLookupResult->result = title;
|
|
||||||
currentLookupResult->dunno = 2;
|
|
||||||
|
|
||||||
__asm
|
// prepare return value
|
||||||
{
|
operand->internals.stringVal.string = title;
|
||||||
mov eax, title;
|
operand->dataType = Game::VAL_STRING;
|
||||||
pop ecx;
|
|
||||||
mov ecx, currentLookupRequest;
|
return title;
|
||||||
mov ecx, DWORD ptr[ecx + 4];
|
|
||||||
retn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the title was changed it already returned at this point so...
|
// If the title was changed it already returned at this point so...
|
||||||
// Remove prefix and data to make being readable to the normal lookuprequest
|
// Remove prefix and data to make being readable to the normal lookuprequest
|
||||||
currentLookupRequest->tableRow = static_cast<std::int32_t>(*(reinterpret_cast<WORD*>(¤tLookupRequest->tableRow)));
|
request->tableRow = static_cast<std::int32_t>(*(reinterpret_cast<WORD*>(&request->tableRow)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Continue with the normal lookup request because we did not use our custom result
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) CardTitles::TableLookupByRowHookStub()
|
||||||
|
{
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
|
push esi;
|
||||||
|
push ebx;
|
||||||
|
|
||||||
|
pushad;
|
||||||
|
call TableLookupByRowHook;
|
||||||
|
cmp eax, 0;
|
||||||
|
popad;
|
||||||
|
|
||||||
|
jz OriginalTitle;
|
||||||
|
|
||||||
|
add esp, 8;
|
||||||
|
|
||||||
|
pop ecx;
|
||||||
|
mov ecx, DWORD ptr[esi + 4];
|
||||||
|
retn;
|
||||||
|
|
||||||
|
OriginalTitle:
|
||||||
|
|
||||||
|
add esp, 8;
|
||||||
|
|
||||||
mov eax, [esi + 50h];
|
mov eax, [esi + 50h];
|
||||||
cmp eax, 3;
|
cmp eax, 3;
|
||||||
|
|
||||||
@ -208,9 +186,13 @@ namespace Components
|
|||||||
CardTitles::CustomTitles.resize(18);
|
CardTitles::CustomTitles.resize(18);
|
||||||
|
|
||||||
Utils::Hook(0x62EB26, GetPlayerCardClientInfoStub).install()->quick();
|
Utils::Hook(0x62EB26, GetPlayerCardClientInfoStub).install()->quick();
|
||||||
Utils::Hook(0x63A2D5, LocalizationSkipHookStub).install()->quick();
|
|
||||||
Utils::Hook(0x62DCC1, TableLookupByRowHookStub).install()->quick();
|
|
||||||
|
|
||||||
|
// Translation fixup
|
||||||
|
// Utils::Hook(0x63A2D9, LocalizationSkipHookStub).install()->quick();
|
||||||
|
// Utils::Hook::Nop(0x63A2D5, 3);
|
||||||
|
|
||||||
|
// Table lookup stuff
|
||||||
|
Utils::Hook(0x62DCC1, TableLookupByRowHookStub).install()->quick();
|
||||||
Utils::Hook::Nop(0x62DCC6, 1);
|
Utils::Hook::Nop(0x62DCC6, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,6 @@ namespace Components
|
|||||||
std::uint8_t padding3[4];
|
std::uint8_t padding3[4];
|
||||||
std::int32_t tableColumn;
|
std::int32_t tableColumn;
|
||||||
};
|
};
|
||||||
struct tablelookupresult_s
|
|
||||||
{
|
|
||||||
std::uint32_t dunno;
|
|
||||||
const char* result;
|
|
||||||
};
|
|
||||||
struct playercarddata_s
|
struct playercarddata_s
|
||||||
{
|
{
|
||||||
std::uint32_t padding;
|
std::uint32_t padding;
|
||||||
@ -71,7 +66,9 @@ namespace Components
|
|||||||
static CClient * GetClientByIndex(std::uint32_t index);
|
static CClient * GetClientByIndex(std::uint32_t index);
|
||||||
static std::int32_t GetPlayerCardClientInfo(std::int32_t lookupResult, playercarddata_s * data);
|
static std::int32_t GetPlayerCardClientInfo(std::int32_t lookupResult, playercarddata_s * data);
|
||||||
static void GetPlayerCardClientInfoStub();
|
static void GetPlayerCardClientInfoStub();
|
||||||
|
static const char* LocalizationSkipHook(const char * string);
|
||||||
static void LocalizationSkipHookStub();
|
static void LocalizationSkipHookStub();
|
||||||
|
static const char* TableLookupByRowHook(Game::Operand * operand, tablelookuprequest_s * request);
|
||||||
static void TableLookupByRowHookStub();
|
static void TableLookupByRowHookStub();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user