Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Party shared_ptr instead of raw pointers #4687

Closed
wants to merge 74 commits into from

Conversation

ramon-bernardo
Copy link
Contributor

@ramon-bernardo ramon-bernardo commented May 16, 2024

Pull Request Prelude

Changes Proposed

  • Replace party raw pointers with shared_ptr.
  • Use auto and const auto, at all, when possible.

src/events.cpp Show resolved Hide resolved
src/game.cpp Show resolved Hide resolved
EvilHero90 and others added 15 commits May 16, 2024 21:39
- checking now if param 2 is not a number, incase that's true we tell that the player does not exist
- added another check which actually looks if the player is valid before comparing any names
…land#4686)

* Replace deprecated asio functions

* Bump minimal Boost version
* added request resource balance

* pr comments
* Update workflow actions, trigger builds on workflow update

* Fix artifact naming
* doubling the vartrack size

Increasing the max-vartrack-size because luascript.cpp has a function which exceeded the limit and thus the build failed
* Refactor Docker image workflow with docker actions
* Don't install libiconv outside OSX, install Lua by default
@@ -564,8 +563,7 @@ ChatChannel* Chat::getChannel(const Player& player, uint16_t channelId)
}

case CHANNEL_PARTY: {
Party* party = player.getParty();
if (party) {
if (const auto& party = player.getParty()) {
Copy link
Contributor

@Codinablack Codinablack May 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been my experience that declaring a variable and checking it at same time inside the if statement causes crashes. I'm sure this isn't true in all cases, but I'm just stating what has been my experience so far.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so? It's equivalent other than the scoping (which would cause compilation errors, not crashes)

Would be interesting to see a form of reproduction though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an example you can use to reproduce. I will contact you about it on discord.

glecko and others added 6 commits May 26, 2024 00:03
* Use Guild shared_ptr

* Member rank level default to constexpr

* Use const when possible

* @ramon-bernardo
Use const when possible

* Use shared_ptr alias

* Fix

* Fix

* Fix

* Fix

* Fix delete

* Fix

* No need to reuse the variable

* Use const shared ptr

* Use const& ptr

* Inline rank check
* Split game core into different files

* eof
danyelvarejao and others added 29 commits June 7, 2024 01:25
* Fix some warnings and improve type annotations

* Fix `item:transform` type annotation

* Remove `dump` function from compat.lua

* Fix `configKeys` type annotations

* Refactor all enums/constants of `cpplinter.lua` and fix ident style to tabs

Some were missing and others were wrong, I got them all directly from the source.

* Refactor the PlayerFlag constants in cpplinter.lua to use bitwise shift operators instead of exponentiation
* Moved everything to NpcScriptInterface

There was an issue with the Revisioned Npc System.
Because it was included in 2 different lua environments it would not correctly work on any of the cmake builds only the msvc builds worked fine (they somehow have shared lua envs)
Now the npcs should correctly work as it's expected
Moved all std::vector out of the pointer class itself and put them into their singleton classes (Actions/MoveEvents)
They're now stored in a std::map map by their pointer as a std::vector and once it is registered it clears the std::map with the pointer index.
- checking first if the pointer has a map (is valid) before trying to get it's content
this sets NULL default for session tokens, just for safety
Add monster icons correctly when creature appears on the screen
- Added `onSight` event, this has to be enabled with `NpcType:sight(x, y)` unless that is not set the event wont fire. This event triggers whenever a creature (monsters/npcs/players) steps into the sight range, will only re trigger once you walk out of idle range and back in again.
- fixed event callbacks, they're now moved into `NpcCallbacks` they can be set like: `NpcType:callbacks().onSay/onSight/etc.`
- fixed a crash which could occur if you had a npc disabled then enabled him and /reload npcs, this is now fixed
- fixed a crash that if a xml npc is invalid on server startup that it throws an error instead of crashing
- made all the functions in the lib overloadable, only the table data is protected, you can now change functions and they will be correctly changed on /reload npcs
- changed everything related to focus from seconds into ms
- changed focus so it works for all creatures not only players
- changed NpcTalkQueue it now works for creatures not only for players
- changed the onCreatureSay event, it now triggers for all creatures not only for players
- selfSay has a new parameter now called talkType which is optional and falls back to TALKTYPE_SAY
- added `onSpeechBubble` event, with this we can set the speech bubble for each player individual.
example:
Npc has a quest for the player he only shows for this player the quest speech bubble, once the quest is finished the npc wont have a quest speech bubble anymore

---------

Co-authored-by: Evil Puncker <[email protected]>
Co-authored-by: KrecikOnDexin <[email protected]>
* Remove Account class and account.h file

* Update theforgottenserver.vcxproj
Set the correct chance for ice mammoth sculpting.

* Use stats from tibia-stats research (bigger sample size)
was constant 650, now it's 65–350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Increase or improvement in quality, value, or extent
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.