Changing movement

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:
Re: Changing movement

Post by Carsten » 2010-08-19, 00:49

Sorry, but it is very difficult to make sense of that portion of code:
  • For a start, indentation is wrong, e.g. the curly brackets in

    Code: Select all

        if (...)
     {
         ...;
     }
    
  • It's very difficult to see where the code begins and where it ends, what variables you declare, initialize and use where, etc.
Making sense of this code is difficult if not impossible with these factors. Please please read How to Submit Patches very carefully, then send me your code as a patch.

With a patch I'd not only be able to see the code exactly the same as you, I'd also see the whole picture, and I'd even be able to try and run it myself, and this besides all the other advantages mentioned in the above article.

Btw., with TortoiseSVN creating a patch is not more than right-clicking to open the context-menu and choosing where the patch should be saved. :up:
Best regards,
Carsten
User avatar
bigjj13
Posts:68
Joined:2010-04-04, 19:16
Location:Germany
Contact:

Re: Changing movement

Post by bigjj13 » 2010-08-19, 11:24

Hi,

I just made a new Ticket (#38)

Thanks
BigJJ -- SG-O
Image
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Changing movement

Post by Carsten » 2010-08-19, 23:49

bigjj13 wrote:I just made a new Ticket (#38)
Thanks! Got it. I'll look into this as soon as I can, but I cannot guarantee that I can come up with results before or over the weekend. In other words, please don't worry if it takes me until next week.

Also please note that I'll close this ticket with resolution "invalid" soon (independently from my looking into it). This is because the ticket system is for tickets related to Cafu (itself) only. Patches like yours that address individual code and are for individual support are better kept here in the forum or sent via email. :up:
Best regards,
Carsten
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Changing movement

Post by Carsten » 2010-08-20, 10:08

Hi BigJJ,

I just looked at your patch.
Well... it's not entirely obvious to me what your intention is with variable Runspon, or why you need it at all, given all the other information in the various local and member variables.

But I think the big question is if the code in

Code: Select all

if (Keys & PCK_Walk) { ... }
should (all) be in this place. It looks as if some of it should have been in the above

Code: Select all

if (Keys & PCK_MoveForward) { ... }
? (But remember that the meaning of Runspon is not really clear to me.)

Also, certainly unintended and cause of problems is that you test Runspon!=3 and in the body of the same condition Runspon==3:

Code: Select all

if (Keys & PCK_Walk)  
{ 
    if (Runspon!=3) 
    { 
        WishVelocity=scale(WishVelocity, 2.0);
        if (Runspon==3) Runspon=4; 
        else Runspon=1; 
    } 
} 
Please review these pieces of code, your problem is certainly somewhere in this (flawed) logic.

Also, some general tips:
  • Configure your editor to use 4 spaces, not TABs for indentation. As you can see in your patch, the TABs break the alignment.
  • Update your code to the latest revision in SVN trunk (it's just a matter of entering svn update at the command line). Your patch is missing fixes for bugs that have been addressed in the meanwhile.
:up:
Best regards,
Carsten
User avatar
bigjj13
Posts:68
Joined:2010-04-04, 19:16
Location:Germany
Contact:

Re: Changing movement

Post by bigjj13 » 2010-09-18, 19:30

Hi,

Here is the final changed HumanPlayer.cpp code with better animation and more realistic movement.

Ticket43

Sincerely
BigJJ -- SG-O
Image
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests