Skip to content

Commit

Permalink
Add reset definies by resetdefines.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinW1998 committed Dec 7, 2014
1 parent 8d7cf5e commit 0261ee4
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 7 deletions.
88 changes: 81 additions & 7 deletions LunaDll/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

void resetDefines();

#define PATCHIT
//#define PATCHIT

// Standard DLL loader main
BOOL WINAPI DllMain(HANDLE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Expand Down Expand Up @@ -317,14 +317,88 @@ void InitLevel() {
}


using namespace std;
vector<wstring> wsplit( wstring str, wchar_t delimiter )
{
vector<wstring> ret;
while ( true )
{
size_t pos = str.find_first_of( delimiter );
wstring cur = str.substr( 0, pos );
ret.push_back( cur );
if ( pos == wstring::npos )
break;
str = str.substr( pos + 1 );
}
return ret;
}

#include <sstream>
void resetDefines(){
VASM_END_ANIM = 11;
VASM_END_COINSOUND = 14;
VASM_END_COINVAL = 1;
VASM_END_ANIM = 11;
VASM_END_COINSOUND = 14;
VASM_END_COINVAL = 1;

GM_GRAVITY = 12;
GM_JUMPHIGHT = 20;
GM_JUMPHIGHT_BOUNCE = 20;


HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
int count = GetModuleFileNameW(hModule, path, MAX_PATH);
for(int i = count; i > 3; i--) {
if(path[i] == L'\\') {
path[i] = 0;
break;
}
}

wstring resetDefinies = path;
resetDefinies = resetDefinies.append(L"\\resetdefines.txt");
wifstream rdef(resetDefinies, ios::binary|ios::in);
if(!rdef.is_open()){
return;
}

std::wstring wrdefCode((std::istreambuf_iterator<wchar_t>(rdef)), std::istreambuf_iterator<wchar_t>());
rdef.close();

vector<wstring> lines = wsplit(wrdefCode, L'\n');
for(int i = 0; i < lines.size(); ++i){
wstring rdefLine = lines[i];
vector<wstring> reDef = wsplit(rdefLine, L'\t');
vector<wstring> clReDef;
for(int j = 0; j < reDef.size(); ++j){
if(reDef[j].length()){
clReDef.push_back(reDef[j]);
}
}
if(clReDef.size() < 3)
continue;


DWORD addr;
wstring addrType;
double val;

addr = wcstoul(clReDef[0].c_str(), NULL, 16);
addrType = clReDef[1];
val = wcstod(clReDef[2].c_str(), NULL);

if(addrType == L"b"){
*(BYTE*)addr = (BYTE)val;
}else if(addrType == L"w"){
*(WORD*)addr = (WORD)val;
}else if(addrType == L"dw"){
*(DWORD*)addr = (DWORD)val;
}else if(addrType == L"f"){
*(float*)addr = (float)val;
}else if(addrType == L"df"){
*(double*)addr = val;
}
}

GM_GRAVITY = 12;
GM_JUMPHIGHT = 20;
GM_JUMPHIGHT_BOUNCE = 20;
}


2 changes: 2 additions & 0 deletions LunaDll/MiscFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static inline double round(double val)
return floor(val + 0.5);
}



static inline const wchar_t* const BoolToString(bool b)
{
return b ? L"TRUE" : L"FALSE";
Expand Down
3 changes: 3 additions & 0 deletions resetdefines.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0x00B2C6F4 w 120 Gravity
0x00B2C6DC w 200 Jumpheight
0x00B2C6E2 w 200 Jumpheight bounce

0 comments on commit 0261ee4

Please sign in to comment.