YaLTeR / OpenAG

An open-source reimplementation of Adrenaline Gamer's client library.
https://j.mp/OpenAG
Other
131 stars 39 forks source link

Sync up the condition for cl_righthand with the one that's in engine #129

Closed chinese-soup closed 3 years ago

chinese-soup commented 3 years ago

Resolves #128

Looks like an engine bug (couldn't really find where it happens in Ghidra, but it's pretty obvious seeing as we don't use cl_righthand's actual value anywhere in the client code), so not much we can do here other than clamp it.

EDIT: alright yea looks like this is it

  (*qglCullFace)(0x404);
  bVar4 = false;
  if (((cl_righthand != (cvar_t *)0x0) && (0.0 < cl_righthand->value)) &&
     (cl.viewent.index == currententity->index)) {
    (*qglDisable)(0xb44);
    bVar4 = true;
  }
tmp64 commented 3 years ago

The engine checks whether cl_righthand is enabled using value > 0.0 while the client uses value != 0.0. This somehow inverts back surface culling.

void R_GLStudioDrawPoints() {
  ...
  if ( cl_righthand && cl_righthand->value > 0.0 && ei.viewent.index == currententity->index )
  {
    qglDisable(0xB44u); // 0xB44u == GL_CULL_FACE
    iFlippedVModelb = 1;
  }

I think a better fix would be to replace all != 0 conditions with > 0 like in the engine.

Edit: Added meaning of 0xB44u to the code

chinese-soup commented 3 years ago

Oh yea, I found that code as well, but I didn't read the if statement correctly in Ghidra before so it didn't occur to me at all. :smile:

I think a better fix would be to replace all != 0 conditions with > 0 like in the engine.

So yea, good point, did this instead, many thanks!

YaLTeR commented 3 years ago

Thanks