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

Make IDs easier to edit #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

dedmen
Copy link

@dedmen dedmen commented Nov 2, 2023

In case you need to edit the Entity/GameObject ID's it can now be done in just 4 places.
Instead of in two dozen


// Offsets from creatures_objects.sql
constexpr uint32 GetCreatureEntry(uint32 offset) {
return 500030 + offset;
Copy link
Member

Choose a reason for hiding this comment

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

Okay, but what if I set @C_TEMPLATE = 40050, then everything would break.

Copy link
Author

@dedmen dedmen Nov 15, 2023

Choose a reason for hiding this comment

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

Same as before.
But now you can easily change it in this one (four) place(s).
If you change it in SQL script, you need to change it here too.

But atleast there are only 4 places to change, instead of two dozen as before

Copy link
Member

Choose a reason for hiding this comment

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

well then put it into the config. Hardcoded stuff are bad.

@pangolp
Copy link

pangolp commented Apr 8, 2024

ERROR: Permission to DedmenWoW/mod-guildhouse.git denied to pangolp.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I tried to make modifications and solve the conflicts, but when it comes to make the push, I find that I don't have permissions to upload the changes. If you could enable those permissions, I would push the changes. @dedmen

@dedmen
Copy link
Author

dedmen commented Apr 8, 2024

Huh weird the checkbox isn't present to allow access to maintainers.
I've sent you invite to my project to give you access. Thank you

I just checked for changes here 3 days ago :D

@pangolp
Copy link

pangolp commented Apr 8, 2024

Huh weird the checkbox isn't present to allow access to maintainers.
I've sent you invite to my project to give you access. Thank you

I just checked for changes here 3 days ago :D

From the mobile phone, when I want to open the invitation, it gives me a 404 error. However, I will try from the PC. It's strange, usually, they don't have to invite me. Simply modifying the permissions in the fork settings is usually enough.

I have to check if, in addition to solving the conflict, I don't have to make one more change. Because I was not sure if when editing a SQL file, a new hash was created and executed again. Yesterday I confirmed that, and I saw that it does. But without knowing it, I created a third file. After I upload the changes, I will have to test the branch and verify that everything is fine.

@pangolp
Copy link

pangolp commented Apr 8, 2024

The conflict is resolved, but I think some suggestions about codes or new hardcore are missing.

@pangolp
Copy link

pangolp commented Apr 8, 2024

I think the changes are compatible, but we still need to review the hardcore numbers part.

@dedmen
Copy link
Author

dedmen commented Apr 8, 2024

The hardcoded numbers will also get worse when we add SQL patches, like we did with the previous PR you merged.
The update script again has a hardcoded number in it, which again needs to be changed.

Maybe we could store the "base number" in the database, some table.
Then c++ code can fetch it from there, SQL update scripts can fetch the base number from there, and we can make it changeable in one single place (the initial init SQL script)

But that's a quite bigger change. I didn't want to provide a full solution here, I just wanted to make it a bit easier (edit 4 places instead of over 20), and the better solution can be done later (more easily because I already did half of it).

Also the way I did it with the constexpr function, means the value needs to be present at compile-time, so putting it into config file isn't possible that way. But it solved my use case as I compile from source with edited ID's (which you already had to do previously)

@pangolp
Copy link

pangolp commented Apr 8, 2024

The hardcoded numbers will also get worse when we add SQL patches, like we did with the previous PR you merged. The update script again has a hardcoded number in it, which again needs to be changed.

Maybe we could store the "base number" in the database, some table. Then c++ code can fetch it from there, SQL update scripts can fetch the base number from there, and we can make it changeable in one single place (the initial init SQL script)

But that's a quite bigger change. I didn't want to provide a full solution here, I just wanted to make it a bit easier (edit 4 places instead of over 20), and the better solution can be done later (more easily because I already did half of it).

Also the way I did it with the constexpr function, means the value needs to be present at compile-time, so putting it into config file isn't possible that way. But it solved my use case as I compile from source with edited ID's (which you already had to do previously)

If you can't edit it, from the configuration file, then bye-bye to the solution I wanted to give you...
What happens if we remove the constexpr and add the value in the configuration file?

@dedmen
Copy link
Author

dedmen commented Apr 8, 2024

If you remove constexpr it fails to compile.
Because the switch cases need to be compiletime constant values https://github.com/azerothcore/mod-guildhouse/pull/45/files#diff-718379843cd95689dd90c3b83f7107660e3c4bdaa7d3930617e3239dfac24f2eR259-R266

Of course can make that not be a switch and instead some different runtime dispatch. But that would be a bigger rework there too that I didn't want to go down to.

Maybe I'd have some time soon-ish to do just that. But probably would be a couple weeks to get to it.

@pangolp
Copy link

pangolp commented Apr 8, 2024

If you remove constexpr it fails to compile. Because the switch cases need to be compiletime constant values https://github.com/azerothcore/mod-guildhouse/pull/45/files#diff-718379843cd95689dd90c3b83f7107660e3c4bdaa7d3930617e3239dfac24f2eR259-R266

Of course can make that not be a switch and instead some different runtime dispatch. But that would be a bigger rework there too that I didn't want to go down to.

Maybe I'd have some time soon-ish to do just that. But probably would be a couple weeks to get to it.

I leave you the updated branch then, the module compiles and works, when you have time to check it, welcome.

@pangolp
Copy link

pangolp commented Apr 8, 2024

What this person did, doesn't it work, or is it complementary to what you want to do: #39.

@dedmen
Copy link
Author

dedmen commented Apr 10, 2024

#39 is completely unrelated to my thing.

@Helias
Copy link
Member

Helias commented Aug 15, 2024

if no objections, I would merge this, it improves the code quality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CreatureTemplate/GameObjectTemplate ID's are partially hardcoded
4 participants