fix game crash
This commit is contained in:
parent
6ac94178fa
commit
3c1d1f139a
|
@ -575,38 +575,27 @@ namespace GakumasLocal::HookMain {
|
||||||
|
|
||||||
void* AddIdsToUserDataCollectionFromMaster(void* origList, std::vector<std::string>& allIds,
|
void* AddIdsToUserDataCollectionFromMaster(void* origList, std::vector<std::string>& allIds,
|
||||||
UnityResolve::Method* get_CostumeId, UnityResolve::Method* set_CostumeId, UnityResolve::Method* Clone) {
|
UnityResolve::Method* get_CostumeId, UnityResolve::Method* set_CostumeId, UnityResolve::Method* Clone) {
|
||||||
|
std::unordered_set<std::string> existIds{};
|
||||||
Il2cppUtils::Tools::CSListEditor listEditor(origList);
|
Il2cppUtils::Tools::CSListEditor listEditor(origList);
|
||||||
if (listEditor.get_Count() <= 0) {
|
if (listEditor.get_Count() <= 0) {
|
||||||
return origList;
|
return origList;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto i : listEditor) {
|
for (auto i : listEditor) {
|
||||||
auto currCostumeId = get_CostumeId->Invoke<Il2cppString*>(i);
|
auto costumeId = get_CostumeId->Invoke<Il2cppString*>(i);
|
||||||
if (!currCostumeId) continue;
|
if (!costumeId) continue;
|
||||||
std::string currCostumeIdStr = currCostumeId->ToString();
|
existIds.emplace(costumeId->ToString());
|
||||||
if (std::find(allIds.begin(), allIds.end(), currCostumeIdStr) == allIds.end()) {
|
|
||||||
allIds.emplace_back(currCostumeIdStr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currIndex = 0;
|
|
||||||
int origSize = listEditor.get_Count();
|
|
||||||
for (auto& i : allIds) {
|
for (auto& i : allIds) {
|
||||||
if (i.empty()) continue;
|
if (i.empty()) continue;
|
||||||
// Log::DebugFmt("Try add %s", i.c_str());
|
// Log::DebugFmt("Try add %s", i.c_str());
|
||||||
|
if (existIds.contains(i)) continue;
|
||||||
|
|
||||||
if (currIndex < origSize) {
|
|
||||||
auto userCostume = listEditor.get_Item(currIndex);
|
|
||||||
set_CostumeId->Invoke<void>(userCostume, Il2cppString::New(i));
|
|
||||||
listEditor.set_Item(currIndex, userCostume);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
auto userCostume = Clone->Invoke<void*>(listEditor.get_Item(0));
|
auto userCostume = Clone->Invoke<void*>(listEditor.get_Item(0));
|
||||||
set_CostumeId->Invoke<void>(userCostume, Il2cppString::New(i));
|
set_CostumeId->Invoke<void>(userCostume, Il2cppString::New(i));
|
||||||
listEditor.Add(userCostume);
|
listEditor.Add(userCostume);
|
||||||
}
|
}
|
||||||
currIndex++;
|
|
||||||
}
|
|
||||||
return origList;
|
return origList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue