14 Mar 2011

This commit is contained in:
g-cont 2011-03-14 00:00:00 +03:00 committed by Alibek Omarov
parent 62f7ad7bb1
commit a8d7781692
16 changed files with 136 additions and 98 deletions

View File

@ -1627,5 +1627,9 @@ void CL_Shutdown( void )
IN_Shutdown ();
SCR_Shutdown ();
CL_UnloadProgs ();
S_Shutdown ();
R_Shutdown ();
cls.initialized = false;
}

View File

@ -578,12 +578,12 @@ CL_ParseServerData
*/
void CL_ParseServerData( sizebuf_t *msg )
{
string gamefolder;
int i;
MsgDev( D_NOTE, "Serverdata packet received.\n" );
clgame.load_sequence++; // now all hud sprites are invalid
clgame.dllFuncs.pfnVidInit();
// wipe the client_t struct
CL_ClearState();
@ -604,6 +604,22 @@ void CL_ParseServerData( sizebuf_t *msg )
Q_strncpy( clgame.mapname, BF_ReadString( msg ), MAX_STRING );
Q_strncpy( clgame.maptitle, BF_ReadString( msg ), MAX_STRING );
cl.background = BF_ReadOneBit( msg );
Q_strncpy( gamefolder, BF_ReadString( msg ), MAX_STRING );
if( Q_stricmp( host.gamefolder, gamefolder ))
{
// so reload all images (remote connect)
Mod_ClearAll();
R_ShutdownImages();
FS_LoadGameInfo( gamefolder );
R_InitImages();
SCR_VidInit();
SCR_RegisterShaders();
}
else
{
clgame.dllFuncs.pfnVidInit();
}
UI_SetActiveMenu( cl.background );

View File

@ -264,7 +264,8 @@ typedef struct host_parm_s
qboolean con_showalways; // show console always (developer and dedicated)
qboolean change_game; // initialize when game is changed
qboolean shutdown_issued; // engine is shutting down
char gamefolder[64]; // it's a default gamefolder
byte *imagepool; // imagelib mempool
byte *soundpool; // soundlib mempool
@ -519,6 +520,7 @@ qboolean Host_IsLocalGame( void );
void Host_ShutdownServer( void );
void Host_Print( const char *txt );
void Host_Error( const char *error, ... );
void Host_InitDecals( void );
void Host_Credits( void );
/*
@ -671,6 +673,7 @@ qboolean SV_GetComment( const char *savename, char *comment );
qboolean SV_NewGame( const char *mapName, qboolean loadGame );
void SV_SysError( const char *error_string );
void SV_InitGameProgs( void );
void SV_FreeGameProgs( void );
void SV_ForceError( void );
void CL_WriteMessageHistory( void );
void CL_MouseEvent( int mx, int my );

View File

@ -892,6 +892,8 @@ void Host_WriteServerConfig( const char *name )
FS_Close( f );
}
else MsgDev( D_ERROR, "Couldn't write %s.\n", name );
SV_FreeGameProgs(); // release progs with all variables
}
/*

View File

@ -1389,6 +1389,8 @@ void FS_LoadGameInfo( const char *rootfolder )
SI.GameInfo = SI.games[i];
FS_Rescan(); // create new filesystem
Host_InitDecals (); // reload decals
}
/*

View File

@ -511,19 +511,16 @@ void Host_Error( const char *error, ... )
if( host.framecount < 3 )
{
SV_SysError( hosterror1 );
Sys_Error( "Host_InitError: %s", hosterror1 );
}
else if( host.framecount == host.errorframe )
{
SV_SysError( hosterror2 );
Sys_Error( "Host_MultiError: %s", hosterror2 );
return;
}
else
{
Msg( "Host_Error: %s", hosterror1 );
SV_SysError( hosterror1 );
}
// host is shutting down. don't invoke infinite loop
@ -562,7 +559,6 @@ void Sys_Error_f( void )
const char *error = Cmd_Argv( 1 );
if( !*error ) error = "Invoked sys error";
SV_SysError( error );
Sys_Error( "%s\n", error );
}
@ -647,6 +643,8 @@ void Host_InitCommon( const char *progname, qboolean bChangeGame )
return;
}
Sys_MergeCommandLine( GetCommandLine( ));
CloseHandle( host.hMutex );
host.hMutex = CreateSemaphore( NULL, 0, 1, "Xash Dedicated Server" );
if( host.developer < 3 ) host.developer = 3; // otherwise we see empty console
@ -661,7 +659,8 @@ void Host_InitCommon( const char *progname, qboolean bChangeGame )
if( GetModuleFileName( hCurrent, szTemp, sizeof( szTemp )))
FS_FileBase( szTemp, szTemp );
if( Q_stricmp( szTemp, "xash" ))
// protect to rename xash.dll
if( Q_stricmp( szTemp, "xash" ) && Com_RandomLong( 0, 1 ))
{
host.type = HOST_CREDITS;
host.con_showalways = true;
@ -673,7 +672,6 @@ void Host_InitCommon( const char *progname, qboolean bChangeGame )
// first text message into console or log
MsgDev( D_NOTE, "Sys_LoadLibrary: Loading xash.dll - ok\n" );
Sys_MergeCommandLine( GetCommandLine( ));
// startup cmds and cvars subsystem
Cmd_Init();
@ -690,10 +688,10 @@ void Host_InitCommon( const char *progname, qboolean bChangeGame )
Sound_Init();
FS_LoadGameInfo( NULL );
HPAK_Init();
Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));
Host_InitEvents();
Host_InitDecals();
HPAK_Init();
IN_Init();
Key_Init();
@ -835,8 +833,6 @@ void EXPORT Host_Shutdown( void )
CL_Shutdown();
Mod_Shutdown();
S_Shutdown();
R_Shutdown();
NET_Shutdown();
Host_FreeCommon();
Con_DestroyConsole();

View File

@ -726,7 +726,6 @@ void Delta_InitFields( void )
static string errormsg;
Q_snprintf( errormsg, sizeof( errormsg ), "DELTA_Load: couldn't load file %s\n", DELTA_PATH );
SV_SysError( errormsg );
Sys_Error( errormsg );
}

View File

@ -5,7 +5,7 @@
#ifndef PROTOCOL_H
#define PROTOCOL_H
#define PROTOCOL_VERSION 40
#define PROTOCOL_VERSION 41
// server to client
#define svc_bad 0 // immediately crash client when received

View File

@ -172,11 +172,15 @@ Sys_ParseCommandLine
void Sys_ParseCommandLine( LPSTR lpCmdLine )
{
const char *blank = "censored";
static char commandline[1024];
int i;
host.argc = 1;
host.argv[0] = "exe";
Q_strncpy( commandline, lpCmdLine, Q_strlen( lpCmdLine ) + 1 );
lpCmdLine = commandline; // prevent to modify original commandline
while( *lpCmdLine && ( host.argc < MAX_NUM_ARGVS ))
{
while( *lpCmdLine && *lpCmdLine <= ' ' )
@ -490,10 +494,10 @@ long _stdcall Sys_Crash( PEXCEPTION_POINTERS pInfo )
{
// check to avoid recursive call
error_on_exit = true;
host.state = HOST_CRASHED;
if( host.type == HOST_NORMAL ) CL_Crashed(); // tell client about crash
Msg( "Sys_Crash: call %p at address %p\n", pInfo->ExceptionRecord->ExceptionAddress, pInfo->ExceptionRecord->ExceptionCode );
host.state = HOST_CRASHED;
if( host.developer <= 0 )
{
@ -536,7 +540,9 @@ void Sys_Error( const char *error, ... )
Q_vsprintf( text, error, argptr );
va_end( argptr );
if( host.type = HOST_NORMAL )
SV_SysError( text );
if( host.type == HOST_NORMAL )
CL_Shutdown(); // kill video
if( host.developer > 0 )
@ -568,20 +574,20 @@ void Sys_Break( const char *error, ... )
if( host.state == HOST_ERR_FATAL )
return; // don't multiple executes
error_on_exit = true;
host.state = HOST_ERR_FATAL;
va_start( argptr, error );
Q_vsprintf( text, error, argptr );
va_end( argptr );
error_on_exit = true;
host.state = HOST_ERR_FATAL;
if( host.type == HOST_NORMAL )
CL_Shutdown(); // kill video
if( host.type != HOST_NORMAL || host.developer > 0 )
{
Con_ShowConsole( true );
Con_DisableInput(); // disable input line for dedicated server
Sys_Print( text );
Sys_WaitForQuit();
}

View File

@ -613,6 +613,7 @@ void SV_Info( netadr_t from )
Info_SetValueForKey( string, "coop", va( "%i", svgame.globals->coop ));
Info_SetValueForKey( string, "numcl", va( "%i", count ));
Info_SetValueForKey( string, "maxcl", va( "%i", sv_maxclients->integer ));
Info_SetValueForKey( string, "gamedir", GI->gamefolder );
}
Netchan_OutOfBandPrint( NS_SERVER, from, "info\n%s", string );
}
@ -1016,6 +1017,7 @@ void SV_New_f( sv_client_t *cl )
BF_WriteString( &cl->netchan.message, sv.name );
BF_WriteString( &cl->netchan.message, STRING( EDICT_NUM( 0 )->v.message )); // Map Message
BF_WriteOneBit( &cl->netchan.message, sv.background ); // tell client about background map
BF_WriteString( &cl->netchan.message, GI->gamefolder );
// refresh userinfo on spawn
SV_RefreshUserinfo();

View File

@ -516,6 +516,10 @@ void SV_InitGame( void )
}
else
{
// restore gamefolder here (in case client was connected to another game)
if( Q_stricmp( host.gamefolder, GI->gamefolder ))
FS_LoadGameInfo( host.gamefolder );
// init game after host error
if( !svgame.hInstance )
{
@ -622,6 +626,14 @@ void SV_InitGameProgs( void )
SV_LoadProgs( GI->game_dll );
}
void SV_FreeGameProgs( void )
{
if( svs.initialized ) return; // server is active
// unload progs (and free cvars and commands)
SV_UnloadProgs();
}
qboolean SV_NewGame( const char *mapName, qboolean loadGame )
{
if( !loadGame )

View File

@ -615,7 +615,8 @@ void SV_Init( void )
Cvar_Get ("sv_language", "0", 0, "game language (currently unused)" );
Cvar_Get ("suitvolume", "0.25", CVAR_ARCHIVE, "HEV suit volume" );
Cvar_Get ("sv_background", "0", CVAR_READ_ONLY, "indicate what background map is running" );
Cvar_Get( "gamedir", GI->gamefolder, CVAR_SERVERINFO|CVAR_SERVERNOTIFY|CVAR_INIT, "game folder" );
// half-life shared variables
sv_zmax = Cvar_Get ("sv_zmax", "4096", CVAR_PHYSICINFO, "zfar server value" );
sv_wateramp = Cvar_Get ("sv_wateramp", "0", CVAR_PHYSICINFO, "global water wave height" );

View File

@ -307,7 +307,7 @@ typedef struct
int menuDepth;
netadr_t serverAddresses[UI_MAX_SERVERS];
char serverNames[UI_MAX_SERVERS][80];
char serverNames[UI_MAX_SERVERS][256];
int numServers;
int updateServers; // true is receive new info about servers

View File

@ -124,6 +124,9 @@ static void UI_LanGame_GetGamesList( void )
{
if( i >= UI_MAX_SERVERS ) break;
info = uiStatic.serverNames[i];
// if( stricmp( gMenu.m_gameinfo.gamefolder, Info_ValueForKey( info, "gamedir" )))
// continue; // filter by game
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "host" ), GAME_LENGTH );
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, GAME_LENGTH );

View File

@ -3,26 +3,21 @@
#include "utils.h"
#include "ui_title_anim.h"
cvar_t* cr_banner_fix_x;
cvar_t* cr_banner_fix_y;
#define BANNER_X_FIX -16
#define BANNER_Y_FIX -20
#define BANNER_X_FIX -16
#define BANNER_Y_FIX -20
// Title Transition Time period
#define TTT_PERIOD 200.0f
#define TTT_PERIOD 200.0f
quad_t TitleLerpQuads[2];
int transition_initial_time;
int transition_state;
HIMAGE TransPic=0;
HIMAGE TransPic = 0;
int PreClickDepth;
void UI_TACheckMenuDepth()
void UI_TACheckMenuDepth( void )
{
PreClickDepth=uiStatic.menuDepth;
PreClickDepth = uiStatic.menuDepth;
}
menuPicButton_s *ButtonStack[UI_MAX_MENUDEPTH];
@ -30,110 +25,107 @@ int ButtonStackDepth;
void UI_PopPButtonStack()
{
UI_SetTitleAnim(AS_TO_BUTTON,ButtonStack[ButtonStackDepth]);
UI_SetTitleAnim( AS_TO_BUTTON, ButtonStack[ButtonStackDepth] );
ButtonStackDepth--;
}
void UI_PushPButtonStack(menuPicButton_s*button)
void UI_PushPButtonStack( menuPicButton_s *button )
{
if (ButtonStack[ButtonStackDepth]==button) return;
// UI_PushMenu ïîìàòåðèòüñÿ çà íàñ åñëè ãëóáèíà ïðåâûñèëà äîïóñòèìîå çíà÷åíèå, íàäåþñü
if( ButtonStack[ButtonStackDepth] == button )
return;
ButtonStackDepth++;
ButtonStack[ButtonStackDepth]=button;
ButtonStack[ButtonStackDepth] = button;
}
float UI_GetTitleTransFraction()
float UI_GetTitleTransFraction( void )
{
float fraction=(float)(uiStatic.realTime-transition_initial_time)/TTT_PERIOD;
float fraction = (float)(uiStatic.realTime - transition_initial_time ) / TTT_PERIOD;
if (fraction>1) fraction=1;
if( fraction > 1.0f )
fraction = 1.0f;
return fraction;
}
void LerpQuad(quad_t a,quad_t b,float frac,quad_t * c)
void LerpQuad( quad_t a, quad_t b, float frac, quad_t *c )
{
c->x=a.x+(b.x-a.x)*frac;
c->y=a.y+(b.y-a.y)*frac;
c->lx=a.lx+(b.lx-a.lx)*frac;
c->ly=a.ly+(b.ly-a.ly)*frac;
c->x = a.x + (b.x - a.x) * frac;
c->y = a.y + (b.y - a.y) * frac;
c->lx = a.lx + (b.lx - a.lx) * frac;
c->ly = a.ly + (b.ly - a.ly) * frac;
}
void UI_SetupTitleQuad()
{
TitleLerpQuads[1].x=UI_BANNER_POSX+BANNER_X_FIX;
TitleLerpQuads[1].y=UI_BANNER_POSY+BANNER_Y_FIX;
TitleLerpQuads[1].lx=UI_BANNER_WIDTH-125;
TitleLerpQuads[1].ly=UI_BANNER_HEIGHT-40;
TitleLerpQuads[1].x = UI_BANNER_POSX + BANNER_X_FIX;
TitleLerpQuads[1].y = UI_BANNER_POSY + BANNER_Y_FIX;
TitleLerpQuads[1].lx = UI_BANNER_WIDTH - 125;
TitleLerpQuads[1].ly = UI_BANNER_HEIGHT - 40;
}
void UI_DrawTitleAnim()
{
UI_SetupTitleQuad();
if (!TransPic) return;
if( !TransPic ) return;
wrect_t r={ 0, uiStatic.buttons_width, 26, 51 };
wrect_t r = { 0, uiStatic.buttons_width, 26, 51 };
float frac=UI_GetTitleTransFraction();/*(sin(gpGlobals->time*4)+1)/2*/;
float frac = UI_GetTitleTransFraction();/*(sin(gpGlobals->time*4)+1)/2*/;
#ifdef TA_ALT_MODE
if (frac==1 && transition_state==AS_TO_BUTTON) return;
if( frac == 1 && transition_state == AS_TO_BUTTON )
return;
#else
if (frac==1) return;
if( frac == 1 ) return;
#endif
quad_t c;
int f_idx=(transition_state==AS_TO_TITLE) ? 0 : 1;
int s_idx=(transition_state==AS_TO_TITLE) ? 1 : 0;
int f_idx = (transition_state == AS_TO_TITLE) ? 0 : 1;
int s_idx = (transition_state == AS_TO_TITLE) ? 1 : 0;
LerpQuad(TitleLerpQuads[f_idx],TitleLerpQuads[s_idx],frac,&c);
LerpQuad( TitleLerpQuads[f_idx], TitleLerpQuads[s_idx], frac, &c );
PIC_Set(TransPic,255,255,255,255);
PIC_DrawAdditive(c.x,c.y,c.lx,c.ly,&r);
PIC_Set( TransPic, 255, 255, 255, 255 );
PIC_DrawAdditive( c.x, c.y, c.lx, c.ly, &r );
}
void UI_SetTitleAnim(int anim_state,menuPicButton_s* button)
void UI_SetTitleAnim( int anim_state, menuPicButton_s *button )
{
// skip buttons which don't call new menu
if (PreClickDepth==uiStatic.menuDepth && anim_state==AS_TO_TITLE) return;
if( !button || PreClickDepth == uiStatic.menuDepth && anim_state == AS_TO_TITLE )
return;
// replace cancel\done button with button which called this menu
if (PreClickDepth>uiStatic.menuDepth && anim_state==AS_TO_TITLE)
{
anim_state=AS_TO_BUTTON;
// HACK HACK HACK
if (ButtonStack[ButtonStackDepth+1])
button=ButtonStack[ButtonStackDepth+1];
}
if( PreClickDepth > uiStatic.menuDepth && anim_state == AS_TO_TITLE )
anim_state = AS_TO_BUTTON;
// don't reset anim if dialog buttons pressed
if (button->generic.id==130 || button->generic.id==131) return;
if( button->generic.id == 130 || button->generic.id == 131 )
return;
if (anim_state==AS_TO_TITLE)
UI_PushPButtonStack(button);
if( anim_state == AS_TO_TITLE )
UI_PushPButtonStack( button );
transition_state=anim_state;
transition_state = anim_state;
TitleLerpQuads[0].x=button->generic.x;
TitleLerpQuads[0].y=button->generic.y;
TitleLerpQuads[0].lx=button->generic.width;
TitleLerpQuads[0].ly=button->generic.height;
TitleLerpQuads[0].x = button->generic.x;
TitleLerpQuads[0].y = button->generic.y;
TitleLerpQuads[0].lx = button->generic.width;
TitleLerpQuads[0].ly = button->generic.height;
transition_initial_time=uiStatic.realTime;
TransPic=button->pic;
transition_initial_time = uiStatic.realTime;
TransPic = button->pic;
}
void UI_InitTitleAnim()
{
// cr_banner_fix_x=g_engfuncs.pfnRegisterVariable("cr_banner_fix_x","1",0);
// cr_banner_fix_y=g_engfuncs.pfnRegisterVariable("cr_banner_fix_y","1",0);
memset(TitleLerpQuads,0,sizeof(quad_t)*2);
memset( TitleLerpQuads, 0, sizeof( quad_t ) * 2 );
UI_SetupTitleQuad();
ButtonStackDepth=0;
memset(ButtonStack,0,sizeof(ButtonStack));
}
ButtonStackDepth = 0;
memset( ButtonStack, 0, sizeof( ButtonStack ));
}

View File

@ -1,18 +1,18 @@
#define AS_TO_TITLE 1
#define AS_TO_BUTTON 2
#define AS_TO_TITLE 1
#define AS_TO_BUTTON 2
void UI_SetTitleAnim(int anim_state,menuPicButton_s* picid);
void UI_DrawTitleAnim();
void UI_InitTitleAnim();
void UI_TACheckMenuDepth();
float UI_GetTitleTransFraction();
void UI_SetTitleAnim( int anim_state, menuPicButton_s *picid );
void UI_DrawTitleAnim( void );
void UI_InitTitleAnim( void );
void UI_TACheckMenuDepth( void );
float UI_GetTitleTransFraction( void );
typedef struct
{
int x,y,lx,ly;
}quad_t;
int x, y, lx, ly;
} quad_t;
void UI_PopPButtonStack();
void UI_PopPButtonStack( void );
// Èñïîëüçîâàòü êóñîê èç btns_main.bmp çàìåñòî head_%s.bmp
// èñïîëüçîâàòü êóñîê èç btns_main.bmp çàìåñòî head_%s.bmp
//#define TA_ALT_MODE 1