Skip to content

Commit

Permalink
New options for show_fps, full and minimal.
Browse files Browse the repository at this point in the history
Minimal is default.
  • Loading branch information
twist84 committed Dec 9, 2017
1 parent 2d472d4 commit 887d961
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 31 deletions.
13 changes: 8 additions & 5 deletions ElDorito.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2003
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CefProcess", "CefProcess/CefProcess.vcxproj", "{261CC8A8-EF80-3FD6-8094-9295652437EC}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CefProcess", "CefProcess\CefProcess.vcxproj", "{261CC8A8-EF80-3FD6-8094-9295652437EC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ElDorito", "ElDorito/ElDorito.vcxproj", "{715A189F-024C-3E8E-8462-9036BF583FA1}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ElDorito", "ElDorito\ElDorito.vcxproj", "{715A189F-024C-3E8E-8462-9036BF583FA1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -24,4 +24,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4A13913-5316-44F7-8E1D-A52896CDB729}
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions ElDorito/ElDorito.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<ClCompile Include="Source\Patches\Equipment.cpp" />
<ClCompile Include="Source\Patches\Events.cpp" />
<ClCompile Include="Source\Patches\Forge.cpp" />
<ClCompile Include="Source\Patches\FpsCounter.cpp" />
<ClCompile Include="Source\Patches\Hf2pExperimental.cpp" />
<ClCompile Include="Source\Patches\Input.cpp" />
<ClCompile Include="Source\Patches\LoadingScreen.cpp" />
Expand Down Expand Up @@ -298,6 +299,7 @@
<ClInclude Include="Source\Patches\Equipment.hpp" />
<ClInclude Include="Source\Patches\Events.hpp" />
<ClInclude Include="Source\Patches\Forge.hpp" />
<ClInclude Include="Source\Patches\FpsCounter.hpp" />
<ClInclude Include="Source\Patches\Hf2pExperimental.hpp" />
<ClInclude Include="Source\Patches\Input.hpp" />
<ClInclude Include="Source\Patches\LoadingScreen.hpp" />
Expand Down
6 changes: 6 additions & 0 deletions ElDorito/ElDorito.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@
<ClCompile Include="Source\Discord\DiscordRPC.cpp">
<Filter>Discord</Filter>
</ClCompile>
<ClCompile Include="Source\Patches\FpsCounter.cpp">
<Filter>Patches</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Source\Blam\BitStream.hpp">
Expand Down Expand Up @@ -1245,6 +1248,9 @@
<ClInclude Include="Source\ThirdParty\rapidjson\internal\swap.h">
<Filter>ThirdParty\rapidjson\internal</Filter>
</ClInclude>
<ClInclude Include="Source\Patches\FpsCounter.hpp">
<Filter>Patches</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Source\ElDorito.rc" />
Expand Down
30 changes: 27 additions & 3 deletions ElDorito/Source/Modules/ModuleGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <unordered_map>
#include <codecvt>
#include "../Blam/Tags/Camera/AreaScreenEffect.hpp"
#include "../Patches/FpsCounter.hpp"

namespace
{
Expand Down Expand Up @@ -1084,12 +1085,35 @@ namespace
return true;
}

bool ShortFormBool = true;
bool CommandShowFPS(const std::vector<std::string>& Arguments, std::string& returnInfo)
{
float current_fps = Pointer(0x22B47F8).Read<float>(); // for future use
bool ShowFps = Pointer(0x22B47FC).Read<bool>();
std::stringstream ss;

if (Arguments.size() == 0)
{
Patches::FpsCounter::Enable(!ShowFps);
ss << "Fps ui: " << (!ShowFps ? "enabled." : "disabled.");
}

Pointer &show_fps = Pointer(0x22B47FC);
show_fps.WriteFast<bool>(!show_fps.Read<bool>());
if (Arguments.size() == 1)
{
if (Utils::String::ToLower(Arguments[0]) == "full")
ShortFormBool = false;
else if (Utils::String::ToLower(Arguments[0]) == "minimal")
ShortFormBool = true;
else
{
returnInfo = "Invalid argument, only \"full\" and \"minimal\" are valid.";
return false;
}

Patches::FpsCounter::ShortForm(ShortFormBool);
ss << "Fps ui: " << (ShortFormBool ? "minimal." : "full.");
}

returnInfo = ss.str();
return true;
}

Expand Down
20 changes: 10 additions & 10 deletions ElDorito/Source/Modules/ModuleWeapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ namespace
}
}

auto *weaponDeinition = TagInstance(weaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
auto *weaponDefinition = TagInstance(weaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();

auto weaponOffset = weaponDeinition->FirstPersonWeaponOffset;
auto weaponOffset = weaponDefinition->FirstPersonWeaponOffset;

if (Arguments.size() != 4) {
std::stringstream ss;
Expand Down Expand Up @@ -98,9 +98,9 @@ namespace
}
}

auto *weaponDeinition = TagInstance(weaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
auto *weaponDefinition = TagInstance(weaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();

weaponDeinition->FirstPersonWeaponOffset = Patches::Weapon::GetOffsetByName(true, weaponName);
weaponDefinition->FirstPersonWeaponOffset = Patches::Weapon::GetOffsetByName(true, weaponName);
Patches::Weapon::SetOffsetModified(weaponName, Patches::Weapon::GetOffsetByName(true, weaponName));

std::stringstream ss;
Expand Down Expand Up @@ -155,15 +155,15 @@ namespace

auto equippedWeaponName = Patches::Weapon::GetEquippedWeaponName();

auto *weaponDeinition = TagInstance(equippedWeaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
auto equippedWeaponOffset = weaponDeinition->FirstPersonWeaponOffset;
auto *weaponDefinition = TagInstance(equippedWeaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
auto equippedWeaponOffset = weaponDefinition->FirstPersonWeaponOffset;

std::stringstream index_;
index_ << "0x" << std::hex << equippedWeaponIndex;
std::string Index = index_.str();

std::string MultiplayerWeaponType, WeaponType, TrackingType, SpecialHUDType;
GetTypes(weaponDeinition, MultiplayerWeaponType, WeaponType, TrackingType, SpecialHUDType);
GetTypes(weaponDefinition, MultiplayerWeaponType, WeaponType, TrackingType, SpecialHUDType);

std::string format;
if (Arguments.size() == 0)
Expand Down Expand Up @@ -245,15 +245,15 @@ namespace
auto equippedWeaponIndex = Patches::Weapon::GetEquippedWeaponIndex();
auto equippedWeaponName = Patches::Weapon::GetEquippedWeaponName();

auto *weaponDeinition = TagInstance(equippedWeaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
auto equippedWeaponOffset = weaponDeinition->FirstPersonWeaponOffset;
auto *weaponDefinition = TagInstance(equippedWeaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
auto equippedWeaponOffset = weaponDefinition->FirstPersonWeaponOffset;

std::stringstream temp;
temp << "0x" << std::hex << equippedWeaponIndex;
std::string Index = temp.str();

std::string MultiplayerWeaponType, WeaponType, TrackingType, SpecialHUDType;
GetTypes(weaponDeinition, MultiplayerWeaponType, WeaponType, TrackingType, SpecialHUDType);
GetTypes(weaponDefinition, MultiplayerWeaponType, WeaponType, TrackingType, SpecialHUDType);

rapidjson::StringBuffer jsonBuffer;
rapidjson::Writer<rapidjson::StringBuffer> jsonWriter(jsonBuffer);
Expand Down
3 changes: 3 additions & 0 deletions ElDorito/Source/Patches/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "../Blam/Tags/TagInstance.hpp"
#include "../Blam/Tags/Items/DefinitionWeapon.hpp"
#include "../Blam/Tags/Scenario/Scenario.hpp"
#include "../Patches/FpsCounter.hpp"
#include "../Modules/ModuleGame.hpp"
#include "../Modules/ModuleServer.hpp"
#include "../Modules/ModulePlayer.hpp"
Expand Down Expand Up @@ -141,6 +142,8 @@ namespace Patches::Core

Pointer(0x530FAA).Write<float>(7); // podium duration in seconds

Patches::FpsCounter::ShortForm(true);

#ifndef _DEBUG
// Dirty disk error at 0x0xA9F6D0 is disabled in this build
Hook(0x69F6C0, DirtyDiskErrorHook).Apply();
Expand Down
28 changes: 28 additions & 0 deletions ElDorito/Source/Patches/FpsCounter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "FpsCounter.hpp"
#include "../ElDorito.hpp"
#include "../Patch.hpp"

namespace
{
float fps_value = Pointer(0x22B47F8).Read<float>(); // for future use

Patch FpsTextMinimalPatch(0x12503E0, { 0x25, 0x32, 0x2E, 0x32, 0x66, 0x00 }); // show fps as "%2.2f" and not "t[%2.2f] r[%2.2f]|nmin%2.2f max%2.2f|ngfx %d dip %d max %d|n%s|n"
}

namespace Patches::FpsCounter
{
void Enable(bool enabled)
{
Pointer(0x22B47FC).WriteFast<bool>(enabled);
}

void ShortForm(bool enabled)
{
if (enabled) {
FpsTextMinimalPatch.Apply();
}
else {
FpsTextMinimalPatch.Reset();
}
}
}
7 changes: 7 additions & 0 deletions ElDorito/Source/Patches/FpsCounter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

namespace Patches::FpsCounter
{
void Enable(bool enabled);
void ShortForm(bool enabled);
}
32 changes: 19 additions & 13 deletions ElDorito/Source/Patches/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ namespace Patches::Weapon
auto weapIndex = Patches::Weapon::GetIndex(selected);
if (weapIndex != 0xFFFF)
{
auto *weaponDeinition = TagInstance(weapIndex).GetDefinition<Blam::Tags::Items::Weapon>();
if(weaponDeinition)
weaponOffsetsDefault.emplace(selected, weaponDeinition->FirstPersonWeaponOffset);
auto *weaponDefinition = TagInstance(weapIndex).GetDefinition<Blam::Tags::Items::Weapon>();
if(weaponDefinition)
weaponOffsetsDefault.emplace(selected, weaponDefinition->FirstPersonWeaponOffset);
}
}
}
Expand Down Expand Up @@ -266,9 +266,9 @@ namespace Patches::Weapon
{
if (!IsMainMenu)
{
auto *weaponDeinition = TagInstance(weaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
if(weaponDeinition)
weaponDeinition->FirstPersonWeaponOffset = weaponOffset;
auto *weaponDefinition = TagInstance(weaponIndex).GetDefinition<Blam::Tags::Items::Weapon>();
if(weaponDefinition)
weaponDefinition->FirstPersonWeaponOffset = weaponOffset;
}
}

Expand All @@ -280,9 +280,9 @@ namespace Patches::Weapon
auto weapIndex = Patches::Weapon::GetIndex(weaponName);
if (weapIndex != 0xFFFF)
{
auto *weaponDeinition = TagInstance(weapIndex).GetDefinition<Blam::Tags::Items::Weapon>();
if(weaponDeinition)
weaponDeinition->FirstPersonWeaponOffset = weaponOffset;
auto *weaponDefinition = TagInstance(weapIndex).GetDefinition<Blam::Tags::Items::Weapon>();
if(weaponDefinition)
weaponDefinition->FirstPersonWeaponOffset = weaponOffset;
}
}
}
Expand Down Expand Up @@ -321,8 +321,14 @@ namespace Patches::Weapon
std::string weaponname = weaponsObject["name"].GetString();
std::string tagname = weaponsObject["tagname"].GetString();

weapon_indices.emplace(weaponname.c_str(), TagInstance::Find('weap', tagname.c_str()).Index);
weapon_names.emplace(weaponname.c_str(), tagname.c_str());
try {
weapon_indices.emplace(weaponname.c_str(), TagInstance::Find('weap', tagname.c_str()).Index);
weapon_names.emplace(weaponname.c_str(), tagname.c_str());
} catch (const std::exception&) {
std::stringstream ss;
ss << "Unable to add " << weaponname.c_str() << " to supported list." << std::endl;
Console::WriteLine(ss.str());
}
}
}
}
Expand Down Expand Up @@ -606,9 +612,9 @@ namespace
return 0;

auto index = *(uint32_t*)GetObjectDataAddress(objectIndex);
auto *weaponDeinition = TagInstance(index).GetDefinition<Weapon>();
auto *weaponDefinition = TagInstance(index).GetDefinition<Weapon>();

return ((int32_t)weaponDeinition->WeaponFlags1 & (int32_t)Weapon::Flags1::CanBeDualWielded) != 0;
return ((int32_t)weaponDefinition->WeaponFlags1 & (int32_t)Weapon::Flags1::CanBeDualWielded) != 0;
}

__declspec(naked) void DualWieldSprintInputHook()
Expand Down

0 comments on commit 887d961

Please sign in to comment.