02 Oct 2007

This commit is contained in:
g-cont 2007-10-02 00:00:00 +04:00 committed by Alibek Omarov
parent cdbf0903ea
commit b56ac26c6c
14 changed files with 316 additions and 3336 deletions

View File

@ -20,6 +20,7 @@ SV_ClipToLinks SV_ClipMoveToEntities
переписать compile targets
OP_POWER_I - добавить XOR для right result
добавить новые операции в Bounds checker
починить zlib
}

View File

@ -54,7 +54,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98
# ADD LINK32 msvcrt.lib winmm.lib user32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# ADD LINK32 common/zlib.lib winmm.lib user32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# Begin Custom Build
TargetDir=\XASH3D\src_main\!source\temp\common\!release
InputPath=\XASH3D\src_main\!source\temp\common\!release\common.dll
@ -90,7 +90,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 msvcrt.lib winmm.lib user32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept
# ADD LINK32 common/zlib.lib winmm.lib user32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept
# SUBTRACT LINK32 /incremental:no /nodefaultlib
# Begin Custom Build
TargetDir=\XASH3D\src_main\!source\temp\common\!debug
@ -243,10 +243,6 @@ SOURCE=.\bsplib\winding.c
SOURCE=.\bsplib\writebsp.c
# End Source File
# Begin Source File
SOURCE=.\common\ziplib.c
# End Source File
# End Group
# Begin Group "Header Files"

76
common/common.plg Normal file
View File

@ -0,0 +1,76 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: common - Win32 Release--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSPB51.tmp" with contents
[
/nologo /MD /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./common" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\common\!release/" /Fd"..\temp\common\!release/" /FD /c
"D:\XASH3D\src_main\!source\common\common\filesystem.c"
"D:\XASH3D\src_main\!source\common\qcclib\qcc_utils.c"
]
Creating command line "cl.exe @"C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSPB51.tmp""
Creating temporary file "C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSPB52.tmp" with contents
[
common/zlib.lib winmm.lib user32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /out:"..\temp\common\!release/common.dll" /implib:"..\temp\common\!release/common.lib" /opt:nowin98
"\XASH3D\src_main\!source\temp\common\!release\brushbsp.obj"
"\XASH3D\src_main\!source\temp\common\!release\bspfile.obj"
"\XASH3D\src_main\!source\temp\common\!release\csg.obj"
"\XASH3D\src_main\!source\temp\common\!release\faces.obj"
"\XASH3D\src_main\!source\temp\common\!release\filesystem.obj"
"\XASH3D\src_main\!source\temp\common\!release\flow.obj"
"\XASH3D\src_main\!source\temp\common\!release\image.obj"
"\XASH3D\src_main\!source\temp\common\!release\imglib.obj"
"\XASH3D\src_main\!source\temp\common\!release\leakfile.obj"
"\XASH3D\src_main\!source\temp\common\!release\lightmap.obj"
"\XASH3D\src_main\!source\temp\common\!release\map.obj"
"\XASH3D\src_main\!source\temp\common\!release\memory.obj"
"\XASH3D\src_main\!source\temp\common\!release\patches.obj"
"\XASH3D\src_main\!source\temp\common\!release\platform.obj"
"\XASH3D\src_main\!source\temp\common\!release\portals.obj"
"\XASH3D\src_main\!source\temp\common\!release\pr_comp.obj"
"\XASH3D\src_main\!source\temp\common\!release\pr_lex.obj"
"\XASH3D\src_main\!source\temp\common\!release\prtfile.obj"
"\XASH3D\src_main\!source\temp\common\!release\qbsp3.obj"
"\XASH3D\src_main\!source\temp\common\!release\qcc_utils.obj"
"\XASH3D\src_main\!source\temp\common\!release\qccmain.obj"
"\XASH3D\src_main\!source\temp\common\!release\qrad3.obj"
"\XASH3D\src_main\!source\temp\common\!release\qvis3.obj"
"\XASH3D\src_main\!source\temp\common\!release\shaders.obj"
"\XASH3D\src_main\!source\temp\common\!release\spritegen.obj"
"\XASH3D\src_main\!source\temp\common\!release\studio.obj"
"\XASH3D\src_main\!source\temp\common\!release\studio_utils.obj"
"\XASH3D\src_main\!source\temp\common\!release\textures.obj"
"\XASH3D\src_main\!source\temp\common\!release\trace.obj"
"\XASH3D\src_main\!source\temp\common\!release\tree.obj"
"\XASH3D\src_main\!source\temp\common\!release\utils.obj"
"\XASH3D\src_main\!source\temp\common\!release\winding.obj"
"\XASH3D\src_main\!source\temp\common\!release\writebsp.obj"
]
Creating command line "link.exe @"C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSPB52.tmp""
Creating temporary file "C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSPB53.bat" with contents
[
@echo off
copy \XASH3D\src_main\!source\temp\common\!release\common.dll "D:\Xash3D\bin\common.dll"
]
Creating command line ""C:\DOCUME~1\ÌÈØÀ\LOCALS~1\Temp\RSPB53.bat""
Compiling...
filesystem.c
qcc_utils.c
Generating Code...
Linking...
Creating library ..\temp\common\!release/common.lib and object ..\temp\common\!release/common.exp
<h3>Output Window</h3>
Performing Custom Build Step on \XASH3D\src_main\!source\temp\common\!release\common.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
common.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -104,6 +104,20 @@ typedef struct mip_s
/*
========================================================================
.FLAT image format (Doom I\II textures)
========================================================================
*/
typedef struct flat_s
{
short width;
short height;
long desc; // image desc (not used)
} flat_t;
/*
========================================================================
.TGA image format (Truevision Targa)
========================================================================

View File

@ -7,6 +7,33 @@
#include "basemath.h" // nearest_pow
#include "utils.h"
byte palette_d1[768] =
{
0,0,0,31,23,11,23,15,7,75,75,75,255,255,255,27,27,27,19,19,19,11,11,11,7,7,7,47,55,31,35,43,15,23,31,7,15,23,0,79,
59,43,71,51,35,63,43,27,255,183,183,247,171,171,243,163,163,235,151,151,231,143,143,223,135,135,219,123,123,211,115,
115,203,107,107,199,99,99,191,91,91,187,87,87,179,79,79,175,71,71,167,63,63,163,59,59,155,51,51,151,47,47,143,43,43,
139,35,35,131,31,31,127,27,27,119,23,23,115,19,19,107,15,15,103,11,11,95,7,7,91,7,7,83,7,7,79,0,0,71,0,0,67,0,0,255,
235,223,255,227,211,255,219,199,255,211,187,255,207,179,255,199,167,255,191,155,255,187,147,255,179,131,247,171,123,
239,163,115,231,155,107,223,147,99,215,139,91,207,131,83,203,127,79,191,123,75,179,115,71,171,111,67,163,107,63,155,
99,59,143,95,55,135,87,51,127,83,47,119,79,43,107,71,39,95,67,35,83,63,31,75,55,27,63,47,23,51,43,19,43,35,15,239,
239,239,231,231,231,223,223,223,219,219,219,211,211,211,203,203,203,199,199,199,191,191,191,183,183,183,179,179,179,
171,171,171,167,167,167,159,159,159,151,151,151,147,147,147,139,139,139,131,131,131,127,127,127,119,119,119,111,111,
111,107,107,107,99,99,99,91,91,91,87,87,87,79,79,79,71,71,71,67,67,67,59,59,59,55,55,55,47,47,47,39,39,39,35,35,35,
119,255,111,111,239,103,103,223,95,95,207,87,91,191,79,83,175,71,75,159,63,67,147,55,63,131,47,55,115,43,47,99,35,39,
83,27,31,67,23,23,51,15,19,35,11,11,23,7,191,167,143,183,159,135,175,151,127,167,143,119,159,135,111,155,127,107,147,
123,99,139,115,91,131,107,87,123,99,79,119,95,75,111,87,67,103,83,63,95,75,55,87,67,51,83,63,47,159,131,99,143,119,83,
131,107,75,119,95,63,103,83,51,91,71,43,79,59,35,67,51,27,123,127,99,111,115,87,103,107,79,91,99,71,83,87,59,71,79,51,
63,71,43,55,63,39,255,255,115,235,219,87,215,187,67,195,155,47,175,123,31,155,91,19,135,67,7,115,43,0,255,255,255,255,
219,219,255,187,187,255,155,155,255,123,123,255,95,95,255,63,63,255,31,31,255,0,0,239,0,0,227,0,0,215,0,0,203,0,0,191,
0,0,179,0,0,167,0,0,155,0,0,139,0,0,127,0,0,115,0,0,103,0,0,91,0,0,79,0,0,67,0,0,231,231,255,199,199,255,171,171,255,
143,143,255,115,115,255,83,83,255,55,55,255,27,27,255,0,0,255,0,0,227,0,0,203,0,0,179,0,0,155,0,0,131,0,0,107,0,0,83,
255,255,255,255,235,219,255,215,187,255,199,155,255,179,123,255,163,91,255,143,59,255,127,27,243,115,23,235,111,15,
223,103,15,215,95,11,203,87,7,195,79,0,183,71,0,175,67,0,255,255,255,255,255,215,255,255,179,255,255,143,255,255,107,
255,255,71,255,255,35,255,255,0,167,63,0,159,55,0,147,47,0,135,35,0,79,59,39,67,47,27,55,35,19,47,27,11,0,0,83,0,0,71,
0,0,59,0,0,47,0,0,35,0,0,23,0,0,11,0,255,255,255,159,67,255,231,75,255,123,255,255,0,255,207,0,207,159,0,155,111,0,107,
167,107,107
};
byte palette_q1[768] =
{
0,0,0,15,15,15,31,31,31,47,47,47,63,63,63,75,75,75,91,91,91,107,107,107,123,123,123,139,139,139,155,155,155,171,
@ -59,10 +86,12 @@ byte palette_q2[768] =
159,91,83
};
uint d_8toD1table[256];
uint d_8toQ1table[256];
uint d_8toQ2table[256];
uint d_8to24table[256];
uint *d_currentpal;
bool d1palette_init = false;
bool q1palette_init = false;
bool q2palette_init = false;
@ -80,7 +109,17 @@ void Image_GetPalette( byte *pal, uint *d_table )
rgba[1] = pal[i*3+2];
d_table[i] = BuffBigLong( rgba );
}
d_currentpal = d_table;
}
void Image_GetD1Palette( void )
{
if(!d1palette_init)
{
Image_GetPalette( palette_d1, d_8toD1table );
d_8toD1table[255] = 247; // 247 is transparent
d1palette_init = true;
}
d_currentpal = d_8toD1table;
}
void Image_GetQ1Palette( void )
@ -91,7 +130,7 @@ void Image_GetQ1Palette( void )
d_8toQ1table[255] = 0; // 255 is transparent
q1palette_init = true;
}
else d_currentpal = d_8toQ1table;
d_currentpal = d_8toQ1table;
}
void Image_GetQ2Palette( void )
@ -102,7 +141,7 @@ void Image_GetQ2Palette( void )
d_8toQ2table[255] &= LittleLong(0xffffff);
q2palette_init = true;
}
else d_currentpal = d_8toQ2table;
d_currentpal = d_8toQ2table;
}
void Image_GetPalettePCX( byte *pal )
@ -130,7 +169,7 @@ void Image_Copy8bitRGBA(const byte *in, byte *out, int pixels)
if(!d_currentpal)
{
MsgDev(D_ERROR, "Image_Copy8bitRGBA: no palette set\n");
MsgDev(D_ERROR,"Image_Copy8bitRGBA: no palette set\n");
return;
}
@ -214,7 +253,7 @@ byte *Image_Resample(uint *in, int inwidth, int inheight, int outwidth, int outh
frac += fracstep;
}
for (i = 0; i < outheight; i++, buf += outwidth)
for (i = 0; i < outheight; i++,buf += outwidth)
{
inrow1 = in + inwidth * (int)((i + 0.25) * inheight / outheight);
inrow2 = in + inwidth * (int)((i + 0.75) * inheight / outheight);
@ -246,14 +285,14 @@ bool Image_Processing( const char *name, rgbdata_t **pix )
w = image->width;
h = image->height;
Image_RoundDimensions( &w, &h ); //detect new size
Image_RoundDimensions( &w,&h ); //detect new size
out = Image_Resample((uint *)image->buffer, image->width, image->height, w, h );
if(out != image->buffer)
{
Msg("Resampling %s from[%d x %d] to[%d x %d]\n", name, image->width, image->height, w, h );
Msg("Resampling %s from[%d x %d] to[%d x %d]\n",name, image->width, image->height, w, h );
Mem_Move( imagepool, &image->buffer, out, w * h * 4 );// update image->buffer
image->width = w, image->height = h;
image->width = w,image->height = h;
*pix = image;
return true;
}
@ -268,13 +307,13 @@ bool ConvertImagePixels ( byte *mempool, const char *name, byte parms )
if(!image || !image->buffer) return false;
strncpy( savename, name, sizeof(savename)-1);
strncpy( savename,name,sizeof(savename)-1);
FS_StripExtension( savename ); // remove extension if needed
FS_DefaultExtension( savename, ".tga" );// set new extension
w = image->width, h = image->height;
if(FS_CheckParm("-resample"))
Image_Processing( name, &image );
Image_Processing( name,&image );
FS_SaveImage( savename, image );// save as TGA
FS_FreeImage( image );

View File

@ -6,339 +6,48 @@
#ifndef COM_ZLIB_H
#define COM_ZLIB_H
#define ZLIB_VERSION "1.2.3"
#define ZLIB_VERSION "1.2.3"
#define MAX_WBITS 15
#define PUP(a) *(a)++
#define DEF_MEM_LEVEL 8
// compression levels
#define Z_DEFAULT_COMPRESSION (-1)
#define Z_NO_COMPRESSION 0
#define Z_BEST_SPEED 1
#define Z_BEST_COMPRESSION 9
// compression strategy; see deflateInit2() below for details
#define Z_DEFAULT_STRATEGY 0
#define Z_FILTERED 1
#define Z_HUFFMAN_ONLY 2
// Possible values of the data_type field
#define Z_BINARY 0
#define Z_ASCII 1
#define Z_UNKNOWN 2
// tree types
#define STORED_BLOCK 0
#define STATIC_TREES 1
#define DYN_TREES 2
//zflags
#define PRESET_DICT 0x20 // preset dictionary flag in zlib header
#define MIN_LOOKAHEAD (258+3+1)// MAX_MATCH+MIN_MATCH+1
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
#define LENGTH_CODES 29
#define LITERALS 256
#define L_CODES (LITERALS+1+LENGTH_CODES)
#define D_CODES 30
#define BL_CODES 19
#define HEAP_SIZE (2*L_CODES+1)
#define ZipAlloc(strm, items, size) (*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZipFree(strm, addr) (*((strm)->zfree))((strm)->opaque, (void*)(addr))
typedef struct
{
byte op; // operation, extra bits, table bits
byte bits; // bits in this part of the code
word val; // offset in table or code value
} code;
typedef enum
{
CODES,
LENS,
DISTS
} codetype;
typedef enum
{
need_more, // block not completed, need more input or more output
block_done, // block flush performed
finish_started, // finish started, need only more output at next deflate
finish_done // finish done, accept no more input or output
} block_state;
typedef struct ct_data_s
{
union
{
word freq; // frequency count
word code; // bit string
} fc;
union
{
word dad; // father node in Huffman tree
word len; // length of bit string
} dl;
} ct_data;
typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s
{
ct_data *dyn_tree; // the dynamic tree
int max_code; // largest code with non zero frequency
static_tree_desc *stat_desc; // the corresponding static tree
} tree_desc;
typedef byte* (*alloc_func)();
typedef void (*free_func)();
typedef block_state (*compress_func)();
// Possible inflate modes between inflate() calls
typedef enum
{
HEAD, // i: waiting for magic header
FLAGS, // i: waiting for method and flags (gzip)
TIME, // i: waiting for modification time (gzip)
OS, // i: waiting for extra flags and operating system (gzip)
EXLEN, // i: waiting for extra length (gzip)
EXTRA, // i: waiting for extra bytes (gzip)
NAME, // i: waiting for end of file name (gzip)
COMMENT, // i: waiting for end of comment (gzip)
HCRC, // i: waiting for header crc (gzip)
DICTID, // i: waiting for dictionary check value
DICT, // waiting for inflateSetDictionary() call
TYPE, // i: waiting for type bits, including last-flag bit
TYPEDO, // i: same, but skip check to exit inflate on new block
STORED, // i: waiting for stored size (length and complement)
COPY, // i/o: waiting for input or output to copy stored block
TABLE, // i: waiting for dynamic block table lengths
LENLENS, // i: waiting for code length code lengths
CODELENS, // i: waiting for length/lit and distance code lengths
LEN, // i: waiting for length/lit code
LENEXT, // i: waiting for length extra bits
DIST, // i: waiting for distance code
DISTEXT, // i: waiting for distance extra bits
MATCH, // o: waiting for output space to copy string
LIT, // o: waiting for output space to write literal
CHECK, // i: waiting for 32-bit check value
LENGTH, // i: waiting for 32-bit length (gzip)
DONE, // finished check, done -- remain here until reset
BAD, // got a data error -- remain here until reset
MEM, // got an inflate() memory error -- remain here until reset
SYNC // looking for synchronization bytes to restart inflate()
} inflate_mode;
typedef struct gz_header_s
{
int text; // true if compressed data believed to be text
dword time; // modification time
int xflags; // extra flags (not used when writing a gzip file)
int os; // operating system
byte *extra; // pointer to extra field or Z_NULL if none
dword extra_len;// extra field length (valid if extra != Z_NULL)
dword extra_max;// space at extra (only when reading header)
byte *name; // pointer to zero-terminated file name or Z_NULL
dword name_max; // space at name (only when reading header)
byte *comment; // pointer to zero-terminated comment or Z_NULL
dword comm_max; // space at comment (only when reading header)
int hcrc; // true if there was or will be a header crc
int done; // true when done reading gzip header (not used when writing a gzip file)
}gz_header;
typedef gz_header *gz_headerp;
// zlib errors
#define Z_OK 0
#define Z_STREAM_END 1
#define Z_SYNC_FLUSH 2
#define Z_FINISH 4
typedef struct z_stream_s
{
byte *next_in; // next input byte
dword avail_in; // number of bytes available at next_in
uint avail_in; // number of bytes available at next_in
dword total_in; // total nb of input bytes read so far
byte *next_out; // next output byte should be put there
dword avail_out; // remaining free space at next_out
uint avail_out; // remaining free space at next_out
dword total_out; // total nb of bytes output so far
char *msg; // last error message, NULL if no error
struct int_state *state; // not visible by applications
alloc_func zalloc; // used to allocate the internal state
free_func zfree; // used to free the internal state
byte *state; // not visible by applications
byte* (*zalloc)(); // used to allocate the internal state
void (*zfree)(); // used to free the internal state
byte* opaque; // private data object passed to zalloc and zfree
int data_type; // best guess about the data type: binary or text
dword adler; // adler32 value of the uncompressed data
dword reserved; // reserved for future use
}z_stream;
typedef z_stream *z_streamp;
struct inflate_state
{
inflate_mode mode; // current inflate mode
int last; // true if processing last block
int wrap; // bit 0 true for zlib, bit 1 true for gzip
int havedict; // true if dictionary provided
int flags; // gzip header method and flags (0 if zlib)
uint dmax; // zlib header max distance (INFLATE_STRICT)
dword check; // protected copy of check value
dword total; // protected copy of output count
gz_headerp head; // where to save gzip header information
// sliding window
uint wbits; // log base 2 of requested window size
uint wsize; // window size or zero if not using window
uint whave; // valid bytes in the window
uint write; // window write index
byte *window; // allocated sliding window, if needed
// bit accumulator
dword hold; // input bit accumulator
uint bits; // number of bits in "in"
// for string and stored block copying
uint length; // literal or length of data to copy
uint offset; // distance back to copy string from
// for table and code decoding
uint extra; // extra bits needed
// fixed and dynamic code tables
code const *lencode; // starting table for length/literal codes
code const *distcode; // starting table for distance codes
uint lenbits; // index bits for lencode
uint distbits; // index bits for distcode
// dynamic table building
uint ncode; // number of code length code lengths
uint nlen; // number of length code lengths
uint ndist; // number of distance code lengths
uint have; // number of code lengths in lens[]
code *next; // next available space in codes[]
word lens[320]; // temporary storage for code lengths
word work[288]; // work area for code table building
code codes[2048]; // space for code tables
};
typedef struct int_state
{
z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */
byte *pending_buf; /* output still pending */
dword pending_buf_size; /* size of pending_buf */
byte *pending_out; /* next pending byte to output to the stream */
int pending; /* nb of bytes in the pending buffer */
int noheader; /* suppress zlib header and adler32 */
byte data_type; /* UNKNOWN, BINARY or ASCII */
byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
uint w_size; /* LZ77 window size (32K by default) */
uint w_bits; /* log2(w_size) (8..16) */
uint w_mask; /* w_size - 1 */
byte *window;
dword window_size;
word *prev;
word *head; /* Heads of the hash chains or NIL. */
uint ins_h; /* hash index of string to be inserted */
uint hash_size; /* number of elements in hash table */
uint hash_bits; /* log2(hash_size) */
uint hash_mask; /* hash_size-1 */
uint hash_shift;
long block_start;
uint match_length; /* length of best match */
uint prev_match; /* previous match */
int match_available; /* set if previous match exists */
uint strstart; /* start of string to insert */
uint match_start; /* start of matching string */
uint lookahead; /* number of valid bytes ahead in window */
uint prev_length;
uint max_chain_length;
uint max_lazy_match;
int level; // compression level (1..9)
int strategy; // favor or force Huffman coding
uint good_match;
int nice_match; // Stop searching when current match exceeds this
byte *l_buf; // buffer for literals or lengths
uint lit_bufsize;
uint last_lit; // running index in l_buf
word *d_buf;
ct_data dyn_ltree[HEAP_SIZE]; // literal and length tree
ct_data dyn_dtree[2*D_CODES+1]; // distance tree
ct_data bl_tree[2*BL_CODES+1]; // Huffman tree for bit lengths
tree_desc l_desc; // desc. for literal tree
tree_desc d_desc; // desc. for distance tree
tree_desc bl_desc; // desc. for bit length tree
word bl_count[MAX_WBITS+1];
int heap[2*L_CODES+1]; // heap used to build the Huffman trees
int heap_len; // number of elements in the heap
int heap_max; // element of largest frequency
byte depth[2*L_CODES+1];
dword opt_len; // bit length of current block with optimal trees
dword static_len; // bit length of current block with static trees
uint matches; // number of string matches in current block
int last_eob_len; // bit length of EOB code for last block
word bi_buf;
int bi_valid;
} deflate_state;
//zlib errors
#define Z_OK 0
#define Z_STREAM_END 1
#define Z_NEED_DICT 2
#define Z_ERRNO (-1)
#define Z_STREAM_ERROR (-2)
#define Z_DATA_ERROR (-3)
#define Z_MEM_ERROR (-4)
#define Z_BUF_ERROR (-5)
#define Z_VERSION_ERROR (-6)
#define Z_NO_FLUSH 0
#define Z_PARTIAL_FLUSH 1
#define Z_SYNC_FLUSH 2
#define Z_FULL_FLUSH 3
#define Z_FINISH 4
#define Z_BLOCK 5
#define Z_DEFLATED 8
// zlib states
#define INIT_STATE 42
#define BUSY_STATE 113
#define FINISH_STATE 666
#define put_byte(s, c) { s->pending_buf[s->pending++] = (c); }
#define put_short(s, w) { put_byte(s, (byte)((w) & 0xff)); put_byte(s, (byte)((byte)(w) >> 8)); }
_inline void putShortMSB (deflate_state *s, uint b){ put_byte(s, (byte)(b >> 8)); put_byte(s, (byte)(b & 0xff)); }
} z_stream;
// exported functions
dword adler32(dword adler, const byte *buf, dword len);
extern int inflate(z_streamp strm, int flush);
extern int inflateEnd(z_streamp strm);
extern int inflateInit_(z_streamp strm, const char *version, int stream_size);
extern int inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size);
extern int inflateReset(z_streamp strm);
extern int deflate (z_streamp strm, int flush);
extern int deflateEnd (z_streamp strm);
extern int deflateInit_(z_streamp strm, int level, const char *version, int stream_size);
extern int deflateInit2_(z_streamp strm, int level, int windowBits, const char *version, int stream_size);
extern int deflateReset (z_streamp strm);
extern int inflate(z_stream *strm, int flush);
extern int inflateEnd(z_stream *strm);
extern int inflateInit_(z_stream *strm, const char *version, int stream_size);
extern int inflateInit2_(z_stream *strm, int windowBits, const char *version, int stream_size);
extern int inflateReset(z_stream *strm);
extern int deflate (z_stream *strm, int flush);
extern int deflateEnd (z_stream *strm);
extern int deflateInit_(z_stream *strm, int level, const char *version, int stream_size);
extern int deflateInit2_ (z_stream *strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size);
extern int deflateReset (z_stream *strm);
#define inflateInit(strm) inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
#define inflateInit2(strm, windowBits) inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
#define deflateInit(strm, level) deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
#define deflateInit2(strm, level, windowBits) deflateInit2_((strm),(level),(windowBits), ZLIB_VERSION, sizeof(z_stream))
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) deflateInit2_((strm),(level),(method),(windowBits),(memLevel),(strategy), ZLIB_VERSION, sizeof(z_stream))
#endif//COM_ZLIB_H

File diff suppressed because it is too large Load Diff

BIN
common/common/zlib.lib Normal file

Binary file not shown.

View File

@ -284,17 +284,16 @@ int PR_decode(int complen, int len, int method, char *info, char **data)
}
else if (method == 2)// compression (ZLIB)
{
z_stream strm = {info, complen, 0, buffer, len, 0, NULL, NULL, NULL, NULL, NULL, Z_BINARY, 0, 0 };
z_stream strm = {info, complen, 0, buffer, len, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
inflateInit( &strm );
// decompress it in one go.
if (Z_STREAM_END != inflate( &strm, Z_FINISH ))
{
Msg("Failed block decompression: %s\n", strm.msg );
Sys_Error("Failed block decompression: %s\n", strm.msg );
return false;
}
inflateEnd( &strm );
Msg("inflanting %s\n", strm.msg );
}
else
{
@ -326,23 +325,22 @@ int PR_encode(int len, int method, char *in, vfile_t *handle)
else if (method == 2)// compression (ZLIB)
{
char out[8192];
z_stream strm = {in, len, 0, out, sizeof(out), 0, NULL, NULL, NULL, NULL, NULL, Z_BINARY, 0, 0 };
z_stream strm = {in, len, 0, out, sizeof(out), 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
deflateInit( &strm, Z_BEST_COMPRESSION);
deflateInit( &strm, 9 ); // Z_BEST_COMPRESSION
while(deflate( &strm, Z_FINISH) == Z_OK)
{
// compress in chunks of 8192. Saves having to allocate a huge-mega-big buffer
VFS_Write( handle, out, sizeof(out) - strm.avail_out);
i += sizeof(out) - strm.avail_out;
Msg("Zlib statuc %s\n", strm.msg );
strm.next_out = out;
strm.avail_out = sizeof(out);
}
VFS_Write( handle, out, sizeof(out) - strm.avail_out );
i += sizeof(out) - strm.avail_out;
Msg("real length %d, compressed len %d\n", len, i );
deflateEnd( &strm );
return i;
}

View File

@ -1294,11 +1294,11 @@ PRVM_LoadProgs
*/
void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int numedfields, prvm_fieldvars_t *ed_field)
{
int i, len;
dstatement_t *st;
ddef_t *infielddefs;
dfunction_t *dfunctions;
fs_offset_t filesize;
int i, len, complen;
byte *s;
if( prog->loaded )
@ -1341,13 +1341,20 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
PRVM_ERROR ("%s: %s system vars have been modified, progdefs.h is out of date", PRVM_NAME, filename);
break;
}
Msg("Loading %s\n", filename );
Msg("Loading %s [CRC %d]\n", filename, prog->progs->crc );
// set initial pointers
prog->statements = (dstatement_t *)((byte *)prog->progs + prog->progs->ofs_statements);
prog->globaldefs = (ddef_t *)((byte *)prog->progs + prog->progs->ofs_globaldefs);
infielddefs = (ddef_t *)((byte *)prog->progs + prog->progs->ofs_fielddefs);
dfunctions = (dfunction_t *)((byte *)prog->progs + prog->progs->ofs_functions);
prog->strings = (char *)prog->progs + prog->progs->ofs_strings;
prog->globals.gp = (float *)((byte *)prog->progs + prog->progs->ofs_globals);
// debug info
if (prog->progs->ofslinenums) prog->linenums = (int *)((byte *)prog->progs + prog->progs->ofslinenums);
if (prog->progs->ofs_types) prog->types = (typeinfo_t *)((byte *)prog->progs + prog->progs->ofs_types);
prog->statements = (dstatement_t *)((byte *)prog->progs + prog->progs->ofs_statements);
// decompress progs if needed
if (prog->progs->blockscompressed & COMP_STATEMENTS)
{
@ -1361,39 +1368,138 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
len = sizeof(dstatement16_t) * prog->progs->numstatements;
break;
}
s = Mem_Alloc(prog->progs_mempool, len ); //alloc memory for inflate block
Com->Compile.DecryptDAT(LittleLong(*(int*)prog->statements), len, 2, (char *)(((int *)prog->statements)+1), &s);
prog->statements = (dstatement16_t *)s;
}
Sys_Error("breakpoint\n");
dfunctions = (dfunction_t *)((byte *)prog->progs + prog->progs->ofs_functions);
complen = LittleLong(*(int*)prog->statements);
Msg("Unpacked statements: len %d, comp len %d\n", len, complen );
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->statements)+1), &s);
prog->statements = (dstatement16_t *)s;
filesize += len - complen - sizeof(int); //merge filesize
}
if (prog->progs->blockscompressed & COMP_DEFS)
{
switch(prog->intsize)
{
case 32:
len = sizeof(ddef32_t) * prog->progs->numglobaldefs;
break;
case 16:
default:
len = sizeof(ddef16_t) * prog->progs->numglobaldefs;
break;
}
complen = LittleLong(*(int*)prog->globaldefs);
Msg("Unpacked defs: len %d, comp len %d\n", len, complen);
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->globaldefs)+1), &s);
prog->globaldefs = (ddef16_t *)s;
filesize += len - complen - sizeof(int); //merge filesize
}
if (prog->progs->blockscompressed & COMP_FIELDS)
{
switch(prog->intsize)
{
case 32:
len = sizeof(ddef32_t) * prog->progs->numfielddefs;
break;
case 16:
default:
len = sizeof(ddef16_t) * prog->progs->numfielddefs;
break;
}
complen = LittleLong(*(int*)infielddefs);
Msg("Unpacked fields: len %d, comp len %d\n", len, complen );
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)infielddefs)+1), &s);
infielddefs = (ddef16_t *)s;
filesize += len - complen - sizeof(int); //merge filesize
}
if (prog->progs->blockscompressed & COMP_FUNCTIONS)
{
len = sizeof(dfunction_t) * prog->progs->numfunctions;
complen = LittleLong(*(int*)dfunctions);
Msg("Unpacked functions: len %d, comp len %d\n", len, complen );
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)dfunctions)+1), &s);
dfunctions = (dfunction_t *)s;
filesize += len - complen - sizeof(int); //merge filesize
}
if (prog->progs->blockscompressed & COMP_STRINGS)
{
len = sizeof(char) * prog->progs->numstrings;
complen = LittleLong(*(int*)prog->strings);
Msg("Unpacked strings: count %d, len %d, comp len %d\n", prog->progs->numstrings, len, complen );
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->strings)+1), &s);
prog->strings = (char *)s;
prog->progs->ofs_strings += 4;
filesize += len - complen - sizeof(int); //merge filesize
}
if (prog->progs->blockscompressed & COMP_GLOBALS)
{
len = sizeof(float) * prog->progs->numglobals;
complen = LittleLong(*(int*)prog->globals.gp);
Msg("Unpacked globals: len %d, comp len %d\n", len, complen );
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->globals.gp)+1), &s);
prog->globals.gp = (float *)s;
filesize += len - complen - sizeof(int); //merge filesize
}
if (prog->linenums && prog->progs->blockscompressed & COMP_LINENUMS)
{
len = sizeof(int) * prog->progs->numstatements;
complen = LittleLong(*(int*)prog->linenums);
Msg("Unpacked linenums: len %d, comp len %d\n", len, complen );
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->linenums)+1), &s);
prog->linenums = (int *)s;
filesize += len - complen - sizeof(int); //merge filesize
}
if (prog->types && prog->progs->blockscompressed & COMP_TYPES)
{
len = sizeof(typeinfo_t) * prog->progs->numtypes;
complen = LittleLong(*(int*)prog->types);
Msg("Unpacked types: len %d, comp len %d\n", len, complen );
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
Com->Compile.DecryptDAT( complen, len, 2, (char *)(((int *)prog->types)+1), &s);
prog->types = (typeinfo_t *)s;
filesize += len - complen - sizeof(int); //merge filesize
}
prog->strings = (char *)prog->progs + prog->progs->ofs_strings;
prog->stringssize = 0;
for (i = 0; i < prog->progs->numstrings; i++)
for (i = 0; prog->stringssize < prog->progs->numstrings; i++)
{
if (prog->progs->ofs_strings + prog->stringssize >= (int)filesize)
PRVM_ERROR ("%s: %s strings go past end of file", PRVM_NAME, filename);
prog->stringssize += (int)strlen (prog->strings + prog->stringssize) + 1;
prog->stringssize += (int)strlen(prog->strings + prog->stringssize) + 1;
}
prog->numknownstrings = 0;
prog->maxknownstrings = 0;
prog->knownstrings = NULL;
prog->knownstrings_freeable = NULL;
prog->globaldefs = (ddef_t *)((byte *)prog->progs + prog->progs->ofs_globaldefs);
// we need to expand the fielddefs list to include all the engine fields,
// so allocate a new place for it
infielddefs = (ddef_t *)((byte *)prog->progs + prog->progs->ofs_fielddefs);
// ( + DPFIELDS )
// so allocate a new place for it ( + DPFIELDS )
prog->fielddefs = (ddef_t *)Mem_Alloc(prog->progs_mempool, (prog->progs->numfielddefs + numedfields) * sizeof(ddef_t));
prog->statement_profile = (double *)Mem_Alloc(prog->progs_mempool, prog->progs->numstatements * sizeof(*prog->statement_profile));
// moved edict_size calculation down below field adding code
prog->globals.gp = (float *)((byte *)prog->progs + prog->progs->ofs_globals);
// byte swap the lumps
for (i = 0; i < prog->progs->numstatements; i++)
{
@ -1402,7 +1508,6 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
prog->statements[i].b = LittleShort(prog->statements[i].b);
prog->statements[i].c = LittleShort(prog->statements[i].c);
}
prog->functions = (mfunction_t *)Mem_Alloc(prog->progs_mempool, sizeof(mfunction_t) * prog->progs->numfunctions);
for (i = 0; i < prog->progs->numfunctions; i++)
{
@ -1552,7 +1657,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
}
}
PRVM_LoadLNO(filename);
if(!prog->linenums) PRVM_LoadLNO(filename);
PRVM_Init_Exec();

View File

@ -1,7 +1,8 @@
=======================================================================
Xash3D QuakeC Compiler started at Sep30 2007 [23:56:40]
Xash3D QuakeC Compiler started at Oct02 2007 [22:41:55]
=======================================================================
--------------------Configuration: server - Vm16 Debug--------------------
warning C0: Unrecognised optimisation parameter (/Oz)
--------------------Configuration: server - Vm16 Release--------------------
Compiling...
defs.c
main.c
@ -35,26 +36,34 @@ ents/funcs/func_areaportal.c
ents/items/items.c
impulses.c
Xash3D virtual machine
19056 strofs (of 1000000)
10704 strofs (of 1000000)
2799 numstatements (of 524288)
281 numfunctions (of 16384)
916 numglobaldefs (of 32768)
691 numglobaldefs (of 32768)
245 numfielddefs (218 unique) (of 2048)
927 numpr_globals (of 65536)
Writing server.dat
64748 TOTAL SIZE
real length 10704, compressed len 4119
real length 22392, compressed len 5194
real length 10116, compressed len 2226
real length 5528, compressed len 2467
real length 1960, compressed len 980
real length 3708, compressed len 1191
16389 TOTAL SIZE
17 unique precache_sounds
3 unique precache_models
optres_shortenifnots 28
optres_overlaptemps 1284
optres_noduplicatestrings 4943
optres_nonvec_parms 479
optres_assignments 40
optres_unreferenced 52
optres_dupconstdefs 68
optres_stripfunctions 225
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
server.dat - 0 error(s), 0 warning(s)
=======================================================================
Xash3D QuakeC Compiler stopped at Sep30 2007 [23:56:40]
Xash3D QuakeC Compiler stopped at Oct02 2007 [22:41:55]
=======================================================================

View File

@ -12,7 +12,7 @@
| refuse to run. |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
*/
#pragma TARGET DEBUG
#pragma TARGET RELEASE
// These lines CANNOT be altered/moved
// pointers to ents

View File

@ -1 +1 @@
qcclib -log -debug
qcclib -log -debug -O3 /Oz

Binary file not shown.