#include "../game/q_shared.h"
#include "qcommon.h"
#include <setjmp.h>
#include <winsock.h>
Include dependency graph for common.c:

Go to the source code of this file.
|
|
Definition at line 48 of file common.c. Referenced by Com_InitHunkMemory(). |
|
|
Definition at line 49 of file common.c. Referenced by Com_InitZoneMemory(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1891 of file common.c. Referenced by Com_GetEvent(), and Com_PushEvent(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Referenced by Hunk_Alloc(), Hunk_Log(), and Hunk_SmallLog(). |
|
|
Referenced by Com_Meminfo_f(), Com_TouchMemory(), CopyString(), Z_CheckHeap(), Z_ClearZone(), Z_Free(), Z_LogZoneHeap(), and Z_TagMalloc(). |
|
|
|
|
|
Referenced by Z_LogZoneHeap(). |
|
|
Definition at line 143 of file cl_cin.c. References CIN_StopCinematic(), cinTable, cin_cache::fileName, and i. Referenced by Hunk_Clear(). 00143 {
00144 int i;
00145
00146 for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {
00147 if (cinTable[i].fileName[0] != 0 ) {
00148 CIN_StopCinematic(i);
00149 }
00150 }
00151 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 3265 of file cl_main.c. References byte, ch, i, Q_stricmp(), qboolean, sprintf(), and strlen(). Referenced by CL_UISystemCalls(), Com_AppendCDKey(), Com_ReadCDKey(), and Com_WriteCDKey(). 03265 {
03266 char ch;
03267 byte sum;
03268 char chs[3];
03269 int i, len;
03270
03271 len = strlen(key);
03272 if( len != CDKEY_LEN ) {
03273 return qfalse;
03274 }
03275
03276 if( checksum && strlen( checksum ) != CDCHKSUM_LEN ) {
03277 return qfalse;
03278 }
03279
03280 sum = 0;
03281 // for loop gets rid of conditional assignment warning
03282 for (i = 0; i < len; i++) {
03283 ch = *key++;
03284 if (ch>='a' && ch<='z') {
03285 ch -= 32;
03286 }
03287 switch( ch ) {
03288 case '2':
03289 case '3':
03290 case '7':
03291 case 'A':
03292 case 'B':
03293 case 'C':
03294 case 'D':
03295 case 'G':
03296 case 'H':
03297 case 'J':
03298 case 'L':
03299 case 'P':
03300 case 'R':
03301 case 'S':
03302 case 'T':
03303 case 'W':
03304 sum += ch;
03305 continue;
03306 default:
03307 return qfalse;
03308 }
03309 }
03310
03311 sprintf(chs, "%02x", sum);
03312
03313 if (checksum && !Q_stricmp(chs, checksum)) {
03314 return qtrue;
03315 }
03316
03317 if (!checksum) {
03318 return qtrue;
03319 }
03320
03321 return qfalse;
03322 }
|
Here is the call graph for this function:

|
|
Definition at line 389 of file cl_cgame.c. References CG_SHUTDOWN, clientStatic_t::cgameStarted, cgvm, cls, clientStatic_t::keyCatchers, VM_Call(), and VM_Free(). Referenced by CL_ShutdownAll(), CL_Vid_Restart_f(), and Hunk_Clear(). 00389 {
00390 cls.keyCatchers &= ~KEYCATCH_CGAME;
00391 cls.cgameStarted = qfalse;
00392 if ( !cgvm ) {
00393 return;
00394 }
00395 VM_Call( cgvm, CG_SHUTDOWN );
00396 VM_Free( cgvm );
00397 cgvm = NULL;
00398 }
|
Here is the call graph for this function:

|
|
Definition at line 1127 of file cl_ui.c. References cls, clientStatic_t::keyCatchers, UI_SHUTDOWN, clientStatic_t::uiStarted, uivm, VM_Call(), and VM_Free(). Referenced by CL_Shutdown(), CL_ShutdownAll(), CL_Vid_Restart_f(), and Hunk_Clear(). 01127 {
01128 cls.keyCatchers &= ~KEYCATCH_UI;
01129 cls.uiStarted = qfalse;
01130 if ( !uivm ) {
01131 return;
01132 }
01133 VM_Call( uivm, UI_SHUTDOWN );
01134 VM_Free( uivm );
01135 uivm = NULL;
01136 }
|
Here is the call graph for this function:

|
|
Definition at line 455 of file common.c. References Cbuf_AddText(), com_consoleLines, i, Q_stricmpn(), and qboolean. Referenced by Com_Init(). 00455 {
00456 int i;
00457 qboolean added;
00458
00459 added = qfalse;
00460 // quote every token, so args with semicolons can work
00461 for (i=0 ; i < com_numConsoleLines ; i++) {
00462 if ( !com_consoleLines[i] || !com_consoleLines[i][0] ) {
00463 continue;
00464 }
00465
00466 // set commands won't override menu startup
00467 if ( Q_stricmpn( com_consoleLines[i], "set", 3 ) ) {
00468 added = qtrue;
00469 }
00470 Cbuf_AddText( com_consoleLines[i] );
00471 Cbuf_AddText( "\n" );
00472 }
00473
00474 return added;
00475 }
|
Here is the call graph for this function:

|
|
Definition at line 2283 of file common.c. References buffer, cl_cdkey, CL_CDKeyValidate(), Com_Memset(), f, fileHandle_t, FS_FCloseFile(), FS_Read(), FS_SV_FOpenFileRead(), NULL, Q_strncpyz(), sprintf(), and strcat(). Referenced by FS_Startup(). 02283 {
02284 fileHandle_t f;
02285 char buffer[33];
02286 char fbuffer[MAX_OSPATH];
02287
02288 sprintf(fbuffer, "%s/q3key", filename);
02289
02290 FS_SV_FOpenFileRead( fbuffer, &f );
02291 if (!f) {
02292 Q_strncpyz( &cl_cdkey[16], " ", 17 );
02293 return;
02294 }
02295
02296 Com_Memset( buffer, 0, sizeof(buffer) );
02297
02298 FS_Read( buffer, 16, f );
02299 FS_FCloseFile( f );
02300
02301 if (CL_CDKeyValidate(buffer, NULL)) {
02302 strcat( &cl_cdkey[16], buffer );
02303 } else {
02304 Q_strncpyz( &cl_cdkey[16], " ", 17 );
02305 }
02306 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 111 of file common.c. References buffer, rd_buffer, rd_buffersize, and rd_flush. Referenced by SVC_RemoteCommand(). 00112 {
00113 if (!buffer || !buffersize || !flush)
00114 return;
00115 rd_buffer = buffer;
00116 rd_buffersize = buffersize;
00117 rd_flush = flush;
00118
00119 *rd_buffer = 0;
00120 }
|
|
|
Definition at line 2234 of file common.c. Referenced by Com_Init(). 02234 {
02235 * ( int * ) 0 = 0x12345678;
02236 }
|
|
||||||||||||
|
Definition at line 209 of file common.c. 00209 {
00210 va_list argptr;
00211 char msg[MAXPRINTMSG];
00212
00213 if ( !com_developer || !com_developer->integer ) {
00214 return; // don't confuse non-developers with techie stuff...
00215 }
00216
00217 va_start (argptr,fmt);
00218 Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
00219 va_end (argptr);
00220
00221 Com_Printf ("%s", msg);
00222 }
|
|
|
Definition at line 122 of file common.c. References rd_buffer, rd_buffersize, and rd_flush. Referenced by SVC_RemoteCommand(). 00123 {
00124 if ( rd_flush ) {
00125 rd_flush(rd_buffer);
00126 }
00127
00128 rd_buffer = NULL;
00129 rd_buffersize = 0;
00130 rd_flush = NULL;
00131 }
|
|
||||||||||||||||
|
Definition at line 232 of file common.c. References abortframe, CL_CDDialog(), CL_Disconnect(), CL_FlushMemory(), CL_Shutdown(), code, com_buildScript, com_cl_running, com_errorEntered, com_errorMessage, Com_Printf(), Com_Shutdown(), Cvar_Set(), ERR_DISCONNECT, ERR_DROP, errorCount, FS_PureServerSetLoadedPaks(), cvar_s::integer, longjmp(), QDECL, qtrue, SV_Shutdown(), Sys_Error(), Sys_Milliseconds(), va(), va_end, va_list, va_start, and vsprintf(). 00232 {
00233 va_list argptr;
00234 static int lastErrorTime;
00235 static int errorCount;
00236 int currentTime;
00237
00238 #if defined(_WIN32) && defined(_DEBUG)
00239 if ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {
00240 if (!com_noErrorInterrupt->integer) {
00241 __asm {
00242 int 0x03
00243 }
00244 }
00245 }
00246 #endif
00247
00248 // when we are running automated scripts, make sure we
00249 // know if anything failed
00250 if ( com_buildScript && com_buildScript->integer ) {
00251 code = ERR_FATAL;
00252 }
00253
00254 // make sure we can get at our local stuff
00255 FS_PureServerSetLoadedPaks( "", "" );
00256
00257 // if we are getting a solid stream of ERR_DROP, do an ERR_FATAL
00258 currentTime = Sys_Milliseconds();
00259 if ( currentTime - lastErrorTime < 100 ) {
00260 if ( ++errorCount > 3 ) {
00261 code = ERR_FATAL;
00262 }
00263 } else {
00264 errorCount = 0;
00265 }
00266 lastErrorTime = currentTime;
00267
00268 if ( com_errorEntered ) {
00269 Sys_Error( "recursive error after: %s", com_errorMessage );
00270 }
00271 com_errorEntered = qtrue;
00272
00273 va_start (argptr,fmt);
00274 vsprintf (com_errorMessage,fmt,argptr);
00275 va_end (argptr);
00276
00277 if ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {
00278 Cvar_Set("com_errorMessage", com_errorMessage);
00279 }
00280
00281 if ( code == ERR_SERVERDISCONNECT ) {
00282 CL_Disconnect( qtrue );
00283 CL_FlushMemory( );
00284 com_errorEntered = qfalse;
00285 longjmp (abortframe, -1);
00286 } else if ( code == ERR_DROP || code == ERR_DISCONNECT ) {
00287 Com_Printf ("********************\nERROR: %s\n********************\n", com_errorMessage);
00288 SV_Shutdown (va("Server crashed: %s\n", com_errorMessage));
00289 CL_Disconnect( qtrue );
00290 CL_FlushMemory( );
00291 com_errorEntered = qfalse;
00292 longjmp (abortframe, -1);
00293 } else if ( code == ERR_NEED_CD ) {
00294 SV_Shutdown( "Server didn't have CD\n" );
00295 if ( com_cl_running && com_cl_running->integer ) {
00296 CL_Disconnect( qtrue );
00297 CL_FlushMemory( );
00298 com_errorEntered = qfalse;
00299 CL_CDDialog();
00300 } else {
00301 Com_Printf("Server didn't have CD\n" );
00302 }
00303 longjmp (abortframe, -1);
00304 } else {
00305 CL_Shutdown ();
00306 SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage));
00307 }
00308
00309 Com_Shutdown ();
00310
00311 Sys_Error ("%s", com_errorMessage);
00312 }
|
Here is the call graph for this function:

|
|
Definition at line 2190 of file common.c. References Cmd_Argc(), Com_Error(), ERR_DROP, and ERR_FATAL. Referenced by Com_Init(). 02190 {
02191 if ( Cmd_Argc() > 1 ) {
02192 Com_Error( ERR_DROP, "Testing drop error" );
02193 } else {
02194 Com_Error( ERR_FATAL, "Testing fatal error" );
02195 }
02196 }
|
Here is the call graph for this function:

|
|
Definition at line 2065 of file common.c. References byte, Cbuf_AddText(), CL_CharEvent(), CL_JoystickEvent(), CL_KeyEvent(), CL_MouseEvent(), CL_PacketEvent(), com_dropsim, Com_Error(), Com_GetEvent(), Com_Memcpy(), Com_Printf(), Com_RunAndTimeServerPacket(), com_sv_running, msg_t::cursize, msg_t::data, ERR_FATAL, sysEvent_t::evPtr, sysEvent_t::evPtrLength, sysEvent_t::evTime, sysEvent_t::evType, sysEvent_t::evValue, sysEvent_t::evValue2, cvar_s::integer, msg_t::maxsize, MSG_Init(), NET_GetLoopPacket(), NS_CLIENT, NS_SERVER, Q_random(), SE_CHAR, SE_CONSOLE, SE_JOYSTICK_AXIS, SE_KEY, SE_MOUSE, SE_NONE, SE_PACKET, cvar_s::value, and Z_Free(). Referenced by CL_DownloadsComplete(), and Com_Frame(). 02065 {
02066 sysEvent_t ev;
02067 netadr_t evFrom;
02068 byte bufData[MAX_MSGLEN];
02069 msg_t buf;
02070
02071 MSG_Init( &buf, bufData, sizeof( bufData ) );
02072
02073 while ( 1 ) {
02074 ev = Com_GetEvent();
02075
02076 // if no more events are available
02077 if ( ev.evType == SE_NONE ) {
02078 // manually send packet events for the loopback channel
02079 while ( NET_GetLoopPacket( NS_CLIENT, &evFrom, &buf ) ) {
02080 CL_PacketEvent( evFrom, &buf );
02081 }
02082
02083 while ( NET_GetLoopPacket( NS_SERVER, &evFrom, &buf ) ) {
02084 // if the server just shut down, flush the events
02085 if ( com_sv_running->integer ) {
02086 Com_RunAndTimeServerPacket( &evFrom, &buf );
02087 }
02088 }
02089
02090 return ev.evTime;
02091 }
02092
02093
02094 switch ( ev.evType ) {
02095 default:
02096 // bk001129 - was ev.evTime
02097 Com_Error( ERR_FATAL, "Com_EventLoop: bad event type %i", ev.evType );
02098 break;
02099 case SE_NONE:
02100 break;
02101 case SE_KEY:
02102 CL_KeyEvent( ev.evValue, ev.evValue2, ev.evTime );
02103 break;
02104 case SE_CHAR:
02105 CL_CharEvent( ev.evValue );
02106 break;
02107 case SE_MOUSE:
02108 CL_MouseEvent( ev.evValue, ev.evValue2, ev.evTime );
02109 break;
02110 case SE_JOYSTICK_AXIS:
02111 CL_JoystickEvent( ev.evValue, ev.evValue2, ev.evTime );
02112 break;
02113 case SE_CONSOLE:
02114 Cbuf_AddText( (char *)ev.evPtr );
02115 Cbuf_AddText( "\n" );
02116 break;
02117 case SE_PACKET:
02118 // this cvar allows simulation of connections that
02119 // drop a lot of packets. Note that loopback connections
02120 // don't go through here at all.
02121 if ( com_dropsim->value > 0 ) {
02122 static int seed;
02123
02124 if ( Q_random( &seed ) < com_dropsim->value ) {
02125 break; // drop this packet
02126 }
02127 }
02128
02129 evFrom = *(netadr_t *)ev.evPtr;
02130 buf.cursize = ev.evPtrLength - sizeof( evFrom );
02131
02132 // we must copy the contents of the message out, because
02133 // the event buffers are only large enough to hold the
02134 // exact payload, but channel messages need to be large
02135 // enough to hold fragment reassembly
02136 if ( (unsigned)buf.cursize > buf.maxsize ) {
02137 Com_Printf("Com_EventLoop: oversize packet\n");
02138 continue;
02139 }
02140 Com_Memcpy( buf.data, (byte *)((netadr_t *)ev.evPtr + 1), buf.cursize );
02141 if ( com_sv_running->integer ) {
02142 Com_RunAndTimeServerPacket( &evFrom, &buf );
02143 } else {
02144 CL_PacketEvent( evFrom, &buf );
02145 }
02146 break;
02147 }
02148
02149 // free any block data
02150 if ( ev.evPtr ) {
02151 Z_Free( ev.evPtr );
02152 }
02153 }
02154
02155 return 0; // never reached
02156 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 556 of file common.c. 00557 {
00558 char buf[MAX_TOKEN_CHARS];
00559 char *ptr;
00560 int i, found;
00561
00562 while(*filter) {
00563 if (*filter == '*') {
00564 filter++;
00565 for (i = 0; *filter; i++) {
00566 if (*filter == '*' || *filter == '?') break;
00567 buf[i] = *filter;
00568 filter++;
00569 }
00570 buf[i] = '\0';
00571 if (strlen(buf)) {
00572 ptr = Com_StringContains(name, buf, casesensitive);
00573 if (!ptr) return qfalse;
00574 name = ptr + strlen(buf);
00575 }
00576 }
00577 else if (*filter == '?') {
00578 filter++;
00579 name++;
00580 }
00581 else if (*filter == '[' && *(filter+1) == '[') {
00582 filter++;
00583 }
00584 else if (*filter == '[') {
00585 filter++;
00586 found = qfalse;
00587 while(*filter && !found) {
00588 if (*filter == ']' && *(filter+1) != ']') break;
00589 if (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']')) {
00590 if (casesensitive) {
00591 if (*name >= *filter && *name <= *(filter+2)) found = qtrue;
00592 }
00593 else {
00594 if (toupper(*name) >= toupper(*filter) &&
00595 toupper(*name) <= toupper(*(filter+2))) found = qtrue;
00596 }
00597 filter += 3;
00598 }
00599 else {
00600 if (casesensitive) {
00601 if (*filter == *name) found = qtrue;
00602 }
00603 else {
00604 if (toupper(*filter) == toupper(*name)) found = qtrue;
00605 }
00606 filter++;
00607 }
00608 }
00609 if (!found) return qfalse;
00610 while(*filter) {
00611 if (*filter == ']' && *(filter+1) != ']') break;
00612 filter++;
00613 }
00614 filter++;
00615 name++;
00616 }
00617 else {
00618 if (casesensitive) {
00619 if (*filter != *name) return qfalse;
00620 }
00621 else {
00622 if (toupper(*filter) != toupper(*name)) return qfalse;
00623 }
00624 filter++;
00625 name++;
00626 }
00627 }
00628 return qtrue;
00629 }
|
|
||||||||||||||||
|
Definition at line 636 of file common.c. References Com_Filter(), i, MAX_QPATH, and name. Referenced by FS_ListFilteredFiles(), and Sys_ListFilteredFiles(). 00637 {
00638 int i;
00639 char new_filter[MAX_QPATH];
00640 char new_name[MAX_QPATH];
00641
00642 for (i = 0; i < MAX_QPATH-1 && filter[i]; i++) {
00643 if ( filter[i] == '\\' || filter[i] == ':' ) {
00644 new_filter[i] = '/';
00645 }
00646 else {
00647 new_filter[i] = filter[i];
00648 }
00649 }
00650 new_filter[i] = '\0';
00651 for (i = 0; i < MAX_QPATH-1 && name[i]; i++) {
00652 if ( name[i] == '\\' || name[i] == ':' ) {
00653 new_name[i] = '/';
00654 }
00655 else {
00656 new_name[i] = name[i];
00657 }
00658 }
00659 new_name[i] = '\0';
00660 return Com_Filter(new_filter, new_name, casesensitive);
00661 }
|
Here is the call graph for this function:

|
|
Definition at line 2635 of file common.c. References abortframe, c_brush_traces, c_patch_traces, c_pointcontents, c_traces, Cbuf_Execute(), cl, CL_Frame(), CL_Init(), CL_Shutdown(), com_dedicated, Com_EventLoop(), com_frameMsec, com_frameNumber, com_frameTime, com_maxfps, Com_ModifyMsec(), Com_Printf(), com_showtrace, com_speeds, com_timedemo, com_viewlog, Com_WriteConfiguration(), Cvar_Get(), cvar_s::integer, cvar_s::modified, qfalse, qtrue, setjmp(), sv, SV_Frame(), Sys_Milliseconds(), Sys_ShowConsole(), time_backend, time_frontend, time_game, and cvar_s::value. Referenced by main(), and WinMain(). 02635 {
02636
02637 int msec, minMsec;
02638 static int lastTime;
02639 int key;
02640
02641 int timeBeforeFirstEvents;
02642 int timeBeforeServer;
02643 int timeBeforeEvents;
02644 int timeBeforeClient;
02645 int timeAfter;
02646
02647
02648
02649
02650
02651 if ( setjmp (abortframe) ) {
02652 return; // an ERR_DROP was thrown
02653 }
02654
02655 // bk001204 - init to zero.
02656 // also: might be clobbered by `longjmp' or `vfork'
02657 timeBeforeFirstEvents =0;
02658 timeBeforeServer =0;
02659 timeBeforeEvents =0;
02660 timeBeforeClient = 0;
02661 timeAfter = 0;
02662
02663
02664 // old net chan encryption key
02665 key = 0x87243987;
02666
02667 // write config file if anything changed
02668 Com_WriteConfiguration();
02669
02670 // if "viewlog" has been modified, show or hide the log console
02671 if ( com_viewlog->modified ) {
02672 if ( !com_dedicated->value ) {
02673 Sys_ShowConsole( com_viewlog->integer, qfalse );
02674 }
02675 com_viewlog->modified = qfalse;
02676 }
02677
02678 //
02679 // main event loop
02680 //
02681 if ( com_speeds->integer ) {
02682 timeBeforeFirstEvents = Sys_Milliseconds ();
02683 }
02684
02685 // we may want to spin here if things are going too fast
02686 if ( !com_dedicated->integer && com_maxfps->integer > 0 && !com_timedemo->integer ) {
02687 minMsec = 1000 / com_maxfps->integer;
02688 } else {
02689 minMsec = 1;
02690 }
02691 do {
02692 com_frameTime = Com_EventLoop();
02693 if ( lastTime > com_frameTime ) {
02694 lastTime = com_frameTime; // possible on first frame
02695 }
02696 msec = com_frameTime - lastTime;
02697 } while ( msec < minMsec );
02698 Cbuf_Execute ();
02699
02700 lastTime = com_frameTime;
02701
02702 // mess with msec if needed
02703 com_frameMsec = msec;
02704 msec = Com_ModifyMsec( msec );
02705
02706 //
02707 // server side
02708 //
02709 if ( com_speeds->integer ) {
02710 timeBeforeServer = Sys_Milliseconds ();
02711 }
02712
02713 SV_Frame( msec );
02714
02715 // if "dedicated" has been modified, start up
02716 // or shut down the client system.
02717 // Do this after the server may have started,
02718 // but before the client tries to auto-connect
02719 if ( com_dedicated->modified ) {
02720 // get the latched value
02721 Cvar_Get( "dedicated", "0", 0 );
02722 com_dedicated->modified = qfalse;
02723 if ( !com_dedicated->integer ) {
02724 CL_Init();
02725 Sys_ShowConsole( com_viewlog->integer, qfalse );
02726 } else {
02727 CL_Shutdown();
02728 Sys_ShowConsole( 1, qtrue );
02729 }
02730 }
02731
02732 //
02733 // client system
02734 //
02735 if ( !com_dedicated->integer ) {
02736 //
02737 // run event loop a second time to get server to client packets
02738 // without a frame of latency
02739 //
02740 if ( com_speeds->integer ) {
02741 timeBeforeEvents = Sys_Milliseconds ();
02742 }
02743 Com_EventLoop();
02744 Cbuf_Execute ();
02745
02746
02747 //
02748 // client side
02749 //
02750 if ( com_speeds->integer ) {
02751 timeBeforeClient = Sys_Milliseconds ();
02752 }
02753
02754 CL_Frame( msec );
02755
02756 if ( com_speeds->integer ) {
02757 timeAfter = Sys_Milliseconds ();
02758 }
02759 }
02760
02761 //
02762 // report timing information
02763 //
02764 if ( com_speeds->integer ) {
02765 int all, sv, ev, cl;
02766
02767 all = timeAfter - timeBeforeServer;
02768 sv = timeBeforeEvents - timeBeforeServer;
02769 ev = timeBeforeServer - timeBeforeFirstEvents + timeBeforeClient - timeBeforeEvents;
02770 cl = timeAfter - timeBeforeClient;
02771 sv -= time_game;
02772 cl -= time_frontend + time_backend;
02773
02774 Com_Printf ("frame:%i all:%3i sv:%3i ev:%3i cl:%3i gm:%3i rf:%3i bk:%3i\n",
02775 com_frameNumber, all, sv, ev, cl, time_game, time_frontend, time_backend );
02776 }
02777
02778 //
02779 // trace optimization tracking
02780 //
02781 if ( com_showtrace->integer ) {
02782
02783 extern int c_traces, c_brush_traces, c_patch_traces;
02784 extern int c_pointcontents;
02785
02786 Com_Printf ("%4i traces (%ib %ip) %4i points\n", c_traces,
02787 c_brush_traces, c_patch_traces, c_pointcontents);
02788 c_traces = 0;
02789 c_brush_traces = 0;
02790 c_patch_traces = 0;
02791 c_pointcontents = 0;
02792 }
02793
02794 // old net chan encryption key
02795 key = lastTime * 0x87243987;
02796
02797 com_frameNumber++;
02798 }
|
Here is the call graph for this function:

|
|
Definition at line 2207 of file common.c. References atof(), Cmd_Argc(), Cmd_Argv(), Com_Milliseconds(), Com_Printf(), and s. Referenced by Com_Init(). 02207 {
02208 float s;
02209 int start, now;
02210
02211 if ( Cmd_Argc() != 2 ) {
02212 Com_Printf( "freeze <seconds>\n" );
02213 return;
02214 }
02215 s = atof( Cmd_Argv(1) );
02216
02217 start = Com_Milliseconds();
02218
02219 while ( 1 ) {
02220 now = Com_Milliseconds();
02221 if ( ( now - start ) * 0.001 > s ) {
02222 break;
02223 }
02224 }
02225 }
|
Here is the call graph for this function:

|
|
Definition at line 2025 of file common.c. References Com_GetRealEvent(), com_pushedEvents, com_pushedEventsHead, com_pushedEventsTail, and MAX_PUSHED_EVENTS. Referenced by Com_EventLoop(). 02025 {
02026 if ( com_pushedEventsHead > com_pushedEventsTail ) {
02027 com_pushedEventsTail++;
02028 return com_pushedEvents[ (com_pushedEventsTail-1) & (MAX_PUSHED_EVENTS-1) ];
02029 }
02030 return Com_GetRealEvent();
02031 }
|
Here is the call graph for this function:

|
|
Definition at line 1933 of file common.c. References Com_Error(), com_journal, com_journalFile, ERR_FATAL, sysEvent_t::evPtr, FS_Read(), FS_Write(), cvar_s::integer, r, Sys_GetEvent(), and Z_Malloc(). Referenced by Com_GetEvent(), and Com_Milliseconds(). 01933 {
01934 int r;
01935 sysEvent_t ev;
01936
01937 // either get an event from the system or the journal file
01938 if ( com_journal->integer == 2 ) {
01939 r = FS_Read( &ev, sizeof(ev), com_journalFile );
01940 if ( r != sizeof(ev) ) {
01941 Com_Error( ERR_FATAL, "Error reading from journal file" );
01942 }
01943 if ( ev.evPtrLength ) {
01944 ev.evPtr = Z_Malloc( ev.evPtrLength );
01945 r = FS_Read( ev.evPtr, ev.evPtrLength, com_journalFile );
01946 if ( r != ev.evPtrLength ) {
01947 Com_Error( ERR_FATAL, "Error reading from journal file" );
01948 }
01949 }
01950 } else {
01951 ev = Sys_GetEvent();
01952
01953 // write the journal value out if needed
01954 if ( com_journal->integer == 1 ) {
01955 r = FS_Write( &ev, sizeof(ev), com_journalFile );
01956 if ( r != sizeof(ev) ) {
01957 Com_Error( ERR_FATAL, "Error writing to journal file" );
01958 }
01959 if ( ev.evPtrLength ) {
01960 r = FS_Write( ev.evPtr, ev.evPtrLength, com_journalFile );
01961 if ( r != ev.evPtrLength ) {
01962 Com_Error( ERR_FATAL, "Error writing to journal file" );
01963 }
01964 }
01965 }
01966 }
01967
01968 return ev;
01969 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 668 of file common.c. Referenced by CL_WritePacket(), and SV_UserMove(). 00668 {
00669 int register hash, i;
00670
00671 hash = 0;
00672 for (i = 0; i < maxlen && string[i] != '\0'; i++) {
00673 hash += string[i] * (119 + i);
00674 }
00675 hash = (hash ^ (hash >> 10) ^ (hash >> 20));
00676 return hash;
00677 }
|
Here is the call graph for this function:

|
|
Definition at line 2351 of file common.c. References abortframe, Cbuf_AddText(), Cbuf_Execute(), Cbuf_Init(), CL_Init(), CL_InitKeyCommands(), cl_paused, CL_StartHunkUsers(), Cmd_AddCommand(), Cmd_Init(), Com_AddStartupCommands(), com_blood, com_buildScript, com_cameraMode, com_cl_running, Com_Crash_f(), com_dedicated, com_developer, com_dropsim, Com_Error_f(), com_fixedtime, com_frameTime, Com_Freeze_f(), com_fullyInitialized, Com_InitHunkMemory(), Com_InitJournaling(), Com_InitPushEvent(), Com_InitSmallZoneMemory(), Com_InitZoneMemory(), com_introPlayed, com_logfile, com_maxfps, Com_Milliseconds(), Com_ParseCommandLine(), Com_Printf(), Com_Quit_f(), Com_SafeMode(), com_showtrace, com_speeds, Com_StartupVariable(), com_sv_running, com_timedemo, com_timescale, com_version, com_viewlog, Com_WriteConfig_f(), CVAR_ARCHIVE, CVAR_CHEAT, Cvar_Get(), Cvar_Init(), CVAR_LATCH, cvar_modifiedFlags, CVAR_ROM, CVAR_SERVERINFO, Cvar_Set(), CVAR_SYSTEMINFO, CVAR_TEMP, FS_InitFilesystem(), cvar_s::integer, cvar_s::modified, MSG_ReportChangeVectors_f(), cvar_s::name, Netchan_Init(), NULL, Q3_VERSION, qfalse, s, setjmp(), SV_Init(), sv_paused, Sys_Error(), Sys_Init(), Sys_ShowConsole(), va(), and VM_Init(). Referenced by main(), and WinMain(). 02351 {
02352 char *s;
02353
02354 Com_Printf( "%s %s %s\n", Q3_VERSION, CPUSTRING, __DATE__ );
02355
02356 if ( setjmp (abortframe) ) {
02357 Sys_Error ("Error during initialization");
02358 }
02359
02360 // bk001129 - do this before anything else decides to push events
02361 Com_InitPushEvent();
02362
02363 Com_InitSmallZoneMemory();
02364 Cvar_Init ();
02365
02366 // prepare enough of the subsystems to handle
02367 // cvar and command buffer management
02368 Com_ParseCommandLine( commandLine );
02369
02370 // Swap_Init ();
02371 Cbuf_Init ();
02372
02373 Com_InitZoneMemory();
02374 Cmd_Init ();
02375
02376 // override anything from the config files with command line args
02377 Com_StartupVariable( NULL );
02378
02379 // get the developer cvar set as early as possible
02380 Com_StartupVariable( "developer" );
02381
02382 // done early so bind command exists
02383 CL_InitKeyCommands();
02384
02385 FS_InitFilesystem ();
02386
02387 Com_InitJournaling();
02388
02389 Cbuf_AddText ("exec default.cfg\n");
02390
02391 // skip the q3config.cfg if "safe" is on the command line
02392 if ( !Com_SafeMode() ) {
02393 Cbuf_AddText ("exec q3config.cfg\n");
02394 }
02395
02396 Cbuf_AddText ("exec autoexec.cfg\n");
02397
02398 Cbuf_Execute ();
02399
02400 // override anything from the config files with command line args
02401 Com_StartupVariable( NULL );
02402
02403 // get dedicated here for proper hunk megs initialization
02404 #ifdef DEDICATED
02405 com_dedicated = Cvar_Get ("dedicated", "1", CVAR_ROM);
02406 #else
02407 com_dedicated = Cvar_Get ("dedicated", "0", CVAR_LATCH);
02408 #endif
02409 // allocate the stack based hunk allocator
02410 Com_InitHunkMemory();
02411
02412 // if any archived cvars are modified after this, we will trigger a writing
02413 // of the config file
02414 cvar_modifiedFlags &= ~CVAR_ARCHIVE;
02415
02416 //
02417 // init commands and vars
02418 //
02419 com_maxfps = Cvar_Get ("com_maxfps", "85", CVAR_ARCHIVE);
02420 com_blood = Cvar_Get ("com_blood", "1", CVAR_ARCHIVE);
02421
02422 com_developer = Cvar_Get ("developer", "0", CVAR_TEMP );
02423 com_logfile = Cvar_Get ("logfile", "0", CVAR_TEMP );
02424
02425 com_timescale = Cvar_Get ("timescale", "1", CVAR_CHEAT | CVAR_SYSTEMINFO );
02426 com_fixedtime = Cvar_Get ("fixedtime", "0", CVAR_CHEAT);
02427 com_showtrace = Cvar_Get ("com_showtrace", "0", CVAR_CHEAT);
02428 com_dropsim = Cvar_Get ("com_dropsim", "0", CVAR_CHEAT);
02429 com_viewlog = Cvar_Get( "viewlog", "0", CVAR_CHEAT );
02430 com_speeds = Cvar_Get ("com_speeds", "0", 0);
02431 com_timedemo = Cvar_Get ("timedemo", "0", CVAR_CHEAT);
02432 com_cameraMode = Cvar_Get ("com_cameraMode", "0", CVAR_CHEAT);
02433
02434 cl_paused = Cvar_Get ("cl_paused", "0", CVAR_ROM);
02435 sv_paused = Cvar_Get ("sv_paused", "0", CVAR_ROM);
02436 com_sv_running = Cvar_Get ("sv_running", "0", CVAR_ROM);
02437 com_cl_running = Cvar_Get ("cl_running", "0", CVAR_ROM);
02438 com_buildScript = Cvar_Get( "com_buildScript", "0", 0 );
02439
02440 com_introPlayed = Cvar_Get( "com_introplayed", "0", CVAR_ARCHIVE);
02441
02442 #if defined(_WIN32) && defined(_DEBUG)
02443 com_noErrorInterrupt = Cvar_Get( "com_noErrorInterrupt", "0", 0 );
02444 #endif
02445
02446 if ( com_dedicated->integer ) {
02447 if ( !com_viewlog->integer ) {
02448 Cvar_Set( "viewlog", "1" );
02449 }
02450 }
02451
02452 if ( com_developer && com_developer->integer ) {
02453 Cmd_AddCommand ("error", Com_Error_f);
02454 Cmd_AddCommand ("crash", Com_Crash_f );
02455 Cmd_AddCommand ("freeze", Com_Freeze_f);
02456 }
02457 Cmd_AddCommand ("quit", Com_Quit_f);
02458 Cmd_AddCommand ("changeVectors", MSG_ReportChangeVectors_f );
02459 Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );
02460
02461 s = va("%s %s %s", Q3_VERSION, CPUSTRING, __DATE__ );
02462 com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
02463
02464 Sys_Init();
02465 Netchan_Init( Com_Milliseconds() & 0xffff ); // pick a port value that should be nice and random
02466 VM_Init();
02467 SV_Init();
02468
02469 com_dedicated->modified = qfalse;
02470 if ( !com_dedicated->integer ) {
02471 CL_Init();
02472 Sys_ShowConsole( com_viewlog->integer, qfalse );
02473 }
02474
02475 // set com_frameTime so that if a map is started on the
02476 // command line it will still be able to count on com_frameTime
02477 // being random enough for a serverid
02478 com_frameTime = Com_Milliseconds();
02479
02480 // add + commands from command line
02481 if ( !Com_AddStartupCommands() ) {
02482 // if the user didn't give any commands, run default action
02483 if ( !com_dedicated->integer ) {
02484 Cbuf_AddText ("cinematic idlogo.RoQ\n");
02485 if( !com_introPlayed->integer ) {
02486 Cvar_Set( com_introPlayed->name, "1" );
02487 Cvar_Set( "nextmap", "cinematic intro.RoQ" );
02488 }
02489 }
02490 }
02491
02492 // start in full screen ui mode
02493 Cvar_Set("r_uiFullScreen", "1");
02494
02495 CL_StartHunkUsers();
02496
02497 // make sure single player is off by default
02498 Cvar_Set("ui_singlePlayerActive", "0");
02499
02500 com_fullyInitialized = qtrue;
02501 Com_Printf ("--- Common Initialization Complete ---\n");
02502 }
|
Here is the call graph for this function:

|
|
Definition at line 1490 of file common.c. References byte, calloc(), Cmd_AddCommand(), com_dedicated, Com_Error(), Com_Meminfo_f(), Com_Printf(), CVAR_ARCHIVE, Cvar_Get(), CVAR_LATCH, cvar_t, DEF_COMHUNKMEGS, ERR_FATAL, FS_LoadStack(), Hunk_Clear(), Hunk_Log(), Hunk_SmallLog(), cvar_s::integer, s_hunkData, s_hunkTotal, and Z_LogHeap(). Referenced by Com_Init(). 01490 {
01491 cvar_t *cv;
01492 int nMinAlloc;
01493 char *pMsg = NULL;
01494
01495 // make sure the file system has allocated and "not" freed any temp blocks
01496 // this allows the config and product id files ( journal files too ) to be loaded
01497 // by the file system without redunant routines in the file system utilizing different
01498 // memory systems
01499 if (FS_LoadStack() != 0) {
01500 Com_Error( ERR_FATAL, "Hunk initialization failed. File system load stack not zero");
01501 }
01502
01503 // allocate the stack based hunk allocator
01504 cv = Cvar_Get( "com_hunkMegs", DEF_COMHUNKMEGS, CVAR_LATCH | CVAR_ARCHIVE );
01505
01506 // if we are not dedicated min allocation is 56, otherwise min is 1
01507 if (com_dedicated && com_dedicated->integer) {
01508 nMinAlloc = MIN_DEDICATED_COMHUNKMEGS;
01509 pMsg = "Minimum com_hunkMegs for a dedicated server is %i, allocating %i megs.\n";
01510 }
01511 else {
01512 nMinAlloc = MIN_COMHUNKMEGS;
01513 pMsg = "Minimum com_hunkMegs is %i, allocating %i megs.\n";
01514 }
01515
01516 if ( cv->integer < nMinAlloc ) {
01517 s_hunkTotal = 1024 * 1024 * nMinAlloc;
01518 Com_Printf(pMsg, nMinAlloc, s_hunkTotal / (1024 * 1024));
01519 } else {
01520 s_hunkTotal = cv->integer * 1024 * 1024;
01521 }
01522
01523
01524 // bk001205 - was malloc
01525 s_hunkData = calloc( s_hunkTotal + 31, 1 );
01526 if ( !s_hunkData ) {
01527 Com_Error( ERR_FATAL, "Hunk data failed to allocate %i megs", s_hunkTotal / (1024*1024) );
01528 }
01529 // cacheline align
01530 s_hunkData = (byte *) ( ( (int)s_hunkData + 31 ) & ~31 );
01531 Hunk_Clear();
01532
01533 Cmd_AddCommand( "meminfo", Com_Meminfo_f );
01534 #ifdef ZONE_DEBUG
01535 Cmd_AddCommand( "zonelog", Z_LogHeap );
01536 #endif
01537 #ifdef HUNK_DEBUG
01538 Cmd_AddCommand( "hunklog", Hunk_Log );
01539 Cmd_AddCommand( "hunksmalllog", Hunk_SmallLog );
01540 #endif
01541 }
|
Here is the call graph for this function:

|
|
Definition at line 1903 of file common.c. References com_journal, com_journalDataFile, com_journalFile, Com_Printf(), Com_StartupVariable(), Cvar_Get(), CVAR_INIT, Cvar_Set(), FS_FOpenFileRead(), FS_FOpenFileWrite(), cvar_s::integer, and qtrue. Referenced by Com_Init(). 01903 {
01904 Com_StartupVariable( "journal" );
01905 com_journal = Cvar_Get ("journal", "0", CVAR_INIT);
01906 if ( !com_journal->integer ) {
01907 return;
01908 }
01909
01910 if ( com_journal->integer == 1 ) {
01911 Com_Printf( "Journaling events\n");
01912 com_journalFile = FS_FOpenFileWrite( "journal.dat" );
01913 com_journalDataFile = FS_FOpenFileWrite( "journaldata.dat" );
01914 } else if ( com_journal->integer == 2 ) {
01915 Com_Printf( "Replaying journaled events\n");
01916 FS_FOpenFileRead( "journal.dat", &com_journalFile, qtrue );
01917 FS_FOpenFileRead( "journaldata.dat", &com_journalDataFile, qtrue );
01918 }
01919
01920 if ( !com_journalFile || !com_journalDataFile ) {
01921 Cvar_Set( "com_journal", "0" );
01922 com_journalFile = 0;
01923 com_journalDataFile = 0;
01924 Com_Printf( "Couldn't open journal files\n" );
01925 }
01926 }
|
Here is the call graph for this function:

|
|
Definition at line 1978 of file common.c. References com_pushedEvents, com_pushedEventsHead, com_pushedEventsTail, and memset(). Referenced by Com_Init(). 01978 {
01979 // clear the static buffer array
01980 // this requires SE_NONE to be accepted as a valid but NOP event
01981 memset( com_pushedEvents, 0, sizeof(com_pushedEvents) );
01982 // reset counters while we are at it
01983 // beware: GetEvent might still return an SE_NONE from the buffer
01984 com_pushedEventsHead = 0;
01985 com_pushedEventsTail = 0;
01986 }
|
Here is the call graph for this function:

|
|
Definition at line 1375 of file common.c. References calloc(), Com_Error(), ERR_FATAL, s_smallZoneTotal, smallzone, and Z_ClearZone(). Referenced by Com_Init(). 01375 {
01376 s_smallZoneTotal = 512 * 1024;
01377 // bk001205 - was malloc
01378 smallzone = calloc( s_smallZoneTotal, 1 );
01379 if ( !smallzone ) {
01380 Com_Error( ERR_FATAL, "Small zone data failed to allocate %1.1f megs", (float)s_smallZoneTotal / (1024*1024) );
01381 }
01382 Z_ClearZone( smallzone, s_smallZoneTotal );
01383
01384 return;
01385 }
|
Here is the call graph for this function:

|
|
Definition at line 1387 of file common.c. References calloc(), Com_Error(), CVAR_ARCHIVE, Cvar_Get(), CVAR_LATCH, cvar_t, DEF_COMZONEMEGS, ERR_FATAL, cvar_s::integer, mainzone, s_zoneTotal, and Z_ClearZone(). Referenced by Com_Init(). 01387 {
01388 cvar_t *cv;
01389 // allocate the random block zone
01390 cv = Cvar_Get( "com_zoneMegs", DEF_COMZONEMEGS, CVAR_LATCH | CVAR_ARCHIVE );
01391
01392 if ( cv->integer < 20 ) {
01393 s_zoneTotal = 1024 * 1024 * 16;
01394 } else {
01395 s_zoneTotal = cv->integer * 1024 * 1024;
01396 }
01397
01398 // bk001205 - was malloc
01399 mainzone = calloc( s_zoneTotal, 1 );
01400 if ( !mainzone ) {
01401 Com_Error( ERR_FATAL, "Zone data failed to allocate %i megs", s_zoneTotal / (1024*1024) );
01402 }
01403 Z_ClearZone( mainzone, s_zoneTotal );
01404
01405 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2822 of file common.c. References count, memcpy(), and src. 02823 {
02824 memcpy(dest, src, count);
02825 }
|
Here is the call graph for this function:

|
|
Definition at line 1234 of file common.c. References memzone_t::blocklist, byte, Cmd_Argc(), Com_Printf(), hunk_high, hunk_low, mainzone, hunkUsed_t::mark, memblock_t, memblock_s::next, hunkUsed_t::permanent, memblock_s::prev, s_hunkTotal, s_zoneTotal, memblock_s::size, smallzone, memblock_s::tag, hunkUsed_t::temp, and hunkUsed_t::tempHighwater. Referenced by Com_InitHunkMemory(). 01234 {
01235 memblock_t *block;
01236 int zoneBytes, zoneBlocks;
01237 int smallZoneBytes, smallZoneBlocks;
01238 int botlibBytes, rendererBytes;
01239 int unused;
01240
01241 zoneBytes = 0;
01242 botlibBytes = 0;
01243 rendererBytes = 0;
01244 zoneBlocks = 0;
01245 for (block = mainzone->blocklist.next ; ; block = block->next) {
01246 if ( Cmd_Argc() != 1 ) {
01247 Com_Printf ("block:%p size:%7i tag:%3i\n",
01248 block, block->size, block->tag);
01249 }
01250 if ( block->tag ) {
01251 zoneBytes += block->size;
01252 zoneBlocks++;
01253 if ( block->tag == TAG_BOTLIB ) {
01254 botlibBytes += block->size;
01255 } else if ( block->tag == TAG_RENDERER ) {
01256 rendererBytes += block->size;
01257 }
01258 }
01259
01260 if (block->next == &mainzone->blocklist) {
01261 break; // all blocks have been hit
01262 }
01263 if ( (byte *)block + block->size != (byte *)block->next) {
01264 Com_Printf ("ERROR: block size does not touch the next block\n");
01265 }
01266 if ( block->next->prev != block) {
01267 Com_Printf ("ERROR: next block doesn't have proper back link\n");
01268 }
01269 if ( !block->tag && !block->next->tag ) {
01270 Com_Printf ("ERROR: two consecutive free blocks\n");
01271 }
01272 }
01273
01274 smallZoneBytes = 0;
01275 smallZoneBlocks = 0;
01276 for (block = smallzone->blocklist.next ; ; block = block->next) {
01277 if ( block->tag ) {
01278 smallZoneBytes += block->size;
01279 smallZoneBlocks++;
01280 }
01281
01282 if (block->next == &smallzone->blocklist) {
01283 break; // all blocks have been hit
01284 }
01285 }
01286
01287 Com_Printf( "%8i bytes total hunk\n", s_hunkTotal );
01288 Com_Printf( "%8i bytes total zone\n", s_zoneTotal );
01289 Com_Printf( "\n" );
01290 Com_Printf( "%8i low mark\n", hunk_low.mark );
01291 Com_Printf( "%8i low permanent\n", hunk_low.permanent );
01292 if ( hunk_low.temp != hunk_low.permanent ) {
01293 Com_Printf( "%8i low temp\n", hunk_low.temp );
01294 }
01295 Com_Printf( "%8i low tempHighwater\n", hunk_low.tempHighwater );
01296 Com_Printf( "\n" );
01297 Com_Printf( "%8i high mark\n", hunk_high.mark );
01298 Com_Printf( "%8i high permanent\n", hunk_high.permanent );
01299 if ( hunk_high.temp != hunk_high.permanent ) {
01300 Com_Printf( "%8i high temp\n", hunk_high.temp );
01301 }
01302 Com_Printf( "%8i high tempHighwater\n", hunk_high.tempHighwater );
01303 Com_Printf( "\n" );
01304 Com_Printf( "%8i total hunk in use\n", hunk_low.permanent + hunk_high.permanent );
01305 unused = 0;
01306 if ( hunk_low.tempHighwater > hunk_low.permanent ) {
01307 unused += hunk_low.tempHighwater - hunk_low.permanent;
01308 }
01309 if ( hunk_high.tempHighwater > hunk_high.permanent ) {
01310 unused += hunk_high.tempHighwater - hunk_high.permanent;
01311 }
01312 Com_Printf( "%8i unused highwater\n", unused );
01313 Com_Printf( "\n" );
01314 Com_Printf( "%8i bytes in %i zone blocks\n", zoneBytes, zoneBlocks );
01315 Com_Printf( " %8i bytes in dynamic botlib\n", botlibBytes );
01316 Com_Printf( " %8i bytes in dynamic renderer\n", rendererBytes );
01317 Com_Printf( " %8i bytes in dynamic other\n", zoneBytes - ( botlibBytes + rendererBytes ) );
01318 Com_Printf( " %8i bytes in small Zone memory\n", smallZoneBytes );
01319 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 2827 of file common.c. References count, and memset(). 02828 {
02829 memset(dest, val, count);
02830 }
|
Here is the call graph for this function:

|
|
Definition at line 2165 of file common.c. References Com_GetRealEvent(), Com_PushEvent(), sysEvent_t::evTime, and sysEvent_t::evType. Referenced by CL_RequestMotd(), CL_ServerStatus(), CL_ServerStatusResponse(), Com_Freeze_f(), Com_Init(), S_AddLoopSounds(), S_ChannelMalloc(), S_FreeOldestSound(), S_LoadSound(), S_StartSound(), S_Update_(), SV_InitGameVM(), SV_SpawnServer(), and SVC_RemoteCommand(). 02165 {
02166 sysEvent_t ev;
02167
02168 // get events and push them until we get a null event with the current time
02169 do {
02170
02171 ev = Com_GetRealEvent();
02172 if ( ev.evType != SE_NONE ) {
02173 Com_PushEvent( &ev );
02174 }
02175 } while ( ev.evType != SE_NONE );
02176
02177 return ev.evTime;
02178 }
|
Here is the call graph for this function:

|
|
Definition at line 2584 of file common.c. References com_cameraMode, com_dedicated, com_fixedtime, Com_Printf(), com_sv_running, com_timescale, cvar_s::integer, and cvar_s::value. Referenced by Com_Frame(). 02584 {
02585 int clampTime;
02586
02587 //
02588 // modify time for debugging values
02589 //
02590 if ( com_fixedtime->integer ) {
02591 msec = com_fixedtime->integer;
02592 } else if ( com_timescale->value ) {
02593 msec *= com_timescale->value;
02594 } else if (com_cameraMode->integer) {
02595 msec *= com_timescale->value;
02596 }
02597
02598 // don't let it scale below 1 msec
02599 if ( msec < 1 && com_timescale->value) {
02600 msec = 1;
02601 }
02602
02603 if ( com_dedicated->integer ) {
02604 // dedicated servers don't want to clamp for a much longer
02605 // period, because it would mess up all the client's views
02606 // of time.
02607 if ( msec > 500 ) {
02608 Com_Printf( "Hitch warning: %i msec frame time\n", msec );
02609 }
02610 clampTime = 5000;
02611 } else
02612 if ( !com_sv_running->integer ) {
02613 // clients of remote servers do not want to clamp time, because
02614 // it would skew their view of the server's time temporarily
02615 clampTime = 5000;
02616 } else {
02617 // for local single player gaming
02618 // we may want to clamp the time to prevent players from
02619 // flying off edges when something hitches.
02620 clampTime = 200;
02621 }
02622
02623 if ( msec > clampTime ) {
02624 msec = clampTime;
02625 }
02626
02627 return msec;
02628 }
|
Here is the call graph for this function:

|
|
Definition at line 364 of file common.c. References com_consoleLines, and com_numConsoleLines. Referenced by Com_Init(). 00364 {
00365 int inq = 0;
00366 com_consoleLines[0] = commandLine;
00367 com_numConsoleLines = 1;
00368
00369 while ( *commandLine ) {
00370 if (*commandLine == '"') {
00371 inq = !inq;
00372 }
00373 // look for a + seperating character
00374 // if commandLine came from a file, we might have real line seperators
00375 if ( (*commandLine == '+' && !inq) || *commandLine == '\n' || *commandLine == '\r' ) {
00376 if ( com_numConsoleLines == MAX_CONSOLE_LINES ) {
00377 return;
00378 }
00379 com_consoleLines[com_numConsoleLines] = commandLine + 1;
00380 com_numConsoleLines++;
00381 *commandLine = 0;
00382 }
00383 commandLine++;
00384 }
00385 }
|
|
||||||||||||
|
Definition at line 143 of file common.c. References asctime(), CL_ConsolePrint(), com_dedicated, com_logfile, Com_Printf(), FS_FOpenFileWrite(), FS_ForceFlush(), FS_Initialized(), FS_Write(), cvar_s::integer, localtime(), logfile, Q_strcat(), Q_vsnprintf, qboolean, QDECL, rd_buffer, rd_buffersize, rd_flush, strlen(), Sys_Print(), time(), time_t, va_end, va_list, and va_start. 00143 {
00144 va_list argptr;
00145 char msg[MAXPRINTMSG];
00146 static qboolean opening_qconsole = qfalse;
00147
00148 va_start (argptr,fmt);
00149 Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
00150 va_end (argptr);
00151
00152 if ( rd_buffer ) {
00153 if ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {
00154 rd_flush(rd_buffer);
00155 *rd_buffer = 0;
00156 }
00157 Q_strcat(rd_buffer, rd_buffersize, msg);
00158 // TTimo nooo .. that would defeat the purpose
00159 //rd_flush(rd_buffer);
00160 //*rd_buffer = 0;
00161 return;
00162 }
00163
00164 // echo to console if we're not a dedicated server
00165 if ( com_dedicated && !com_dedicated->integer ) {
00166 CL_ConsolePrint( msg );
00167 }
00168
00169 // echo to dedicated console and early console
00170 Sys_Print( msg );
00171
00172 // logfile
00173 if ( com_logfile && com_logfile->integer ) {
00174 // TTimo: only open the qconsole.log if the filesystem is in an initialized state
00175 // also, avoid recursing in the qconsole.log opening (i.e. if fs_debug is on)
00176 if ( !logfile && FS_Initialized() && !opening_qconsole) {
00177 struct tm *newtime;
00178 time_t aclock;
00179
00180 opening_qconsole = qtrue;
00181
00182 time( &aclock );
00183 newtime = localtime( &aclock );
00184
00185 logfile = FS_FOpenFileWrite( "qconsole.log" );
00186 Com_Printf( "logfile opened on %s\n", asctime( newtime ) );
00187 if ( com_logfile->integer > 1 ) {
00188 // force it to not buffer so we get valid
00189 // data even if we are crashing
00190 FS_ForceFlush(logfile);
00191 }
00192
00193 opening_qconsole = qfalse;
00194 }
00195 if ( logfile && FS_Initialized()) {
00196 FS_Write(msg, strlen(msg), logfile);
00197 }
00198 }
00199 }
|
Here is the call graph for this function:

|
|
Definition at line 1994 of file common.c. References Com_Printf(), com_pushedEvents, com_pushedEventsHead, com_pushedEventsTail, sysEvent_t::evPtr, MAX_PUSHED_EVENTS, and Z_Free(). Referenced by Com_Milliseconds(). 01994 {
01995 sysEvent_t *ev;
01996 static int printedWarning = 0; // bk001129 - init, bk001204 - explicit int
01997
01998 ev = &com_pushedEvents[ com_pushedEventsHead & (MAX_PUSHED_EVENTS-1) ];
01999
02000 if ( com_pushedEventsHead - com_pushedEventsTail >= MAX_PUSHED_EVENTS ) {
02001
02002 // don't print the warning constantly, or it can give time for more...
02003 if ( !printedWarning ) {
02004 printedWarning = qtrue;
02005 Com_Printf( "WARNING: Com_PushEvent overflow\n" );
02006 }
02007
02008 if ( ev->evPtr ) {
02009 Z_Free( ev->evPtr );
02010 }
02011 com_pushedEventsTail++;
02012 } else {
02013 printedWarning = qfalse;
02014 }
02015
02016 *ev = *event;
02017 com_pushedEventsHead++;
02018 }
|
Here is the call graph for this function:

|
|
Definition at line 323 of file common.c. References CL_Shutdown(), Com_Shutdown(), FS_Shutdown(), qtrue, SV_Shutdown(), and Sys_Quit(). Referenced by Com_Init(), Sys_Error(), and Sys_GetEvent(). 00323 {
00324 // don't try to shutdown if we are in a recursive error
00325 if ( !com_errorEntered ) {
00326 SV_Shutdown ("Server quit\n");
00327 CL_Shutdown ();
00328 Com_Shutdown ();
00329 FS_Shutdown(qtrue);
00330 }
00331 Sys_Quit ();
00332 }
|
Here is the call graph for this function:

|
|
Definition at line 2253 of file common.c. References buffer, cl_cdkey, CL_CDKeyValidate(), Com_Memset(), f, fileHandle_t, FS_FCloseFile(), FS_Read(), FS_SV_FOpenFileRead(), NULL, Q_strncpyz(), and sprintf(). Referenced by FS_Startup(). 02253 {
02254 fileHandle_t f;
02255 char buffer[33];
02256 char fbuffer[MAX_OSPATH];
02257
02258 sprintf(fbuffer, "%s/q3key", filename);
02259
02260 FS_SV_FOpenFileRead( fbuffer, &f );
02261 if ( !f ) {
02262 Q_strncpyz( cl_cdkey, " ", 17 );
02263 return;
02264 }
02265
02266 Com_Memset( buffer, 0, sizeof(buffer) );
02267
02268 FS_Read( buffer, 16, f );
02269 FS_FCloseFile( f );
02270
02271 if (CL_CDKeyValidate(buffer, NULL)) {
02272 Q_strncpyz( cl_cdkey, buffer, 17 );
02273 } else {
02274 Q_strncpyz( cl_cdkey, " ", 17 );
02275 }
02276 }
|
Here is the call graph for this function:

|
|
Definition at line 684 of file common.c. References localtime(), NULL, qtime_t, t, time(), time_t, qtime_s::tm_hour, tm::tm_hour, qtime_s::tm_isdst, tm::tm_isdst, qtime_s::tm_mday, tm::tm_mday, qtime_s::tm_min, tm::tm_min, qtime_s::tm_mon, tm::tm_mon, qtime_s::tm_sec, tm::tm_sec, qtime_s::tm_wday, tm::tm_wday, qtime_s::tm_yday, tm::tm_yday, qtime_s::tm_year, and tm::tm_year. Referenced by CL_CgameSystemCalls(), CL_UISystemCalls(), and SV_GameSystemCalls(). 00684 {
00685 time_t t;
00686 struct tm *tms;
00687
00688 t = time(NULL);
00689 if (!qtime)
00690 return t;
00691 tms = localtime(&t);
00692 if (tms) {
00693 qtime->tm_sec = tms->tm_sec;
00694 qtime->tm_min = tms->tm_min;
00695 qtime->tm_hour = tms->tm_hour;
00696 qtime->tm_mday = tms->tm_mday;
00697 qtime->tm_mon = tms->tm_mon;
00698 qtime->tm_year = tms->tm_year;
00699 qtime->tm_wday = tms->tm_wday;
00700 qtime->tm_yday = tms->tm_yday;
00701 qtime->tm_isdst = tms->tm_isdst;
00702 }
00703 return t;
00704 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 2038 of file common.c. References Com_Printf(), com_speeds, cvar_s::integer, SV_PacketEvent(), and Sys_Milliseconds(). Referenced by Com_EventLoop(). 02038 {
02039 int t1, t2, msec;
02040
02041 t1 = 0;
02042
02043 if ( com_speeds->integer ) {
02044 t1 = Sys_Milliseconds ();
02045 }
02046
02047 SV_PacketEvent( *evFrom, buf );
02048
02049 if ( com_speeds->integer ) {
02050 t2 = Sys_Milliseconds ();
02051 msec = t2 - t1;
02052 if ( com_speeds->integer == 3 ) {
02053 Com_Printf( "SV_PacketEvent time: %i\n", msec );
02054 }
02055 }
02056 }
|
Here is the call graph for this function:

|
|
Definition at line 396 of file common.c. References Cmd_Argv(), Cmd_TokenizeString(), com_consoleLines, i, Q_stricmp(), and qboolean. Referenced by Com_Init(), and FS_Restart(). 00396 {
00397 int i;
00398
00399 for ( i = 0 ; i < com_numConsoleLines ; i++ ) {
00400 Cmd_TokenizeString( com_consoleLines[i] );
00401 if ( !Q_stricmp( Cmd_Argv(0), "safe" )
00402 || !Q_stricmp( Cmd_Argv(0), "cvar_restart" ) ) {
00403 com_consoleLines[i][0] = 0;
00404 return qtrue;
00405 }
00406 }
00407 return qfalse;
00408 }
|
Here is the call graph for this function:

|
|
Definition at line 2805 of file common.c. References com_journalFile, FS_FCloseFile(), and logfile. Referenced by Com_Error(), and Com_Quit_f(). 02805 {
02806 if (logfile) {
02807 FS_FCloseFile (logfile);
02808 logfile = 0;
02809 }
02810
02811 if ( com_journalFile ) {
02812 FS_FCloseFile( com_journalFile );
02813 com_journalFile = 0;
02814 }
02815
02816 }
|
Here is the call graph for this function:

|
|
Definition at line 422 of file common.c. References Cmd_Argv(), Cmd_TokenizeString(), com_consoleLines, Cvar_Get(), Cvar_Set(), cvar_t, cvar_s::flags, i, match(), s, and strcmp(). Referenced by Com_Init(), Com_InitJournaling(), and FS_InitFilesystem(). 00422 {
00423 int i;
00424 char *s;
00425 cvar_t *cv;
00426
00427 for (i=0 ; i < com_numConsoleLines ; i++) {
00428 Cmd_TokenizeString( com_consoleLines[i] );
00429 if ( strcmp( Cmd_Argv(0), "set" ) ) {
00430 continue;
00431 }
00432
00433 s = Cmd_Argv(1);
00434 if ( !match || !strcmp( s, match ) ) {
00435 Cvar_Set( s, Cmd_Argv(2) );
00436 cv = Cvar_Get( s, "", 0 );
00437 cv->flags |= CVAR_USER_CREATED;
00438 // com_consoleLines[i] = 0;
00439 }
00440 }
00441 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 527 of file common.c. References i, j, strlen(), and toupper(). 00527 {
00528 int len, i, j;
00529
00530 len = strlen(str1) - strlen(str2);
00531 for (i = 0; i <= len; i++, str1++) {
00532 for (j = 0; str2[j]; j++) {
00533 if (casesensitive) {
00534 if (str1[j] != str2[j]) {
00535 break;
00536 }
00537 }
00538 else {
00539 if (toupper(str1[j]) != toupper(str2[j])) {
00540 break;
00541 }
00542 }
00543 }
00544 if (!str2[j]) {
00545 return str1;
00546 }
00547 }
00548 return NULL;
00549 }
|
Here is the call graph for this function:

|
|
Definition at line 1328 of file common.c. References memzone_t::blocklist, Com_Printf(), hunk_high, hunk_low, i, j, mainzone, memblock_t, memblock_s::next, hunkUsed_t::permanent, s_hunkTotal, memblock_s::size, Sys_Milliseconds(), memblock_s::tag, and Z_CheckHeap(). Referenced by CL_InitCGame(). 01328 {
01329 int start, end;
01330 int i, j;
01331 int sum;
01332 memblock_t *block;
01333
01334 Z_CheckHeap();
01335
01336 start = Sys_Milliseconds();
01337
01338 sum = 0;
01339
01340 j = hunk_low.permanent >> 2;
01341 for ( i = 0 ; i < j ; i+=64 ) { // only need to touch each page
01342 sum += ((int *)s_hunkData)[i];
01343 }
01344
01345 i = ( s_hunkTotal - hunk_high.permanent ) >> 2;
01346 j = hunk_high.permanent >> 2;
01347 for ( ; i < j ; i+=64 ) { // only need to touch each page
01348 sum += ((int *)s_hunkData)[i];
01349 }
01350
01351 for (block = mainzone->blocklist.next ; ; block = block->next) {
01352 if ( block->tag ) {
01353 j = block->size >> 2;
01354 for ( i = 0 ; i < j ; i+=64 ) { // only need to touch each page
01355 sum += ((int *)block)[i];
01356 }
01357 }
01358 if ( block->next == &mainzone->blocklist ) {
01359 break; // all blocks have been hit
01360 }
01361 }
01362
01363 end = Sys_Milliseconds();
01364
01365 Com_Printf( "Com_TouchMemory: %i msec\n", end - start );
01366 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 2314 of file common.c. References CL_CDKeyValidate(), Com_Printf(), f, fileHandle_t, FS_FCloseFile(), FS_Printf(), FS_SV_FOpenFileWrite(), FS_Write(), NULL, Q_strncpyz(), and sprintf(). Referenced by Com_WriteConfiguration(). 02314 {
02315 fileHandle_t f;
02316 char fbuffer[MAX_OSPATH];
02317 char key[17];
02318
02319
02320 sprintf(fbuffer, "%s/q3key", filename);
02321
02322
02323 Q_strncpyz( key, ikey, 17 );
02324
02325 if(!CL_CDKeyValidate(key, NULL) ) {
02326 return;
02327 }
02328
02329 f = FS_SV_FOpenFileWrite( fbuffer );
02330 if ( !f ) {
02331 Com_Printf ("Couldn't write %s.\n", filename );
02332 return;
02333 }
02334
02335 FS_Write( key, 16, f );
02336
02337 FS_Printf( f, "\n// generated by quake, do not modify\r\n" );
02338 FS_Printf( f, "// Do not give this file to ANYONE.\r\n" );
02339 FS_Printf( f, "// id Software and Activision will NOT ask you to send this file to them.\r\n");
02340
02341 FS_FCloseFile( f );
02342 }
|
Here is the call graph for this function:

|
|
Definition at line 2565 of file common.c. References Cmd_Argc(), Cmd_Argv(), COM_DefaultExtension(), Com_Printf(), Com_WriteConfigToFile(), and Q_strncpyz(). Referenced by Com_Init(). 02565 {
02566 char filename[MAX_QPATH];
02567
02568 if ( Cmd_Argc() != 2 ) {
02569 Com_Printf( "Usage: writeconfig <filename>\n" );
02570 return;
02571 }
02572
02573 Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );
02574 COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
02575 Com_Printf( "Writing %s.\n", filename );
02576 Com_WriteConfigToFile( filename );
02577 }
|
Here is the call graph for this function:

|
|
Definition at line 2506 of file common.c. References Com_Printf(), Cvar_WriteVariables(), f, fileHandle_t, FS_FCloseFile(), FS_FOpenFileWrite(), FS_Printf(), and Key_WriteBindings(). Referenced by Com_WriteConfig_f(), and Com_WriteConfiguration(). 02506 {
02507 fileHandle_t f;
02508
02509 f = FS_FOpenFileWrite( filename );
02510 if ( !f ) {
02511 Com_Printf ("Couldn't write %s.\n", filename );
02512 return;
02513 }
02514
02515 FS_Printf (f, "// generated by quake, do not modify\n");
02516 Key_WriteBindings (f);
02517 Cvar_WriteVariables (f);
02518 FS_FCloseFile( f );
02519 }
|
Here is the call graph for this function:

|
|
Definition at line 2529 of file common.c. References cl_cdkey, Com_WriteCDKey(), Com_WriteConfigToFile(), Cvar_Get(), CVAR_INIT, cvar_modifiedFlags, CVAR_SYSTEMINFO, cvar_t, cvar_s::string, and UI_usesUniqueCDKey(). Referenced by Com_Frame(). 02529 {
02530 #ifndef DEDICATED // bk001204
02531 cvar_t *fs;
02532 #endif
02533 // if we are quiting without fully initializing, make sure
02534 // we don't write out anything
02535 if ( !com_fullyInitialized ) {
02536 return;
02537 }
02538
02539 if ( !(cvar_modifiedFlags & CVAR_ARCHIVE ) ) {
02540 return;
02541 }
02542 cvar_modifiedFlags &= ~CVAR_ARCHIVE;
02543
02544 Com_WriteConfigToFile( "q3config.cfg" );
02545
02546 // bk001119 - tentative "not needed for dedicated"
02547 #ifndef DEDICATED
02548 fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO );
02549 if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) {
02550 Com_WriteCDKey( fs->string, &cl_cdkey[16] );
02551 } else {
02552 Com_WriteCDKey( "baseq3", cl_cdkey );
02553 }
02554 #endif
02555 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 3246 of file common.c. References field_t::buffer, completionField, keyConcatArgs(), Q_strcat(), src, strlen(), and strstr(). Referenced by Field_CompleteCommand(). 03246 {
03247 char *str;
03248
03249 str = strstr(src, start);
03250 if (!str) {
03251 keyConcatArgs();
03252 return;
03253 }
03254
03255 str += strlen(start);
03256 Q_strcat( completionField->buffer, sizeof( completionField->buffer ), str);
03257 }
|
Here is the call graph for this function:

|
|
Definition at line 1142 of file common.c. References in, memblock_t, numberstring, S_Malloc(), strcpy(), and strlen(). Referenced by Cmd_AddCommand(), ConWndProc(), Cvar_Get(), Cvar_Set2(), FS_AddFileToList(), FS_PureServerSetLoadedPaks(), FS_PureServerSetReferencedPaks(), Key_SetBinding(), SV_SetConfigstring(), SV_SpawnServer(), Sys_ListFiles(), and Sys_ListFilteredFiles(). 01142 {
01143 char *out;
01144
01145 if (!in[0]) {
01146 return ((char *)&emptystring) + sizeof(memblock_t);
01147 }
01148 else if (!in[1]) {
01149 if (in[0] >= '0' && in[0] <= '9') {
01150 return ((char *)&numberstring[in[0]-'0']) + sizeof(memblock_t);
01151 }
01152 }
01153 out = S_Malloc (strlen(in)+1);
01154 strcpy (out, in);
01155 return out;
01156 }
|
Here is the call graph for this function:

|
|
Definition at line 3175 of file common.c. References field_t::buffer, field_t::cursor, MAX_EDIT_LINE, memset(), and field_t::scroll. Referenced by Con_Close(), Con_Init(), Con_MessageMode2_f(), Con_MessageMode3_f(), Con_MessageMode4_f(), Con_MessageMode_f(), Con_ToggleConsole_f(), Console_Key(), Field_CharEvent(), Message_Key(), Sys_ConsoleInput(), Sys_ConsoleInputInit(), and UI_DrawConnectScreen(). 03175 {
03176 memset(edit->buffer, 0, MAX_EDIT_LINE);
03177 edit->cursor = 0;
03178 edit->scroll = 0;
03179 }
|
Here is the call graph for this function:

|
|
Definition at line 3268 of file common.c. References field_t::buffer, Cmd_Argc(), Cmd_Argv(), Cmd_CommandCompletion(), Cmd_TokenizeString(), Com_Memcpy(), Com_Printf(), Com_sprintf(), completionField, completionString, ConcatRemaining(), field_t::cursor, Cvar_CommandCompletion(), FindMatches(), matchCount, PrintMatches(), Q_strcat(), shortestMatch, and strlen(). Referenced by Console_Key(), and Sys_ConsoleInput(). 03268 {
03269 field_t temp;
03270
03271 completionField = field;
03272
03273 // only look at the first token for completion purposes
03274 Cmd_TokenizeString( completionField->buffer );
03275
03276 completionString = Cmd_Argv(0);
03277 if ( completionString[0] == '\\' || completionString[0] == '/' ) {
03278 completionString++;
03279 }
03280 matchCount = 0;
03281 shortestMatch[0] = 0;
03282
03283 if ( strlen( completionString ) == 0 ) {
03284 return;
03285 }
03286
03287 Cmd_CommandCompletion( FindMatches );
03288 Cvar_CommandCompletion( FindMatches );
03289
03290 if ( matchCount == 0 ) {
03291 return; // no matches
03292 }
03293
03294 Com_Memcpy(&temp, completionField, sizeof(field_t));
03295
03296 if ( matchCount == 1 ) {
03297 Com_sprintf( completionField->buffer, sizeof( completionField->buffer ), "\\%s", shortestMatch );
03298 if ( Cmd_Argc() == 1 ) {
03299 Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " );
03300 } else {
03301 ConcatRemaining( temp.buffer, completionString );
03302 }
03303 completionField->cursor = strlen( completionField->buffer );
03304 return;
03305 }
03306
03307 // multiple matches, complete to shortest
03308 Com_sprintf( completionField->buffer, sizeof( completionField->buffer ), "\\%s", shortestMatch );
03309 completionField->cursor = strlen( completionField->buffer );
03310 ConcatRemaining( temp.buffer, completionString );
03311
03312 Com_Printf( "]%s\n", completionField->buffer );
03313
03314 // run through again, printing matches
03315 Cmd_CommandCompletion( PrintMatches );
03316 Cvar_CommandCompletion( PrintMatches );
03317 }
|
Here is the call graph for this function:

|
|
Definition at line 3193 of file common.c. References completionString, i, matchCount, Q_stricmpn(), Q_strncpyz(), s, shortestMatch, strlen(), and tolower(). Referenced by Field_CompleteCommand(). 03193 {
03194 int i;
03195
03196 if ( Q_stricmpn( s, completionString, strlen( completionString ) ) ) {
03197 return;
03198 }
03199 matchCount++;
03200 if ( matchCount == 1 ) {
03201 Q_strncpyz( shortestMatch, s, sizeof( shortestMatch ) );
03202 return;
03203 }
03204
03205 // cut shortestMatch to the amount common with s
03206 for ( i = 0 ; s[i] ; i++ ) {
03207 if ( tolower(shortestMatch[i]) != tolower(s[i]) ) {
03208 shortestMatch[i] = 0;
03209 }
03210 }
03211 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1662 of file common.c. References byte, Com_Error(), Com_Memset(), ERR_DROP, ERR_FATAL, hunkblock_s::file, h_dontcare, h_high, h_low, hunk_high, Hunk_Log(), hunk_low, hunk_permanent, Hunk_SmallLog(), Hunk_SwapBanks(), hunk_temp, hunkblock_t, hunkblocks, hunkblock_s::label, hunkblock_s::line, hunkblock_s::next, hunkUsed_t::permanent, s_hunkData, s_hunkTotal, hunkblock_s::size, and hunkUsed_t::temp. Referenced by BotImport_HunkAlloc(), CM_GeneratePatchCollide(), CM_LoadMap(), CM_PatchCollideFromGrid(), CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadEntityString(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadLeafSurfaces(), CMod_LoadNodes(), CMod_LoadPatches(), CMod_LoadPlanes(), CMod_LoadShaders(), CMod_LoadSubmodels(), CMod_LoadVisibility(), SV_SpawnServer(), VM_Compile(), VM_Create(), VM_LoadSymbols(), and VM_PrepareInterpreter(). 01662 {
01663 #endif
01664 void *buf;
01665
01666 if ( s_hunkData == NULL)
01667 {
01668 Com_Error( ERR_FATAL, "Hunk_Alloc: Hunk memory system not initialized" );
01669 }
01670
01671 // can't do preference if there is any temp allocated
01672 if (preference == h_dontcare || hunk_temp->temp != hunk_temp->permanent) {
01673 Hunk_SwapBanks();
01674 } else {
01675 if (preference == h_low && hunk_permanent != &hunk_low) {
01676 Hunk_SwapBanks();
01677 } else if (preference == h_high && hunk_permanent != &hunk_high) {
01678 Hunk_SwapBanks();
01679 }
01680 }
01681
01682 #ifdef HUNK_DEBUG
01683 size += sizeof(hunkblock_t);
01684 #endif
01685
01686 // round to cacheline
01687 size = (size+31)&~31;
01688
01689 if ( hunk_low.temp + hunk_high.temp + size > s_hunkTotal ) {
01690 #ifdef HUNK_DEBUG
01691 Hunk_Log();
01692 Hunk_SmallLog();
01693 #endif
01694 Com_Error( ERR_DROP, "Hunk_Alloc failed on %i", size );
01695 }
01696
01697 if ( hunk_permanent == &hunk_low ) {
01698 buf = (void *)(s_hunkData + hunk_permanent->permanent);
01699 hunk_permanent->permanent += size;
01700 } else {
01701 hunk_permanent->permanent += size;
01702 buf = (void *)(s_hunkData + s_hunkTotal - hunk_permanent->permanent );
01703 }
01704
01705 hunk_permanent->temp = hunk_permanent->permanent;
01706
01707 Com_Memset( buf, 0, size );
01708
01709 #ifdef HUNK_DEBUG
01710 {
01711 hunkblock_t *block;
01712
01713 block = (hunkblock_t *) buf;
01714 block->size = size - sizeof(hunkblock_t);
01715 block->file = file;
01716 block->label = label;
01717 block->line = line;
01718 block->next = hunkblocks;
01719 hunkblocks = block;
01720 buf = ((byte *) buf) + sizeof(hunkblock_t);
01721 }
01722 #endif
01723 return buf;
01724 }
|
Here is the call graph for this function:

|
|
Definition at line 1735 of file common.c. References Com_Error(), ERR_DROP, hunk_permanent, Hunk_SwapBanks(), hunk_temp, hunkHeader_t::magic, hunkUsed_t::permanent, s_hunkData, s_hunkTotal, hunkHeader_t::size, hunkUsed_t::temp, hunkUsed_t::tempHighwater, and Z_Malloc(). Referenced by CIN_DrawCinematic(), FS_ReadFile(), S_LoadSound(), and SV_ChangeMaxClients(). 01735 {
01736 void *buf;
01737 hunkHeader_t *hdr;
01738
01739 // return a Z_Malloc'd block if the hunk has not been initialized
01740 // this allows the config and product id files ( journal files too ) to be loaded
01741 // by the file system without redunant routines in the file system utilizing different
01742 // memory systems
01743 if ( s_hunkData == NULL )
01744 {
01745 return Z_Malloc(size);
01746 }
01747
01748 Hunk_SwapBanks();
01749
01750 size = ( (size+3)&~3 ) + sizeof( hunkHeader_t );
01751
01752 if ( hunk_temp->temp + hunk_permanent->permanent + size > s_hunkTotal ) {
01753 Com_Error( ERR_DROP, "Hunk_AllocateTempMemory: failed on %i", size );
01754 }
01755
01756 if ( hunk_temp == &hunk_low ) {
01757 buf = (void *)(s_hunkData + hunk_temp->temp);
01758 hunk_temp->temp += size;
01759 } else {
01760 hunk_temp->temp += size;
01761 buf = (void *)(s_hunkData + s_hunkTotal - hunk_temp->temp );
01762 }
01763
01764 if ( hunk_temp->temp > hunk_temp->tempHighwater ) {
01765 hunk_temp->tempHighwater = hunk_temp->temp;
01766 }
01767
01768 hdr = (hunkHeader_t *)buf;
01769 buf = (void *)(hdr+1);
01770
01771 hdr->magic = HUNK_MAGIC;
01772 hdr->size = size;
01773
01774 // don't bother clearing, because we are going to load a file over it
01775 return buf;
01776 }
|
Here is the call graph for this function:

|
|
Definition at line 1586 of file common.c. References hunk_high, hunk_low, hunkUsed_t::mark, and qboolean. Referenced by BotImport_HunkAlloc(). 01586 {
01587 if( hunk_low.mark || hunk_high.mark ) {
01588 return qtrue;
01589 }
01590 return qfalse;
01591 }
|
|
Here is the call graph for this function:

|
|
Definition at line 1832 of file common.c. References hunk_temp, hunkUsed_t::permanent, s_hunkData, and hunkUsed_t::temp. Referenced by FS_FreeFile(). 01832 {
01833 if ( s_hunkData != NULL ) {
01834 hunk_temp->temp = hunk_temp->permanent;
01835 }
01836 }
|
|
|
Definition at line 1576 of file common.c. References hunk_high, hunk_low, hunkUsed_t::mark, hunkUsed_t::permanent, and hunkUsed_t::temp. Referenced by CL_FlushMemory(), and CL_Vid_Restart_f(). 01576 {
01577 hunk_low.permanent = hunk_low.temp = hunk_low.mark;
01578 hunk_high.permanent = hunk_high.temp = hunk_high.mark;
01579 }
|
|
|
Definition at line 1784 of file common.c. References Com_Error(), Com_Printf(), ERR_FATAL, hunk_temp, hunkHeader_t::magic, s_hunkData, s_hunkTotal, hunkHeader_t::size, hunkUsed_t::temp, and Z_Free(). Referenced by CIN_DrawCinematic(), FS_FreeFile(), S_LoadSound(), and SV_ChangeMaxClients(). 01784 {
01785 hunkHeader_t *hdr;
01786
01787 // free with Z_Free if the hunk has not been initialized
01788 // this allows the config and product id files ( journal files too ) to be loaded
01789 // by the file system without redunant routines in the file system utilizing different
01790 // memory systems
01791 if ( s_hunkData == NULL )
01792 {
01793 Z_Free(buf);
01794 return;
01795 }
01796
01797
01798 hdr = ( (hunkHeader_t *)buf ) - 1;
01799 if ( hdr->magic != HUNK_MAGIC ) {
01800 Com_Error( ERR_FATAL, "Hunk_FreeTempMemory: bad magic" );
01801 }
01802
01803 hdr->magic = HUNK_FREE_MAGIC;
01804
01805 // this only works if the files are freed in stack order,
01806 // otherwise the memory will stay around until Hunk_ClearTempMemory
01807 if ( hunk_temp == &hunk_low ) {
01808 if ( hdr == (void *)(s_hunkData + hunk_temp->temp - hdr->size ) ) {
01809 hunk_temp->temp -= hdr->size;
01810 } else {
01811 Com_Printf( "Hunk_FreeTempMemory: not the final block\n" );
01812 }
01813 } else {
01814 if ( hdr == (void *)(s_hunkData + s_hunkTotal - hunk_temp->temp ) ) {
01815 hunk_temp->temp -= hdr->size;
01816 } else {
01817 Com_Printf( "Hunk_FreeTempMemory: not the final block\n" );
01818 }
01819 }
01820 }
|
Here is the call graph for this function:

|
|
Definition at line 1412 of file common.c. References Com_sprintf(), hunkblock_s::file, FS_Initialized(), FS_Write(), hunkblock_t, hunkblock_s::label, hunkblock_s::line, logfile, hunkblock_s::next, hunkblock_s::size, and strlen(). Referenced by Com_InitHunkMemory(), and Hunk_Alloc(). 01412 {
01413 hunkblock_t *block;
01414 char buf[4096];
01415 int size, numBlocks;
01416
01417 if (!logfile || !FS_Initialized())
01418 return;
01419 size = 0;
01420 numBlocks = 0;
01421 Com_sprintf(buf, sizeof(buf), "\r\n================\r\nHunk log\r\n================\r\n");
01422 FS_Write(buf, strlen(buf), logfile);
01423 for (block = hunkblocks ; block; block = block->next) {
01424 #ifdef HUNK_DEBUG
01425 Com_sprintf(buf, sizeof(buf), "size = %8d: %s, line: %d (%s)\r\n", block->size, block->file, block->line, block->label);
01426 FS_Write(buf, strlen(buf), logfile);
01427 #endif
01428 size += block->size;
01429 numBlocks++;
01430 }
01431 Com_sprintf(buf, sizeof(buf), "%d Hunk memory\r\n", size);
01432 FS_Write(buf, strlen(buf), logfile);
01433 Com_sprintf(buf, sizeof(buf), "%d hunk blocks\r\n", numBlocks);
01434 FS_Write(buf, strlen(buf), logfile);
01435 }
|
Here is the call graph for this function:

|
|
Definition at line 1548 of file common.c. References hunk_high, hunk_low, hunkUsed_t::permanent, s_hunkTotal, and hunkUsed_t::temp. Referenced by CL_CgameSystemCalls(), CL_UISystemCalls(), and VM_Create(). 01548 {
01549 int low, high;
01550
01551 low = hunk_low.permanent > hunk_low.temp ? hunk_low.permanent : hunk_low.temp;
01552 high = hunk_high.permanent > hunk_high.temp ? hunk_high.permanent : hunk_high.temp;
01553
01554 return s_hunkTotal - ( low + high );
01555 }
|
|
|
Definition at line 1564 of file common.c. References hunk_high, hunk_low, hunkUsed_t::mark, and hunkUsed_t::permanent. Referenced by SV_SpawnServer(). 01564 {
01565 hunk_low.mark = hunk_low.permanent;
01566 hunk_high.mark = hunk_high.permanent;
01567 }
|
|
|
Definition at line 1442 of file common.c. References Com_sprintf(), hunkblock_s::file, FS_Initialized(), FS_Write(), hunkblock_t, hunkblock_s::label, hunkblock_s::line, logfile, hunkblock_s::next, hunkblock_s::printed, Q_stricmp(), hunkblock_s::size, and strlen(). Referenced by Com_InitHunkMemory(), and Hunk_Alloc(). 01442 {
01443 hunkblock_t *block, *block2;
01444 char buf[4096];
01445 int size, locsize, numBlocks;
01446
01447 if (!logfile || !FS_Initialized())
01448 return;
01449 for (block = hunkblocks ; block; block = block->next) {
01450 block->printed = qfalse;
01451 }
01452 size = 0;
01453 numBlocks = 0;
01454 Com_sprintf(buf, sizeof(buf), "\r\n================\r\nHunk Small log\r\n================\r\n");
01455 FS_Write(buf, strlen(buf), logfile);
01456 for (block = hunkblocks; block; block = block->next) {
01457 if (block->printed) {
01458 continue;
01459 }
01460 locsize = block->size;
01461 for (block2 = block->next; block2; block2 = block2->next) {
01462 if (block->line != block2->line) {
01463 continue;
01464 }
01465 if (Q_stricmp(block->file, block2->file)) {
01466 continue;
01467 }
01468 size += block2->size;
01469 locsize += block2->size;
01470 block2->printed = qtrue;
01471 }
01472 #ifdef HUNK_DEBUG
01473 Com_sprintf(buf, sizeof(buf), "size = %8d: %s, line: %d (%s)\r\n", locsize, block->file, block->line, block->label);
01474 FS_Write(buf, strlen(buf), logfile);
01475 #endif
01476 size += block->size;
01477 numBlocks++;
01478 }
01479 Com_sprintf(buf, sizeof(buf), "%d Hunk memory\r\n", size);
01480 FS_Write(buf, strlen(buf), logfile);
01481 Com_sprintf(buf, sizeof(buf), "%d hunk blocks\r\n", numBlocks);
01482 FS_Write(buf, strlen(buf), logfile);
01483 }
|
Here is the call graph for this function:

|
|
Definition at line 1634 of file common.c. References hunk_permanent, hunk_temp, hunkUsed_t::permanent, swap, hunkUsed_t::temp, and hunkUsed_t::tempHighwater. Referenced by Hunk_Alloc(), Hunk_AllocateTempMemory(), and Hunk_Trash(). 01634 {
01635 hunkUsed_t *swap;
01636
01637 // can't swap banks if there is any temp already allocated
01638 if ( hunk_temp->temp != hunk_temp->permanent ) {
01639 return;
01640 }
01641
01642 // if we have a larger highwater mark on this side, start making
01643 // our permanent allocations here and use the other side for temp
01644 if ( hunk_temp->tempHighwater - hunk_temp->permanent >
01645 hunk_permanent->tempHighwater - hunk_permanent->permanent ) {
01646 swap = hunk_temp;
01647 hunk_temp = hunk_permanent;
01648 hunk_permanent = swap;
01649 }
01650 }
|
|
|
Definition at line 1843 of file common.c. References Com_Error(), Cvar_Set(), ERR_DROP, hunk_permanent, Hunk_SwapBanks(), i, length(), hunkUsed_t::permanent, random, s_hunkData, s_hunkTotal, and value. 01843 {
01844 int length, i, rnd;
01845 char *buf, value;
01846
01847 return;
01848
01849 if ( s_hunkData == NULL )
01850 return;
01851
01852 #ifdef _DEBUG
01853 Com_Error(ERR_DROP, "hunk trashed\n");
01854 return;
01855 #endif
01856
01857 Cvar_Set("com_jp", "1");
01858 Hunk_SwapBanks();
01859
01860 if ( hunk_permanent == &hunk_low ) {
01861 buf = (void *)(s_hunkData + hunk_permanent->permanent);
01862 } else {
01863 buf = (void *)(s_hunkData + s_hunkTotal - hunk_permanent->permanent );
01864 }
01865 length = hunk_permanent->permanent;
01866
01867 if (length > 0x7FFFF) {
01868 //randomly trash data within buf
01869 rnd = random() * (length - 0x7FFFF);
01870 value = 31;
01871 for (i = 0; i < 0x7FFFF; i++) {
01872 value *= 109;
01873 buf[rnd+i] ^= value;
01874 }
01875 }
01876 }
|
Here is the call graph for this function:

|
|
Definition at line 480 of file common.c. References Com_Memset(), Com_Printf(), l, s, and value. Referenced by CL_Clientinfo_f(), SV_DumpUser_f(), SV_Serverinfo_f(), and SV_Systeminfo_f(). 00480 {
00481 char key[512];
00482 char value[512];
00483 char *o;
00484 int l;
00485
00486 if (*s == '\\')
00487 s++;
00488 while (*s)
00489 {
00490 o = key;
00491 while (*s && *s != '\\')
00492 *o++ = *s++;
00493
00494 l = o - key;
00495 if (l < 20)
00496 {
00497 Com_Memset (o, ' ', 20-l);
00498 key[20] = 0;
00499 }
00500 else
00501 *o = 0;
00502 Com_Printf ("%s", key);
00503
00504 if (!*s)
00505 {
00506 Com_Printf ("MISSING VALUE\n");
00507 return;
00508 }
00509
00510 o = value;
00511 s++;
00512 while (*s && *s != '\\')
00513 *o++ = *s++;
00514 *o = 0;
00515
00516 if (*s)
00517 s++;
00518 Com_Printf ("%s\n", value);
00519 }
00520 }
|
Here is the call graph for this function:

|
|
Definition at line 3225 of file common.c. References field_t::buffer, Cmd_Argc(), Cmd_Argv(), completionField, i, and Q_strcat(). Referenced by ConcatRemaining(). 03225 {
03226 int i;
03227 char *arg;
03228
03229 for ( i = 1 ; i < Cmd_Argc() ; i++ ) {
03230 Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " );
03231 arg = Cmd_Argv( i );
03232 while (*arg) {
03233 if (*arg == ' ') {
03234 Q_strcat( completionField->buffer, sizeof( completionField->buffer ), "\"");
03235 break;
03236 }
03237 arg++;
03238 }
03239 Q_strcat( completionField->buffer, sizeof( completionField->buffer ), Cmd_Argv( i ) );
03240 if (*arg == ' ') {
03241 Q_strcat( completionField->buffer, sizeof( completionField->buffer ), "\"");
03242 }
03243 }
03244 }
|
Here is the call graph for this function:

|
|
Definition at line 3219 of file common.c. References Com_Printf(), Q_stricmpn(), s, shortestMatch, and strlen(). Referenced by Field_CompleteCommand(). 03219 {
03220 if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) {
03221 Com_Printf( " %s\n", s );
03222 }
03223 }
|
Here is the call graph for this function:

|
|
Definition at line 3150 of file common.c. Referenced by CL_CgameSystemCalls(), and R_InitSkyTexCoords(). 03150 {
03151 float angle;
03152
03153 angle = acos(c);
03154
03155 if (angle > M_PI) {
03156 return (float)M_PI;
03157 }
03158 if (angle < -M_PI) {
03159 return (float)M_PI;
03160 }
03161 return angle;
03162 }
|
Here is the call graph for this function:

|
|
Definition at line 1021 of file common.c. References TAG_SMALL, and Z_TagMalloc(). Referenced by Cmd_AddCommand(), and CopyString(). 01021 {
01022 return Z_TagMalloc( size, TAG_SMALL );
01023 }
|
Here is the call graph for this function:

|
|
Definition at line 877 of file sv_game.c. Referenced by Hunk_Clear(), SV_Shutdown(), and SV_SpawnServer(). 00877 {
00878 if ( !gvm ) {
00879 return;
00880 }
00881 VM_Call( gvm, GAME_SHUTDOWN, qfalse );
00882 VM_Free( gvm );
00883 gvm = NULL;
00884 }
|
|
|
Definition at line 796 of file common.c. References mainzone, and Z_AvailableZoneMemory(). 00796 {
00797 return Z_AvailableZoneMemory( mainzone );
00798 }
|
Here is the call graph for this function:

|
|
Definition at line 787 of file common.c. References memzone_t::size, and memzone_t::used. Referenced by Z_AvailableMemory().
|
|
|
Definition at line 1031 of file common.c. References memzone_t::blocklist, byte, Com_Error(), ERR_FATAL, mainzone, memblock_t, memblock_s::next, memblock_s::prev, memblock_s::size, and memblock_s::tag. Referenced by Com_TouchMemory(). 01031 {
01032 memblock_t *block;
01033
01034 for (block = mainzone->blocklist.next ; ; block = block->next) {
01035 if (block->next == &mainzone->blocklist) {
01036 break; // all blocks have been hit
01037 }
01038 if ( (byte *)block + block->size != (byte *)block->next)
01039 Com_Error( ERR_FATAL, "Z_CheckHeap: block size does not touch the next block\n" );
01040 if ( block->next->prev != block) {
01041 Com_Error( ERR_FATAL, "Z_CheckHeap: next block doesn't have proper back link\n" );
01042 }
01043 if ( !block->tag && !block->next->tag ) {
01044 Com_Error( ERR_FATAL, "Z_CheckHeap: two consecutive free blocks\n" );
01045 }
01046 }
01047 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 762 of file common.c. References memzone_t::blocklist, byte, memblock_s::id, memblock_t, memblock_s::next, memblock_s::prev, memzone_t::rover, memzone_t::size, memblock_s::size, memblock_s::tag, and memzone_t::used. Referenced by Com_InitSmallZoneMemory(), and Com_InitZoneMemory(). 00762 {
00763 memblock_t *block;
00764
00765 // set the entire zone to one free block
00766
00767 zone->blocklist.next = zone->blocklist.prev = block =
00768 (memblock_t *)( (byte *)zone + sizeof(memzone_t) );
00769 zone->blocklist.tag = 1; // in use block
00770 zone->blocklist.id = 0;
00771 zone->blocklist.size = 0;
00772 zone->rover = block;
00773 zone->size = size;
00774 zone->used = 0;
00775
00776 block->prev = block->next = &zone->blocklist;
00777 block->tag = 0; // free block
00778 block->id = ZONEID;
00779 block->size = size - sizeof(memzone_t);
00780 }
|
|
|
Definition at line 805 of file common.c. References byte, Com_Error(), Com_Memset(), ERR_DROP, ERR_FATAL, FreeMemory(), memblock_s::id, memblock_t, memblock_s::next, memblock_s::prev, ptr(), memzone_t::rover, memblock_s::size, memblock_s::tag, and memzone_t::used. Referenced by BotImport_FreeMemory(), Cmd_RemoveCommand(), Com_EventLoop(), Com_PushEvent(), Cvar_Get(), Cvar_Restart_f(), Cvar_Set2(), Cvar_SetCheatState(), Field_Paste(), FreeWinding(), FS_FreeFileList(), FS_LoadZipFile(), FS_PureServerSetLoadedPaks(), FS_PureServerSetReferencedPaks(), FS_Shutdown(), FS_SortFileList(), GetClipboardData(), Hunk_FreeTempMemory(), Key_SetBinding(), RE_RegisterFont(), SV_BotInitBotLib(), SV_ChangeMaxClients(), SV_ClearServer(), SV_CloseDownload(), SV_Netchan_TransmitNextFragment(), SV_RankCloseContext(), SV_SetConfigstring(), SV_Shutdown(), Sys_ConcatenateFileLists(), Sys_FreeFileList(), Sys_QueEvent(), VM_Compile(), VM_Free(), VM_VmProfile_f(), Z_FreeTags(), and zcfree(). 00805 {
00806 memblock_t *block, *other;
00807 memzone_t *zone;
00808
00809 if (!ptr) {
00810 Com_Error( ERR_DROP, "Z_Free: NULL pointer" );
00811 }
00812
00813 block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
00814 if (block->id != ZONEID) {
00815 Com_Error( ERR_FATAL, "Z_Free: freed a pointer without ZONEID" );
00816 }
00817 if (block->tag == 0) {
00818 Com_Error( ERR_FATAL, "Z_Free: freed a freed pointer" );
00819 }
00820 // if static memory
00821 if (block->tag == TAG_STATIC) {
00822 return;
00823 }
00824
00825 // check the memory trash tester
00826 if ( *(int *)((byte *)block + block->size - 4 ) != ZONEID ) {
00827 Com_Error( ERR_FATAL, "Z_Free: memory block wrote past end" );
00828 }
00829
00830 if (block->tag == TAG_SMALL) {
00831 zone = smallzone;
00832 }
00833 else {
00834 zone = mainzone;
00835 }
00836
00837 zone->used -= block->size;
00838 // set the block to something that should cause problems
00839 // if it is referenced...
00840 Com_Memset( ptr, 0xaa, block->size - sizeof( *block ) );
00841
00842 block->tag = 0; // mark as free
00843
00844 other = block->prev;
00845 if (!other->tag) {
00846 // merge with previous free block
00847 other->size += block->size;
00848 other->next = block->next;
00849 other->next->prev = other;
00850 if (block == zone->rover) {
00851 zone->rover = other;
00852 }
00853 block = other;
00854 }
00855
00856 zone->rover = block;
00857
00858 other = block->next;
00859 if ( !other->tag ) {
00860 // merge the next free block onto the end
00861 block->size += other->size;
00862 block->next = other->next;
00863 block->next->prev = block;
00864 if (other == zone->rover) {
00865 zone->rover = block;
00866 }
00867 }
00868 }
|
Here is the call graph for this function:

|
|
Definition at line 876 of file common.c. References memzone_t::blocklist, count, memblock_s::next, memzone_t::rover, memblock_s::tag, and Z_Free(). 00876 {
00877 int count;
00878 memzone_t *zone;
00879
00880 if ( tag == TAG_SMALL ) {
00881 zone = smallzone;
00882 }
00883 else {
00884 zone = mainzone;
00885 }
00886 count = 0;
00887 // use the rover as our pointer, because
00888 // Z_Free automatically adjusts it
00889 zone->rover = zone->blocklist.next;
00890 do {
00891 if ( zone->rover->tag == tag ) {
00892 count++;
00893 Z_Free( (void *)(zone->rover + 1) );
00894 continue;
00895 }
00896 zone->rover = zone->rover->next;
00897 } while ( zone->rover != &zone->blocklist );
00898 }
|
Here is the call graph for this function:

|
|
Definition at line 1107 of file common.c. References mainzone, smallzone, and Z_LogZoneHeap(). Referenced by Com_InitHunkMemory(), and Z_TagMalloc(). 01107 {
01108 Z_LogZoneHeap( mainzone, "MAIN" );
01109 Z_LogZoneHeap( smallzone, "SMALL" );
01110 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1054 of file common.c. References memzone_t::blocklist, Com_sprintf(), dump, FS_Initialized(), FS_Write(), i, j, logfile, memblock_t, name, memblock_s::next, ptr(), memblock_s::size, strlen(), memblock_s::tag, and zonedebug_t. Referenced by Z_LogHeap(). 01054 {
01055 #ifdef ZONE_DEBUG
01056 char dump[32], *ptr;
01057 int i, j;
01058 #endif
01059 memblock_t *block;
01060 char buf[4096];
01061 int size, allocSize, numBlocks;
01062
01063 if (!logfile || !FS_Initialized())
01064 return;
01065 size = allocSize = numBlocks = 0;
01066 Com_sprintf(buf, sizeof(buf), "\r\n================\r\n%s log\r\n================\r\n", name);
01067 FS_Write(buf, strlen(buf), logfile);
01068 for (block = zone->blocklist.next ; block->next != &zone->blocklist; block = block->next) {
01069 if (block->tag) {
01070 #ifdef ZONE_DEBUG
01071 ptr = ((char *) block) + sizeof(memblock_t);
01072 j = 0;
01073 for (i = 0; i < 20 && i < block->d.allocSize; i++) {
01074 if (ptr[i] >= 32 && ptr[i] < 127) {
01075 dump[j++] = ptr[i];
01076 }
01077 else {
01078 dump[j++] = '_';
01079 }
01080 }
01081 dump[j] = '\0';
01082 Com_sprintf(buf, sizeof(buf), "size = %8d: %s, line: %d (%s) [%s]\r\n", block->d.allocSize, block->d.file, block->d.line, block->d.label, dump);
01083 FS_Write(buf, strlen(buf), logfile);
01084 allocSize += block->d.allocSize;
01085 #endif
01086 size += block->size;
01087 numBlocks++;
01088 }
01089 }
01090 #ifdef ZONE_DEBUG
01091 // subtract debug memory
01092 size -= numBlocks * sizeof(zonedebug_t);
01093 #else
01094 allocSize = numBlocks * sizeof(memblock_t); // + 32 bit alignment
01095 #endif
01096 Com_sprintf(buf, sizeof(buf), "%d %s memory in %d blocks\r\n", size, name, numBlocks);
01097 FS_Write(buf, strlen(buf), logfile);
01098 Com_sprintf(buf, sizeof(buf), "%d %s memory overhead\r\n", size - allocSize, name);
01099 FS_Write(buf, strlen(buf), logfile);
01100 }
|
Here is the call graph for this function:

|
|
Definition at line 1000 of file common.c. References Com_Memset(), file, GetClearedMemory(), line, TAG_GENERAL, and Z_TagMalloc(). Referenced by AllocWinding(), Com_GetRealEvent(), FS_AddGameDirectory(), FS_ListFilteredFiles(), FS_LoadZipFile(), FS_SortFileList(), Hunk_AllocateTempMemory(), LoadJPG(), RE_RegisterFont(), SV_BotInitBotLib(), SV_ChangeMaxClients(), SV_Netchan_Transmit(), SV_RankBegin(), SV_Startup(), SV_WriteDownloadToClient(), Sys_ConcatenateFileLists(), Sys_GetClipboardData(), Sys_GetEvent(), Sys_ListFiles(), VM_Compile(), VM_VmProfile_f(), and zcalloc(). 01000 {
01001 #endif
01002 void *buf;
01003
01004 //Z_CheckHeap (); // DEBUG
01005
01006 #ifdef ZONE_DEBUG
01007 buf = Z_TagMallocDebug( size, TAG_GENERAL, label, file, line );
01008 #else
01009 buf = Z_TagMalloc( size, TAG_GENERAL );
01010 #endif
01011 Com_Memset( buf, 0, size );
01012
01013 return buf;
01014 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 909 of file common.c. References byte, Com_Error(), ERR_FATAL, extra, memblock_s::id, memblock_t, memblock_s::next, memblock_s::prev, memzone_t::rover, memblock_s::size, smallzone, memblock_s::tag, memzone_t::used, and Z_LogHeap(). Referenced by BotImport_GetMemory(), CL_RefMalloc(), S_Malloc(), and Z_Malloc(). 00909 {
00910 #endif
00911 int extra, allocSize;
00912 memblock_t *start, *rover, *new, *base;
00913 memzone_t *zone;
00914
00915 if (!tag) {
00916 Com_Error( ERR_FATAL, "Z_TagMalloc: tried to use a 0 tag" );
00917 }
00918
00919 if ( tag == TAG_SMALL ) {
00920 zone = smallzone;
00921 }
00922 else {
00923 zone = mainzone;
00924 }
00925
00926 allocSize = size;
00927 //
00928 // scan through the block list looking for the first free block
00929 // of sufficient size
00930 //
00931 size += sizeof(memblock_t); // account for size of block header
00932 size += 4; // space for memory trash tester
00933 size = (size + 3) & ~3; // align to 32 bit boundary
00934
00935 base = rover = zone->rover;
00936 start = base->prev;
00937
00938 do {
00939 if (rover == start) {
00940 #ifdef ZONE_DEBUG
00941 Z_LogHeap();
00942 #endif
00943 // scaned all the way around the list
00944 Com_Error( ERR_FATAL, "Z_Malloc: failed on allocation of %i bytes from the %s zone",
00945 size, zone == smallzone ? "small" : "main");
00946 return NULL;
00947 }
00948 if (rover->tag) {
00949 base = rover = rover->next;
00950 } else {
00951 rover = rover->next;
00952 }
00953 } while (base->tag || base->size < size);
00954
00955 //
00956 // found a block big enough
00957 //
00958 extra = base->size - size;
00959 if (extra > MINFRAGMENT) {
00960 // there will be a free fragment after the allocated block
00961 new = (memblock_t *) ((byte *)base + size );
00962 new->size = extra;
00963 new->tag = 0; // free block
00964 new->prev = base;
00965 new->id = ZONEID;
00966 new->next = base->next;
00967 new->next->prev = new;
00968 base->next = new;
00969 base->size = size;
00970 }
00971
00972 base->tag = tag; // no longer a free block
00973
00974 zone->rover = base->next; // next allocation will start looking here
00975 zone->used += base->size; //
00976
00977 base->id = ZONEID;
00978
00979 #ifdef ZONE_DEBUG
00980 base->d.label = label;
00981 base->d.file = file;
00982 base->d.line = line;
00983 base->d.allocSize = allocSize;
00984 #endif
00985
00986 // marker for memory trash testing
00987 *(int *)((byte *)base + base->size - 4) = ZONEID;
00988
00989 return (void *) ((byte *)base + sizeof(memblock_t));
00990 }
|
Here is the call graph for this function:

|
|
Definition at line 55 of file common.c. Referenced by Com_Error(), Com_Frame(), and Com_Init(). |
|
|
Definition at line 2242 of file common.c. Referenced by CL_RequestAuthorization(), CLUI_GetCDKey(), CLUI_SetCDKey(), Com_AppendCDKey(), Com_ReadCDKey(), and Com_WriteConfiguration(). |
|
|
Definition at line 81 of file common.c. Referenced by CL_CheckTimeout(), CL_CheckUserinfo(), CL_SendCmd(), CL_SetCGameTime(), Com_Init(), and SV_CheckPaused(). |
|
|
|
|
|
|
|
|
Definition at line 78 of file common.c. Referenced by Com_Init(). |
|
|
Definition at line 79 of file common.c. Referenced by Com_Error(), and Com_Init(). |
|
|
Definition at line 83 of file common.c. Referenced by Com_Init(), and Com_ModifyMsec(). |
|
|
Definition at line 74 of file common.c. Referenced by CL_Disconnect(), CL_Frame(), CL_MapLoading(), CL_StartHunkUsers(), Cmd_ExecuteString(), Com_Error(), Com_Init(), Con_Close(), and SV_ClientCommand(). |
|
|
Definition at line 355 of file common.c. Referenced by Com_AddStartupCommands(), Com_ParseCommandLine(), Com_SafeMode(), and Com_StartupVariable(). |
|
|
Definition at line 66 of file common.c. Referenced by Com_Frame(), Com_Init(), Com_InitHunkMemory(), Com_ModifyMsec(), Com_Printf(), ConWndProc(), NET_Sleep(), SV_AddOperatorCommands(), SV_ChangeMaxClients(), SV_Frame(), SV_MasterHeartbeat(), SV_SendServerCommand(), SV_SpawnServer(), SV_Startup(), SV_UserinfoChanged(), Sys_ConsoleInput(), Sys_GetEvent(), Sys_InitInput(), Sys_ShutdownInput(), and WinMain(). |
|
|
Definition at line 65 of file common.c. Referenced by Com_DPrintf(), Com_Init(), SV_RankBegin(), uninstall_grabs(), VM_LoadSymbols(), and XLateKey(). |
|
|
Definition at line 69 of file common.c. Referenced by Com_EventLoop(), and Com_Init(). |
|
|
Definition at line 97 of file common.c. Referenced by Com_Error(). |
|
|
Definition at line 100 of file common.c. Referenced by Com_Error(). |
|
|
Definition at line 68 of file common.c. Referenced by Com_Init(), and Com_ModifyMsec(). |
|
|
Definition at line 94 of file common.c. Referenced by Com_Frame(). |
|
|
Definition at line 95 of file common.c. Referenced by Com_Frame(). |
|
|
Definition at line 93 of file common.c. Referenced by CL_CreateNewCommands(), CL_KeyState(), Com_Frame(), Com_Init(), and SV_MapRestart_f(). |
|
|
Definition at line 98 of file common.c. Referenced by Com_Init(), and FS_FOpenFileRead(). |
|
|
Definition at line 80 of file common.c. Referenced by Com_Init(). |
|
|
Definition at line 70 of file common.c. Referenced by Com_GetRealEvent(), Com_InitJournaling(), and FS_ReadFile(). |
|
|
Definition at line 61 of file common.c. Referenced by Com_InitJournaling(), and FS_ReadFile(). |
|
|
Definition at line 60 of file common.c. Referenced by Com_GetRealEvent(), Com_InitJournaling(), and Com_Shutdown(). |
|
|
Definition at line 75 of file common.c. Referenced by Com_Init(), and Com_Printf(). |
|
|
Definition at line 71 of file common.c. Referenced by Com_Frame(), and Com_Init(). |
|
|
Definition at line 354 of file common.c. Referenced by Com_ParseCommandLine(). |
|
|
Definition at line 1896 of file common.c. Referenced by Com_GetEvent(), Com_InitPushEvent(), and Com_PushEvent(). |
|
|
Definition at line 1893 of file common.c. Referenced by Com_GetEvent(), Com_InitPushEvent(), and Com_PushEvent(). |
|
|
Definition at line 1894 of file common.c. Referenced by Com_GetEvent(), Com_InitPushEvent(), and Com_PushEvent(). |
|
|
Definition at line 76 of file common.c. Referenced by Com_Frame(), and Com_Init(). |
|
|
Definition at line 64 of file common.c. Referenced by Com_Frame(), Com_Init(), Com_RunAndTimeServerPacket(), SCR_UpdateScreen(), and SV_Frame(). |
|
|
Definition at line 73 of file common.c. Referenced by CL_AdjustTimeDelta(), CL_Connect_f(), CL_FlushMemory(), CL_Frame(), CL_GetServerCommand(), CL_SendCmd(), CL_SetCGameTime(), CL_Vid_Restart_f(), Cmd_ExecuteString(), Com_EventLoop(), Com_Init(), Com_ModifyMsec(), SV_Ban_f(), SV_BanNum_f(), SV_ConSay_f(), SV_DumpUser_f(), SV_Frame(), SV_GetPlayerByName(), SV_GetPlayerByNum(), SV_Kick_f(), SV_KickNum_f(), SV_MapRestart_f(), SV_Shutdown(), and SV_Status_f(). |
|
|
Definition at line 72 of file common.c. Referenced by Com_Frame(), and Com_Init(). |
|
|
Definition at line 67 of file common.c. Referenced by CIN_RunCinematic(), CL_AdjustTimeDelta(), CL_Frame(), CL_ScaledMilliseconds(), Com_Init(), Com_ModifyMsec(), RoQ_init(), and RoQInterrupt(). |
|
|
Definition at line 77 of file common.c. Referenced by CL_RequestMotd(), and Com_Init(). |
|
|
Definition at line 63 of file common.c. Referenced by Com_Frame(), Com_Init(), ConWndProc(), and WinMain(). |
|
|
Definition at line 3185 of file common.c. Referenced by ConcatRemaining(), Field_CompleteCommand(), and keyConcatArgs(). |
|
|
Definition at line 3181 of file common.c. Referenced by Field_CompleteCommand(), and FindMatches(). |
|
|
|
|
|
Initial value:
{ 66, 67, 68, 0 }
Definition at line 37 of file common.c. Referenced by CL_PlayDemo_f(), and CL_WalkDemoExt(). |
|
|
Initial value:
{ {(sizeof(memblock_t)+2 + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'\0', '\0'} }
Definition at line 1119 of file common.c. Referenced by BotLoadMatchPieces(). |
|
|
Definition at line 1219 of file common.c. Referenced by Com_Meminfo_f(), Com_TouchMemory(), Hunk_Alloc(), Hunk_CheckMark(), Hunk_Clear(), Hunk_ClearToMark(), Hunk_MemoryRemaining(), and Hunk_SetMark(). |
|
|
Definition at line 1219 of file common.c. Referenced by Com_Meminfo_f(), Com_TouchMemory(), Hunk_Alloc(), Hunk_CheckMark(), Hunk_Clear(), Hunk_ClearToMark(), Hunk_MemoryRemaining(), and Hunk_SetMark(). |
|
|
Definition at line 1220 of file common.c. Referenced by Hunk_Alloc(), Hunk_AllocateTempMemory(), Hunk_Clear(), Hunk_SwapBanks(), and Hunk_Trash(). |
|
|
Definition at line 1220 of file common.c. Referenced by Hunk_Alloc(), Hunk_AllocateTempMemory(), Hunk_Clear(), Hunk_ClearTempMemory(), Hunk_FreeTempMemory(), and Hunk_SwapBanks(). |
|
|
Definition at line 1217 of file common.c. Referenced by Hunk_Alloc(), and Hunk_Clear(). |
|
|
|
|
|
Definition at line 750 of file common.c. Referenced by Com_InitZoneMemory(), Com_Meminfo_f(), Com_TouchMemory(), Z_AvailableMemory(), Z_CheckHeap(), and Z_LogHeap(). |
|
|
Definition at line 3183 of file common.c. Referenced by Field_CompleteCommand(), and FindMatches(). |
|
|
Initial value: {
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'0', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'1', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'2', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'3', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'4', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'5', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'6', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'7', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'8', '\0'} },
{ {(sizeof(memstatic_t) + 3) & ~3, TAG_STATIC, NULL, NULL, ZONEID}, {'9', '\0'} }
}
Definition at line 1121 of file common.c. Referenced by CopyString(). |
|
|
Definition at line 107 of file common.c. Referenced by Com_BeginRedirect(), Com_EndRedirect(), and Com_Printf(). |
|
|
Definition at line 108 of file common.c. Referenced by Com_BeginRedirect(), Com_EndRedirect(), and Com_Printf(). |
|
|
Definition at line 109 of file common.c. Referenced by Com_BeginRedirect(), Com_EndRedirect(), and Com_Printf(). |
|
|
Definition at line 1222 of file common.c. Referenced by Com_InitHunkMemory(), Hunk_Alloc(), Hunk_AllocateTempMemory(), Hunk_ClearTempMemory(), Hunk_FreeTempMemory(), and Hunk_Trash(). |
|
|
Definition at line 1223 of file common.c. Referenced by Com_InitHunkMemory(), Com_Meminfo_f(), Com_TouchMemory(), Hunk_Alloc(), Hunk_AllocateTempMemory(), Hunk_FreeTempMemory(), Hunk_MemoryRemaining(), and Hunk_Trash(). |
|
|
Definition at line 1226 of file common.c. Referenced by Com_InitSmallZoneMemory(). |
|
|
Definition at line 1225 of file common.c. Referenced by Com_InitZoneMemory(), and Com_Meminfo_f(). |
|
|
Definition at line 3182 of file common.c. Referenced by Field_CompleteCommand(), FindMatches(), and PrintMatches(). |
|
|
Definition at line 753 of file common.c. Referenced by Com_InitSmallZoneMemory(), Com_Meminfo_f(), Z_LogHeap(), and Z_TagMalloc(). |
|
|
Definition at line 82 of file common.c. Referenced by CL_CheckTimeout(), CL_SendCmd(), CL_SetCGameTime(), Com_Init(), and SV_CheckPaused(). |
|
|
Definition at line 91 of file common.c. Referenced by Com_Frame(), and SCR_UpdateScreen(). |
|
|
Definition at line 90 of file common.c. Referenced by Com_Frame(), and SCR_UpdateScreen(). |
|
|
Definition at line 89 of file common.c. Referenced by Com_Frame(), and SV_Frame(). |
1.3.9.1