-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk_util.cpp
73 lines (60 loc) · 1.85 KB
/
sdk_util.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// sdk_util.cpp
//
// Utility code from the HLSDK. Functions copied there as needed.
//
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
#include "main.h"
/*
===== util.cpp ========================================================
Utility code. Really not optional after all.
*/
short FixedSigned16( float value, float scale )
{
int output = (int)(value * scale);
if ( output > 32767 )
output = 32767;
if ( output < -32768 )
output = -32768;
return (short)output;
}
unsigned short FixedUnsigned16( float value, float scale )
{
int output = (int)(value * scale);
if ( output < 0 )
output = 0;
if ( output > 0xFFFF )
output = 0xFFFF;
return (unsigned short)output;
}
void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4)
{
static int gmsgTextMsg = 0;
if (gmsgTextMsg == 0)
gmsgTextMsg = REG_USER_MSG( "TextMsg", -1 );
MESSAGE_BEGIN( MSG_ONE_UNRELIABLE, gmsgTextMsg, NULL, client );
WRITE_BYTE( msg_dest );
WRITE_STRING( msg_name );
if ( param1 )
WRITE_STRING( param1 );
if ( param2 )
WRITE_STRING( param2 );
if ( param3 )
WRITE_STRING( param3 );
if ( param4 )
WRITE_STRING( param4 );
MESSAGE_END();
}