Skip to content

Commit

Permalink
Fix an issue with multiple scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrapivin committed Jan 31, 2021
1 parent 1441b82 commit d1aa626
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
17 changes: 12 additions & 5 deletions libLassebq/libLassebq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,23 @@ void lassebq_patchObject(CObjectGM* gmObj)
CEvent* origev = GetEventRecursive(cogm, type, subtype);
if (origev != nullptr)
{
// Don't do anything if we've already added our lua stub.
if (origev->e_code->i_pFunc->ptr == lassebq_lua_GMLRoutine
|| origev->e_code->i_pFunc->ptr == lassebq_luaPatch_GMLRoutine)
continue;

std::cout << "AN EVENT " << pair.second << " ALREADY EXISTS! brb replacing..." << std::endl;
EventPatchMap[i][pair.first] = origev->e_code->i_pFunc->ptr; // save the original function.
origev->e_code->i_pFunc->ptr = lassebq_luaPatch_GMLRoutine;
continue;
}

memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf), "libLassebq_%s_%s", str, pair.second.c_str());
std::cout << "Adding event " << buf << "..." << std::endl;
lassebq_addEvent(cogm, type, subtype, buf, lassebq_lua_GMLRoutine);
else
{
memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf), "libLassebq_%s_%s", str, pair.second.c_str());
std::cout << "Adding event " << buf << "..." << std::endl;
lassebq_addEvent(cogm, type, subtype, buf, lassebq_lua_GMLRoutine);
}
}
lua_pop(lS, 1);
}
Expand Down
16 changes: 11 additions & 5 deletions libLassebqInjector.csx → llbqInjector.csx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// libLassebq script
/// libLassebq injector script
/// @author Nikita Krapivin
/// @version v1.0.0

Expand Down Expand Up @@ -61,7 +61,13 @@ void InjectDLL()
Data.FORM.EXTN.productIdData.Add(System.Text.Encoding.ASCII.GetBytes("LIBLASSEBQYYCDLL"));
}

// We start here.
if (!ScriptQuestion("This will modify your .win, be sure to make a backup, proceed?")) return;
InjectDLL();
ScriptMessage("Done! Save and load the .win & start rocking!");
bool ScriptEntry()
{
// We start here.
if (!ScriptQuestion("This will modify your .win, be sure to make a backup, proceed?")) return false;
InjectDLL();
ScriptMessage("Done! Save the .win and start the game.");
return true;
}

if (!ScriptEntry()) return;

0 comments on commit d1aa626

Please sign in to comment.