18 Nov 2010

This commit is contained in:
g-cont 2010-11-18 00:00:00 +03:00 committed by Alibek Omarov
parent 7e9f934ce3
commit aeb70b1c6f
17 changed files with 291 additions and 108 deletions

View File

@ -40,8 +40,6 @@ static dllfunc_t cdll_exports[] =
{ "HUD_ConnectionlessPacket", (void **)&clgame.dllFuncs.pfnConnectionlessPacket },
{ "HUD_GetHullBounds", (void **)&clgame.dllFuncs.pfnGetHullBounds },
{ "HUD_Frame", (void **)&clgame.dllFuncs.pfnFrame },
{ "HUD_VoiceStatus", (void **)&clgame.dllFuncs.pfnVoiceStatus },
{ "HUD_DirectorMessage", (void **)&clgame.dllFuncs.pfnDirectorMessage },
{ "HUD_PostRunCmd", (void **)&clgame.dllFuncs.pfnPostRunCmd },
{ "HUD_Key_Event", (void **)&clgame.dllFuncs.pfnKey_Event },
{ "HUD_AddEntity", (void **)&clgame.dllFuncs.pfnAddEntity },
@ -51,7 +49,6 @@ static dllfunc_t cdll_exports[] =
{ "HUD_ProcessPlayerState", (void **)&clgame.dllFuncs.pfnProcessPlayerState },
{ "HUD_TxferPredictionData", (void **)&clgame.dllFuncs.pfnTxferPredictionData },
{ "HUD_TempEntUpdate", (void **)&clgame.dllFuncs.pfnTempEntUpdate },
{ "HUD_GetStudioModelInterface", (void **)&clgame.dllFuncs.pfnGetStudioModelInterface },
{ "HUD_DrawNormalTriangles", (void **)&clgame.dllFuncs.pfnDrawNormalTriangles },
{ "HUD_DrawTransparentTriangles", (void **)&clgame.dllFuncs.pfnDrawTransparentTriangles },
{ "HUD_GetUserEntity", (void **)&clgame.dllFuncs.pfnGetUserEntity },
@ -69,6 +66,14 @@ static dllfunc_t cdll_exports[] =
{ NULL, NULL }
};
static dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3
{
{ "HUD_GetStudioModelInterface", (void **)&clgame.dllFuncs.pfnGetStudioModelInterface },
{ "HUD_DirectorMessage", (void **)&clgame.dllFuncs.pfnDirectorMessage },
{ "HUD_VoiceStatus", (void **)&clgame.dllFuncs.pfnVoiceStatus },
{ NULL, NULL }
};
/*
====================
CL_GetEntityByIndex
@ -1835,8 +1840,8 @@ prints dirctly into console (can skip notify)
static void pfnConsolePrint( const char *string )
{
if( !string || !*string ) return;
if( *string != 1 ) Con_Print( string ); // show notify
else Con_Print( va( "[skipnotify]%s", string + 1 )); // skip notify
if( *string != 1 ) Msg( string ); // show notify
else Msg( "[skipnotify]%s", string + 1 ); // skip notify
}
/*
@ -3574,9 +3579,10 @@ void CL_UnloadProgs( void )
CL_FreeTempEnts();
CL_FreeViewBeams();
CL_FreeParticles();
VGui_Shutdown();
clgame.dllFuncs.pfnShutdown();
FS_FreeLibrary( clgame.hInstance );
Mem_FreePool( &cls.mempool );
Mem_FreePool( &clgame.mempool );
@ -3600,6 +3606,11 @@ qboolean CL_LoadProgs( const char *name )
clgame.mempool = Mem_AllocPool( "Client Edicts Zone" );
clgame.entities = NULL;
// NOTE: important stuff!
// vgui must startup BEFORE loading client.dll to avoid get error ERROR_NOACESS
// during LoadLibrary
VGui_Startup ();
clgame.hInstance = FS_LoadLibrary( name, false );
if( !clgame.hInstance ) return false;
@ -3619,6 +3630,18 @@ qboolean CL_LoadProgs( const char *name )
}
}
// clear new exports
for( func = cdll_new_exports; func && func->name; func++ )
*func->func = NULL;
for( func = cdll_new_exports; func && func->name != NULL; func++ )
{
// functions are cleared before all the extensions are evaluated
// NOTE: new exports can be missed without stop the engine
if(!( *func->func = (void *)FS_GetProcAddress( clgame.hInstance, func->name )))
MsgDev( D_NOTE, "CL_LoadProgs: failed to get address of %s proc\n", func->name );
}
if( !clgame.dllFuncs.pfnInitialize( &gEngfuncs, CLDLL_INTERFACE_VERSION ))
{
FS_FreeLibrary( clgame.hInstance );
@ -3643,8 +3666,6 @@ qboolean CL_LoadProgs( const char *name )
CL_InitViewBeams ();
CL_InitTempEnts ();
VGui_Startup ();
// initialize game
clgame.dllFuncs.pfnInit();

View File

@ -261,6 +261,7 @@ void SCR_UpdateScreen( void )
if( !clgame.hInstance ) return;
clgame.dllFuncs.pfnFrame( cl.time );
VGui_Paint ();
}

View File

@ -511,6 +511,10 @@ Initialize client studio
*/
qboolean CL_InitStudioAPI( void )
{
// Xash will be used internal StudioModelRenderer
if( !clgame.dllFuncs.pfnGetStudioModelInterface )
return true;
pStudioDraw = NULL; // clear previous API
return clgame.dllFuncs.pfnGetStudioModelInterface( STUDIO_INTERFACE_VERSION, &pStudioDraw, &gStudioAPI );

View File

@ -690,6 +690,7 @@ extern "C" {
#endif
void VGui_Startup( void );
void VGui_Shutdown( void );
void *VGui_GetPanel( void );
void VGui_Paint( void );
void VGui_ViewportPaintBackground( int extents[4] );

View File

@ -705,19 +705,19 @@ qboolean Cmd_GetGamesList( const char *s, char *completedname, int length )
return true;
}
qboolean Cmd_CheckMapsList( qboolean fRefresh )
qboolean Cmd_CheckMapsList_R( qboolean fRefresh, qboolean onlyingamedir )
{
byte buf[MAX_MSGLEN];
byte buf[MAX_SYSPATH];
char *buffer;
string result;
int i, size;
search_t *t;
file_t *f;
int i;
if( FS_FileExistsEx( "maps.lst", true ) && !fRefresh )
if( FS_FileSizeEx( "maps.lst", onlyingamedir ) > 0 && !fRefresh )
return true; // exist
t = FS_SearchExt( "maps/*.bsp", false, true );
t = FS_SearchExt( "maps/*.bsp", false, onlyingamedir );
if( !t ) return false;
buffer = Mem_Alloc( host.mempool, t->numfilenames * 2 * sizeof( result ));
@ -729,7 +729,7 @@ qboolean Cmd_CheckMapsList( qboolean fRefresh )
const char *ext = FS_FileExtension( t->filenames[i] );
if( com.stricmp( ext, "bsp" )) continue;
f = FS_OpenEx( t->filenames[i], "rb", true );
f = FS_OpenEx( t->filenames[i], "rb", onlyingamedir );
FS_FileBase( t->filenames[i], mapname );
if( f )
@ -817,6 +817,13 @@ qboolean Cmd_CheckMapsList( qboolean fRefresh )
}
if( t ) Mem_Free( t ); // free search result
size = com.strlen( buffer );
if( !size && onlyingamedir )
{
if( buffer ) Mem_Free( buffer );
return Cmd_CheckMapsList_R( fRefresh, false );
}
// write generated maps.lst
if( FS_WriteFile( "maps.lst", buffer, com.strlen( buffer )))
{
@ -826,6 +833,11 @@ qboolean Cmd_CheckMapsList( qboolean fRefresh )
return false;
}
qboolean Cmd_CheckMapsList( qboolean fRefresh )
{
return Cmd_CheckMapsList_R( fRefresh, true );
}
autocomplete_list_t cmd_list[] =
{
{ "gl_texturemode", Cmd_GetTexturemodes },

View File

@ -833,7 +833,7 @@ void Host_Init( const int argc, const char **argv )
if( host.type != HOST_DEDICATED )
{
// NOTE: client.dll must be loaded first to get mlook state from congig.cfg
// NOTE: client.dll must be loaded first to get mlook state from config.cfg
if( !CL_LoadProgs( va( "%s/client.dll", GI->dll_path )))
Host_Error( "CL_InitGame: can't initialize client.dll\n" );

View File

@ -456,8 +456,8 @@ long IN_WndProc( void *hWnd, uint uMsg, uint wParam, long lParam )
break;
case WM_CREATE:
host.hWnd = hWnd;
scr_xpos = Cvar_Get( "r_xpos", "3", CVAR_ARCHIVE, "window position by horizontal" );
scr_ypos = Cvar_Get( "r_ypos", "22", CVAR_ARCHIVE, "window position by vertical" );
scr_xpos = Cvar_Get( "r_xpos", "130", CVAR_ARCHIVE, "window position by horizontal" );
scr_ypos = Cvar_Get( "r_ypos", "48", CVAR_ARCHIVE, "window position by vertical" );
scr_fullscreen = Cvar_Get( "fullscreen", "0", CVAR_ARCHIVE|CVAR_LATCH_VIDEO, "toggle fullscreen" );
GetWindowRect( host.hWnd, &real_rect );
break;

View File

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

View File

@ -11,99 +11,158 @@
#include<VGUI_App.h>
#include<VGUI_Panel.h>
#include<VGUI_SurfaceBase.h>
#include<VGUI_Surface.h>
#include<VGUI_SurfaceGL.h>
#include<VGUI_ActionSignal.h>
#include<VGUI_BorderLayout.h>
using namespace vgui;
SurfaceGL::SurfaceGL( Panel* embeddedPanel ):Surface( embeddedPanel )
class CEngineSurface : public SurfaceBase
{
_embeddedPanel = embeddedPanel;
}
public:
CEngineSurface( Panel *embeddedPanel ):SurfaceBase( embeddedPanel )
{
_embeddedPanel = embeddedPanel;
}
public:
virtual void setTitle( const char *title )
{
Msg( "SetTitle: %s\n", title );
}
void SurfaceGL::texturedRect( int x0, int y0, int x1, int y1 )
{
Msg( "texturedRect: %i %i %i %i\n", x0, y0, x1, y1 );
}
bool SurfaceGL:: recreateContext()
{
return true;
}
void SurfaceGL:: createPopup( Panel *embeddedPanel )
{
}
virtual bool setFullscreenMode( int wide, int tall, int bpp )
{
return false;
}
void SurfaceGL:: pushMakeCurrent( Panel* panel, bool useInsets )
{
}
virtual void setWindowedMode( void )
{
}
void SurfaceGL:: popMakeCurrent( Panel* panel )
{
}
virtual void setAsTopMost( bool state )
{
}
void SurfaceGL:: makeCurrent( void )
{
}
virtual int getModeInfoCount( void )
{
Msg( "getModeInfoCount()\n" );
return 0;
}
void SurfaceGL::swapBuffers( void )
{
}
virtual void createPopup( Panel* embeddedPanel )
{
}
void SurfaceGL::setColor( int r, int g, int b )
{
}
virtual bool hasFocus( void )
{
Msg( "hasFocus()\n" );
return false;
}
void SurfaceGL::filledRect( int x0, int y0, int x1, int y1 )
{
}
virtual bool isWithin( int x, int y )
{
Msg( "isWithin()\n" );
return false;
}
protected:
virtual int createNewTextureID( void )
{
Msg( "createNewTextureID()\n" );
return 0;
}
void SurfaceGL::outlinedRect( int x0, int y0, int x1, int y1 )
{
}
virtual void drawSetColor( int r, int g, int b, int a )
{
}
void SurfaceGL::setTextFont( Font* font )
{
}
virtual void drawFilledRect( int x0, int y0, int x1, int y1 )
{
}
void SurfaceGL::setTextColor( int r, int g, int b )
{
Msg( "setTextColor: %i %i %i\n", r, g, b );
}
virtual void drawOutlinedRect( int x0,int y0,int x1,int y1 )
{
}
virtual void drawSetTextFont( Font *font )
{
}
void SurfaceGL::setDrawPos( int x, int y )
{
Msg( "setDrawPos: %i %i\n", x, y );
}
virtual void drawSetTextColor( int r, int g, int b, int a )
{
}
void SurfaceGL::printText( const char *str, int strlen )
{
Msg( "printText: %s\n", str );
}
virtual void drawSetTextPos( int x, int y )
{
}
void SurfaceGL::setTextureRGBA( int id, const char *rgba, int wide, int tall )
{
Msg( "setTextureRGBA: %i\n", id );
}
virtual void drawPrintText( const char* text, int textLen )
{
}
void SurfaceGL::setTexture( int id )
{
Msg( "setTexture: %i\n", id );
}
virtual void drawSetTextureRGBA( int id, const char* rgba, int wide, int tall )
{
}
virtual void drawSetTexture( int id )
{
}
virtual void drawTexturedRect( int x0, int y0, int x1, int y1 )
{
}
virtual void invalidate( Panel *panel )
{
}
virtual bool createPlat()
{
return false;
}
virtual bool recreateContext()
{
return false;
}
virtual void enableMouseCapture(bool state)
{
}
virtual void setCursor(Cursor* cursor)
{
}
virtual void swapBuffers()
{
}
virtual void pushMakeCurrent(Panel* panel,bool useInsets)
{
}
virtual void popMakeCurrent(Panel* panel)
{
}
virtual void applyChanges( void )
{
}
protected:
friend class App;
friend class Panel;
};
class CEngineApp : public App
{
public:
CEngineApp( void )
{
reset();
App::reset();
}
virtual void main( int argc, char* argv[] )
{
Msg( "App main()\n" );
}
virtual void setCursorPos( int x, int y )
@ -116,51 +175,105 @@ public:
App::getCursorPos( x, y );
Msg( "getCursorPos: %i %i\n", x, y );
}
};
class CEnginePanel : public Panel, public CEngineApp
{
typedef Panel BaseClass;
public:
CEnginePanel( void )
virtual App* getApp( void )
{
_surfaceBase = new SurfaceGL( this );
setSurfaceBaseTraverse( _surfaceBase );
setParent( NULL );
return this;
}
};
CEngineSurface *surface = NULL;
CEngineApp *pApp = NULL;
class CEnginePanel : public Panel
{
public:
CEnginePanel()
{
vgui::Panel();
}
CEnginePanel( int x, int y, int wide, int tall )
{
vgui::Panel( x, y, wide, tall );
}
virtual SurfaceBase* getSurfaceBase( void )
{
return surface;
}
virtual App* getApp( void )
{
return pApp;
}
virtual void paintBackground( void )
{
for( int i = 0; i < getChildCount(); i++ )
{
Panel *pChild = getChild( i );
pChild->repaintAll();
}
}
friend class Panel;
friend class App;
friend class SurfaceBase;
friend class Image;
};
CEnginePanel *rootpanel = NULL;
void VGui_Startup( void )
{
if( rootpanel )
{
rootpanel->reset();
// rootpanel->reset();
rootpanel->setSize( menu.globals->scrWidth, menu.globals->scrHeight );
return;
}
rootpanel = new CEnginePanel();
rootpanel->setLayout( new BorderLayout( 0 ));
rootpanel->setEnabled( true );
rootpanel = new CEnginePanel;
rootpanel->setPaintBorderEnabled( false );
rootpanel->setPaintBackgroundEnabled( false );
rootpanel->setVisible( true );
rootpanel->setCursor( new Cursor( Cursor::dc_none ));
pApp = new CEngineApp;
pApp->setMinimumTickMillisInterval( 0 );
surface = new CEngineSurface( rootpanel );
ASSERT( rootpanel->getApp() != NULL );
ASSERT( rootpanel->getSurfaceBase() != NULL );
}
void VGui_Shutdown( void )
{
delete rootpanel;
delete surface;
delete pApp;
rootpanel = NULL;
surface = NULL;
pApp = NULL;
}
void VGui_Paint( void )
{
if( !rootpanel ) return;
rootpanel->solveTraverse();
rootpanel->paintTraverse();
rootpanel->paintBackground();
}
void VGui_ViewportPaintBackground( int extents[4] )
{
Msg( "paint()\n" );
if( !rootpanel ) return;
Msg( "ViewportPaintBackground()\n" );
Panel *pVPanel = surface->getPanel();
if( !pVPanel ) return;
rootpanel->setBounds( extents[0], extents[1], extents[2], extents[3] );
rootpanel->repaint();
// paint everything
rootpanel->paintTraverse();
}
void *VGui_GetPanel( void )

View File

@ -4,7 +4,7 @@
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=LAUNCH - WIN32 RELEASE
CFG=game - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
@ -13,7 +13,7 @@ CFG=LAUNCH - WIN32 RELEASE
!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 "game.mak" CFG="LAUNCH - WIN32 RELEASE"
!MESSAGE NMAKE /f "game.mak" CFG="game - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
@ -59,11 +59,11 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\game.rc
SOURCE=.\game.cpp
# End Source File
# Begin Source File
SOURCE=.\game.cpp
SOURCE=.\game.rc
# End Source File
# End Group
# Begin Group "Header Files"

29
game_launch/game.dsw Normal file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "game"=.\game.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@ -1904,7 +1904,7 @@ void FS_InitRootDir( char *path )
// just set cwd
GetModuleFileName( NULL, szTemp, MAX_SYSPATH );
FS_ExtractFilePath( szTemp, szTemp );
SetCurrentDirectory ( szTemp );
SetCurrentDirectory( szTemp );
// use extended pathname
fs_ext_path = true;

View File

@ -19,7 +19,7 @@
#define LAUNCH_DLL // ignore alias names
#include "launch_api.h"
#define XASH_VERSION 0.72f // current version will be shared across gameinfo struct
#define XASH_VERSION 0.73f // current version will be shared across gameinfo struct
#define MAX_NUM_ARGVS 128
#define MAX_CMD_TOKENS 80

View File

@ -760,7 +760,7 @@ void *Com_LoadLibraryExt( const char *dllname, int build_ordinals_table, qboolea
if( !hInst->hInstance )
{
MsgDev( D_NOTE, "Sys_LoadLibrary: Loading %s - failed\n", dllname );
MsgDev( D_NOTE, "Sys_LoadLibrary: Loading %s - failed. Error %i\n", dllname );
Com_FreeLibrary( hInst );
return NULL;
}

View File

@ -204,6 +204,8 @@ static void UI_CreateGame_GetMapsList( void )
numMaps++;
}
if( !numMaps ) uiCreateGame.done.generic.flags |= QMF_GRAYED;
for( ; numMaps < UI_MAXGAMES; numMaps++ ) uiCreateGame.mapsDescriptionPtr[numMaps] = NULL;
uiCreateGame.mapsList.itemNames = (const char **)uiCreateGame.mapsDescriptionPtr;
FREE_FILE( afile );

View File

@ -494,8 +494,8 @@ qboolean R_CreateWindow( int width, int height, qboolean fullscreen )
if( !fullscreen )
{
r_xpos = Cvar_Get( "r_xpos", "3", CVAR_ARCHIVE, "window position by horizontal" );
r_ypos = Cvar_Get( "r_ypos", "22", CVAR_ARCHIVE, "window position by vertical" );
r_xpos = Cvar_Get( "r_xpos", "130", CVAR_ARCHIVE, "window position by horizontal" );
r_ypos = Cvar_Get( "r_ypos", "48", CVAR_ARCHIVE, "window position by vertical" );
x = r_xpos->integer;
y = r_ypos->integer;

View File

@ -1758,7 +1758,7 @@ qboolean R_StudioComputeBBox( vec3_t bbox[8] )
if( p2[2] > studio_maxs[2] ) studio_maxs[2] = p2[2];
}
studio_radius = RadiusFromBounds( studio_mins, studio_maxs );
studio_radius = RadiusFromBounds( studio_mins, studio_maxs ) * e->scale;
return true;
}