Author Topic: [Patch] Mantis Bug 3036 - check alternative file location directory  (Read 1499 times)

0 Members and 1 Guest are viewing this topic.

Offline emkay

  • 23
[Patch] Mantis Bug 3036 - check alternative file location directory
Hello everyone,

attached is a small patch to the http://scp.indiegames.us/mantis/view.php?id=3036 bug reported in Mantis.
It is a small issue related to Linux only (or possibly OSX as well).
As I don't have a Linux OS available for testing, could someone else please have a look at it?

Many thanks!

P.S.: As I'm fairly new to SCP coding, I'm well aware that this patch might not be what experienced SCP coders are looking for. I'm open for suggestions.

[attachment kidnapped by pirates]

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: [Patch] Mantis Bug 3036 - check alternative file location directory
Appreciate the patch!  However, in light of how simple the other two related functions are, I had another idea that might make the function in question behave correctly and make it simpler at the same time, and follow something closer to the existing pattern.  See the attached patch.

[attachment kidnapped by pirates]
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline emkay

  • 23
Re: [Patch] Mantis Bug 3036 - check alternative file location directory
I agree, yours is a much better solution.

Well, that's the thing if you're new to some big bunch of code - you hardly know where to start... :rolleyes:

EDIT: Btw, shouldn't there also be a line
Code: [Select]
Assert(CF_TYPE_SPECIFIED(dir_type)); in cf_exists_full() and cf_exists_full_ext(), as there is in cf_exists()?
« Last Edit: January 18, 2015, 04:16:16 am by emkay »

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: [Patch] Mantis Bug 3036 - check alternative file location directory
I was debating on even leaving it in cf_exists since the other two didn't have it, but decided that someone may have wanted that there for a specific reason.  It might be useful to have in all three but I wasn't interested in attaching my name to any more functions in svn blame than necessary ;)
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

  

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: [Patch] Mantis Bug 3036 - check alternative file location directory
The reason for the assertion in the old code is because cf_create_default_path_string() requires it (even though cf_create_default_path_string() has its own assertion for the exact same thing). Since the new version doesn't call it directly, but instead goes through cf_find_file_location() (which allows it to search all directory types if it wants to), the assertion doesn't need to be there at all, just like it isn't for the other two.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.