Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sryder
SRB2
Commits
eb0f9681
Commit
eb0f9681
authored
7 years ago
by
Monster Iestyn
Browse files
Options
Downloads
Plain Diff
Merge branch 'findfile-rewrite' into 'master'
Rewrite of d_netfil.c's findfile See merge request
STJr/SRB2!240
parents
48a85512
9cdf8740
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/d_netfil.c
+30
-8
30 additions, 8 deletions
src/d_netfil.c
with
30 additions
and
8 deletions
src/d_netfil.c
+
30
−
8
View file @
eb0f9681
...
...
@@ -990,19 +990,41 @@ filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum)
return
FS_FOUND
;
// will never happen, but makes the compiler shut up
}
// Rewritten by Monster Iestyn to be less stupid
// Note: if completepath is true, "filename" is modified, but only if FS_FOUND is going to be returned
// (Don't worry about WinCE's version of filesearch, nobody cares about that OS anymore)
filestatus_t
findfile
(
char
*
filename
,
const
UINT8
*
wantedmd5sum
,
boolean
completepath
)
{
filestatus_t
homecheck
=
filesearch
(
filename
,
srb2home
,
wantedmd5sum
,
false
,
10
);
if
(
homecheck
==
FS_FOUND
)
return
filesearch
(
filename
,
srb2home
,
wantedmd5sum
,
completepath
,
10
);
filestatus_t
homecheck
;
// store result of last file search
boolean
badmd5
=
false
;
// store whether md5 was bad from either of the first two searches (if nothing was found in the third)
homecheck
=
filesearch
(
filename
,
srb2path
,
wantedmd5sum
,
false
,
10
);
if
(
homecheck
==
FS_FOUND
)
return
filesearch
(
filename
,
srb2path
,
wantedmd5sum
,
completepath
,
10
);
// first, check SRB2's "home" directory
homecheck
=
filesearch
(
filename
,
srb2home
,
wantedmd5sum
,
completepath
,
10
);
if
(
homecheck
==
FS_FOUND
)
// we found the file, so return that we have :)
return
FS_FOUND
;
else
if
(
homecheck
==
FS_MD5SUMBAD
)
// file has a bad md5; move on and look for a file with the right md5
badmd5
=
true
;
// if not found at all, just move on without doing anything
// next, check SRB2's "path" directory
homecheck
=
filesearch
(
filename
,
srb2path
,
wantedmd5sum
,
completepath
,
10
);
if
(
homecheck
==
FS_FOUND
)
// we found the file, so return that we have :)
return
FS_FOUND
;
else
if
(
homecheck
==
FS_MD5SUMBAD
)
// file has a bad md5; move on and look for a file with the right md5
badmd5
=
true
;
// if not found at all, just move on without doing anything
// finally check "." directory
#ifdef _arch_dreamcast
return
filesearch
(
filename
,
"/cd"
,
wantedmd5sum
,
completepath
,
10
);
homecheck
=
filesearch
(
filename
,
"/cd"
,
wantedmd5sum
,
completepath
,
10
);
#else
return
filesearch
(
filename
,
"."
,
wantedmd5sum
,
completepath
,
10
);
homecheck
=
filesearch
(
filename
,
"."
,
wantedmd5sum
,
completepath
,
10
);
#endif
if
(
homecheck
!=
FS_NOTFOUND
)
// if not found this time, fall back on the below return statement
return
homecheck
;
// otherwise return the result we got
return
(
badmd5
?
FS_MD5SUMBAD
:
FS_NOTFOUND
);
// md5 sum bad or file not found
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment