Browse Source

startup fixes

legacy
touky 8 years ago
parent
commit
9174a1e43d
3 changed files with 32 additions and 5 deletions
  1. +14
    -4
      src/gpu/shader.cpp
  2. +13
    -0
      src/lol/base/string.h
  3. +5
    -1
      src/lolimgui.cpp

+ 14
- 4
src/gpu/shader.cpp View File

@@ -674,12 +674,22 @@ String ShaderData::Patch(String const &code, ShaderType type)

for (char const * const *rep = fast_replaces; rep[0]; rep += 2)
{
char *match;
size_t l0 = strlen(rep[0]);
size_t l1 = strlen(rep[1]);

if (l1 > l0)
{
int padding = patched_code.count_occurence(rep[0]) * (l1 - l0);
if (padding > 0)
{
patched_code.resize(patched_code.count() + padding);
end = patched_code.C() + patched_code.count() + 1 - padding;
}
}

char *match;
while ((match = strstr(patched_code.C(), rep[0])))
{
size_t l0 = strlen(rep[0]);
size_t l1 = strlen(rep[1]);

if (l1 > l0)
memmove(match + l1, match + l0, (end - match) - l0);
memcpy(match, rep[1], l1);


+ 13
- 0
src/lol/base/string.h View File

@@ -170,6 +170,19 @@ public:
return -1;
}

int count_occurence(String const& token) const { return last_index_of(token.C()); }
int count_occurence(char const* token) const
{
int count = 0;
const char *match = strstr(C(), token);
while (match)
{
count++;
match = strstr(match + 1, token);
}
return count;
}

int replace(char const old_token, char const new_token,
bool all_occurrences = false)
{


+ 5
- 1
src/lolimgui.cpp View File

@@ -145,7 +145,11 @@ io.AddInputCharacter((unsigned short)c);

void LolImGui::Shutdown()
{
Ticker::Unref(g_lolimgui);
if (g_lolimgui)
{
Ticker::Unref(g_lolimgui);
g_lolimgui = nullptr;
}

ImGui::Shutdown();
}


Loading…
Cancel
Save