06 Jun 2008

This commit is contained in:
g-cont 2008-06-06 00:00:00 +04:00 committed by Alibek Omarov
parent 81d8b5a537
commit 25cb250bc5
11 changed files with 247 additions and 82 deletions

View File

@ -274,6 +274,33 @@ void ProcessCollisionTree( void )
pe->WriteCollisionLump( NULL, AddCollision );
}
void Init_PhysicsLibrary( void )
{
static physic_imp_t pi;
launch_t CreatePhysic;
pi.api_size = sizeof(physic_imp_t);
Sys_LoadLibrary( &physic_dll );
if(physic_dll.link)
{
CreatePhysic = (void *)physic_dll.main;
pe = CreatePhysic( &com, &pi ); // sys_error not overrided
pe->Init(); // initialize phys callback
}
else memset( &pe, 0, sizeof(pe));
}
void Free_PhysicLibrary( void )
{
if(physic_dll.link)
{
pe->Shutdown();
memset( &pe, 0, sizeof(pe));
}
Sys_FreeLibrary( &physic_dll );
}
/*
============
WbspMain
@ -318,12 +345,7 @@ void WbspMain ( bool option )
bool PrepareBSPModel ( const char *dir, const char *name, byte params )
{
static physic_imp_t pi;
launch_t CreatePhysic;
int numshaders;
// phys callback
pi.api_size = sizeof(physic_imp_t);
int numshaders;
if( dir ) com.strncpy(gs_basedir, dir, sizeof(gs_basedir));
if( name ) com.strncpy(gs_filename, name, sizeof(gs_filename));
@ -334,19 +356,9 @@ bool PrepareBSPModel ( const char *dir, const char *name, byte params )
onlyrad = (params & BSP_ONLYRAD) ? true : false;
full_compile = (params & BSP_FULLCOMPILE) ? true : false;
Sys_LoadLibrary( &physic_dll );
if(physic_dll.link)
{
CreatePhysic = (void *)physic_dll.main;
pe = CreatePhysic( &com, &pi ); // sys_error not overrided
pe->Init();
}
else memset( &pe, 0, sizeof(pe));
// don't worry about that
FS_LoadGameInfo("gameinfo.txt");
FS_LoadGameInfo( "gameinfo.txt" ); // same as normal gamemode
Init_PhysicsLibrary();
numshaders = LoadShaderInfo();
Msg( "%5i shaderInfo\n", numshaders );
@ -367,12 +379,7 @@ bool CompileBSPModel ( void )
}
else WbspMain( false ); // just create bsp
if(physic_dll.link)
{
pe->Shutdown();
memset( &pe, 0, sizeof(pe));
}
Sys_FreeLibrary( &physic_dll );
Free_PhysicLibrary();
if( onlyrad && onlyvis && full_compile )
{

View File

@ -517,7 +517,7 @@ void Host_Init (uint funcname, int argc, char **argv)
// init commands and vars
if(host.developer)
{
host_cheats = Cvar_Get("host_cheats", "1", CVAR_READ_ONLY | CVAR_SYSTEMINFO );
host_cheats = Cvar_Get("host_cheats", "1", CVAR_SYSTEMINFO );
Cmd_AddCommand ("error", Host_Error_f, "just throw a fatal error to test shutdown procedures" );
Cmd_AddCommand ("crash", Host_Crash_f, "a way to force a bus error for development reasons");
}
@ -531,7 +531,7 @@ void Host_Init (uint funcname, int argc, char **argv)
else dedicated = Cvar_Get ("dedicated", "0", CVAR_INIT);
s = va("^1Xash %g ^3%s", GI->version, buildstring );
Cvar_Get ("version", s, CVAR_SERVERINFO|CVAR_INIT);
Cvar_Get ("version", s, CVAR_SERVERINFO|CVAR_INIT );
if(dedicated->value) Cmd_AddCommand ("quit", Sys_Quit, "quit the game" );

View File

@ -283,6 +283,27 @@ void Cmd_Exec_f (void)
Mem_Free(f);
}
/*
===============
Cmd_SystemCfg_f
===============
*/
void Cmd_SystemCfg_f( void )
{
char *f;
size_t len;
f = FS_LoadFile( "system.rc", &len );
if (!f)
{
MsgWarn("couldn't exec system.rc\n" );
return;
}
MsgDev(D_INFO, "execing system.rc\n" );
Cbuf_InsertText(f);
Mem_Free(f);
}
/*
===============
Cmd_Echo_f
@ -607,6 +628,7 @@ void Cmd_Init( void )
// register our commands
Cmd_AddCommand ("exec", Cmd_Exec_f, "execute a script file" );
Cmd_AddCommand ("systemcfg", Cmd_SystemCfg_f, "execute a system config script" );
Cmd_AddCommand ("echo", Cmd_Echo_f, "print a message to the console (useful in scripts)" );
Cmd_AddCommand ("wait", Cmd_Wait_f, "make script execution wait for some rendered frames" );
Cmd_AddCommand ("cmdlist", Cmd_List_f, "display all console commands beginning with the specified prefix" );

View File

@ -81,7 +81,7 @@ static long _stdcall Con_WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
return TRUE;
break;
case WM_CLOSE:
if(Sys.error)
if( Sys.app_state == SYS_ERROR )
{
// send windows message
PostQuitMessage( 0 );
@ -366,7 +366,7 @@ destroy win32 console
void Con_DestroyConsole( void )
{
// last text message into console or log
if(Sys.crash) MsgDev(D_NOTE, "Sys_FreeLibrary: Hold launch.dll for debugging\n" );
if( Sys.app_state == SYS_CRASH ) MsgDev(D_NOTE, "Sys_FreeLibrary: Hold launch.dll for debugging\n" );
else MsgDev(D_NOTE, "Sys_FreeLibrary: Unloading launch.dll\n");
Sys_CloseLog();

View File

@ -208,7 +208,7 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags, const
// allocate a new cvar
if( cvar_numIndexes >= MAX_CVARS )
{
MsgWarn("Cvar_Get: MAX_CVARS limit exceeded\n" );
MsgDev( D_ERROR, "Cvar_Get: MAX_CVARS limit exceeded\n" );
return NULL;
}
@ -256,7 +256,7 @@ cvar_t *Cvar_Set2 (const char *var_name, const char *value, bool force)
value = "default";
}
var = Cvar_FindVar (var_name);
var = Cvar_FindVar( var_name );
if(!var)
{
if( !value ) return NULL;
@ -284,6 +284,11 @@ cvar_t *Cvar_Set2 (const char *var_name, const char *value, bool force)
MsgDev(D_INFO, "%s is write protected.\n", var_name);
return var;
}
if (var->flags & CVAR_SYSTEMINFO)
{
MsgDev(D_INFO, "%s is system variable.\n", var_name);
return var;
}
if (var->flags & CVAR_LATCH)
{
if (var->latched_string)
@ -363,10 +368,10 @@ void Cvar_FullSet( char *var_name, char *value, int flags )
cvar_t *var;
var = Cvar_FindVar (var_name);
if (!var)
if(!var)
{
// create it
Cvar_Get(var_name, value, flags, "" );
Cvar_Get( var_name, value, flags, "" );
return;
}
var->modified = true;
@ -594,6 +599,24 @@ void Cvar_SetA_f( void )
v->flags |= CVAR_ARCHIVE;
}
/*
============
Cvar_SetC_f
As Cvar_Set, but also flags it as systeminfo
============
*/
void Cvar_SetC_f( void )
{
if( Cmd_Argc() != 3 )
{
Msg("usage: setc <variable> <value>\n");
return;
}
Cvar_FullSet( Cmd_Argv(1), Cmd_Argv(2), CVAR_SYSTEMINFO );
}
/*
============
Cvar_Reset_f
@ -675,7 +698,7 @@ void Cvar_Restart_f( void )
// don't mess with rom values, or some inter-module
// communication will get broken (com_cl_running, etc)
if ( var->flags & ( CVAR_READ_ONLY | CVAR_INIT ))
if ( var->flags & ( CVAR_READ_ONLY|CVAR_INIT|CVAR_SYSTEMINFO ))
{
prev = &var->next;
continue;
@ -714,6 +737,7 @@ void Cvar_Init (void)
Cmd_AddCommand ("set", Cvar_Set_f, "create or change the value of a console variable" );
Cmd_AddCommand ("sets", Cvar_SetS_f, "create or change the value of a serverinfo variable");
Cmd_AddCommand ("setu", Cvar_SetU_f, "create or change the value of a userinfo variable");
Cmd_AddCommand ("setc", Cvar_SetC_f, "create or change the value of a systeminfo variable");
Cmd_AddCommand ("seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to vars.rc");
Cmd_AddCommand ("reset", Cvar_Reset_f, "reset any type variable to initial value" );
Cmd_AddCommand ("cvarlist", Cvar_List_f, "display all console variables beginning with the specified prefix" );

View File

@ -17,6 +17,8 @@
#define PACKFILE_FLAG_DEFLATED (1<<1) // file compressed using the deflate algorithm
#define FILE_BUFF_SIZE 2048
#define FS_READONLY_PATH 1
typedef struct
{
z_stream zstream;
@ -83,6 +85,7 @@ typedef struct searchpath_s
{
char filename[MAX_SYSPATH];
pack_t *pack;
int flags;
struct searchpath_s *next;
} searchpath_t;
@ -115,6 +118,8 @@ char gs_mapname[ 64 ]; // used for compilers only
int fs_argc;
char *fs_argv[MAX_NUM_ARGVS];
bool fs_ext_path = false; // attempt to read\write from ./ or ../ pathes
bool fs_use_wads = false; // some utilities needs this
cvar_t *fs_wadsupport;
gameinfo_t GI;
@ -578,7 +583,7 @@ void FS_CreatePath (char *path)
/*
============
FS_Path
FS_Path_f
debug info
============
@ -595,6 +600,18 @@ void FS_Path_f( void )
}
}
/*
============
FS_Path_f
debug info
============
*/
void FS_ClearPaths_f( void )
{
FS_ClearSearchPath();
}
/*
============
FS_FileBase
@ -916,7 +933,7 @@ Sets fs_gamedir, adds the directory to the head of the path,
then loads and adds pak1.pak pak2.pak ...
================
*/
void FS_AddGameDirectory (const char *dir)
void FS_AddGameDirectory( const char *dir, int flags )
{
int i;
stringlist_t list;
@ -966,6 +983,7 @@ void FS_AddGameDirectory (const char *dir)
search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t));
com_strncpy (search->filename, dir, sizeof (search->filename));
search->next = fs_searchpaths;
search->flags = flags;
fs_searchpaths = search;
}
@ -1162,19 +1180,22 @@ FS_AddGameHierarchy
*/
void FS_AddGameHierarchy (const char *dir)
{
search_t *search;
int i, numWads = 0;
// Add the common game directory
if(dir || *dir)
{
FS_AddGameDirectory (va("%s%s/", fs_basedir, dir));
FS_AddGameDirectory( va("%s%s/", fs_basedir, dir), 0 );
search = FS_Search( "*.wad", true );
if(!search) return;
for( i = 0; i < search->numfilenames; i++ )
FS_AddWad3File( search->filenames[i] );
Mem_Free( search );
if( fs_wadsupport->integer || fs_use_wads )
{
search_t *search;
int i, numWads = 0;
search = FS_Search( "*.wad", true );
if(!search) return;
for( i = 0; i < search->numfilenames; i++ )
FS_AddWad3File( search->filenames[i] );
Mem_Free( search );
}
}
}
@ -1242,22 +1263,30 @@ void FS_ExtractFilePath(const char* const path, char* dest)
FS_ClearSearchPath
================
*/
void FS_ClearSearchPath (void)
void FS_ClearSearchPath( void )
{
uint i;
wadfile_t *w;
while (fs_searchpaths)
while( fs_searchpaths )
{
searchpath_t *search = fs_searchpaths;
fs_searchpaths = search->next;
if (search->pack)
if( search->flags & FS_READONLY_PATH )
{
if (search->pack->files)
// skip read-only pathes e.g. "bin"
if( search->next ) fs_searchpaths = search->next->next;
else break;
}
else fs_searchpaths = search->next;
if( search->pack )
{
if( search->pack->files )
Mem_Free(search->pack->files);
Mem_Free(search->pack);
}
Mem_Free(search);
Mem_Free( search );
}
// close all wad files and free their lumps data
@ -1378,7 +1407,7 @@ void FS_LoadGameInfo( const char *filename )
// lock uplevel of gamedir for read\write
fs_ext_path = false;
// prepare to loading
FS_ClearSearchPath();
FS_AddGameHierarchy( gs_basedir );
@ -1470,7 +1499,11 @@ void FS_Init( void )
FS_InitMemory();
FS_AddGameDirectory( "bin/", FS_READONLY_PATH ); // execute system config
Cmd_AddCommand( "fs_path", FS_Path_f, "show filesystem search pathes" );
Cmd_AddCommand( "fs_clearpaths", FS_ClearPaths_f, "clear filesystem search pathes" );
fs_wadsupport = Cvar_Get( "fs_wadsupport", "0", CVAR_SYSTEMINFO, "enable wad-archive support" );
// ignore commandlineoption "-game" for other stuff
if(Sys.app_name == HOST_NORMAL || Sys.app_name == HOST_DEDICATED || Sys.app_name == COMP_BSPLIB)
@ -1509,6 +1542,24 @@ void FS_Init( void )
stringlistfreecontents(&dirs);
}
// enable temporary wad support for some tools
switch( Sys.app_name )
{
case COMP_WADLIB:
case RIPP_MIPDEC:
case RIPP_MDLDEC:
case RIPP_LMPDEC:
case RIPP_SNDDEC:
fs_use_wads = true;
break;
default:
fs_use_wads = false;
break;
}
Cbuf_ExecuteText( EXEC_NOW, "systemcfg\n" );
Cbuf_Execute(); // apply system cvars immediately
FS_ResetGameInfo();
MsgDev(D_INFO, "FS_Init: done\n");
}
@ -1541,29 +1592,49 @@ bool FS_GetParmFromCmdLine( char *parm, char *out )
return true;
}
/*
============
FS_WriteVariables
Appends lines containing "set variable value" for all variables
with the archive flag set to true.
============
*/
static void FS_WriteCvar( const char *name, const char *string, const char *unused, void *f )
{
FS_Printf(f, "setc %s \"%s\"\n", name, string );
}
void FS_WriteVariables( file_t *f )
{
FS_Printf (f, "unsetall\n" );
Cvar_LookupVars( CVAR_SYSTEMINFO, NULL, f, FS_WriteCvar );
}
/*
================
FS_Shutdown
================
*/
void FS_Shutdown (void)
void FS_Shutdown( void )
{
wadfile_t *w;
int i;
file_t *f;
// close all wad files and free their lumps data
for (i = 0; i < Mem_ArraySize( fs_searchwads ); i++ )
FS_ClearSearchPath(); // release all wad files too
FS_UpdateEnvironmentVariables(); // merge working directory
com_strncpy( fs_gamedir, "bin", sizeof(fs_gamedir)); // set write directory for system config
f = FS_Open( "system.rc", "w" );
if( f )
{
w = Mem_GetElement( fs_searchwads, i );
if(!w) continue;
if(w->lumps) Mem_Free(w->lumps);
w->lumps = NULL;
if(w->file) FS_Close(w->file);
w->file = NULL;
w->name[0] = 0;
FS_Printf (f, "//=======================================================================\n");
FS_Printf (f, "//\t\t\tCopyright XashXT Group 2008 ©\n");
FS_Printf (f, "//\t\tsystem.rc - archive of system cvars\n");
FS_Printf (f, "//=======================================================================\n");
FS_WriteVariables( f );
FS_Close (f);
}
if( fs_searchwads ) Mem_RemoveArray( fs_searchwads );
fs_searchwads = NULL;
else MsgWarn("Couldn't write system.rc.\n");
Mem_FreePool(&fs_mempool);
}
@ -2834,8 +2905,6 @@ void FS_InitMemory( void )
// add a path separator to the end of the basedir if it lacks one
if (fs_basedir[0] && fs_basedir[com_strlen(fs_basedir) - 1] != '/' && fs_basedir[com_strlen(fs_basedir) - 1] != '\\')
com_strncat(fs_basedir, "/", sizeof(fs_basedir));
if( !fs_searchwads ) fs_searchwads = Mem_CreateArray( fs_mempool, sizeof(wadfile_t), 16 );
}
/*

View File

@ -447,6 +447,9 @@ void Sys_CreateInstance( void )
Cbuf_ExecuteText( EXEC_NOW, "stuffcmds\n" );
break;
}
Cmd_RemoveCommand( "setc" ); // potentially backdoor for change system settings
Sys.app_state = SYS_FRAME; // system is now active
}
uint Sys_SendKeyEvents( void )
@ -519,11 +522,21 @@ void Sys_InitLog( void )
void Sys_CloseLog( void )
{
string event_name;
if(!logfile) return;
switch( Sys.app_state )
{
case SYS_CRASH: com_strncpy( event_name, "crashed", MAX_STRING ); break;
case SYS_ABORT: com_strncpy( event_name, "aborted by user", MAX_STRING ); break;
case SYS_ERROR: com_strncpy( event_name, "stopped with error", MAX_STRING ); break;
default: com_strncpy( event_name, "stopped", MAX_STRING ); break;
}
fprintf(logfile, "\n");
fprintf(logfile, "=======================================================================");
fprintf(logfile, "\n\t%s %sed at %s\n", Sys.caption, Sys.crash ? "crash" : "stopp", com_timestamp(TIME_FULL));
fprintf(logfile, "\n\t%s %s at %s\n", Sys.caption, event_name, com_timestamp(TIME_FULL));
fprintf(logfile, "=======================================================================");
fclose(logfile);
@ -838,13 +851,15 @@ void Sys_Error(const char *error, ...)
va_list argptr;
char text[MAX_INPUTLINE];
if(Sys.error) return; // don't multiple executes
if( Sys.app_state == SYS_ERROR )
return; // don't multiple executes
Sys.error = true;
Sys.app_state = SYS_ERROR;
va_start (argptr, error);
com_vsprintf (text, error, argptr);
va_end (argptr);
Sys.error = true;
Con_ShowConsole( true );
if(Sys.developer) Sys_Print( text ); // print error message
else Sys_Print( "Internal engine error\n" ); // don't confuse non-developers with technique stuff
@ -861,21 +876,33 @@ void Sys_Break(const char *error, ...)
va_start (argptr, error);
com_vsprintf (text, error, argptr);
va_end (argptr);
Sys.error = true;
Sys.error = true;
Sys.app_state = SYS_ERROR;
Con_ShowConsole( true );
Sys_Print( text );
Sys_WaitForQuit();
Sys_Exit();
}
void Sys_Abort( void )
{
// to avoid double calling
if( Sys.app_state != SYS_FRAME ) return;
// aborting by user, run normal shutdown procedure
Sys.app_state = SYS_ABORT;
Sys_Exit();
}
long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
{
// save config
if(!Sys.crash)
if(Sys.app_state != SYS_CRASH )
{
// check to avoid recursive call
Sys.crash = true;
Sys.error = true;
Sys.app_state = SYS_CRASH;
Sys.Free(); // prepare host to close
Sys_FreeLibrary( Sys.linked_dll );
@ -918,6 +945,7 @@ void Sys_Init( void )
if(FS_GetParmFromCmdLine("-dev", dev_level )) Sys.developer = com_atoi(dev_level);
FS_UpdateEnvironmentVariables(); // set working directory
SetErrorMode( SEM_FAILCRITICALERRORS ); // no abort/retry/fail errors
if( Sys.hooked_out ) atexit( Sys_Abort );
Sys.con_showalways = true;
Sys.con_readonly = true;
@ -943,8 +971,11 @@ NOTE: we must prepare engine to shutdown
before call this
================
*/
void Sys_Exit ( void )
void Sys_Exit( void )
{
if( Sys.app_state == SYS_FRAME )
Sys.app_state = SYS_SHUTDOWN;
// prepare host to close
Sys.Free();
Sys_FreeLibrary( Sys.linked_dll );
@ -1057,7 +1088,7 @@ bool Sys_FreeLibrary ( dll_info_t *dll )
{
if(!dll || !dll->link) // invalid desc or alredy freed
return false;
if(Sys.crash)
if( Sys.app_state == SYS_CRASH )
{
// we need to hold down all modules, while MSVC can find erorr
MsgDev(D_NOTE, "Sys_FreeLibrary: Hold %s for debugging\n", dll->name );

View File

@ -24,10 +24,20 @@
#define XASH_VERSION 0.48f // current version will be shared over gameinfo struct
enum state_e
{
SYS_SHUTDOWN = 0,
SYS_CRASH,
SYS_ABORT,
SYS_ERROR,
SYS_FRAME,
};
typedef struct system_s
{
char progname[MAX_QPATH];
int app_name;
int app_state;
bool debug;
bool developer;
@ -45,12 +55,11 @@ typedef struct system_s
bool con_showalways;
bool con_showcredits;
bool con_silentmode;
bool error;
bool crash;
byte *basepool;
byte *zonepool;
byte *imagepool;
byte *stringpool;
bool error;
// simply profiling
double start, end;
@ -109,6 +118,7 @@ char *Sys_GetClipboardData( void );
void Sys_Sleep( int msec );
void Sys_Init( void );
void Sys_Exit( void );
void Sys_Abort( void );
bool Sys_LoadLibrary ( dll_info_t *dll );
void* Sys_GetProcAddress ( dll_info_t *dll, const char* name );
bool Sys_FreeLibrary ( dll_info_t *dll );
@ -277,7 +287,7 @@ bool FS_Eof( file_t* file);
cvar_t *Cvar_FindVar (const char *var_name);
cvar_t *Cvar_Get (const char *var_name, const char *value, int flags, const char *description);
void Cvar_Set( const char *var_name, const char *value);
cvar_t *Cvar_Set2 (const char *var_name, const char *value, bool force);
cvar_t *Cvar_Set2( const char *var_name, const char *value, bool force );
void Cvar_LookupVars( int checkbit, char *buffer, void *ptr, cvarcmd_t callback );
void Cvar_FullSet (char *var_name, char *value, int flags);
void Cvar_SetLatched( const char *var_name, const char *value);

View File

@ -26,7 +26,7 @@ bool InitPhysics( void )
CM_InitMaterials();
cm_noareas = Cvar_Get( "cm_noareas", "0", 0 );
cm_use_triangles = Cvar_Get("cm_convert_polygons", "1", CVAR_INIT|CVAR_SYSTEMINFO );//, "convert bsp polygons to triangles, slowly but more safety way" );
cm_use_triangles = Cvar_Get("cm_convert_polygons", "1", CVAR_SYSTEMINFO );//, "convert bsp polygons to triangles, slowly but more safety way" );
cm_solver_model = Cvar_Get("cm_solver", "0", CVAR_ARCHIVE );//, "change solver model: 0 - precision, 1 - adaptive, 2 - fast. (changes need restart server to take effect)" );
cm_friction_model = Cvar_Get("cm_friction", "0", CVAR_ARCHIVE );//, "change solver model: 0 - precision, 1 - adaptive. (changes need restart server to take effect)" );
cm_physics_model = Cvar_Get("cm_physic", "1", CVAR_ARCHIVE );//, "change physic model: 0 - Classic Quake Physic, 1 - Physics Engine" );

View File

@ -59,7 +59,7 @@
#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc
#define CVAR_USERINFO 2 // added to userinfo when changed
#define CVAR_SERVERINFO 4 // added to serverinfo when changed
#define CVAR_SYSTEMINFO 8 // these cvars will be duplicated on all clients
#define CVAR_SYSTEMINFO 8 // don't changed from console, saved into system.rc
#define CVAR_INIT 16 // don't allow change from console at all, but can be set from the command line
#define CVAR_LATCH 32 // save changes until server restart
#define CVAR_READ_ONLY 64 // display only, cannot be set by user at all

View File

@ -10,6 +10,8 @@ SprExplorer
fopen завешивает приложение, при попытке создать файл в несуществующей директории. Ну вылетал бы чтоли, или ошибку
возвращал.
1. почистить комп от говна
Глобальные задачи:
1. вернуть обратно roq video OK
2. исправить проигрывание movie после загрузки карты