Fixing GuiHealthTextHud For Networking ShowTrueHealth

Expanding and utilizing the engine via C++.
2 posts Page 1 of 1
Steve_Yorkshire
Posts: 316
Joined: Tue Feb 03, 2015 10:30 pm
 
  by Steve_Yorkshire » Mon May 06, 2019 9:29 pm
ShowTrueHealth does not work in GuiHealthTextHud for clients joining the server (works in local conditions).

Image
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.

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

Thanks to @ Azaezel for the confirmation and fix tip.
Jason Campbell
Posts: 297
Joined: Fri Feb 13, 2015 2:51 am
 
by Jason Campbell » Tue May 07, 2019 3:43 am
Thanks Steve.
2 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests