Forum > Serverside Modding
[QUESTION] Trinity C++ Mod for third faction and C++ syntax
(1/3) > >>
canabalt:
Hi Modcraft, i am sorry to trouble you with yet another "help i dont understand this basic problem and need others to spoonfeed me the answer" but the shoutbox is down, so i cannot voice my simple problem on there in the hopes somebody notices.
I have been Attempting to modify Trinitys' source to allow for the addition of a Third Faction, in this case called in-code as TEAM_NEUTRAL and while i understand the most basic of basic of basic c++, and have modified trinity a basic amount, i am still rather useless at certain parts. namely these lines of code for the determining of a characters TeamId.
static uint32 TeamForRace(uint8 race); uint32 GetTeam() const { return m_team; } TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } void setFactionForRace(uint8 race); The line in question i am confused about is TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } Because c++ uses the boolean conditional operator (Variable == X ? X : Y) i am unable to turn this statement into an operator that handles interger values. (I am thrown off with the whole const { return X } part and do not know were to put the if/else if statements)
How would i go about changing it so instead it goes something like:
TeamId GetTeamId() const { return m_team; if (m_team == ALLIANCE) TEAM_ALLIANCE; else if (m_team == HORDE) TEAM_HORDE; else TEAM_NEUTRAL; (Except works) So that it allows me to input a third value if m_team throws a value besides horde/alliance faction IDs and without Visual Studio sezureing at my poor ability to syntax and inability to go from uint32 to constant.
Thanks for any help, and sorry if this thread is either lacking in information required to help, or just plain hard to understand/inconvenient.
stoneharry:
Something like this would work:
--- Code: ---TeamId GetTeamId() const { if (m_team == ALLIANCE) return TEAM_ALLIANCE; else if (m_team == HORDE) return TEAM_HORDE; else if (m_team == NEUTRAL) return TEAM_NEUTRAL; }
--- End code ---
Since:
--- Code: ---TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE;
--- End code ---
Returns TEAM_ALLIANCE if the condition is true, else it returns TEAM_HORDE.
Teams are handled client side as well, a lot of modifications are going to be required to get a new 'team' implemented properly I think, though I haven't researched the matter greatly.
What I did is had a new boolean in the player class handling whether the player was a neutral race, then set them to a friendly faction and such.
edit: Skim-read thread, you already had this except. If it's moaning about it being a constant function when returning values, just remove the constant part. It doesn't need to be, just makes things more efficient.
Steff:
Would it be possible to just recode the stuff so we can have teams defined from DBC or MySQL and no need to hack around in code every time. This would also be a good goal for all the rest like races or classes or whatever.
Like a modding core. And perhaps Trinity will take back the patches and merg in main core.
stoneharry:
--- Quote from: "Steff" ---Would it be possible to just recode the stuff so we can have teams defined from DBC or MySQL and no need to hack around in code every time. This would also be a good goal for all the rest like races or classes or whatever.
Like a modding core. And perhaps Trinity will take back the patches and merg in main core. --- End quote ---
It's a confusing one. Trinity and Mangos both aim to emulate Blizzard as far as possible, replicating the same procedures to create an almost identical server. They do not really support the addition or modification of existing data. So they wouldn't accept such changes.
It's just a bit hypocritical of them to act this way and still only partially load data from DBC's - much more could be retrieved from there rather than the database.
deep6ixed:
I don't understand that either. One of the latest revisions on trinity core hard codes the talent tabs directly into the core. Why would you do that? Every time Blizz moves talents around, you would have to then patch the code.
Ah well, we do what we must I guess.
Navigation
[0] Message Index
[#] Next page
|