port in some improvements from OT (namely fs_basepath, etc, though commandline parsing isn't finished yet)

split up the headerfiles and such. common.[ch] and qwsvdef.h no longer exist. More work still needs to be done (esp for windows) but this should be a major improvement.
This commit is contained in:
Bill Currie 2000-05-21 08:24:45 +00:00
parent e471c785d8
commit af032b8d55
121 changed files with 1055 additions and 3086 deletions

View file

@ -35,8 +35,7 @@
#include <stdlib.h>
#include "bothdefs.h" // needed by: common.h, net.h, client.h
#include "common.h"
#include "quakefs.h"
#include "bspfile.h" // needed by: glquake.h
#include "vid.h"
#include "sys.h"
@ -358,7 +357,7 @@ byte *pcx_rgb;
LoadPCX
============
*/
void LoadPCX (FILE *f)
void LoadPCX (QFile *f)
{
pcx_t *pcx, pcxbuf;
byte palette[768];
@ -370,7 +369,7 @@ void LoadPCX (FILE *f)
//
// parse the PCX file
//
fread (&pcxbuf, 1, sizeof(pcxbuf), f);
Qread (f, &pcxbuf, sizeof(pcxbuf));
pcx = &pcxbuf;
@ -386,10 +385,10 @@ void LoadPCX (FILE *f)
}
// seek to palette
fseek (f, -768, SEEK_END);
fread (palette, 1, 768, f);
Qseek (f, -768, SEEK_END);
Qread (f, palette, 768);
fseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
Qseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
count = (pcx->xmax+1) * (pcx->ymax+1);
pcx_rgb = malloc( count * 4);
@ -399,12 +398,12 @@ void LoadPCX (FILE *f)
pix = pcx_rgb + 4*y*(pcx->xmax+1);
for (x=0 ; x<=pcx->ymax ; )
{
dataByte = fgetc(f);
dataByte = Qgetc(f);
if((dataByte & 0xC0) == 0xC0)
{
runLength = dataByte & 0x3F;
dataByte = fgetc(f);
dataByte = Qgetc(f);
}
else
runLength = 1;
@ -442,24 +441,24 @@ typedef struct _TargaHeader {
TargaHeader targa_header;
byte *targa_rgba;
int fgetLittleShort (FILE *f)
int fgetLittleShort (QFile *f)
{
byte b1, b2;
b1 = fgetc(f);
b2 = fgetc(f);
b1 = Qgetc(f);
b2 = Qgetc(f);
return (short)(b1 + b2*256);
}
int fgetLittleLong (FILE *f)
int fgetLittleLong (QFile *f)
{
byte b1, b2, b3, b4;
b1 = fgetc(f);
b2 = fgetc(f);
b3 = fgetc(f);
b4 = fgetc(f);
b1 = Qgetc(f);
b2 = Qgetc(f);
b3 = Qgetc(f);
b4 = Qgetc(f);
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
}
@ -470,26 +469,26 @@ int fgetLittleLong (FILE *f)
LoadTGA
=============
*/
void LoadTGA (FILE *fin)
void LoadTGA (QFile *fin)
{
int columns, rows, numPixels;
byte *pixbuf;
int row, column;
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
targa_header.id_length = fgetc(fin);
targa_header.colormap_type = fgetc(fin);
targa_header.image_type = fgetc(fin);
targa_header.id_length = Qgetc(fin);
targa_header.colormap_type = Qgetc(fin);
targa_header.image_type = Qgetc(fin);
targa_header.colormap_index = fgetLittleShort(fin);
targa_header.colormap_length = fgetLittleShort(fin);
targa_header.colormap_size = fgetc(fin);
targa_header.colormap_size = Qgetc(fin);
targa_header.x_origin = fgetLittleShort(fin);
targa_header.y_origin = fgetLittleShort(fin);
targa_header.width = fgetLittleShort(fin);
targa_header.height = fgetLittleShort(fin);
targa_header.pixel_size = fgetc(fin);
targa_header.attributes = fgetc(fin);
targa_header.pixel_size = Qgetc(fin);
targa_header.attributes = Qgetc(fin);
if (targa_header.image_type!=2
&& targa_header.image_type!=10)
@ -506,7 +505,7 @@ void LoadTGA (FILE *fin)
targa_rgba = malloc (numPixels*4);
if (targa_header.id_length != 0)
fseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
Qseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
if (targa_header.image_type==2) { // Uncompressed, RGB images
for(row=rows-1; row>=0; row--) {
@ -515,19 +514,19 @@ void LoadTGA (FILE *fin)
switch (targa_header.pixel_size) {
case 24:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
blue = Qgetc(fin);
green = Qgetc(fin);
red = Qgetc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
*pixbuf++ = 255;
break;
case 32:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
alphabyte = getc(fin);
blue = Qgetc(fin);
green = Qgetc(fin);
red = Qgetc(fin);
alphabyte = Qgetc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
@ -542,21 +541,21 @@ void LoadTGA (FILE *fin)
for(row=rows-1; row>=0; row--) {
pixbuf = targa_rgba + row*columns*4;
for(column=0; column<columns; ) {
packetHeader=getc(fin);
packetHeader=Qgetc(fin);
packetSize = 1 + (packetHeader & 0x7f);
if (packetHeader & 0x80) { // run-length packet
switch (targa_header.pixel_size) {
case 24:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
blue = Qgetc(fin);
green = Qgetc(fin);
red = Qgetc(fin);
alphabyte = 255;
break;
case 32:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
alphabyte = getc(fin);
blue = Qgetc(fin);
green = Qgetc(fin);
red = Qgetc(fin);
alphabyte = Qgetc(fin);
break;
}
@ -580,19 +579,19 @@ void LoadTGA (FILE *fin)
for(j=0;j<packetSize;j++) {
switch (targa_header.pixel_size) {
case 24:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
blue = Qgetc(fin);
green = Qgetc(fin);
red = Qgetc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
*pixbuf++ = 255;
break;
case 32:
blue = getc(fin);
green = getc(fin);
red = getc(fin);
alphabyte = getc(fin);
blue = Qgetc(fin);
green = Qgetc(fin);
red = Qgetc(fin);
alphabyte = Qgetc(fin);
*pixbuf++ = red;
*pixbuf++ = green;
*pixbuf++ = blue;
@ -615,7 +614,7 @@ void LoadTGA (FILE *fin)
}
}
fclose(fin);
Qclose(fin);
}
/*
@ -627,7 +626,7 @@ char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
void R_LoadSkys (char * skyname)
{
int i;
FILE *f;
QFile *f;
char name[64];
if (stricmp (skyname, "none") == 0)