Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed Nov 2, 2023
1 parent d6678bc commit 6ec6726
Show file tree
Hide file tree
Showing 43 changed files with 697 additions and 548 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Create and Upload Artifact
uses: actions/upload-artifact@main
with:
name: canary-${{ matrix.os }}-${{ matrix.buildtype }}-${{ github.sha }}
name: otxserver-${{ matrix.os }}-${{ matrix.buildtype }}-${{ github.sha }}
path: |
${{ github.workspace }}/build/${{ matrix.buildtype }}/bin/
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/clean-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Cleanup caches by a branch
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R "$REPO" -B "$BRANCH" -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
4 changes: 2 additions & 2 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ CREATE TABLE IF NOT EXISTS `players` (
`skill_manaleech_amount` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`manashield` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
`max_manashield` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
`xpboost_stamina` smallint(5) DEFAULT NULL,
`xpboost_value` tinyint(4) DEFAULT NULL,
`xpboost_stamina` smallint(5) UNSIGNED DEFAULT NULL,
`xpboost_value` tinyint(4) UNSIGNED DEFAULT NULL,
`marriage_status` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`marriage_spouse` int(11) NOT NULL DEFAULT '-1',
`bonus_rerolls` bigint(21) NOT NULL DEFAULT '0',
Expand Down
16 changes: 7 additions & 9 deletions src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ CanaryServer::CanaryServer(
) :
logger(logger),
rsa(rsa),
serviceManager(serviceManager),
loaderUniqueLock(loaderLock) {
serviceManager(serviceManager) {
logInfos();
toggleForceCloseButton();
g_game().setGameState(GAME_STATE_STARTUP);
Expand Down Expand Up @@ -93,27 +92,26 @@ int CanaryServer::run() {

g_webhook().sendMessage("Server is now online", "Server has successfully started.", WEBHOOK_COLOR_ONLINE);

loaderDone = true;
loaderSignal.notify_all();
loaderStatus = LoaderStatus::LOADED;
} catch (FailedToInitializeCanary &err) {
loadFailed = true;
loaderStatus = LoaderStatus::FAILED;
logger.error(err.what());

logger.error("The program will close after pressing the enter key...");

if (isatty(STDIN_FILENO)) {
getchar();
}

loaderSignal.notify_all();
}

loaderStatus.notify_one();
},
"CanaryServer::run"
);

loaderSignal.wait(loaderUniqueLock, [this] { return loaderDone || loadFailed; });
loaderStatus.wait(LoaderStatus::LOADING);

if (loadFailed || !serviceManager.is_running()) {
if (loaderStatus == LoaderStatus::FAILED || !serviceManager.is_running()) {
logger.error("No services running. The server is NOT online!");
shutdown();
return EXIT_FAILURE;
Expand Down
15 changes: 7 additions & 8 deletions src/canary_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ class CanaryServer {
int run();

private:
enum class LoaderStatus : uint8_t {
LOADING,
LOADED,
FAILED
};

RSA &rsa;
Logger &logger;
ServiceManager &serviceManager;

std::mutex loaderLock;
std::condition_variable loaderSignal;
std::condition_variable mapSignal;
std::unique_lock<std::mutex> loaderUniqueLock;
std::string threadFailMsg;

bool loaderDone = false;
bool loadFailed = false;
std::atomic<LoaderStatus> loaderStatus = LoaderStatus::LOADING;

void logInfos();
static void toggleForceCloseButton();
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ void Combat::addDistanceEffect(std::shared_ptr<Creature> caster, const Position

void Combat::doChainEffect(const Position &origin, const Position &dest, uint8_t effect) {
if (effect > 0) {
std::forward_list<Direction> dirList;
stdext::arraylist<Direction> dirList(128);
FindPathParams fpp;
fpp.minTargetDist = 0;
fpp.maxTargetDist = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/creatures/combat/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ bool ConditionFeared::getFleeDirection(std::shared_ptr<Creature> creature) {
return false;
}

bool ConditionFeared::getFleePath(std::shared_ptr<Creature> creature, const Position &pos, std::forward_list<Direction> &dirList) {
bool ConditionFeared::getFleePath(std::shared_ptr<Creature> creature, const Position &pos, stdext::arraylist<Direction> &dirList) {
const std::vector<uint8_t> walkSize { 15, 9, 3, 1 };
bool found = false;
std::ptrdiff_t found_size = 0;
Expand Down Expand Up @@ -2030,7 +2030,7 @@ bool ConditionFeared::startCondition(std::shared_ptr<Creature> creature) {

bool ConditionFeared::executeCondition(std::shared_ptr<Creature> creature, int32_t interval) {
Position currentPos = creature->getPosition();
std::forward_list<Direction> listDir;
stdext::arraylist<Direction> listDir(128);

g_logger().debug("[ConditionFeared::executeCondition] Executing condition, current position is {}", currentPos.toString());

Expand All @@ -2040,7 +2040,7 @@ bool ConditionFeared::executeCondition(std::shared_ptr<Creature> creature, int32
}

if (getFleePath(creature, currentPos, listDir)) {
g_dispatcher().addEvent(std::bind(&Game::forcePlayerAutoWalk, &g_game(), creature->getID(), listDir), "ConditionFeared::executeCondition");
g_dispatcher().addEvent(std::bind(&Game::forcePlayerAutoWalk, &g_game(), creature->getID(), listDir.data()), "ConditionFeared::executeCondition");
g_logger().debug("[ConditionFeared::executeCondition] Walking Scheduled");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/condition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class ConditionFeared final : public Condition {
private:
bool canWalkTo(std::shared_ptr<Creature> creature, Position pos, Direction moveDirection) const;
bool getFleeDirection(std::shared_ptr<Creature> creature);
bool getFleePath(std::shared_ptr<Creature> creature, const Position &pos, std::forward_list<Direction> &dirList);
bool getFleePath(std::shared_ptr<Creature> creature, const Position &pos, stdext::arraylist<Direction> &dirList);
bool getRandomDirection(std::shared_ptr<Creature> creature, Position pos);
bool isStuck(std::shared_ptr<Creature> creature, Position pos) const;

Expand Down
Loading

0 comments on commit 6ec6726

Please sign in to comment.