Skip to content

Commit

Permalink
Merge branch 'main' into dudantas/change-while-to-std-erase-if
Browse files Browse the repository at this point in the history
  • Loading branch information
murilo09 authored Dec 31, 2024
2 parents 1b5cf00 + 0091ce1 commit c926adf
Show file tree
Hide file tree
Showing 1,132 changed files with 47,716 additions and 34,155 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ jobs:
with:
install: true

- name: Cache Docker layers
uses: actions/cache@main
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-x86-${{ github.sha }}
restore-keys: |
${{ runner.os }}-x86-
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -109,14 +101,6 @@ jobs:
with:
install: true

- name: Cache Docker layers
uses: actions/cache@main
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-arm-${{ github.sha }}
restore-keys: |
${{ runner.os }}-arm-
- name: Build
uses: docker/[email protected]
with:
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ endif()
# *****************************************************************************
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

# Configure build options for compatibility with commodity CPUs
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64 -mtune=generic -mno-avx -mno-sse4")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=x86-64 -mtune=generic -mno-avx -mno-sse4")
endif()

# *****************************************************************************
# Include cmake tools
# *****************************************************************************
Expand Down
74 changes: 74 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributing to Canary

Thank you for your interest in contributing to Canary! This document provides guidelines for contributing to the project to ensure a smooth and effective collaboration.

## Code of Conduct

This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/opentibiabr/canary/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at email: [email protected] or discord: https://discord.com/invite/gvTj5sh9Mp

## Project Roadmap

- The Canary project is part of a larger ecosystem within the Open Tibia BR organization, which includes various projects focused on enhancing and innovating within OT server development. You can follow our shared roadmap, encompassing projects like Canary, OTServBR, and OTServBR-Global, among others, in the projects section on GitHub: [Open Tibia BR - Project Roadmap](https://github.com/orgs/opentibiabr/projects).

- This roadmap aims to ensure alignment of initiatives and prioritize the development of improvements and new features that benefit the community. Community participation is crucial, and we encourage contributors to review the roadmap before proposing major changes, to ensure these align with the strategic direction of our projects.


## Getting Started

### Issues

- **Bug Reports**: If you encounter any bugs or issues while using Canary, please submit them via our [bug report template](https://github.com/opentibiabr/canary/blob/main/.github/ISSUE_TEMPLATE/bug.yaml).
- **Feature Requests**: If you have any ideas for features or enhancements, you can submit them through our [feature request template](https://github.com/opentibiabr/canary/blob/main/.github/ISSUE_TEMPLATE/request.yaml).

Please provide as much relevant information as possible, including logs, screenshots, or other details to help the team understand the problem or your request.

### Pull Requests

To contribute code to the project, please follow these guidelines:

1. **Fork the Repository**: Fork the Canary repository and create your own branch to make changes.
2. **Follow the Style Guides**: The project uses **Clang Format** for C++ and **Lua Format** for Lua scripts. It is important that your code follows these styles. We use GitHub Actions (GHA) for formatting checks, so make sure to format your code properly before submitting.
3. **No Complex Lua Scripts**: Contributions involving Lua scripts should focus on simple and efficient implementations. Performance-heavy features should be implemented in C++, and contributions that introduce overly complex Lua scripts may be rejected in favor of a C++ implementation.
4. **Database Standards**: We use an advanced key/value system for data storage called "KV System." We do not accept new tables in the MySQL database. All persistent data must be integrated using the KV system, which includes a protobuf-based abstraction for performance and integration. Please refer to the [KV System README](https://github.com/opentibiabr/canary/blob/main/src/kv/README.md) for more information.
5. **PR Guidelines**: Use our [Pull Request Template](https://github.com/opentibiabr/canary/blob/main/.github/PULL_REQUEST_TEMPLATE.md) when submitting a pull request. Ensure your PR:
- Follows the project coding standards.
- Contains relevant descriptions and details about the changes.
- Respects project maintainers' decisions. Some contributions may not be merged immediately or might be rejected due to internal project priorities.
6. **Do Not Use Legacy Storage System**: Pull requests that introduce new features using the legacy storage system will not be accepted. Contributors must adopt the "KV System" to ensure compatibility with our modern approach.

## Development Standards

### Code Quality
- Follow modern C++20+ standards when contributing to the codebase.
- Ensure that your code is well-documented. Comments should be in English, and special attention should be given to areas that are hard to understand.

### Formatting and Style
- **C++**: Code must be formatted with **Clang Format** according to the project's style configuration.
- **Lua**: Scripts must follow the formatting provided by **Lua Format**.

We recommend using the provided GitHub Actions to validate the formatting before submitting any pull requests.

## Communication

Please use a respectful and welcoming tone when communicating with others. We aim to foster a positive and friendly community, so be mindful of others' perspectives and experiences.

If you need to reach out to project maintainers for any assistance or inquiries, feel free to contact us at [email protected].

## Review Process

- Pull requests will be reviewed by the project maintainers. Please be patient, as it may take some time to get feedback.
- Contributors must be prepared for their PRs to be modified or even rejected. Reasons for this include internal priorities, a need for better performance, or violations of contribution guidelines.

## Best Practices
- Respect the project standards and guidelines.
- Make small, focused pull requests, as it makes the review process easier.
- Write tests where possible to ensure that your changes do not introduce new issues.
- Provide clear descriptions in your commits and pull requests.
- Ensure that new features are properly integrated with existing systems.

## Advanced Contribution
- **Complex Systems**: For features that impact performance or require deeper integrations, discuss them with the maintainers before implementation.
- **KV System Usage**: All persistent data should leverage the KV system. It allows for efficient data mapping, storing complex structures seamlessly. Learn more about the KV system [here](https://github.com/opentibiabr/canary/blob/main/src/kv/README.md).

Thank you for your contributions and for helping make Canary better!

1 change: 1 addition & 0 deletions cmake/modules/BaseConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ endif()
# cmake -DDEBUG_LOG=ON ..
if(DEBUG_LOG)
add_definitions(-DDEBUG_LOG=ON)
add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
log_option_enabled("DEBUG LOG")
else()
log_option_disabled("DEBUG LOG")
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/CanaryLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ target_include_directories(${PROJECT_NAME}_lib
${GMP_INCLUDE_DIRS}
${LUAJIT_INCLUDE_DIRS}
${PARALLEL_HASHMAP_INCLUDE_DIRS}
${ATOMIC_QUEUE_INCLUDE_DIRS}
)

# *****************************************************************************
Expand Down
11 changes: 7 additions & 4 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ coreDirectory = "data"

-- Set log level
-- It can be trace, debug, info, warning, error, critical, off (default: info).
-- NOTE: Will only display logs with level higher or equal the one set.
-- NOTE: It will only be valid after the server starts up and only display logs with level higher or equal the one set.
-- NOTE: Debug and trace logs are only available if compiled in debug mode.
logLevel = "info"

--- Toggles the server's maintenance mode.
Expand Down Expand Up @@ -52,7 +53,7 @@ cleanProtectionZones = false
-- Connection Config
-- NOTE: allowOldProtocol can allow login on 10x protocol. (11.00)
-- NOTE: maxPlayers set to 0 means no limit
-- NOTE: MaxPacketsPerSeconds if you change you will be subject to bugs by WPE, keep the default value of 25,
-- NOTE: MaxPacketsPerSeconds if you change you will be subject to bugs by WPE, keep the default value of 25,
-- It's recommended to use a range like min 50 in this function, otherwise you will be disconnected after equipping two-handed distance weapons.
ip = "127.0.0.1"
allowOldProtocol = false
Expand Down Expand Up @@ -145,7 +146,7 @@ forgeAmountMultiplier = 3
forgeMinSlivers = 3
forgeMaxSlivers = 7
forgeInfluencedLimit = 300
forgeFiendishLimit = 3
forgeFiendishLimit = 4
forgeFiendishIntervalType = "hour"
forgeFiendishIntervalTime = "1"

Expand Down Expand Up @@ -343,9 +344,11 @@ Setting this to false may pose risks; if a house is abandoned and contains a lar
]]
-- Periods: daily/weekly/monthly/yearly/never
-- Base: sqm,rent,sqm+rent
toggleCyclopediaHouseAuction = true
daysToCloseBid = 7
housePriceRentMultiplier = 0.0
housePriceEachSQM = 1000
houseRentPeriod = "never"
houseRentPeriod = "monthly"
houseRentRate = 1.0
houseOwnedByAccount = false
houseBuyLevel = 100
Expand Down
3 changes: 0 additions & 3 deletions data-canary/migrations/0.lua

This file was deleted.

5 changes: 0 additions & 5 deletions data-canary/migrations/1.lua

This file was deleted.

45 changes: 45 additions & 0 deletions data-canary/migrations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Database Migration System

This document provides an overview of the current database migration system for the project. The migration process has been streamlined to ensure that all migration scripts are automatically applied in order, making it easier to maintain database updates.

## How It Works

The migration system is designed to apply updates to the database schema or data whenever a new server version is started. Migration scripts are stored in the `migrations` directory, and the system will automatically apply any scripts that have not yet been executed.

### Steps Involved

1. **Retrieve Current Database Version**:
- The system first retrieves the current version of the database using `getDatabaseVersion()`.
- This version is used to determine which migration scripts need to be executed.

2. **Migration Files Directory**:
- All migration scripts are stored in the `migrations` directory.
- Each migration script is named using a numerical pattern, such as `1.lua`, `2.lua`, etc.
- The naming convention helps determine the order in which scripts should be applied.

3. **Execute Migration Scripts**:
- The migration system iterates through the migration directory and applies each migration script that has a version greater than the current database version.
- Only scripts that have not been applied are executed.
- The Lua state (`lua_State* L`) is initialized to run each script.

4. **Update Database Version**:
- After each migration script is successfully applied, the system updates the database version to reflect the applied change.
- This ensures that the script is not re-applied on subsequent server startups.

## Example Migration Script

Below is an example of what a migration script might look like. Note that no return value is required, as all migration files are applied based on the current database version.

```lua
-- Migration script example (for documentation purposes only)
-- This migration script should include all necessary SQL commands or operations to apply a specific update to the database.

-- Example: Adding a new column to the "players" table
local query = [[
ALTER TABLE players ADD COLUMN new_feature_flag TINYINT(1) NOT NULL DEFAULT 0;
]]

-- Execute the query
db.execute(query) -- This function executes the given SQL query on the database.

-- Note: Ensure that queries are validated to avoid errors during the migration process.
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/apocalypse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/apprentice_sheng.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/bazir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/black_knight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/bullwark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/custodian.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/dharalion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
14 changes: 0 additions & 14 deletions data-canary/monster/bosses/shadowpelt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,4 @@ monster.immunities = {
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
2 changes: 2 additions & 0 deletions data-canary/scripts/actions/objects/imbuement_shrine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ function imbuement.onUse(player, item, fromPosition, target, toPosition, isHotke
return true
end

imbuement:position({ x = 1943, y = 1340, z = 7 }, 25061)

imbuement:id(25060, 25061, 25103, 25104, 25202, 25174, 25175, 25182, 25183)
imbuement:register()
Loading

0 comments on commit c926adf

Please sign in to comment.