Skip to content

Commit

Permalink
Fixed style
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioMartin86 committed Jul 28, 2024
1 parent 78a5d4a commit 4911aca
Show file tree
Hide file tree
Showing 28 changed files with 1,044 additions and 1,053 deletions.
6 changes: 3 additions & 3 deletions emulators/emulatorList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ namespace jaffarPlus
{
#define DETECT_EMULATOR(EMULATOR) \
if (emulatorName == EMULATOR::getName()) \
{ \
e = std::make_unique<EMULATOR>(emulatorConfig); \
isRecognized = true; \
{ \
e = std::make_unique<EMULATOR>(emulatorConfig); \
isRecognized = true; \
}

std::unique_ptr<Emulator> Emulator::getEmulator(const nlohmann::json &emulatorConfig)
Expand Down
28 changes: 9 additions & 19 deletions emulators/quickerArkBot/quickerArkBot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ class QuickerArkBot final : public Emulator
_quickerArkBot->initialize();
}


// Function to get a reference to the input parser from the base emulator
virtual jaffar::InputParser* getInputParser() const
{
return _quickerArkBot->getInputParser();
}

virtual jaffar::InputParser *getInputParser() const { return _quickerArkBot->getInputParser(); }

// State advancing function
void advanceStateImpl(const jaffar::input_t &input) override { _quickerArkBot->advanceState(input); }

Expand All @@ -67,26 +63,20 @@ class QuickerArkBot final : public Emulator
}

// This function opens the video output (e.g., window)
void initializeVideoOutput() override { }
void initializeVideoOutput() override {}

// This function closes the video output (e.g., window)
void finalizeVideoOutput() override { }
void finalizeVideoOutput() override {}

__INLINE__ void enableRendering() override { }
__INLINE__ void enableRendering() override {}

__INLINE__ void disableRendering() override { }
__INLINE__ void disableRendering() override {}

__INLINE__ void updateRendererState(const size_t stepIdx, const std::string input) override {}

__INLINE__ void serializeRendererState(jaffarCommon::serializer::Base &serializer) const override
{
serializeState(serializer);
}
__INLINE__ void serializeRendererState(jaffarCommon::serializer::Base &serializer) const override { serializeState(serializer); }

__INLINE__ void deserializeRendererState(jaffarCommon::deserializer::Base &deserializer) override
{
deserializeState(deserializer);
}
__INLINE__ void deserializeRendererState(jaffarCommon::deserializer::Base &deserializer) override { deserializeState(deserializer); }

__INLINE__ size_t getRendererStateSize() const
{
Expand All @@ -97,7 +87,7 @@ class QuickerArkBot final : public Emulator

GameState *getGameState() { return _quickerArkBot->getGameState(); }

__INLINE__ void showRender() override { }
__INLINE__ void showRender() override {}

__INLINE__ void doSoftReset() { _quickerArkBot->doSoftReset(); };

Expand Down
20 changes: 10 additions & 10 deletions emulators/quickerGPGX/quickerGPGX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ class QuickerGPGX final : public Emulator

// If initial state file defined, load it
if (_initialStateFilePath.empty() == false)
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
enableStateProperties();
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
enableStateProperties();
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

// Now disabling state properties, as requested
Expand Down
56 changes: 28 additions & 28 deletions emulators/quickerNES/quickerNES.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,31 @@ class QuickerNES final : public Emulator

// Advancing the state using the initial sequence, if provided
if (_initialSequenceFilePath != "")
{
// Load initial sequence
std::string initialSequenceFileString;
if (jaffarCommon::file::loadStringFromFile(initialSequenceFileString, _initialSequenceFilePath) == false)
JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial sequence file: %s\n", _initialSequenceFilePath.c_str());
{
// Load initial sequence
std::string initialSequenceFileString;
if (jaffarCommon::file::loadStringFromFile(initialSequenceFileString, _initialSequenceFilePath) == false)
JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial sequence file: %s\n", _initialSequenceFilePath.c_str());

// Getting input sequence
const auto initialSequence = jaffarCommon::string::split(initialSequenceFileString, '\0');
// Getting input sequence
const auto initialSequence = jaffarCommon::string::split(initialSequenceFileString, '\0');

// Running inputs in the initial sequence
for (const auto &input : initialSequence) advanceState(input);
// Running inputs in the initial sequence
for (const auto &input : initialSequence) advanceState(input);
}

// If initial state file defined, load it
if (_initialStateFilePath.empty() == false)
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
enableStateProperties();
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
enableStateProperties();
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

// Now disabling state properties, as requested
Expand Down Expand Up @@ -174,14 +174,14 @@ class QuickerNES final : public Emulator

for (unsigned h = 0; h < emulator_t::image_height; h++, in_pixels += e->frame().pitch, out_pixels += emulator_t::image_width)
for (unsigned w = 0; w < emulator_t::image_width; w++)
{
unsigned col = e->frame().palette[in_pixels[w]];
const emulator_t::rgb_t &rgb = e->nes_colors[col];
unsigned r = rgb.red;
unsigned g = rgb.green;
unsigned b = rgb.blue;
out_pixels[w] = (r << 16) | (g << 8) | (b << 0);
}
{
unsigned col = e->frame().palette[in_pixels[w]];
const emulator_t::rgb_t &rgb = e->nes_colors[col];
unsigned r = rgb.red;
unsigned g = rgb.green;
unsigned b = rgb.blue;
out_pixels[w] = (r << 16) | (g << 8) | (b << 0);
}
}

// This function opens the video output (e.g., window)
Expand Down Expand Up @@ -291,7 +291,7 @@ class QuickerNES final : public Emulator
std::string _controller2Type;
std::string _romFilePath;
std::string _romFileSHA1;

std::string _initialStateFilePath;
std::string _initialSequenceFilePath;
};
Expand Down
18 changes: 9 additions & 9 deletions emulators/quickerRAW/quickerRAW.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class QuickerRAW final : public Emulator

// If initial state file defined, load it
if (_initialStateFilePath.empty() == false)
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

_mutex.unlock();
Expand Down
10 changes: 5 additions & 5 deletions emulators/quickerSDLPoP/quickerSDLPoP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class QuickerSDLPoP final : public Emulator

// If an initial state is provided, load it now
if (_stateFilePath != "")
{
std::string stateFileData;
if (jaffarCommon::file::loadStringFromFile(stateFileData, _stateFilePath) == false) JAFFAR_THROW_LOGIC("Could not initial state file: %s\n", _stateFilePath.c_str());
{
std::string stateFileData;
if (jaffarCommon::file::loadStringFromFile(stateFileData, _stateFilePath) == false) JAFFAR_THROW_LOGIC("Could not initial state file: %s\n", _stateFilePath.c_str());

jaffarCommon::deserializer::Contiguous deserializer(stateFileData.data());
_QuickerSDLPoP->deserializeState(deserializer);
jaffarCommon::deserializer::Contiguous deserializer(stateFileData.data());
_QuickerSDLPoP->deserializeState(deserializer);
}

// Check if RNG elements need overriding
Expand Down
18 changes: 9 additions & 9 deletions emulators/quickerSMBC/quickerSMBC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class QuickerSMBC final : public Emulator

// If initial state file defined, load it
if (_initialStateFilePath.empty() == false)
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

// Now disabling state properties, as requested
Expand Down
20 changes: 10 additions & 10 deletions emulators/quickerSnes9x/quickerSnes9x.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ class QuickerSnes9x final : public Emulator

// If initial state file defined, load it
if (_initialStateFilePath.empty() == false)
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
enableStateProperties();
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
{
// Reading from initial state file
std::string initialState;
bool success = jaffarCommon::file::loadStringFromFile(initialState, _initialStateFilePath);
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
enableStateProperties();
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

// Now disabling state properties, as requested
Expand Down
6 changes: 3 additions & 3 deletions games/gameList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ namespace jaffarPlus
{
#define DETECT_GAME(GAME) \
if (gameName == games::GAME::getName()) \
{ \
g = std::make_unique<games::GAME>(std::move(e), gameConfig); \
isRecognized = true; \
{ \
g = std::make_unique<games::GAME>(std::move(e), gameConfig); \
isRecognized = true; \
}

std::unique_ptr<Game> Game::getGame(const nlohmann::json &emulatorConfig, const nlohmann::json &gameConfig)
Expand Down
16 changes: 8 additions & 8 deletions games/genesis/dinoRunner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class DinoRunner final : public jaffarPlus::Game
void printInfoImpl() const override
{
if (std::abs(_pointMagnet.intensity) > 0.0f)
{
jaffarCommon::logger::log("[J+] + Point Magnet Intensity: %.5f, Y: %3.3f\n", _pointMagnet.intensity, _pointMagnet.y);
jaffarCommon::logger::log("[J+] + Distance %3.3f\n", _player1DistanceToPoint);
{
jaffarCommon::logger::log("[J+] + Point Magnet Intensity: %.5f, Y: %3.3f\n", _pointMagnet.intensity, _pointMagnet.y);
jaffarCommon::logger::log("[J+] + Distance %3.3f\n", _player1DistanceToPoint);
}
}

Expand All @@ -101,11 +101,11 @@ class DinoRunner final : public jaffarPlus::Game
bool recognizedActionType = false;

if (actionType == "Set Point Magnet")
{
auto intensity = jaffarCommon::json::getNumber<float>(actionJs, "Intensity");
auto y = jaffarCommon::json::getNumber<float>(actionJs, "Y");
rule.addAction([=, this]() { this->_pointMagnet = pointMagnet_t{.intensity = intensity, .y = y}; });
recognizedActionType = true;
{
auto intensity = jaffarCommon::json::getNumber<float>(actionJs, "Intensity");
auto y = jaffarCommon::json::getNumber<float>(actionJs, "Y");
rule.addAction([=, this]() { this->_pointMagnet = pointMagnet_t{.intensity = intensity, .y = y}; });
recognizedActionType = true;
}

return recognizedActionType;
Expand Down
40 changes: 20 additions & 20 deletions games/nes/sprilo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ class Sprilo final : public jaffarPlus::Game
void printInfoImpl() const override
{
if (std::abs(_pointMagnet.intensity) > 0.0f)
{
jaffarCommon::logger::log("[J+] + Point Magnet Intensity: %.5f, X: %3.3f, Y: %3.3f\n", _pointMagnet.intensity, _pointMagnet.x, _pointMagnet.y);
jaffarCommon::logger::log("[J+] + Distance X %3.3f\n", _player1DistanceToPointX);
jaffarCommon::logger::log("[J+] + Distance Y %3.3f\n", _player1DistanceToPointY);
jaffarCommon::logger::log("[J+] + Total Distance %3.3f\n", _player1DistanceToPoint);
{
jaffarCommon::logger::log("[J+] + Point Magnet Intensity: %.5f, X: %3.3f, Y: %3.3f\n", _pointMagnet.intensity, _pointMagnet.x, _pointMagnet.y);
jaffarCommon::logger::log("[J+] + Distance X %3.3f\n", _player1DistanceToPointX);
jaffarCommon::logger::log("[J+] + Distance Y %3.3f\n", _player1DistanceToPointY);
jaffarCommon::logger::log("[J+] + Total Distance %3.3f\n", _player1DistanceToPoint);
}
}

Expand All @@ -138,30 +138,30 @@ class Sprilo final : public jaffarPlus::Game
bool recognizedActionType = false;

if (actionType == "Set Point Magnet")
{
auto intensity = jaffarCommon::json::getNumber<float>(actionJs, "Intensity");
auto x = jaffarCommon::json::getNumber<float>(actionJs, "X");
auto y = jaffarCommon::json::getNumber<float>(actionJs, "Y");
rule.addAction([=, this]() { this->_pointMagnet = pointMagnet_t{.intensity = intensity, .x = x, .y = y}; });
recognizedActionType = true;
{
auto intensity = jaffarCommon::json::getNumber<float>(actionJs, "Intensity");
auto x = jaffarCommon::json::getNumber<float>(actionJs, "X");
auto y = jaffarCommon::json::getNumber<float>(actionJs, "Y");
rule.addAction([=, this]() { this->_pointMagnet = pointMagnet_t{.intensity = intensity, .x = x, .y = y}; });
recognizedActionType = true;
}

if (actionType == "Advance Lap Progress")
{
rule.addAction([this]() { *_lapProgress = *_lapProgress + 1; });
recognizedActionType = true;
{
rule.addAction([this]() { *_lapProgress = *_lapProgress + 1; });
recognizedActionType = true;
}

if (actionType == "Clear Lap Progress")
{
rule.addAction([this]() { *_lapProgress = 0; });
recognizedActionType = true;
{
rule.addAction([this]() { *_lapProgress = 0; });
recognizedActionType = true;
}

if (actionType == "Stop Processing Reward")
{
rule.addAction([this]() { _stopProcessingReward = true; });
recognizedActionType = true;
{
rule.addAction([this]() { _stopProcessingReward = true; });
recognizedActionType = true;
}

return recognizedActionType;
Expand Down
Loading

0 comments on commit 4911aca

Please sign in to comment.