mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 01:11:18 +00:00
fix up a couple of error cases (and catch them!)
This commit is contained in:
parent
1f5cabcba9
commit
8a9cd78072
2 changed files with 9 additions and 5 deletions
|
@ -97,7 +97,7 @@ PR_LoadProgsFile (progs_t * pr, QFile *file, int size, int edicts, int zone)
|
|||
|
||||
pr->progs = 0;
|
||||
if (Qread (file, &progs, sizeof (progs)) != sizeof (progs))
|
||||
return;
|
||||
PR_Error (pr, "error reading header");
|
||||
|
||||
pr->progs_size = com_filesize;
|
||||
Sys_DPrintf ("Programs occupy %iK.\n", com_filesize / 1024);
|
||||
|
|
|
@ -93,10 +93,8 @@ open_file (const char *path, int *len)
|
|||
{
|
||||
QFile *file = Qopen (path, "rbz");
|
||||
|
||||
if (!file) {
|
||||
perror (path);
|
||||
if (!file)
|
||||
return 0;
|
||||
}
|
||||
*len = Qfilesize (file);
|
||||
return file;
|
||||
}
|
||||
|
@ -112,6 +110,7 @@ load_file (progs_t *pr, const char *name)
|
|||
if (!file) {
|
||||
file = open_file (va ("%s.gz", name), &size);
|
||||
if (!file) {
|
||||
perror (name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +195,10 @@ load_progs (const char *name)
|
|||
pr.progs_name = name;
|
||||
PR_LoadProgsFile (&pr, file, size, 1, 0);
|
||||
Qclose (file);
|
||||
|
||||
if (!pr.progs)
|
||||
return 0;
|
||||
|
||||
PR_LoadStrings (&pr);
|
||||
|
||||
for (i = 0; i < pr.progs->numfunctions; i++) {
|
||||
|
@ -244,7 +247,8 @@ main (int argc, char **argv)
|
|||
}
|
||||
init_qf ();
|
||||
while (optind < argc) {
|
||||
load_progs (argv[optind++]);
|
||||
if (!load_progs (argv[optind++]))
|
||||
return 1;
|
||||
func (&pr);
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue