Skip to content

Commit

Permalink
Fixes issue with quickload patches on AC
Browse files Browse the repository at this point in the history
- Fixes quickload patches not working on AC.
  • Loading branch information
Whitetigerswt committed Mar 7, 2015
1 parent 019fc31 commit 24cedac
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 2 deletions.
Binary file added crashes/Release/crashes.asi
Binary file not shown.
Binary file modified crashes/crashes.v12.suo
Binary file not shown.
41 changes: 41 additions & 0 deletions crashes/crashes/CParseCommandLine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "CParseCommandLine.h"

std::map <std::string, std::string> CParseCommandLine::CmdLine;

std::map <std::string, std::string> CParseCommandLine::parseCmdLine(std::string CommandLine)
{
for (unsigned int i = 0; i < CommandLine.length(); ++i)
{
if (CommandLine.at(i) == '-' || CommandLine.at(i) == '/')
{
// Get past the -h or -p or -whatever
// there's also a space after the -h or -p.
// so i + 1 = 'h'
// and i + 2 = ' '
// so we want to find the next space AFTER i + 2.
std::size_t stringPos = CommandLine.find(' ', i + 3);

// If no space was found, assume we're at the end of the string.
if (stringPos == std::string::npos)
{
stringPos = CommandLine.length();
}

// Make sure parameter isn't empty.
// If it's empty, the next parameter will be collided with
if (CommandLine.at(i + 3) != '-')
{
int characters = stringPos - (i + 3);
switch (CommandLine.at(i + 1))
{

case 'h': CmdLine["Host"] = CommandLine.substr(i + 3, characters);
case 'p': CmdLine["Port"] = CommandLine.substr(i + 3, characters);
case 'z': CmdLine["Password"] = CommandLine.substr(i + 3, characters);
case 'n': CmdLine["Name"] = CommandLine.substr(i + 3, characters);
}
}
}
}
return CmdLine;
}
14 changes: 14 additions & 0 deletions crashes/crashes/CParseCommandLine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <vector>
#include <map>
#include <string>

class CParseCommandLine {

public:

// PURPOSE: Parse the command line and get the ip, port, and password
// REQUIRES: The command line.
static std::map <std::string, std::string> parseCmdLine(std::string CommandLine);
private:
static std::map<std::string, std::string> CmdLine;
};
2 changes: 2 additions & 0 deletions crashes/crashes/crashes.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="Addresses.h" />
<ClInclude Include="CParseCommandLine.h" />
<ClInclude Include="CrashHandler.h" />
<ClInclude Include="CLog.h" />
<ClInclude Include="crashes.h" />
Expand All @@ -108,6 +109,7 @@
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CParseCommandLine.cpp" />
<ClCompile Include="CrashHandler.cpp" />
<ClCompile Include="CLog.cpp" />
<ClCompile Include="crashes.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions crashes/crashes/crashes.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<ClInclude Include="CrashHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CParseCommandLine.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="crashes.cpp">
Expand Down Expand Up @@ -116,5 +119,8 @@
<ClCompile Include="PatternScan.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CParseCommandLine.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions crashes/crashes/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "fixes.h"
#include "Addresses.h"
#include "CrashHandler.h"
#include "CParseCommandLine.h"
#include <iostream>
#include <fstream>
#include <Wininet.h>
Expand Down Expand Up @@ -119,8 +120,11 @@ static void WINAPI Load(HMODULE hModule) {
DWORD oldProt;
VirtualProtect((LPVOID)0x401000, 0x4A3000, PAGE_EXECUTE_READWRITE, &oldProt);

//patcher_install(&patch_DisableLoadingScreen);
if(GetModuleHandle("samp.dll") != NULL) {
std::map < std::string, std::string > cmdline;
cmdline = CParseCommandLine::parseCmdLine(GetCommandLineA());

if(cmdline["Host"].length() > 0)
{
quickLoadPatches();
}

Expand Down

0 comments on commit 24cedac

Please sign in to comment.