mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-03-23 11:22:05 +00:00
Merge in den Trunk:
- OGG/Vorbis Support - pk3 Support (ungetestet)
This commit is contained in:
parent
caa63853c3
commit
b6f5dadf4c
21 changed files with 4699 additions and 1117 deletions
42
Makefile
42
Makefile
|
@ -58,6 +58,9 @@ endif
|
|||
# work on all CPUs. Adjust to your needs
|
||||
# CFLAFS_BASE += -mmmx -msse -msse2 -msse3 -m3dnow
|
||||
|
||||
# OGG/Vorbis
|
||||
OGGCFLAGS = -I/usr/include -I/usr/local/include
|
||||
|
||||
# SDL
|
||||
SDLCFLAGS = $(shell sdl-config --cflags)
|
||||
|
||||
|
@ -100,9 +103,15 @@ ifeq ($(OSTYPE),FreeBSD)
|
|||
LDFLAGS=-lm
|
||||
endif
|
||||
|
||||
# OGG/Vorbis
|
||||
OGGLDFLAGS = -lvorbis -lvorbisfile -logg
|
||||
|
||||
# SDL
|
||||
SDLLDFLAGS=$(shell sdl-config --libs)
|
||||
|
||||
# ZLib
|
||||
ZLDFLAGS = -lz
|
||||
|
||||
# OpenGL
|
||||
OPENGLLDFLAGS = -shared
|
||||
|
||||
|
@ -129,6 +138,7 @@ client:
|
|||
build/posix/vid \
|
||||
build/sdl \
|
||||
build/server \
|
||||
build/unzip \
|
||||
release
|
||||
$(MAKE) release/quake2
|
||||
|
||||
|
@ -188,7 +198,8 @@ CLIENT_OBJS = \
|
|||
build/client/menu/qmenu.o \
|
||||
build/client/sound/snd_dma.o \
|
||||
build/client/sound/snd_mem.o \
|
||||
build/client/sound/snd_mix.o
|
||||
build/client/sound/snd_mix.o \
|
||||
build/client/sound/snd_ogg.o
|
||||
|
||||
# ---------
|
||||
|
||||
|
@ -206,6 +217,13 @@ COMMON_OBJS = \
|
|||
|
||||
# ----------
|
||||
|
||||
# Unzip Object
|
||||
UNZIP_OBJ = \
|
||||
build/unzip/ioapi.o \
|
||||
build/unzip/unzip.o
|
||||
|
||||
# ----------
|
||||
|
||||
# Game ABI objets
|
||||
GAME_ABI_OBJS = \
|
||||
build/gameabi/m_flash.o \
|
||||
|
@ -452,6 +470,9 @@ build/client/sound/snd_mem.o : src/client/sound/snd_mem.c
|
|||
build/client/sound/snd_mix.o : src/client/sound/snd_mix.c
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
|
||||
|
||||
build/client/sound/snd_ogg.o : src/client/sound/snd_ogg.c
|
||||
$(CC) $(CFLAGS_CLIENT) $(OGGCFLAGS) -o $@ -c $<
|
||||
|
||||
# ---------
|
||||
|
||||
# Common build
|
||||
|
@ -484,6 +505,14 @@ build/common/pmove.o : src/common/pmove.c
|
|||
|
||||
# ----------
|
||||
|
||||
build/unzip/ioapi.o : src/unzip/ioapi.c
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
|
||||
|
||||
build/unzip/unzip.o : src/unzip/unzip.c
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
|
||||
|
||||
# ----------
|
||||
|
||||
# Game ABI build
|
||||
build/gameabi/m_flash.o : src/game/baseq2/m_flash.c
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ -c $<
|
||||
|
@ -903,16 +932,17 @@ build/ctf/q_shared.o: src/game/ctf/q_shared.c
|
|||
|
||||
# The client
|
||||
release/quake2 : $(CLIENT_OBJS) $(COMMON_OBJS) $(GAME_ABI_OBJS) \
|
||||
$(SERVER_OBJS) $(POSIX_OBJS) $(SDL_OBJS)
|
||||
$(UNZIP_OBJ) $(SERVER_OBJS) $(POSIX_OBJS) $(SDL_OBJS)
|
||||
$(CC) $(CFLAGS_CLIENT) -o $@ $(CLIENT_OBJS) $(COMMON_OBJS) $(GAME_ABI_OBJS) \
|
||||
$(SERVER_OBJS) $(POSIX_OBJS) $(SDL_OBJS) $(LDFLAGS) $(SDLLDFLAGS)
|
||||
$(SERVER_OBJS) $(POSIX_OBJS) $(SDL_OBJS) $(UNZIP_OBJ) $(LDFLAGS) \
|
||||
$(SDLLDFLAGS) $(OGGLDFLAGS) $(ZLDFLAGS)
|
||||
|
||||
# Dedicated Server
|
||||
release/q2ded : $(DEDICATED_SERVER_OBJS) $(DEDICATED_SERVER_COMMON_OBJS) \
|
||||
$(GAME_ABI_OBJS) $(DEDICATED_SERVER_POSIX_OBJS)
|
||||
$(GAME_ABI_OBJS) $(DEDICATED_SERVER_POSIX_OBJS) $(UNZIP_OBJ)
|
||||
$(CC) $(CFLAGS_DEDICATED_SERVER) -o $@ $(DEDICATED_SERVER_OBJS) \
|
||||
$(DEDICATED_SERVER_COMMON_OBJS) $(GAME_ABI_OBJS) \
|
||||
$(DEDICATED_SERVER_POSIX_OBJS) $(LDFLAGS)
|
||||
$(DEDICATED_SERVER_COMMON_OBJS) $(GAME_ABI_OBJS) $(UNZIP_OBJ)\
|
||||
$(DEDICATED_SERVER_POSIX_OBJS) $(LDFLAGS) $(ZLDFLAGS)
|
||||
|
||||
# OpenGL refresher
|
||||
release/ref_gl.so : $(OPENGL_OBJS) $(OPENGL_POSIX_OBJS) $(OPENGL_GAME_OBJS)
|
||||
|
|
|
@ -1,32 +1,30 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
* Copyright (C) 1997-2001 Id Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
#include "header/client.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte *data;
|
||||
typedef struct {
|
||||
byte *data;
|
||||
int count;
|
||||
} cblock_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
qboolean restart_sound;
|
||||
int s_rate;
|
||||
int s_width;
|
||||
|
@ -34,11 +32,11 @@ typedef struct
|
|||
|
||||
int width;
|
||||
int height;
|
||||
byte *pic;
|
||||
byte *pic_pending;
|
||||
byte *pic;
|
||||
byte *pic_pending;
|
||||
|
||||
// order 1 huffman stuff
|
||||
int *hnodes1; // [256][256][2];
|
||||
/* order 1 huffman stuff */
|
||||
int *hnodes1;/* [256][256][2]; */
|
||||
int numhnodes1[256];
|
||||
|
||||
int h_used[512];
|
||||
|
@ -48,182 +46,160 @@ typedef struct
|
|||
cinematics_t cin;
|
||||
|
||||
/*
|
||||
=================================================================
|
||||
|
||||
PCX LOADING
|
||||
|
||||
=================================================================
|
||||
*/
|
||||
* =================================================================
|
||||
*
|
||||
* PCX LOADING
|
||||
*
|
||||
* =================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
SCR_LoadPCX
|
||||
==============
|
||||
*/
|
||||
void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)
|
||||
* ==============
|
||||
* SCR_LoadPCX
|
||||
* ==============
|
||||
*/
|
||||
void
|
||||
SCR_LoadPCX(char *filename, byte ** pic, byte ** palette, int *width, int *height)
|
||||
{
|
||||
byte *raw;
|
||||
pcx_t *pcx;
|
||||
int x, y;
|
||||
byte *raw;
|
||||
pcx_t *pcx;
|
||||
int x , y;
|
||||
int len;
|
||||
int dataByte, runLength;
|
||||
byte *out, *pix;
|
||||
int dataByte , runLength;
|
||||
byte *out, *pix;
|
||||
|
||||
*pic = NULL;
|
||||
|
||||
//
|
||||
// load the file
|
||||
//
|
||||
len = FS_LoadFile (filename, (void **)&raw);
|
||||
/* load the file */
|
||||
len = FS_LoadFile(filename, (void **)&raw);
|
||||
if (!raw)
|
||||
return; // Com_Printf ("Bad pcx file %s\n", filename);
|
||||
return; /* Com_Printf ("Bad pcx file %s\n", filename); */
|
||||
|
||||
//
|
||||
// parse the PCX file
|
||||
//
|
||||
pcx = (pcx_t *)raw;
|
||||
/* parse the PCX file */
|
||||
pcx = (pcx_t *) raw;
|
||||
raw = &pcx->data;
|
||||
|
||||
if (pcx->manufacturer != 0x0a
|
||||
|| pcx->version != 5
|
||||
|| pcx->encoding != 1
|
||||
|| pcx->bits_per_pixel != 8
|
||||
|| pcx->xmax >= 640
|
||||
|| pcx->ymax >= 480)
|
||||
{
|
||||
Com_Printf ("Bad pcx file %s\n", filename);
|
||||
|| pcx->version != 5
|
||||
|| pcx->encoding != 1
|
||||
|| pcx->bits_per_pixel != 8
|
||||
|| pcx->xmax >= 640
|
||||
|| pcx->ymax >= 480) {
|
||||
Com_Printf("Bad pcx file %s\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
out = Z_Malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
|
||||
out = Z_Malloc((pcx->ymax + 1) * (pcx->xmax + 1));
|
||||
|
||||
*pic = out;
|
||||
|
||||
pix = out;
|
||||
|
||||
if (palette)
|
||||
{
|
||||
if (palette) {
|
||||
*palette = Z_Malloc(768);
|
||||
memcpy (*palette, (byte *)pcx + len - 768, 768);
|
||||
memcpy(*palette, (byte *) pcx + len - 768, 768);
|
||||
}
|
||||
|
||||
if (width)
|
||||
*width = pcx->xmax+1;
|
||||
*width = pcx->xmax + 1;
|
||||
if (height)
|
||||
*height = pcx->ymax+1;
|
||||
*height = pcx->ymax + 1;
|
||||
|
||||
for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
|
||||
{
|
||||
for (x=0 ; x<=pcx->xmax ; )
|
||||
{
|
||||
for (y = 0; y <= pcx->ymax; y++, pix += pcx->xmax + 1) {
|
||||
for (x = 0; x <= pcx->xmax;) {
|
||||
dataByte = *raw++;
|
||||
|
||||
if((dataByte & 0xC0) == 0xC0)
|
||||
{
|
||||
if ((dataByte & 0xC0) == 0xC0) {
|
||||
runLength = dataByte & 0x3F;
|
||||
dataByte = *raw++;
|
||||
}
|
||||
else
|
||||
} else
|
||||
runLength = 1;
|
||||
|
||||
while(runLength-- > 0)
|
||||
while (runLength-- > 0)
|
||||
pix[x++] = dataByte;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( raw - (byte *)pcx > len)
|
||||
{
|
||||
Com_Printf ("PCX file %s was malformed", filename);
|
||||
Z_Free (*pic);
|
||||
if (raw - (byte *) pcx > len) {
|
||||
Com_Printf("PCX file %s was malformed", filename);
|
||||
Z_Free(*pic);
|
||||
*pic = NULL;
|
||||
}
|
||||
|
||||
FS_FreeFile (pcx);
|
||||
FS_FreeFile(pcx);
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
/* ============================================================= */
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_StopCinematic
|
||||
==================
|
||||
*/
|
||||
void SCR_StopCinematic (void)
|
||||
* ================== SCR_StopCinematic ==================
|
||||
*/
|
||||
void
|
||||
SCR_StopCinematic(void)
|
||||
{
|
||||
cl.cinematictime = 0; // done
|
||||
if (cin.pic)
|
||||
{
|
||||
Z_Free (cin.pic);
|
||||
cl.cinematictime = 0; /* done */
|
||||
if (cin.pic) {
|
||||
Z_Free(cin.pic);
|
||||
cin.pic = NULL;
|
||||
}
|
||||
if (cin.pic_pending)
|
||||
{
|
||||
Z_Free (cin.pic_pending);
|
||||
if (cin.pic_pending) {
|
||||
Z_Free(cin.pic_pending);
|
||||
cin.pic_pending = NULL;
|
||||
}
|
||||
if (cl.cinematicpalette_active)
|
||||
{
|
||||
if (cl.cinematicpalette_active) {
|
||||
re.CinematicSetPalette(NULL);
|
||||
cl.cinematicpalette_active = false;
|
||||
}
|
||||
if (cl.cinematic_file)
|
||||
{
|
||||
fclose (cl.cinematic_file);
|
||||
cl.cinematic_file = NULL;
|
||||
if (cl.cinematic_file) {
|
||||
FS_FCloseFile((size_t)cl.cinematic_file);
|
||||
cl.cinematic_file = 0;
|
||||
}
|
||||
if (cin.hnodes1)
|
||||
{
|
||||
Z_Free (cin.hnodes1);
|
||||
if (cin.hnodes1) {
|
||||
Z_Free(cin.hnodes1);
|
||||
cin.hnodes1 = NULL;
|
||||
}
|
||||
|
||||
// switch back down to 11 khz sound if necessary
|
||||
if (cin.restart_sound)
|
||||
{
|
||||
/* switch back down to 11 khz sound if necessary */
|
||||
if (cin.restart_sound) {
|
||||
cin.restart_sound = false;
|
||||
CL_Snd_Restart_f ();
|
||||
CL_Snd_Restart_f();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
SCR_FinishCinematic
|
||||
|
||||
Called when either the cinematic completes, or it is aborted
|
||||
====================
|
||||
*/
|
||||
void SCR_FinishCinematic (void)
|
||||
* ====================
|
||||
* SCR_FinishCinematic
|
||||
*
|
||||
* Called when either the cinematic completes, or it is aborted
|
||||
* ====================
|
||||
*/
|
||||
void
|
||||
SCR_FinishCinematic(void)
|
||||
{
|
||||
// tell the server to advance to the next map / cinematic
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
SZ_Print (&cls.netchan.message, va("nextserver %i\n", cl.servercount));
|
||||
/* tell the server to advance to the next map / cinematic */
|
||||
MSG_WriteByte(&cls.netchan.message, clc_stringcmd);
|
||||
SZ_Print(&cls.netchan.message, va("nextserver %i\n", cl.servercount));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
/* ========================================================================== */
|
||||
|
||||
/*
|
||||
==================
|
||||
SmallestNode1
|
||||
==================
|
||||
*/
|
||||
int SmallestNode1 (int numhnodes)
|
||||
* ==================
|
||||
* SmallestNode1
|
||||
* ==================
|
||||
*/
|
||||
int
|
||||
SmallestNode1(int numhnodes)
|
||||
{
|
||||
int i;
|
||||
int best, bestnode;
|
||||
int best , bestnode;
|
||||
|
||||
best = 99999999;
|
||||
bestnode = -1;
|
||||
for (i=0 ; i<numhnodes ; i++)
|
||||
{
|
||||
for (i = 0; i < numhnodes; i++) {
|
||||
if (cin.h_used[i])
|
||||
continue;
|
||||
if (!cin.h_count[i])
|
||||
continue;
|
||||
if (cin.h_count[i] < best)
|
||||
{
|
||||
if (cin.h_count[i] < best) {
|
||||
best = cin.h_count[i];
|
||||
bestnode = i;
|
||||
}
|
||||
|
@ -238,47 +214,46 @@ int SmallestNode1 (int numhnodes)
|
|||
|
||||
|
||||
/*
|
||||
==================
|
||||
Huff1TableInit
|
||||
|
||||
Reads the 64k counts table and initializes the node trees
|
||||
==================
|
||||
*/
|
||||
void Huff1TableInit (void)
|
||||
* ==================
|
||||
* Huff1TableInit
|
||||
*
|
||||
* Reads the 64k counts table and initializes the node trees
|
||||
* ==================
|
||||
*/
|
||||
void
|
||||
Huff1TableInit(void)
|
||||
{
|
||||
int prev;
|
||||
int j;
|
||||
int *node, *nodebase;
|
||||
byte counts[256];
|
||||
int *node, *nodebase;
|
||||
byte counts [256];
|
||||
int numhnodes;
|
||||
|
||||
cin.hnodes1 = Z_Malloc (256*256*2*4);
|
||||
memset (cin.hnodes1, 0, 256*256*2*4);
|
||||
cin.hnodes1 = Z_Malloc(256 * 256 * 2 * 4);
|
||||
memset(cin.hnodes1, 0, 256 * 256 * 2 * 4);
|
||||
|
||||
for (prev=0 ; prev<256 ; prev++)
|
||||
{
|
||||
memset (cin.h_count,0,sizeof(cin.h_count));
|
||||
memset (cin.h_used,0,sizeof(cin.h_used));
|
||||
for (prev = 0; prev < 256; prev++) {
|
||||
memset(cin.h_count, 0, sizeof(cin.h_count));
|
||||
memset(cin.h_used, 0, sizeof(cin.h_used));
|
||||
|
||||
// read a row of counts
|
||||
FS_Read (counts, sizeof(counts), cl.cinematic_file);
|
||||
for (j=0 ; j<256 ; j++)
|
||||
/* read a row of counts */
|
||||
FS_Read(counts, sizeof(counts), (size_t)cl.cinematic_file);
|
||||
for (j = 0; j < 256; j++)
|
||||
cin.h_count[j] = counts[j];
|
||||
|
||||
// build the nodes
|
||||
/* build the nodes */
|
||||
numhnodes = 256;
|
||||
nodebase = cin.hnodes1 + prev*256*2;
|
||||
nodebase = cin.hnodes1 + prev * 256 * 2;
|
||||
|
||||
while (numhnodes != 511)
|
||||
{
|
||||
node = nodebase + (numhnodes-256)*2;
|
||||
while (numhnodes != 511) {
|
||||
node = nodebase + (numhnodes - 256) * 2;
|
||||
|
||||
// pick two lowest counts
|
||||
node[0] = SmallestNode1 (numhnodes);
|
||||
/* pick two lowest counts */
|
||||
node[0] = SmallestNode1(numhnodes);
|
||||
if (node[0] == -1)
|
||||
break; // no more
|
||||
break; /* no more */
|
||||
|
||||
node[1] = SmallestNode1 (numhnodes);
|
||||
node[1] = SmallestNode1(numhnodes);
|
||||
if (node[1] == -1)
|
||||
break;
|
||||
|
||||
|
@ -286,133 +261,123 @@ void Huff1TableInit (void)
|
|||
numhnodes++;
|
||||
}
|
||||
|
||||
cin.numhnodes1[prev] = numhnodes-1;
|
||||
cin.numhnodes1[prev] = numhnodes - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Huff1Decompress
|
||||
==================
|
||||
*/
|
||||
cblock_t Huff1Decompress (cblock_t in)
|
||||
* ==================
|
||||
* Huff1Decompress
|
||||
* ==================
|
||||
*/
|
||||
cblock_t
|
||||
Huff1Decompress(cblock_t in)
|
||||
{
|
||||
byte *input;
|
||||
byte *out_p;
|
||||
int nodenum;
|
||||
int count;
|
||||
byte *input;
|
||||
byte *out_p;
|
||||
int nodenum;
|
||||
int count;
|
||||
cblock_t out;
|
||||
int inbyte;
|
||||
int *hnodes, *hnodesbase;
|
||||
//int i;
|
||||
int inbyte;
|
||||
int *hnodes, *hnodesbase;
|
||||
/* int i; */
|
||||
|
||||
// get decompressed count
|
||||
count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) + (in.data[3]<<24);
|
||||
/* get decompressed count */
|
||||
count = in.data[0] + (in.data[1] << 8) + (in.data[2] << 16) + (in.data[3] << 24);
|
||||
input = in.data + 4;
|
||||
out_p = out.data = Z_Malloc (count);
|
||||
out_p = out.data = Z_Malloc(count);
|
||||
|
||||
// read bits
|
||||
|
||||
hnodesbase = cin.hnodes1 - 256*2; // nodes 0-255 aren't stored
|
||||
/* read bits */
|
||||
hnodesbase = cin.hnodes1 - 256 * 2; /* nodes 0-255 aren't stored */
|
||||
|
||||
hnodes = hnodesbase;
|
||||
nodenum = cin.numhnodes1[0];
|
||||
while (count)
|
||||
{
|
||||
while (count) {
|
||||
inbyte = *input++;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
//-----------
|
||||
if (nodenum < 256)
|
||||
{
|
||||
hnodes = hnodesbase + (nodenum<<9);
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
/*----------- */
|
||||
if (nodenum < 256) {
|
||||
hnodes = hnodesbase + (nodenum << 9);
|
||||
*out_p++ = nodenum;
|
||||
if (!--count)
|
||||
break;
|
||||
nodenum = cin.numhnodes1[nodenum];
|
||||
}
|
||||
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
||||
inbyte >>=1;
|
||||
nodenum = hnodes[nodenum * 2 + (inbyte & 1)];
|
||||
inbyte >>= 1;
|
||||
}
|
||||
|
||||
if (input - in.data != in.count && input - in.data != in.count+1)
|
||||
{
|
||||
Com_Printf ("Decompression overread by %i", (input - in.data) - in.count);
|
||||
if (input - in.data != in.count && input - in.data != in.count + 1) {
|
||||
Com_Printf("Decompression overread by %i", (input - in.data) - in.count);
|
||||
}
|
||||
out.count = out_p - out.data;
|
||||
|
||||
|
@ -420,58 +385,57 @@ cblock_t Huff1Decompress (cblock_t in)
|
|||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_ReadNextFrame
|
||||
==================
|
||||
*/
|
||||
byte *SCR_ReadNextFrame (void)
|
||||
* ==================
|
||||
* SCR_ReadNextFrame
|
||||
* ==================
|
||||
*/
|
||||
byte *
|
||||
SCR_ReadNextFrame(void)
|
||||
{
|
||||
int r;
|
||||
int command;
|
||||
byte samples[22050/14*4];
|
||||
byte compressed[0x20000];
|
||||
byte samples [22050 / 14 * 4];
|
||||
byte compressed[0x20000];
|
||||
int size;
|
||||
byte *pic;
|
||||
cblock_t in, huf1;
|
||||
int start, end, count;
|
||||
byte *pic;
|
||||
cblock_t in , huf1;
|
||||
int start , end, count;
|
||||
|
||||
// read the next frame
|
||||
r = fread (&command, 4, 1, cl.cinematic_file);
|
||||
if (r == 0) // we'll give it one more chance
|
||||
r = fread (&command, 4, 1, cl.cinematic_file);
|
||||
/* read the next frame */
|
||||
r = FS_FRead(&command, 4, 1, (size_t)cl.cinematic_file);
|
||||
if (r == 0) /* we'll give it one more chance */
|
||||
r = FS_FRead(&command, 4, 1, (size_t)cl.cinematic_file);
|
||||
|
||||
if (r != 1)
|
||||
if (r != 4) /* was 1 */
|
||||
return NULL;
|
||||
command = LittleLong(command);
|
||||
if (command == 2)
|
||||
return NULL; // last frame marker
|
||||
return NULL; /* last frame marker */
|
||||
|
||||
if (command == 1)
|
||||
{ // read palette
|
||||
FS_Read (cl.cinematicpalette, sizeof(cl.cinematicpalette), cl.cinematic_file);
|
||||
cl.cinematicpalette_active=0; // dubious.... exposes an edge case
|
||||
if (command == 1) { /* read palette */
|
||||
FS_Read(cl.cinematicpalette, sizeof(cl.cinematicpalette), (size_t)cl.cinematic_file);
|
||||
cl.cinematicpalette_active = 0; /* dubious.... exposes an edge case */
|
||||
}
|
||||
|
||||
// decompress the next frame
|
||||
FS_Read (&size, 4, cl.cinematic_file);
|
||||
/* decompress the next frame */
|
||||
FS_Read(&size, 4, (size_t)cl.cinematic_file);
|
||||
size = LittleLong(size);
|
||||
if (size > sizeof(compressed) || size < 1)
|
||||
Com_Error (ERR_DROP, "Bad compressed frame size");
|
||||
FS_Read (compressed, size, cl.cinematic_file);
|
||||
Com_Error(ERR_DROP, "Bad compressed frame size");
|
||||
FS_Read(compressed, size, (size_t)cl.cinematic_file);
|
||||
|
||||
// read sound
|
||||
start = cl.cinematicframe*cin.s_rate/14;
|
||||
end = (cl.cinematicframe+1)*cin.s_rate/14;
|
||||
/* read sound */
|
||||
start = cl.cinematicframe * cin.s_rate / 14;
|
||||
end = (cl.cinematicframe + 1) * cin.s_rate / 14;
|
||||
count = end - start;
|
||||
|
||||
FS_Read (samples, count*cin.s_width*cin.s_channels, cl.cinematic_file);
|
||||
FS_Read(samples, count * cin.s_width * cin.s_channels, (size_t)cl.cinematic_file);
|
||||
|
||||
S_RawSamples (count, cin.s_rate, cin.s_width, cin.s_channels, samples);
|
||||
S_RawSamples(count, cin.s_rate, cin.s_width, cin.s_channels, samples);
|
||||
|
||||
in.data = compressed;
|
||||
in.count = size;
|
||||
|
||||
huf1 = Huff1Decompress (in);
|
||||
huf1 = Huff1Decompress(in);
|
||||
|
||||
pic = huf1.data;
|
||||
|
||||
|
@ -482,168 +446,151 @@ byte *SCR_ReadNextFrame (void)
|
|||
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_RunCinematic
|
||||
|
||||
==================
|
||||
*/
|
||||
void SCR_RunCinematic (void)
|
||||
* ==================
|
||||
* SCR_RunCinematic
|
||||
* ==================
|
||||
*/
|
||||
void
|
||||
SCR_RunCinematic(void)
|
||||
{
|
||||
int frame;
|
||||
|
||||
if (cl.cinematictime <= 0)
|
||||
{
|
||||
SCR_StopCinematic ();
|
||||
if (cl.cinematictime <= 0) {
|
||||
SCR_StopCinematic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cl.cinematicframe == -1)
|
||||
return; // static image
|
||||
return; /* static image */
|
||||
|
||||
if (cls.key_dest != key_game)
|
||||
{ // pause if menu or console is up
|
||||
cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
|
||||
if (cls.key_dest != key_game)
|
||||
{ /* pause if menu or console is up */
|
||||
cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14;
|
||||
return;
|
||||
}
|
||||
|
||||
frame = (cls.realtime - cl.cinematictime)*14.0/1000;
|
||||
frame = (cls.realtime - cl.cinematictime) * 14.0 / 1000;
|
||||
if (frame <= cl.cinematicframe)
|
||||
return;
|
||||
if (frame > cl.cinematicframe+1)
|
||||
{
|
||||
Com_Printf ("Dropped frame: %i > %i\n", frame, cl.cinematicframe+1);
|
||||
cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
|
||||
if (frame > cl.cinematicframe + 1) {
|
||||
Com_Printf("Dropped frame: %i > %i\n", frame, cl.cinematicframe + 1);
|
||||
cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14;
|
||||
}
|
||||
if (cin.pic)
|
||||
Z_Free (cin.pic);
|
||||
Z_Free(cin.pic);
|
||||
cin.pic = cin.pic_pending;
|
||||
cin.pic_pending = NULL;
|
||||
cin.pic_pending = SCR_ReadNextFrame ();
|
||||
if (!cin.pic_pending)
|
||||
{
|
||||
SCR_StopCinematic ();
|
||||
SCR_FinishCinematic ();
|
||||
cl.cinematictime = 1; // hack to get the black screen behind loading
|
||||
SCR_BeginLoadingPlaque ();
|
||||
cin.pic_pending = SCR_ReadNextFrame();
|
||||
if (!cin.pic_pending) {
|
||||
SCR_StopCinematic();
|
||||
SCR_FinishCinematic();
|
||||
cl.cinematictime = 1; /* hack to get the black screen behind loading */
|
||||
SCR_BeginLoadingPlaque();
|
||||
cl.cinematictime = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_DrawCinematic
|
||||
|
||||
Returns true if a cinematic is active, meaning the view rendering
|
||||
should be skipped
|
||||
==================
|
||||
*/
|
||||
qboolean SCR_DrawCinematic (void)
|
||||
* ==================
|
||||
* SCR_DrawCinematic
|
||||
*
|
||||
* Returns true if a cinematic is active, meaning the view rendering should be
|
||||
* skipped
|
||||
* ==================
|
||||
*/
|
||||
qboolean
|
||||
SCR_DrawCinematic(void)
|
||||
{
|
||||
if (cl.cinematictime <= 0)
|
||||
{
|
||||
if (cl.cinematictime <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cls.key_dest == key_menu)
|
||||
{ // blank screen and pause if menu is up
|
||||
if (cls.key_dest == key_menu) { /* blank screen and pause if menu is up */
|
||||
re.CinematicSetPalette(NULL);
|
||||
cl.cinematicpalette_active = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!cl.cinematicpalette_active)
|
||||
{
|
||||
if (!cl.cinematicpalette_active) {
|
||||
re.CinematicSetPalette(cl.cinematicpalette);
|
||||
cl.cinematicpalette_active = true;
|
||||
}
|
||||
|
||||
if (!cin.pic)
|
||||
return true;
|
||||
|
||||
re.DrawStretchRaw (0, 0, viddef.width, viddef.height,
|
||||
cin.width, cin.height, cin.pic);
|
||||
re.DrawStretchRaw(0, 0, viddef.width, viddef.height,
|
||||
cin.width, cin.height, cin.pic);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_PlayCinematic
|
||||
|
||||
==================
|
||||
*/
|
||||
void SCR_PlayCinematic (char *arg)
|
||||
* ==================
|
||||
* SCR_PlayCinematic
|
||||
* ==================
|
||||
*/
|
||||
void
|
||||
SCR_PlayCinematic(char *arg)
|
||||
{
|
||||
int width, height;
|
||||
byte *palette;
|
||||
char name[MAX_OSPATH], *dot;
|
||||
byte *palette;
|
||||
char name[MAX_OSPATH], *dot;
|
||||
int old_khz;
|
||||
|
||||
// make sure CD isn't playing music
|
||||
/* make sure CD isn't playing music */
|
||||
CDAudio_Stop();
|
||||
OGG_Stop();
|
||||
|
||||
cl.cinematicframe = 0;
|
||||
dot = strstr (arg, ".");
|
||||
if (dot && !strcmp (dot, ".pcx"))
|
||||
{ // static pcx image
|
||||
Com_sprintf (name, sizeof(name), "pics/%s", arg);
|
||||
SCR_LoadPCX (name, &cin.pic, &palette, &cin.width, &cin.height);
|
||||
dot = strstr(arg, ".");
|
||||
if (dot && !strcmp(dot, ".pcx")) { /* static pcx image */
|
||||
Com_sprintf(name, sizeof(name), "pics/%s", arg);
|
||||
SCR_LoadPCX(name, &cin.pic, &palette, &cin.width, &cin.height);
|
||||
cl.cinematicframe = -1;
|
||||
cl.cinematictime = 1;
|
||||
SCR_EndLoadingPlaque ();
|
||||
SCR_EndLoadingPlaque();
|
||||
cls.state = ca_active;
|
||||
if (!cin.pic)
|
||||
{
|
||||
Com_Printf ("%s not found.\n", name);
|
||||
if (!cin.pic) {
|
||||
Com_Printf("%s not found.\n", name);
|
||||
cl.cinematictime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette));
|
||||
Z_Free (palette);
|
||||
} else {
|
||||
memcpy(cl.cinematicpalette, palette, sizeof(cl.cinematicpalette));
|
||||
Z_Free(palette);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Com_sprintf (name, sizeof(name), "video/%s", arg);
|
||||
FS_FOpenFile (name, &cl.cinematic_file);
|
||||
if (!cl.cinematic_file)
|
||||
{
|
||||
SCR_FinishCinematic ();
|
||||
cl.cinematictime = 0; // done
|
||||
Com_sprintf(name, sizeof(name), "video/%s", arg);
|
||||
FS_FOpenFile(name, (fileHandle_t *) &cl.cinematic_file, FS_READ);
|
||||
if (!cl.cinematic_file) {
|
||||
/* Com_Error (ERR_DROP, "Cinematic %s not found.\n", name); */
|
||||
SCR_FinishCinematic();
|
||||
cl.cinematictime = 0; /* done */
|
||||
return;
|
||||
}
|
||||
|
||||
SCR_EndLoadingPlaque ();
|
||||
SCR_EndLoadingPlaque();
|
||||
|
||||
cls.state = ca_active;
|
||||
|
||||
FS_Read (&width, 4, cl.cinematic_file);
|
||||
FS_Read (&height, 4, cl.cinematic_file);
|
||||
FS_Read(&width, 4, (size_t)cl.cinematic_file);
|
||||
FS_Read(&height, 4, (size_t)cl.cinematic_file);
|
||||
cin.width = LittleLong(width);
|
||||
cin.height = LittleLong(height);
|
||||
|
||||
FS_Read (&cin.s_rate, 4, cl.cinematic_file);
|
||||
FS_Read(&cin.s_rate, 4, (size_t)cl.cinematic_file);
|
||||
cin.s_rate = LittleLong(cin.s_rate);
|
||||
FS_Read (&cin.s_width, 4, cl.cinematic_file);
|
||||
FS_Read(&cin.s_width, 4, (size_t)cl.cinematic_file);
|
||||
cin.s_width = LittleLong(cin.s_width);
|
||||
FS_Read (&cin.s_channels, 4, cl.cinematic_file);
|
||||
FS_Read(&cin.s_channels, 4, (size_t)cl.cinematic_file);
|
||||
cin.s_channels = LittleLong(cin.s_channels);
|
||||
|
||||
Huff1TableInit ();
|
||||
Huff1TableInit();
|
||||
|
||||
// switch up to 22 khz sound if necessary
|
||||
old_khz = Cvar_VariableValue ("s_khz");
|
||||
if (old_khz != cin.s_rate/1000)
|
||||
{
|
||||
/* switch up to 22 khz sound if necessary */
|
||||
old_khz = Cvar_VariableValue("s_khz");
|
||||
if (old_khz != cin.s_rate / 1000) {
|
||||
cin.restart_sound = true;
|
||||
Cvar_SetValue ("s_khz", cin.s_rate/1000);
|
||||
CL_Snd_Restart_f ();
|
||||
Cvar_SetValue ("s_khz", old_khz);
|
||||
Cvar_SetValue("s_khz", cin.s_rate / 1000);
|
||||
CL_Snd_Restart_f();
|
||||
Cvar_SetValue("s_khz", old_khz);
|
||||
}
|
||||
|
||||
cl.cinematicframe = 0;
|
||||
cin.pic = SCR_ReadNextFrame ();
|
||||
cl.cinematictime = Sys_Milliseconds ();
|
||||
cin.pic = SCR_ReadNextFrame();
|
||||
cl.cinematictime = Sys_Milliseconds();
|
||||
}
|
||||
|
|
|
@ -1798,7 +1798,6 @@ void CL_Init (void)
|
|||
CL_InitLocal ();
|
||||
IN_Init ();
|
||||
|
||||
// Cbuf_AddText ("exec autoexec.cfg\n");
|
||||
FS_ExecAutoexec ();
|
||||
Cbuf_Execute ();
|
||||
|
||||
|
@ -1827,6 +1826,7 @@ void CL_Shutdown(void)
|
|||
CL_WriteConfiguration ();
|
||||
|
||||
CDAudio_Shutdown ();
|
||||
OGG_Stop();
|
||||
S_Shutdown();
|
||||
IN_Shutdown ();
|
||||
VID_Shutdown();
|
||||
|
|
|
@ -532,7 +532,10 @@ void CL_ParseConfigString (void)
|
|||
else if (i == CS_CDTRACK)
|
||||
{
|
||||
if (cl.refresh_prepped)
|
||||
{
|
||||
CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
|
||||
OGG_ResumeCmd();
|
||||
}
|
||||
}
|
||||
else if (i >= CS_MODELS && i < CS_MODELS+MAX_MODELS)
|
||||
{
|
||||
|
|
|
@ -561,6 +561,7 @@ void SCR_BeginLoadingPlaque (void)
|
|||
S_StopAllSounds ();
|
||||
cl.sound_prepped = false; // don't play ambients
|
||||
CDAudio_Stop ();
|
||||
OGG_Stop();
|
||||
if (cls.disable_screen)
|
||||
return;
|
||||
if (developer->value)
|
||||
|
|
|
@ -355,6 +355,17 @@ void CL_PrepRefresh (void)
|
|||
}
|
||||
else{
|
||||
CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
|
||||
|
||||
/* OGG/Vorbis */
|
||||
if (atoi(cl.configstrings[CS_CDTRACK]) < 10)
|
||||
{
|
||||
char tmp[2] = "0";
|
||||
OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
|
||||
}
|
||||
else
|
||||
{
|
||||
OGG_ParseCmd(cl.configstrings[CS_CDTRACK]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "../input/keys.h"
|
||||
#include "../console/console.h"
|
||||
#include "../sound/cdaudio.h"
|
||||
#include "../sound/snd_ogg.h"
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
|
|
@ -30,23 +30,23 @@ static char *menu_move_sound = "misc/menu2.wav";
|
|||
static char *menu_out_sound = "misc/menu3.wav";
|
||||
|
||||
void M_Menu_Main_f (void);
|
||||
static void M_Menu_Game_f (void);
|
||||
static void M_Menu_LoadGame_f (void);
|
||||
static void M_Menu_SaveGame_f (void);
|
||||
static void M_Menu_PlayerConfig_f (void);
|
||||
static void M_Menu_DownloadOptions_f (void);
|
||||
static void M_Menu_Credits_f( void );
|
||||
static void M_Menu_Multiplayer_f( void );
|
||||
static void M_Menu_JoinServer_f (void);
|
||||
static void M_Menu_AddressBook_f( void );
|
||||
static void M_Menu_StartServer_f (void);
|
||||
static void M_Menu_DMOptions_f (void);
|
||||
static void M_Menu_Video_f (void);
|
||||
static void M_Menu_Options_f (void);
|
||||
static void M_Menu_Keys_f (void);
|
||||
static void M_Menu_Quit_f (void);
|
||||
static void M_Menu_Game_f (void);
|
||||
static void M_Menu_LoadGame_f (void);
|
||||
static void M_Menu_SaveGame_f (void);
|
||||
static void M_Menu_PlayerConfig_f (void);
|
||||
static void M_Menu_DownloadOptions_f (void);
|
||||
static void M_Menu_Credits_f( void );
|
||||
static void M_Menu_Multiplayer_f( void );
|
||||
static void M_Menu_JoinServer_f (void);
|
||||
static void M_Menu_AddressBook_f( void );
|
||||
static void M_Menu_StartServer_f (void);
|
||||
static void M_Menu_DMOptions_f (void);
|
||||
static void M_Menu_Video_f (void);
|
||||
static void M_Menu_Options_f (void);
|
||||
static void M_Menu_Keys_f (void);
|
||||
static void M_Menu_Quit_f (void);
|
||||
|
||||
void M_Menu_Credits( void );
|
||||
void M_Menu_Credits( void );
|
||||
|
||||
qboolean m_entersound; // play after drawing a frame, so caching
|
||||
// won't disrupt the sound
|
||||
|
@ -1010,7 +1010,8 @@ static menulist_s s_options_crosshair_box;
|
|||
static menuslider_s s_options_sfxvolume_slider;
|
||||
static menulist_s s_options_joystick_box;
|
||||
static menulist_s s_options_cdvolume_box;
|
||||
static menulist_s s_options_cdshuffle_box;
|
||||
static menulist_s s_options_cdshuffle_box;
|
||||
static menulist_s s_options_oggvolume_box;
|
||||
static menulist_s s_options_quality_list;
|
||||
static menulist_s s_options_compatibility_list;
|
||||
static menulist_s s_options_console_action;
|
||||
|
@ -1057,7 +1058,14 @@ static void ControlsSetMenuItemValues( void )
|
|||
s_options_sfxvolume_slider.curvalue = Cvar_VariableValue( "s_volume" ) * 10;
|
||||
s_options_cdvolume_box.curvalue = !Cvar_VariableValue("cd_nocd");
|
||||
|
||||
s_options_cdshuffle_box.curvalue = Cvar_VariableValue("cd_shuffle");
|
||||
s_options_oggvolume_box.curvalue = Cvar_VariableValue("ogg_enable");
|
||||
|
||||
cvar_t *ogg;
|
||||
ogg = Cvar_Get("ogg_sequence", "1", CVAR_ARCHIVE);
|
||||
if(!strcmp(ogg->string, "random"))
|
||||
s_options_cdshuffle_box.curvalue = 1;
|
||||
else
|
||||
s_options_cdshuffle_box.curvalue = 0;
|
||||
|
||||
s_options_quality_list.curvalue = !Cvar_VariableValue( "s_loadas8bit" );
|
||||
s_options_sensitivity_slider.curvalue = ( sensitivity->value ) * 2;
|
||||
|
@ -1113,14 +1121,46 @@ static void UpdateVolumeFunc( void *unused )
|
|||
|
||||
static void CDShuffleFunc(void *unused)
|
||||
{
|
||||
Cvar_SetValue("cd_shuffle", s_options_cdshuffle_box.curvalue);
|
||||
Cvar_SetValue("cd_shuffle", s_options_cdshuffle_box.curvalue);
|
||||
|
||||
cvar_t *ogg;
|
||||
ogg = Cvar_Get("ogg_enable", "1", CVAR_ARCHIVE);
|
||||
|
||||
if (s_options_cdshuffle_box.curvalue)
|
||||
{
|
||||
Cvar_Set("ogg_sequence", "random");
|
||||
|
||||
if(ogg->value)
|
||||
{
|
||||
OGG_ParseCmd("?");
|
||||
OGG_Stop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Cvar_Set("ogg_sequence", "loop");
|
||||
if(ogg->value)
|
||||
{
|
||||
if (atoi(cl.configstrings[CS_CDTRACK]) < 10)
|
||||
{
|
||||
char tmp[2] = "0";
|
||||
OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
|
||||
}
|
||||
else
|
||||
{
|
||||
OGG_ParseCmd(cl.configstrings[CS_CDTRACK]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateCDVolumeFunc( void *unused )
|
||||
{
|
||||
Cvar_SetValue( "cd_nocd", (float)!s_options_cdvolume_box.curvalue );
|
||||
Cvar_SetValue( "ogg_enable", 0 );
|
||||
if (s_options_cdvolume_box.curvalue)
|
||||
{
|
||||
OGG_Shutdown();
|
||||
CDAudio_Init();
|
||||
if (s_options_cdshuffle_box.curvalue)
|
||||
{
|
||||
|
@ -1137,6 +1177,31 @@ static void UpdateCDVolumeFunc( void *unused )
|
|||
}
|
||||
}
|
||||
|
||||
static void UpdateOGGVolumeFunc( void *unused )
|
||||
{
|
||||
Cvar_SetValue( "ogg_enable", (float)s_options_oggvolume_box.curvalue );
|
||||
Cvar_SetValue( "cd_nocd", 1 );
|
||||
if (s_options_oggvolume_box.curvalue)
|
||||
{
|
||||
CDAudio_Stop();
|
||||
OGG_Init();
|
||||
OGG_Stop();
|
||||
if (atoi(cl.configstrings[CS_CDTRACK]) < 10)
|
||||
{
|
||||
char tmp[2] = "0";
|
||||
OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK]));
|
||||
}
|
||||
else
|
||||
{
|
||||
OGG_ParseCmd(cl.configstrings[CS_CDTRACK]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OGG_Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
extern void Key_ClearTyping( void );
|
||||
static void ConsoleFunc( void *unused )
|
||||
{
|
||||
|
@ -1190,7 +1255,14 @@ static void Options_MenuInit( void )
|
|||
"enabled",
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
static const char *ogg_music_items[] =
|
||||
{
|
||||
"disabled",
|
||||
"enabled",
|
||||
0
|
||||
};
|
||||
|
||||
static const char *cd_shuffle[] =
|
||||
{
|
||||
"disabled",
|
||||
|
@ -1248,17 +1320,25 @@ static void Options_MenuInit( void )
|
|||
s_options_cdvolume_box.itemnames = cd_music_items;
|
||||
s_options_cdvolume_box.curvalue = !Cvar_VariableValue("cd_nocd");
|
||||
|
||||
s_options_oggvolume_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_oggvolume_box.generic.x = 0;
|
||||
s_options_oggvolume_box.generic.y = 20;
|
||||
s_options_oggvolume_box.generic.name = "OGG music";
|
||||
s_options_oggvolume_box.generic.callback = UpdateOGGVolumeFunc;
|
||||
s_options_oggvolume_box.itemnames = ogg_music_items;
|
||||
s_options_oggvolume_box.curvalue = Cvar_VariableValue("ogg_enable");
|
||||
|
||||
s_options_cdshuffle_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_cdshuffle_box.generic.x = 0;
|
||||
s_options_cdshuffle_box.generic.y = 20;
|
||||
s_options_cdshuffle_box.generic.name = "CD shuffle";
|
||||
s_options_cdshuffle_box.generic.y = 30;
|
||||
s_options_cdshuffle_box.generic.name = "Shuffle";
|
||||
s_options_cdshuffle_box.generic.callback = CDShuffleFunc;
|
||||
s_options_cdshuffle_box.itemnames = cd_shuffle;
|
||||
s_options_cdshuffle_box.curvalue = Cvar_VariableValue("cd_shuffle");;
|
||||
|
||||
|
||||
s_options_quality_list.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_quality_list.generic.x = 0;
|
||||
s_options_quality_list.generic.y = 30;;
|
||||
s_options_quality_list.generic.y = 40;;
|
||||
s_options_quality_list.generic.name = "sound quality";
|
||||
s_options_quality_list.generic.callback = UpdateSoundQualityFunc;
|
||||
s_options_quality_list.itemnames = quality_items;
|
||||
|
@ -1266,7 +1346,7 @@ static void Options_MenuInit( void )
|
|||
|
||||
s_options_compatibility_list.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_compatibility_list.generic.x = 0;
|
||||
s_options_compatibility_list.generic.y = 40;
|
||||
s_options_compatibility_list.generic.y = 50;
|
||||
s_options_compatibility_list.generic.name = "sound compatibility";
|
||||
s_options_compatibility_list.generic.callback = UpdateSoundQualityFunc;
|
||||
s_options_compatibility_list.itemnames = compatibility_items;
|
||||
|
@ -1274,7 +1354,7 @@ static void Options_MenuInit( void )
|
|||
|
||||
s_options_sensitivity_slider.generic.type = MTYPE_SLIDER;
|
||||
s_options_sensitivity_slider.generic.x = 0;
|
||||
s_options_sensitivity_slider.generic.y = 60;
|
||||
s_options_sensitivity_slider.generic.y = 70;
|
||||
s_options_sensitivity_slider.generic.name = "mouse speed";
|
||||
s_options_sensitivity_slider.generic.callback = MouseSpeedFunc;
|
||||
s_options_sensitivity_slider.minvalue = 2;
|
||||
|
@ -1282,68 +1362,68 @@ static void Options_MenuInit( void )
|
|||
|
||||
s_options_alwaysrun_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_alwaysrun_box.generic.x = 0;
|
||||
s_options_alwaysrun_box.generic.y = 70;
|
||||
s_options_alwaysrun_box.generic.y = 80;
|
||||
s_options_alwaysrun_box.generic.name = "always run";
|
||||
s_options_alwaysrun_box.generic.callback = AlwaysRunFunc;
|
||||
s_options_alwaysrun_box.itemnames = yesno_names;
|
||||
|
||||
s_options_invertmouse_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_invertmouse_box.generic.x = 0;
|
||||
s_options_invertmouse_box.generic.y = 80;
|
||||
s_options_invertmouse_box.generic.y = 90;
|
||||
s_options_invertmouse_box.generic.name = "invert mouse";
|
||||
s_options_invertmouse_box.generic.callback = InvertMouseFunc;
|
||||
s_options_invertmouse_box.itemnames = yesno_names;
|
||||
|
||||
s_options_lookspring_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_lookspring_box.generic.x = 0;
|
||||
s_options_lookspring_box.generic.y = 90;
|
||||
s_options_lookspring_box.generic.y = 100;
|
||||
s_options_lookspring_box.generic.name = "lookspring";
|
||||
s_options_lookspring_box.generic.callback = LookspringFunc;
|
||||
s_options_lookspring_box.itemnames = yesno_names;
|
||||
|
||||
s_options_lookstrafe_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_lookstrafe_box.generic.x = 0;
|
||||
s_options_lookstrafe_box.generic.y = 100;
|
||||
s_options_lookstrafe_box.generic.y = 110;
|
||||
s_options_lookstrafe_box.generic.name = "lookstrafe";
|
||||
s_options_lookstrafe_box.generic.callback = LookstrafeFunc;
|
||||
s_options_lookstrafe_box.itemnames = yesno_names;
|
||||
|
||||
s_options_freelook_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_freelook_box.generic.x = 0;
|
||||
s_options_freelook_box.generic.y = 110;
|
||||
s_options_freelook_box.generic.y = 120;
|
||||
s_options_freelook_box.generic.name = "free look";
|
||||
s_options_freelook_box.generic.callback = FreeLookFunc;
|
||||
s_options_freelook_box.itemnames = yesno_names;
|
||||
|
||||
s_options_crosshair_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_crosshair_box.generic.x = 0;
|
||||
s_options_crosshair_box.generic.y = 120;
|
||||
s_options_crosshair_box.generic.y = 130;
|
||||
s_options_crosshair_box.generic.name = "crosshair";
|
||||
s_options_crosshair_box.generic.callback = CrosshairFunc;
|
||||
s_options_crosshair_box.itemnames = crosshair_names;
|
||||
|
||||
s_options_joystick_box.generic.type = MTYPE_SPINCONTROL;
|
||||
s_options_joystick_box.generic.x = 0;
|
||||
s_options_joystick_box.generic.y = 130;
|
||||
s_options_joystick_box.generic.y = 140;
|
||||
s_options_joystick_box.generic.name = "use joystick";
|
||||
s_options_joystick_box.generic.callback = JoystickFunc;
|
||||
s_options_joystick_box.itemnames = yesno_names;
|
||||
|
||||
s_options_customize_options_action.generic.type = MTYPE_ACTION;
|
||||
s_options_customize_options_action.generic.x = 0;
|
||||
s_options_customize_options_action.generic.y = 150;
|
||||
s_options_customize_options_action.generic.y = 160;
|
||||
s_options_customize_options_action.generic.name = "customize controls";
|
||||
s_options_customize_options_action.generic.callback = CustomizeControlsFunc;
|
||||
|
||||
s_options_defaults_action.generic.type = MTYPE_ACTION;
|
||||
s_options_defaults_action.generic.x = 0;
|
||||
s_options_defaults_action.generic.y = 160;
|
||||
s_options_defaults_action.generic.y = 170;
|
||||
s_options_defaults_action.generic.name = "reset defaults";
|
||||
s_options_defaults_action.generic.callback = ControlsResetDefaultsFunc;
|
||||
|
||||
s_options_console_action.generic.type = MTYPE_ACTION;
|
||||
s_options_console_action.generic.x = 0;
|
||||
s_options_console_action.generic.y = 170;
|
||||
s_options_console_action.generic.y = 180;
|
||||
s_options_console_action.generic.name = "go to console";
|
||||
s_options_console_action.generic.callback = ConsoleFunc;
|
||||
|
||||
|
@ -1351,6 +1431,7 @@ static void Options_MenuInit( void )
|
|||
|
||||
Menu_AddItem( &s_options_menu, ( void * ) &s_options_sfxvolume_slider );
|
||||
Menu_AddItem( &s_options_menu, ( void * ) &s_options_cdvolume_box );
|
||||
Menu_AddItem( &s_options_menu, ( void * ) &s_options_oggvolume_box );
|
||||
Menu_AddItem( &s_options_menu, ( void * ) &s_options_cdshuffle_box );
|
||||
Menu_AddItem( &s_options_menu, ( void * ) &s_options_quality_list );
|
||||
Menu_AddItem( &s_options_menu, ( void * ) &s_options_compatibility_list );
|
||||
|
@ -2064,7 +2145,7 @@ static void Create_Savestrings (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
FS_Read (m_savestrings[i], sizeof(m_savestrings[i]), f);
|
||||
FS_Read (m_savestrings[i], sizeof(m_savestrings[i]), (size_t)f);
|
||||
fclose (f);
|
||||
m_savevalid[i] = true;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "../header/client.h"
|
||||
#include "snd_loc.h"
|
||||
#include "snd_ogg.h"
|
||||
|
||||
void S_Play(void);
|
||||
void S_SoundList(void);
|
||||
|
@ -137,6 +138,8 @@ void S_Init (void)
|
|||
Cmd_AddCommand("stopsound", S_StopAllSounds);
|
||||
Cmd_AddCommand("soundlist", S_SoundList);
|
||||
Cmd_AddCommand("soundinfo", S_SoundInfo_f);
|
||||
Cmd_AddCommand("ogg_init", OGG_Init);
|
||||
Cmd_AddCommand("ogg_shutdown", OGG_Shutdown);
|
||||
|
||||
if (!SNDDMA_Init())
|
||||
return;
|
||||
|
@ -152,6 +155,8 @@ void S_Init (void)
|
|||
Com_Printf ("sound sampling rate: %i\n", dma.speed);
|
||||
|
||||
S_StopAllSounds ();
|
||||
|
||||
OGG_Init();
|
||||
}
|
||||
|
||||
Com_Printf("------------------------------------\n");
|
||||
|
@ -170,6 +175,11 @@ void S_Shutdown(void)
|
|||
if (!sound_started)
|
||||
return;
|
||||
|
||||
OGG_Shutdown();
|
||||
|
||||
Cmd_RemoveCommand("ogg_init");
|
||||
Cmd_RemoveCommand("ogg_shutdown");
|
||||
|
||||
SNDDMA_Shutdown();
|
||||
|
||||
sound_started = 0;
|
||||
|
@ -621,11 +631,11 @@ struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base)
|
|||
if (!sfx)
|
||||
{
|
||||
// no, so see if it exists
|
||||
FS_FOpenFile (&sexedFilename[1], &f);
|
||||
FS_FOpenFile (&sexedFilename[1], (fileHandle_t *)&f, FS_READ);
|
||||
if (f)
|
||||
{
|
||||
// yes, close the file and register it
|
||||
FS_FCloseFile (f);
|
||||
FS_FCloseFile ((size_t)f);
|
||||
sfx = S_RegisterSound (sexedFilename);
|
||||
}
|
||||
else
|
||||
|
@ -1111,6 +1121,9 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
|
|||
|
||||
// mix some sound
|
||||
S_Update_();
|
||||
|
||||
/* stream music */
|
||||
OGG_Stream();
|
||||
}
|
||||
|
||||
void GetSoundtime(void)
|
||||
|
|
|
@ -1708,7 +1708,7 @@ and recalculates the area connections
|
|||
*/
|
||||
void CM_ReadPortalState (FILE *f)
|
||||
{
|
||||
FS_Read (portalopen, sizeof(portalopen), f);
|
||||
FS_Read (portalopen, sizeof(portalopen), (size_t)f);
|
||||
FloodAreaConnections ();
|
||||
}
|
||||
|
||||
|
|
2374
src/common/files.c
2374
src/common/files.c
File diff suppressed because it is too large
Load diff
|
@ -660,27 +660,71 @@ FILESYSTEM
|
|||
==============================================================
|
||||
*/
|
||||
|
||||
void FS_InitFilesystem (void);
|
||||
void FS_SetGamedir (char *dir);
|
||||
char *FS_Gamedir (void);
|
||||
char *FS_NextPath (char *prevpath);
|
||||
void FS_ExecAutoexec (void);
|
||||
#define SFF_INPACK 0x20 /* For FS_ListFiles2(). */
|
||||
|
||||
int FS_FOpenFile (char *filename, FILE **file);
|
||||
void FS_FCloseFile (FILE *f);
|
||||
// note: this can't be called from another DLL, due to MS libc issues
|
||||
extern int file_from_pak; /* ZOID did file come from pak? */
|
||||
|
||||
int FS_LoadFile (char *path, void **buffer);
|
||||
// a null buffer will just return the file length without loading
|
||||
// a -1 length is not present
|
||||
typedef int fileHandle_t;
|
||||
|
||||
void FS_Read (void *buffer, int len, FILE *f);
|
||||
// properly handles partial reads
|
||||
typedef enum {
|
||||
FS_READ,
|
||||
FS_WRITE,
|
||||
FS_APPEND
|
||||
} fsMode_t;
|
||||
|
||||
void FS_FreeFile (void *buffer);
|
||||
typedef enum {
|
||||
FS_SEEK_CUR,
|
||||
FS_SEEK_SET,
|
||||
FS_SEEK_END
|
||||
} fsOrigin_t;
|
||||
|
||||
void FS_CreatePath (char *path);
|
||||
typedef enum {
|
||||
FS_SEARCH_PATH_EXTENSION,
|
||||
FS_SEARCH_BY_FILTER,
|
||||
FS_SEARCH_FULL_PATH
|
||||
} fsSearchType_t;
|
||||
|
||||
void FS_Startup(void);
|
||||
void FS_Shutdown(void);
|
||||
void FS_DPrintf(const char *format,...);
|
||||
FILE *FS_FileForHandle(fileHandle_t f);
|
||||
int FS_FOpenFile(const char *name, fileHandle_t * f, fsMode_t mode);
|
||||
void FS_FCloseFile(fileHandle_t f);
|
||||
int FS_Read (void *buffer, int size, fileHandle_t f);
|
||||
int FS_FRead (void *buffer, int size, int count, fileHandle_t f);
|
||||
int FS_Write (const void *buffer, int size, fileHandle_t f);
|
||||
void FS_Seek (fileHandle_t f, int offset, fsOrigin_t origin);
|
||||
int FS_FTell (fileHandle_t f);
|
||||
int FS_Tell (fileHandle_t f);
|
||||
qboolean FS_FileExists(char *path);
|
||||
void FS_CopyFile(const char *srcPath, const char *dstPath);
|
||||
void FS_RenameFile(const char *oldPath, const char *newPath);
|
||||
void FS_DeleteFile(const char *path);
|
||||
void FS_DeletePath(char *path);
|
||||
int FS_GetFileList(const char *path, const char *extension, char *buffer, int size, fsSearchType_t searchType);
|
||||
char **FS_ListPak(char *find, int *num); /* Knighmare- pak list function */
|
||||
char **FS_ListFiles(char *findname, int *numfiles, unsigned musthave, unsigned canthave);
|
||||
char **FS_ListFiles2(char *findname, int *numfiles, unsigned musthave, unsigned canthave);
|
||||
void FS_FreeList(char **list, int nfiles);
|
||||
|
||||
void FS_InitFilesystem(void);
|
||||
void FS_SetGamedir(char *dir);
|
||||
char *FS_Gamedir(void);
|
||||
char *FS_NextPath(char *prevpath);
|
||||
void FS_ExecAutoexec(void);
|
||||
|
||||
/* note: this can't be called from another DLL, due to MS libc issues */
|
||||
|
||||
int FS_LoadFile(char *path, void **buffer);
|
||||
|
||||
/* a null buffer will just return the file length without loading */
|
||||
/* a -1 length is not present */
|
||||
|
||||
/* properly handles partial reads */
|
||||
|
||||
void FS_FreeFile(void *buffer);
|
||||
|
||||
void FS_CreatePath(char *path);
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
|
|
@ -240,6 +240,8 @@ extern int curtime; // time returned by last Sys_Milliseconds
|
|||
|
||||
int Sys_Milliseconds (void);
|
||||
void Sys_Mkdir (char *path);
|
||||
void Sys_Rmdir(char *path);
|
||||
char *strlwr (char *s);
|
||||
|
||||
// large block stack allocation routines
|
||||
void *Hunk_Begin (int maxsize);
|
||||
|
|
|
@ -158,6 +158,23 @@ void Sys_Mkdir (char *path)
|
|||
mkdir (path, 0777);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Rmdir(char *path)
|
||||
{
|
||||
rmdir(path);
|
||||
}
|
||||
|
||||
char *
|
||||
Sys_GetCurrentDirectory(void)
|
||||
{
|
||||
static char dir[MAX_OSPATH];
|
||||
|
||||
if (!getcwd(dir, sizeof(dir)))
|
||||
Sys_Error("Couldn't get current working directory");
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
char *strlwr (char *s)
|
||||
{
|
||||
char *p = s;
|
||||
|
|
|
@ -317,7 +317,7 @@ void SV_ReadLevelFile (void)
|
|||
Com_Printf ("Failed to open %s\n", name);
|
||||
return;
|
||||
}
|
||||
FS_Read (sv.configstrings, sizeof(sv.configstrings), f);
|
||||
FS_Read (sv.configstrings, sizeof(sv.configstrings), (size_t)f);
|
||||
CM_ReadPortalState (f);
|
||||
fclose (f);
|
||||
|
||||
|
@ -421,10 +421,10 @@ void SV_ReadServerFile (void)
|
|||
return;
|
||||
}
|
||||
// read the comment field
|
||||
FS_Read (comment, sizeof(comment), f);
|
||||
FS_Read (comment, sizeof(comment), (size_t)f);
|
||||
|
||||
// read the mapcmd
|
||||
FS_Read (mapcmd, sizeof(mapcmd), f);
|
||||
FS_Read (mapcmd, sizeof(mapcmd), (size_t)f);
|
||||
|
||||
// read all CVAR_LATCH cvars
|
||||
// these will be things like coop, skill, deathmatch, etc
|
||||
|
@ -432,7 +432,7 @@ void SV_ReadServerFile (void)
|
|||
{
|
||||
if (!fread (name, 1, sizeof(name), f))
|
||||
break;
|
||||
FS_Read (string, sizeof(string), f);
|
||||
FS_Read (string, sizeof(string), (size_t)f);
|
||||
Com_DPrintf ("Set %s = %s\n", name, string);
|
||||
Cvar_ForceSet (name, string);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void SV_BeginDemoserver (void)
|
|||
char name[MAX_OSPATH];
|
||||
|
||||
Com_sprintf (name, sizeof(name), "demos/%s", sv.name);
|
||||
FS_FOpenFile (name, &sv.demofile);
|
||||
FS_FOpenFile (name, (fileHandle_t *)&sv.demofile, FS_READ);
|
||||
if (!sv.demofile)
|
||||
Com_Error (ERR_DROP, "Couldn't open %s\n", name);
|
||||
}
|
||||
|
|
138
src/unzip/crypt.h
Normal file
138
src/unzip/crypt.h
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
*
|
||||
*
|
||||
* Version 1.01e, February 12th, 2005
|
||||
*
|
||||
* Copyright (C) 1998-2005 Gilles Vollant
|
||||
*
|
||||
* This code is a modified version of crypting code in Infozip distribution
|
||||
*
|
||||
* The encryption/decryption parts of this source code (as opposed to the
|
||||
* non-echoing password parts) were originally written in Europe. The whole
|
||||
* source package can be freely distributed, including from the USA. (Prior
|
||||
* to January 2000, re-export from the US was a violation of US law.)
|
||||
*
|
||||
* This encryption code is a direct transcription of the algorithm from Roger
|
||||
* Schlafly, described by Phil Katz in the file appnote.txt. This file
|
||||
* (appnote.txt) is distributed with the PKZIP program (even in the version
|
||||
* without encryption capabilities).
|
||||
*
|
||||
* If you don't need crypting in your application, just define symbols NOCRYPT
|
||||
* and NOUNCRYPT.
|
||||
*
|
||||
* This code support the "Traditional PKWARE Encryption".
|
||||
*
|
||||
* The new AES encryption added on Zip format by Winzip (see the page
|
||||
* http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
*/
|
||||
/* Encryption is not supported. */
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int
|
||||
decrypt_byte(unsigned long *pkeys, const unsigned long *pcrc_32_tab)
|
||||
{
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow
|
||||
* in an unpredictable manner on 16-bit
|
||||
* systems; not a problem with any known
|
||||
* compiler so far, though */
|
||||
|
||||
temp = ((unsigned)(*(pkeys + 2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int
|
||||
update_keys(unsigned long *pkeys, const unsigned long *pcrc_32_tab, int c)
|
||||
{
|
||||
(*(pkeys + 0)) = CRC32((*(pkeys + 0)), c);
|
||||
(*(pkeys + 1)) += (*(pkeys + 0)) & 0xff;
|
||||
(*(pkeys + 1)) = (*(pkeys + 1)) * 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)((*(pkeys + 1)) >> 24);
|
||||
|
||||
(*(pkeys + 2)) = CRC32((*(pkeys + 2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void
|
||||
init_keys(const char *passwd, unsigned long *pkeys, const unsigned long *pcrc_32_tab)
|
||||
{
|
||||
*(pkeys + 0) = 305419896L;
|
||||
*(pkeys + 1) = 591751049L;
|
||||
*(pkeys + 2) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(pkeys, pcrc_32_tab, (int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||
|
||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
#ifndef ZCR_SEED2
|
||||
#define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
#endif
|
||||
|
||||
static int
|
||||
crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
|
||||
const char *passwd; /* password string */
|
||||
unsigned char *buf; /* where to write header */
|
||||
int bufSize;
|
||||
unsigned long *pkeys;
|
||||
const unsigned long *pcrc_32_tab;
|
||||
unsigned long crcForCrypting;
|
||||
{
|
||||
int n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
unsigned char header[RAND_HEAD_LEN - 2]; /* random header */
|
||||
static unsigned calls = 0; /* ensure different random header
|
||||
* each time */
|
||||
|
||||
if (bufSize < RAND_HEAD_LEN)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the output
|
||||
* of rand() to get less predictability, since rand() is often poorly
|
||||
* implemented.
|
||||
*/
|
||||
if (++calls == 1) {
|
||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||
}
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN - 2; n++) {
|
||||
c = (rand() >> 7) & 0xff;
|
||||
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
||||
}
|
||||
/* Encrypt random header (last two bytes is high word of crc) */
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN - 2; n++) {
|
||||
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||
}
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
191
src/unzip/ioapi.c
Normal file
191
src/unzip/ioapi.c
Normal file
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* ioapi.c -- IO base function header for compress/uncompress .zip files
|
||||
* using zlib + zip or unzip API
|
||||
*
|
||||
* Version 1.01e, February 12th, 2005
|
||||
*
|
||||
* Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zlib.h"
|
||||
#include "ioapi.h"
|
||||
|
||||
|
||||
|
||||
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
|
||||
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR 1
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END 2
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
|
||||
voidpf ZCALLBACK fopen_file_func
|
||||
OF((
|
||||
voidpf opaque,
|
||||
const char *filename,
|
||||
int mode));
|
||||
|
||||
uLong ZCALLBACK fread_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
void *buf,
|
||||
uLong size));
|
||||
|
||||
uLong ZCALLBACK fwrite_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
const void *buf,
|
||||
uLong size));
|
||||
|
||||
long ZCALLBACK ftell_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
long ZCALLBACK fseek_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
uLong offset,
|
||||
int origin));
|
||||
|
||||
int ZCALLBACK fclose_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
int ZCALLBACK ferror_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
|
||||
voidpf ZCALLBACK fopen_file_func(opaque, filename, mode)
|
||||
voidpf opaque;
|
||||
const char *filename;
|
||||
int mode;
|
||||
{
|
||||
FILE *file = NULL;
|
||||
const char *mode_fopen = NULL;
|
||||
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = "r+b";
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = "wb";
|
||||
|
||||
if ((filename != NULL) && (mode_fopen != NULL))
|
||||
file = fopen(filename, mode_fopen);
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK
|
||||
fread_file_func(opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
void *buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret;
|
||||
|
||||
ret = (uLong) fread(buf, 1, (size_t) size, (FILE *) stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK
|
||||
fwrite_file_func(opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
const void *buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret;
|
||||
|
||||
ret = (uLong) fwrite(buf, 1, (size_t) size, (FILE *) stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK
|
||||
ftell_file_func(opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
long ret;
|
||||
|
||||
ret = ftell((FILE *) stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK
|
||||
fseek_file_func(opaque, stream, offset, origin)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
uLong offset;
|
||||
int origin;
|
||||
{
|
||||
int fseek_origin = 0;
|
||||
long ret;
|
||||
|
||||
switch (origin) {
|
||||
case ZLIB_FILEFUNC_SEEK_CUR:
|
||||
fseek_origin = SEEK_CUR;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END:
|
||||
fseek_origin = SEEK_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET:
|
||||
fseek_origin = SEEK_SET;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
ret = 0;
|
||||
fseek((FILE *) stream, offset, fseek_origin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK
|
||||
fclose_file_func(opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = fclose((FILE *) stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK
|
||||
ferror_file_func(opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ferror((FILE *) stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
fill_fopen_filefunc(pzlib_filefunc_def)
|
||||
zlib_filefunc_def *pzlib_filefunc_def;
|
||||
{
|
||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
|
||||
pzlib_filefunc_def->ztell_file = ftell_file_func;
|
||||
pzlib_filefunc_def->zseek_file = fseek_file_func;
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
75
src/unzip/ioapi.h
Normal file
75
src/unzip/ioapi.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* ioapi.h -- IO base function header for compress/uncompress .zip files
|
||||
* using zlib + zip or unzip API
|
||||
*
|
||||
* Version 1.01e, February 12th, 2005
|
||||
*
|
||||
* Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#define _ZLIBIOAPI_H
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
#define ZLIB_FILEFUNC_SEEK_END (2)
|
||||
#define ZLIB_FILEFUNC_SEEK_SET (0)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_READ (1)
|
||||
#define ZLIB_FILEFUNC_MODE_WRITE (2)
|
||||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
|
||||
|
||||
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
|
||||
#define ZLIB_FILEFUNC_MODE_CREATE (8)
|
||||
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
|
||||
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef voidpf (ZCALLBACK * open_file_func) OF((voidpf opaque, const char *filename, int mode));
|
||||
typedef uLong (ZCALLBACK * read_file_func) OF((voidpf opaque, voidpf stream, void *buf, uLong size));
|
||||
typedef uLong (ZCALLBACK * write_file_func) OF((voidpf opaque, voidpf stream, const void *buf, uLong size));
|
||||
typedef long (ZCALLBACK * tell_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef long (ZCALLBACK * seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
|
||||
typedef int (ZCALLBACK * close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK * testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
typedef struct zlib_filefunc_def_s {
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
testerror_file_func zerror_file;
|
||||
voidpf opaque;
|
||||
} zlib_filefunc_def;
|
||||
|
||||
|
||||
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def * pzlib_filefunc_def));
|
||||
|
||||
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
|
||||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
|
||||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
1644
src/unzip/unzip.c
Normal file
1644
src/unzip/unzip.c
Normal file
File diff suppressed because it is too large
Load diff
398
src/unzip/unzip.h
Normal file
398
src/unzip/unzip.h
Normal file
|
@ -0,0 +1,398 @@
|
|||
/*
|
||||
* unzip.h -- IO for uncompress .zip files using zlib Version 1.01e, February
|
||||
* 12th, 2005
|
||||
*
|
||||
* Copyright (C) 1998-2005 Gilles Vollant
|
||||
*
|
||||
* This unzip package allow extract file from .ZIP file, compatible with PKZip
|
||||
* 2.04g WinZip, InfoZip tools and compatible.
|
||||
*
|
||||
* Multi volume ZipFile (span) are not supported. Encryption compatible with
|
||||
* pkzip 2.04g only supported Old compressions used by old PKZip 1.x are not
|
||||
* supported
|
||||
*
|
||||
*
|
||||
* I WAIT FEEDBACK at mail info@winimage.com Visit also
|
||||
* http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
*/
|
||||
/*
|
||||
Condition of use and distribution are the same than zlib:
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications,
|
||||
and to alter it and redistribute it
|
||||
freely , subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software.If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* for more info about .ZIP format, see
|
||||
* http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
*/
|
||||
/*
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at:
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
|
||||
/*
|
||||
* like the STRICT of WIN32, we define a pointer that cannot be
|
||||
* converted from (void*) without cast
|
||||
*/
|
||||
typedef struct TagunzFile__ {
|
||||
int unused;
|
||||
} unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s {
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight -
|
||||
* [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/*
|
||||
* unz_global_info structure contain global data about the ZIPfile
|
||||
* These data comes from the end of central dir
|
||||
*/
|
||||
typedef struct unz_global_info_s {
|
||||
uLong number_entry; /* total number of entries in
|
||||
* the central dir on this
|
||||
* disk */
|
||||
uLong size_comment; /* size of the global comment
|
||||
* of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s {
|
||||
uLong version; /* version made by
|
||||
* 2 bytes */
|
||||
uLong version_needed; /* version needed to extract
|
||||
* 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2
|
||||
* bytes */
|
||||
uLong compression_method; /* compression method
|
||||
* 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos
|
||||
* fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4
|
||||
* bytes */
|
||||
uLong compressed_size; /* compressed size
|
||||
* 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size
|
||||
* 4 bytes */
|
||||
uLong size_filename; /* filename length
|
||||
* 2 bytes */
|
||||
uLong size_file_extra; /* extra field length
|
||||
* 2 bytes */
|
||||
uLong size_file_comment; /* file comment length
|
||||
* 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start
|
||||
* 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes
|
||||
* 2 bytes */
|
||||
uLong external_fa; /* external file attributes
|
||||
* 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF((const char *fileName1,
|
||||
const char *fileName2,
|
||||
int iCaseSensitivity));
|
||||
|
||||
/*
|
||||
* Compare two filename (fileName1,fileName2). If iCaseSenisivity =
|
||||
* 1, comparision is case sensitivity (like strcmp) If
|
||||
* iCaseSenisivity = 2, comparision is not case sensitivity (like
|
||||
* strcmpi or strcasecmp) If iCaseSenisivity = 0, case sensitivity is
|
||||
* defaut of your operating system (like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
|
||||
/*
|
||||
* Open a Zip file. path contain the full pathname (by example, on a
|
||||
* Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
* "zlib/zlib113.zip". If the zipfile cannot be opened (file don't
|
||||
* exist or in not valid), the return value is NULL. Else, the return
|
||||
* value is a unzFile Handle, usable with other function of this
|
||||
* unzip package.
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def * pzlib_filefunc_def));
|
||||
|
||||
/*
|
||||
* Open a Zip file, like unzOpen, but provide a set of file low level
|
||||
* API for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
|
||||
/*
|
||||
* Close a ZipFile opened with unzipOpen. If there is files inside
|
||||
* the .Zip opened with unzOpenCurrentFile (see later), these files
|
||||
* MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
* return UNZ_OK if there is no problem.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info * pglobal_info));
|
||||
|
||||
/*
|
||||
* Write info about the ZipFile in the *pglobal_info structure. No
|
||||
* preparation of the structure is needed return UNZ_OK if there is
|
||||
* no problem.
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
|
||||
/*
|
||||
* Get the global comment string of the ZipFile, in the szComment
|
||||
* buffer. uSizeBuf is the size of the szComment buffer. return the
|
||||
* number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
|
||||
/*
|
||||
* Set the current file of the zipfile to the first file. return
|
||||
* UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
|
||||
/*
|
||||
* Set the current file of the zipfile to the next file. return
|
||||
* UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if
|
||||
* the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
|
||||
/*
|
||||
* Try locate the file szFileName in the zipfile. For the
|
||||
* iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
*
|
||||
* return value : UNZ_OK if the file is found. It becomes the current
|
||||
* file. UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
/* ****************************************** */
|
||||
/* Ryan supplied functions */
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_pos_s {
|
||||
uLong pos_in_zip_directory; /* offset in zip file
|
||||
* directory */
|
||||
uLong num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(
|
||||
unzFile file ,
|
||||
unz_file_pos * file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file ,
|
||||
unz_file_pos * file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info * pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
|
||||
/*
|
||||
* Get Info about the current file if pfile_info!=NULL, the
|
||||
* *pfile_info structure will contain somes info about the current
|
||||
* file if szFileName!=NULL, the filemane string will be copied in
|
||||
* szFileName (fileNameBufferSize is the size of the buffer) if
|
||||
* extraField!=NULL, the extra field information will be copied in
|
||||
* extraField (extraFieldBufferSize is the size of the buffer). This
|
||||
* is the Central-header version of the extra field if
|
||||
* szComment!=NULL, the comment string of the file will be copied in
|
||||
* szComment (commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/*
|
||||
* for reading the content of the current zipfile, you can open it,
|
||||
* read data from it, and close it (you can close it before reading
|
||||
* all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
|
||||
/*
|
||||
* Open for reading data the current file in the zipfile. If there is
|
||||
* no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||
const char *password));
|
||||
|
||||
/*
|
||||
* Open for reading data the current file in the zipfile. password is
|
||||
* a crypting password If there is no error, the return value is
|
||||
* UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
int *method,
|
||||
int *level,
|
||||
int raw));
|
||||
|
||||
/*
|
||||
* Same than unzOpenCurrentFile, but open for read raw the file (not
|
||||
* uncompress) if raw==1 method will receive method of compression,
|
||||
* *level will receive level of compression note : you can set level
|
||||
* parameter as NULL (if you did not want known level, but you CANNOT
|
||||
* set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int *method,
|
||||
int *level,
|
||||
int raw ,
|
||||
const char *password));
|
||||
|
||||
/*
|
||||
* Same than unzOpenCurrentFile, but open for read raw the file (not
|
||||
* uncompress) if raw==1 method will receive method of compression,
|
||||
* *level will receive level of compression note : you can set level
|
||||
* parameter as NULL (if you did not want known level, but you CANNOT
|
||||
* set method parameter as NULL
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
|
||||
/*
|
||||
* Close the file in zip opened with unzOpenCurrentFile Return
|
||||
* UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf ,
|
||||
unsigned len));
|
||||
|
||||
/*
|
||||
* Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
* buf contain buffer where data must be copied len the size of buf.
|
||||
*
|
||||
* return the number of byte copied if somes bytes are copied return 0
|
||||
* if the end of file was reached return <0 with error code if there
|
||||
* is an error (UNZ_ERRNO for IO error, or zLib error for uncompress
|
||||
* error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
|
||||
/*
|
||||
* Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
|
||||
/*
|
||||
* return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf ,
|
||||
unsigned len));
|
||||
|
||||
/*
|
||||
* Read extra field from the current file (opened by
|
||||
* unzOpenCurrentFile) This is the local-header version of the extra
|
||||
* field (sometimes, there is more info in the local-header version
|
||||
* than in the central-header)
|
||||
*
|
||||
* if buf==NULL, it return the size of the local extra field
|
||||
*
|
||||
* if buf!=NULL, len is the size of the buffer, the extra header is
|
||||
* copied in buf. the return value is the number of bytes copied in
|
||||
* buf, or (if <0) the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern uLong ZEXPORT unzGetOffset(unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset(unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
Loading…
Reference in a new issue