Skip to content

Commit

Permalink
Merge pull request #5472 from unknownbrackets/reporting
Browse files Browse the repository at this point in the history
Fix reporting improperly disabled when outside a game
  • Loading branch information
hrydgard committed Feb 16, 2014
2 parents d22793e + f5c7837 commit 37d198d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 28 deletions.
53 changes: 32 additions & 21 deletions Core/CwCheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,29 @@ CWCheatEngine::CWCheatEngine() {
void CWCheatEngine::Exit() {
exit2 = true;
}

static inline std::vector<std::string> makeCodeParts(const std::vector<std::string> CodesList) { //Takes a single code line and creates a two-part vector for each code. Feeds to CreateCodeList
std::string currentcode;
std::vector<std::string> finalList;
char split_char = '\n';
char empty = ' ';
for (size_t i = 0; i < CodesList.size(); i++) {
currentcode = CodesList[i];
for (size_t j=0; j < currentcode.length(); j++) {
if (currentcode[j] == empty) {
currentcode[j] = '\n';
}
}
trim2(currentcode);
std::istringstream iss(currentcode);
std::string each;
while (std::getline(iss, each, split_char)) {
finalList.push_back(each);
}
}
return finalList;
}

void CWCheatEngine::CreateCodeList() { //Creates code list to be used in function GetNextCode
initialCodesList = GetCodesList();
std::string currentcode, codename;
Expand Down Expand Up @@ -146,27 +169,7 @@ void CWCheatEngine::CreateCodeList() { //Creates code list to be used in functio
}
parts = makeCodeParts(codelist);
}
inline std::vector<std::string> makeCodeParts(std::vector<std::string> CodesList) { //Takes a single code line and creates a two-part vector for each code. Feeds to CreateCodeList
std::string currentcode;
std::vector<std::string> finalList;
char split_char = '\n';
char empty = ' ';
for (size_t i = 0; i < CodesList.size(); i++) {
currentcode = CodesList[i];
for (size_t j=0; j < currentcode.length(); j++) {
if (currentcode[j] == empty) {
currentcode[j] = '\n';
}
}
trim2(currentcode);
std::istringstream iss(currentcode);
std::string each;
while (std::getline(iss, each, split_char)) {
finalList.push_back(each);
}
}
return finalList;
}

std::vector<int> CWCheatEngine::GetNextCode() { // Feeds a size-2 vector of ints to Run() which contains the address and value of one cheat.
std::string code1;
std::string code2;
Expand Down Expand Up @@ -565,5 +568,13 @@ void CWCheatEngine::Run() {
Exit();
}

bool CWCheatEngine::HasCheats() {
return !parts.empty();
}

bool CheatsInEffect() {
if (!cheatEngine || !cheatsEnabled)
return false;
return cheatEngine->HasCheats();
}

7 changes: 3 additions & 4 deletions Core/CwCheat.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ void __CheatInit();
void __CheatShutdown();
void __CheatDoState(PointerWrap &p);

std::vector<std::string> makeCodeParts(std::vector<std::string> CodesList);
// Return whether cheats are enabled and in effect.
bool CheatsInEffect();

class CWCheatEngine {
public:
CWCheatEngine();
std::string String();
void AddCheatLine(std::string& line);
std::vector<std::string> GetCodesList();
void CreateCodeList();
void Exit();
void Run();
std::vector<int> GetNextCode();

bool HasCheats();

private:
void SkipCodes(int count);
Expand Down
14 changes: 11 additions & 3 deletions Core/Reporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Common/CPUDetect.h"
#include "Core/CoreTiming.h"
#include "Core/Config.h"
#include "Core/CwCheat.h"
#include "Core/SaveState.h"
#include "Core/System.h"
#include "Core/FileSystems/MetaFileSystem.h"
Expand Down Expand Up @@ -51,8 +52,8 @@ namespace Reporting
static u32 spamProtectionCount = 0;
// Temporarily stores a reference to the hostname.
static std::string lastHostname;
// Keeps track of report-only-once identifiers.
static std::set<std::string> logOnceUsed;
// Keeps track of report-only-once identifiers. Since they're always constants, a pointer is okay.
static std::set<const char *> logOnceUsed;
// Keeps track of whether a harmful setting was ever used.
static bool everUnsupported = false;

Expand Down Expand Up @@ -291,10 +292,17 @@ namespace Reporting
// Disabled when using certain hacks, because they make for poor reports.
if (g_Config.iRenderingMode >= FBO_READFBOMEMORY_MIN)
return false;
if (g_Config.bTimerHack)
return false;
if (CheatsInEffect())
return false;
// Not sure if we should support locked cpu at all, but definitely not far out values.
if (g_Config.iLockedCPUSpeed != 0 && (g_Config.iLockedCPUSpeed < 111 || g_Config.iLockedCPUSpeed > 333))
return false;

// Some users run the exe from a zip or something, and don't have fonts.
// This breaks things, but let's not report it since it's confusing.
if (!pspFileSystem.GetFileInfo("flash0:/font").exists)
if (!File::Exists(g_Config.flash0Directory + "/font"))
return false;

return true;
Expand Down
2 changes: 2 additions & 0 deletions GPU/GLES/GLES_GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ void GLES_GPU::BuildReportingInfo() {
snprintf(temp, sizeof(temp), "%s (%s %s), %s (extensions: %s)", glVersion, glVendor, glRenderer, glSlVersion, glExtensions);
reportingPrimaryInfo_ = glVendor;
reportingFullInfo_ = temp;

Reporting::UpdateConfig();
}

void GLES_GPU::DeviceLost() {
Expand Down

0 comments on commit 37d198d

Please sign in to comment.