Forum

Grrr ... find the humor ...

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Grrr ... find the humor ...

Postby Baker » Wed Oct 13, 2010 11:55 am

This is in the Kurok PSP source, not surprisingly ... it doesn't actually work. But I didn't notice and was wondering why the KurokPSP wasn't doing what I expected.

Code: Select all
  // Tomaz - QC Alpha Scale Glow Begin

    {
        eval_t  *val;

        alpha=1;
        scale=1;

        if (val == GetEdictFieldValue(ent, "alpha"))
        {
            alpha = val->_float;
        }
        else
            alpha = 1;

        if (val == GetEdictFieldValue(ent, "scale"))
        {
            scale = val->_float;
        }
        else
            scale = 1;

        if (scale > 4)
            scale = 4;
.
.
.
    }

    // Tomaz - QC Alpha Scale Glow End
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Spike » Wed Oct 13, 2010 1:28 pm

well it fixes one warning, at least.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Grrr ... find the humor ...

Postby Spirit » Wed Oct 13, 2010 3:22 pm

Missing {} for the last if? I am guessing wildly, QuakeC's rules confuse me since I never really did anything in it. :D
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Postby Spike » Wed Oct 13, 2010 3:41 pm

Its C, not C++, and {} works the same way - not needed if it would contain a single line (or rather a single semi-colon.... unless its a control statement in which case its allowed multiple... you know what, I'm just gonna shut up now).

Have another go. :)
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby frag.machine » Wed Oct 13, 2010 4:17 pm

Just took a quick look, but looks like nobody is initializing val before it's being referenced, correct ?
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby qbism » Wed Oct 13, 2010 5:06 pm

Didn't see alpha or scale declared. Also, if it's wrong, let it be wrong more efficiently:
Code: Select all
  // Tomaz - QC Alpha Scale Glow Begin

    {
        eval_t  *val;

        alpha=1;
        scale=1;

        if (val == GetEdictFieldValue(ent, "alpha"))
              alpha =val->_float;

        if (val == GetEdictFieldValue(ent, "scale"))
       {
            scale = val->_float;
            if (scale > 4)
            scale = 4;
        }

.
.
.
    }

    // Tomaz - QC Alpha Scale Glow End


Maybe check alpha >=0 and <=1? Check scale >0?
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Postby frag.machine » Wed Oct 13, 2010 5:15 pm

The compiler would complain about undeclared vars, but it may fail to detect references to a non-initialized pointer. Anyway, this comes exactly to reforce my point: people should at least try to understand what they're doing when doing Ctrl+C/Ctrl+V. It's very likely that someone pasted that at some point, the change obviously didn't work, and he/she didn't bother to revert things. :/
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby metlslime » Wed Oct 13, 2010 6:32 pm

== should be =
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Postby mh » Wed Oct 13, 2010 9:19 pm

metlslime wrote:== should be =

Dammit you're right. I've been scratching my head over that one! :D

Probably intended to be something like this:
Code: Select all
if ((val = GetEdictFieldValue(ent, "alpha")) != NULL)
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby qbism » Wed Oct 13, 2010 10:48 pm

Looks so obvious now.
[facepalm] Picard [/facepalm] good catch! :)
User avatar
qbism
 
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am

Postby Baker » Thu Oct 14, 2010 1:58 am

I thought I need a custom protocol to integrate true Kurok support the way the author presented it!

I don't.

It was never working to begin with. Yeah, Spike obviously nailed it on reply #1 with Metlslime saying the answer, but I actually "fixed" the code with = and got endless crashes not realizing I had "fixed" what had never been operational.

So tasks -1. Kurok was not using a custom protocol on the PSP. :D
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest