29 Aug 2007
This commit is contained in:
parent
dfd352011a
commit
8cb4ca3d6d
|
@ -1,18 +1,9 @@
|
|||
//==================================================
|
||||
// FIXME
|
||||
//==================================================
|
||||
render.dll
|
||||
|
||||
engine.dll
|
||||
1. убить остатки .md2
|
||||
|
||||
platform.dll
|
||||
1. научить rad суммировать цвета в dxt
|
||||
|
||||
server.dll
|
||||
|
||||
client.dll
|
||||
1. разработать интерфейсы взаимодействия
|
||||
1. Раз и навсегда переписать SC_ParseToken и SC_ParseWord OK
|
||||
2. Подогнать новую VFS под QCC
|
||||
3. Парсинг выходного имени файла исправить qccmsource3
|
||||
|
||||
//==================================================
|
||||
// то, что уже готово
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// client.cpp - client export & import
|
||||
//=======================================================================
|
||||
|
||||
#include "client.h"
|
||||
|
||||
void DLLEXPORT *ClientAPI (void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="client" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=client - Win32 Release
|
||||
!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 "client.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 "client.mak" CFG="client - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "client - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "client - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "client - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "..\temp\client\!release"
|
||||
# PROP Intermediate_Dir "..\temp\client\!release"
|
||||
# PROP Ignore_Export_Lib 1
|
||||
# PROP Target_Dir "."
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I ".\\" /I "../public" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
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 /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib winmm.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386
|
||||
# SUBTRACT LINK32 /debug
|
||||
# Begin Custom Build
|
||||
TargetDir=\XASH3D\src_main\!source\temp\client\!release
|
||||
InputPath=\XASH3D\src_main\!source\temp\client\!release\client.dll
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
"D:\Xash3D\xash\bin\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
copy $(TargetDir)\client.dll "D:\Xash3D\xash\bin\client.dll"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "client - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir "."
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "..\temp\client\!debug"
|
||||
# PROP Intermediate_Dir "..\temp\client\!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" /YX /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I ".\\" /I "../public" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
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 /dll /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# SUBTRACT LINK32 /incremental:no /map
|
||||
# Begin Custom Build
|
||||
TargetDir=\XASH3D\src_main\!source\temp\client\!debug
|
||||
InputPath=\XASH3D\src_main\!source\temp\client\!debug\client.dll
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
"D:\Xash3D\xash\bin\client.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
copy $(TargetDir)\client.dll "D:\Xash3D\xash\bin\client.dll"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "client - Win32 Release"
|
||||
# Name "client - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
|
@ -1,24 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// client.h - client dll definition file
|
||||
//=======================================================================
|
||||
#ifndef CLIENT_H
|
||||
#define CLIENT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <setjmp.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <direct.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "basetypes.h"
|
||||
#include "basemath.h"
|
||||
#include <ref_system.h>
|
||||
|
||||
|
||||
#endif//CLIENT_H
|
|
@ -26,9 +26,6 @@ if errorlevel 1 set BUILD_ERROR=1
|
|||
%MSDEV% server/server.dsp %CONFIG%"server - Win32 Debug" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
%MSDEV% client/client.dsp %CONFIG%"client - Win32 Debug" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
if "%BUILD_ERROR%"=="" goto build_ok
|
||||
|
||||
echo *********************
|
||||
|
@ -53,7 +50,6 @@ 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 server\server.plg del /f /q server\server.plg
|
||||
if exist client\client.plg del /f /q client\client.plg
|
||||
|
||||
echo Build succeeded!
|
||||
echo Please wait. Xash is now loading
|
||||
|
|
|
@ -3,18 +3,9 @@
|
|||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: editor - Win32 Release--------------------
|
||||
--------------------Configuration: editor - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\Temp\RSP1F64.bat" with contents
|
||||
[
|
||||
@echo off
|
||||
copy \XASH3D\src_main\!source\temp\editor\!release\editor.dll "D:\Xash3D\bin\editor.dll"
|
||||
]
|
||||
Creating command line "C:\Temp\RSP1F64.bat"
|
||||
<h3>Output Window</h3>
|
||||
Performing Custom Build Step on \XASH3D\src_main\!source\temp\editor\!release\editor.dll
|
||||
‘ª®¯¨à®¢ ® ä ©«®¢: 1.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
#include "client.h"
|
||||
#include <image.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -28,15 +27,15 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
bool restart_sound;
|
||||
bool restart_sound;
|
||||
int s_rate;
|
||||
int s_width;
|
||||
int s_channels;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
byte *pic;
|
||||
byte *pic_pending;
|
||||
byte *pic;
|
||||
byte *pic_pending;
|
||||
|
||||
// order 1 huffman stuff
|
||||
int *hnodes1; // [256][256][2];
|
||||
|
@ -47,97 +46,6 @@ typedef struct
|
|||
} cinematics_t;
|
||||
|
||||
cinematics_t cin;
|
||||
|
||||
/*
|
||||
=================================================================
|
||||
|
||||
PCX LOADING
|
||||
|
||||
=================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
SCR_LoadPCX
|
||||
==============
|
||||
*/
|
||||
void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)
|
||||
{
|
||||
byte *raw;
|
||||
pcx_t *pcx;
|
||||
int x, y;
|
||||
int len;
|
||||
int dataByte, runLength;
|
||||
byte *out, *pix;
|
||||
|
||||
*pic = NULL;
|
||||
|
||||
//
|
||||
// load the file
|
||||
//
|
||||
raw = FS_LoadFile (filename, &len);
|
||||
if (!raw) return;// Msg ("Bad pcx file %s\n", filename);
|
||||
|
||||
//
|
||||
// parse the PCX file
|
||||
//
|
||||
pcx = (pcx_t *)raw;
|
||||
raw = &pcx->data;
|
||||
|
||||
if (pcx->manufacturer != 0x0a || pcx->version != 5 || pcx->encoding != 1 || pcx->bits_per_pixel != 8 || pcx->xmax >= 640 || pcx->ymax >= 480)
|
||||
{
|
||||
Msg ("Bad pcx file %s\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
out = Z_Malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
|
||||
|
||||
*pic = out;
|
||||
|
||||
pix = out;
|
||||
|
||||
if (palette)
|
||||
{
|
||||
*palette = Z_Malloc(768);
|
||||
memcpy (*palette, (byte *)pcx + len - 768, 768);
|
||||
}
|
||||
|
||||
if (width)
|
||||
*width = pcx->xmax+1;
|
||||
if (height)
|
||||
*height = pcx->ymax+1;
|
||||
|
||||
for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
|
||||
{
|
||||
for (x=0 ; x<=pcx->xmax ; )
|
||||
{
|
||||
dataByte = *raw++;
|
||||
|
||||
if((dataByte & 0xC0) == 0xC0)
|
||||
{
|
||||
runLength = dataByte & 0x3F;
|
||||
dataByte = *raw++;
|
||||
}
|
||||
else
|
||||
runLength = 1;
|
||||
|
||||
while(runLength-- > 0)
|
||||
pix[x++] = dataByte;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( raw - (byte *)pcx > len)
|
||||
{
|
||||
Msg ("PCX file %s was malformed", filename);
|
||||
Z_Free (*pic);
|
||||
*pic = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_StopCinematic
|
||||
|
@ -538,8 +446,9 @@ bool SCR_DrawCinematic (void)
|
|||
}
|
||||
|
||||
if (cls.key_dest == key_menu)
|
||||
{ // blank screen and pause if menu is up
|
||||
re->CinematicSetPalette(NULL);
|
||||
{
|
||||
// blank screen and pause if menu is up
|
||||
re->CinematicSetPalette( NULL );
|
||||
cl.cinematicpalette_active = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -553,8 +462,7 @@ bool SCR_DrawCinematic (void)
|
|||
if (!cin.pic)
|
||||
return true;
|
||||
|
||||
re->DrawStretchRaw (0, 0, viddef.width, viddef.height,
|
||||
cin.width, cin.height, cin.pic);
|
||||
re->DrawStretchRaw (0, 0, viddef.width, viddef.height, cin.width, cin.height, cin.pic);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -568,30 +476,34 @@ SCR_PlayCinematic
|
|||
void SCR_PlayCinematic (char *arg)
|
||||
{
|
||||
int width, height;
|
||||
byte *palette;
|
||||
char name[MAX_OSPATH], *dot;
|
||||
byte *palette;
|
||||
char name[MAX_OSPATH];
|
||||
int old_khz;
|
||||
rgbdata_t *pic = NULL;
|
||||
const char *ext = FS_FileExtension( arg );
|
||||
|
||||
cl.cinematicframe = 0;
|
||||
dot = strstr (arg, ".");
|
||||
if (dot && !strcmp (dot, ".pcx"))
|
||||
{ // static pcx image
|
||||
sprintf (name, "pics/%s", arg);
|
||||
SCR_LoadPCX (name, &cin.pic, &palette, &cin.width, &cin.height);
|
||||
cl.cinematicframe = -1;
|
||||
cl.cinematictime = 1;
|
||||
SCR_EndLoadingPlaque ();
|
||||
cls.state = ca_active;
|
||||
if (!cin.pic)
|
||||
|
||||
if (!strcmp (ext, "pcx"))
|
||||
{
|
||||
pic = FS_LoadImage( va("textures/base_menu/%s", arg), NULL, 0 );
|
||||
|
||||
if(pic)
|
||||
{
|
||||
Msg ("%s not found.\n", name);
|
||||
cl.cinematictime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette));
|
||||
Z_Free (palette);
|
||||
cin.pic = pic->buffer;
|
||||
palette = pic->palette;
|
||||
cin.width = pic->width;
|
||||
cin.height = pic->height;
|
||||
|
||||
cl.cinematicframe = -1;
|
||||
cl.cinematictime = 1;
|
||||
|
||||
SCR_EndLoadingPlaque ();
|
||||
|
||||
cls.state = ca_active;
|
||||
Mem_Copy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette));
|
||||
}
|
||||
else Com_Error (ERR_DROP, "%s not found.\n", arg );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -599,7 +511,6 @@ void SCR_PlayCinematic (char *arg)
|
|||
cl.cinematic_file = FS_Open(name, "rb" );
|
||||
if (!cl.cinematic_file)
|
||||
{
|
||||
// Com_Error (ERR_DROP, "Cinematic %s not found.\n", name);
|
||||
SCR_FinishCinematic ();
|
||||
cl.cinematictime = 0; // done
|
||||
return;
|
||||
|
|
|
@ -579,7 +579,7 @@ void SCR_BeginLoadingPlaque (void)
|
|||
if (cls.key_dest == key_console)
|
||||
return;
|
||||
if (cl.cinematictime > 0)
|
||||
scr_draw_loading = 2; // clear to balack first
|
||||
scr_draw_loading = 2; // clear to black first
|
||||
else
|
||||
scr_draw_loading = 1;
|
||||
SCR_UpdateScreen ();
|
||||
|
@ -947,7 +947,7 @@ void SCR_ExecuteLayoutString (char *s)
|
|||
{
|
||||
int x, y;
|
||||
int value;
|
||||
char *token;
|
||||
char *token;
|
||||
int width;
|
||||
int index;
|
||||
clientinfo_t *ci;
|
||||
|
@ -955,8 +955,7 @@ void SCR_ExecuteLayoutString (char *s)
|
|||
if (cls.state != ca_active || !cl.refresh_prepped)
|
||||
return;
|
||||
|
||||
if (!s[0])
|
||||
return;
|
||||
if (!s[0]) return;
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
@ -1195,7 +1194,8 @@ void SCR_ExecuteLayoutString (char *s)
|
|||
continue;
|
||||
}
|
||||
if (!strcmp(token, "if"))
|
||||
{ // draw a number
|
||||
{
|
||||
// draw a number
|
||||
token = COM_Parse (&s);
|
||||
value = cl.frame.playerstate.stats[atoi(token)];
|
||||
|
||||
|
@ -1306,7 +1306,8 @@ void SCR_UpdateScreen (void)
|
|||
re->BeginFrame( separation[i] );
|
||||
|
||||
if (scr_draw_loading == 2)
|
||||
{ // loading plaque over black screen
|
||||
{
|
||||
// loading plaque over black screen
|
||||
re->CinematicSetPalette(NULL);
|
||||
scr_draw_loading = false;
|
||||
SCR_DrawString( "loading" );
|
||||
|
|
|
@ -541,11 +541,11 @@ Cmd_MacroExpandString
|
|||
char *Cmd_MacroExpandString (char *text)
|
||||
{
|
||||
int i, j, count, len;
|
||||
bool inquote;
|
||||
char *scan;
|
||||
static char expanded[MAX_STRING_CHARS];
|
||||
char temporary[MAX_STRING_CHARS];
|
||||
char *token, *start;
|
||||
bool inquote;
|
||||
char *scan;
|
||||
static char expanded[MAX_STRING_CHARS];
|
||||
char temporary[MAX_STRING_CHARS];
|
||||
char *token, *start;
|
||||
|
||||
inquote = false;
|
||||
scan = text;
|
||||
|
@ -559,19 +559,16 @@ char *Cmd_MacroExpandString (char *text)
|
|||
|
||||
count = 0;
|
||||
|
||||
for (i=0 ; i<len ; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (scan[i] == '"')
|
||||
inquote ^= 1;
|
||||
if (inquote)
|
||||
continue; // don't expand inside quotes
|
||||
if (scan[i] != '$')
|
||||
continue;
|
||||
if (scan[i] == '"') inquote ^= 1;
|
||||
if (inquote) continue; // don't expand inside quotes
|
||||
if (scan[i] != '$') continue;
|
||||
|
||||
// scan out the complete macro
|
||||
start = scan+i+1;
|
||||
start = scan + i + 1;
|
||||
token = COM_Parse (&start);
|
||||
if (!start)
|
||||
continue;
|
||||
if (!start) continue;
|
||||
|
||||
token = Cvar_VariableString (token);
|
||||
|
||||
|
@ -621,22 +618,20 @@ void Cmd_TokenizeString (char *text, bool macroExpand)
|
|||
int i;
|
||||
char *token;
|
||||
|
||||
// clear the args from the last string
|
||||
for (i=0 ; i<cmd_argc ; i++)
|
||||
Z_Free (cmd_argv[i]);
|
||||
// clear the args from the last string
|
||||
for (i = 0; i < cmd_argc; i++) Z_Free (cmd_argv[i]);
|
||||
|
||||
cmd_argc = 0;
|
||||
cmd_args[0] = 0;
|
||||
|
||||
// macro expand the text
|
||||
if (macroExpand)
|
||||
text = Cmd_MacroExpandString (text);
|
||||
if (!text)
|
||||
return;
|
||||
if (macroExpand) text = Cmd_MacroExpandString (text);
|
||||
|
||||
if (!text) return;
|
||||
|
||||
while (1)
|
||||
{
|
||||
// skip whitespace up to a /n
|
||||
// skip whitespace up to a /n
|
||||
while (*text && *text <= ' ' && *text != '\n')
|
||||
{
|
||||
text++;
|
||||
|
@ -648,8 +643,7 @@ void Cmd_TokenizeString (char *text, bool macroExpand)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!*text)
|
||||
return;
|
||||
if (!*text) return;
|
||||
|
||||
// set cmd_args to everything after the first arg
|
||||
if (cmd_argc == 1)
|
||||
|
@ -668,9 +662,8 @@ void Cmd_TokenizeString (char *text, bool macroExpand)
|
|||
}
|
||||
|
||||
token = COM_Parse (&text);
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
if (!text) return;
|
||||
|
||||
if (cmd_argc < MAX_STRING_TOKENS)
|
||||
{
|
||||
cmd_argv[cmd_argc] = Z_Malloc (strlen(token)+1);
|
||||
|
|
|
@ -2272,7 +2272,7 @@ bool CreateMapsList( void )
|
|||
|
||||
int p = 0, lumpofs = 0, lumplen = 0;
|
||||
char *entities = NULL;
|
||||
const char *data = NULL;
|
||||
char *data = NULL;
|
||||
char mapname[32];
|
||||
char message[64];
|
||||
char string[96];
|
||||
|
@ -2418,11 +2418,11 @@ void StartServer_MenuInit( void )
|
|||
char scratch[200];
|
||||
int j, l;
|
||||
|
||||
strcpy( shortname, COM_Parse( &s ) );
|
||||
strcpy( shortname, COM_Parse( &s ));
|
||||
l = strlen(shortname);
|
||||
for (j=0 ; j<l ; j++)
|
||||
shortname[j] = toupper(shortname[j]);
|
||||
strcpy( longname, COM_Parse( &s ) );
|
||||
strcpy( longname, COM_Parse( &s ));
|
||||
sprintf( scratch, "%s\n%s", longname, shortname );
|
||||
|
||||
mapnames[i] = Z_Malloc( strlen( scratch ) + 1 );
|
||||
|
@ -3677,10 +3677,9 @@ void M_Draw (void)
|
|||
SCR_DirtyScreen ();
|
||||
|
||||
// dim everything behind it down
|
||||
if (cl.cinematictime > 0)
|
||||
re->DrawFill (0,0,viddef.width, viddef.height, 0);
|
||||
else
|
||||
re->DrawFadeScreen ();
|
||||
if (cl.cinematictime > 0)
|
||||
re->DrawFill (0, 0, viddef.width, viddef.height, 0);
|
||||
else re->DrawFadeScreen ();
|
||||
|
||||
m_drawfunc ();
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ filesystem manager
|
|||
===========================================
|
||||
*/
|
||||
#define FS_LoadFile(name, size) pi->Fs.LoadFile(name, size)
|
||||
#define FS_LoadImage(name, width, height) pi->Fs.LoadFile(name, width, height)
|
||||
#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 )
|
||||
|
@ -73,6 +73,7 @@ filesystem manager
|
|||
#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
|
||||
|
@ -85,6 +86,7 @@ scriptsystem manager
|
|||
===========================================
|
||||
*/
|
||||
#define COM_Parse(data) pi->Script.ParseToken(data)
|
||||
#define COM_Token pi->Script.Token
|
||||
|
||||
/*
|
||||
===========================================
|
||||
|
|
|
@ -324,9 +324,10 @@ void Sys_CreateConsoleW( void )
|
|||
WNDCLASS wc;
|
||||
RECT rect;
|
||||
int nHeight;
|
||||
int swidth, sheight;
|
||||
int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION;// | WS_MINIMIZEBOX;
|
||||
int swidth, sheight, fontsize;
|
||||
int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION;
|
||||
int CONSTYLE = WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | WS_EX_CLIENTEDGE | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY;
|
||||
char Title[32], FontName[32];
|
||||
|
||||
memset( &wc, 0, sizeof( wc ) );
|
||||
|
||||
|
@ -342,13 +343,27 @@ void Sys_CreateConsoleW( void )
|
|||
wc.lpszClassName = SYSCONSOLE;
|
||||
|
||||
if (!RegisterClass (&wc) ) return;
|
||||
|
||||
if(console_read_only)
|
||||
|
||||
if(about_mode)
|
||||
{
|
||||
CONSTYLE &= ~WS_VSCROLL;
|
||||
rect.left = 0;
|
||||
rect.right = 536;
|
||||
rect.top = 0;
|
||||
rect.bottom = 280;
|
||||
strcpy(Title, "" );
|
||||
strcpy(FontName, "Arial" );
|
||||
fontsize = 16;
|
||||
}
|
||||
else if(console_read_only)
|
||||
{
|
||||
rect.left = 0;
|
||||
rect.right = 536;
|
||||
rect.top = 0;
|
||||
rect.bottom = 364;
|
||||
strcpy(Title, "Xash Console" );
|
||||
strcpy(FontName, "Fixedsys" );
|
||||
fontsize = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -356,6 +371,9 @@ void Sys_CreateConsoleW( void )
|
|||
rect.right = 540;
|
||||
rect.top = 0;
|
||||
rect.bottom = 392;
|
||||
strcpy(Title, "Xash Dedicated Console" );
|
||||
strcpy(FontName, "Fixedsys" );
|
||||
fontsize = 8;
|
||||
}
|
||||
AdjustWindowRect( &rect, DEDSTYLE, FALSE );
|
||||
|
||||
|
@ -367,14 +385,13 @@ void Sys_CreateConsoleW( void )
|
|||
s_wcd.windowWidth = rect.right - rect.left;
|
||||
s_wcd.windowHeight = rect.bottom - rect.top;
|
||||
|
||||
s_wcd.hWnd = CreateWindowEx( WS_EX_DLGMODALFRAME, SYSCONSOLE, "Xash Console", DEDSTYLE, ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1, NULL, NULL, base_hInstance, NULL );
|
||||
|
||||
s_wcd.hWnd = CreateWindowEx( WS_EX_DLGMODALFRAME, SYSCONSOLE, Title, DEDSTYLE, ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1, NULL, NULL, base_hInstance, NULL );
|
||||
if ( s_wcd.hWnd == NULL ) return;
|
||||
|
||||
// create fonts
|
||||
hDC = GetDC( s_wcd.hWnd );
|
||||
nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY), 72);
|
||||
s_wcd.hfBufferFont = CreateFont( nHeight, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH, "Fixedsys" );
|
||||
nHeight = -MulDiv( fontsize, GetDeviceCaps( hDC, LOGPIXELSY), 72);
|
||||
s_wcd.hfBufferFont = CreateFont( nHeight, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH, FontName );
|
||||
ReleaseDC( s_wcd.hWnd, hDC );
|
||||
|
||||
if(!console_read_only)
|
||||
|
@ -389,7 +406,7 @@ void Sys_CreateConsoleW( void )
|
|||
// create the scrollbuffer
|
||||
GetClientRect(s_wcd.hWnd, &rect);
|
||||
|
||||
s_wcd.hwndBuffer = CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE, "edit", NULL, CONSTYLE, 0, 0, rect.right - rect.left, 365, s_wcd.hWnd, ( HMENU )EDIT_ID, base_hInstance, NULL );
|
||||
s_wcd.hwndBuffer = CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE, "edit", NULL, CONSTYLE, 0, 0, rect.right - rect.left, min(365, rect.bottom), s_wcd.hWnd, ( HMENU )EDIT_ID, base_hInstance, NULL );
|
||||
SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
|
||||
|
||||
if(!console_read_only)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
//=======================================================================
|
||||
// Copyright (C) XashXT Group 2007
|
||||
//=======================================================================
|
||||
|
||||
#include "../getlib.h"
|
||||
|
||||
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
Run32( credits );
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#=============================
|
||||
# Makefile to build xash utils
|
||||
# Author: Unkle Mike <xash.ru>
|
||||
#
|
||||
# Please associate .nmake files as NMAKE.EXE "/f" "%1" for build this file
|
||||
#=============================
|
||||
|
||||
!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
|
||||
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp > nul
|
||||
@copy $(MAINTARGET).exe D:\Xash3D\$(MAINTARGET).exe
|
||||
@del $(MAINTARGET).exe
|
||||
@echo !!! Done !!!
|
||||
clean:
|
||||
|
||||
.cpp.obj:
|
||||
$(CC) $(CFLAGS) /c $<
|
|
@ -10,8 +10,11 @@ static int app_name;
|
|||
bool hooked_out = false;
|
||||
bool log_active = false;
|
||||
bool show_always = true;
|
||||
bool about_mode = false;
|
||||
char dllname[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";
|
||||
|
||||
//app name
|
||||
typedef enum
|
||||
{
|
||||
|
@ -20,6 +23,7 @@ typedef enum
|
|||
HOST_DEDICATED, // "host_dedicated"
|
||||
HOST_EDITOR, // "host_editor"
|
||||
BSPLIB, // "bsplib"
|
||||
QCCLIB, // "qcclib"
|
||||
SPRITE, // "sprite"
|
||||
STUDIO, // "studio"
|
||||
CREDITS, // misc
|
||||
|
@ -43,6 +47,7 @@ NOTE: at this day we have seven instnaces
|
|||
2. "host_dedicated" - dedicated server
|
||||
3. "host_editor" - resource editor
|
||||
4. "bsplib" - three BSP compilers in one
|
||||
5. "qcclib" - quake c complier
|
||||
5. "sprite" - sprite creator (requires qc. script)
|
||||
6. "studio" - Half-Life style models creatror (requires qc. script)
|
||||
7. "credits" - display credits of engine developers
|
||||
|
@ -87,6 +92,12 @@ void LookupInstance( const char *funcname )
|
|||
strcpy(dllname, "bin/platform.dll" );
|
||||
strcpy(log_path, "bsplib.log" ); // xash3d root directory
|
||||
}
|
||||
else if(!strcmp(progname, "qcclib"))
|
||||
{
|
||||
app_name = QCCLIB;
|
||||
strcpy(dllname, "bin/platform.dll" );
|
||||
sprintf(log_path, "%s/compile.log", sys_rootdir ); // same as .exe file
|
||||
}
|
||||
else if(!strcmp(progname, "sprite"))
|
||||
{
|
||||
app_name = SPRITE;
|
||||
|
@ -102,6 +113,7 @@ void LookupInstance( const char *funcname )
|
|||
else if(!strcmp(progname, "credits")) //easter egg
|
||||
{
|
||||
app_name = CREDITS;
|
||||
about_mode = true;
|
||||
}
|
||||
else app_name = DEFAULT;
|
||||
}
|
||||
|
@ -116,8 +128,8 @@ so do it manually
|
|||
*/
|
||||
void PlatformInit ( char *funcname, int argc, char **argv )
|
||||
{
|
||||
byte bspflags = 0;
|
||||
char mapname[64], gamedir[64];
|
||||
byte bspflags = 0, qccflags = 0;
|
||||
char source[64], gamedir[64];
|
||||
|
||||
if(pi->apiversion != PLATFORM_API_VERSION)
|
||||
Sys_Error("mismatch version (%i should be %i)\n", pi->apiversion, PLATFORM_API_VERSION);
|
||||
|
@ -128,19 +140,29 @@ void PlatformInit ( char *funcname, int argc, char **argv )
|
|||
|
||||
if(!GetParmFromCmdLine("-game", gamedir ))
|
||||
strncpy(gamedir, "xash", sizeof(gamedir));
|
||||
if(!GetParmFromCmdLine("+map", mapname ))
|
||||
strncpy(mapname, "newmap", sizeof(mapname));
|
||||
if(!GetParmFromCmdLine("+map", source ))
|
||||
strncpy(source, "newmap", sizeof(source));
|
||||
if(!GetParmFromCmdLine("+dat", source ))
|
||||
strncpy(source, "progs", sizeof(source));
|
||||
|
||||
if(CheckParm("-vis")) bspflags |= BSP_ONLYVIS;
|
||||
if(CheckParm("-rad")) bspflags |= BSP_ONLYRAD;
|
||||
if(CheckParm("-full")) bspflags |= BSP_FULLCOMPILE;
|
||||
if(CheckParm("-onlyents")) bspflags |= BSP_ONLYENTS;
|
||||
|
||||
if(CheckParm("-progdefs")) qccflags |= QCC_PROGDEFS;
|
||||
if(CheckParm("/O0")) qccflags |= QCC_OPT_LEVEL_0;
|
||||
if(CheckParm("/O1")) qccflags |= QCC_OPT_LEVEL_1;
|
||||
if(CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_2;
|
||||
if(CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_3;
|
||||
|
||||
switch(app_name)
|
||||
{
|
||||
case BSPLIB:
|
||||
// this does nothing
|
||||
pi->Compile.PrepareBSP( gamedir, mapname, bspflags );
|
||||
pi->Compile.PrepareBSP( gamedir, source, bspflags );
|
||||
break;
|
||||
case QCCLIB:
|
||||
pi->Compile.PrepareDAT( gamedir, source, qccflags );
|
||||
break;
|
||||
case SPRITE:
|
||||
pi->InitRootDir(".");
|
||||
|
@ -177,6 +199,10 @@ void PlatformMain ( void )
|
|||
pi->Compile.BSP();
|
||||
strcpy(typemod, "maps" );
|
||||
break;
|
||||
case QCCLIB:
|
||||
pi->Compile.DAT();
|
||||
strcpy(typemod, "progs" );
|
||||
break;
|
||||
case DEFAULT:
|
||||
strcpy(typemod, "things" );
|
||||
break;
|
||||
|
@ -235,7 +261,10 @@ void CreateInstance( void )
|
|||
std.exit = Sys_Exit;
|
||||
std.print = Sys_Print;
|
||||
std.input = Sys_Input;
|
||||
|
||||
|
||||
// first text message into console or log
|
||||
if(app_name != CREDITS) Msg("------- Loading bin/launcher.dll [%g] -------\n", LAUNCHER_VERSION );
|
||||
|
||||
switch(app_name)
|
||||
{
|
||||
case HOST_SHARED:
|
||||
|
@ -253,6 +282,7 @@ void CreateInstance( void )
|
|||
Host_Free = Host->Free;
|
||||
break;
|
||||
case BSPLIB:
|
||||
case QCCLIB:
|
||||
case SPRITE:
|
||||
case STUDIO:
|
||||
if (( linked_dll = LoadLibrary( dllname )) == 0 )
|
||||
|
@ -266,7 +296,7 @@ void CreateInstance( void )
|
|||
Host_Free = PlatformShutdown;
|
||||
break;
|
||||
case CREDITS:
|
||||
//blank
|
||||
Sys_Error( (char *)show_credits );
|
||||
break;
|
||||
case DEFAULT:
|
||||
Sys_Error("CreateInstance: unsupported instance\n");
|
||||
|
@ -354,8 +384,6 @@ void InitLauncher( char *funcname )
|
|||
API_SetConsole(); //initialize system console
|
||||
Sys_InitConsole();
|
||||
|
||||
// first text message into console or log
|
||||
Msg("------- Loading bin/launcher.dll [%g] -------\n", LAUNCHER_VERSION );
|
||||
CreateInstance();
|
||||
|
||||
// NOTE: host will working in loop mode and never returned
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <winreg.h>
|
||||
#include <fcntl.h>
|
||||
#include <basetypes.h>
|
||||
typedef int bool;
|
||||
|
||||
#include <ref_system.h>
|
||||
|
||||
//import variables
|
||||
|
@ -40,6 +42,7 @@ extern char sys_rootdir[ MAX_SYSPATH ];
|
|||
extern char log_path[256];
|
||||
extern bool console_read_only;
|
||||
extern bool show_always;
|
||||
extern bool about_mode;
|
||||
char *va(const char *format, ...);
|
||||
static int sys_error = false;
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#=============================
|
||||
# Makefile to build xash utils
|
||||
# Author: Unkle Mike <xash.ru>
|
||||
#
|
||||
# Please associate .nmake files as NMAKE.EXE "/f" "%1" for build this file
|
||||
#=============================
|
||||
|
||||
!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
|
||||
@del $(MAINTARGET).obj $(MAINTARGET).lib $(MAINTARGET).exp $(MAINTARGET).res > nul
|
||||
@copy $(MAINTARGET).exe D:\Xash3D\bin\$(MAINTARGET).exe
|
||||
@del $(MAINTARGET).exe
|
||||
@echo !!! Done !!!
|
||||
clean:
|
||||
|
||||
.cpp.obj:
|
||||
$(CC) $(CFLAGS) /c $<
|
||||
|
||||
qcclib.res : qcclib.rc
|
||||
$(RC) $(RCFLAGS) /r qcclib.rc
|
|
@ -0,0 +1,10 @@
|
|||
//=======================================================================
|
||||
// Copyright (C) XashXT Group 2007
|
||||
//=======================================================================
|
||||
|
||||
#include "../getlib.h"
|
||||
|
||||
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
Run32( qcclib );
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#include <winver.h>
|
||||
|
||||
#define IDI_ICON1 101
|
||||
|
||||
#define VER_FILEVERSION 0,45
|
||||
#define VER_FILEVERSION_STR "0.45"
|
||||
#define VER_PRODUCTVERSION 0,45
|
||||
#define VER_PRODUCTVERSION_STR "0.45"
|
||||
|
||||
#define VER_FILEFLAGSMASK VS_FF_PRERELEASE | VS_FF_PATCHED
|
||||
#define VER_FILEFLAGS VS_FF_PRERELEASE
|
||||
#define VER_FILEOS VOS__WINDOWS32
|
||||
#define VER_FILETYPE VFT_DLL
|
||||
#define VER_FILESUBTYPE VFT2_UNKNOWN
|
||||
|
||||
#define VER_COMPANYNAME_STR "XashXT Group"
|
||||
#define VER_LEGALCOPYRIGHT_STR "XashXT 2007"
|
||||
#define VER_PRODUCTNAME_STR "QccLib Launcher"
|
||||
|
||||
#define VER_ANSICP
|
||||
|
||||
#define VER_FILEDESCRIPTION_STR "QccLib Launcher"
|
||||
#define VER_ORIGINALFILENAME_STR "qcclib.exe"
|
||||
#define VER_INTERNALNAME_STR "qcclib"
|
||||
|
||||
#include <common.ver>
|
||||
|
||||
IDI_ICON1 ICON DISCARDABLE "tool.ico"
|
Binary file not shown.
After Width: | Height: | Size: 766 B |
|
@ -104,13 +104,16 @@ void *_Mem_Realloc(byte *poolptr, void *memptr, size_t size, const char *filenam
|
|||
memheader_t *hdr;
|
||||
|
||||
if (size <= 0) return memptr;//no need to reallocate
|
||||
if (!memptr) Sys_Error("Mem_Realloc: memptr == NULL (called at %s:%i)", filename, fileline);
|
||||
nb = _Mem_Alloc(poolptr, size, filename, fileline);
|
||||
|
||||
//get size of old block
|
||||
hdr = (memheader_t *)((byte *) memptr - sizeof(memheader_t));
|
||||
_Mem_Copy( nb, memptr, hdr->size, filename, fileline );
|
||||
_Mem_Free( memptr, filename, fileline);//free unused old block
|
||||
if (memptr) //first allocate?
|
||||
{
|
||||
//get size of old block
|
||||
hdr = (memheader_t *)((byte *) memptr - sizeof(memheader_t));
|
||||
_Mem_Copy( nb, memptr, hdr->size, filename, fileline );
|
||||
_Mem_Free( memptr, filename, fileline);//free unused old block
|
||||
}
|
||||
else MsgWarn("Mem_Realloc: memptr == NULL (called at %s:%i)\n", filename, fileline);
|
||||
|
||||
return (void *)nb;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
#include "platform.h"
|
||||
#include <winreg.h>
|
||||
#include "baseutils.h"
|
||||
#include "bsplib.h"
|
||||
#include "mdllib.h"
|
||||
#include "qcclib.h"
|
||||
#include "blankframe.h"
|
||||
|
||||
|
||||
char *strupr (char *start)
|
||||
{
|
||||
char *in;
|
||||
|
@ -329,27 +333,28 @@ Parse a token out of a string
|
|||
char *SC_ParseToken(const char **data_p)
|
||||
{
|
||||
int c;
|
||||
int len;
|
||||
int len = 0;
|
||||
const char *data;
|
||||
|
||||
data = *data_p;
|
||||
len = 0;
|
||||
token[0] = 0;
|
||||
|
||||
if (!data)
|
||||
token[0] = 0;
|
||||
data = *data_p;
|
||||
|
||||
if (!data)
|
||||
{
|
||||
endofscript = true;
|
||||
*data_p = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
skipwhite: // skip whitespace
|
||||
// skip whitespace
|
||||
skipwhite:
|
||||
while ( (c = *data) <= ' ')
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
endofscript = true;
|
||||
*data_p = NULL;
|
||||
return NULL;
|
||||
return NULL; // end of file;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
|
@ -362,46 +367,188 @@ skipwhite: // skip whitespace
|
|||
goto skipwhite;
|
||||
}
|
||||
|
||||
// skip /* comments
|
||||
if (c=='/' && data[1] == '*')
|
||||
{
|
||||
while (data[1] && (data[0] != '*' || data[1] != '/'))
|
||||
data++;
|
||||
data += 2;
|
||||
goto skipwhite;
|
||||
}
|
||||
|
||||
|
||||
// handle quoted strings specially
|
||||
if (c == '\"')
|
||||
{
|
||||
data++;
|
||||
while (1)
|
||||
while(1)
|
||||
{
|
||||
c = *data++;
|
||||
if (c=='\"' || !c)
|
||||
if (c=='\"'||c=='\0')
|
||||
{
|
||||
token[len] = 0;
|
||||
*data_p = data;
|
||||
return token;
|
||||
}
|
||||
if (len < MAX_OSPATH)
|
||||
{
|
||||
token[len] = c;
|
||||
len++;
|
||||
}
|
||||
token[len] = c;
|
||||
len++;
|
||||
}
|
||||
}
|
||||
|
||||
// parse single characters
|
||||
if (c == '{' || c == '}'|| c == ')' || c == '(' || c == '\'' || c == ':' || c == ',')
|
||||
{
|
||||
token[len] = c;
|
||||
data++;
|
||||
len++;
|
||||
token[len] = 0;
|
||||
*data_p = data;
|
||||
return token;
|
||||
}
|
||||
|
||||
// parse a regular word
|
||||
do
|
||||
{
|
||||
if (len < MAX_OSPATH)
|
||||
{
|
||||
token[len] = c;
|
||||
len++;
|
||||
}
|
||||
token[len] = c;
|
||||
data++;
|
||||
len++;
|
||||
c = *data;
|
||||
} while (c > 32);
|
||||
|
||||
if (len == MAX_OSPATH) len = 0;
|
||||
if (c == '{' || c == '}'|| c == ')'|| c == '(' || c == '\'' || c == ':' || c == ',')
|
||||
break;
|
||||
} while(c > 32);
|
||||
|
||||
token[len] = 0;
|
||||
|
||||
*data_p = data;
|
||||
return token;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SC_ParseWord
|
||||
|
||||
Parse a word out of a string
|
||||
==============
|
||||
*/
|
||||
char *SC_ParseWord( const char **data_p )
|
||||
{
|
||||
int c;
|
||||
int len = 0;
|
||||
const char *data;
|
||||
|
||||
token[0] = 0;
|
||||
data = *data_p;
|
||||
|
||||
if (!data)
|
||||
{
|
||||
*data_p = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// skip whitespace
|
||||
skipwhite:
|
||||
while ( (c = *data) <= ' ')
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
*data_p = NULL;
|
||||
endofscript = true;
|
||||
return NULL; // end of file;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
|
||||
// skip // comments
|
||||
if (c=='/' && data[1] == '/')
|
||||
{
|
||||
while (*data && *data != '\n')
|
||||
data++;
|
||||
goto skipwhite;
|
||||
}
|
||||
|
||||
|
||||
// handle quoted strings specially
|
||||
if (c == '\"')
|
||||
{
|
||||
data++;
|
||||
do
|
||||
{
|
||||
c = *data++;
|
||||
if (c=='\"' || c=='\0')
|
||||
{
|
||||
token[len] = 0;
|
||||
*data_p = data;
|
||||
return token;
|
||||
}
|
||||
token[len] = c;
|
||||
len++;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
// parse numbers
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
if (c == '0' && data[1] == 'x')
|
||||
{
|
||||
//parse hex
|
||||
token[0] = '0';
|
||||
c='x';
|
||||
len=1;
|
||||
data++;
|
||||
while( 1 )
|
||||
{
|
||||
//parse regular number
|
||||
token[len] = c;
|
||||
data++;
|
||||
len++;
|
||||
c = *data;
|
||||
if ((c < '0'|| c > '9') && (c < 'a'||c > 'f') && (c < 'A'|| c > 'F') && c != '.')
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
//parse regular number
|
||||
token[len] = c;
|
||||
data++;
|
||||
len++;
|
||||
c = *data;
|
||||
if ((c < '0'|| c > '9') && c != '.')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
token[len] = 0;
|
||||
*data_p = data;
|
||||
return token;
|
||||
}
|
||||
|
||||
// parse words
|
||||
else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_')
|
||||
{
|
||||
do
|
||||
{
|
||||
token[len] = c;
|
||||
data++;
|
||||
len++;
|
||||
c = *data;
|
||||
} while ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_');
|
||||
|
||||
token[len] = 0;
|
||||
*data_p = data;
|
||||
return token;
|
||||
}
|
||||
else
|
||||
{
|
||||
token[len] = c;
|
||||
len++;
|
||||
token[len] = 0;
|
||||
*data_p = data;
|
||||
return token;
|
||||
}
|
||||
}
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
|
@ -514,7 +661,8 @@ scriptsystem_api_t Sc_GetAPI( void )
|
|||
sc.SkipToken = SC_SkipToken;
|
||||
sc.MatchToken = SC_MatchToken;
|
||||
sc.ParseToken = SC_ParseToken;
|
||||
|
||||
sc.ParseWord = SC_ParseWord;
|
||||
|
||||
return sc;
|
||||
}
|
||||
|
||||
|
@ -1400,6 +1548,8 @@ compilers_api_t Comp_GetAPI( void )
|
|||
cp.Sprite = CompileSpriteModel;
|
||||
cp.PrepareBSP = PrepareBSPModel;
|
||||
cp.BSP = CompileBSPModel;
|
||||
cp.PrepareDAT = PrepareDATProgs;
|
||||
cp.DAT = CompileDATProgs;
|
||||
|
||||
return cp;
|
||||
}
|
|
@ -28,7 +28,7 @@ void CalcTextureReflectivity (void)
|
|||
texture_reflectivity[0][1] = 0.5;
|
||||
texture_reflectivity[0][2] = 0.5;
|
||||
|
||||
for (i=0 ; i<numtexinfo ; i++)
|
||||
for (i = 0; i < numtexinfo; i++)
|
||||
{
|
||||
// see if an earlier texinfo allready got the value
|
||||
for (j=0 ; j<i ; j++)
|
||||
|
@ -47,22 +47,39 @@ void CalcTextureReflectivity (void)
|
|||
tex = FS_LoadImage(texinfo[i].texture, NULL, 0);
|
||||
if(tex)
|
||||
{
|
||||
texels = tex->width * tex->height;
|
||||
for (j = 0; j < texels; j++, tex->buffer += 4)
|
||||
texels = tex->width * tex->height;
|
||||
|
||||
switch(tex->type)
|
||||
{
|
||||
color[0] += tex->buffer[0];
|
||||
color[1] += tex->buffer[1];
|
||||
color[2] += tex->buffer[2];
|
||||
case PF_RGBA_32:
|
||||
case PF_ABGR_64:
|
||||
for (j = 0; j < texels; j++, tex->buffer += 4)
|
||||
{
|
||||
color[0] += tex->buffer[0];
|
||||
color[1] += tex->buffer[1];
|
||||
color[2] += tex->buffer[2];
|
||||
}
|
||||
break;
|
||||
case PF_RGB_24:
|
||||
for (j = 0; j < texels; j++, tex->buffer += 3)
|
||||
{
|
||||
color[0] += tex->buffer[0];
|
||||
color[1] += tex->buffer[1];
|
||||
color[2] += tex->buffer[2];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
MsgWarn("Can't calculate reflectivity for %s\n", texinfo[i].texture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else Msg("Couldn't load %s\n", texinfo[i].texture);
|
||||
else MsgWarn("Couldn't load %s\n", texinfo[i].texture);
|
||||
|
||||
//try also get direct values from shader
|
||||
if(si = FindShader( texinfo[i].texture ))
|
||||
{
|
||||
if(!VectorIsNull(si->color))
|
||||
{
|
||||
//Msg("Shader color %g %g %g\n", si->color[0], si->color[1], si->color[2]);
|
||||
TransformRGB(si->color, texture_reflectivity[i]);
|
||||
texinfo[i].value = si->intensity;
|
||||
continue;
|
||||
|
|
|
@ -2380,6 +2380,13 @@ vfile_t *VFS_Open(file_t* real_file, const char* mode)
|
|||
{
|
||||
vfile_t *file = (vfile_t *)Mem_Alloc (fs_mempool, sizeof (*file));
|
||||
|
||||
if(!real_file)
|
||||
{
|
||||
Free( file );
|
||||
MsgWarn("VFS_Open: can't open NULL handle\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// If the file is opened in "write", "append", or "read/write" mode
|
||||
if (mode[0] == 'w')
|
||||
{
|
||||
|
@ -2420,6 +2427,7 @@ vfile_t *VFS_Open(file_t* real_file, const char* mode)
|
|||
fs_offset_t VFS_Read( vfile_t* file, void* buffer, size_t buffersize)
|
||||
{
|
||||
if (buffersize == 0) return 0;
|
||||
if (!file) return 0;
|
||||
|
||||
//check for enough room
|
||||
if(file->offset >= file->length)
|
||||
|
@ -2469,11 +2477,14 @@ fs_offset_t VFS_Write( vfile_t *file, const void *buf, size_t size )
|
|||
|
||||
fs_offset_t VFS_Tell (vfile_t* file)
|
||||
{
|
||||
if (!file) return -1;
|
||||
return file->offset;
|
||||
}
|
||||
|
||||
int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence )
|
||||
{
|
||||
if (!file) return -1;
|
||||
|
||||
// Compute the file offset
|
||||
switch (whence)
|
||||
{
|
||||
|
@ -2499,7 +2510,7 @@ int VFS_Close( vfile_t *file )
|
|||
{
|
||||
if(!file) return -1;
|
||||
|
||||
if(file->mode == O_WRONLY)
|
||||
if(file->file && file->mode == O_WRONLY)
|
||||
{
|
||||
// write real file into disk
|
||||
FS_Write (file->file, file->buff, (file->length + 3) & ~3);// align
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "platform.h"
|
||||
#include "baseutils.h"
|
||||
#include "bsplib.h"
|
||||
#include "mdllib.h"
|
||||
#include "qcclib.h"
|
||||
|
||||
bool host_debug = false;
|
||||
|
||||
|
|
|
@ -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 "PLATFORM_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /Ob0 /I "./" /I "./bsplib/" /I "../public" /I "./formats" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /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
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
|
@ -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 "PLATFORM_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "./bsplib/" /I "../public" /I "./formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /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
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
|
@ -173,6 +173,14 @@ SOURCE=.\bsplib\portals.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\qcclib\pr_comp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\qcclib\pr_lex.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bsplib\prtfile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -181,6 +189,14 @@ SOURCE=.\bsplib\qbsp3.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\qcclib\qcc_utils.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\qcclib\qccmain.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bsplib\qrad3.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -197,11 +213,11 @@ SOURCE=.\spritegen.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\studio.c
|
||||
SOURCE=.\mdllib\studio.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\studio_utils.c
|
||||
SOURCE=.\mdllib\studio_utils.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -237,11 +253,15 @@ SOURCE=.\basemem.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bsplib.h
|
||||
SOURCE=.\baseutils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\qcclib\cmdlib.h
|
||||
SOURCE=.\blankframe.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bsplib\bsplib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -249,7 +269,7 @@ SOURCE=.\image.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mdllib.h
|
||||
SOURCE=.\mdllib\mdllib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -257,7 +277,7 @@ SOURCE=.\platform.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\public\ref_platform.h
|
||||
SOURCE=.\qcclib\qcclib.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -265,6 +285,10 @@ SOURCE=..\public\ref_system.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zip32.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ziplib.h
|
||||
# End Source File
|
||||
# End Group
|
||||
|
|
|
@ -9,10 +9,14 @@
|
|||
#include <setjmp.h>
|
||||
#include <windows.h>
|
||||
#include <basetypes.h>
|
||||
typedef int bool;
|
||||
|
||||
#include "image.h"
|
||||
#include "basemem.h"
|
||||
#include <ref_system.h>
|
||||
|
||||
#include "basemem.h"
|
||||
|
||||
//=====================================
|
||||
// platform export
|
||||
//=====================================
|
||||
|
@ -55,12 +59,13 @@ void _Mem_Copy (void *dest, void *src, size_t size, const char *filename, int fi
|
|||
//=====================================
|
||||
bool FS_LoadScript( const char *name, char *buf, int size );
|
||||
bool FS_AddScript( const char *name, char *buf, int size );
|
||||
bool SC_MatchToken( const char *match );//match token
|
||||
char *SC_GetToken( bool newline ); //unsafe way
|
||||
bool SC_TryToken ( void ); //safe way
|
||||
bool SC_MatchToken( const char *match ); // match token
|
||||
char *SC_GetToken( bool newline ); // unsafe way
|
||||
bool SC_TryToken ( void ); // safe way
|
||||
void SC_SkipToken( void );
|
||||
void SC_FreeToken( void );
|
||||
char *SC_ParseToken(const char **data_p);
|
||||
char *SC_ParseToken(const char **data_p );
|
||||
char *SC_ParseWord( const char **data_p );
|
||||
char *SC_Token( void );
|
||||
|
||||
#endif//BASEPLATFORM_H
|
|
@ -0,0 +1,73 @@
|
|||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: platform - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\Temp\RSPF6D.tmp" with contents
|
||||
[
|
||||
/nologo /ML /W3 /GX /O2 /Ob0 /I "./" /I "../public" /I "./bsplib/" /I "./qcclib" /I "./mdllib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"..\temp\platform\!release/" /Fd"..\temp\platform\!release/" /FD /c
|
||||
"D:\XASH3D\src_main\!source\platform\qcclib\qccmain.c"
|
||||
]
|
||||
Creating command line "cl.exe @C:\Temp\RSPF6D.tmp"
|
||||
Creating temporary file "C:\Temp\RSPF6E.tmp" with contents
|
||||
[
|
||||
kernel32.lib winmm.lib user32.lib /nologo /dll /pdb:none /machine:I386 /out:"..\temp\platform\!release/platform.dll" /implib:"..\temp\platform\!release/platform.lib"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\basemem.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\baseutils.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\brushbsp.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\bspfile.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\csg.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\faces.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\filesystem.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\flow.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\imglib.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\leakfile.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\lightmap.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\map.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\patches.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\platform.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\portals.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\pr_comp.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\pr_lex.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\prtfile.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\qbsp3.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\qcc_utils.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\qccmain.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\qrad3.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\qvis3.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\shaders.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\spritegen.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\studio.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\studio_utils.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\textures.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\trace.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\tree.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\winding.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\writebsp.obj"
|
||||
"\XASH3D\src_main\!source\temp\platform\!release\ziplib.obj"
|
||||
]
|
||||
Creating command line "link.exe @C:\Temp\RSPF6E.tmp"
|
||||
Creating temporary file "C:\Temp\RSPF6F.bat" with contents
|
||||
[
|
||||
@echo off
|
||||
copy \XASH3D\src_main\!source\temp\platform\!release\platform.dll "D:\Xash3D\bin\platform.dll"
|
||||
]
|
||||
Creating command line "C:\Temp\RSPF6F.bat"
|
||||
Compiling...
|
||||
qccmain.c
|
||||
Linking...
|
||||
Creating library ..\temp\platform\!release/platform.lib and object ..\temp\platform\!release/platform.exp
|
||||
<h3>Output Window</h3>
|
||||
Performing Custom Build Step on \XASH3D\src_main\!source\temp\platform\!release\platform.dll
|
||||
‘ª®¯¨à®¢ ® ä ©«®¢: 1.
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
platform.dll - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,327 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// qcc_utils.c - qcc common tools
|
||||
//=======================================================================
|
||||
|
||||
#include "qcclib.h"
|
||||
|
||||
void Hash_InitTable(hashtable_t *table, int numbucks, void *mem)
|
||||
{
|
||||
table->numbuckets = numbucks;
|
||||
table->bucket = (bucket_t **)mem;
|
||||
}
|
||||
|
||||
int Hash_Key(char *name, int modulus)
|
||||
{
|
||||
//fixme: optimize.
|
||||
uint key;
|
||||
for (key = 0; *name; name++)
|
||||
key += ((key<<3) + (key>>28) + *name);
|
||||
|
||||
return (int)(key%modulus);
|
||||
}
|
||||
|
||||
int Hash_KeyInsensative(char *name, int modulus)
|
||||
{
|
||||
//fixme: optimize.
|
||||
uint key;
|
||||
for (key = 0; *name; name++)
|
||||
{
|
||||
if (*name >= 'A' && *name <= 'Z')
|
||||
key += ((key<<3) + (key>>28) + (*name-'A'+'a'));
|
||||
else key += ((key<<3) + (key>>28) + *name);
|
||||
}
|
||||
|
||||
return (int)(key%modulus);
|
||||
}
|
||||
|
||||
void *Hash_Get(hashtable_t *table, char *name)
|
||||
{
|
||||
int bucknum = Hash_Key(name, table->numbuckets);
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
while(buck)
|
||||
{
|
||||
if (!STRCMP(name, buck->keystring))
|
||||
return buck->data;
|
||||
|
||||
buck = buck->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *Hash_GetInsensative(hashtable_t *table, char *name)
|
||||
{
|
||||
int bucknum = Hash_KeyInsensative(name, table->numbuckets);
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
while(buck)
|
||||
{
|
||||
if (!stricmp(name, buck->keystring))
|
||||
return buck->data;
|
||||
|
||||
buck = buck->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *Hash_GetKey(hashtable_t *table, int key)
|
||||
{
|
||||
int bucknum = key%table->numbuckets;
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
while(buck)
|
||||
{
|
||||
if ((int)buck->keystring == key)
|
||||
return buck->data;
|
||||
|
||||
buck = buck->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *Hash_GetNext(hashtable_t *table, char *name, void *old)
|
||||
{
|
||||
int bucknum = Hash_Key(name, table->numbuckets);
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
while(buck)
|
||||
{
|
||||
if (!STRCMP(name, buck->keystring))
|
||||
{
|
||||
if (buck->data == old)//found the old one
|
||||
break;
|
||||
}
|
||||
buck = buck->next;
|
||||
}
|
||||
if (!buck) return NULL;
|
||||
|
||||
buck = buck->next;//don't return old
|
||||
while(buck)
|
||||
{
|
||||
if (!STRCMP(name, buck->keystring))
|
||||
return buck->data;
|
||||
|
||||
buck = buck->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *Hash_GetNextInsensative(hashtable_t *table, char *name, void *old)
|
||||
{
|
||||
int bucknum = Hash_KeyInsensative(name, table->numbuckets);
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
while(buck)
|
||||
{
|
||||
if (!STRCMP(name, buck->keystring))
|
||||
{
|
||||
if (buck->data == old)//found the old one
|
||||
break;
|
||||
}
|
||||
buck = buck->next;
|
||||
}
|
||||
if (!buck)return NULL;
|
||||
|
||||
buck = buck->next;//don't return old
|
||||
while(buck)
|
||||
{
|
||||
if (!STRCMP(name, buck->keystring))
|
||||
return buck->data;
|
||||
|
||||
buck = buck->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *Hash_Add(hashtable_t *table, char *name, void *data, bucket_t *buck)
|
||||
{
|
||||
int bucknum = Hash_Key(name, table->numbuckets);
|
||||
|
||||
buck->data = data;
|
||||
buck->keystring = name;
|
||||
buck->next = table->bucket[bucknum];
|
||||
table->bucket[bucknum] = buck;
|
||||
|
||||
return buck;
|
||||
}
|
||||
|
||||
void *Hash_AddInsensative(hashtable_t *table, char *name, void *data, bucket_t *buck)
|
||||
{
|
||||
int bucknum = Hash_KeyInsensative(name, table->numbuckets);
|
||||
|
||||
buck->data = data;
|
||||
buck->keystring = name;
|
||||
buck->next = table->bucket[bucknum];
|
||||
table->bucket[bucknum] = buck;
|
||||
|
||||
return buck;
|
||||
}
|
||||
|
||||
void *Hash_AddKey(hashtable_t *table, int key, void *data, bucket_t *buck)
|
||||
{
|
||||
int bucknum = key%table->numbuckets;
|
||||
|
||||
buck->data = data;
|
||||
buck->keystring = (char*)key;
|
||||
buck->next = table->bucket[bucknum];
|
||||
table->bucket[bucknum] = buck;
|
||||
|
||||
return buck;
|
||||
}
|
||||
|
||||
void Hash_Remove(hashtable_t *table, char *name)
|
||||
{
|
||||
int bucknum = Hash_Key(name, table->numbuckets);
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
if (!STRCMP(name, buck->keystring))
|
||||
{
|
||||
table->bucket[bucknum] = buck->next;
|
||||
return;
|
||||
}
|
||||
|
||||
while(buck->next)
|
||||
{
|
||||
if (!STRCMP(name, buck->next->keystring))
|
||||
{
|
||||
buck->next = buck->next->next;
|
||||
return;
|
||||
}
|
||||
|
||||
buck = buck->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Hash_RemoveData(hashtable_t *table, char *name, void *data)
|
||||
{
|
||||
int bucknum = Hash_Key(name, table->numbuckets);
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
if (buck->data == data)
|
||||
{
|
||||
if (!STRCMP(name, buck->keystring))
|
||||
{
|
||||
table->bucket[bucknum] = buck->next;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while(buck->next)
|
||||
{
|
||||
if (buck->next->data == data)
|
||||
{
|
||||
if (!STRCMP(name, buck->next->keystring))
|
||||
{
|
||||
buck->next = buck->next->next;
|
||||
return;
|
||||
}
|
||||
}
|
||||
buck = buck->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Hash_RemoveKey(hashtable_t *table, int key)
|
||||
{
|
||||
int bucknum = key%table->numbuckets;
|
||||
bucket_t *buck;
|
||||
|
||||
buck = table->bucket[bucknum];
|
||||
if ((int)buck->keystring == key)
|
||||
{
|
||||
table->bucket[bucknum] = buck->next;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while(buck->next)
|
||||
{
|
||||
if ((int)buck->next->keystring == key)
|
||||
{
|
||||
buck->next = buck->next->next;
|
||||
return;
|
||||
}
|
||||
buck = buck->next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
PR_decode
|
||||
================
|
||||
*/
|
||||
char *PR_decode(int complen, int len, int method, char *info, char *buffer)
|
||||
{
|
||||
int i;
|
||||
if (method == 0) //copy
|
||||
{
|
||||
if (complen != len) Sys_Error("lengths do not match");
|
||||
memcpy(buffer, info, len);
|
||||
}
|
||||
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");
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
PR_encode
|
||||
================
|
||||
*/
|
||||
int PR_encode(int len, int method, char *in, vfile_t *handle)
|
||||
{
|
||||
int i;
|
||||
if (method == 0) //copy
|
||||
{
|
||||
VFS_Write(handle, in, len);
|
||||
return len;
|
||||
}
|
||||
else if (method == 1)//encryption
|
||||
{
|
||||
for (i = 0; i < len; i++) in[i] = in[i] ^ 0xA5;
|
||||
VFS_Write(handle, in, len);
|
||||
return len;
|
||||
}
|
||||
else
|
||||
{
|
||||
Sys_Error("Wierd method");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
byte *PR_LoadFile(char *filename, fs_offset_t *filesizeptr, int type )
|
||||
{
|
||||
char *mem;
|
||||
int len = FS_FileSize(filename);
|
||||
if (!len) Sys_Error("Couldn't open file %s", filename);
|
||||
|
||||
mem = Qalloc(sizeof(cachedsourcefile_t) + len );
|
||||
((cachedsourcefile_t*)mem)->next = sourcefile;
|
||||
sourcefile = (cachedsourcefile_t*)mem;
|
||||
sourcefile->size = len;
|
||||
mem += sizeof(cachedsourcefile_t);
|
||||
strcpy(sourcefile->filename, filename);
|
||||
sourcefile->file = mem;
|
||||
sourcefile->type = type;
|
||||
|
||||
mem = FS_LoadFile( filename, filesizeptr );
|
||||
return mem;
|
||||
}
|
|
@ -0,0 +1,622 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// qcclib.h - qcclib header
|
||||
//=======================================================================
|
||||
#ifndef QCCLIB_H
|
||||
#define QCCLIB_H
|
||||
|
||||
#include "platform.h"
|
||||
#include "baseutils.h"
|
||||
#include "vprogs.h"
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
"stopped at 10 errors"
|
||||
other pointer types for models and clients?
|
||||
compact string heap?
|
||||
always initialize all variables to something safe
|
||||
the def->type->type arrangement is really silly.
|
||||
return type checking
|
||||
parm count type checking
|
||||
immediate overflow checking
|
||||
pass the first two parms in call->b and call->c
|
||||
*/
|
||||
|
||||
#define MEMBERFIELDNAME "__m%s" //mark
|
||||
|
||||
#define MAX_ERRORS 10
|
||||
#define MAX_NAME 64 // chars long
|
||||
#define MAX_PARMS 8
|
||||
#define MAX_PARMS_EXTRA 128
|
||||
|
||||
#define MAX_SOUNDS 2048
|
||||
#define MAX_TEXTURES 1024
|
||||
#define MAX_MODELS 2048
|
||||
#define MAX_FILES 1024
|
||||
|
||||
//compiler flags
|
||||
#define FLAG_KILLSDEBUGGERS 1
|
||||
#define FLAG_ASDEFAULT 2
|
||||
#define FLAG_SETINGUI 4
|
||||
#define FLAG_HIDDENINGUI 8
|
||||
#define FLAG_MIDCOMPILE 16 //option can be changed mid-compile with the special pragma
|
||||
|
||||
#define G_FLOAT(o) (pr_globals[o])
|
||||
#define G_INT(o) (*(int *)&pr_globals[o])
|
||||
#define G_VECTOR(o) (&pr_globals[o])
|
||||
#define G_STRING(o) (strings + *(string_t *)&pr_globals[o])
|
||||
#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
|
||||
|
||||
//qcc private pool
|
||||
#define Qalloc( size ) Mem_Alloc(qccpool, size )
|
||||
#define Qrealloc( ptr, size ) Mem_Realloc(qccpool, ptr, size )
|
||||
|
||||
//loading files
|
||||
#define QCC_LoadFile(f) PR_LoadFile(f, NULL, FT_CODE)
|
||||
#define QCC_LoadData(f) PR_LoadFile(f, NULL, FT_DATA)
|
||||
|
||||
#define BytesForBuckets(b) (sizeof(bucket_t)*b)
|
||||
#define STRCMP(s1, s2) (((*s1)!=(*s2)) || strcmp(s1+1,s2+1))
|
||||
#define STRNCMP(s1, s2, l) (((*s1)!=(*s2)) || strncmp(s1+1,s2+1,l))
|
||||
|
||||
typedef uint gofs_t; // offset in global data block
|
||||
typedef struct function_s function_t;
|
||||
typedef char PATHSTRING[MAX_NAME];
|
||||
|
||||
typedef enum {
|
||||
QCF_STANDARD,
|
||||
QCF_HEXEN2,
|
||||
QCF_FTE,
|
||||
QCF_FTEDEBUG,
|
||||
QCF_KK7
|
||||
} targetformat_t;
|
||||
|
||||
typedef enum {
|
||||
tt_eof, // end of file reached
|
||||
tt_name, // an alphanumeric name token
|
||||
tt_punct, // code punctuation
|
||||
tt_immediate, // string, float, vector
|
||||
} token_type_t;
|
||||
|
||||
typedef struct bucket_s
|
||||
{
|
||||
void *data;
|
||||
char *keystring;
|
||||
struct bucket_s *next;
|
||||
}bucket_t;
|
||||
|
||||
typedef struct hashtable_s
|
||||
{
|
||||
int numbuckets;
|
||||
bucket_t **bucket;
|
||||
}hashtable_t;
|
||||
|
||||
typedef struct cachedsourcefile_s
|
||||
{
|
||||
char filename[128];
|
||||
int size;
|
||||
char *file;
|
||||
enum
|
||||
{
|
||||
FT_CODE, //quakec source
|
||||
FT_DATA, //quakec lib
|
||||
} type;
|
||||
struct cachedsourcefile_s *next;
|
||||
} cachedsourcefile_t;
|
||||
|
||||
struct function_s
|
||||
{
|
||||
int builtin; // if non 0, call an internal function
|
||||
int code; // first statement
|
||||
char *file; // source file with definition
|
||||
int file_line;
|
||||
struct def_s *def;
|
||||
uint parm_ofs[MAX_PARMS];// always contiguous, right?
|
||||
};
|
||||
|
||||
typedef struct temp_s
|
||||
{
|
||||
gofs_t ofs;
|
||||
struct def_s *scope;
|
||||
struct def_s *lastfunc;
|
||||
struct temp_s *next;
|
||||
bool used;
|
||||
uint size;
|
||||
} temp_t;
|
||||
|
||||
typedef union eval_s
|
||||
{
|
||||
string_t string;
|
||||
float _float;
|
||||
float vector[3];
|
||||
func_t function;
|
||||
int _int;
|
||||
union eval_s *ptr;
|
||||
} eval_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool *enabled;
|
||||
char *abbrev;
|
||||
int optimisationlevel;
|
||||
int flags; //1: kills debuggers. 2: applied as default.
|
||||
char *fullname;
|
||||
char *description;
|
||||
void *guiinfo;
|
||||
|
||||
} optimisations_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool *enabled;
|
||||
int flags; //2 applied as default
|
||||
char *abbrev;
|
||||
char *fullname;
|
||||
char *description;
|
||||
void *guiinfo;
|
||||
|
||||
} compiler_flag_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[MAX_NAME];
|
||||
char value[MAX_NAME * 4];
|
||||
char params[MAX_PARMS][32];
|
||||
int numparams;
|
||||
bool used;
|
||||
bool inside;
|
||||
int namelen;
|
||||
} const_t;
|
||||
|
||||
typedef struct type_s
|
||||
{
|
||||
etype_t type;
|
||||
|
||||
struct type_s *parentclass; //type_entity...
|
||||
struct type_s *next;
|
||||
|
||||
struct type_s *aux_type; // return type or field type
|
||||
struct type_s *param;
|
||||
int num_parms; // -1 = variable args
|
||||
uint ofs; //inside a structure.
|
||||
uint size;
|
||||
char *name;
|
||||
} type_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int targetflags; //weather we need to mark the progs as a newer version
|
||||
char *name;
|
||||
char *opname;
|
||||
int priority;
|
||||
enum
|
||||
{
|
||||
ASSOC_LEFT,
|
||||
ASSOC_RIGHT,
|
||||
ASSOC_RIGHT_RESULT
|
||||
|
||||
} associative;
|
||||
struct type_s **type_a;
|
||||
struct type_s **type_b;
|
||||
struct type_s **type_c;
|
||||
} opcode_t;
|
||||
|
||||
typedef struct def_s
|
||||
{
|
||||
type_t *type;
|
||||
char *name;
|
||||
struct def_s *next;
|
||||
struct def_s *nextlocal; //provides a chain of local variables
|
||||
gofs_t ofs; //for the opt_locals_marshalling optimisation.
|
||||
struct def_s *scope; // function the var was defined in, or NULL
|
||||
int initialized; // 1 when a declaration included "= immediate"
|
||||
int constant; // 1 says we can use the value over and over again
|
||||
|
||||
int references;
|
||||
int timescalled; //part of the opt_stripfunctions optimisation.
|
||||
|
||||
int s_file;
|
||||
int s_line;
|
||||
|
||||
int arraysize;
|
||||
bool shared;
|
||||
bool saved;
|
||||
|
||||
temp_t *temp;
|
||||
} def_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *memory;
|
||||
int max_memory;
|
||||
int current_memory;
|
||||
type_t *types;
|
||||
|
||||
def_t def_head; // unused head of linked list
|
||||
def_t *def_tail; // add new defs after this and move it
|
||||
def_t *localvars; // chain of variables which need to be pushed and stuff.
|
||||
|
||||
int size_fields;
|
||||
} pr_info_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
WARN_DEBUGGING,
|
||||
WARN_ERROR,
|
||||
WARN_NOTREFERENCED,
|
||||
WARN_NOTREFERENCEDCONST,
|
||||
WARN_CONFLICTINGRETURNS,
|
||||
WARN_TOOFEWPARAMS,
|
||||
WARN_TOOMANYPARAMS,
|
||||
WARN_UNEXPECTEDPUNCT,
|
||||
WARN_ASSIGNMENTTOCONSTANT,
|
||||
WARN_ASSIGNMENTTOCONSTANTFUNC,
|
||||
WARN_MISSINGRETURNVALUE,
|
||||
WARN_WRONGRETURNTYPE,
|
||||
WARN_POINTLESSSTATEMENT,
|
||||
WARN_MISSINGRETURN,
|
||||
WARN_DUPLICATEDEFINITION,
|
||||
WARN_UNDEFNOTDEFINED,
|
||||
WARN_PRECOMPILERMESSAGE,
|
||||
WARN_TOOMANYPARAMETERSFORFUNC,
|
||||
WARN_STRINGTOOLONG,
|
||||
WARN_BADTARGET,
|
||||
WARN_BADPRAGMA,
|
||||
WARN_HANGINGSLASHR,
|
||||
WARN_NOTDEFINED,
|
||||
WARN_NOTCONSTANT,
|
||||
WARN_SWITCHTYPEMISMATCH,
|
||||
WARN_CONFLICTINGUNIONMEMBER,
|
||||
WARN_KEYWORDDISABLED,
|
||||
WARN_ENUMFLAGS_NOTINTEGER,
|
||||
WARN_ENUMFLAGS_NOTBINARY,
|
||||
WARN_CASEINSENSATIVEFRAMEMACRO,
|
||||
WARN_DUPLICATELABEL,
|
||||
WARN_DUPLICATEMACRO,
|
||||
WARN_ASSIGNMENTINCONDITIONAL,
|
||||
WARN_MACROINSTRING,
|
||||
WARN_BADPARAMS,
|
||||
WARN_IMPLICITCONVERSION,
|
||||
WARN_FIXEDRETURNVALUECONFLICT,
|
||||
WARN_EXTRAPRECACHE,
|
||||
WARN_NOTPRECACHED,
|
||||
WARN_DEADCODE,
|
||||
WARN_UNREACHABLECODE,
|
||||
WARN_NOTSTANDARDBEHAVIOUR,
|
||||
WARN_INEFFICIENTPLUSPLUS,
|
||||
WARN_DUPLICATEPRECOMPILER,
|
||||
WARN_IDENTICALPRECOMPILER,
|
||||
WARN_FTE_SPECIFIC, //extension that only FTEQCC will have a clue about.
|
||||
WARN_EXTENSION_USED, //extension that frikqcc also understands
|
||||
WARN_IFSTRING_USED,
|
||||
WARN_LAXCAST, //some errors become this with a compiler flag
|
||||
WARN_UNDESIRABLECONVENTION,
|
||||
WARN_SAMENAMEASGLOBAL,
|
||||
WARN_CONSTANTCOMPARISON,
|
||||
|
||||
ERR_PARSEERRORS, //caused by pr_parseerror being called.
|
||||
|
||||
//these are definatly my fault...
|
||||
ERR_INTERNAL,
|
||||
ERR_TOOCOMPLEX,
|
||||
ERR_BADOPCODE,
|
||||
ERR_TOOMANYSTATEMENTS,
|
||||
ERR_TOOMANYSTRINGS,
|
||||
ERR_BADTARGETSWITCH,
|
||||
ERR_TOOMANYTYPES,
|
||||
ERR_TOOMANYPAKFILES,
|
||||
ERR_PRECOMPILERCONSTANTTOOLONG,
|
||||
ERR_MACROTOOMANYPARMS,
|
||||
ERR_CONSTANTTOOLONG,
|
||||
ERR_TOOMANYFRAMEMACROS,
|
||||
|
||||
//limitations, some are imposed by compiler, some arn't.
|
||||
ERR_TOOMANYGLOBALS,
|
||||
ERR_TOOMANYGOTOS,
|
||||
ERR_TOOMANYBREAKS,
|
||||
ERR_TOOMANYCONTINUES,
|
||||
ERR_TOOMANYCASES,
|
||||
ERR_TOOMANYLABELS,
|
||||
ERR_TOOMANYOPENFILES,
|
||||
ERR_TOOMANYPARAMETERSVARARGS,
|
||||
ERR_TOOMANYTOTALPARAMETERS,
|
||||
|
||||
//these are probably yours, or qcc being fussy.
|
||||
ERR_BADEXTENSION,
|
||||
ERR_BADIMMEDIATETYPE,
|
||||
ERR_NOOUTPUT,
|
||||
ERR_NOTAFUNCTION,
|
||||
ERR_FUNCTIONWITHVARGS,
|
||||
ERR_BADHEX,
|
||||
ERR_UNKNOWNPUCTUATION,
|
||||
ERR_EXPECTED,
|
||||
ERR_NOTANAME,
|
||||
ERR_NAMETOOLONG,
|
||||
ERR_NOFUNC,
|
||||
ERR_COULDNTOPENFILE,
|
||||
ERR_NOTFUNCTIONTYPE,
|
||||
ERR_TOOFEWPARAMS,
|
||||
ERR_TOOMANYPARAMS,
|
||||
ERR_CONSTANTNOTDEFINED,
|
||||
ERR_BADFRAMEMACRO,
|
||||
ERR_TYPEMISMATCH,
|
||||
ERR_TYPEMISMATCHREDEC,
|
||||
ERR_TYPEMISMATCHPARM,
|
||||
ERR_TYPEMISMATCHARRAYSIZE,
|
||||
ERR_UNEXPECTEDPUNCTUATION,
|
||||
ERR_NOTACONSTANT,
|
||||
ERR_REDECLARATION,
|
||||
ERR_INITIALISEDLOCALFUNCTION,
|
||||
ERR_NOTDEFINED,
|
||||
ERR_ARRAYNEEDSSIZE,
|
||||
ERR_ARRAYNEEDSBRACES,
|
||||
ERR_TOOMANYINITIALISERS,
|
||||
ERR_TYPEINVALIDINSTRUCT,
|
||||
ERR_NOSHAREDLOCALS,
|
||||
ERR_TYPEWITHNONAME,
|
||||
ERR_BADARRAYSIZE,
|
||||
ERR_NONAME,
|
||||
ERR_SHAREDINITIALISED,
|
||||
ERR_UNKNOWNVALUE,
|
||||
ERR_BADARRAYINDEXTYPE,
|
||||
ERR_NOVALIDOPCODES,
|
||||
ERR_MEMBERNOTVALID,
|
||||
ERR_BADPLUSPLUSOPERATOR,
|
||||
ERR_BADNOTTYPE,
|
||||
ERR_BADTYPECAST,
|
||||
ERR_MULTIPLEDEFAULTS,
|
||||
ERR_CASENOTIMMEDIATE,
|
||||
ERR_BADSWITCHTYPE,
|
||||
ERR_BADLABELNAME,
|
||||
ERR_NOLABEL,
|
||||
ERR_THINKTIMETYPEMISMATCH,
|
||||
ERR_STATETYPEMISMATCH,
|
||||
ERR_BADBUILTINIMMEDIATE,
|
||||
ERR_PARAMWITHNONAME,
|
||||
ERR_BADPARAMORDER,
|
||||
ERR_ILLEGALCONTINUES,
|
||||
ERR_ILLEGALBREAKS,
|
||||
ERR_ILLEGALCASES,
|
||||
ERR_NOTANUMBER,
|
||||
ERR_WRONGSUBTYPE,
|
||||
ERR_EOF,
|
||||
ERR_NOPRECOMPILERIF,
|
||||
ERR_NOENDIF,
|
||||
ERR_HASHERROR,
|
||||
ERR_NOTATYPE,
|
||||
ERR_TOOMANYPACKFILES,
|
||||
ERR_INVALIDVECTORIMMEDIATE,
|
||||
ERR_INVALIDSTRINGIMMEDIATE,
|
||||
ERR_BADCHARACTURECODE,
|
||||
ERR_BADPARMS,
|
||||
|
||||
WARN_MAX,
|
||||
};
|
||||
|
||||
|
||||
extern pr_info_t pr;
|
||||
extern byte *qccpool;
|
||||
extern file_t *asmfile;
|
||||
extern uint MAX_REGS;
|
||||
extern int MAX_STRINGS;
|
||||
extern int MAX_GLOBALS;
|
||||
extern int MAX_FIELDS;
|
||||
extern int MAX_STATEMENTS;
|
||||
extern int MAX_FUNCTIONS;
|
||||
extern int MAX_CONSTANTS;
|
||||
extern type_t *type_void;
|
||||
extern type_t *type_string;
|
||||
extern type_t *type_float;
|
||||
extern type_t *type_vector;
|
||||
extern type_t *type_entity;
|
||||
extern type_t *type_field;
|
||||
extern type_t *type_function;
|
||||
extern type_t *type_pointer;
|
||||
extern type_t *type_integer;
|
||||
extern type_t *type_variant;
|
||||
extern type_t *type_floatfield;
|
||||
extern targetformat_t targetformat;
|
||||
extern cachedsourcefile_t *sourcefile;
|
||||
extern optimisations_t optimisations[];
|
||||
extern compiler_flag_t compiler_flag[];
|
||||
extern char v_copyright[1024];
|
||||
extern hashtable_t compconstantstable;
|
||||
extern hashtable_t globalstable, localstable;
|
||||
extern opcode_t pr_opcodes[]; // sized by initialization
|
||||
const extern int type_size[];
|
||||
extern const_t *CompilerConstant;
|
||||
extern bool pr_dumpasm;
|
||||
extern char pr_token[8192];
|
||||
extern token_type_t pr_token_type;
|
||||
extern type_t *pr_immediate_type;
|
||||
extern eval_t pr_immediate;
|
||||
|
||||
//keywords
|
||||
extern bool keyword_asm;
|
||||
extern bool keyword_break;
|
||||
extern bool keyword_case;
|
||||
extern bool keyword_class;
|
||||
extern bool keyword_const;
|
||||
extern bool keyword_continue;
|
||||
extern bool keyword_default;
|
||||
extern bool keyword_do;
|
||||
extern bool keyword_entity;
|
||||
extern bool keyword_float;
|
||||
extern bool keyword_for;
|
||||
extern bool keyword_goto;
|
||||
extern bool keyword_int;
|
||||
extern bool keyword_integer;
|
||||
extern bool keyword_state;
|
||||
extern bool keyword_string;
|
||||
extern bool keyword_struct;
|
||||
extern bool keyword_switch;
|
||||
extern bool keyword_thinktime;
|
||||
extern bool keyword_var;
|
||||
extern bool keyword_vector;
|
||||
extern bool keyword_union;
|
||||
extern bool keyword_enum; //kinda like in c, but typedef not supported.
|
||||
extern bool keyword_enumflags; //like enum, but doubles instead of adds 1.
|
||||
extern bool keyword_typedef; //fixme
|
||||
extern bool keyword_extern; //function is external, don't error or warn if the body was not found
|
||||
extern bool keyword_shared; //mark global to be copied over when progs changes (part of FTE_MULTIPROGS)
|
||||
extern bool keyword_noref; //nowhere else references this, don't strip it.
|
||||
extern bool keyword_nosave; //don't write the def to the output.
|
||||
extern bool keyword_union; //you surly know what a union is!
|
||||
extern bool keywords_coexist;
|
||||
|
||||
//compiler flags
|
||||
extern bool output_parms;
|
||||
extern bool autoprototype;
|
||||
extern bool flag_ifstring;
|
||||
extern bool flag_laxcasts;
|
||||
extern bool flag_hashonly;
|
||||
extern bool flag_fasttrackarrays;
|
||||
extern bool opt_overlaptemps;
|
||||
extern bool opt_shortenifnots;
|
||||
extern bool opt_noduplicatestrings;
|
||||
extern bool opt_constantarithmatic;
|
||||
extern bool opt_nonvec_parms;
|
||||
extern bool opt_constant_names;
|
||||
extern bool opt_precache_file;
|
||||
extern bool opt_filenames;
|
||||
extern bool opt_assignments;
|
||||
extern bool opt_unreferenced;
|
||||
extern bool opt_function_names;
|
||||
extern bool opt_locals;
|
||||
extern bool opt_dupconstdefs;
|
||||
extern bool opt_constant_names_strings;
|
||||
extern bool opt_return_only;
|
||||
extern bool opt_compound_jumps;
|
||||
extern bool opt_stripfunctions;
|
||||
extern bool opt_locals_marshalling;
|
||||
extern bool opt_logicops;
|
||||
extern bool opt_vectorcalls;
|
||||
extern int optres_shortenifnots;
|
||||
extern int optres_overlaptemps;
|
||||
extern int optres_noduplicatestrings;
|
||||
extern int optres_constantarithmatic;
|
||||
extern int optres_nonvec_parms;
|
||||
extern int optres_constant_names;
|
||||
extern int optres_precache_file;
|
||||
extern int optres_filenames;
|
||||
extern int optres_assignments;
|
||||
extern int optres_unreferenced;
|
||||
extern int optres_function_names;
|
||||
extern int optres_locals;
|
||||
extern int optres_dupconstdefs;
|
||||
extern int optres_constant_names_strings;
|
||||
extern int optres_return_only;
|
||||
extern int optres_compound_jumps;
|
||||
extern int optres_stripfunctions;
|
||||
extern int optres_locals_marshalling;
|
||||
extern int optres_logicops;
|
||||
extern bool pr_warning[WARN_MAX];
|
||||
extern char pr_parm_names[MAX_PARMS + MAX_PARMS_EXTRA][MAX_NAME];
|
||||
extern def_t *extra_parms[MAX_PARMS_EXTRA];
|
||||
extern jmp_buf pr_parse_abort; // longjump with this on parse error
|
||||
extern int pr_source_line;
|
||||
extern char *pr_file_p;
|
||||
extern def_t *pr_scope;
|
||||
extern int pr_error_count;
|
||||
extern int pr_warning_count;
|
||||
extern bool pr_dumpasm;
|
||||
extern string_t s_file; // filename for function definition
|
||||
extern def_t def_ret;
|
||||
extern def_t def_parms[MAX_PARMS];
|
||||
extern char pr_immediate_string[8192];
|
||||
extern float *pr_globals;
|
||||
extern uint numpr_globals;
|
||||
extern char *strings;
|
||||
extern int strofs;
|
||||
extern dstatement_t *statements;
|
||||
extern int numstatements;
|
||||
extern int *statement_linenums;
|
||||
extern dfunction_t *functions;
|
||||
extern int numfunctions;
|
||||
extern ddef_t *qcc_globals;
|
||||
extern int numglobaldefs;
|
||||
extern def_t *activetemps;
|
||||
extern ddef_t *fields;
|
||||
extern int numfielddefs;
|
||||
extern type_t *qcc_typeinfo;
|
||||
extern int numtypeinfos;
|
||||
extern int maxtypeinfos;
|
||||
extern int *qcc_tempofs;
|
||||
extern int max_temps;
|
||||
extern int tempsstart;
|
||||
extern int numtemps;
|
||||
|
||||
//hash.c
|
||||
extern int typecmp(type_t *a, type_t *b);
|
||||
void Hash_InitTable(hashtable_t *table, int numbucks, void *mem);
|
||||
int Hash_Key(char *name, int modulus);
|
||||
void *Hash_Get(hashtable_t *table, char *name);
|
||||
void *Hash_GetKey(hashtable_t *table, int key);
|
||||
void *Hash_GetInsensative(hashtable_t *table, char *name);
|
||||
void Hash_Remove(hashtable_t *table, char *name);
|
||||
void Hash_RemoveKey(hashtable_t *table, int key);
|
||||
void *Hash_GetNext(hashtable_t *table, char *name, void *old);
|
||||
void Hash_RemoveData(hashtable_t *table, char *name, void *data);
|
||||
void *Hash_GetNextInsensative(hashtable_t *table, char *name, void *old);
|
||||
void *Hash_Add(hashtable_t *table, char *name, void *data, bucket_t *buck);
|
||||
void *Hash_AddKey(hashtable_t *table, int key, void *data, bucket_t *buck);
|
||||
void *Hash_AddInsensative(hashtable_t *table, char *name, void *data, bucket_t *buck);
|
||||
void *(*pHash_Get)(hashtable_t *table, char *name);
|
||||
void *(*pHash_GetNext)(hashtable_t *table, char *name, void *old);
|
||||
void *(*pHash_Add)(hashtable_t *table, char *name, void *data, bucket_t *);
|
||||
|
||||
//pr_comp.c
|
||||
void PR_Lex( void );
|
||||
bool PR_UnInclude( void );
|
||||
void PR_PrintDefs( void );
|
||||
char *PR_ParseName( void );
|
||||
int PR_CopyString (char *str);
|
||||
void PR_Expect (char *string);
|
||||
char *TypeName( type_t *type );
|
||||
void PR_ResetErrorScope( void );
|
||||
void PR_SkipToSemicolon( void );
|
||||
type_t *TypeForName(char *name);
|
||||
void PR_ClearGrabMacros( void );
|
||||
void PR_NewLine (bool incomment);
|
||||
int PR_WarningForName(char *name);
|
||||
bool PR_CheckToken (char *string);
|
||||
bool PR_CheckName (char *string);
|
||||
const_t *PR_DefineName(char *name);
|
||||
type_t *PR_ParseType (int newtype);
|
||||
void PR_PrintStatement (dstatement_t *s);
|
||||
char *PR_ValueString (etype_t type, void *val);
|
||||
type_t *PR_NewType (char *name, int basictype);
|
||||
bool PR_CompileFile (char *string, char *filename);
|
||||
void PR_ParsePrintDef (int warningtype, def_t *def);
|
||||
void PR_ParseError (int errortype, char *error, ...);
|
||||
bool PR_CheckKeyword(int keywordenabled, char *string);
|
||||
void PR_ParseWarning (int warningtype, char *error, ...);
|
||||
void PR_EmitClassFromFunction(def_t *scope, char *tname);
|
||||
int PR_encode( int len, int method, char *in, vfile_t *handle);
|
||||
void PR_EmitArrayGetFunction(def_t *scope, char *arrayname);
|
||||
void PR_EmitArraySetFunction(def_t *scope, char *arrayname);
|
||||
type_t *PR_ParseFunctionType (int newtype, type_t *returntype);
|
||||
void PR_IncludeChunk (char *data, bool duplicate, char *filename);
|
||||
void PR_Warning (int type, char *file, int line, char *error, ...);
|
||||
byte *PR_LoadFile(char *filename, fs_offset_t *filesizeptr, int type );
|
||||
void PR_ParseErrorPrintDef (int errortype, def_t *def, char *error, ...);
|
||||
char *PR_decode( int complen, int len, int method, char *info, char *buffer);
|
||||
def_t *PR_GetDef (type_t *type, char *name, def_t *scope, bool allocate, int arraysize);
|
||||
void PR_RemapOffsets(uint firststatement, uint laststatement, uint min, uint max, uint newmin);
|
||||
|
||||
//pr_utils
|
||||
bool PrepareDATProgs ( const char *dir, const char *name, byte params );
|
||||
bool CompileDATProgs ( void );
|
||||
|
||||
//debug info about used recources
|
||||
PATHSTRING *precache_sounds;
|
||||
PATHSTRING *precache_files;
|
||||
PATHSTRING *precache_textures;
|
||||
PATHSTRING *precache_models;
|
||||
int numsounds;
|
||||
int numtextures;
|
||||
int nummodels;
|
||||
int numfiles;
|
||||
|
||||
#endif//QCCLIB_H
|
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@
|
|||
#define PUP(a) *(a)++
|
||||
|
||||
typedef byte* (*alloc_func)();
|
||||
typedef void (*free_func)();
|
||||
typedef void (*free_func) ();
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -89,34 +89,34 @@ struct inflate_state
|
|||
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)
|
||||
unsigned dmax; // zlib header max distance (INFLATE_STRICT)
|
||||
unsigned long check; // protected copy of check value
|
||||
unsigned long total; // protected copy of output count
|
||||
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
|
||||
unsigned wbits; // log base 2 of requested window size
|
||||
unsigned wsize; // window size or zero if not using window
|
||||
unsigned whave; // valid bytes in the window
|
||||
unsigned write; // window write index
|
||||
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
|
||||
unsigned bits; // number of bits in "in"
|
||||
uint bits; // number of bits in "in"
|
||||
// for string and stored block copying
|
||||
unsigned length; // literal or length of data to copy
|
||||
unsigned offset; // distance back to copy string from
|
||||
uint length; // literal or length of data to copy
|
||||
uint offset; // distance back to copy string from
|
||||
// for table and code decoding
|
||||
unsigned extra; // extra bits needed
|
||||
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
|
||||
unsigned lenbits; // index bits for lencode
|
||||
unsigned distbits; // index bits for distcode
|
||||
uint lenbits; // index bits for lencode
|
||||
uint distbits; // index bits for distcode
|
||||
// dynamic table building
|
||||
unsigned ncode; // number of code length code lengths
|
||||
unsigned nlen; // number of length code lengths
|
||||
unsigned ndist; // number of distance code lengths
|
||||
unsigned have; // number of code lengths in lens[]
|
||||
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
|
||||
|
@ -163,7 +163,7 @@ typedef z_stream *z_streamp;
|
|||
#define Z_DEFLATED 8
|
||||
|
||||
//exported functions
|
||||
unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned len); //crc32
|
||||
unsigned long crc32(dword crc, const byte *buf, uint len);// crc32
|
||||
unsigned long adler32(dword adler, const byte *buf, dword len);
|
||||
extern int inflate(z_streamp strm, int flush);
|
||||
extern int inflateEnd(z_streamp strm);
|
|
@ -4,6 +4,7 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "platform.h"
|
||||
#include "baseutils.h"
|
||||
#include "zip32.h"
|
||||
|
||||
#define BASE 65521UL // largest prime smaller than 65536
|
||||
|
@ -24,16 +25,14 @@
|
|||
#define MOD4(a) a %= BASE
|
||||
|
||||
//memory opertions
|
||||
byte* zcalloc (byte* opaque, unsigned items, unsigned size)
|
||||
byte* zcalloc (byte* opaque, uint items, uint size)
|
||||
{
|
||||
if (opaque) items += size - size; // make compiler happy
|
||||
return sizeof(dword) > 2 ? (byte*)malloc(items * size) : (byte*)calloc(items, size);
|
||||
return (byte *)Malloc( items * size );
|
||||
}
|
||||
|
||||
void zcfree (byte* opaque, byte* ptr)
|
||||
{
|
||||
free(ptr);
|
||||
if (opaque) return; /* make compiler happy */
|
||||
Free( ptr );
|
||||
}
|
||||
|
||||
static const code lenfix[512] = {
|
||||
|
@ -122,86 +121,12 @@ static const code distfix[32] = {
|
|||
{22,5,193},{64,5,0}
|
||||
};
|
||||
|
||||
//crc32 table
|
||||
const unsigned long crc_table[1][256] = {
|
||||
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
|
||||
0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
|
||||
0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
|
||||
0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
|
||||
0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
|
||||
0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
|
||||
0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
|
||||
0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
|
||||
0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
|
||||
0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
|
||||
0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
|
||||
0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
|
||||
0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
|
||||
0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
|
||||
0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
|
||||
0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
|
||||
0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
|
||||
0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
|
||||
0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
|
||||
0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
|
||||
0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
|
||||
0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
|
||||
0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
|
||||
0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
|
||||
0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
|
||||
0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
|
||||
0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
|
||||
0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
|
||||
0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
|
||||
0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
|
||||
0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
|
||||
0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
|
||||
0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
|
||||
0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
|
||||
0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
|
||||
0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
|
||||
0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
|
||||
0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
|
||||
0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
|
||||
0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
|
||||
0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
|
||||
0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
|
||||
0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
|
||||
0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
|
||||
0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
|
||||
0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
|
||||
0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
|
||||
0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
|
||||
0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
|
||||
0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
|
||||
0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
|
||||
0x2d02ef8dUL
|
||||
};
|
||||
|
||||
unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned len)
|
||||
{
|
||||
if (buf == NULL) return 0UL;
|
||||
|
||||
crc = crc ^ 0xffffffffUL;
|
||||
while (len >= 8)
|
||||
{
|
||||
DO8;
|
||||
len -= 8;
|
||||
}
|
||||
if (len) do
|
||||
{
|
||||
DO1;
|
||||
}while (--len);
|
||||
|
||||
return crc ^ 0xffffffffUL;
|
||||
}
|
||||
|
||||
dword adler32(dword adler, const byte *buf, dword len)
|
||||
{
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
dword sum2;
|
||||
uint n;
|
||||
|
||||
/* split Adler-32 into component sums */
|
||||
// split Adler-32 into component sums
|
||||
sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
|
@ -228,25 +153,25 @@ dword adler32(dword adler, const byte *buf, dword len)
|
|||
}
|
||||
|
||||
if (adler >= BASE) adler -= BASE;
|
||||
MOD4(sum2); /* only added so many BASE's */
|
||||
MOD4(sum2); // only added so many BASE's
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* do length NMAX blocks -- requires just one modulo operation */
|
||||
// do length NMAX blocks -- requires just one modulo operation
|
||||
while (len >= NMAX)
|
||||
{
|
||||
len -= NMAX;
|
||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
||||
n = NMAX / 16; // NMAX is divisible by 16
|
||||
do
|
||||
{
|
||||
ADO16(buf); /* 16 sums unrolled */
|
||||
buf += 16;
|
||||
}while (--n);
|
||||
ADO16(buf); // 16 sums unrolled
|
||||
buf += 16;
|
||||
} while (--n);
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
||||
// do remaining bytes (less than NMAX, still just one modulo)
|
||||
if (len) // avoid modulos if none remaining
|
||||
{
|
||||
while (len >= 16)
|
||||
|
@ -529,7 +454,7 @@ int inflate_table(codetype type, unsigned short *lens, unsigned codes, code **ta
|
|||
else huff = 0;
|
||||
}
|
||||
|
||||
/* set return parameters */
|
||||
// set return parameters
|
||||
*table += used;
|
||||
*bits = root;
|
||||
return 0;
|
||||
|
@ -538,8 +463,8 @@ int inflate_table(codetype type, unsigned short *lens, unsigned codes, code **ta
|
|||
void inflate_fast(z_streamp strm, unsigned start)
|
||||
{
|
||||
struct inflate_state *state;
|
||||
unsigned char *in; /* local strm->next_in */
|
||||
unsigned char *last; /* while in < last, enough input available */
|
||||
byte *in; /* local strm->next_in */
|
||||
byte *last; /* while in < last, enough input available */
|
||||
unsigned char *out; /* local strm->next_out */
|
||||
unsigned char *beg; /* inflate()'s initial strm->next_out */
|
||||
unsigned char *end; /* while out < end, enough space available */
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#pragma warning(disable : 4244) // MIPS
|
||||
#pragma warning(disable : 4018) // signed/unsigned mismatch
|
||||
#pragma warning(disable : 4305) // truncation from const double to float
|
||||
#pragma warning(disable : 4201) // nameless struct/union
|
||||
#pragma warning(disable : 4514) // unreferenced inline function removed
|
||||
#pragma warning(disable : 4100) // unreferenced formal parameter
|
||||
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#define DLLIMPORT __declspec(dllimport)
|
||||
|
@ -30,8 +33,8 @@
|
|||
#define YAW 1
|
||||
#define ROLL 2
|
||||
|
||||
typedef enum{false, true} bool;
|
||||
typedef unsigned char byte;
|
||||
typedef enum {false, true} bool;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned long dword;
|
||||
typedef unsigned int uint;
|
||||
|
@ -39,9 +42,13 @@ typedef signed __int64 int64;
|
|||
typedef struct file_s file_t;
|
||||
typedef struct vfile_s vfile_t;
|
||||
typedef struct edict_s edict_t;
|
||||
typedef struct gclient_s gclient_t;
|
||||
typedef int func_t;
|
||||
typedef struct image_s image_t;
|
||||
typedef struct model_s model_t;
|
||||
typedef int string_t;
|
||||
typedef struct gclient_s gclient_t;
|
||||
typedef int progsnum_t;
|
||||
typedef struct progfuncs_s progfuncs_t;
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec3_t[3];
|
||||
typedef vec_t vec4_t[4];
|
||||
|
@ -56,7 +63,6 @@ typedef struct { byte r; byte g; byte b; byte a; } color32;
|
|||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef O_NONBLOCK
|
||||
#define O_NONBLOCK 0
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,13 @@
|
|||
#define BSP_ONLYRAD 0x04
|
||||
#define BSP_FULLCOMPILE 0x08
|
||||
|
||||
//qcclib compile flags
|
||||
#define QCC_PROGDEFS 0x01
|
||||
#define QCC_OPT_LEVEL_0 0x02
|
||||
#define QCC_OPT_LEVEL_1 0x04
|
||||
#define QCC_OPT_LEVEL_2 0x08
|
||||
#define QCC_OPT_LEVEL_3 0x10
|
||||
|
||||
#define MAX_DLIGHTS 32
|
||||
#define MAX_ENTITIES 128
|
||||
#define MAX_PARTICLES 4096
|
||||
|
@ -424,7 +431,8 @@ typedef struct scriptsystem_api_s
|
|||
void (*FreeToken)( void ); // free current token to may get it again
|
||||
void (*SkipToken)( void ); // skip current token and jump into newline
|
||||
bool (*MatchToken)( const char *match ); // compare current token with user keyword
|
||||
char *(*ParseToken)(const char **data_p); // parse token from char buffer
|
||||
char *(*ParseToken)(const char **data ); // parse token from char buffer
|
||||
char *(*ParseWord)( const char **data ); // parse word from char buffer
|
||||
|
||||
} scriptsystem_api_t;
|
||||
|
||||
|
@ -488,7 +496,8 @@ typedef struct compilers_api_s
|
|||
bool (*Sprite)( byte *mempool, const char *name, byte parms ); // input name of qc-script
|
||||
bool (*PrepareBSP)( const char *dir, const char *name, byte params ); // compile map in gamedir
|
||||
bool (*BSP)( void );
|
||||
|
||||
bool (*PrepareDAT)( const char *dir, const char *name, byte params ); // compile dat in gamedir
|
||||
bool (*DAT)( void );
|
||||
} compilers_api_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,456 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// vprogs.h - virtual machine header
|
||||
//=======================================================================
|
||||
#ifndef VPROGS_H
|
||||
#define VPROGS_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
VIRTUAL MACHINE
|
||||
|
||||
a internal virtual machine like as QuakeC, but it has more extensions
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#define PROG_EXTENDEDVERSION 7//remove
|
||||
|
||||
//header
|
||||
#define VPROGS_VERSION 6
|
||||
#define VPROGSHEADER16 (('6'<<24)+('1'<<16)+('C'<<8)+'Q') // little-endian "QC16"
|
||||
#define VPROGSHEADER32 (('2'<<24)+('3'<<16)+('C'<<8)+'Q') // little-endian "QC32"
|
||||
|
||||
//global ofssets
|
||||
#define OFS_NULL 0
|
||||
#define OFS_RETURN 1
|
||||
#define OFS_PARM0 4
|
||||
#define OFS_PARM1 7
|
||||
#define OFS_PARM2 10
|
||||
#define OFS_PARM3 13
|
||||
#define OFS_PARM4 16
|
||||
#define OFS_PARM5 19
|
||||
#define OFS_PARM6 22
|
||||
#define OFS_PARM7 25
|
||||
#define RESERVED_OFS 28
|
||||
|
||||
|
||||
#define DEF_SHARED (1<<14)
|
||||
#define DEF_SAVEGLOBAL (1<<15)
|
||||
|
||||
|
||||
#define MAX_PARMS 8
|
||||
|
||||
#define dstatement_t dstatement16_t
|
||||
#define ddef_t ddef16_t //these should be the same except the string type
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ev_void,
|
||||
ev_string,
|
||||
ev_float,
|
||||
ev_vector,
|
||||
ev_entity,
|
||||
ev_field,
|
||||
ev_function,
|
||||
ev_pointer,
|
||||
ev_integer,
|
||||
ev_variant,
|
||||
ev_struct,
|
||||
ev_union,
|
||||
} etype_t;
|
||||
|
||||
enum {
|
||||
OP_DONE, // 0
|
||||
OP_MUL_F,
|
||||
OP_MUL_V,
|
||||
OP_MUL_FV,
|
||||
OP_MUL_VF,
|
||||
OP_DIV_F,
|
||||
OP_ADD_F,
|
||||
OP_ADD_V,
|
||||
OP_SUB_F,
|
||||
OP_SUB_V,
|
||||
|
||||
OP_EQ_F, // 10
|
||||
OP_EQ_V,
|
||||
OP_EQ_S,
|
||||
OP_EQ_E,
|
||||
OP_EQ_FNC,
|
||||
|
||||
OP_NE_F,
|
||||
OP_NE_V,
|
||||
OP_NE_S,
|
||||
OP_NE_E,
|
||||
OP_NE_FNC,
|
||||
|
||||
OP_LE, // 20
|
||||
OP_GE,
|
||||
OP_LT,
|
||||
OP_GT,
|
||||
|
||||
OP_LOAD_F,
|
||||
OP_LOAD_V,
|
||||
OP_LOAD_S,
|
||||
OP_LOAD_ENT,
|
||||
OP_LOAD_FLD,
|
||||
OP_LOAD_FNC,
|
||||
|
||||
OP_ADDRESS, // 30
|
||||
|
||||
OP_STORE_F,
|
||||
OP_STORE_V,
|
||||
OP_STORE_S,
|
||||
OP_STORE_ENT,
|
||||
OP_STORE_FLD,
|
||||
OP_STORE_FNC,
|
||||
|
||||
OP_STOREP_F,
|
||||
OP_STOREP_V,
|
||||
OP_STOREP_S,
|
||||
OP_STOREP_ENT, // 40
|
||||
OP_STOREP_FLD,
|
||||
OP_STOREP_FNC,
|
||||
|
||||
OP_RETURN,
|
||||
OP_NOT_F,
|
||||
OP_NOT_V,
|
||||
OP_NOT_S,
|
||||
OP_NOT_ENT,
|
||||
OP_NOT_FNC,
|
||||
OP_IF,
|
||||
OP_IFNOT, // 50
|
||||
OP_CALL0, // careful... hexen2 and q1 have different calling conventions
|
||||
OP_CALL1, // remap hexen2 calls to OP_CALL2H
|
||||
OP_CALL2,
|
||||
OP_CALL3,
|
||||
OP_CALL4,
|
||||
OP_CALL5,
|
||||
OP_CALL6,
|
||||
OP_CALL7,
|
||||
OP_CALL8,
|
||||
OP_STATE, // 60
|
||||
OP_GOTO,
|
||||
OP_AND,
|
||||
OP_OR,
|
||||
|
||||
OP_BITAND,
|
||||
OP_BITOR,
|
||||
|
||||
// these following ones are Hexen 2 constants.
|
||||
|
||||
OP_MULSTORE_F,
|
||||
OP_MULSTORE_V,
|
||||
OP_MULSTOREP_F,
|
||||
OP_MULSTOREP_V,
|
||||
|
||||
OP_DIVSTORE_F, // 70
|
||||
OP_DIVSTOREP_F,
|
||||
|
||||
OP_ADDSTORE_F,
|
||||
OP_ADDSTORE_V,
|
||||
OP_ADDSTOREP_F,
|
||||
OP_ADDSTOREP_V,
|
||||
|
||||
OP_SUBSTORE_F,
|
||||
OP_SUBSTORE_V,
|
||||
OP_SUBSTOREP_F,
|
||||
OP_SUBSTOREP_V,
|
||||
|
||||
OP_FETCH_GBL_F, // 80
|
||||
OP_FETCH_GBL_V,
|
||||
OP_FETCH_GBL_S,
|
||||
OP_FETCH_GBL_E,
|
||||
OP_FETCH_GBL_FNC,
|
||||
|
||||
OP_CSTATE,
|
||||
OP_CWSTATE,
|
||||
|
||||
OP_THINKTIME,
|
||||
|
||||
OP_BITSET,
|
||||
OP_BITSETP,
|
||||
OP_BITCLR, // 90
|
||||
OP_BITCLRP,
|
||||
|
||||
OP_RAND0,
|
||||
OP_RAND1,
|
||||
OP_RAND2,
|
||||
OP_RANDV0,
|
||||
OP_RANDV1,
|
||||
OP_RANDV2,
|
||||
|
||||
OP_SWITCH_F,
|
||||
OP_SWITCH_V,
|
||||
OP_SWITCH_S, // 100
|
||||
OP_SWITCH_E,
|
||||
OP_SWITCH_FNC,
|
||||
|
||||
OP_CASE,
|
||||
OP_CASERANGE,
|
||||
|
||||
// the rest are added
|
||||
// mostly they are various different ways of adding two vars with conversions.
|
||||
|
||||
OP_CALL1H,
|
||||
OP_CALL2H,
|
||||
OP_CALL3H,
|
||||
OP_CALL4H,
|
||||
OP_CALL5H,
|
||||
OP_CALL6H, // 110
|
||||
OP_CALL7H,
|
||||
OP_CALL8H,
|
||||
|
||||
|
||||
OP_STORE_I,
|
||||
OP_STORE_IF,
|
||||
OP_STORE_FI,
|
||||
|
||||
OP_ADD_I,
|
||||
OP_ADD_FI,
|
||||
OP_ADD_IF, // 110
|
||||
|
||||
OP_SUB_I,
|
||||
OP_SUB_FI,
|
||||
OP_SUB_IF,
|
||||
|
||||
OP_CONV_ITOF,
|
||||
OP_CONV_FTOI,
|
||||
OP_CP_ITOF,
|
||||
OP_CP_FTOI,
|
||||
OP_LOAD_I,
|
||||
OP_STOREP_I,
|
||||
OP_STOREP_IF, // 120
|
||||
OP_STOREP_FI,
|
||||
|
||||
OP_BITAND_I,
|
||||
OP_BITOR_I,
|
||||
|
||||
OP_MUL_I,
|
||||
OP_DIV_I,
|
||||
OP_EQ_I,
|
||||
OP_NE_I,
|
||||
|
||||
OP_IFNOTS,
|
||||
OP_IFS,
|
||||
|
||||
OP_NOT_I, // 130
|
||||
|
||||
OP_DIV_VF,
|
||||
|
||||
OP_POWER_I,
|
||||
OP_RSHIFT_I,
|
||||
OP_LSHIFT_I,
|
||||
|
||||
OP_GLOBALADDRESS,
|
||||
OP_POINTER_ADD, // 32 bit pointers
|
||||
|
||||
OP_LOADA_F,
|
||||
OP_LOADA_V,
|
||||
OP_LOADA_S,
|
||||
OP_LOADA_ENT, // 140
|
||||
OP_LOADA_FLD,
|
||||
OP_LOADA_FNC,
|
||||
OP_LOADA_I,
|
||||
|
||||
OP_STORE_P,
|
||||
OP_LOAD_P,
|
||||
|
||||
OP_LOADP_F,
|
||||
OP_LOADP_V,
|
||||
OP_LOADP_S,
|
||||
OP_LOADP_ENT,
|
||||
OP_LOADP_FLD, // 150
|
||||
OP_LOADP_FNC,
|
||||
OP_LOADP_I,
|
||||
|
||||
OP_LE_I,
|
||||
OP_GE_I,
|
||||
OP_LT_I,
|
||||
OP_GT_I,
|
||||
|
||||
OP_LE_IF,
|
||||
OP_GE_IF,
|
||||
OP_LT_IF,
|
||||
OP_GT_IF, // 160
|
||||
|
||||
OP_LE_FI,
|
||||
OP_GE_FI,
|
||||
OP_LT_FI,
|
||||
OP_GT_FI,
|
||||
|
||||
OP_EQ_IF,
|
||||
OP_EQ_FI,
|
||||
|
||||
OP_ADD_SF, // (char*)c = (char*)a + (float)b
|
||||
OP_SUB_S, // (float)c = (char*)a - (char*)b
|
||||
OP_STOREP_C, // (float)c = *(char*)b = (float)a
|
||||
OP_LOADP_C, // (float)c = *(char*) // 170
|
||||
|
||||
OP_MUL_IF,
|
||||
OP_MUL_FI,
|
||||
OP_MUL_VI,
|
||||
OP_MUL_IV,
|
||||
OP_DIV_IF,
|
||||
OP_DIV_FI,
|
||||
OP_BITAND_IF,
|
||||
OP_BITOR_IF,
|
||||
OP_BITAND_FI,
|
||||
OP_BITOR_FI, // 180
|
||||
OP_AND_I,
|
||||
OP_OR_I,
|
||||
OP_AND_IF,
|
||||
OP_OR_IF,
|
||||
OP_AND_FI,
|
||||
OP_OR_FI,
|
||||
OP_NE_IF,
|
||||
OP_NE_FI,
|
||||
OP_BOUNDCHECK, // bounds checker from dp
|
||||
|
||||
// back to ones that we do use.
|
||||
|
||||
OP_STOREP_P, // 190
|
||||
OP_PUSH,
|
||||
OP_POP,
|
||||
|
||||
OP_NUMOPS,
|
||||
};
|
||||
|
||||
|
||||
typedef struct statement16_s
|
||||
{
|
||||
word op;
|
||||
word a,b,c;
|
||||
|
||||
} dstatement16_t;
|
||||
|
||||
typedef struct statement32_s
|
||||
{
|
||||
dword op;
|
||||
dword a,b,c;
|
||||
|
||||
} dstatement32_t;
|
||||
|
||||
typedef struct ddef16_s
|
||||
{
|
||||
word type; // if DEF_SAVEGLOBAL bit is set
|
||||
// the variable needs to be saved in savegames
|
||||
word ofs;
|
||||
string_t s_name;
|
||||
} ddef16_t;
|
||||
|
||||
typedef struct ddef32_s
|
||||
{
|
||||
dword type; // if DEF_SAVEGLOBAL bit is set
|
||||
// the variable needs to be saved in savegames
|
||||
dword ofs;
|
||||
string_t s_name;
|
||||
} ddef32_t;
|
||||
|
||||
typedef struct fdef_s
|
||||
{
|
||||
uint type; // if DEF_SAVEGLOBAL bit is set
|
||||
// the variable needs to be saved in savegames
|
||||
uint ofs;
|
||||
uint progsofs; // used at loading time, so maching field offsets (unions/members)
|
||||
// are positioned at the same runtime offset.
|
||||
char *name;
|
||||
} fdef_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int first_statement; // negative numbers are builtins
|
||||
int parm_start;
|
||||
int locals; // total ints of parms + locals
|
||||
|
||||
int profile; // runtime
|
||||
|
||||
string_t s_name;
|
||||
string_t s_file; // source file defined in
|
||||
|
||||
int numparms;
|
||||
byte parm_size[MAX_PARMS];
|
||||
} dfunction_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int version;
|
||||
int crc; // check of header file
|
||||
|
||||
uint ofs_statements; // comp 1
|
||||
uint numstatements; // statement 0 is an error
|
||||
|
||||
uint ofs_globaldefs; // comp 2
|
||||
uint numglobaldefs;
|
||||
|
||||
uint ofs_fielddefs; // comp 4
|
||||
uint numfielddefs;
|
||||
|
||||
uint ofs_functions; // comp 8
|
||||
uint numfunctions; // function 0 is an empty
|
||||
|
||||
uint ofs_strings; // comp 16
|
||||
uint numstrings; // first string is a null string
|
||||
|
||||
uint ofs_globals; // comp 32
|
||||
uint numglobals;
|
||||
|
||||
uint entityfields;
|
||||
|
||||
//debug / version 7 extensions
|
||||
uint ofsfiles; // non list format. no comp
|
||||
uint ofslinenums; // numstatements big // comp 64
|
||||
uint ofsbodylessfuncs; // no comp
|
||||
uint numbodylessfuncs;
|
||||
|
||||
uint ofs_types; // comp 128
|
||||
uint numtypes;
|
||||
uint blockscompressed;
|
||||
|
||||
int header; // strange "header", erh...
|
||||
} dprograms_t;
|
||||
|
||||
typedef struct mfunction_s
|
||||
{
|
||||
int first_statement; // negative numbers are builtins
|
||||
int parm_start;
|
||||
int locals; // total ints of parms + locals
|
||||
|
||||
// these are doubles so that they can count up to 54bits or so rather than 32bit
|
||||
|
||||
double profile; // runtime
|
||||
double builtinsprofile; // cost of builtin functions called by this function
|
||||
double callcount; // times the functions has been called since the last profile call
|
||||
|
||||
int s_name;
|
||||
int s_file; // source file defined in
|
||||
|
||||
int numparms;
|
||||
byte parm_size[MAX_PARMS];
|
||||
} mfunction_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char filename[128];
|
||||
int size;
|
||||
int compsize;
|
||||
int compmethod;
|
||||
int ofs;
|
||||
|
||||
} includeddatafile_t;
|
||||
|
||||
typedef struct typeinfo_s
|
||||
{
|
||||
etype_t type;
|
||||
|
||||
int next;
|
||||
int aux_type;
|
||||
int num_parms;
|
||||
|
||||
int ofs; // inside a structure.
|
||||
int size;
|
||||
char *name;
|
||||
|
||||
} typeinfo_t;
|
||||
|
||||
#endif//VPROGS_H
|
|
@ -27,9 +27,6 @@ if errorlevel 1 set BUILD_ERROR=1
|
|||
%MSDEV% server/server.dsp %CONFIG%"server - Win32 Release" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
%MSDEV% client/client.dsp %CONFIG%"client - Win32 Release" %build_target%
|
||||
if errorlevel 1 set BUILD_ERROR=1
|
||||
|
||||
if "%BUILD_ERROR%"=="" goto build_ok
|
||||
|
||||
echo *********************
|
||||
|
@ -54,7 +51,6 @@ 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 server\server.plg del /f /q server\server.plg
|
||||
if exist client\client.plg del /f /q client\client.plg
|
||||
|
||||
echo Build succeeded!
|
||||
echo Please wait. Xash is now loading
|
||||
|
|
|
@ -239,16 +239,14 @@ void Draw_Fill (int x, int y, int w, int h, int c)
|
|||
qglDisable (GL_TEXTURE_2D);
|
||||
|
||||
color.c = d_8to24table[c];
|
||||
qglColor3f (color.v[0]/255.0,
|
||||
color.v[1]/255.0,
|
||||
color.v[2]/255.0);
|
||||
qglColor3f (color.v[0]/255.0, color.v[1]/255.0, color.v[2]/255.0);
|
||||
|
||||
qglBegin (GL_QUADS);
|
||||
|
||||
qglVertex2f (x,y);
|
||||
qglVertex2f (x+w, y);
|
||||
qglVertex2f (x+w, y+h);
|
||||
qglVertex2f (x, y+h);
|
||||
qglVertex2f (x, y);
|
||||
qglVertex2f (x + w, y);
|
||||
qglVertex2f (x + w, y + h);
|
||||
qglVertex2f (x, y + h);
|
||||
|
||||
qglEnd ();
|
||||
qglColor3f (1,1,1);
|
||||
|
|
|
@ -1385,13 +1385,13 @@ void R_BeginFrame( float camera_separation )
|
|||
R_SetPalette
|
||||
=============
|
||||
*/
|
||||
unsigned r_rawpalette[256];
|
||||
uint r_rawpalette[256];
|
||||
|
||||
void R_SetPalette ( const unsigned char *palette)
|
||||
void R_SetPalette ( const byte *palette)
|
||||
{
|
||||
int i;
|
||||
|
||||
byte *rp = ( byte * ) r_rawpalette;
|
||||
byte *rp = (byte *)r_rawpalette;
|
||||
|
||||
if ( palette )
|
||||
{
|
||||
|
@ -1407,16 +1407,16 @@ void R_SetPalette ( const unsigned char *palette)
|
|||
{
|
||||
for ( i = 0; i < 256; i++ )
|
||||
{
|
||||
rp[i*4+0] = d_8to24table[i] & 0xff;
|
||||
rp[i*4+0] = ( d_8to24table[i] >> 0 ) & 0xff;
|
||||
rp[i*4+1] = ( d_8to24table[i] >> 8 ) & 0xff;
|
||||
rp[i*4+2] = ( d_8to24table[i] >> 16 ) & 0xff;
|
||||
rp[i*4+2] = ( d_8to24table[i] >> 16) & 0xff;
|
||||
rp[i*4+3] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
qglClearColor (0,0,0,0);
|
||||
qglClear (GL_COLOR_BUFFER_BIT);
|
||||
qglClearColor (1,0, 0.5 , 0.5);
|
||||
qglClearColor (1, 0, 0.5, 0.5);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
//=======================================================================
|
||||
// Copyright (C) XashXT Group 2007
|
||||
// baseentity.h - main game definitions
|
||||
//=======================================================================
|
||||
|
||||
#include "g_local.h"
|
|
@ -0,0 +1,89 @@
|
|||
//=======================================================================
|
||||
// Copyright (C) XashXT Group 2007
|
||||
// client.cpp - client/server game specific stuff
|
||||
//=======================================================================
|
||||
|
||||
#include "baseentity.h"
|
||||
|
||||
void ClientUserinfoChanged (edict_t *ent, char *userinfo);
|
||||
|
||||
/*
|
||||
===========
|
||||
ClientConnect
|
||||
|
||||
Called when a player begins connecting to the server.
|
||||
============
|
||||
*/
|
||||
bool ClientConnect (edict_t *ent, char *userinfo)
|
||||
{
|
||||
char *value;
|
||||
|
||||
// check to see if they are on the banned IP list
|
||||
value = Info_ValueForKey (userinfo, "ip");
|
||||
|
||||
if (SV_FilterPacket(value))
|
||||
{
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Banned.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for a spectator
|
||||
value = Info_ValueForKey (userinfo, "spectator");
|
||||
if (deathmatch->value && *value && strcmp(value, "0"))
|
||||
{
|
||||
int i, numspec;
|
||||
|
||||
if (*spectator_password->string && strcmp(spectator_password->string, "none") && strcmp(spectator_password->string, value))
|
||||
{
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Spectator password required or incorrect.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// count spectators
|
||||
for (i = numspec = 0; i < maxclients->value; i++)
|
||||
{
|
||||
if (g_edicts[i+1].inuse && g_edicts[i+1].client->pers.spectator)
|
||||
numspec++;
|
||||
}
|
||||
if (numspec >= maxspectators->value)
|
||||
{
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Server spectator limit is full.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// check for a password
|
||||
value = Info_ValueForKey (userinfo, "password");
|
||||
if (*password->string && strcmp(password->string, "none") && strcmp(password->string, value))
|
||||
{
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Password required or incorrect.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// they can connect
|
||||
ent->client = game.clients + (ent - g_edicts - 1);
|
||||
|
||||
// if there is already a body waiting for us (a loadgame), just
|
||||
// take it, otherwise spawn one from scratch
|
||||
if (ent->inuse == false)
|
||||
{
|
||||
// clear the respawning variables
|
||||
InitClientResp (ent->client);
|
||||
if (!game.autosaved || !ent->client->pers.weapon)
|
||||
{
|
||||
InitClientPersistant (ent->client,world->style);
|
||||
}
|
||||
}
|
||||
|
||||
ClientUserinfoChanged (ent, userinfo);
|
||||
|
||||
if (game.maxclients > 1) gi.dprintf ("%s connected\n", ent->client->pers.netname);
|
||||
|
||||
ent->svflags = 0; // make sure we start with known default
|
||||
ent->client->pers.connected = true;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
#include "m_player.h"
|
||||
|
||||
int nostatus = 0;
|
||||
|
@ -2102,7 +2102,7 @@ void ClientCommand (edict_t *ent)
|
|||
return;
|
||||
}
|
||||
e = G_Spawn();
|
||||
e->classname = TagMalloc(strlen(parm)+1,TAG_LEVEL);
|
||||
e->classname = (char *)TagMalloc(strlen(parm)+1,TAG_LEVEL);
|
||||
strcpy(e->classname,parm);
|
||||
AngleVectors(ent->client->v_angle,forward,NULL,NULL);
|
||||
VectorMA(ent->s.origin,128,forward,e->s.origin);
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
|
||||
bool Pickup_Weapon (edict_t *ent, edict_t *other);
|
||||
void Use_Weapon (edict_t *ent, gitem_t *inv);
|
||||
void Drop_Weapon (edict_t *ent, gitem_t *inv);
|
||||
|
||||
void Weapon_Blaster (edict_t *ent);
|
||||
void Weapon_HyperBlaster (edict_t *ent);
|
||||
void Weapon_Null(edict_t *ent);
|
||||
bool Pickup_Weapon (edict_t *ent, edict_t *other);
|
||||
|
||||
gitem_armor_t jacketarmor_info = { 25, 50, .30, .00, ARMOR_JACKET};
|
||||
gitem_armor_t combatarmor_info = { 50, 100, .60, .30, ARMOR_COMBAT};
|
||||
|
@ -673,18 +672,6 @@ bool Pickup_Health (edict_t *ent, edict_t *other)
|
|||
|
||||
int ArmorIndex (edict_t *ent)
|
||||
{
|
||||
if (!ent->client)
|
||||
return 0;
|
||||
|
||||
if (ent->client->pers.inventory[jacket_armor_index] > 0)
|
||||
return jacket_armor_index;
|
||||
|
||||
if (ent->client->pers.inventory[combat_armor_index] > 0)
|
||||
return combat_armor_index;
|
||||
|
||||
if (ent->client->pers.inventory[body_armor_index] > 0)
|
||||
return body_armor_index;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1439,7 +1426,6 @@ void SP_item_health (edict_t *self)
|
|||
self->class_id = ENTITY_ITEM_HEALTH;
|
||||
self->model = "models/items/healing/medium/tris.md2";
|
||||
self->count = 10;
|
||||
// SpawnItem (self, FindItem ("Health"));
|
||||
SpawnItem (self, FindItemByClassname ("item_health"));
|
||||
gi.soundindex ("items/n_health.wav");
|
||||
}
|
||||
|
|
|
@ -403,6 +403,7 @@ typedef struct
|
|||
|
||||
} level_locals_t;
|
||||
|
||||
extern level_locals_t level;
|
||||
|
||||
// spawn_temp_t is only used to hold entity field values that
|
||||
// can be set from the editor, but aren't actualy present
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
game_locals_t game;
|
||||
level_locals_t level;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// g_misc.c
|
||||
|
||||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
int gibsthisframe=0;
|
||||
int lastgibframe=0;
|
||||
|
@ -168,7 +168,7 @@ void ThrowGib (edict_t *self, char *gibname, int damage, int type)
|
|||
|
||||
gib = G_Spawn();
|
||||
|
||||
gib->classname = TagMalloc (4,TAG_LEVEL);
|
||||
gib->classname = (char *)TagMalloc (4,TAG_LEVEL);
|
||||
strcpy(gib->classname,"gib");
|
||||
|
||||
// Lazarus: mapper-definable gib class
|
||||
|
@ -181,7 +181,7 @@ void ThrowGib (edict_t *self, char *gibname, int damage, int type)
|
|||
}
|
||||
|
||||
// Save gibname and type for level transition gibs
|
||||
gib->key_message = TagMalloc (strlen(modelname)+1,TAG_LEVEL);
|
||||
gib->key_message = (char *)TagMalloc (strlen(modelname)+1,TAG_LEVEL);
|
||||
strcpy(gib->key_message, modelname);
|
||||
gib->style = type;
|
||||
|
||||
|
@ -288,7 +288,7 @@ void ThrowHead (edict_t *self, char *gibname, int damage, int type)
|
|||
}
|
||||
|
||||
// Save gibname and type for level transition gibs
|
||||
self->key_message = TagMalloc (strlen(modelname)+1,TAG_LEVEL);
|
||||
self->key_message = (char *)TagMalloc (strlen(modelname)+1,TAG_LEVEL);
|
||||
strcpy(self->key_message, modelname);
|
||||
|
||||
self->style = type;
|
||||
|
@ -435,7 +435,7 @@ void ThrowDebris (edict_t *self, char *modelname, float speed, vec3_t origin, in
|
|||
chunk->die = debris_die;
|
||||
|
||||
// Lazarus: Preserve model name for level changes:
|
||||
chunk->message = TagMalloc (strlen(modelname) + 1,TAG_LEVEL);
|
||||
chunk->message = (char *)TagMalloc (strlen(modelname) + 1,TAG_LEVEL);
|
||||
strcpy(chunk->message, modelname);
|
||||
|
||||
// Lazarus: skin number and effects
|
||||
|
@ -2201,7 +2201,7 @@ void SP_func_clock (edict_t *self)
|
|||
|
||||
func_clock_reset (self);
|
||||
|
||||
self->message = TagMalloc (CLOCK_MESSAGE_SIZE, TAG_LEVEL);
|
||||
self->message = (char *)TagMalloc (CLOCK_MESSAGE_SIZE, TAG_LEVEL);
|
||||
|
||||
self->think = func_clock_think;
|
||||
|
||||
|
@ -2985,7 +2985,7 @@ void SP_target_precipitation (edict_t *ent)
|
|||
G_FreeEdict(ent);
|
||||
return;
|
||||
}
|
||||
buffer = TagMalloc(strlen(ent->usermodel)+10,TAG_LEVEL);
|
||||
buffer = (char *)TagMalloc(strlen(ent->usermodel)+10,TAG_LEVEL);
|
||||
if(strstr(ent->usermodel,".spr"))
|
||||
sprintf(buffer, "sprites/%s", ent->usermodel);
|
||||
else
|
||||
|
@ -3181,7 +3181,7 @@ void SP_target_fountain (edict_t *ent)
|
|||
G_FreeEdict(ent);
|
||||
return;
|
||||
}
|
||||
buffer = TagMalloc(strlen(ent->usermodel)+10,TAG_LEVEL);
|
||||
buffer = (char *)TagMalloc(strlen(ent->usermodel)+10,TAG_LEVEL);
|
||||
if(strstr(ent->usermodel,".spr"))
|
||||
sprintf(buffer, "sprites/%s", ent->usermodel);
|
||||
else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// g_phys.c
|
||||
|
||||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
bool wasonground;
|
||||
bool onconveyor;
|
||||
|
@ -859,7 +859,7 @@ retry:
|
|||
}
|
||||
|
||||
// if blocked by player AND on a conveyor
|
||||
if (hit->client && onconveyor)
|
||||
if (hit && hit->client && onconveyor)
|
||||
{
|
||||
vec3_t player_dest;
|
||||
trace_t ptrace;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
#define Function(f) {#f, f}
|
||||
|
||||
|
@ -180,7 +180,7 @@ field_t fields[] =
|
|||
{"viewheight", FOFS(viewheight), F_INT},
|
||||
{"yaw_speed", FOFS(yaw_speed), F_FLOAT},
|
||||
|
||||
{0, 0, 0, 0}
|
||||
{0, 0, F_INT, 0}
|
||||
|
||||
};
|
||||
|
||||
|
@ -361,13 +361,13 @@ void InitGame (void)
|
|||
|
||||
// initialize all entities for this game
|
||||
game.maxentities = maxentities->value;
|
||||
g_edicts = TagMalloc (game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
|
||||
g_edicts = (edict_t *)TagMalloc (game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
|
||||
globals.edicts = g_edicts;
|
||||
globals.max_edicts = game.maxentities;
|
||||
|
||||
// initialize all clients for this game
|
||||
game.maxclients = maxclients->value;
|
||||
game.clients = TagMalloc (game.maxclients * sizeof(game.clients[0]), TAG_GAME);
|
||||
game.clients = (gclient_t *)TagMalloc (game.maxclients * sizeof(game.clients[0]), TAG_GAME);
|
||||
globals.num_edicts = game.maxclients+1;
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ void ReadField (vfile_t *f, field_t *field, byte *base)
|
|||
if (!len) *(char **)p = NULL;
|
||||
else
|
||||
{
|
||||
*(char **)p = TagMalloc (len, TAG_LEVEL);
|
||||
*(char **)p = (char *)TagMalloc (len, TAG_LEVEL);
|
||||
gi.VFs.Read (f, *(char **)p, len);
|
||||
}
|
||||
break;
|
||||
|
@ -637,11 +637,11 @@ void ReadGame (vfile_t *f)
|
|||
gi.error ("Savegame from an older version.\n");
|
||||
}
|
||||
|
||||
g_edicts = TagMalloc (game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
|
||||
g_edicts = (edict_t *)TagMalloc (game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
|
||||
globals.edicts = g_edicts;
|
||||
|
||||
gi.VFs.Read (f, &game, sizeof(game));
|
||||
game.clients = TagMalloc (game.maxclients * sizeof(game.clients[0]), TAG_GAME);
|
||||
game.clients = (gclient_t *)TagMalloc (game.maxclients * sizeof(game.clients[0]), TAG_GAME);
|
||||
for (i = 0; i < game.maxclients; i++) ReadClient (f, &game.clients[i]);
|
||||
}
|
||||
|
||||
|
@ -904,7 +904,7 @@ void ReadLump (byte *base, lump_t *l, int lumpnum)
|
|||
vfile_t *vf;
|
||||
byte *in;
|
||||
|
||||
in = (void *)(base + l->fileofs);
|
||||
in = (byte *)(base + l->fileofs);
|
||||
if (l->filelen % sizeof(*in)) gi.error("Sav_LoadGame: funny lump size\n" );
|
||||
|
||||
vf = gi.VFs.Create(in, l->filelen );
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
void SP_info_player_start (edict_t *ent);
|
||||
void SP_info_player_deathmatch (edict_t *ent);
|
||||
|
@ -72,14 +72,14 @@ void ED_CallSpawn (edict_t *ent)
|
|||
ED_NewString
|
||||
=============
|
||||
*/
|
||||
char *ED_NewString (char *string)
|
||||
char *ED_NewString (const char *string)
|
||||
{
|
||||
char *newb, *new_p;
|
||||
int i,l;
|
||||
|
||||
l = strlen(string) + 1;
|
||||
|
||||
newb = TagMalloc (l, TAG_LEVEL);
|
||||
newb = (char *)TagMalloc (l, TAG_LEVEL);
|
||||
|
||||
new_p = newb;
|
||||
|
||||
|
@ -111,7 +111,7 @@ Takes a key/value pair and sets the binary values
|
|||
in an edict
|
||||
===============
|
||||
*/
|
||||
void ED_ParseField (char *key, char *value, edict_t *ent)
|
||||
void ED_ParseField (char *key, const char *value, edict_t *ent)
|
||||
{
|
||||
field_t *f;
|
||||
byte *b;
|
||||
|
@ -169,7 +169,7 @@ ed should be a properly initialized empty edict.
|
|||
*/
|
||||
char *ED_ParseEdict (char *data, edict_t *ent)
|
||||
{
|
||||
bool init;
|
||||
bool init;
|
||||
char keyname[256];
|
||||
char *com_token;
|
||||
|
||||
|
@ -204,7 +204,7 @@ char *ED_ParseEdict (char *data, edict_t *ent)
|
|||
|
||||
if (!init) memset (ent, 0, sizeof(*ent));
|
||||
|
||||
return data;
|
||||
return (char *)data;
|
||||
}
|
||||
|
||||
|
||||
|
@ -278,7 +278,7 @@ void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
|
|||
edict_t *ent;
|
||||
int inhibit;
|
||||
char *com_token;
|
||||
int i;
|
||||
int i;
|
||||
float skill_level;
|
||||
extern int max_modelindex;
|
||||
extern int max_soundindex;
|
||||
|
@ -319,8 +319,7 @@ void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
|
|||
{
|
||||
// parse the opening brace
|
||||
com_token = COM_Parse (&entities);
|
||||
if (!entities)
|
||||
break;
|
||||
if (!entities) break;
|
||||
if (com_token[0] != '{')
|
||||
gi.error ("ED_LoadFromFile: found %s when expecting {",com_token);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
|
||||
void Svcmd_Test_f (void)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// g_utils.c -- misc utility functions for game module
|
||||
|
||||
#include "g_local.h"
|
||||
|
||||
#include "baseentity.h"
|
||||
|
||||
void *TagMalloc (int size, int tag)
|
||||
{
|
||||
|
@ -510,7 +509,7 @@ char *G_CopyString (char *in)
|
|||
{
|
||||
char *out;
|
||||
|
||||
out = TagMalloc (strlen(in)+1, TAG_LEVEL);
|
||||
out = (char *)TagMalloc (strlen(in)+1, TAG_LEVEL);
|
||||
strcpy (out, in);
|
||||
return out;
|
||||
}
|
||||
|
@ -1178,7 +1177,7 @@ void T_Damage (edict_t *in_targ, edict_t *inflictor, edict_t *in_attacker, vec3_
|
|||
// damaged, as in switching from func_monitor usage. Limit
|
||||
// damage so that player isn't killed, and make him temporarily
|
||||
// invincible
|
||||
targ->health = max(2,targ->health - take);
|
||||
targ->health = max(2, targ->health - take);
|
||||
targ->client->invincible_framenum = level.framenum+2;
|
||||
targ->pain_debounce_time = max(targ->pain_debounce_time,level.time+0.3);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
#include "m_player.h"
|
||||
|
||||
#define MUD1BASE 0.20
|
||||
|
@ -1627,86 +1627,6 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
|
|||
strncpy (ent->client->pers.userinfo, userinfo, sizeof(ent->client->pers.userinfo)-1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
ClientConnect
|
||||
|
||||
Called when a player begins connecting to the server.
|
||||
The game can refuse entrance to a client by returning false.
|
||||
If the client is allowed, the connection process will continue
|
||||
and eventually get to ClientBegin()
|
||||
Changing levels will NOT cause this to be called again, but
|
||||
loadgames will.
|
||||
============
|
||||
*/
|
||||
bool ClientConnect (edict_t *ent, char *userinfo)
|
||||
{
|
||||
char *value;
|
||||
|
||||
// check to see if they are on the banned IP list
|
||||
value = Info_ValueForKey (userinfo, "ip");
|
||||
if (SV_FilterPacket(value)) {
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Banned.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for a spectator
|
||||
value = Info_ValueForKey (userinfo, "spectator");
|
||||
if (deathmatch->value && *value && strcmp(value, "0")) {
|
||||
int i, numspec;
|
||||
|
||||
if (*spectator_password->string &&
|
||||
strcmp(spectator_password->string, "none") &&
|
||||
strcmp(spectator_password->string, value)) {
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Spectator password required or incorrect.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// count spectators
|
||||
for (i = numspec = 0; i < maxclients->value; i++)
|
||||
if (g_edicts[i+1].inuse && g_edicts[i+1].client->pers.spectator)
|
||||
numspec++;
|
||||
|
||||
if (numspec >= maxspectators->value) {
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Server spectator limit is full.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// check for a password
|
||||
value = Info_ValueForKey (userinfo, "password");
|
||||
if (*password->string && strcmp(password->string, "none") &&
|
||||
strcmp(password->string, value)) {
|
||||
Info_SetValueForKey(userinfo, "rejmsg", "Password required or incorrect.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// they can connect
|
||||
ent->client = game.clients + (ent - g_edicts - 1);
|
||||
|
||||
// if there is already a body waiting for us (a loadgame), just
|
||||
// take it, otherwise spawn one from scratch
|
||||
if (ent->inuse == false)
|
||||
{
|
||||
// clear the respawning variables
|
||||
InitClientResp (ent->client);
|
||||
if (!game.autosaved || !ent->client->pers.weapon)
|
||||
InitClientPersistant (ent->client,world->style);
|
||||
}
|
||||
|
||||
ClientUserinfoChanged (ent, userinfo);
|
||||
|
||||
if (game.maxclients > 1)
|
||||
gi.dprintf ("%s connected\n", ent->client->pers.netname);
|
||||
|
||||
ent->svflags = 0; // make sure we start with known default
|
||||
ent->client->pers.connected = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
ClientDisconnect
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
/*
|
||||
======================================================================
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
void PMenu_Open(edict_t *ent, pmenu_t *entries, int cur, int num)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ void PMenu_Open(edict_t *ent, pmenu_t *entries, int cur, int num)
|
|||
PMenu_Close(ent);
|
||||
}
|
||||
|
||||
hnd = malloc(sizeof(*hnd));
|
||||
hnd = (pmenuhnd_t *)malloc(sizeof(*hnd));
|
||||
|
||||
hnd->entries = entries;
|
||||
hnd->num = num;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
#include "m_player.h"
|
||||
|
||||
static edict_t *current_player;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// g_weapon.c
|
||||
|
||||
#include "g_local.h"
|
||||
#include "baseentity.h"
|
||||
#include "m_player.h"
|
||||
|
||||
|
||||
|
|
|
@ -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" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I ".\\" /I ".\monsters" /I ".\ents" /I ".\global" /I "../public" /I "../public/libs" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I ".\\" /I ".\gamerules" /I ".\ents" /I ".\global" /I "../public" /I "../public/libs" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
|
@ -80,7 +80,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" /YX /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I ".\\" /I ".\monsters" /I ".\ents" /I ".\global" /I "../public" /I "../public/libs" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I ".\\" /I ".\gamerules" /I ".\ents" /I ".\global" /I "../public" /I "../public/libs" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
|
@ -114,6 +114,10 @@ SOURCE="$(InputPath)"
|
|||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\g_cmds.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -174,6 +178,10 @@ SOURCE=.\p_weapon.c
|
|||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\baseentity.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\const.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
12
xash.dsw
12
xash.dsw
|
@ -3,18 +3,6 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
|
|||
|
||||
###############################################################################
|
||||
|
||||
Project: "client"=".\client\client.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "editor"=".\editor\editor.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
|
Reference in New Issue