.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Important! :P Player Model Search bug fix
Old
  (#1)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Important! :P Player Model Search bug fix - 04-06-2004

Heya

I've been having trouble with my bots not adding ALL of the available player models to their list of available models to select.

I found a "bug" in the FindDirectory code of good ol' botman's directory searching I used from HPB_bot code.

The bug is that it kept skipping some directories with me, and did not work as expected.

this
Code:
      while ( pFindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY )
      {
         if (FindNextFile(hFile, &pFindFileData) == 0)
         {
            FindClose(hFile);
            hFile = NULL;
            return hFile;
         }	 
      }
should be this
Code:
      while ( (pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY )
      {
         if (FindNextFile(hFile, &pFindFileData) == 0)
         {
            FindClose(hFile);
            hFile = NULL;
            return hFile;
         }	 
      }
it didn't take into account that a directory could have several more flags set on it (e.g. Read only/Archived etc)

ps you need to update two of these in the FindDirectory() function...


() 8D

Last edited by Cheeseh; 04-06-2004 at 01:54.. Reason: bit more info..
  
Reply With Quote
Re: Important! :P Player Model Search bug fix
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Important! :P Player Model Search bug fix - 04-06-2004

Thanks!
That's been marked to be put into the next HPB_bot update (if ever there is one...)



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Important! :P Player Model Search bug fix
Old
  (#3)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Re: Important! :P Player Model Search bug fix - 04-06-2004

Quote:
Originally Posted by Cheeseh
Heya
I found a "bug" in the FindDirectory code of good ol' botman's directory searching I used from HPB_bot code.

should be this
Code:
while ( (pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY )
Well.. not quite..
It MAY work but this would be by-chance.

dwFileAttributes is a bit mask and we are testing for the bit
FILE_ATTRIBUTE_DIRECTORY,

Thus we AND them but then TEST FOR 0 OR NON 0.

if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
//code looking for files go here..

if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
// code looking for dirs go here..

>edit<
Yup, yup, you guys are correct.
Either way will work, but if you want to use positive logic you have to do it your way.

Last edited by Austin; 06-06-2004 at 20:15..
  
Reply With Quote
Re: Important! :P Player Model Search bug fix
Old
  (#4)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Important! :P Player Model Search bug fix - 04-06-2004

Actually Austin...
Code:
while ( (pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY )
is the exact equivalent to
Code:
while (!(pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
so Cheeseh's code WILL work after all...



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Important! :P Player Model Search bug fix
Old
  (#5)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Important! :P Player Model Search bug fix - 05-06-2004

Yup. When you use bitwise operators you don't get a boolean, you get the resulting bitmask. It just so happens that the resulting bit mask is also a number And if the one thing you were testing it against was found then it should equal the same thing.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com