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
Core/AreaTrigger : Basic areaTrigger entities system #17997
Conversation
wow. |
|
||
public: | ||
// Called when the AreaTrigger has just been created | ||
void OnCreate(AreaTrigger* areaTrigger) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't all of these be virtual void? sorry if it's a dumb question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a dumb question, you were right :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, make Travis happy, use/*areaTrigger*/
/*unit*/
and /*diff*/
:D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but all together, amazing job ^^
…into areatrigger_template
@@ -2297,6 +2305,9 @@ class TC_GAME_API Unit : public WorldObject | |||
typedef std::list<GameObject*> GameObjectList; | |||
GameObjectList m_gameObj; | |||
|
|||
typedef std::list<AreaTrigger*> AreaTriggerList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vector is prefered i think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, DEFINITELY use a vector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well Unit::_UnregisterAreaTrigger use the .remove function, which is lacking in std::vector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_areaTrigger.erase(std::remove(m_areaTrigger.begin(), m_areaTrigger.end(), areaTrigger));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shauren erasing twice will cause out of range exception :) either .erase and provide an iterator, or std::remove. std::remove will give you a past-end iterator, so if you call .erase with that, it will crash the server. maybe you wanted std::find() instead of std::remove()?
Also, I suggest making a for through m_areaTriggers on WorldSession::LogoutPlayer, and calling Remove() function for all of them. All other objects get deleted before logging out, except AreaTriggers. this also caused crashes for me (though not on logout, but on login, Map::Update() tried to call _UnregisterAreaTrigger, but it wasn't in m_areaTriggers, so it got invalid itr, and crashed.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matukaa std::remove
does not remove the element from container. It moves it to the end of it and gives you iterator pointing to it (more precisely, past the end of unerased elements = first erased one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shauren I understand, thanks for clarification :) although m_areaTrigger.erase(std::find()) should also work, no? (completely offtopic)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
`data5` float NOT NULL DEFAULT '0', | ||
`scriptName` char(64) NOT NULL DEFAULT '', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=MyISAM DEFAULT CHARSET=utf8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#17976 (comment) applies here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't the comment about using MyISAM ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, i cant read, ignore it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UpperCamelCase style for columns since all new fields are named so
default uint32 type is int(10) unsigned
add a VerifiedBuild field for tables that have sniffable content
great work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Replace self invented techniques by G3D methods.
- Add script swap hook
- Replace list -> vector
@@ -0,0 +1,41 @@ | |||
CREATE TABLE `areatrigger_template` ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the table before creating it please (same in the create statement below)
|
||
m_valuesCount = AREATRIGGER_END; | ||
_dynamicValuesCount = AREATRIGGER_DYNAMIC_END; | ||
|
||
_areaTriggerTemplate = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize this in L32 after _timeSinceCreated
please (_areaTriggerTemplate(nullptr)
).
float tempX = vertice.VerticeX; | ||
float tempY = vertice.VerticeY; | ||
|
||
vertice.VerticeX = tempX * angleCos - tempY * angleSin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no rotation implementation you could use from G3D?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not found any, but I'm open to suggestions.
|
||
void AreaTrigger::SearchUnitInSphere() | ||
{ | ||
std::list<Unit*> targetList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Shauren said already: list -> vector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think UnitListSearcher only accept std::list at this time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right, leave it for now as it is, the searchers probably need an overall refactoring...
Trinity::UnitListSearcher<Trinity::AnyUnitInObjectRangeCheck> searcher(this, targetList, check); | ||
VisitNearbyObject(GetTemplate()->MaxSearchRadius, searcher); | ||
|
||
float halfExtentsX = extentsX / 2.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of the box seems legit however G3D offers this implementation already through AABox
, you could use:
AABox box({x_low, y_low, z_low}, {x_high, y_high, z_high});
...
box.contains({x, y, z});
instead.
@@ -96,6 +96,10 @@ template<> | |||
struct is_script_database_bound<AchievementCriteriaScript> | |||
: std::true_type { }; | |||
|
|||
template<> | |||
struct is_script_database_bound<AreaTriggerEntityScript> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AreaTriggerEntityScript
also needs a specialization of ScriptRegistrySwapHooks
to be swapped correctly when using script hotswapping (otherwise it will cause crashes because unloaded scripts are not cleaned up and will still be referenced).
If you can't make it specialize it as:
template<typename Base>
class ScriptRegistrySwapHooks<AreaTriggerEntityScript, Base>
: public UnsupportedScriptRegistrySwapHooks<Base> { };
and I will take care of it before it gets merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review, i will take a look :)
I suppose i have to do the same thing for SceneScript ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good catch. It has to be done for every database bound script (scripts that use scriptnames in the database).
Should IDs be used instead to avoid dangling pointers in AreaTriggerList? |
# Conflicts: # src/server/game/Accounts/RBAC.h # src/server/game/Globals/ObjectMgr.cpp # src/server/game/Globals/ObjectMgr.h # src/server/game/Scripting/ScriptMgr.cpp # src/server/game/Scripting/ScriptMgr.h # src/server/game/World/World.cpp # src/server/scripts/Commands/cs_reload.cpp
Any closing comment (reason for closing) ? |
Sry, same reason as Conversation (fail on previous repo), new PR here : #18035 |
Changes proposed:
Target branch(es): 6.x
Issues addressed:
Tests performed: (Does it build, tested in-game, etc)
Builded
Tested ingame with spell 187651 (AreaTrigger 4424), type Cylinder
Tested ingame with spell 163559 (AreaTrigger 2472), type Polygon
Known issues and ToDo list: