Skip to content

Commit

Permalink
Merge branch 'master' into Fix_Monster_Look_Direction
Browse files Browse the repository at this point in the history
  • Loading branch information
NRH-AA authored Feb 5, 2025
2 parents d2f08b2 + b227678 commit c23e13f
Show file tree
Hide file tree
Showing 485 changed files with 6,498 additions and 7,953 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

**Issues addressed:** <!-- Write here the issue number, if any. -->

**How to test:** <!-- Write here how to test changes. -->

<!-- You can safely ignore the links below: -->

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ build/
[Bb]in/
[Oo]bj/
cmake-build-*/
vcpkg_installed/

# MSTest test Results
[Tt]est[Rr]esult*/
Expand Down
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ endif ()

# Find packages.
find_package(OpenSSL 3.0.0 REQUIRED COMPONENTS Crypto)
find_package(ZLIB REQUIRED)

find_package(fmt 8.1.1 CONFIG)
if (NOT fmt_FOUND)
Expand Down Expand Up @@ -105,15 +106,12 @@ add_executable(tfs ${tfs_MAIN})
target_link_libraries(tfs tfslib)

### INTERPROCEDURAL_OPTIMIZATION ###
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT error)
if (result)
set(ENABLE_IPO ON)
set_target_properties(tfs PROPERTIES INTERPROCEDURAL_OPTIMIZATION True)
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else ()
message(STATUS "IPO / LTO not supported: <${error}>")
message(STATUS "IPO is not supported: ${error}")
endif ()
### END INTERPROCEDURAL_OPTIMIZATION ###

Expand Down
6 changes: 0 additions & 6 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ depotPremiumLimit = 15000
questTrackerFreeLimit = 10
questTrackerPremiumLimit = 15

-- World Light
-- NOTE: if defaultWorldLight is set to true the world light algorithm will
-- be handled in the sources. set it to false to avoid conflicts if you wish
-- to make use of the function setWorldLight(level, color)
defaultWorldLight = true

-- Server Save
-- NOTE: serverSaveNotifyDuration in minutes
serverSaveNotifyMessage = true
Expand Down
142 changes: 36 additions & 106 deletions data/cpplinter.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---@class os
---@field mtime fun(): number
os = {}
---@alias os.mtime fun(): number

---@class table
---@field create fun(arrayLength: number, keyLength: number): table
---@field pack fun(...): table
table = {}
---@alias table.create fun(arrayLength: number, keyLength: number): table
---@alias table.pack fun(...): table

---@class rawgetmetatable
---@field __index fun(self: table, key: any): any
Expand Down Expand Up @@ -96,7 +92,6 @@ configManager = {}
---@field createNpc fun(name: string, position: Position, extended?: boolean, force?: boolean, magicEffect?: MagicEffect_t): Npc
---@field createTile fun(position: Position): Tile
---@field createMonsterType fun(name: string): MonsterType
---@field createNpcType fun(name: string): NpcType
---@field startEvent fun(eventName: string): boolean
---@field getClientVersion fun(): string
---@field reload fun(reloadType: number): boolean
Expand Down Expand Up @@ -322,7 +317,7 @@ Podium = {}
---@field setSkull fun(self: Creature, skullType: number)
---@field getOutfit fun(self: Creature): Outfit
---@field setOutfit fun(self: Creature, outfit: Outfit)
---@field getCondition fun(self: Creature, conditionType: number, conditionId?: number, subId?: number): Condition
---@field getCondition fun(self: Creature, conditionType: number): Condition
---@field addCondition fun(self: Creature, condition: Condition)
---@field removeCondition fun(self: Creature, conditionType: number)
---@field hasCondition fun(self: Creature, conditionType: number): boolean
Expand Down Expand Up @@ -394,13 +389,13 @@ Creature = {}
---@field addOfflineTrainingTries fun(self: Player, skill: number, amount: number)
---@field getOfflineTrainingSkill fun(self: Player): number
---@field setOfflineTrainingSkill fun(self: Player, skill: number)
---@field getItemCount fun(self: Player, itemId: number, subType?: number, ignoreEquipped?: boolean): number
---@field getItemCount fun(self: Player, itemId: number): number
---@field getItemById fun(self: Player, itemId: number, subType?: number): Item
---@field getVocation fun(self: Player): Vocation
---@field setVocation fun(self: Player, vocationId: number)
---@field getSex fun(self: Player): number
---@field setSex fun(self: Player, sexId: number)
---@field getTown fun(self: Player): Town
---@field getTown fun(self: Player): number
---@field setTown fun(self: Player, townId: number)
---@field getGuild fun(self: Player): Guild
---@field setGuild fun(self: Player, guild: Guild)
Expand All @@ -419,7 +414,7 @@ Creature = {}
---@field setBankBalance fun(self: Player, balance: number)
---@field addItem fun(self: Player, itemId: number, count?: number): Item
---@field addItemEx fun(self: Player, item: Item, copyItem?: boolean): boolean
---@field removeItem fun(self: Player, itemId: number, count?: number, subtype?: number, ignoreEquipped?: boolean): boolean
---@field removeItem fun(self: Player, itemId: number, count?: number, subtype?: number): boolean
---@field sendSupplyUsed fun(self: Player, item: Item)
---@field getMoney fun(self: Player): number
---@field addMoney fun(self: Player, amount: number)
Expand Down Expand Up @@ -449,10 +444,10 @@ Creature = {}
---@field hasBlessing fun(self: Player, blessingId: number): boolean
---@field addBlessing fun(self: Player, blessingId: number)
---@field removeBlessing fun(self: Player, blessingId: number)
---@field canLearnSpell fun(self: Player, name: string): boolean
---@field learnSpell fun(self: Player, name: string)
---@field forgetSpell fun(self: Player, name: string)
---@field hasLearnedSpell fun(self: Player, name: string): boolean
---@field canLearnSpell fun(self: Player, spellId: number): boolean
---@field learnSpell fun(self: Player, spellId: number)
---@field forgetSpell fun(self: Player, spellId: number)
---@field hasLearnedSpell fun(self: Player, spellId: number): boolean
---@field sendTutorial fun(self: Player, tutorialId: number)
---@field addMapMark fun(self: Player, position: Position, type: number, description?: string)
---@field save fun(self: Player)
Expand Down Expand Up @@ -526,66 +521,6 @@ Monster = {}
---@field getSpectators fun(self: Npc, centerPos: Position, rangeX: number, rangeY: number, multifloor: boolean): table
Npc = {}

---@class NpcType
---@field create fun(): NpcType
---@field name fun(self: NpcType, name?: string): any
---@field setName fun(self: NpcType, name: string): boolean
---@field getName fun(self: NpcType): string
---@field eventType fun(self: NpcType, eventType?: string): any
---@field setEventType fun(self: NpcType, type: string): boolean
---@field getEventType fun(self: NpcType): string
---@field speechBubble fun(self: NpcType, speechBubble?: number): any
---@field setSpeechBubble fun(self: NpcType, bubble: number): boolean
---@field getSpeechBubble fun(self: NpcType): number
---@field walkInterval fun(self: NpcType, interval?: number): any
---@field setWalkInterval fun(self: NpcType, interval: number): boolean
---@field getWalkInterval fun(self: NpcType): number
---@field walkSpeed fun(self: NpcType, speed?: number): any
---@field setWalkSpeed fun(self: NpcType, speed: number): boolean
---@field getWalkSpeed fun(self: NpcType): number
---@field spawnRadius fun(self: NpcType, radius?: number): any
---@field setSpawnRadius fun(self: NpcType, radius: number): boolean
---@field getSpawnRadius fun(self: NpcType): number
---@field floorChange fun(self: NpcType, floorChange?: boolean): any
---@field setFloorChange fun(self: NpcType, floorChange: boolean): boolean
---@field getFloorChange fun(self: NpcType): boolean
---@field attackable fun(self: NpcType, attackable?: boolean): any
---@field setAttackable fun(self: NpcType, attackable: boolean): boolean
---@field getAttackable fun(self: NpcType): boolean
---@field ignoreHeight fun(self: NpcType, ignoreHeight?: boolean): any
---@field setIgnoreHeight fun(self: NpcType, ignoreHeight: boolean): boolean
---@field getIgnoreHeight fun(self: NpcType): boolean
---@field isIdle fun(self: NpcType, isIdle?: boolean): any
---@field setIsIdle fun(self: NpcType, isIdle: boolean): boolean
---@field getIsIdle fun(self: NpcType): boolean
---@field pushable fun(self: NpcType, pushable?: boolean): any
---@field setPushable fun(self: NpcType, pushable: boolean): boolean
---@field getPushable fun(self: NpcType): boolean
---@field outfit fun(self: NpcType, outfit?: Outfit|table): any
---@field setOutfit fun(self: NpcType, outfit: Outfit): boolean
---@field getOutfit fun(self: NpcType): Outfit
---@field parameters fun(self: NpcType, key?: any, value?: any): any
---@field setParameters fun(self: NpcType, key: any, value: any): boolean
---@field getParameters fun(self: NpcType, key: any): table
---@field health fun(self: NpcType, health?: number): any
---@field setHealth fun(self: NpcType, health: number): boolean
---@field getHealth fun(self: NpcType): number
---@field maxHealth fun(self: NpcType, maxHealth?: number): any
---@field setMaxHealth fun(self: NpcType, maxHealth: number): boolean
---@field getMaxHealth fun(self: NpcType): number
---@field sight fun(self: NpcType, x?: number, y?: number): number?, number?
---@field setSight fun(self: NpcType, x: number, y: number)
---@field getSight fun(self: NpcType): number, number
---@field onSay fun(self: NpcType, callback: function)
---@field onDisappear fun(self: NpcType, callback: function)
---@field onAppear fun(self: NpcType, callback: function)
---@field onMove fun(self: NpcType, callback: function)
---@field onPlayerCloseChannel fun(self: NpcType, callback: function)
---@field onPlayerEndTrade fun(self: NpcType, callback: function)
---@field onThink fun(self: NpcType, callback: function)
---@field onSight fun(self: NpcType, callback: function)
NpcType = {}

---@class Guild
---@field create fun(): Guild
---@field __eq fun(self: Guild, other: Guild): boolean
Expand Down Expand Up @@ -783,18 +718,19 @@ Combat = {}
Condition = {}

---@class Outfit
---@field lookType number|nil
---@field lookHead number|nil
---@field lookBody number|nil
---@field lookLegs number|nil
---@field lookFeet number|nil
---@field lookAddons number|nil
---@field lookMount number|nil
---@field lookMountHead number|nil
---@field lookMountBody number|nil
---@field lookMountLegs number|nil
---@field lookMountFeet number|nil
---@field lookTypeEx number|nil
---@field create fun(): Outfit
---@field lookType number
---@field lookHead number
---@field lookBody number
---@field lookLegs number
---@field lookFeet number
---@field lookAddons number
---@field lookMount number
---@field lookMountHead number
---@field lookMountBody number
---@field lookMountLegs number
---@field lookMountFeet number
---@field lookTypeEx number
Outfit = {}

---@class MonsterType
Expand Down Expand Up @@ -1002,6 +938,7 @@ TalkAction = {}
---@field register fun(self:CreatureEvent):boolean
---@field onLogin fun(player:Player):boolean
---@field onLogout fun(player:Player):boolean
---@field onReconnect fun(player:Player)
---@field onThink fun(creature:Creature, interval:integer):boolean
---@field onPrepareDeath fun(creature:Creature, killer:Creature):boolean
---@field onDeath fun(creature:Creature, corpse:Item, killer:Creature, mostDamageKiller:Creature, lastHitUnjustified:boolean, mostDamageUnjustified:boolean):boolean
Expand Down Expand Up @@ -1309,8 +1246,7 @@ function isScriptsInterface() end
---@alias isScriptsInterface fun(): boolean

function getNpcCid() end
function selfSay(message, player, talkType) end
---@alias selfSay fun(message: string, player?: number, talkType?: number)
function selfSay(message, player) end
function selfMove(direction) end
function selfMoveTo(...) end
function selfTurn(direction) end
Expand All @@ -1319,7 +1255,7 @@ function getDistanceTo(creature) end
function doNpcSetCreatureFocus(creature) end
function getNpcParameter(key) end
function openShopWindow(shopWindow) end
function closeShopWindow(player) end
function closeShopWindow() end
function doSellItem(item) end

storages = {}
Expand Down Expand Up @@ -2192,16 +2128,15 @@ configKeys = {
YELL_ALLOW_PREMIUM = 27,
PREMIUM_TO_SEND_PRIVATE = 28,
FORCE_MONSTERTYPE_LOAD = 29,
DEFAULT_WORLD_LIGHT = 30,
HOUSE_OWNED_BY_ACCOUNT = 31,
CLEAN_PROTECTION_ZONES = 32,
HOUSE_DOOR_SHOW_PRICE = 33,
ONLY_INVITED_CAN_MOVE_HOUSE_ITEMS = 34,
REMOVE_ON_DESPAWN = 35,
TWO_FACTOR_AUTH = 36,
MANASHIELD_BREAKABLE = 37,
CHECK_DUPLICATE_STORAGE_KEYS = 38,
MONSTER_OVERSPAWN = 39,
HOUSE_OWNED_BY_ACCOUNT = 30,
CLEAN_PROTECTION_ZONES = 31,
HOUSE_DOOR_SHOW_PRICE = 32,
ONLY_INVITED_CAN_MOVE_HOUSE_ITEMS = 33,
REMOVE_ON_DESPAWN = 34,
TWO_FACTOR_AUTH = 35,
MANASHIELD_BREAKABLE = 36,
CHECK_DUPLICATE_STORAGE_KEYS = 37,
MONSTER_OVERSPAWN = 38,

-- ConfigKeysString
MAP_NAME = 0,
Expand Down Expand Up @@ -2432,11 +2367,6 @@ GAME_STATE_SHUTDOWN = 4
GAME_STATE_CLOSING = 5
GAME_STATE_MAINTAIN = 6

BUG_CATEGORY_MAP = 0
BUG_CATEGORY_TYPO = 1
BUG_CATEGORY_TECHNICAL = 2
BUG_CATEGORY_OTHER = 3

REPORT_TYPE_NAME = 0
REPORT_TYPE_STATEMENT = 1
REPORT_TYPE_BOT = 2
Expand Down
4 changes: 2 additions & 2 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ function Player:onReportRuleViolation(targetName, reportType, reportReason, comm
end
end

function Player:onReportBug(message, position, category)
function Player:onReportBug(message, position)
if hasEvent.onReportBug then
return Event.onReportBug(self, message, position, category)
return Event.onReportBug(self, message, position)
end
return true
end
Expand Down
64 changes: 8 additions & 56 deletions data/lib/compat/compat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,50 +132,6 @@ do
rawgetmetatable("Action").__newindex = ActionNewIndex
end

do
local function NpcTypeNewIndex(self, key, value)
if key == "onSay" then
self:eventType("say")
self:onSay(value)
return
elseif key == "onDisappear" then
self:eventType("disappear")
self:onDisappear(value)
return
elseif key == "onAppear" then
self:eventType("appear")
self:onAppear(value)
return
elseif key == "onMove" then
self:eventType("move")
self:onMove(value)
return
elseif key == "onPlayerCloseChannel" then
self:eventType("closechannel")
self:onPlayerCloseChannel(value)
return
elseif key == "onPlayerEndTrade" then
self:eventType("endtrade")
self:onPlayerEndTrade(value)
return
elseif key == "onThink" then
self:eventType("think")
self:onThink(value)
return
elseif key == "onSight" then
self:eventType("sight")
self:onSight(value)
return
elseif key == "onSpeechBubble" then
self:eventType("speechbubble")
self:onSpeechBubble(value)
return
end
rawset(self, key, value)
end
rawgetmetatable("NpcType").__newindex = NpcTypeNewIndex
end

do
local function TalkActionNewIndex(self, key, value)
if key == "onSay" then
Expand All @@ -197,6 +153,10 @@ do
self:type("logout")
self:onLogout(value)
return
elseif key == "onReconnect" then
self:type("reconnect")
self:onReconnect(value)
return
elseif key == "onThink" then
self:type("think")
self:onThink(value)
Expand Down Expand Up @@ -632,6 +592,8 @@ function isPremium(cid) local p = Player(cid) return p and p:isPremium() or fals

STORAGEVALUE_EMPTY = -1
function Player:getStorageValue(key)
print("[Warning - " .. debug.getinfo(2).source:match("@?(.*)") .. "] Invoking Creature:getStorageValue will return nil to indicate absence in the future. Please update your scripts accordingly.")

local v = Creature.getStorageValue(self, key)
return v or STORAGEVALUE_EMPTY
end
Expand Down Expand Up @@ -706,19 +668,9 @@ function getPlayerGUIDByName(name)
end
return 0
end
function getAccountNumberByPlayerName(name)
local player = Player(name)
if player then
return player:getAccountId()
end

local resultId = db.storeQuery("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(name))
if resultId then
local accountId = result.getNumber(resultId, "account_id")
result.free(resultId)
return accountId
end
return 0
function getAccountNumberByPlayerName(name)
return Game.getPlayerAccountId(name)
end

getPlayerAccountBalance = getPlayerBalance
Expand Down
Loading

0 comments on commit c23e13f

Please sign in to comment.