14 Sep 2007

This commit is contained in:
g-cont 2007-09-14 00:00:00 +04:00 committed by Alibek Omarov
parent fd89db2808
commit 5ddcd71116
152 changed files with 3834 additions and 1950 deletions

View File

@ -1,4 +1,5 @@
Разработать концепцию языка VirtualC\VirtualC++ (базируется на QuakeC)
Придумать новые имена (6 символов) для launcher.dll
Quake1 Quake2
SV_MoveBounds SV_TraceBounds
@ -14,12 +15,21 @@ SV_ClipToLinks SV_ClipMoveToEntities
6. Перевести сервер на float OK
7. Имплементация загрузки дллок (в лаунчер) OK
8. Перенести в лаунчер большинство Sys_ вызовов OK
9. Присоеденить msvcrt.dll ко всем проектам
9. Присоеденить msvcrt.dll ко всем проектам OK
10. Имплементировать GetProcAddress в stdinout_t OK
11. Имплементация второй части zlib в platform.dll OK
12. Подключить advapi динамически OK
13. Переименовать platform.dll в common.dll OK
14. Переименовать renderer.dll в render.dll OK
15. Упорядочить файлы и код в common.dll
//==================================================
// то, что уже готово
//==================================================
+исправлен баг с флагом RF_FULLBRIGHT для studio models в режиме RDF_NOWORLDMODEL
+существенно уменьшен размер всех лаунчеров
+новая система загрузки дллок (поддержка нативных библиотек)
+добавлены кастомные названия окна для различных инстанций (studiomdl, bsplib итд)
+исправлен баг с кодом возвращаемой ошибки

View File

@ -28,18 +28,6 @@ void Plat_LinkDlls( void )
//Sys_LoadLibrary( &winmm_dll );
}
char *strupr (char *start)
{
char *in;
in = start;
while (*in)
{
*in = toupper(*in);
in++;
}
return start;
}
char *strlower (char *start)
{
char *in;

View File

@ -91,7 +91,7 @@ void FS_Shutdown (void);
#define Mem_Move(dest, src, size ) _Mem_Move (dest, src, size, __FILE__, __LINE__)
#define Mem_Copy(dest, src, size ) _Mem_Copy (dest, src, size, __FILE__, __LINE__)
stdinout_api_t std;
extern stdlib_api_t std;
extern gameinfo_t GI;
#define Msg std.printf
@ -123,9 +123,7 @@ extern byte *studiopool;
//misc common functions
char *copystring(char *s);
char *strupr (char *start);
char *strlower (char *start);
char* FlipSlashes(char* string);
char *va(const char *format, ...);
char *stristr( const char *string, const char *string2 );
void ExtractFilePath(const char* const path, char* dest);

View File

@ -1,24 +1,24 @@
# Microsoft Developer Studio Project File - Name="platform" - Package Owner=<4>
# Microsoft Developer Studio Project File - Name="common" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=platform - Win32 Debug
CFG=common - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "platform.mak".
!MESSAGE NMAKE /f "common.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "platform.mak" CFG="platform - Win32 Debug"
!MESSAGE NMAKE /f "common.mak" CFG="common - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "platform - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "platform - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "common - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "common - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
@ -29,7 +29,7 @@ CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "platform - Win32 Release"
!IF "$(CFG)" == "common - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
@ -38,12 +38,12 @@ RSC=rc.exe
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\temp\platform\!release"
# PROP Intermediate_Dir "..\temp\platform\!release"
# PROP Output_Dir "..\temp\common\!release"
# PROP Intermediate_Dir "..\temp\common\!release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./mdllib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./mdllib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -54,18 +54,18 @@ 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 kernel32.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /opt:nowin98
# ADD LINK32 msvcrt.lib winmm.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# Begin Custom Build
TargetDir=\XASH3D\src_main\!source\temp\platform\!release
InputPath=\XASH3D\src_main\!source\temp\platform\!release\platform.dll
TargetDir=\XASH3D\src_main\!source\temp\common\!release
InputPath=\XASH3D\src_main\!source\temp\common\!release\common.dll
SOURCE="$(InputPath)"
"D:\Xash3D\bin\platform.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\platform.dll "D:\Xash3D\bin\platform.dll"
"D:\Xash3D\bin\common.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\common.dll "D:\Xash3D\bin\common.dll"
# End Custom Build
!ELSEIF "$(CFG)" == "platform - Win32 Debug"
!ELSEIF "$(CFG)" == "common - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
@ -74,12 +74,12 @@ SOURCE="$(InputPath)"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\temp\platform\!debug"
# PROP Intermediate_Dir "..\temp\platform\!debug"
# PROP Output_Dir "..\temp\common\!debug"
# PROP Intermediate_Dir "..\temp\common\!debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLATFORM_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./mdllib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -90,15 +90,15 @@ 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 kernel32.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept
# ADD LINK32 msvcrt.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept
# SUBTRACT LINK32 /incremental:no /nodefaultlib
# Begin Custom Build
TargetDir=\XASH3D\src_main\!source\temp\platform\!debug
InputPath=\XASH3D\src_main\!source\temp\platform\!debug\platform.dll
TargetDir=\XASH3D\src_main\!source\temp\common\!debug
InputPath=\XASH3D\src_main\!source\temp\common\!debug\common.dll
SOURCE="$(InputPath)"
"D:\Xash3D\bin\platform.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\platform.dll "D:\Xash3D\bin\platform.dll"
"D:\Xash3D\bin\common.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\common.dll "D:\Xash3D\bin\common.dll"
# End Custom Build
@ -106,8 +106,8 @@ SOURCE="$(InputPath)"
# Begin Target
# Name "platform - Win32 Release"
# Name "platform - Win32 Debug"
# Name "common - Win32 Release"
# Name "common - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
@ -213,11 +213,11 @@ SOURCE=.\spritegen.c
# End Source File
# Begin Source File
SOURCE=.\mdllib\studio.c
SOURCE=.\common\studio.c
# End Source File
# Begin Source File
SOURCE=.\mdllib\studio_utils.c
SOURCE=.\common\studio_utils.c
# End Source File
# Begin Source File
@ -269,7 +269,7 @@ SOURCE=.\image.h
# End Source File
# Begin Source File
SOURCE=.\mdllib\mdllib.h
SOURCE=.\common\mdllib.h
# End Source File
# Begin Source File

View File

@ -10,6 +10,7 @@
#include "qcclib.h"
bool host_debug = false;
stdlib_api_t std;
gameinfo_t Plat_GameInfo( void )
{
@ -18,7 +19,7 @@ gameinfo_t Plat_GameInfo( void )
bool InitPlatform ( int argc, char **argv )
{
MsgDev(D_INFO, "------- Loading bin/platform.dll [%g] -------\n", PLATFORM_VERSION );
MsgDev(D_INFO, "------- Loading bin/common.dll [%g] -------\n", COMMON_VERSION );
InitMemory();
Plat_InitCPU();
@ -39,9 +40,9 @@ void ClosePlatform ( void )
FreeMemory();
}
platform_exp_t DLLEXPORT *CreateAPI ( stdinout_api_t *input )
common_exp_t DLLEXPORT *CreateAPI ( stdlib_api_t *input )
{
static platform_exp_t pi;
static common_exp_t Com;
// Sys_LoadLibrary can create fake instance, to check
// api version and api size, but first argument will be 0
@ -49,27 +50,27 @@ platform_exp_t DLLEXPORT *CreateAPI ( stdinout_api_t *input )
if(input) std = *input;
//generic functions
pi.apiversion = PLATFORM_API_VERSION;
pi.api_size = sizeof(platform_exp_t);
Com.apiversion = COMMON_API_VERSION;
Com.api_size = sizeof(common_exp_t);
pi.Init = InitPlatform;
pi.Shutdown = ClosePlatform;
Com.Init = InitPlatform;
Com.Shutdown = ClosePlatform;
//get interfaces
pi.Fs = FS_GetAPI();
pi.VFs = VFS_GetAPI();
pi.Mem = Mem_GetAPI();
pi.Script = Sc_GetAPI();
pi.Compile = Comp_GetAPI();
pi.Info = Info_GetAPI();
Com.Fs = FS_GetAPI();
Com.VFs = VFS_GetAPI();
Com.Mem = Mem_GetAPI();
Com.Script = Sc_GetAPI();
Com.Compile = Comp_GetAPI();
Com.Info = Info_GetAPI();
pi.InitRootDir = FS_InitRootDir;
pi.LoadGameInfo = FS_LoadGameInfo;
pi.AddGameHierarchy = FS_AddGameHierarchy;
Com.InitRootDir = FS_InitRootDir;
Com.LoadGameInfo = FS_LoadGameInfo;
Com.AddGameHierarchy = FS_AddGameHierarchy;
//timer
pi.DoubleTime = Plat_DoubleTime;
pi.GameInfo = Plat_GameInfo;
Com.DoubleTime = Plat_DoubleTime;
Com.GameInfo = Plat_GameInfo;
return &pi;
return &Com;
}

View File

@ -4,6 +4,7 @@
//=======================================================================
#include "qcclib.h"
#include "zip32.h"
void Hash_InitTable(hashtable_t *table, int numbucks, void *mem)
{
@ -265,18 +266,27 @@ PR_decode
char *PR_decode(int complen, int len, int method, char *info, char *buffer)
{
int i;
if (method == 0) //copy
if (method == 0) // copy
{
if (complen != len) Sys_Error("lengths do not match");
memcpy(buffer, info, len);
}
else if (method == 1)//encryption
else if (method == 1)// encryption
{
if (complen != len) Sys_Error("lengths do not match");
for (i = 0; i < len; i++) buffer[i] = info[i] ^ 0xA5;
}
else Sys_Error("Bad file encryption routine\n");
else if (method == 2)// compression (ZLIB)
{
z_stream strm = {info, complen, 0, buffer, len, 0, NULL, NULL, NULL, NULL, NULL, Z_BINARY, 0, 0 };
inflateInit( &strm );
// decompress it in one go.
if (Z_STREAM_END != inflate( &strm, Z_FINISH ))
Sys_Error("Failed block decompression\n");
inflateEnd( &strm );
}
else Sys_Error("PR_decode: Bad file encryption routine\n");
return buffer;
}
@ -288,21 +298,44 @@ PR_encode
*/
int PR_encode(int len, int method, char *in, vfile_t *handle)
{
int i;
if (method == 0) //copy
int i = 0;
if (method == 0) // copy
{
VFS_Write(handle, in, len);
return len;
}
else if (method == 1)//encryption
else if (method == 1)// encryption
{
for (i = 0; i < len; i++) in[i] = in[i] ^ 0xA5;
VFS_Write(handle, in, len);
return len;
}
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 };
deflateInit( &strm, 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;
deflateEnd( &strm );
return i;
}
else
{
Sys_Error("Wierd method");
Sys_Error("PR_encode: Bad encryption method\n");
return 0;
}
}

View File

@ -38,7 +38,7 @@ int numtemps;
void PR_ResetErrorScope(void);
bool compressoutput;
bool compressoutput = false;
bool newstylesource;
char destfile[1024];
@ -337,7 +337,6 @@ void PR_PrintGlobals (void)
}
}
int encode(int len, int method, char *in, int handle);
int WriteSourceFiles(vfile_t *h, dprograms_t *progs, bool sourceaswell)
{
includeddatafile_t *idf;
@ -345,26 +344,6 @@ int WriteSourceFiles(vfile_t *h, dprograms_t *progs, bool sourceaswell)
int num=0;
int ofs;
/*
for (f = sourcefile; f ; f=f->next)
{
if (f->type == FT_CODE && !sourceaswell)
continue;
VFS_Write(h, f->filename, strlen(f->filename)+1);
i = LittleLong(f->size);
VFS_Write(h, &i, sizeof(int));
i = LittleLong(encrpytmode);
VFS_Write(h, &i, sizeof(int));
if (encrpytmode)
for (i = 0; i < f->size; i++)
f->file[i] ^= 0xA5;
VFS_Write(h, f->file, f->size);
}*/
for (f = sourcefile,num=0; f ; f=f->next)
{
if (f->type == FT_CODE && !sourceaswell)
@ -372,8 +351,7 @@ int WriteSourceFiles(vfile_t *h, dprograms_t *progs, bool sourceaswell)
num++;
}
if (!num)
return 0;
if (!num) return 0;
idf = Qalloc(sizeof(includeddatafile_t)*num);
for (f = sourcefile,num=0; f ; f=f->next)
{
@ -2078,6 +2056,7 @@ void PR_SetDefaultProperties (void)
PR_DefineName("OP_COMP_GLOBALS");
PR_DefineName("OP_COMP_LINES");
PR_DefineName("OP_COMP_TYPES");
compressoutput = true; //enable compression
}
if (FS_CheckParm("/O0") || FS_CheckParm("-O0"))
@ -2088,8 +2067,7 @@ void PR_SetDefaultProperties (void)
level = 2;
else if (FS_CheckParm("/O3") || FS_CheckParm("-O3"))
level = 3;
else
level = -1;
else level = -1;
if (level == -1)
{
@ -2112,7 +2090,7 @@ void PR_SetDefaultProperties (void)
}
}
targetformat = QCF_STANDARD;
//targetformat = QCF_STANDARD;
//enable all warnings
@ -2172,7 +2150,6 @@ void PR_main ( void ) //as part of the quake engine
maxtypeinfos = 16384;
MAX_CONSTANTS = 2048;
compressoutput = 0;
strcpy(v_copyright, "This file was created with ForeThought's modified QuakeC compiler\nThanks to ID Software");
for (p = 0; compiler_flag[p].enabled; p++)

View File

@ -8,11 +8,45 @@
#define ZLIB_VERSION "1.2.3"
#define MAX_WBITS 15
#define MAX_WBITS 15
#define PUP(a) *(a)++
#define DEF_MEM_LEVEL 8
typedef byte* (*alloc_func)();
typedef void (*free_func) ();
// 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
{
@ -28,6 +62,41 @@ typedef enum
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
{
@ -82,6 +151,26 @@ typedef struct gz_header_s
typedef gz_header *gz_headerp;
typedef struct z_stream_s
{
byte *next_in; // next input byte
dword 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
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* 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
@ -123,26 +212,86 @@ struct inflate_state
code codes[2048]; // space for code tables
};
typedef struct z_stream_s
typedef struct int_state
{
byte *next_in; // next input byte
dword 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
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* 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;
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 */
typedef z_stream *z_streamp;
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
@ -162,16 +311,34 @@ typedef z_stream *z_streamp;
#define Z_BLOCK 5
#define Z_DEFLATED 8
//exported functions
unsigned long crc32(dword crc, const byte *buf, uint len);// crc32
unsigned long adler32(dword adler, const byte *buf, dword len);
// 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)); }
// 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);
#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))
#endif//COM_ZLIB_H

2967
common/ziplib.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,13 +17,13 @@ if errorlevel 1 set BUILD_ERROR=1
%MSDEV% launcher/launcher.dsp %CONFIG%"launcher - Win32 Debug" %build_target%
if errorlevel 1 set BUILD_ERROR=1
%MSDEV% platform/platform.dsp %CONFIG%"platform - Win32 Debug" %build_target%
%MSDEV% common/common.dsp %CONFIG%"common - Win32 Debug" %build_target%
if errorlevel 1 set BUILD_ERROR=1
%MSDEV% renderer/renderer.dsp %CONFIG%"renderer - Win32 Debug" %build_target%
%MSDEV% render/render.dsp %CONFIG%"render - Win32 Debug" %build_target%
if errorlevel 1 set BUILD_ERROR=1
progs\qcclib.exe
vprogs\qcclib.exe
if errorlevel 1 set BUILD_ERROR=1
if "%BUILD_ERROR%"=="" goto build_ok
@ -48,9 +48,9 @@ rem //delete log files
if exist editor\editor.plg del /f /q editor\editor.plg
if exist engine\engine.plg del /f /q engine\engine.plg
if exist launcher\launcher.plg del /f /q launcher\launcher.plg
if exist platform\platform.plg del /f /q platform\platform.plg
if exist renderer\renderer.plg del /f /q renderer\renderer.plg
if exist progs\server.dat copy progs\server.dat D:\Xash3D\xash\server.dat
if exist common\common.plg del /f /q common\common.plg
if exist render\render.plg del /f /q render\render.plg
if exist vprogs\server.dat move vprogs\server.dat D:\Xash3D\xash\server.dat
echo Build succeeded!
echo Please wait. Xash is now loading

View File

@ -5,7 +5,7 @@
#include "editor.h"
stdinout_api_t std;
stdlib_api_t std;
/*
==================
@ -13,7 +13,7 @@ DllMain
==================
*/
launcher_exp_t DLLEXPORT *CreateAPI( stdinout_api_t *input )
launcher_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input )
{
static launcher_exp_t Editor;

View File

@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EDITOR_EXPORTS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -54,10 +54,10 @@ 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
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /machine:I386
# ADD LINK32 msvcrt.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /machine:I386 /nodefaultlib:"libc.lib"
# Begin Custom Build
TargetDir=\Xash3D\src_main\!source\temp\editor\!release
InputPath=\Xash3D\src_main\!source\temp\editor\!release\editor.dll
TargetDir=\XASH3D\src_main\!source\temp\editor\!release
InputPath=\XASH3D\src_main\!source\temp\editor\!release\editor.dll
SOURCE="$(InputPath)"
"D:\Xash3D\bin\editor.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
@ -79,7 +79,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EDITOR_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -90,10 +90,10 @@ 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 kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 msvcrt.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept
# Begin Custom Build
TargetDir=\Xash3D\src_main\!source\temp\editor\!debug
InputPath=\Xash3D\src_main\!source\temp\editor\!debug\editor.dll
TargetDir=\XASH3D\src_main\!source\temp\editor\!debug
InputPath=\XASH3D\src_main\!source\temp\editor\!debug\editor.dll
SOURCE="$(InputPath)"
"D:\Xash3D\bin\editor.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
@ -120,11 +120,11 @@ SOURCE=.\editor.rc
# End Source File
# Begin Source File
SOURCE=.\guiutils.c
SOURCE=.\guiforms.c
# End Source File
# Begin Source File
SOURCE=.\guiforms.c
SOURCE=.\guiutils.c
# End Source File
# End Group
# Begin Group "Header Files"

View File

@ -1,6 +1,6 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// platform.h - game platform dll
// editor.h - recource editor
//=======================================================================
#ifndef GENERICEDIT_H
#define GENERICEDIT_H
@ -29,7 +29,7 @@ void FreeEditor ( void );
extern int com_argc;
extern int dev_mode;
extern bool debug_mode;
extern platform_exp_t *pi;
extern common_exp_t *com;
extern char *com_argv[MAX_NUM_ARGVS];
int CheckParm (const char *parm);
bool _GetParmFromCmdLine( char *parm, char *out, size_t size );
@ -44,7 +44,7 @@ void GUI_Msg( const char *pMsg, ... );
void GUI_MsgDev( int level, const char *pMsg, ... );
void GUI_MsgWarn( const char *pMsg, ... );
extern stdinout_api_t std;
extern stdlib_api_t std;
#define Msg GUI_Msg
#define MsgDev GUI_MsgDev
#define MsgWarn GUI_MsgWarn

View File

@ -31,10 +31,12 @@ typedef struct tag_dlghdr
GUI_Form s_gui;
wnd_options_t w_opts; //window options
platform_exp_t *pi;//platform utils
common_exp_t *com; //common utils
static bool editor_init = false;
static char textbuffer[MAX_INPUTLINE];
dll_info_t platform_dll = { "platform.dll", NULL, "CreateAPI", NULL, NULL, false, PLATFORM_API_VERSION, sizeof(platform_exp_t) };
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, false, COMMON_API_VERSION, sizeof(common_exp_t) };
dll_info_t richedit_dll = { "riched32.dll", NULL, NULL, NULL, NULL, false, 0, 0 };
/*
=============================================================================
@ -454,36 +456,37 @@ void GUI_LoadWndOptions( wnd_options_t *settings )
bool GUI_LoadPlatfrom( char *funcname, int argc, char **argv )
{
stdinout_api_t pistd;//platform callback
platform_t CreatePlat;
stdlib_api_t io; //common callback
common_t CreatePlat;
//create callbacks for platform.dll
pistd.printf = GUI_Msg;
pistd.dprintf = GUI_MsgDev;
pistd.wprintf = GUI_MsgWarn;
pistd.error = GUI_Error;
pistd.exit = std.exit;
pistd.print = GUI_Print;
pistd.input = std.input;
pistd.sleep = std.sleep;
// create callbacks for common.dll
io.printf = GUI_Msg;
io.dprintf = GUI_MsgDev;
io.wprintf = GUI_MsgWarn;
io.error = GUI_Error;
io.exit = std.exit;
io.print = GUI_Print;
io.input = std.input;
io.sleep = std.sleep;
pistd.LoadLibrary = std.LoadLibrary;
pistd.FreeLibrary = std.FreeLibrary;
//loading platform.dll
if (!Sys_LoadLibrary( &platform_dll ))
io.LoadLibrary = std.LoadLibrary;
io.FreeLibrary = std.FreeLibrary;
io.GetProcAddress = std.GetProcAddress;
// loading common.dll
if (!Sys_LoadLibrary( &common_dll ))
{
GUI_Error("couldn't find platform.dll\n");
GUI_Error("couldn't find common.dll\n");
return false;
}
CreatePlat = (void *)platform_dll.main;
pi = CreatePlat( &pistd );//make links
CreatePlat = (void *)common_dll.main;
com = CreatePlat( &io );//make links
//initialziing platform.dll
pi->Init( argc, argv );
//initialziing common.dll
com->Init( argc, argv );
pi->Fs.ClearSearchPath();
pi->AddGameHierarchy( "bin" );
com->Fs.ClearSearchPath();
com->AddGameHierarchy( "bin" );
return true;
}
@ -495,30 +498,29 @@ HWND GUI_CreateConsole( bool readonly )
WS_VSCROLL | ES_LEFT | ES_WANTRETURN | ES_MULTILINE | ES_AUTOVSCROLL;
if (readonly) dwStyle |= ES_READONLY;
if (!s_gui.richedit) s_gui.richedit = LoadLibrary("riched32.dll");
Sys_LoadLibrary( &richedit_dll );
newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, s_gui.richedit ? RICHEDIT_CLASS:"EDIT", "",
newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, richedit_dll.link ? RICHEDIT_CLASS : "EDIT", "",
dwStyle, 0, 0, 0, 0, s_gui.hWnd, NULL, s_gui.gHinst, NULL);
if (!newwnd)
{
//fall back to the earlier version
newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, s_gui.richedit ? RICHEDIT_CLASS10A : "EDIT", "",
newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, richedit_dll.link ? RICHEDIT_CLASS10A : "EDIT", "",
dwStyle, 0, 0, 0, 0, s_gui.hWnd, NULL, s_gui.gHinst, NULL);
}
if (!newwnd)
{
//we don't have RICHEDIT installed properly
FreeLibrary(s_gui.richedit);
s_gui.richedit = NULL;
// we don't have RICHEDIT installed properly
Sys_FreeLibrary( &richedit_dll );
newwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", dwStyle, 0, 0, 0, 0,
s_gui.hWnd, NULL, s_gui.gHinst, NULL);
}
GUI_SetFont( newwnd );
if (s_gui.richedit) SendMessage(newwnd, EM_EXLIMITTEXT, 0, 1<<20);
if (richedit_dll.link) SendMessage(newwnd, EM_EXLIMITTEXT, 0, 1<<20);
return newwnd;
}
@ -992,7 +994,7 @@ void InitEditor ( char *funcname, int argc, char **argv )
wnd_options_t *config_dat;
int config_size;
config_dat = (wnd_options_t *)pi->Fs.LoadFile( "editor.dat", &config_size );
config_dat = (wnd_options_t *)com->Fs.LoadFile( "editor.dat", &config_size );
if(config_dat) //verify our config before read
{
@ -1048,23 +1050,23 @@ void EditorMain ( void )
}
}
if(platform_dll.link)
if(common_dll.link)
{
// save our settings
pi->Fs.WriteFile("editor.dat", &w_opts, w_opts.csize );
com->Fs.WriteFile("editor.dat", &w_opts, w_opts.csize );
}
}
void FreeEditor ( void )
{
// free richedit32
if (s_gui.richedit) FreeLibrary( s_gui.richedit );
Sys_FreeLibrary( &richedit_dll );
// free platform
if(platform_dll.link)
// free common
if(common_dll.link)
{
pi->Shutdown();
Sys_FreeLibrary(&platform_dll);
com->Shutdown();
Sys_FreeLibrary(&common_dll);
}
GUI_RemoveAccelTable();

View File

@ -863,7 +863,7 @@ void CL_AddPacketEntities (frame_t *frame)
renderfx |= RF_SHELL_BLUE;
}
//copy state to renderer
//copy state to render
ent.prev.frame = cent->prev.frame;
ent.backlerp = 1.0 - cl.lerpfrac;
ent.alpha = s1->alpha;

View File

@ -1824,7 +1824,7 @@ void CL_Shutdown(void)
S_Shutdown();
IN_Shutdown ();
VID_FreeRenderer();
VID_FreeRender();
}

View File

@ -339,7 +339,7 @@ void CL_PrepRefresh (void)
re->SetSky (cl.configstrings[CS_SKY], rotate, axis);
Msg (" \r");
// the renderer can now free unneeded stuff
// the render can now free unneeded stuff
re->EndRegistration ();
// clear any lines of console text

View File

@ -421,7 +421,7 @@ void CL_ParseLayout (void);
//
// cl_main
//
extern renderer_exp_t *re;
extern render_exp_t *re;
void CL_Init (void);

View File

@ -44,9 +44,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define RAD_TO_STUDIO (32768.0/M_PI)
#define STUDIO_TO_RAD (M_PI/32768.0)
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);
//============================================================================
typedef struct sizebuf_s

View File

@ -1768,7 +1768,7 @@ cmodel_t *CM_StudioModel (char *name, byte *buffer)
out = &map_cmodels[max_models];
out->extradata = buffer;
out->numframes = 0;//reset sprite info
strlcpy(out->name, modname, sizeof(out->name));
strncpy(out->name, modname, sizeof(out->name));
if(SV_StudioExtractBbox( phdr, 0, out->mins, out->maxs ))
{
@ -1818,7 +1818,7 @@ cmodel_t *CM_SpriteModel (char *name, byte *buffer)
out = &map_cmodels[max_models];
out->numframes = phdr->numframes;
strlcpy(out->name, modname, sizeof(out->name));
strncpy(out->name, modname, sizeof(out->name));
out->mins[0] = out->mins[1] = -phdr->width / 2;
out->maxs[0] = out->maxs[1] = phdr->width / 2;

View File

@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MAXPRINTMSG 4096
jmp_buf abortframe;
int com_argc;
char *com_argv[MAX_NUM_ARGVS+1];
@ -289,61 +287,4 @@ void Com_PageInMemory (byte *buffer, int size)
for (i = size - 1; i > 0; i -= 4096)
paged_total += buffer[i];
}
#ifndef HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
size_t dlen;
// Find the end of dst and adjust bytes left but don't go past end
while (n-- != 0 && *d != '\0') d++;
dlen = d - dst;
n = siz - dlen;
if (n == 0) return(dlen + strlen(s));
while (*s != '\0')
{
if (n != 1)
{
*d++ = *s;
n--;
}
s++;
}
*d = '\0';
return(dlen + (s - src)); //count does not include NUL
}
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
// Copy as many bytes as will fit
if (n != 0 && --n != 0)
{
do
{
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
// Not enough room in dst, add NUL and traverse rest of src
if (n == 0)
{
if (siz != 0) *d = '\0'; //NUL-terminate dst
while (*s++);
}
return(s - src - 1); //count does not include NUL
}
#endif
}

View File

@ -422,7 +422,7 @@ void M_Main_Draw (void)
re->DrawPic( xoffset, ystart + i * 40 + 13, names[i] );
}
strcpy( litname, names[m_main_cursor] );
strlcat( litname, "_sel", 80 );
strncat( litname, "_sel", 80 );
re->DrawPic( xoffset, ystart + m_main_cursor * 40 + 13, litname );
M_DrawCursor( xoffset - 25, ystart + m_main_cursor * 40 + 11, (int)(cls.realtime * 8.0f) % NUM_CURSOR_FRAMES );
@ -2140,7 +2140,7 @@ bool Menu_CreateMapsList( void )
fp = FS_Open(t->filenames[i], "rb");
FS_FileBase( t->filenames[i], mapname );
strlcpy(message, "No Title", 64);
strncpy(message, "No Title", 64);
if(fp)
{
@ -2189,7 +2189,7 @@ bool Menu_CreateMapsList( void )
if (!strcmp(keyname, "message") && !have_title)
{
// get the message contents
strlcpy(message, com_token, sizeof(message));
strncpy(message, com_token, sizeof(message));
have_title = true;//get title once only
}
else if(!strcmp(keyname, "classname"))
@ -3017,7 +3017,7 @@ static bool IconOfSkinExists( char *skin, char **pcxfiles, int npcxfiles )
strcpy( scratch, skin );
*strrchr( scratch, '.' ) = 0;
strlcat( scratch, "_i.pcx", 1024 );
strncat( scratch, "_i.pcx", 1024 );
for ( i = 0; i < npcxfiles; i++ )
{
@ -3066,13 +3066,13 @@ static bool PlayerConfig_ScanDirectories( void )
// verify the existence of tris.md2
strcpy( scratch, dirnames[i] );
strlcat( scratch, "/tris.md2", 1024 );
strncat( scratch, "/tris.md2", 1024 );
if(!FS_FileExists( scratch )) continue;
// verify the existence of at least one pcx skin
strcpy( scratch, dirnames[i] );
strlcat( scratch, "/*.pcx", 1024 );
strncat( scratch, "/*.pcx", 1024 );
search2 = FS_Search( scratch );
@ -3349,7 +3349,6 @@ void PlayerConfig_MenuDraw( void )
if ( s_pmi[s_player_model_box.curvalue].skindisplaynames )
{
static int yaw;
int maxframe = 29;
entity_t entity;
memset( &entity, 0, sizeof( entity ) );

View File

@ -38,8 +38,8 @@ static void SpinControl_DoSlide( menulist_s *s, int dir );
#define RCOLUMN_OFFSET 16
#define LCOLUMN_OFFSET -16
extern renderer_exp_t *re;
extern viddef_t viddef;
extern render_exp_t *re;
extern viddef_t viddef;
#define VID_WIDTH viddef.width
#define VID_HEIGHT viddef.height

View File

@ -35,8 +35,8 @@ extern viddef_t viddef; // global video state
// Video module initialisation etc
void VID_Init (void);
void VID_InitRenderer(void);
void VID_FreeRenderer(void);
void VID_InitRender(void);
void VID_FreeRender(void);
void VID_CheckChanges(void);
void VID_MenuInit( void );

View File

@ -53,8 +53,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# 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 /subsystem:windows /machine:I386
# ADD LINK32 winmm.lib user32.lib msvcrt.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib"
# 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 /subsystem:windows /machine:I386 /opt:nowin98
# ADD LINK32 winmm.lib user32.lib msvcrt.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# SUBTRACT LINK32 /debug /nodefaultlib
# Begin Custom Build
TargetDir=\XASH3D\src_main\!source\temp\engine\!release

View File

@ -27,8 +27,8 @@
#include "cvar.h"
#include "console.h"
extern stdinout_api_t std;
extern platform_exp_t *pi;
extern stdlib_api_t std;
extern common_exp_t *Com;
extern byte *zonepool;
typedef enum
@ -95,39 +95,39 @@ memory manager
#define Z_Free(data) Mem_Free(data)
//malloc-free
#define Mem_Alloc(pool,size) pi->Mem.Alloc(pool, size, __FILE__, __LINE__)
#define Mem_Free(mem) pi->Mem.Free(mem, __FILE__, __LINE__)
#define Mem_Alloc(pool,size) Com->Mem.Alloc(pool, size, __FILE__, __LINE__)
#define Mem_Free(mem) Com->Mem.Free(mem, __FILE__, __LINE__)
//Hunk_AllocName
#define Mem_AllocPool(name) pi->Mem.AllocPool(name, __FILE__, __LINE__)
#define Mem_FreePool(pool) pi->Mem.FreePool(pool, __FILE__, __LINE__)
#define Mem_EmptyPool(pool) pi->Mem.EmptyPool(pool, __FILE__, __LINE__)
#define Mem_AllocPool(name) Com->Mem.AllocPool(name, __FILE__, __LINE__)
#define Mem_FreePool(pool) Com->Mem.FreePool(pool, __FILE__, __LINE__)
#define Mem_EmptyPool(pool) Com->Mem.EmptyPool(pool, __FILE__, __LINE__)
#define Mem_Copy(dest, src, size) pi->Mem.Copy(dest, src, size, __FILE__, __LINE__)
#define Mem_Copy(dest, src, size) Com->Mem.Copy(dest, src, size, __FILE__, __LINE__)
/*
===========================================
filesystem manager
===========================================
*/
#define FS_LoadFile(name, size) pi->Fs.LoadFile(name, size)
#define FS_LoadImage(name, data, size) pi->Fs.LoadImage(name, data, size)
#define FS_Search(path) pi->Fs.Search( path, true )
#define FS_WriteFile(name, data, size) pi->Fs.WriteFile(name, data, size )
#define FS_Open( path, mode ) pi->Fs.Open( path, mode )
#define FS_Read( file, buffer, size ) pi->Fs.Read( file, buffer, size )
#define FS_Write( file, buffer, size ) pi->Fs.Write( file, buffer, size )
#define FS_StripExtension( path ) pi->Fs.StripExtension( path )
#define FS_DefaultExtension( path, ext ) pi->Fs.DefaultExtension( path, ext )
#define FS_FileExtension( ext ) pi->Fs.FileExtension( ext )
#define FS_FileExists( file ) pi->Fs.FileExists( file )
#define FS_Close( file ) pi->Fs.Close( file )
#define FS_FileBase( x, y ) pi->Fs.FileBase( x, y )
#define FS_Find( x ) pi->Fs.Search( x, false )
#define FS_Printf pi->Fs.Printf
#define FS_Seek pi->Fs.Seek
#define FS_Tell pi->Fs.Tell
#define FS_Gets pi->Fs.Gets
#define FS_LoadFile(name, size) Com->Fs.LoadFile(name, size)
#define FS_LoadImage(name, data, size) Com->Fs.LoadImage(name, data, size)
#define FS_Search(path) Com->Fs.Search( path, true )
#define FS_WriteFile(name, data, size) Com->Fs.WriteFile(name, data, size )
#define FS_Open( path, mode ) Com->Fs.Open( path, mode )
#define FS_Read( file, buffer, size ) Com->Fs.Read( file, buffer, size )
#define FS_Write( file, buffer, size ) Com->Fs.Write( file, buffer, size )
#define FS_StripExtension( path ) Com->Fs.StripExtension( path )
#define FS_DefaultExtension( path, ext ) Com->Fs.DefaultExtension( path, ext )
#define FS_FileExtension( ext ) Com->Fs.FileExtension( ext )
#define FS_FileExists( file ) Com->Fs.FileExists( file )
#define FS_Close( file ) Com->Fs.Close( file )
#define FS_FileBase( x, y ) Com->Fs.FileBase( x, y )
#define FS_Find( x ) Com->Fs.Search( x, false )
#define FS_Printf Com->Fs.Printf
#define FS_Seek Com->Fs.Seek
#define FS_Tell Com->Fs.Tell
#define FS_Gets Com->Fs.Gets
char *FS_Gamedir( void );
/*
@ -135,19 +135,19 @@ char *FS_Gamedir( void );
scriptsystem manager
===========================================
*/
#define COM_Parse(data) pi->Script.ParseToken(data)
#define COM_Token pi->Script.Token
#define COM_Parse(data) Com->Script.ParseToken(data)
#define COM_Token Com->Script.Token
/*
===========================================
infostring manager
===========================================
*/
#define Info_Print(x) pi->Info.Print
#define Info_Validate(x) pi->Info.Validate(x)
#define Info_RemoveKey(x, y) pi->Info.RemoveKey(x,y)
#define Info_ValueForKey(x,y) pi->Info.ValueForKey(x,y)
#define Info_SetValueForKey(x,y,z) pi->Info.SetValueForKey(x,y,z)
#define Info_Print(x) Com->Info.Print
#define Info_Validate(x) Com->Info.Validate(x)
#define Info_RemoveKey(x, y) Com->Info.RemoveKey(x,y)
#define Info_ValueForKey(x,y) Com->Info.ValueForKey(x,y)
#define Info_SetValueForKey(x,y,z) Com->Info.SetValueForKey(x,y,z)
/*
===========================================
@ -155,7 +155,7 @@ System Timer
===========================================
*/
double Sys_DoubleTime( void );
#define GI pi->GameInfo()
#define GI Com->GameInfo()
/*
===========================================

View File

@ -1,78 +0,0 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: engine - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\Temp\RSP159C.tmp" with contents
[
winmm.lib user32.lib msvcrt.lib /nologo /subsystem:windows /dll /incremental:yes /pdb:"..\temp\engine\!debug/engine.pdb" /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"..\temp\engine\!debug/engine.dll" /implib:"..\temp\engine\!debug/engine.lib" /pdbtype:sept
"\XASH3D\src_main\!source\temp\engine\!debug\cl_cin.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_ents.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_fx.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_input.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_inv.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_main.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_newfx.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_parse.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_pred.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_scrn.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_tent.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cl_view.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cmd.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cmodel.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\common.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\console.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\crc.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\cvar.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\host.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\in_win.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\keys.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\md4.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\menu.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\net_chan.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\net_msg.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\net_wins.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\pmove.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\qmenu.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\snd_dma.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\snd_mem.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\snd_mix.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\snd_win.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_ccmds.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_ents.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_game.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_init.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_main.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_phys.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_save.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_send.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_spawn.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_studio.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_user.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\sv_world.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\system.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\vid_dll.obj"
"\XASH3D\src_main\!source\temp\engine\!debug\vid_menu.obj"
]
Creating command line "link.exe @C:\Temp\RSP159C.tmp"
Creating temporary file "C:\Temp\RSP159D.bat" with contents
[
@echo off
copy \XASH3D\src_main\!source\temp\engine\!debug\engine.dll "D:\Xash3D\bin\engine.dll"
]
Creating command line "C:\Temp\RSP159D.bat"
Linking...
<h3>Output Window</h3>
Performing Custom Build Step on \XASH3D\src_main\!source\temp\engine\!debug\engine.dll
‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
<h3>Results</h3>
engine.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

View File

@ -8,9 +8,9 @@
#include <dsound.h>
#include "engine.h"
platform_exp_t *pi; // fundamental callbacks
common_exp_t *Com; // fundamental callbacks
host_parm_t host; // host parms
stdinout_api_t std;
stdlib_api_t std;
byte *zonepool;
int ActiveApp;
@ -21,44 +21,51 @@ void Key_Init (void);
void SCR_EndLoadingPlaque (void);
HINSTANCE global_hInstance;
dll_info_t platform_dll = { "platform.dll", NULL, "CreateAPI", NULL, NULL, true, PLATFORM_API_VERSION, sizeof(platform_exp_t) };
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, COMMON_API_VERSION, sizeof(common_exp_t) };
cvar_t *timescale;
cvar_t *fixedtime;
cvar_t *showtrace;
void Host_InitPlatform( char *funcname, int argc, char **argv )
void Host_InitCommon( char *funcname, int argc, char **argv )
{
static stdinout_api_t pistd;
platform_t CreatePlat;
static stdlib_api_t io;
common_t CreateCom;
//make callbacks
pistd.printf = Msg;
pistd.dprintf = MsgDev;
pistd.wprintf = MsgWarn;
pistd.error = Sys_Error;
Sys_LoadLibrary( &platform_dll );
io.printf = Msg;
io.dprintf = MsgDev;
io.wprintf = MsgWarn;
io.error = Sys_Error;
io.exit = std.exit;
io.print = Con_Print;
io.input = std.input;
io.sleep = std.sleep;
CreatePlat = (void *)platform_dll.main;
pi = CreatePlat( &pistd );
io.LoadLibrary = Sys_LoadLibrary;
io.FreeLibrary = Sys_FreeLibrary;
io.GetProcAddress = std.GetProcAddress;
// initialize our platform :)
pi->Init( argc, argv );
Sys_LoadLibrary( &common_dll );
//TODO: init basedir here
pi->LoadGameInfo("gameinfo.txt");
CreateCom = (void *)common_dll.main;
Com = CreateCom( &io );
Com->Init( argc, argv );
// TODO: init basedir here
Com->LoadGameInfo("gameinfo.txt");
zonepool = Mem_AllocPool("Zone Engine");
}
void Host_FreePlatform( void )
void Host_FreeCommon( void )
{
if(platform_dll.link)
if(common_dll.link)
{
Mem_FreePool( &zonepool );
pi->Shutdown();
Sys_FreeLibrary( &platform_dll );
Com->Shutdown();
}
Sys_FreeLibrary( &common_dll );
}
/*
@ -91,7 +98,7 @@ void Host_Init (char *funcname, int argc, char **argv)
else host.type = HOST_OFFLINE; // launcher can loading engine for some reasons
COM_InitArgv (argc, argv); // init host.debug & host.developer here
Host_InitPlatform( funcname, argc, argv );
Host_InitCommon( funcname, argc, argv );
MsgDev(D_INFO, "------- Loading bin/engine.dll [%g] -------\n", ENGINE_VERSION );
@ -251,7 +258,7 @@ void Host_Main( void )
// if at a full screen console, don't update unless needed
if (Minimized || (dedicated && dedicated->value) )
{
Sleep (1);
Sys_Sleep (1);
}
while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
@ -289,7 +296,7 @@ void Host_Free (void)
SV_Shutdown ("Server shutdown\n", false);
CL_Shutdown ();
}
Host_FreePlatform ();
Host_FreeCommon ();
}
/*
@ -318,7 +325,7 @@ void Host_Error( const char *error, ... )
Sys_Error ("%s", hosterror1);
}
recursive = true;
strlcpy(hosterror2, hosterror1, sizeof(hosterror2));
strncpy(hosterror2, hosterror1, sizeof(hosterror2));
SV_Shutdown (va("Server crashed: %s", hosterror1), false);
CL_Drop(); // drop clients

View File

@ -53,7 +53,7 @@ size_t COM_PackString( byte *buffer, int pos, char *string )
if(strsize > MAX_QPATH) strsize = MAX_QPATH; //critical stuff
strsize++; // get space for terminator
strlcpy(buffer + pos, string, strsize );
strncpy(buffer + pos, string, strsize );
return pos + strsize;
}
@ -67,7 +67,7 @@ size_t COM_UnpackString( byte *buffer, int pos, char *string )
do { in++, strsize++; } while(*in != '\0' && in != NULL );
strlcpy( string, in - (strsize - 1), strsize );
strncpy( string, in - (strsize - 1), strsize );
return pos + strsize;
}
@ -181,7 +181,7 @@ void Sav_LoadComment( lump_t *l )
if (l->filelen % sizeof(*in)) Host_Error("Sav_LoadComment: funny lump size\n" );
size = l->filelen / sizeof(*in);
strlcpy(svs.comment, in, size );
strncpy(svs.comment, in, size );
}
void Sav_LoadCvars( lump_t *l )
@ -327,7 +327,7 @@ bool Menu_ReadComment( char *comment, int savenum )
if(!savfile)
{
strlcpy( comment, "<EMPTY>", 32 );
strncpy( comment, "<EMPTY>", 32 );
return false;
}
@ -337,13 +337,13 @@ bool Menu_ReadComment( char *comment, int savenum )
if(id != IDSAVEHEADER || i != SAVE_VERSION)
{
strlcpy( comment, "<CORRUPTED>", 32 );
strncpy( comment, "<CORRUPTED>", 32 );
return false;
}
sav_base = (byte *)header;
Sav_LoadComment(&header->lumps[LUMP_COMMENTS]);
strlcpy( comment, svs.comment, 32 );
strncpy( comment, svs.comment, 32 );
return true;
}

View File

@ -325,12 +325,7 @@ void FreeSound (void)
pDS->lpVtbl->Release( pDS );
}
if ( hInstDS )
{
MsgDev(D_INFO, "...freeing DSOUND.DLL\n" );
FreeLibrary( hInstDS );
hInstDS = NULL;
}
Sys_FreeLibrary( &dsound_dll );
pDS = NULL;
pDSBuf = NULL;

View File

@ -49,7 +49,7 @@ void Sys_Error( const char *error, ... )
double Sys_DoubleTime( void )
{
// precision timer
host.realtime = pi->DoubleTime();
host.realtime = Com->DoubleTime();
return host.realtime;
}
@ -112,7 +112,7 @@ DllMain
==================
*/
launcher_exp_t DLLEXPORT *CreateAPI( stdinout_api_t *input )
launcher_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input )
{
static launcher_exp_t Host;

View File

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include ".\client\client.h"
// Structure containing functions exported from refresh DLL
renderer_exp_t *re;
render_exp_t *re;
extern HWND cl_hwnd;
extern bool ActiveApp, Minimized;
@ -46,7 +46,7 @@ cvar_t *vid_fullscreen;
// Global variables used internally by this module
viddef_t viddef; // global video state; used by other modules
dll_info_t renderer_dll = { "renderer.dll", NULL, "CreateAPI", NULL, NULL, true, RENDERER_API_VERSION, sizeof(renderer_exp_t) };
dll_info_t render_dll = { "render.dll", NULL, "CreateAPI", NULL, NULL, true, RENDER_API_VERSION, sizeof(render_exp_t) };
bool reflib_active = 0;
HWND cl_hwnd; // Main window handle for life of program
@ -63,11 +63,11 @@ DLL GLUE
==========================================================================
*/
stdinout_api_t VID_GetStdio( void )
stdlib_api_t VID_GetStdio( void )
{
static stdinout_api_t io;
static stdlib_api_t io;
io.api_size = sizeof(stdinout_api_t);
io.api_size = sizeof(stdlib_api_t);
io.print = Sys_Print;
io.printf = Msg;
@ -76,8 +76,10 @@ stdinout_api_t VID_GetStdio( void )
io.exit = Sys_Quit;
io.input = Sys_ConsoleInput;
io.sleep = Sys_Sleep;
io.LoadLibrary = Sys_LoadLibrary;
io.FreeLibrary = Sys_FreeLibrary;
io.GetProcAddress = std.GetProcAddress;
return io;
}
@ -442,7 +444,7 @@ void VID_NewWindow ( int width, int height)
void VID_FreeReflib (void)
{
Sys_FreeLibrary( &renderer_dll );
Sys_FreeLibrary( &render_dll );
memset (&re, 0, sizeof(re));
reflib_active = false;
@ -460,21 +462,21 @@ char *FS_Title( void )
/*
==============
VID_InitRenderer
VID_InitRender
==============
*/
void VID_InitRenderer( void )
void VID_InitRender( void )
{
static renderer_imp_t ri;
renderer_t CreateRender;
static render_imp_t ri;
render_t CreateRender;
VID_FreeRenderer();
VID_FreeRender();
ri.Fs = pi->Fs;
ri.VFs = pi->VFs;
ri.Mem = pi->Mem;
ri.Script = pi->Script;
ri.Compile = pi->Compile;
ri.Fs = Com->Fs;
ri.VFs = Com->VFs;
ri.Mem = Com->Mem;
ri.Script = Com->Script;
ri.Compile = Com->Compile;
ri.Stdio = VID_GetStdio();
ri.Cmd_AddCommand = Cmd_AddCommand;
@ -495,12 +497,12 @@ void VID_InitRenderer( void )
// studio callbacks
ri.StudioEvent = CL_StudioEvent;
Sys_LoadLibrary( &renderer_dll );
Sys_LoadLibrary( &render_dll );
CreateRender = (void *)renderer_dll.main;
CreateRender = (void *)render_dll.main;
re = CreateRender( &ri );
if(!re->Init( global_hInstance, MainWndProc )) Sys_Error("can't init renderer.dll\n");
if(!re->Init( global_hInstance, MainWndProc )) Sys_Error("can't init render.dll\n");
reflib_active = true;
}
@ -531,7 +533,7 @@ void VID_CheckChanges (void)
cl.refresh_prepped = false;
cls.disable_screen = true;
VID_InitRenderer();
VID_InitRender();
cls.disable_screen = false;
}
@ -570,10 +572,10 @@ void VID_Init (void)
/*
============
VID_FreeRenderer
VID_FreeRender
============
*/
void VID_FreeRenderer (void)
void VID_FreeRender (void)
{
if ( reflib_active )
{

View File

@ -8,18 +8,17 @@
!include <win32.mak>
MAINTARGET = bsplib
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
RES = $(MAINTARGET).rc
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj bsplib.res
$(link) $(OBJS) $(LLDLIBS) bsplib.res /out:"bsplib.exe" /subsystem:windows /opt:nowin98
$(link) $(OBJS) bsplib.res /out:"bsplib.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul
@copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

View File

@ -45,9 +45,34 @@ typedef struct
int status;
int windowWidth, windowHeight;
WNDPROC SysInputLineWndProc;
}WinConData;
} WinConData;
static WinConData s_wcd;
// gdi32 export table
static HDC (_stdcall *pGetDC)(HWND);
static int (_stdcall *pReleaseDC)(HWND,HDC);
static bool (_stdcall *pDeleteObject)(HGDIOBJ);
static int (_stdcall *pGetDeviceCaps)(HDC,int);
static HBRUSH(_stdcall *pCreateSolidBrush)(COLORREF);
static COLORREF (_stdcall *pSetBkColor)(HDC,COLORREF);
static COLORREF (_stdcall *pSetTextColor)(HDC,COLORREF);
static HFONT (_stdcall *pCreateFont)(int,int,int,int,int,dword,dword,dword,dword,dword,dword,dword,dword,LPCSTR);
static dllfunc_t gdi32_funcs[] =
{
{"GetDC", (void **) &pGetDC },
{"ReleaseDC", (void **) &pReleaseDC },
{"SetBkColor", (void **) &pSetBkColor },
{"CreateFontA", (void **) &pCreateFont },
{"DeleteObject", (void **) &pDeleteObject },
{"SetTextColor", (void **) &pSetTextColor },
{"GetDeviceCaps", (void **) &pGetDeviceCaps },
{"CreateSolidBrush", (void **) &pCreateSolidBrush },
{ NULL, NULL }
};
dll_info_t gdi32_dll = { /*"gdi32.dll"*/NULL, gdi32_funcs, NULL, NULL, NULL, true, 0, 0 };
void Sys_ShowConsoleW( bool show )
{
if ( show == s_wcd.status ) return;
@ -342,8 +367,9 @@ void Sys_CreateConsoleW( const char *caption )
wc.lpszMenuName = 0;
wc.lpszClassName = SYSCONSOLE;
if (!RegisterClass (&wc) ) return;
Sys_LoadLibrary( &gdi32_dll );
if (!RegisterClass (&wc)) return;
if(about_mode)
{
CONSTYLE &= ~WS_VSCROLL;
@ -460,6 +486,7 @@ void Sys_DestroyConsoleW( void )
}
UnregisterClass (SYSCONSOLE, base_hInstance);
Sys_FreeLibrary( &gdi32_dll );
}
/*

View File

@ -8,17 +8,16 @@
!include <win32.mak>
MAINTARGET = credits
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj
$(link) $(OBJS) $(LLDLIBS) /out:"credits.exe" /subsystem:windows
$(link) $(OBJS) /out:"credits.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul
@copy $(MAINTARGET).exe D:\Xash3D\$(MAINTARGET).exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

View File

@ -8,18 +8,17 @@
!include <win32.mak>
MAINTARGET = xash
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
RES = $(MAINTARGET).rc
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj xash.res
$(link) $(OBJS) $(LLDLIBS) xash.res /out:"xash.exe" /subsystem:windows
$(link) $(OBJS) xash.res /out:"xash.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul
@copy $(MAINTARGET).exe D:\Xash3D\#xash.exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

View File

@ -8,18 +8,17 @@
!include <win32.mak>
MAINTARGET = editor
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
RES = $(MAINTARGET).rc
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj editor.res
$(link) $(OBJS) $(LLDLIBS) editor.res /out:"editor.exe" /subsystem:windows
$(link) $(OBJS) editor.res /out:"editor.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul
@copy $(MAINTARGET).exe D:\Xash3D\$(MAINTARGET).exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

View File

@ -14,20 +14,33 @@
#include <winreg.h>
#include <stdio.h>
#pragma comment(lib, "advapi32")
#pragma comment(lib, "user32")
#pragma comment(lib, "msvcrt")
#pragma comment(linker,"/MERGE:.rdata=.text")
#pragma comment(linker,"/FILEALIGN:512 /SECTION:.text, EWRX /IGNORE:4078")
#define Run32( prog ) return CreateMain32()( #prog, lpCmdLine )
#define Run32( prog ) return CreateMain32()( #prog )
//console format
typedef int (*winmain_t)( char *funcname, LPSTR lpCmdLine );
typedef int (*winmain_t)( char *funcname );
char szSearch[ 5 ][ 1024 ];
char szFsPath[ 4096 ];
HINSTANCE hmain;
void GetError( const char *errorstring )
{
HINSTANCE user32_dll = LoadLibrary( "user32.dll" );
static int (*pMessageBoxA)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
if(!errorstring) exit( 0 );
if( user32_dll ) pMessageBoxA = (void *)GetProcAddress( user32_dll, "MessageBoxA" );
if(pMessageBoxA) pMessageBoxA( 0, errorstring, "Error", MB_OK );
if( user32_dll ) FreeLibrary( user32_dll ); // no need anymore...
exit( 1 );
}
BOOL GetBin( void )
{
//grab direct path?
@ -45,17 +58,37 @@ BOOL GetEnv( void )
BOOL GetReg( void )
{
HINSTANCE advapi32_dll = LoadLibrary( "advapi32.dll" );
static long(_stdcall *pRegOpenKeyEx)(HKEY,LPCSTR,DWORD,REGSAM,PHKEY);
static long(_stdcall *pRegQueryValueEx)(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
static long(_stdcall *pRegCloseKey)(HKEY);
DWORD dwBufLen = 4096; // max env length
HKEY hKey;
DWORD dwBufLen = 4096; //max env length
long lRet;
lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, KEY_READ, &hKey);
if(lRet != ERROR_SUCCESS) return FALSE;
lRet = RegQueryValueEx( hKey, "Xash3D", NULL, NULL, (byte *)szFsPath, &dwBufLen);
if(lRet != ERROR_SUCCESS) return FALSE;
RegCloseKey( hKey );
if(advapi32_dll)
{
pRegCloseKey = (void *)GetProcAddress( advapi32_dll, "RegCloseKey" );
pRegOpenKeyEx = (void *)GetProcAddress( advapi32_dll, "RegOpenKeyExA" );
pRegQueryValueEx = (void *)GetProcAddress( advapi32_dll, "RegQueryValueExA" );
}
else goto failure;
if(pRegCloseKey && pRegOpenKeyEx && pRegQueryValueEx)
{
lRet = pRegOpenKeyEx( HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\Session Manager\\Environment", 0, KEY_READ, &hKey);
if(lRet != ERROR_SUCCESS) goto failure;
lRet = pRegQueryValueEx( hKey, "Xash3D", NULL, NULL, (byte *)szFsPath, &dwBufLen);
if(lRet != ERROR_SUCCESS) goto failure;
pRegCloseKey( hKey );
}
else goto failure;
return TRUE;
failure:
if( advapi32_dll ) FreeLibrary( advapi32_dll ); //don't forget freeing
return FALSE;
}
void GetLibrary ( void )
@ -91,24 +124,18 @@ void GetLibrary ( void )
winmain_t CreateMain32( void )
{
winmain_t main;
winmain_t main;
GetLibrary();
if (hmain)
{
main = (winmain_t)GetProcAddress( hmain, "CreateAPI" );
if(!main)
{
MessageBox( 0, "Unable to load the launcher.dll", "Error", MB_OK );
exit( 1 );
}
if(!main) GetError("Unable to load the launcher.dll" );
return main;
}
MessageBox( 0, "Unable to load the launcher.dll", "Error", MB_OK );
exit( 1 );
GetError("Unable to load the launcher.dll" );
return 0; //make compiller happy
}

View File

@ -4,7 +4,6 @@
//=======================================================================
#include "launcher.h"
#include <math.h>
static int app_name;
bool hooked_out = false;
@ -16,7 +15,7 @@ char caption[64];
const char *show_credits = "\n\n\n\n\tCopyright XashXT Group 2007 ©\n\t All Rights Reserved\n\n\t Visit www.xash.ru\n";
dll_info_t platform_dll = { "platform.dll", NULL, "CreateAPI", NULL, NULL, true, PLATFORM_API_VERSION, sizeof(platform_exp_t) };
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, COMMON_API_VERSION, sizeof(common_exp_t) };
dll_info_t engine_dll = { "engine.dll", NULL, "CreateAPI", NULL, NULL, true, LAUNCHER_API_VERSION, sizeof(launcher_exp_t) };
dll_info_t editor_dll = { "editor.dll", NULL, "CreateAPI", NULL, NULL, true, LAUNCHER_API_VERSION, sizeof(launcher_exp_t) };
dll_info_t *linked_dll; // generic hinstance
@ -35,12 +34,12 @@ typedef enum
CREDITS, // misc
};
int com_argc;
char *com_argv[MAX_NUM_ARGVS];
char progname[32]; // limit of funcname
platform_exp_t *pi; // callback to utilities
static double start, end;
byte *mempool; // generic mempoolptr
int com_argc;
char *com_argv[MAX_NUM_ARGVS];
char progname[32]; // limit of funcname
common_exp_t *Com; // callback to utilities
static double start, end;
byte *mempool; // generic mempoolptr
/*
@ -98,28 +97,28 @@ void LookupInstance( const char *funcname )
else if(!strcmp(progname, "bsplib"))
{
app_name = BSPLIB;
linked_dll = &platform_dll; // pointer to platform.dll info
linked_dll = &common_dll; // pointer to common.dll info
strcpy(log_path, "bsplib.log" ); // xash3d root directory
strcpy(caption, "Xash3D BSP Compiler");
}
else if(!strcmp(progname, "qcclib"))
{
app_name = QCCLIB;
linked_dll = &platform_dll; // pointer to platform.dll info
linked_dll = &common_dll; // pointer to common.dll info
sprintf(log_path, "%s/compile.log", sys_rootdir ); // same as .exe file
strcpy(caption, "Xash3D QuakeC Compiler");
}
else if(!strcmp(progname, "sprite"))
{
app_name = SPRITE;
linked_dll = &platform_dll; // pointer to platform.dll info
linked_dll = &common_dll; // pointer to common.dll info
sprintf(log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file
strcpy(caption, "Xash3D Sprite Compiler");
}
else if(!strcmp(progname, "studio"))
{
app_name = STUDIO;
linked_dll = &platform_dll; // pointer to platform.dll info
linked_dll = &common_dll; // pointer to common.dll info
sprintf(log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file
strcpy(caption, "Xash3D Studio Models Compiler");
}
@ -133,9 +132,9 @@ void LookupInstance( const char *funcname )
else app_name = DEFAULT;
}
stdinout_api_t *Get_StdAPI( void )
stdlib_api_t *Get_StdAPI( void )
{
static stdinout_api_t std;
static stdlib_api_t std;
// setup sysfuncs
std.printf = Msg;
@ -149,24 +148,25 @@ stdinout_api_t *Get_StdAPI( void )
std.LoadLibrary = Sys_LoadLibrary;
std.FreeLibrary = Sys_FreeLibrary;
std.GetProcAddress = Sys_GetProcAddress;
return &std;
}
/*
==================
PlatformInit
CommonInit
platform.dll needs for some setup operations
so do it manually
==================
*/
void PlatformInit ( char *funcname, int argc, char **argv )
void CommonInit ( char *funcname, int argc, char **argv )
{
byte bspflags = 0, qccflags = 0;
char source[64], gamedir[64];
pi->Init( argc, argv );
Com->Init( argc, argv );
switch(app_name)
{
@ -180,7 +180,7 @@ void PlatformInit ( char *funcname, int argc, char **argv )
if(CheckParm("-full")) bspflags |= BSP_FULLCOMPILE;
if(CheckParm("-onlyents")) bspflags |= BSP_ONLYENTS;
pi->Compile.PrepareBSP( gamedir, source, bspflags );
Com->Compile.PrepareBSP( gamedir, source, bspflags );
break;
case QCCLIB:
if(!GetParmFromCmdLine("+dat", source ))
@ -191,22 +191,22 @@ void PlatformInit ( char *funcname, int argc, char **argv )
if(CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_2;
if(CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_3;
pi->Compile.PrepareDAT( gamedir, source, qccflags );
Com->Compile.PrepareDAT( gamedir, source, qccflags );
break;
case SPRITE:
pi->InitRootDir(".");
start = pi->DoubleTime();
Com->InitRootDir(".");
start = Com->DoubleTime();
break;
case STUDIO:
pi->InitRootDir(".");
start = pi->DoubleTime();
Com->InitRootDir(".");
start = Com->DoubleTime();
break;
case DEFAULT:
break;
}
}
void PlatformMain ( void )
void CommonMain ( void )
{
search_t *search;
char qcfilename[64], typemod[16];
@ -217,19 +217,19 @@ void PlatformMain ( void )
switch(app_name)
{
case SPRITE:
CompileMod = pi->Compile.Sprite;
CompileMod = Com->Compile.Sprite;
strcpy(typemod, "sprites" );
break;
case STUDIO:
CompileMod = pi->Compile.Studio;
CompileMod = Com->Compile.Studio;
strcpy(typemod, "models" );
break;
case BSPLIB:
pi->Compile.BSP();
Com->Compile.BSP();
strcpy(typemod, "maps" );
break;
case QCCLIB:
pi->Compile.DAT();
Com->Compile.DAT();
strcpy(typemod, "progs" );
break;
case DEFAULT:
@ -242,7 +242,7 @@ void PlatformMain ( void )
if(!GetParmFromCmdLine("-qcfile", qcfilename ))
{
//search for all .ac files in folder
search = pi->Fs.Search("*.qc", true );
search = Com->Fs.Search("*.qc", true );
if(!search) Sys_Error("no qcfiles found in this folder!\n");
for( i = 0; i < search->numfilenames; i++ )
@ -253,16 +253,16 @@ void PlatformMain ( void )
}
else CompileMod( mempool, qcfilename, parms );
end = pi->DoubleTime();
end = Com->DoubleTime();
Msg ("%5.1f seconds elapsed\n", end - start);
if(numCompiledMods > 1) Msg("total %d %s compiled\n", numCompiledMods, typemod );
}
void PlatformShutdown ( void )
void CommonShutdown ( void )
{
Mem_Check(); //check for leaks
Mem_FreePool( &mempool );
pi->Shutdown();
Com->Shutdown();
}
@ -274,7 +274,7 @@ Find needed library, setup and run it
void CreateInstance( void )
{
// export
platform_t CreatePlat;
common_t CreateCom;
launcher_t CreateHost;
launcher_exp_t *Host;
@ -300,13 +300,13 @@ void CreateInstance( void )
case QCCLIB:
case SPRITE:
case STUDIO:
CreatePlat = (void *)linked_dll->main;
CreateCom = (void *)linked_dll->main;
// set callback
pi = CreatePlat(Get_StdAPI());
Host_Init = PlatformInit;
Host_Main = PlatformMain;
Host_Free = PlatformShutdown;
Com = CreateCom(Get_StdAPI());
Host_Init = CommonInit;
Host_Main = CommonMain;
Host_Free = CommonShutdown;
break;
case CREDITS:
Sys_Print( show_credits );
@ -374,13 +374,20 @@ void API_SetConsole( void )
}
void InitLauncher( char *funcname )
void RunLauncher( char *funcname )
{
HANDLE hStdout;
char dev_level[4];
OSVERSIONINFO vinfo;
MEMORYSTATUS lpBuffer;
char dev_level[4];
lpBuffer.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus (&lpBuffer);
// parse and copy args into local array
ParseCommandLine(GetCommandLine());
API_Reset();// fill stdinout api
API_Reset();// fill stdlib api
// get current hInstance first
base_hInstance = (HINSTANCE)GetModuleHandle( NULL );
@ -421,16 +428,9 @@ Base Entry Point
=================
*/
DLLEXPORT int CreateAPI( char *funcname, LPSTR lpCmdLine )
DLLEXPORT int CreateAPI( char *funcname )
{
MEMORYSTATUS lpBuffer;
lpBuffer.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus (&lpBuffer);
// parse and copy args into local array
ParseCommandLine( lpCmdLine );
InitLauncher( funcname );
RunLauncher( funcname );
return 0;
}

View File

@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LAUNCHER_EXPORTS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -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 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /pdb:none /machine:I386 /opt:nowin98
# ADD LINK32 msvcrt.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
# Begin Custom Build
TargetDir=\XASH3D\src_main\!source\temp\launcher\!release
InputPath=\XASH3D\src_main\!source\temp\launcher\!release\launcher.dll
@ -79,7 +79,7 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LAUNCHER_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -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 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 msvcrt.lib user32.lib gdi32.lib advapi32.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept
# Begin Custom Build
TargetDir=\XASH3D\src_main\!source\temp\launcher\!debug
InputPath=\XASH3D\src_main\!source\temp\launcher\!debug\launcher.dll
@ -120,6 +120,10 @@ SOURCE=.\launcher.c
# End Source File
# Begin Source File
SOURCE=.\stdlib.c
# End Source File
# Begin Source File
SOURCE=.\utils.c
# End Source File
# End Group

View File

@ -29,6 +29,7 @@ void Sys_Exit( void ); // static
void Sys_Sleep( int msec);
bool Sys_LoadLibrary ( dll_info_t *dll ); // load library
bool Sys_FreeLibrary ( dll_info_t *dll ); // free library
void* Sys_GetProcAddress ( dll_info_t *dll, const char* name );
void Sys_WaitForQuit( void ); // waiting for 'ESC' or close command
// export variables
@ -88,14 +89,14 @@ __inline void NullVoidWithName( const char *caption ) {}
__inline void NullInit ( char *funcname, int argc, char **argv ) {}
//memory manager
#define Mem_Alloc(pool, size) pi->Mem.Alloc(pool, size, __FILE__, __LINE__)
#define Mem_Realloc(pool, ptr, size) pi->Mem.Realloc(pool, ptr, size, __FILE__, __LINE__)
#define Mem_Free(mem) pi->Mem.Free(mem, __FILE__, __LINE__)
#define Mem_AllocPool(name) pi->Mem.AllocPool(name, __FILE__, __LINE__)
#define Mem_FreePool(pool) pi->Mem.FreePool(pool, __FILE__, __LINE__)
#define Mem_EmptyPool(pool) pi->Mem.EmptyPool(pool, __FILE__, __LINE__)
#define Mem_Move(dest, src, size ) pi->Mem.Move (dest, src, size, __FILE__, __LINE__)
#define Mem_Copy(dest, src, size ) pi->Mem.Copy (dest, src, size, __FILE__, __LINE__)
#define Mem_Check() pi->Mem.CheckSentinelsGlobal(__FILE__, __LINE__)
#define Mem_Alloc(pool, size) Com->Mem.Alloc(pool, size, __FILE__, __LINE__)
#define Mem_Realloc(pool, ptr, size) Com->Mem.Realloc(pool, ptr, size, __FILE__, __LINE__)
#define Mem_Free(mem) Com->Mem.Free(mem, __FILE__, __LINE__)
#define Mem_AllocPool(name) Com->Mem.AllocPool(name, __FILE__, __LINE__)
#define Mem_FreePool(pool) Com->Mem.FreePool(pool, __FILE__, __LINE__)
#define Mem_EmptyPool(pool) Com->Mem.EmptyPool(pool, __FILE__, __LINE__)
#define Mem_Move(dest, src, size ) Com->Mem.Move (dest, src, size, __FILE__, __LINE__)
#define Mem_Copy(dest, src, size ) Com->Mem.Copy (dest, src, size, __FILE__, __LINE__)
#define Mem_Check() Com->Mem.CheckSentinelsGlobal(__FILE__, __LINE__)
#endif//LAUNCHER_H

View File

@ -8,18 +8,17 @@
!include <win32.mak>
MAINTARGET = qcclib
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
RES = $(MAINTARGET).rc
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj qcclib.res
$(link) $(OBJS) $(LLDLIBS) qcclib.res /out:"qcclib.exe" /subsystem:windows
$(link) $(OBJS) qcclib.res /out:"qcclib.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul
@copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

View File

@ -8,17 +8,16 @@
!include <win32.mak>
MAINTARGET = spritegen
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj
$(link) $(OBJS) $(LLDLIBS) /out:"spritegen.exe" /subsystem:windows
$(link) $(OBJS) /out:"spritegen.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul
@copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

75
launcher/stdlib.c Normal file
View File

@ -0,0 +1,75 @@
//=======================================================================
// Copyright XashXT Group 2007 ©
// stdlib.c - std lib portable utils
//=======================================================================
#include "launcher.h"
char *strupper(char *start)
{
char *in;
in = start;
while (*in)
{
*in = toupper(*in);
in++;
}
return start;
}
#ifndef HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
size_t dlen;
// Find the end of dst and adjust bytes left but don't go past end
while (n-- != 0 && *d != '\0') d++;
dlen = d - dst;
n = siz - dlen;
if (n == 0) return(dlen + strlen(s));
while (*s != '\0')
{
if (n != 1)
{
*d++ = *s;
n--;
}
s++;
}
*d = '\0';
return(dlen + (s - src)); //count does not include NUL
}
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz)
{
register char *d = dst;
register const char *s = src;
register size_t n = siz;
// Copy as many bytes as will fit
if (n != 0 && --n != 0)
{
do
{
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
// Not enough room in dst, add NUL and traverse rest of src
if (n == 0)
{
if (siz != 0) *d = '\0'; //NUL-terminate dst
while (*s++);
}
return(s - src - 1); //count does not include NUL
}
#endif

View File

@ -8,17 +8,16 @@
!include <win32.mak>
MAINTARGET = studiomdl
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj
$(link) $(OBJS) $(LLDLIBS) /pdb:none /nologo /out:"studiomdl.exe" /subsystem:windows
$(link) $(OBJS) /out:"studiomdl.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul
@copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

View File

@ -35,12 +35,12 @@ const char* Log_Timestamp( void )
float CalcEngineVersion( void )
{
return LAUNCHER_VERSION + PLATFORM_VERSION + RENDERER_VERSION + ENGINE_VERSION;
return LAUNCHER_VERSION + COMMON_VERSION + RENDER_VERSION + ENGINE_VERSION;
}
float CalcEditorVersion( void )
{
return LAUNCHER_VERSION + PLATFORM_VERSION + RENDERER_VERSION + EDITOR_VERSION;
return LAUNCHER_VERSION + COMMON_VERSION + RENDER_VERSION + EDITOR_VERSION;
}
/*
@ -147,7 +147,7 @@ void Sys_Exit (void)
bool Sys_LoadLibrary ( dll_info_t *dll )
{
const dllfunc_t *func;
bool native_lib;
bool native_lib = false;
char errorstring[MAX_QPATH];
// check errors
@ -162,9 +162,8 @@ bool Sys_LoadLibrary ( dll_info_t *dll )
// lookup export table
for (func = dll->fcts; func && func->name != NULL; func++)
*func->func = NULL;
native_lib = false;
}
else native_lib = true;
else if( dll->entry) native_lib = true;
if(!dll->link) dll->link = LoadLibrary ( va("bin/%s", dll->name));
if(!dll->link) dll->link = LoadLibrary ( dll->name ); // environment pathes
@ -178,7 +177,7 @@ bool Sys_LoadLibrary ( dll_info_t *dll )
if(native_lib)
{
if((dll->main = (void *)GetProcAddress(dll->link, dll->entry )) == 0)
if((dll->main = Sys_GetProcAddress(dll, dll->entry )) == 0)
{
sprintf(errorstring, "Sys_LoadLibrary: %s has no valid entry point\n", dll->name );
goto error;
@ -189,7 +188,7 @@ bool Sys_LoadLibrary ( dll_info_t *dll )
// Get the function adresses
for(func = dll->fcts; func && func->name != NULL; func++)
{
if (!(*func->func = (void *)GetProcAddress(dll->link, func->name)))
if (!(*func->func = Sys_GetProcAddress(dll, func->name)))
{
sprintf(errorstring, "Sys_LoadLibrary: %s missing or invalid function (%s)\n", dll->name, func->name );
goto error;
@ -234,11 +233,20 @@ error:
return false;
}
void* Sys_GetProcAddress ( dll_info_t *dll, const char* name )
{
if(!dll || !dll->link) // invalid desc
return NULL;
return (void *)GetProcAddress (dll->link, name);
}
bool Sys_FreeLibrary ( dll_info_t *dll )
{
if(!dll || !dll->link) // invalid desc or alredy freed
return false;
MsgDev(D_ERROR, "Sys_FreeLibrary: Unloading %s\n", dll->name );
FreeLibrary (dll->link);
dll->link = NULL;

View File

@ -8,18 +8,17 @@
!include <win32.mak>
MAINTARGET = xash
LLDLIBS = advapi32.lib user32.lib
OBJS = $(MAINTARGET).obj
RES = $(MAINTARGET).rc
default: $(MAINTARGET).exe
$(MAINTARGET).exe: $(MAINTARGET).obj xash.res
$(link) $(OBJS) $(LLDLIBS) xash.res /out:"xash.exe" /subsystem:windows
$(link) $(OBJS) xash.res /out:"xash.exe" /subsystem:windows /opt:nowin98 /nodefaultlib:"libc.lib"
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul
@copy $(MAINTARGET).exe D:\Xash3D\$(MAINTARGET).exe
@del $(MAINTARGET).exe
@echo !!! Done !!!
@echo ‘ª®¯¨à®¢ ­® ä ©«®¢: 1.
clean:
.cpp.obj:

34
launchers.bat Normal file
View File

@ -0,0 +1,34 @@
@echo off
cd launcher
cd bsplib
makefile.nmake
cd ..
cd credits
makefile.nmake
cd ..
cd dedicated
makefile.nmake
cd ..
cd editor
makefile.nmake
cd ..
cd qcclib
makefile.nmake
cd ..
cd sprite
makefile.nmake
cd ..
cd studio
makefile.nmake
cd ..
cd xash
makefile.nmake
pause

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -22,7 +22,6 @@
#define RANDOM_LONG(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN))
#define RANDOM_FLOAT(MIN,MAX) (((float)rand() / RAND_MAX) * ((MAX)-(MIN)) + (MIN))
#define bound(min,num,max) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
#define VectorSubtract(a,b,c){c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}

View File

@ -99,4 +99,6 @@ _inline char *va(const char *format, ...)
return s;
}
#define bound(min, num, max) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
#endif//BASETYPES_H

View File

@ -11,8 +11,8 @@
#include "version.h"
#define RENDERER_API_VERSION 4
#define PLATFORM_API_VERSION 2
#define RENDER_API_VERSION 4
#define COMMON_API_VERSION 2
#define LAUNCHER_API_VERSION 2
@ -86,9 +86,10 @@ typedef enum
enum dev_level
{
D_INFO = 1, // "-developer 1", shows various system messages
D_WARN, // "-developer 2", shows not critical system warnings, same as MsgWarn
D_ERROR, // "-developer 3", shows critical warnings
D_INFO = 1, // "-dev 1", shows various system messages
D_WARN, // "-dev 2", shows not critical system warnings, same as MsgWarn
D_ERROR, // "-dev 3", shows critical warnings
D_LOAD, // "-dev 4", display info about loading recources
};
// format info table
@ -188,7 +189,7 @@ typedef struct dll_info_s
void *link; // hinstance of loading library
// xash dlls entrypoint
void *(*main)( void* ); // point type (e.g. platform_t)
void *(*main)( void* ); // point type (e.g. common_t)
bool crash; // crash if dll not found
// xash dlls validator
@ -500,10 +501,10 @@ typedef struct compilers_api_s
STDIO SYSTEM INTERFACE
==============================================================================
*/
typedef struct stdinout_api_s
typedef struct stdilib_api_s
{
//interface validator
size_t api_size; // must matched with sizeof(stdinout_api_t)
size_t api_size; // must matched with sizeof(stdlib_api_t)
// base events
void (*print)( char *msg ); // basic text message
@ -518,8 +519,9 @@ typedef struct stdinout_api_s
// xash dll loading system
bool (*LoadLibrary)( dll_info_t *dll ); // load library
bool (*FreeLibrary)( dll_info_t *dll ); // free library
void*(*GetProcAddress)( dll_info_t *dll, const char* name ); // gpa
} stdinout_api_t;
} stdlib_api_t;
/*
==============================================================================
@ -559,21 +561,21 @@ typedef struct launcher_exp_s
/*
==============================================================================
PLATFORM.DLL INTERFACE
COMMON.DLL INTERFACE
==============================================================================
*/
typedef struct platform_exp_s
typedef struct common_exp_s
{
//interface validator
int apiversion; // must matched with PLATFORM_API_VERSION
size_t api_size; // must matched with sizeof(platform_api_t)
int apiversion; // must matched with COMMON_API_VERSION
size_t api_size; // must matched with sizeof(common_api_t)
// initialize
bool (*Init)( int argc, char **argv ); // init all platform systems
void (*Shutdown)( void ); // shutdown all platform systems
bool (*Init)( int argc, char **argv ); // init all common systems
void (*Shutdown)( void ); // shutdown all common systems
//platform systems
//common systems
filesystem_api_t Fs;
vfilesystem_api_t VFs;
memsystem_api_t Mem;
@ -590,24 +592,24 @@ typedef struct platform_exp_s
double (*DoubleTime)( void );
gameinfo_t (*GameInfo)( void );
} platform_exp_t;
} common_exp_t;
/*
==============================================================================
RENDERER.DLL INTERFACE
RENDER.DLL INTERFACE
==============================================================================
*/
typedef struct renderer_exp_s
typedef struct render_exp_s
{
//interface validator
int apiversion; // must matched with RENDERER_API_VERSION
size_t api_size; // must matched with sizeof(renderer_exp_t)
int apiversion; // must matched with RENDER_API_VERSION
size_t api_size; // must matched with sizeof(render_exp_t)
// initialize
bool (*Init)( void *hInstance, void *WndProc ); // init all renderer systems
void (*Shutdown)( void ); // shutdown all renderer systems
bool (*Init)( void *hInstance, void *WndProc ); // init all render systems
void (*Shutdown)( void ); // shutdown all render systems
void (*BeginRegistration) (char *map);
model_t *(*RegisterModel) (char *name);
@ -637,9 +639,9 @@ typedef struct renderer_exp_s
void (*AppActivate)( bool activate ); // ??
} renderer_exp_t;
} render_exp_t;
typedef struct renderer_imp_s
typedef struct render_imp_s
{
//shared xash systems
filesystem_api_t Fs;
@ -647,7 +649,7 @@ typedef struct renderer_imp_s
memsystem_api_t Mem;
scriptsystem_api_t Script;
compilers_api_t Compile;
stdinout_api_t Stdio;
stdlib_api_t Stdio;
void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
void (*Cmd_RemoveCommand) (char *name);
@ -671,12 +673,12 @@ typedef struct renderer_imp_s
void (*Vid_MenuInit)( void );
void (*Vid_NewWindow)( int width, int height );
} renderer_imp_t;
} render_imp_t;
// this is the only function actually exported at the linker level
typedef renderer_exp_t *(*renderer_t)( renderer_imp_t* );
typedef platform_exp_t *(*platform_t)( stdinout_api_t* );
typedef launcher_exp_t *(*launcher_t)( stdinout_api_t* );
typedef render_exp_t *(*render_t)( render_imp_t* );
typedef common_exp_t *(*common_t)( stdlib_api_t* );
typedef launcher_exp_t *(*launcher_t)( stdlib_api_t* );
#endif//REF_SYSTEM_H

View File

@ -6,8 +6,8 @@
#define VERSION_H
#define LAUNCHER_VERSION 0.6
#define PLATFORM_VERSION 1.3
#define RENDERER_VERSION 3.1
#define COMMON_VERSION 1.3
#define RENDER_VERSION 3.1
#define ENGINE_VERSION 1.8
#define EDITOR_VERSION 0.2
#define SERVER_VERSION 0.5

View File

@ -18,13 +18,13 @@ if errorlevel 1 set BUILD_ERROR=1
%MSDEV% launcher/launcher.dsp %CONFIG%"launcher - Win32 Release" %build_target%
if errorlevel 1 set BUILD_ERROR=1
%MSDEV% platform/platform.dsp %CONFIG%"platform - Win32 Release" %build_target%
%MSDEV% common/common.dsp %CONFIG%"common - Win32 Release" %build_target%
if errorlevel 1 set BUILD_ERROR=1
%MSDEV% renderer/renderer.dsp %CONFIG%"renderer - Win32 Release" %build_target%
%MSDEV% render/render.dsp %CONFIG%"render - Win32 Release" %build_target%
if errorlevel 1 set BUILD_ERROR=1
progs\qcclib.exe
vprogs\qcclib.exe
if errorlevel 1 set BUILD_ERROR=1
if "%BUILD_ERROR%"=="" goto build_ok
@ -49,9 +49,9 @@ rem //delete log files
if exist editor\editor.plg del /f /q editor\editor.plg
if exist engine\engine.plg del /f /q engine\engine.plg
if exist launcher\launcher.plg del /f /q launcher\launcher.plg
if exist platform\platform.plg del /f /q platform\platform.plg
if exist renderer\renderer.plg del /f /q renderer\renderer.plg
if exist progs\server.dat copy progs\server.dat D:\Xash3D\xash\server.dat
if exist common\common.plg del /f /q common\common.plg
if exist render\render.plg del /f /q render\render.plg
if exist vprogs\server.dat move vprogs\server.dat D:\Xash3D\xash\server.dat
echo Build succeeded!
echo Please wait. Xash is now loading

View File

@ -554,7 +554,7 @@ IMPORTED FUNCTIONS
====================================================================
*/
extern renderer_imp_t ri;
extern render_imp_t ri;
/*
====================================================================

View File

@ -24,7 +24,7 @@ void R_Clear (void);
viddef_t vid;
renderer_imp_t ri;
render_imp_t ri;
byte *r_temppool;
@ -1091,7 +1091,7 @@ int R_Init( void *hinstance, void *hWnd )
return false;
}
MsgDev(D_INFO, "------- Loading bin/renderer.dll [%g] -------\n", RENDERER_VERSION );
MsgDev(D_INFO, "------- Loading bin/render.dll [%g] -------\n", RENDER_VERSION );
ri.Vid_MenuInit();
//get our various GL strings
@ -1519,17 +1519,17 @@ CreateAPI
@@@@@@@@@@@@@@@@@@@@@
*/
renderer_exp_t DLLEXPORT *CreateAPI(renderer_imp_t *rimp )
render_exp_t DLLEXPORT *CreateAPI(render_imp_t *rimp )
{
static renderer_exp_t re;
static render_exp_t re;
// Sys_LoadLibrary can create fake instance, to check
// api version and api size, but first argument will be 0
// and always make exception, run simply check for avoid it
if(rimp) ri = *rimp;
re.apiversion = RENDERER_API_VERSION;
re.api_size = sizeof(renderer_exp_t);
re.apiversion = RENDER_API_VERSION;
re.api_size = sizeof(render_exp_t);
re.BeginRegistration = R_BeginRegistration;
re.RegisterModel = R_RegisterModel;

Some files were not shown because too many files have changed in this diff Show More