Skip to content

Commit

Permalink
Finalize 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrapivin committed Mar 8, 2021
1 parent ae3e49a commit 6ca4187
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 2,343 deletions.
2 changes: 1 addition & 1 deletion libLassebq/GMAddresses.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// What addresses to use?
#define KZ_105_STEAM
#define DITTO_WIN_STEAM

// Please please please, keep address format like this:
// #define Something_Addr (0xSOMETHINGu)
Expand Down
4 changes: 2 additions & 2 deletions libLassebq/SHAutogen.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "SHAutogen.h"
DEF_LLBQ_DUMMY_PVOID_TABLE;
DEF_LLBQ_DTR_ROUTINE(0)
DEF_LLBQ_DTR_ROUTINE(1)
DEF_LLBQ_DTR_ROUTINE(2)
Expand Down Expand Up @@ -20002,4 +20001,5 @@ GML_Script SH_DummyRoutines[] = {
SH_routine9998,
SH_routine9999,
nullptr
};
};
DEF_LLBQ_DUMMY_PVOID_TABLE;
2 changes: 1 addition & 1 deletion libLassebq/SHAutogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ extern GML_Script SH_DummyRoutines[];
extern PVOID SH_DummyPVOIDs[];

#define DEF_LLBQ_DTR_ROUTINE(ind) RValue& SH_routine ##ind(CInstance* _pSelf, CInstance* _pOther, RValue& _result, int _count, const RValue** _args) { return SH_hookerRoutine((ind), _pSelf, _pOther, _result, _count, _args); }
#define DEF_LLBQ_DUMMY_PVOID_TABLE PVOID SH_DummyPVOIDs[10000]{ nullptr }
#define DEF_LLBQ_DUMMY_PVOID_TABLE PVOID SH_DummyPVOIDs[(sizeof(SH_DummyRoutines)/sizeof(SH_DummyRoutines[0]))-1]{ nullptr }
6 changes: 6 additions & 0 deletions libLassebq/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ bool CheckFileOk(const std::string& filePath)
bool ret = false;

int siz = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filePath.c_str(), -1, nullptr, 0);
if (siz <= 0)
{
std::cout << "UNABLE TO CONVERT YOUR FILENAME TO UTF-16: " << filePath << std::endl;
return false;
}

LPWSTR wFilename = new WCHAR[siz];
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filePath.c_str(), -1, wFilename, siz);

Expand Down
1 change: 1 addition & 0 deletions libLassebq/libLassebq.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
</ItemGroup>
<ItemGroup>
<None Include="lua54.dll" />
<None Include="test.lua" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libLassebq.rc" />
Expand Down
1 change: 1 addition & 0 deletions libLassebq/libLassebq.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
</ItemGroup>
<ItemGroup>
<None Include="lua54.dll" />
<None Include="test.lua" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libLassebq.rc">
Expand Down
53 changes: 53 additions & 0 deletions libLassebq/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-- Quicksave/load for KZ.

local obj_libLassebq = { }
local player_hurt = { }

function getDateTime() -- a helper to get formatted datetime from GM
return GML_date_datetime_string(GML_date_current_datetime())
end

function obj_libLassebq.PressF5(_pSelf, _pOther)
GML_game_save("temp00")
GML_window_set_caption("Saved, time: " .. getDateTime())
end

function obj_libLassebq.PressF6(_pSelf, _pOther)
GML_game_load("temp00")
GML_window_set_caption("Loaded, time: " .. getDateTime())
end

--[[
hooker routine:
if Before defined then
r = call Before
if Before returned
return r
else
r = call Original script
if After defined
r = call After and provide Original r
return r
end
end
end
so by returning from Before, we prevent the original script from executing!
]]--

function player_hurt.Before(_pSelf, _pOther, _args)
--[[ You can't die, you can't die, you can't die, you can't die, you can't die
that would suck, right? sometimes you just *have* to die, your life's over
but no, you are still alive, watching how your close relatives and friends die
pretty painful, ain't it?
welp, I don't have any IRL friends, so not really a problem for me.
UHHHHHHHHHHHHHHHH NEVERMIND I'VE GONE TOO FAR.
oh, btw, `_args` is an array with the arguments. ]]--
return 0 -- ????????
end

function player_hurt.After(_pSelf, _pOther, _args, _ret)
return _ret -- this won't be executed anyway, you don't even need to return
end

return { obj_libLassebq=obj_libLassebq, player_hurt=player_hurt }
Loading

0 comments on commit 6ca4187

Please sign in to comment.