Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2008, 06:33 PM
kraeger
Fire Beetle
 
Join Date: Mar 2008
Location: Halas, Everfrost
Posts: 9
Default Fix for bald players bug

Hey. I've been working on the bald players problem for 2-3 days now. For those who don't know about the problem, one of the hairstyle for every race/gender combo doesn't show as it should on luclin models and we see a bald player instead of the selected hairstyle.

Here is what I found:
-There are two groups of race/gender combos that are affected by this problem. The race/genders that have 3 hairstyle selections and the race/genders that have 4 hairstyle selections.
ex:Human/Female: You can choose from 3 different hairstyles. (Values 0 or 1 or 2)
Human/Male: You can choose from 4 different hairstyles. (Values 255 or 0 or 1 or 2)
*Hairstyle 255 is the bald player model that you can choose on the character creation menu, only available for male characters and troll/ogre female characters.
-The problem we want to solve always happen with hairstyle "0".
-Instead of getting the value "0" when this is what the user pick on character creation, it somehow end up with the value "255". This is why we see a bald character when choosing hairstyle "0", it actually show hairstyle "255".

Note:
-The hairstyle 0 is correctly shown on the character selection screen.
-The hairstyle 0 is correctly shown after using /facepick, but after zoning or dying the bald player problem comes back.
-After selecting hairstyle 0 on character creation menu, the value "0" seems to be stored correctly in pp.hairstyle, but somehow gets lost along the way and is modified to "255".
-Could it be because we transfer a value between int, int8, uint8 and int32 variables?

Anyway, here is a way to fix the bug:

In client.cpp, on line 951, add:
Code:
//Temporary fix for missing hairstyle.
if (cc->hairstyle == 0)
{
	pp.eyecolor1	= 99;
}
In titanium.ccp, replace line 470 with:
Code:
//Temporary fix for missing hairstyle.
if (emu->eyecolor1 == 99)
{
	eq->hairstyle = 0;
	eq->eyecolor1 = emu->eyecolor2;
}
else
{
	eq->hairstyle = emu->hairstyle;
}
In client_packet.cpp, on line 4390, add:
Code:
//Temporary fix for missing hairstyle.
if (fc->hairstyle == 0)
{
	m_pp.eyecolor1	= 99;
}
Basically, what it does is using the variable eyecolor1 to pass a flag value when hairstyle is equal to 0. Then, before the character is drawn, I set back eyecolor1 value using eyecolor2.

*Important: For the fix to work on an old character (if it's affected by the the bug), you have to do a /facepick in game to have it's hairstyle fixed. This only need to be done once.
*Any existing character can pick the new hair style with /facepick.
*New characters automatically have the bug fixed.
*The fix does not affect people who don't use luclin graphic since pre-luclin only uses the variable "face" and is not using the variable "hairstyle".
*If this ends up in the EqEmu code, I could also fix other appearance bugs, using different flag values in eyecolor1, that would only add 2-3 lines to the previous code.
**(An other appearance bug, for example, is when we select the haircolor 0 (ex.: dark brown for human male), we end up with haircolor 255 (ex.: white for human male)).

The best would be to find why the hairstyle value gets switched from "0" to "255". I really start to think it's an int, int8, int32, uint8 problem, but to be honest, I'm not very good with structs and pointers, so after many hours I was not able to find it. But meanwhile (or if no one feels like working on that), this fix solves the problem.
Reply With Quote
  #2  
Old 08-04-2008, 08:52 AM
kraeger
Fire Beetle
 
Join Date: Mar 2008
Location: Halas, Everfrost
Posts: 9
Default

I just got a message from someone who's line numbers aren't matching with mines for the fix, so I will put some surrounding code to make it easier.
(Oh and can someone tell me how to edit posts? )

The bug fix:

In client.cpp, on (or near) line 951:

Old code:
Code:
pp.beard		 = cc->beard;
pp.beardcolor	= cc->beardcolor;

pp.birthday		= bday;
pp.lastlogin	= bday;
New code:
Code:
pp.beard		= cc->beard;
pp.beardcolor	= cc->beardcolor;
//Temporary fix to missing hairstyle.
if (cc->hairstyle == 0)
{
	pp.eyecolor1	= 99;
}
pp.birthday		= bday;
pp.lastlogin	= bday;
In titanium.ccp, on (or near) line 470:

Old code:
Code:
//eq->unknown0140[4] = emu->unknown0140[4];
eq->is_npc = emu->is_npc;
eq->hairstyle = emu->hairstyle;
eq->beard = emu->beard;
//eq->unknown0147[4] = emu->unknown0147[4];
New code:
Code:
//eq->unknown0140[4] = emu->unknown0140[4];
eq->is_npc = emu->is_npc;
//Temporary fix to missing hairstyle.
if (emu->eyecolor1 == 99)
{
	eq->hairstyle = 0;
	eq->eyecolor1 = emu->eyecolor2;
}
else
{
	eq->hairstyle = emu->hairstyle;
}
eq->beard = emu->beard;
//eq->unknown0147[4] = emu->unknown0147[4];
In client_packet.cpp, on (or near) line 4390:

Old code:
Code:
m_pp.beard		= fc->beard;					

	
Save();
Message_StringID(13,FACE_ACCEPTED);
//Message(13, "Facial features updated.");
New code:
Code:
m_pp.beard		= fc->beard;					
//Temporary fix to missing hairstyle.
if (fc->hairstyle == 0)
{
	m_pp.eyecolor1	= 99;
}
	
Save();
Message_StringID(13,FACE_ACCEPTED);
//Message(13, "Facial features updated.");
Reply With Quote
  #3  
Old 08-04-2008, 09:09 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

You have five minutes to edit a post after it's made, then you can't. So making a new post is fine. This deserves a fresh bump anyhow, great fix =)

Looking forward to more of your work, this one has been frustrating for a very long time.
Reply With Quote
  #4  
Old 08-04-2008, 09:44 AM
leslamarch
Discordant
 
Join Date: Sep 2006
Location: Green Bay, WI
Posts: 436
Default

Excellent fix, Thanks very much.
Tested this and it all seems to be working perfect
Reply With Quote
  #5  
Old 08-04-2008, 01:01 PM
kraeger
Fire Beetle
 
Join Date: Mar 2008
Location: Halas, Everfrost
Posts: 9
Default

I improved the fix (If no bug is found, this will be the final version). It now looks better (in the code) and it fixes more visual problems. There was a missing hairstyle, but there was also a missing face, eyecolor, haircolor, beard and beardcolor.

Here is the new fix, please use this one instead of the one in the first post:
(I tested it for 10-20 minutes and it seems to works well, but please write in the thread if you still see any visual problems).

***New code is in blue***

In worlddb.cpp, on (or near) line 85:

New code:
Code:
cs->hair[char_num]				= pp->hairstyle;
cs->beard[char_num]				= pp->beard;

if (pp->face == 99)       {cs->face[char_num] = 0;}
if (pp->eyecolor1 == 99)  {cs->eyecolor1[char_num] = 0;}
if (pp->eyecolor2 == 99)  {cs->eyecolor2[char_num] = 0;}
if (pp->hairstyle == 99)  {cs->hair[char_num] = 0;}
if (pp->haircolor == 99)  {cs->haircolor[char_num] = 0;}
if (pp->beard == 99)      {cs->beard[char_num] = 0;}
if (pp->beardcolor == 99) {cs->beardcolor[char_num] = 0;}
				
// Character's equipped items
// @merth: Haven't done bracer01/bracer02 yet.
In client_packet.cpp, on (or near) line 4390:

New code:
Code:
	
        m_pp.beard		= fc->beard;

	if (fc->face == 0)       {m_pp.face = 99;}
	if (fc->eyecolor1 == 0)  {m_pp.eyecolor1 = 99;}
	if (fc->eyecolor2 == 0)  {m_pp.eyecolor2 = 99;}
	if (fc->hairstyle == 0)  {m_pp.hairstyle = 99;}
	if (fc->haircolor == 0)  {m_pp.haircolor = 99;}
	if (fc->beard == 0)      {m_pp.beard = 99;}
	if (fc->beardcolor == 0) {m_pp.beardcolor = 99;}

	
	Save();
	Message_StringID(13,FACE_ACCEPTED);
In Titanium.cpp, on (or near) line 511:

New code:
Code:
	
               eq->spawnId = emu->spawnId;
//		eq->unknown0344[4] = emu->unknown0344[4];
		eq->lfg = emu->lfg;

		if (emu->face == 99)	      {eq->face = 0;}
		if (emu->eyecolor1 == 99)  {eq->eyecolor1 = 0;}
		if (emu->eyecolor2 == 99)  {eq->eyecolor2 = 0;}
		if (emu->hairstyle == 99)  {eq->hairstyle = 0;}
		if (emu->haircolor == 99)  {eq->haircolor = 0;}
		if (emu->beard == 99)      {eq->beard = 0;}
		if (emu->beardcolor == 99) {eq->beardcolor = 0;}
      }
In client.cpp, on (or near) line 951:

New code:
Code:
 
       pp.beard		 	= cc->beard;
	pp.beardcolor	= cc->beardcolor;

	if (cc->face == 0)       {pp.face = 99;}
	if (cc->eyecolor1 == 0)  {pp.eyecolor1 = 99;}
	if (cc->eyecolor2 == 0)  {pp.eyecolor2 = 99;}
	if (cc->hairstyle == 0)  {pp.hairstyle = 99;}
	if (cc->haircolor == 0)  {pp.haircolor = 99;}
	if (cc->beard == 0)      {pp.beard = 99;}
	if (cc->beardcolor == 0) {pp.beardcolor = 99;}

	pp.birthday		= bday;
	pp.lastlogin	= bday;
Reply With Quote
  #6  
Old 08-04-2008, 01:23 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

I can't find anything referring to 'pp.beard' (or beard for that matter) in client.cpp.
What version source are you working with?
Reply With Quote
  #7  
Old 08-04-2008, 01:28 PM
leslamarch
Discordant
 
Join Date: Sep 2006
Location: Green Bay, WI
Posts: 436
Default

Quote:
Originally Posted by Angelox View Post
I can't find anything referring to 'pp.beard' (or beard for that matter) in client.cpp.
What version source are you working with?
Ax you need to grab the client.cpp from World not zone then your good to go
Reply With Quote
  #8  
Old 08-04-2008, 01:29 PM
kraeger
Fire Beetle
 
Join Date: Mar 2008
Location: Halas, Everfrost
Posts: 9
Default

I am working with 1118. I didn't know that, but there seem to be a client.cpp in "Zone" and in "World". You need to use the one in "World".
Reply With Quote
  #9  
Old 08-04-2008, 01:33 PM
kraeger
Fire Beetle
 
Join Date: Mar 2008
Location: Halas, Everfrost
Posts: 9
Default

Hahah, well two answers is better than none i guess
Reply With Quote
  #10  
Old 08-04-2008, 01:38 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

Ok, I got ya now, I should have searched better.
Thanks for the code BtW
Reply With Quote
  #11  
Old 08-06-2008, 09:47 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

Seems all the NPCs have white hair now. Is that a result of fixing all the different 0 values? I think we were seeing brown hair as the default on NPCs previously because that's what 0 was getting twisted into. Seems that 0 is actually white hair.

Is that the way you understand it to work?
Reply With Quote
  #12  
Old 08-06-2008, 10:12 AM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

Quote:
Originally Posted by So_1337 View Post
Seems all the NPCs have white hair now. Is that a result of fixing all the different 0 values? I think we were seeing brown hair as the default on NPCs previously because that's what 0 was getting twisted into. Seems that 0 is actually white hair.

Is that the way you understand it to work?
it doesn't look like kraeger's fix if you mean the 1120 one
Reply With Quote
  #13  
Old 08-06-2008, 10:41 AM
kraeger
Fire Beetle
 
Join Date: Mar 2008
Location: Halas, Everfrost
Posts: 9
Default

Angelox is right, it's not my fix that is in the code. I was quite happy to see that a better code had been written, but i will be honest, i am a bit sad after seeing that my name is not in the changelog, at least as part of the team that helped solve the problem, i spent 25+ hours working on this bug..

Anyway:

haircolor 255 = white hairs (when working correctly)
haircolor 0 = dark brown hairs (when working correctly)

I haven't tried 1120 and i don't know what the new fix is in the code, but this what i can understand from what So_1337 is seeing in game:

My fix only affected player characters, this is why we didn't see a change on NPC. From what i understand, the new fix is working on both player and NPC, so we would either need to know what kind of characters it's drawing (Player or NPC) or we would need to update the default NPC model to have brown hair (after the fix).
Reply With Quote
  #14  
Old 08-06-2008, 10:43 AM
So_1337
Dragon
 
Join Date: May 2006
Location: Cincinnati, OH
Posts: 689
Default

I had no idea, my apologies. I saw your fix here and the reports that it was working, then saw that 1120 included a fix for bald players and assumed it to be yours.

Guess we'll have to wait for the full story from KLS. Thanks for the information, guys.
Reply With Quote
  #15  
Old 08-06-2008, 02:26 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Yeah I'm sorry, but none of your code was used for the fix, I'm not even sure if it's a full fix atm. But you were the inspiration behind it, I'll add you to the log on next update if you'd like.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:54 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3