Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/cpp-ci-generator-source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: C++ CI Hex Generator

on: [push, pull_request, workflow_dispatch]

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- name: Set up MinGW
if: contains( matrix.os, 'windows')
uses: egor-tensin/setup-mingw@v2
- name: Install Qt
if: contains( matrix.os, 'windows')
uses: jurplel/install-qt-action@v2
with:
version: '5.12.10'
arch: 'win32_mingw73'
- name: Install Qt
if: contains( matrix.os, 'macOS')
uses: jurplel/install-qt-action@v2
with:
version: '5.12.10'
- name: C++ generation
run: |
cd GeneratorSource
qmake
make
- name: Generate windows package
if: contains( matrix.os, 'windows')
run: |
mkdir package
cd package
mkdir Binaries
cd ..
move GeneratorSource/release/HexGenerator.exe package/Binaries/
move Common package/Common/
move GeneratorConfig package/GeneratorConfig/
move NativePrograms package/NativePrograms/
windeployqt ./package/Binaries/HexGenerator.exe
- uses: actions/upload-artifact@v2
if: contains( matrix.os, 'windows')
with:
name: Hex Generator for windows
path: package/
46 changes: 46 additions & 0 deletions .github/workflows/cpp-ci-serial-programs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: C++ CI Serial Programs

on: [push, pull_request, workflow_dispatch]

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [windows-latest]

steps:
- uses: actions/checkout@v2
- name: Set up MinGW
if: contains( matrix.os, 'windows')
uses: egor-tensin/setup-mingw@v2
- name: Install Qt
if: contains( matrix.os, 'windows')
uses: jurplel/install-qt-action@v2
with:
version: '5.12.10'
arch: 'win64_mingw73'
- name: Install Qt
if: contains( matrix.os, 'macOS')
uses: jurplel/install-qt-action@v2
with:
version: '5.12.10'
- name: C++ generation
run: |
cd SerialPrograms
qmake
make
- name: Generate windows package
if: contains( matrix.os, 'windows')
run: |
mkdir package
move SerialPrograms/release/SerialPrograms.exe package/
move SerialPrograms/libtesseractc.dll package/
windeployqt ./package/SerialPrograms.exe
- uses: actions/upload-artifact@v2
if: contains( matrix.os, 'windows')
with:
name: Serial Programs for windows
path: package/
5 changes: 4 additions & 1 deletion ClientSource/Connection/PABotBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void PABotBase::issue_request_and_wait(
issue_request(iter, send_type, send_params, send_bytes, false);

// Wait for ack.
while (iter->second.state != AckState::ACKED){
while (true){
std::unique_lock<std::mutex> lg(m_sleep_lock);
{
SpinLockGuard slg(m_state_lock, "PABotBase::issue_request_and_wait() - 0");
Expand All @@ -595,6 +595,9 @@ void PABotBase::issue_request_and_wait(
remove_request(iter);
throw CancelledException();
}
if (iter->second.state == AckState::ACKED){
break;
}
}
m_cv.wait(lg);
}
Expand Down
1 change: 1 addition & 0 deletions ClientSource/Connection/PABotBaseConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <memory>
#include <string>
#include <deque>
#include "Common/Compiler.h"
#include "Common/MessageProtocol.h"
#include "ClientSource/Libraries/Compiler.h"
#include "BotBase.h"
Expand Down
1 change: 1 addition & 0 deletions ClientSource/Connection/SerialConnectionWinAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <atomic>
#include <thread>
#include <windows.h>
#include "Common/Compiler.h"
#include "Common/Clientside/Unicode.h"
#include "Common/Clientside/SpinLock.h"
#include "ClientSource/Libraries/Logging.h"
Expand Down
13 changes: 11 additions & 2 deletions ClientSource/Libraries/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ std::string current_time();
class MessageLogger : public MessageSniffer{
public:
MessageLogger(bool log_everything = false)
: m_log_everything(log_everything)
: m_low_everything_owner(false)
, m_log_everything(m_low_everything_owner)
{}
MessageLogger(std::atomic<bool>& log_everything)
: m_low_everything_owner(false)
, m_log_everything(log_everything)
{}


std::atomic<bool> m_log_everything;
virtual void log(std::string msg) override;
virtual void on_send(const BotBaseMessage& message, bool is_retransmit) override;
virtual void on_recv(const BotBaseMessage& message) override;

private:
std::atomic<bool> m_low_everything_owner;
std::atomic<bool>& m_log_everything;
};


Expand Down
2 changes: 1 addition & 1 deletion ClientSource/Programs/BeamReset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void program_BeamReset(const std::string& device_name){
}
pbf_wait(DELAY_BEFORE_RESET);

reset_game_from_home(TOLERATE_SYSTEM_UPDATE_MENU_SLOW, 0, false);
reset_game_from_home(TOLERATE_SYSTEM_UPDATE_MENU_SLOW);
}

end_program_callback();
Expand Down
10 changes: 8 additions & 2 deletions Common/Clientside/SpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include <atomic>
#include <emmintrin.h>
#if _WIN32
#include <intrin.h>
#endif

#include <iostream>
using std::cout;
Expand All @@ -32,6 +34,7 @@ class SpinLock{
}
}
void spin_acquire(const char* label){
#if _WIN32
uint64_t start = __rdtsc();
while (true){
bool state = false;
Expand All @@ -45,6 +48,9 @@ class SpinLock{
start = __rdtsc();
}
}
#else
spin_acquire();
#endif
}

void unlock(){
Expand All @@ -63,7 +69,7 @@ class SpinLockGuard{

SpinLockGuard(SpinLock& lock, const char* label)
: m_lock(lock)
, m_label(label)
// , m_label(label)
{
lock.spin_acquire(label);
}
Expand All @@ -73,7 +79,7 @@ class SpinLockGuard{

private:
SpinLock& m_lock;
const char* m_label;
// const char* m_label;
};


Expand Down
4 changes: 2 additions & 2 deletions Common/Clientside/Unicode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace PokemonAutomation{

const uint32_t MAX_CODEPOINT = 0x10ffff;
const uint32_t REPLACEMENT = 0xfffd;
const char REPLACEMENT_UTF8[] = "\xef\xbf\xbd";

void utf8_skip_to_next_codepoint(const char*& str){
while (true){
Expand Down Expand Up @@ -94,7 +93,8 @@ std::u16string utf8_to_utf16(const std::string& str){

#ifdef _WIN32
std::wstring utf8_to_wstr(const std::string& str){
return std::wstring(str.begin(), str.end());
std::u16string tmp(utf8_to_utf16(str));
return std::wstring(tmp.begin(), tmp.end());
}
#endif

Expand Down
40 changes: 40 additions & 0 deletions Common/Compiler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Compiler Specifics
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/

#ifndef PokemonAutomation_Compiler_H
#define PokemonAutomation_Compiler_H

#include <stddef.h>

namespace PokemonAutomation{



#if 0
#elif _MSC_VER

using ssize_t = ptrdiff_t;

#pragma warning(disable:4100) // Unreferenced Formal Parameter



#elif __GNUC__

#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"


#else
#error "Unsupported Compiler."
#endif




}
#endif
6 changes: 4 additions & 2 deletions Common/MessageProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
// (version / 100) must be the same on both server and client.
// (version % 100) can be higher on server than client.
//
#define PABB_PROTOCOL_VERSION 2021030200
#define PABB_PROTOCOL_VERSION 2021032200

// Program versioning doesn't matter. It's just for informational purposes.
#define PABB_PROGRAM_VERSION 2021031900
#define PABB_PROGRAM_VERSION 2021032200

#define PABB_BAUD_RATE 115200
#define PABB_RETRANSMIT_DELAY_MILLIS 80
Expand Down Expand Up @@ -252,6 +252,7 @@ typedef struct{
////////////////////////////////////////////////////////////////////////////////
// Requests
#define PABB_MSG_SEQNUM_RESET 0x40
// After you send this message, the next seqnum you should use is (seqnum + 1).
typedef struct{
seqnum_t seqnum;
} PABB_PACK pabb_MsgInfoSeqnumReset;
Expand All @@ -277,6 +278,7 @@ typedef struct{
} PABB_PACK pabb_system_clock;

#define PABB_MSG_REQUEST_COMMAND_FINISHED 0x45
// When you receive this message, you must ack it with PABB_MSG_ACK_REQUEST.
typedef struct{
seqnum_t seqnum;
seqnum_t seq_of_original_command;
Expand Down
7 changes: 4 additions & 3 deletions Common/PokemonSwSh/PokemonSwShAutoHosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ void connect_to_internet(
params.connect_to_internet_delay = connect_to_internet_delay;
device.issue_request<PABB_MSG_COMMAND_CONNECT_TO_INTERNET>(params);
}
void home_to_add_friends(uint8_t user_slot, bool fix_cursor){
home_to_add_friends(*global_connection, user_slot, fix_cursor);
void home_to_add_friends(uint8_t user_slot, uint8_t scroll_down, bool fix_cursor){
home_to_add_friends(*global_connection, user_slot, scroll_down, fix_cursor);
}
void home_to_add_friends(BotBase& device, uint8_t user_slot, bool fix_cursor){
void home_to_add_friends(BotBase& device, uint8_t user_slot, uint8_t scroll_down, bool fix_cursor){
pabb_home_to_add_friends params;
params.user_slot = user_slot;
params.scroll_down = scroll_down;
params.fix_cursor = fix_cursor;
device.issue_request<PABB_MSG_COMMAND_HOME_TO_ADD_FRIENDS>(params);
}
Expand Down
25 changes: 21 additions & 4 deletions Common/PokemonSwSh/PokemonSwShAutoHosts.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@
////////////////////////////////////////////////////////////////////////////////
// Universal
#ifdef __cplusplus
void connect_to_internet(uint16_t open_ycomm_delay, uint16_t connect_to_internet_delay);
void home_to_add_friends(uint8_t user_slot, bool fix_cursor);
void connect_to_internet(
uint16_t open_ycomm_delay,
uint16_t connect_to_internet_delay
);
void home_to_add_friends(
uint8_t user_slot,
uint8_t scroll_down,
bool fix_cursor
);
uint16_t accept_FRs(
uint8_t slot, bool fix_cursor,
uint16_t game_to_home_delay_safe,
Expand All @@ -43,8 +50,17 @@ void accept_FRs_while_waiting(
namespace PokemonAutomation{
class BotBase;
}
void connect_to_internet(PokemonAutomation::BotBase& device, uint16_t open_ycomm_delay, uint16_t connect_to_internet_delay);
void home_to_add_friends(PokemonAutomation::BotBase& device, uint8_t user_slot, bool fix_cursor);
void connect_to_internet(
PokemonAutomation::BotBase& device,
uint16_t open_ycomm_delay,
uint16_t connect_to_internet_delay
);
void home_to_add_friends(
PokemonAutomation::BotBase& device,
uint8_t user_slot,
uint8_t scroll_down,
bool fix_cursor
);
uint16_t accept_FRs(
PokemonAutomation::BotBase& device,
uint8_t slot, bool fix_cursor,
Expand Down Expand Up @@ -84,6 +100,7 @@ typedef struct{
typedef struct{
seqnum_t seqnum;
uint8_t user_slot;
uint8_t scroll_down;
bool fix_cursor;
} PABB_PACK pabb_home_to_add_friends;

Expand Down
11 changes: 7 additions & 4 deletions Common/PokemonSwSh/PokemonSwShDateSpam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

using namespace PokemonAutomation;

void home_to_date_time(bool fast){
home_to_date_time(*global_connection, fast);
void home_to_date_time(bool to_date_change, bool fast){
home_to_date_time(*global_connection, to_date_change, fast);
}
void home_to_date_time(BotBase& device, bool fast){
void home_to_date_time(BotBase& device, bool to_date_change, bool fast){
pabb_home_to_date_time params;
params.to_date_change = to_date_change;
params.fast = fast;
device.issue_request<PABB_MSG_COMMAND_HOME_TO_DATE_TIME>(params);
}
Expand Down Expand Up @@ -93,6 +94,7 @@ int register_message_converters_pokemon_date_spam(){
if (body.size() != sizeof(pabb_home_to_date_time)){ ss << "(invalid size)" << std::endl; return ss.str(); }
const auto* params = (const pabb_home_to_date_time*)body.c_str();
ss << "seqnum = " << (uint64_t)params->seqnum;
ss << ", to_date_change = " << params->to_date_change;
ss << ", fast = " << params->fast;
return ss.str();
}
Expand Down Expand Up @@ -153,7 +155,8 @@ int register_message_converters_pokemon_date_spam(){
if (body.size() != sizeof(pabb_rollback_hours_from_home)){ ss << "(invalid size)" << std::endl; return ss.str(); }
const auto* params = (const pabb_rollback_hours_from_home*)body.c_str();
ss << "seqnum = " << (uint64_t)params->seqnum;
ss << ", rollback_year = " << params->settings_to_home_delay;
ss << ", hours = " << params->hours;
ss << ", settings_to_home_delay = " << params->settings_to_home_delay;
return ss.str();
}
);
Expand Down
Loading