1
0
Fork 0
forked from valve/halflife-sdk
halflife-sdk-steam/cl_dll/cdll_int.cpp

448 lines
9.5 KiB
C++
Raw Normal View History

1999-04-07 00:00:00 +00:00
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
1999-04-07 00:00:00 +00:00
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//
// cdll_int.c
//
// this implementation handles the linking of the engine to the DLL
//
#include "hud.h"
2000-06-05 00:00:00 +00:00
#include "cl_util.h"
#include "netadr.h"
#undef INTERFACE_H
#include "../public/interface.h"
//#include "vgui_schememanager.h"
2000-06-05 00:00:00 +00:00
extern "C"
{
#include "pm_shared.h"
}
1999-04-07 00:00:00 +00:00
#include <string.h>
2000-06-05 00:00:00 +00:00
#include "hud_servers.h"
#include "vgui_int.h"
2001-08-29 00:00:00 +00:00
#include "interface.h"
1999-04-07 00:00:00 +00:00
#ifdef _WIN32
#include "winsani_in.h"
#include <windows.h>
#include "winsani_out.h"
#endif
#include "Exports.h"
#
#include "tri.h"
#include "vgui_TeamFortressViewport.h"
#include "../public/interface.h"
2001-08-29 00:00:00 +00:00
1999-04-07 00:00:00 +00:00
cl_enginefunc_t gEngfuncs;
CHud gHUD;
2000-06-05 00:00:00 +00:00
TeamFortressViewport *gViewPort = NULL;
1999-04-07 00:00:00 +00:00
#include "particleman.h"
CSysModule *g_hParticleManModule = NULL;
IParticleMan *g_pParticleMan = NULL;
void CL_LoadParticleMan( void );
void CL_UnloadParticleMan( void );
2000-06-05 00:00:00 +00:00
void InitInput (void);
void EV_HookEvents( void );
void IN_Commands( void );
1999-04-07 00:00:00 +00:00
2000-06-05 00:00:00 +00:00
/*
================================
HUD_GetHullBounds
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
================================
*/
int CL_DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
2000-06-05 00:00:00 +00:00
{
// RecClGetHullBounds(hullnumber, mins, maxs);
2000-06-05 00:00:00 +00:00
int iret = 0;
switch ( hullnumber )
{
case 0: // Normal player
mins = Vector(-16, -16, -36);
maxs = Vector(16, 16, 36);
iret = 1;
break;
case 1: // Crouched player
mins = Vector(-16, -16, -18 );
maxs = Vector(16, 16, 18 );
iret = 1;
break;
case 2: // Point based hull
mins = Vector( 0, 0, 0 );
maxs = Vector( 0, 0, 0 );
iret = 1;
break;
}
return iret;
1999-04-07 00:00:00 +00:00
}
2000-06-05 00:00:00 +00:00
/*
================================
HUD_ConnectionlessPacket
Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
size of the response_buffer, so you must zero it out if you choose not to respond.
================================
*/
int CL_DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
2000-06-05 00:00:00 +00:00
{
// RecClConnectionlessPacket(net_from, args, response_buffer, response_buffer_size);
2000-06-05 00:00:00 +00:00
// Parse stuff from args
int max_buffer_size = *response_buffer_size;
// Zero it out since we aren't going to respond.
// If we wanted to response, we'd write data into response_buffer
*response_buffer_size = 0;
// Since we don't listen for anything here, just respond that it's a bogus message
// If we didn't reject the message, we'd return 1 for success instead.
return 0;
}
void CL_DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
2000-06-05 00:00:00 +00:00
{
// RecClClientMoveInit(ppmove);
2000-06-05 00:00:00 +00:00
PM_Init( ppmove );
}
char CL_DLLEXPORT HUD_PlayerMoveTexture( char *name )
2000-06-05 00:00:00 +00:00
{
// RecClClientTextureType(name);
2000-06-05 00:00:00 +00:00
return PM_FindTextureType( name );
}
void CL_DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
2000-06-05 00:00:00 +00:00
{
// RecClClientMove(ppmove, server);
2000-06-05 00:00:00 +00:00
PM_Move( ppmove, server );
}
1999-04-07 00:00:00 +00:00
int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
1999-04-07 00:00:00 +00:00
{
gEngfuncs = *pEnginefuncs;
// RecClInitialize(pEnginefuncs, iVersion);
1999-04-07 00:00:00 +00:00
if (iVersion != CLDLL_INTERFACE_VERSION)
return 0;
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
2000-06-05 00:00:00 +00:00
EV_HookEvents();
CL_LoadParticleMan();
2000-06-05 00:00:00 +00:00
// get tracker interface, if any
1999-04-07 00:00:00 +00:00
return 1;
}
/*
==========================
HUD_VidInit
Called when the game initializes
and whenever the vid_mode is changed
so the HUD can reinitialize itself.
==========================
*/
int CL_DLLEXPORT HUD_VidInit( void )
1999-04-07 00:00:00 +00:00
{
// RecClHudVidInit();
1999-04-07 00:00:00 +00:00
gHUD.VidInit();
2000-06-05 00:00:00 +00:00
VGui_Startup();
1999-04-07 00:00:00 +00:00
return 1;
}
/*
==========================
HUD_Init
Called whenever the client connects
to a server. Reinitializes all
the hud variables.
==========================
*/
void CL_DLLEXPORT HUD_Init( void )
1999-04-07 00:00:00 +00:00
{
// RecClHudInit();
2000-06-05 00:00:00 +00:00
InitInput();
1999-04-07 00:00:00 +00:00
gHUD.Init();
2000-06-05 00:00:00 +00:00
Scheme_Init();
1999-04-07 00:00:00 +00:00
}
/*
==========================
HUD_Redraw
called every screen frame to
redraw the HUD.
===========================
*/
int CL_DLLEXPORT HUD_Redraw( float time, int intermission )
1999-04-07 00:00:00 +00:00
{
// RecClHudRedraw(time, intermission);
1999-04-07 00:00:00 +00:00
gHUD.Redraw( time, intermission );
return 1;
}
/*
==========================
HUD_UpdateClientData
called every time shared client
dll/engine data gets changed,
and gives the cdll a chance
to modify the data.
returns 1 if anything has been changed, 0 otherwise.
==========================
*/
int CL_DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
1999-04-07 00:00:00 +00:00
{
// RecClHudUpdateClientData(pcldata, flTime);
2000-06-05 00:00:00 +00:00
IN_Commands();
1999-04-07 00:00:00 +00:00
return gHUD.UpdateClientData(pcldata, flTime );
}
/*
==========================
HUD_Reset
Called at start and end of demos to restore to "non"HUD state.
==========================
*/
void CL_DLLEXPORT HUD_Reset( void )
1999-04-07 00:00:00 +00:00
{
// RecClHudReset();
1999-04-07 00:00:00 +00:00
gHUD.VidInit();
2000-06-05 00:00:00 +00:00
}
/*
==========================
HUD_Frame
Called by engine every frame that client .dll is loaded
==========================
*/
void CL_DLLEXPORT HUD_Frame( double time )
2000-06-05 00:00:00 +00:00
{
// RecClHudFrame(time);
2000-06-05 00:00:00 +00:00
ServersThink( time );
2001-08-29 00:00:00 +00:00
GetClientVoiceMgr()->Frame(time);
}
/*
==========================
HUD_VoiceStatus
Called when a player starts or stops talking.
==========================
*/
void CL_DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
2001-08-29 00:00:00 +00:00
{
//// RecClVoiceStatus(entindex, bTalking);
2001-08-29 00:00:00 +00:00
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
}
/*
==========================
HUD_DirectorMessage
2001-08-29 00:00:00 +00:00
Called when a director event message was received
==========================
*/
void CL_DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
{
// RecClDirectorMessage(iSize, pbuf);
gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
}
void CL_UnloadParticleMan( void )
{
Sys_UnloadModule( g_hParticleManModule );
g_pParticleMan = NULL;
g_hParticleManModule = NULL;
}
void CL_LoadParticleMan( void )
{
char szPDir[512];
if ( gEngfuncs.COM_ExpandFilename( PARTICLEMAN_DLLNAME, szPDir, sizeof( szPDir ) ) == FALSE )
{
g_pParticleMan = NULL;
g_hParticleManModule = NULL;
return;
}
g_hParticleManModule = Sys_LoadModule( szPDir );
CreateInterfaceFn particleManFactory = Sys_GetFactory( g_hParticleManModule );
if ( particleManFactory == NULL )
{
g_pParticleMan = NULL;
g_hParticleManModule = NULL;
return;
}
g_pParticleMan = (IParticleMan *)particleManFactory( PARTICLEMAN_INTERFACE, NULL);
if ( g_pParticleMan )
{
g_pParticleMan->SetUp( &gEngfuncs );
// Add custom particle classes here BEFORE calling anything else or you will die.
g_pParticleMan->AddCustomParticleClassSize ( sizeof ( CBaseParticle ) );
}
}
cldll_func_dst_t *g_pcldstAddrs;
extern "C" void CL_DLLEXPORT F(void *pv)
2001-08-29 00:00:00 +00:00
{
cldll_func_t *pcldll_func = (cldll_func_t *)pv;
// Hack!
g_pcldstAddrs = ((cldll_func_dst_t *)pcldll_func->pHudVidInitFunc);
cldll_func_t cldll_func =
{
Initialize,
HUD_Init,
HUD_VidInit,
HUD_Redraw,
HUD_UpdateClientData,
HUD_Reset,
HUD_PlayerMove,
HUD_PlayerMoveInit,
HUD_PlayerMoveTexture,
IN_ActivateMouse,
IN_DeactivateMouse,
IN_MouseEvent,
IN_ClearStates,
IN_Accumulate,
CL_CreateMove,
CL_IsThirdPerson,
CL_CameraOffset,
KB_Find,
CAM_Think,
V_CalcRefdef,
HUD_AddEntity,
HUD_CreateEntities,
HUD_DrawNormalTriangles,
HUD_DrawTransparentTriangles,
HUD_StudioEvent,
HUD_PostRunCmd,
HUD_Shutdown,
HUD_TxferLocalOverrides,
HUD_ProcessPlayerState,
HUD_TxferPredictionData,
Demo_ReadBuffer,
HUD_ConnectionlessPacket,
HUD_GetHullBounds,
HUD_Frame,
HUD_Key_Event,
HUD_TempEntUpdate,
HUD_GetUserEntity,
HUD_VoiceStatus,
HUD_DirectorMessage,
HUD_GetStudioModelInterface,
HUD_ChatInputPosition,
};
*pcldll_func = cldll_func;
2001-08-29 00:00:00 +00:00
}
#include "cl_dll/IGameClientExports.h"
//-----------------------------------------------------------------------------
// Purpose: Exports functions that are used by the gameUI for UI dialogs
//-----------------------------------------------------------------------------
class CClientExports : public IGameClientExports
{
public:
// returns the name of the server the user is connected to, if any
virtual const char *GetServerHostName()
{
/*if (gViewPortInterface)
{
return gViewPortInterface->GetServerName();
}*/
return "";
}
// ingame voice manipulation
virtual bool IsPlayerGameVoiceMuted(int playerIndex)
{
if (GetClientVoiceMgr())
return GetClientVoiceMgr()->IsPlayerBlocked(playerIndex);
return false;
}
virtual void MutePlayerGameVoice(int playerIndex)
{
if (GetClientVoiceMgr())
{
GetClientVoiceMgr()->SetPlayerBlockedState(playerIndex, true);
}
}
virtual void UnmutePlayerGameVoice(int playerIndex)
{
if (GetClientVoiceMgr())
{
GetClientVoiceMgr()->SetPlayerBlockedState(playerIndex, false);
}
}
};
2001-08-29 00:00:00 +00:00
EXPOSE_SINGLE_INTERFACE(CClientExports, IGameClientExports, GAMECLIENTEXPORTS_INTERFACE_VERSION);