Jump to content

Fixing GuiHealthTextHud For Networking ShowTrueHealth


Recommended Posts

ShowTrueHealth does not work in GuiHealthTextHud for clients joining the server (works in local conditions).


screenshot_002-00000.png

That "1" should be 100.


maxDamage has been left out of networking ... for whatever reasons ... so let's just add that back in.

in ShapeBase.cpp ~273 and 286

struct ShapeBaseDataProto
{
//...
   F32 maxEnergy;
   F32 maxDamage;//yorks
   F32 cameraMaxDist;
//...   
 
   ShapeBaseDataProto()
   {
//...
      maxEnergy = 0;
	  maxDamage = 0;//yorks
      cameraMaxDist = 0;
//...
   }
};

 

~792 network the info

void ShapeBaseData::packData(BitStream* stream)
{
   Parent::packData(stream);
 
//...
   if(stream->writeFlag(maxEnergy != gShapeBaseDataProto.maxEnergy))
      stream->write(maxEnergy);
   if (stream->writeFlag(maxDamage != gShapeBaseDataProto.maxDamage))//yorks
	   stream->write(maxDamage);//yorks
   if(stream->writeFlag(cameraMaxDist != gShapeBaseDataProto.cameraMaxDist))
      stream->write(cameraMaxDist);
//...

 

And read it ~881

void ShapeBaseData::unpackData(BitStream* stream)
{
   Parent::unpackData(stream);
//...
   if(stream->readFlag())
      stream->read(&maxEnergy);
   else
      maxEnergy = gShapeBaseDataProto.maxEnergy;
 
   if (stream->readFlag())//yorks
	   stream->read(&maxDamage);
   else
	   maxDamage = gShapeBaseDataProto.maxDamage;//yorks
 
   if(stream->readFlag())
      stream->read(&cameraMaxDist);
   else
      cameraMaxDist = gShapeBaseDataProto.cameraMaxDist;
//...

 

Et voila.


networkedDamage.jpg

Local/server on top, client seen behind with correct damage display.


Thanks to @Azaezel for the confirmation and fix tip.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...