Skip to content

Commit

Permalink
Proper fix for game taking input while console is opened
Browse files Browse the repository at this point in the history
If the XN_SYS_UI message filter is updated, the returned param is a bool which determines if the gfwl ui is opened or not, which makes the game determine if it should take input or not
  • Loading branch information
nukeulater committed Feb 12, 2020
1 parent 738d410 commit 8bf3207
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 135 deletions.
2 changes: 0 additions & 2 deletions xlive/Globals.cpp
Expand Up @@ -11,8 +11,6 @@ s_datum_array* game_state_objects_header = nullptr;
bool displayXyz = false;
volatile bool isLobby = true;

ConsoleCommands* commands = new ConsoleCommands();

//TODO: actually check if they have a microphone or check some settings
bool microphoneEnabled = true;
std::unordered_map<XUID, BOOL> xuidIsTalkingMap;
Expand Down
2 changes: 0 additions & 2 deletions xlive/Globals.h
Expand Up @@ -16,7 +16,6 @@
#include "H2MOD\Variants\FireFight\FireFight.h"
#include "H2MOD\Variants\GunGame\GunGame.h"
#include "H2MOD\Variants\HeadHunter\HeadHunter.h"
#include "H2MOD\Modules\Console\ConsoleCommands.h"
#include "H2MOD\Modules\Achievements\Achievements.h"
#include "H2MOD\Modules\AdvLobbySettings\AdvLobbySettings.h"
#include "H2MOD\Modules\Networking\NetworkSession\NetworkSession.h"
Expand All @@ -38,7 +37,6 @@ extern VariantPlayer* variant_player;
extern AdvLobbySettings* advLobbySettings;
extern bool displayXyz;
extern volatile bool isLobby;
extern ConsoleCommands* commands;

extern std::map<DWORD, bool> achievementList;

Expand Down
9 changes: 1 addition & 8 deletions xlive/H2MOD.cpp
Expand Up @@ -8,6 +8,7 @@
#include "H2MOD/Modules/Input/Mouseinput.h"
#include "H2MOD/Modules/MainMenu/Ranks.h"
#include "H2MOD/Modules/MapFix/MPMapFix.h"
#include "H2MOD/Modules/Console/ConsoleCommands.h"
#include "H2MOD/Modules/Networking/Memory/bitstream.h"
#include "H2MOD/Modules/OnScreenDebug/OnscreenDebug.h"
#include "H2MOD/Modules/ServerConsole/ServerConsole.h"
Expand Down Expand Up @@ -402,14 +403,6 @@ signed int __cdecl stringDisplayHook(int a1, unsigned int a2, wchar_t* a3, int a
return p_wcsncpy_s_hook(a1, a2, a3, a4);
}

void H2MOD::handle_command(std::string command) {
commands->handle_command(command);
}

void H2MOD::handle_command(std::wstring command) {
commands->handle_command(std::string(command.begin(), command.end()));
}

/* controller index aka local player index -> player index */
DatumIndex H2MOD::get_player_datum_index_from_controller_index(int controller_index)
{
Expand Down
2 changes: 0 additions & 2 deletions xlive/H2MOD.h
Expand Up @@ -54,8 +54,6 @@ class H2MOD
DatumIndex get_unit_datum_from_player_index(int);
BYTE* get_player_unit_from_player_index(int playerIndex);
void ApplyHooks();
void handle_command(std::string);
void handle_command(std::wstring);
DatumIndex get_player_datum_index_from_controller_index(int controller_index);
wchar_t* get_local_player_name();
Real::Point3D* get_player_unit_coords(int playerIndex);
Expand Down
3 changes: 1 addition & 2 deletions xlive/H2MOD/GUI/GUI.cpp
Expand Up @@ -2,13 +2,12 @@
#include "Globals.h"

#include "GUI.h"
#include "H2MOD\Modules\Console\ConsoleCommands.h"
#include "H2MOD\Modules\OnScreenDebug\OnscreenDebug.h"
#include "H2MOD\Modules\Networking\NetworkStats\NetworkStats.h"
#include "H2MOD\Modules\Config\Config.h"


extern ConsoleCommands* commands;

extern void InitInstance();

extern bool displayXyz;
Expand Down
6 changes: 4 additions & 2 deletions xlive/H2MOD/Modules/Console/ConsoleCommands.cpp
@@ -1,7 +1,8 @@
#include "stdafx.h"

#include "Globals.h"
#include "Blam/BlamLibrary.h"
#include "ConsoleCommands.h"

#include "H2MOD\Modules\Startup\Startup.h"
#include "H2MOD\Modules\Tweaks\Tweaks.h"
#include "H2MOD\Modules\Config\Config.h"
Expand All @@ -18,6 +19,8 @@

std::wstring ERROR_OPENING_CLIPBOARD(L"Error opening clipboard");

ConsoleCommands* commands = new ConsoleCommands();

ConsoleCommands::ConsoleCommands() {
command = "";
caretPos = 0;
Expand Down Expand Up @@ -45,7 +48,6 @@ BOOL ConsoleCommands::handleInput(WPARAM wp) {
if (wp == H2Config_hotkeyIdConsole) {
if (seconds_since_start > 0.5) {
this->console = !this->console;
*h2mod->GetAddress<bool*>(0x479F51) = !this->console;
start = time(0);
}
return true;
Expand Down
8 changes: 7 additions & 1 deletion xlive/H2MOD/Modules/Console/ConsoleCommands.h
@@ -1,5 +1,9 @@
#pragma once

#include "Blam\Cache\DataTypes\DatumIndex.h"

using Blam::Cache::DataTypes::DatumIndex;

class ConsoleCommands {
public:
ConsoleCommands();
Expand All @@ -10,7 +14,7 @@ class ConsoleCommands {
std::vector<std::string> prevCommands;
std::vector<std::string> prevOutput;
BOOL handleInput(WPARAM wp);
BOOL consoleOpen() { return this->console; };
bool consoleOpen() { return this->console; };

std::string command;
int caretPos;
Expand All @@ -26,3 +30,5 @@ class ConsoleCommands {
std::unordered_map<std::string, unsigned int> object_ids;
DWORD sleepTime;
};

extern ConsoleCommands* commands;
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "NetworkSession.h"
#include "Globals.h"

#include "H2MOD/Modules/Console/ConsoleCommands.h"

network_session* NetworkSession::getNetworkSessions()
{
Expand Down
3 changes: 2 additions & 1 deletion xlive/H2MOD/Modules/ServerConsole/ServerConsole.cpp
Expand Up @@ -3,6 +3,7 @@

#include "H2MOD.h"
#include "Util/Hooks/Hook.h"
#include "H2MOD/Modules/Console/ConsoleCommands.h"

typedef void*(__cdecl *dedi_command_hook)(wchar_t** a1, int a2, char a3);
dedi_command_hook p_dedi_command_hook;
Expand All @@ -14,7 +15,7 @@ void* __cdecl dediCommandHook(wchar_t** command_line_args, int split_strings, ch
ServerConsole::logToDedicatedServerConsole(L"Running custom command\n");
//run the chatbox commands
std::wstring wsCommand(command);
h2mod->handle_command(wsCommand);
commands->handle_command(std::string(wsCommand.begin(), wsCommand.end()));
return 0;
}

Expand Down

0 comments on commit 8bf3207

Please sign in to comment.