#include "q_shared.h"Go to the source code of this file.
Defines | |
| #define | min(a, b) (a) < (b) ? a : b |
| #define | swapcode(TYPE, parmi, parmj, n) |
| #define | SWAPINIT(a, es) |
| #define | swap(a, b) |
| #define | vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) |
Typedefs | |
| typedef int | cmp_t (const void *, const void *) |
Functions | |
| void | qsort (void *a, size_t n, size_t es, cmp_t *cmp) |
| void * | memmove (void *dest, const void *src, size_t count) |
| void | srand (unsigned seed) |
| int | rand (void) |
| double | atof (const char *string) |
| double | _atof (const char **stringPtr) |
|
|
|
Value: if (swaptype == 0) { \ long t = *(long *)(a); \ *(long *)(a) = *(long *)(b); \ *(long *)(b) = t; \ } else \ swapfunc(a, b, es, swaptype) Definition at line 88 of file bg_lib.c. Referenced by qsort(). |
|
|
Value: { \
long i = (n) / sizeof (TYPE); \
register TYPE *pi = (TYPE *) (parmi); \
register TYPE *pj = (TYPE *) (parmj); \
do { \
register TYPE t = *pi; \
*pi++ = *pj; \
*pj++ = t; \
} while (--i > 0); \
}
|
|
|
Value: swaptype = ((char *)a - (char *)0) % sizeof(long) || \ es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; Definition at line 77 of file bg_lib.c. Referenced by qsort(). |
|
|
Definition at line 96 of file bg_lib.c. Referenced by qsort(). |
|
|
|
|
|
Definition at line 841 of file bg_lib.c.
00841 {
00842 const char *string;
00843 float sign;
00844 float value;
00845 int c = '0'; // bk001211 - uninitialized use possible
00846
00847 string = *stringPtr;
00848
00849 // skip whitespace
00850 while ( *string <= ' ' ) {
00851 if ( !*string ) {
00852 *stringPtr = string;
00853 return 0;
00854 }
00855 string++;
00856 }
00857
00858 // check sign
00859 switch ( *string ) {
00860 case '+':
00861 string++;
00862 sign = 1;
00863 break;
00864 case '-':
00865 string++;
00866 sign = -1;
00867 break;
00868 default:
00869 sign = 1;
00870 break;
00871 }
00872
00873 // read digits
00874 value = 0;
00875 if ( string[0] != '.' ) {
00876 do {
00877 c = *string++;
00878 if ( c < '0' || c > '9' ) {
00879 break;
00880 }
00881 c -= '0';
00882 value = value * 10 + c;
00883 } while ( 1 );
00884 }
00885
00886 // check for decimal point
00887 if ( c == '.' ) {
00888 double fraction;
00889
00890 fraction = 0.1;
00891 do {
00892 c = *string++;
00893 if ( c < '0' || c > '9' ) {
00894 break;
00895 }
00896 c -= '0';
00897 value += c * fraction;
00898 fraction *= 0.1;
00899 } while ( 1 );
00900
00901 }
00902
00903 // not handling 10e10 notation...
00904 *stringPtr = string;
00905
00906 return value * sign;
00907 }
|
|
|
Definition at line 774 of file bg_lib.c. Referenced by BG_ParseAnimationFile(), BG_ParseField(), BG_SiegeParseClassFile(), BotUtilizePersonality(), CG_DrawSkyBoxPortal(), CG_NewParticleArea(), CG_ROFF_NotetrackCallback(), CG_TestModel_f(), Cmd_SetViewpos_f(), COM_ParseFloat(), Float_Parse(), G_BotConnect(), G_RunFrame(), G_SpawnFloat(), ItemParse_rectcvar(), LoadPathData(), NPC_UpdateAngles(), Parse1DMatrix(), Q3_GetFloat(), Q3_PlaySound(), Q3_Set(), Q3_SetParm(), Script_SetItemColorCvar(), Script_SetItemRectCvar(), Script_Transition3(), SP_misc_skyportal(), SP_terrain(), Svcmd_AddBot_f(), trap_Cvar_VariableValue(), UI_ParseAnimationFile(), UI_SaberBladeLengthForSaber(), UI_SaberBladeRadiusForSaber(), UI_SetSiegeObjectiveGraphicPos(), and WP_ResistForcePush().
00774 {
00775 float sign;
00776 float value;
00777 int c;
00778
00779
00780 // skip whitespace
00781 while ( *string <= ' ' ) {
00782 if ( !*string ) {
00783 return 0;
00784 }
00785 string++;
00786 }
00787
00788 // check sign
00789 switch ( *string ) {
00790 case '+':
00791 string++;
00792 sign = 1;
00793 break;
00794 case '-':
00795 string++;
00796 sign = -1;
00797 break;
00798 default:
00799 sign = 1;
00800 break;
00801 }
00802
00803 // read digits
00804 value = 0;
00805 c = string[0];
00806 if ( c != '.' ) {
00807 do {
00808 c = *string++;
00809 if ( c < '0' || c > '9' ) {
00810 break;
00811 }
00812 c -= '0';
00813 value = value * 10 + c;
00814 } while ( 1 );
00815 } else {
00816 string++;
00817 }
00818
00819 // check for decimal point
00820 if ( c == '.' ) {
00821 double fraction;
00822
00823 fraction = 0.1;
00824 do {
00825 c = *string++;
00826 if ( c < '0' || c > '9' ) {
00827 break;
00828 }
00829 c -= '0';
00830 value += c * fraction;
00831 fraction *= 0.1;
00832 } while ( 1 );
00833
00834 }
00835
00836 // not handling 10e10 notation...
00837
00838 return value * sign;
00839 }
|
|
||||||||||||||||
|
Definition at line 287 of file bg_lib.c. References size_t. Referenced by ClearPlayerAlertEvents(), Item_TextField_HandleKey(), and RemoveOldestAlert().
00287 {
00288 int i;
00289
00290 if ( dest > src ) {
00291 for ( i = count-1 ; i >= 0 ; i-- ) {
00292 ((char *)dest)[i] = ((char *)src)[i];
00293 }
00294 } else {
00295 for ( i = 0 ; i < count ; i++ ) {
00296 ((char *)dest)[i] = ((char *)src)[i];
00297 }
00298 }
00299 return dest;
00300 }
|
|
||||||||||||||||||||
|
Definition at line 105 of file bg_lib.c. References min, pm, size_t, swap, SWAPINIT, and vecswap. Referenced by CalculateRanks(), TeamplayInfoMessage(), and UI_ServersSort().
00106 {
00107 char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
00108 int d, r, swaptype, swap_cnt;
00109
00110 loop: SWAPINIT(a, es);
00111 swap_cnt = 0;
00112 if (n < 7) {
00113 for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
00114 for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;
00115 pl -= es)
00116 swap(pl, pl - es);
00117 return;
00118 }
00119 pm = (char *)a + (n / 2) * es;
00120 if (n > 7) {
00121 pl = a;
00122 pn = (char *)a + (n - 1) * es;
00123 if (n > 40) {
00124 d = (n / 8) * es;
00125 pl = med3(pl, pl + d, pl + 2 * d, cmp);
00126 pm = med3(pm - d, pm, pm + d, cmp);
00127 pn = med3(pn - 2 * d, pn - d, pn, cmp);
00128 }
00129 pm = med3(pl, pm, pn, cmp);
00130 }
00131 swap(a, pm);
00132 pa = pb = (char *)a + es;
00133
00134 pc = pd = (char *)a + (n - 1) * es;
00135 for (;;) {
00136 while (pb <= pc && (r = cmp(pb, a)) <= 0) {
00137 if (r == 0) {
00138 swap_cnt = 1;
00139 swap(pa, pb);
00140 pa += es;
00141 }
00142 pb += es;
00143 }
00144 while (pb <= pc && (r = cmp(pc, a)) >= 0) {
00145 if (r == 0) {
00146 swap_cnt = 1;
00147 swap(pc, pd);
00148 pd -= es;
00149 }
00150 pc -= es;
00151 }
00152 if (pb > pc)
00153 break;
00154 swap(pb, pc);
00155 swap_cnt = 1;
00156 pb += es;
00157 pc -= es;
00158 }
00159 if (swap_cnt == 0) { /* Switch to insertion sort */
00160 for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
00161 for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0;
00162 pl -= es)
00163 swap(pl, pl - es);
00164 return;
00165 }
00166
00167 pn = (char *)a + n * es;
00168 r = min(pa - (char *)a, pb - pa);
00169 vecswap(a, pb - r, r);
00170 r = min(pd - pc, pn - pd - es);
00171 vecswap(pb, pn - r, r);
00172 if ((r = pb - pa) > es)
00173 qsort(a, r / es, es, cmp);
00174 if ((r = pd - pc) > es) {
00175 /* Iterate rather than recurse to save stack space */
00176 a = pn - r;
00177 n = r / es;
00178 goto loop;
00179 }
00180 /* qsort(pn - r, r / es, es, cmp);*/
00181 }
|
|
|
|
Definition at line 765 of file bg_lib.c. Referenced by G_InitGame().
00765 {
00766 randSeed = seed;
00767 }
|