|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
01-20-2015, 02:30 PM
|
Sarnak
|
|
Join Date: Aug 2009
Location: Somewhere
Posts: 53
|
|
EQEmu::GetSkillName() utility function
This patch adds a utility function to skills.h / skills.cpp to provide a lookup of skill ID -> skill name.
Currently this is only used in client.cpp Client::ShowSkillsWindow()
But it certainly could be useful in other places, such as when logging SKILLS__GAIN messages or sending client messages (I use it in my custom code to alert the client if they try to use a tradeskill that they haven't yet unlocked, for example).
Code:
diff --git a/common/skills.cpp b/common/skills.cpp
index ceb726d..c7e787f 100644
--- a/common/skills.cpp
+++ b/common/skills.cpp
@@ -55,3 +55,18 @@ bool EQEmu::IsSpecializedSkill(SkillUseTypes skill)
return false;
}
}
+
+const char* EQEmu::GetSkillName(int skill)
+{
+ // this list of names must keep the same order as that in common/skills.h
+ const char* SkillName[] = {"1H Blunt","1H Slashing","2H Blunt","2H Slashing","Abjuration","Alteration","Apply Poison","Archery",
+ "Backstab","Bind Wound","Bash","Block","Brass Instruments","Channeling","Conjuration","Defense","Disarm","Disarm Traps","Divination",
+ "Dodge","Double Attack","Dragon Punch","Dual Wield","Eagle Strike","Evocation","Feign Death","Flying Kick","Forage","Hand to Hand",
+ "Hide","Kick","Meditate","Mend","Offense","Parry","Pick Lock","Piercing","Ripost","Round Kick","Safe Fall","Sense Heading",
+ "Singing","Sneak","Specialize Abjuration","Specialize Alteration","Specialize Conjuration","Specialize Divination","Specialize Evocation","Pick Pockets",
+ "Stringed Instruments","Swimming","Throwing","Tiger Claw","Tracking","Wind Instruments","Fishing","Make Poison","Tinkering","Research",
+ "Alchemy","Baking","Tailoring","Sense Traps","Blacksmithing","Fletching","Brewing","Alcohol Tolerance","Begging","Jewelry Making",
+ "Pottery","Percussion Instruments","Intimidation","Berserking","Taunt","Frenzy"};
+ return SkillName[skill];
+}
+
diff --git a/common/skills.h b/common/skills.h
index a589129..f91b561 100644
--- a/common/skills.h
+++ b/common/skills.h
@@ -268,6 +268,7 @@ typedef enum {
namespace EQEmu {
bool IsTradeskill(SkillUseTypes skill);
bool IsSpecializedSkill(SkillUseTypes skill);
+ const char* GetSkillName(int skill);
}
#endif
diff --git a/zone/client.cpp b/zone/client.cpp
index b7d52e8..25f291a 100644
--- a/zone/client.cpp
+++ b/zone/client.cpp
@@ -4919,17 +4919,8 @@ void Client::ShowSkillsWindow()
std::map<std::string, SkillUseTypes> Skills;
std::map<std::string, SkillUseTypes>::iterator it;
- // this list of names must keep the same order as that in common/skills.h
- const char* SkillName[] = {"1H Blunt","1H Slashing","2H Blunt","2H Slashing","Abjuration","Alteration","Apply Poison","Archery",
- "Backstab","Bind Wound","Bash","Block","Brass Instruments","Channeling","Conjuration","Defense","Disarm","Disarm Traps","Divination",
- "Dodge","Double Attack","Dragon Punch","Dual Wield","Eagle Strike","Evocation","Feign Death","Flying Kick","Forage","Hand to Hand",
- "Hide","Kick","Meditate","Mend","Offense","Parry","Pick Lock","Piercing","Ripost","Round Kick","Safe Fall","Sense Heading",
- "Singing","Sneak","Specialize Abjuration","Specialize Alteration","Specialize Conjuration","Specialize Divination","Specialize Evocation","Pick Pockets",
- "Stringed Instruments","Swimming","Throwing","Tiger Claw","Tracking","Wind Instruments","Fishing","Make Poison","Tinkering","Research",
- "Alchemy","Baking","Tailoring","Sense Traps","Blacksmithing","Fletching","Brewing","Alcohol Tolerance","Begging","Jewelry Making",
- "Pottery","Percussion Instruments","Intimidation","Berserking","Taunt","Frenzy"};
for(int i = 0; i <= (int)HIGHEST_SKILL; i++)
- Skills[SkillName[i]] = (SkillUseTypes)i;
+ Skills[EQEmu::GetSkillName(i)] = (SkillUseTypes)i;
// print out all available skills
for(it = Skills.begin(); it != Skills.end(); ++it) {
|
|
|
|
01-20-2015, 05:44 PM
|
Administrator
|
|
Join Date: May 2013
Location: United States
Posts: 1,594
|
|
To make this a lot simpler, you can fork a repository, push to your own fork, then make a pull request. Doing this will make it a lot easier on the collaborators who commit it because pull requests are automatically compiled to check for errors or issues. Just a thought.
|
01-21-2015, 11:30 AM
|
Sarnak
|
|
Join Date: Aug 2009
Location: Somewhere
Posts: 53
|
|
I'm a git newb, too used to SVN I'll look into this, thanks!
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 04:03 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|