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

287 lines
6.3 KiB
C++
Raw Normal View History

1999-04-07 00:00:00 +00:00
/***
*
2002-12-23 00:00:00 +00:00
* Copyright (c) 1996-2002, 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"
#include "vgui_schememanager.h"
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
#define DLLEXPORT __declspec( dllexport )
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
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
/*
==========================
Initialize
Called when the DLL is first loaded.
==========================
*/
extern "C"
{
2001-08-29 00:00:00 +00:00
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int DLLEXPORT HUD_VidInit( void );
2002-12-23 00:00:00 +00:00
void DLLEXPORT HUD_Init( void );
2001-08-29 00:00:00 +00:00
int DLLEXPORT HUD_Redraw( float flTime, int intermission );
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
2002-12-23 00:00:00 +00:00
void DLLEXPORT HUD_Reset ( void );
2001-08-29 00:00:00 +00:00
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char DLLEXPORT HUD_PlayerMoveTexture( char *name );
2002-12-23 00:00:00 +00:00
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
2001-08-29 00:00:00 +00:00
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void DLLEXPORT HUD_Frame( double time );
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
2002-12-23 00:00:00 +00:00
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
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 DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
{
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.
================================
*/
2002-12-23 00:00:00 +00:00
int 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
{
// 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 DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
{
PM_Init( ppmove );
}
char DLLEXPORT HUD_PlayerMoveTexture( char *name )
{
return PM_FindTextureType( name );
}
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
{
PM_Move( ppmove, server );
}
1999-04-07 00:00:00 +00:00
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{
gEngfuncs = *pEnginefuncs;
if (iVersion != CLDLL_INTERFACE_VERSION)
return 0;
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
2000-06-05 00:00:00 +00:00
EV_HookEvents();
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 DLLEXPORT HUD_VidInit( void )
{
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.
==========================
*/
2002-12-23 00:00:00 +00:00
void DLLEXPORT HUD_Init( void )
1999-04-07 00:00:00 +00:00
{
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 DLLEXPORT HUD_Redraw( float time, int intermission )
{
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 DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float 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.
==========================
*/
2002-12-23 00:00:00 +00:00
void DLLEXPORT HUD_Reset( void )
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 DLLEXPORT HUD_Frame( double time )
{
ServersThink( time );
2001-08-29 00:00:00 +00:00
GetClientVoiceMgr()->Frame(time);
}
/*
==========================
HUD_VoiceStatus
Called when a player starts or stops talking.
==========================
*/
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
{
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
}
/*
==========================
HUD_DirectorEvent
Called when a director event message was received
==========================
*/
2002-12-23 00:00:00 +00:00
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
2001-08-29 00:00:00 +00:00
{
2002-12-23 00:00:00 +00:00
gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
2001-08-29 00:00:00 +00:00
}