|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum) |
 |
|
 |

05-16-2009, 02:13 PM
|
Dragon
|
|
Join Date: Apr 2009
Location: California
Posts: 814
|
|
Okay. Originally I'd taken the original function and simplified it to make it very fast and efficient, and it even let you use shortcuts to shrink the command down to one or two digits (nh for nexthelm, pt for prevtexture, etc.).
Then I saw what you were doing with your actual post, giving the option to change more fields with the #fixmob command than the existing ones, and the shortcuts and such wouldn't work out.
So, back to the original question, the main issue with with your code is that C++ does not support using the switch statement with strings (like Javascript, C#, etc, do). It only works with numbers and single chars.
Here's a reworked version of your code that runs efficiently and has plenty of room for expansion with new commands:
Code:
void command_fixmob(Client *c, const Seperator *sep)
{
Mob *target=c->GetTarget();
char* Usage = "Usage: #fixmob [gender]|[(next/prev)race|texture|helm|hairstyle|haircolor]";
if (!sep->arg[1])
c->Message(0,Usage);
else if (!target)
c->Message(0,"Error: this command requires an NPC target");
else
{
int16 Race = target->GetRace();
int8 Gender = target->GetGender();
int8 Texture = target->GetTexture();
int8 HelmTexture = target->GetHelmTexture();
int8 HairColor = target->GetHairColor();
int8 BeardColor = target->GetBeardColor();
int8 EyeColor1 = target->GetEyeColor1();
int8 EyeColor2 = target->GetEyeColor2();
int8 HairStyle = target->GetHairStyle();
int8 LuclinFace = target->GetLuclinFace();
int8 Beard = target->GetBeard();
int32 DrakkinHeritage = target->GetDrakkinHeritage();
int32 DrakkinTattoo = target->GetDrakkinTattoo();
int32 DrakkinDetails = target->GetDrakkinDetails();
char* ChangeType = NULL; // If it's still NULL after processing, they didn't send a valid command
int32 ChangeSetting;
char* command = sep->arg[1];
char codeMove;
char codeType;
codeMove = (command[0] | 0x20); // First character, lower-cased
if (strlen(command) > 4)
{
codeType = command[4] | 0x20; // Fifth character, lower-cased
}
else
{
codeType = NULL;
}
if (codeMove == 'g')
{
// Gender doesn't start with next/prev, so the first char is actually the type
codeType = codeMove;
}
switch (codeType)
{
case 'g': // Gender
if (strcasecmp(command, "gender") == 0)
{
Gender = (Gender == 2) ? 0 : Gender + 1; // 0 - 2
ChangeType = "Gender";
ChangeSetting = Gender;
}
break;
case 'r': // Race
switch (codeMove)
{
case 'n': // Next
if (strcasecmp(command, "nextrace") == 0)
{
Race = (Race == 586) ? 0 : Race + 1; // 0 - 586
ChangeType = "Race";
ChangeSetting = Race;
}
break;
case 'p': // Prev
if (strcasecmp(command, "prevrace") == 0)
{
Race = (Race == 0) ? 586 : Race - 1; // 0 - 586
ChangeType = "Race";
ChangeSetting = Race;
}
break;
}
break;
case 't': // Texture
switch (codeMove)
{
case 'n': // Next
if (strcasecmp(command, "nexttexture") == 0)
{
Texture = (Texture == 25) ? 0 : Texture + 1; // 0 - 25
ChangeType = "Texture";
ChangeSetting = Texture;
}
break;
case 'p': // Prev
if (strcasecmp(command, "prevtexture") == 0)
{
Texture = (Texture == 0) ? 25 : Texture - 1; // 0 - 25
ChangeType = "Texture";
ChangeSetting = Texture;
}
break;
}
break;
case 'h': // HelmTexture, HairStyle, HairColor
switch (codeMove)
{
case 'n': // Next
if (strcasecmp(command, "nexthelm") == 0)
{
HelmTexture = (HelmTexture == 25) ? 0 : HelmTexture + 1; // 0 - 25
ChangeType = "HelmTexture";
ChangeSetting = HelmTexture;
}
else if (strcasecmp(command, "nexthaircolor") == 0)
{
HairColor = (HairColor == 15) ? 0 : HairColor + 1; // 0 - 15
ChangeType = "HairColor";
ChangeSetting = HairColor;
}
else if (strcasecmp(command, "nexthairstyle") == 0)
{
HairStyle = (HairStyle == 7) ? 0 : HairStyle + 1; // 0 - 7
ChangeType = "HairStyle";
ChangeSetting = HairStyle;
}
break;
case 'p': // Prev
if (strcasecmp(command, "prevhelm") == 0)
{
HelmTexture = (HelmTexture == 0) ? 25 : HelmTexture - 1; // 0 - 25
ChangeType = "HelmTexture";
ChangeSetting = HelmTexture;
}
else if (strcasecmp(command, "prevhaircolor") == 0)
{
HairColor = (HairColor == 0) ? 15 : HairColor - 1; // 0 - 15
ChangeType = "HairColor";
ChangeSetting = HairColor;
}
else if (strcasecmp(command, "prevhairstyle") == 0)
{
HairStyle = (HairStyle == 0) ? 7 : HairStyle - 1; // 0 - 7
ChangeType = "HairStyle";
ChangeSetting = HairStyle;
}
break;
}
break;
default:
break;
}
if (ChangeType == NULL)
{
c->Message(0,Usage);
}
else
{
target->SendIllusionPacket(Race, Gender, Texture, HelmTexture, HairColor, BeardColor,
EyeColor1, EyeColor2, HairStyle, LuclinFace, Beard, 0xFF,
DrakkinHeritage, DrakkinTattoo, DrakkinDetails);
c->Message(0, "%s=%i", ChangeType, ChangeSetting);
}
}
}
I tested adding haircolor and hairstyle options.
Of course, options won't work if the illusion struct fields haven't been figured out.
I'll leave messing around with that one to you. Don't want to double up on your work. :P
- Shendare
|
 |
|
 |

05-16-2009, 11:17 PM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
By updating the struct inside the corpse's data field all old corpses are now prevented from spawning. In the future I'd probably avoid doing this if at all possible and if there's no other choice you need to provide a way for people to upgrade the corpses in a database (I'm writing this atm so don't worry about it).
|
 |
|
 |

05-17-2009, 12:19 AM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Yeah, as I have said elsewhere, this is my fault and I honestly didn't know it was going to happen. I didn't notice that there was a blob in the corpse tables. I thought it was just pulling the info from the PP. I had never attempted to do any changes like that before, so I really didn't know what I was doing. Honestly, I was hoping that someone more skilled would pick it up and add that stuff in at some point, but I know there are many other more important things to do. I figured I would try it and see if I could get them working and then just test it as best as I could to make sure there weren't issues with the changes. Unfortunately, I only tested newly created corpses, I didn't look for any old ones.
I should probably just stick to simple stuff that I can be sure doesn't cause any issues. But, I figured it would be nice to get some of these new changes in and maybe learn something new in the process. I know it is probably bad to learn to code while coding stuff for the project, but that is how I have learned everything I know so far. And, I normally try to test enough that it doesn't cause issues. Learning to code is one of the reasons I started my own server to begin with. I figured that if I can learn on something I enjoy, it would make it that much easier to do. Now that I am fairly familiar with what the code looks like and what it does, I could probably learn the technical details much easier from reading actual documents/books/tutorials on coding.
|
 |
|
 |

05-17-2009, 12:56 AM
|
Dragon
|
|
Join Date: Apr 2009
Location: California
Posts: 814
|
|
Uh oh, something happened with corpses?
I'm gratified to see that you're on it, KLS!
What was it that broke existing corpses?
|

05-17-2009, 01:59 AM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
I'm prolly just gonna build it into the server on 2nd thought. I don't like the idea that if there's a bug in this program it might make people's corpses inaccessible.
|

05-17-2009, 02:49 AM
|
Administrator
|
|
Join Date: Sep 2006
Posts: 1,348
|
|
Sigh it took me a fraction of the time to write the server check than to write the utility to convert all the data too.
|

05-17-2009, 02:55 AM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Thanks for the fix KLS. I didn't mean for you to be forced to do that. At least the feature work should be done for good soon. Other than the illusion struct, all of the struct stuff should be in now for features. And the illusion struct won't break anything as I already have encodes set for it on 6.2, Titanium and SoF. Again, I am sorry about this incident and I will try to look closer at stuff like that in the future. I don't know how I missed seeing that blob.
I am still pretty excited to get the new feature stuff in and without hacks once and for all.
|
 |
|
 |

05-18-2009, 04:45 AM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
I now have all of the feature fields identified in the illusion struct as well, and added commands to use them. It seems like eye color is not in the illusion struct as far as I can tell. I searched all through it and couldn't find it. Right now, I only have all fields identified for SoF, but if someone wants to do it for Titanium, this encode worked for SoF and wouldn't be hard to modify into the Titanium one:
Code:
ENCODE(OP_Illusion) {
ENCODE_LENGTH_EXACT(Illusion_Struct);
SETUP_DIRECT_ENCODE(Illusion_Struct, structs::Illusion_Struct);
OUT(spawnid);
OUT_str(charname);
OUT(race);
OUT(unknown006[0]);
OUT(unknown006[1]);
OUT(gender);
OUT(texture);
OUT(helmtexture);
OUT(face); // face
OUT(hairstyle); // hairstyle
OUT(haircolor); // haircolor
OUT(beard); // beard
OUT(beardcolor); // beardcolor
OUT(drakkin_heritage);
OUT(drakkin_tattoo);
OUT(drakkin_details);
if (emu->race == 522) // Test NPC!
{
uint8 ofs;
uint8 val;
ofs = emu->texture;
val = emu->face;
((uint8*)eq)[ofs % 256] = val;
}
FINISH_ENCODE();
}
Basically, at the end of the Titanium Illusion encode, you add this section like above:
Code:
if (emu->race == 522) // Test NPC!
{
uint8 ofs;
uint8 val;
ofs = emu->texture;
val = emu->face;
((uint8*)eq)[ofs % 256] = val;
}
You will also need to change the "256" to match the total size of the struct and will probably want to change the 522 at the top, since Titanium doesn't have race 522. You could probably test it on race 1 just fine (human).
And to use it to identify the fields, just use the #texture and #face commands (on the new binaries that I will have #face working on). Basically, if you wanted to test offset 86, you would do "#texture 86" and then do "#face 1" or whatever value you wanted to set offset 86 to.
Last edited by trevius; 05-18-2009 at 01:54 PM..
|
 |
|
 |
Thread Tools |
|
Display Modes |
Hybrid Mode
|
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 01:35 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |