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
Simplify script naming and implement AutoScript class #51
base: master
Are you sure you want to change the base?
Conversation
Remove unused member that was left behind when introducing SetFactionTem...
I think the class name 'AutoScript' doesn't match the purpose of the class and can be confusing. AutoScript isn't a script at all. |
It's not a script. But it refers to a script? |
what i don't like about the patch is that he mixes this functionality with other changes like the intentions in ScriptMgr.h (the change is good but should not be in the same commit!). please don't add them with this PR but create another commit for that. also, about the usage. I don't think that there's any need to write the code like this: s.newScript("at_childrens_week_spot");
s->pAreaTrigger = &AreaTrigger_at_childrens_week_spot; you should instead use this (which is also possible with your patch): s.newScript("at_childrens_week_spot")->pAreaTrigger = &AreaTrigger_at_childrens_week_spot; otherwise it looks nice |
There is also no need to replace std::string with a const char* for the Script member. I assume you changed it because passing NULL (the default for the constructor's const char* argument) to the std::string constructor didn't work - and indeed, that's not something you should do! But there is no need for a change really: you can keep the std::string member of Script, and make the constructor something like this instead: Perfectly backwards compatible too, even though I'd say it doesn't make much sense to create a script without a name. Eventually you'll need a name for the script anyway, as your examples show, so I'd personally even drop the default and require a name at construction. But that's just me, and I don't mind to keep a default for the sake of backwards compatibility :) |
Thanks for the comments guys, i'm waiting a Schmoozerd reaction now. |
May I suggest a better naming? Something like: |
I think this is great boxa :) On Wednesday, March 27, 2013, Radu wrote:
|
@xfurry problem using pNewScript will make the lines even longer (and many registries are now already very long lines) |
Real progress will be replace function structures by virtual methods overides for abstract Script class. |
@Schmoozerd |
Prepared with these renamings:
Some search'n'replace stuff: (RegEx for VC) Note: "instance_azjol-nerub" is consistently named in non-SD2 style However i noticed that you didn't convert all the script registries, and also (as DasBlub mentioned already) some of the converted still are inefficiently converted (two lines instead of one) Please provide (or let somebody provide) a full patch for all scripts :) I did a few changes to make things easier, and pused them to my repo at https://github.com/Schmoozerd/scriptdev2/tree/rewrite_scriptRegistry |
@Schmoozerd |
What's the status of this? @Schmoozerd what is exactly missing from this patch? |
@xfurry - this is only the framework, and not yet applied to all files, hence not yet interesting in my view |
oh, someone raised my old theme =) for example, instead of monstrous:
used simple:
only three line... really, this is very good to use. maybe implement it in CMaNGOS, or extend it? |
|
||
CreatureAI* (*GetAI)(Creature*); | ||
InstanceData* (*GetInstanceData)(Map*); | ||
const char* Name; |
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.
Why are we going from std::string to const char*?
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.
Naming "AutoScript" is a bit misleading.
Going from c++ string to cstring is backwards?
Full backward compatibility, old code will work without any changes.
This just a wrapper for an Script object, simplifies the code.
Usage examples:
AutoScript("script_name")->GetAI = &GetAI_realization;
**
AutoScript s("script_name");
s->pGossipHello = &GossipHello_realization;
s->pGossipSelect = &GossipSelect_realization;
**
AutoScript s;
s.newScript("script_name_1")->GetAI = &GetAI_realization_1;
s.newScript("script_name_2")->GetAI = &GetAI_realization_2;
**
AutoScript s;
s.newScript("script_name_1");
s->GetAI = &GetAI_script_name_1;
s.newScript("script_name_2");
s->GetAI = &GetAI_script_name_2;