summaryrefslogtreecommitdiff
path: root/games/quake3/files/patch-code-game-q_shared.c
blob: 1047fa8aead0c50389184c85c418a453c830ebae (plain) (blame)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
--- ./code/game/q_shared.c.orig	Wed May 31 18:55:11 2006
+++ ./code/game/q_shared.c	Wed May 31 19:06:32 2006
@@ -58,13 +58,20 @@
 COM_StripExtension
 ============
 */
-void COM_StripExtension( const char *in, char *out ) {
-	while ( *in && *in != '.' ) {
-		*out++ = *in++;
-	}
-	*out = 0;
-}
+void COM_StripExtension( const char *in, char *out, int destsize ) {
+	int	length;
 
+	Q_strncpyz(out, in, destsize);
+
+	length = strlen(out)-1;
+	while (length > 0 && out[length] != '.') {
+		length--;
+		if (out[length] == '/')
+			return;		// no extension
+	}
+	if (length)
+		out[length] = 0;
+}
 
 /*
 ==================
@@ -99,29 +106,29 @@
 
 ============================================================================
 */
-/*
+
 // can't just use function pointers, or dll linkage can
 // mess up when qcommon is included in multiple places
-static short	(*_BigShort) (short l);
-static short	(*_LittleShort) (short l);
-static int		(*_BigLong) (int l);
-static int		(*_LittleLong) (int l);
+static int16_t	(*_BigShort) (int16_t l);
+static int16_t	(*_LittleShort) (int16_t l);
+static int32_t		(*_BigLong) (int32_t l);
+static int32_t		(*_LittleLong) (int32_t l);
 static qint64	(*_BigLong64) (qint64 l);
 static qint64	(*_LittleLong64) (qint64 l);
 static float	(*_BigFloat) (const float *l);
 static float	(*_LittleFloat) (const float *l);
 
-short	BigShort(short l){return _BigShort(l);}
-short	LittleShort(short l) {return _LittleShort(l);}
-int		BigLong (int l) {return _BigLong(l);}
-int		LittleLong (int l) {return _LittleLong(l);}
-qint64 	BigLong64 (qint64 l) {return _BigLong64(l);}
-qint64 	LittleLong64 (qint64 l) {return _LittleLong64(l);}
-float	BigFloat (const float *l) {return _BigFloat(l);}
-float	LittleFloat (const float *l) {return _LittleFloat(l);}
-*/
+int16_t	BigShort(int16_t l){return _BigShort(l);}
+int16_t	LittleShort(int16_t l) {return _LittleShort(l);}
+int32_t	BigLong (int32_t l) {return _BigLong(l);}
+int32_t	LittleLong (int32_t l) {return _LittleLong(l);}
+qint64	BigLong64 (qint64 l) {return _BigLong64(l);}
+qint64	LittleLong64 (qint64 l) {return _LittleLong64(l);}
+float	BigFloat (float l) {return _BigFloat(&l);}
+float	LittleFloat (float l) {return _LittleFloat(&l);}
 
-short   ShortSwap (short l)
+
+int16_t	ShortSwap (int16_t l)
 {
 	byte    b1,b2;
 
@@ -131,12 +138,12 @@
 	return (b1<<8) + b2;
 }
 
-short	ShortNoSwap (short l)
+int16_t	ShortNoSwap (int16_t l)
 {
 	return l;
 }
 
-int    LongSwap (int l)
+int32_t	LongSwap (int32_t l)
 {
 	byte    b1,b2,b3,b4;
 
@@ -145,15 +152,15 @@
 	b3 = (l>>16)&255;
 	b4 = (l>>24)&255;
 
-	return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
+	return ((int32_t)b1<<24) + ((int32_t)b2<<16) + ((int32_t)b3<<8) + b4;
 }
 
-int	LongNoSwap (int l)
+int32_t	LongNoSwap (int32_t l)
 {
 	return l;
 }
 
-qint64 Long64Swap (qint64 ll)
+qint64	Long64Swap (qint64 ll)
 {
 	qint64	result;
 
@@ -199,7 +206,7 @@
 Swap_Init
 ================
 */
-/*
+
 void Swap_Init (void)
 {
 	byte	swaptest[2] = {1,0};
@@ -229,7 +236,7 @@
 	}
 
 }
-*/
+
 
 /*
 ============================================================================