void Z_TagPointers(memtag_t eTag) { assert(s_Initialized); #ifndef _GAMECUBE WaitForSingleObject(s_Mutex, INFINITE); #endif Sys_Log( "pointers.txt", va("Pointers for tag %d:\n", eTag) ); for (ZoneLinkHeader* link = s_LinkBase; link;) { ZoneHeader* header = (ZoneHeader*)(link + 1); link = link->m_Next; if (eTag == TAG_ALL || Z_GetTag(header) == eTag) { #ifdef _DEBUG Sys_Log( "pointers.txt", va("%x - %d\n", ((void*)((char*)header + sizeof(ZoneHeader) + sizeof(ZoneDebugHeader))), Z_Size(((void*)((char*)header + sizeof(ZoneHeader) + sizeof(ZoneDebugHeader)))))); #else Sys_Log( "pointers.txt", va("%x - %d\n", (void*)(header + 1), Z_Size((void*)(header + 1)))); #endif } } #ifndef _GAMECUBE ReleaseMutex(s_Mutex); #endif }
bool CG_NetSocket::_NetStartUp(int VersionHigh,int VersionLow) { #ifdef WIN32 WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD(VersionHigh,VersionLow); err=WSAStartup(wVersionRequested, &wsaData); /* startup failed */ if (err!=0) { Sys_Log("WSAStartup Error"); WSACleanup(); return false; } /* version error */ if (LOBYTE(wsaData.wVersion)!= VersionLow || HIBYTE(wsaData.wVersion)!= VersionHigh ) { Sys_Log("WSAStartup Version Error"); WSACleanup(); return false; } Sys_Log("WSAStartup OK"); #endif return true; }
bool CG_NetSocket::Connect(char *szAddr, int port, unsigned long ip) { SOCKADDR_IN addrRemote; hostent *host=NULL; memset(&addrRemote,0,sizeof(addrRemote)); addrRemote.sin_family=AF_INET; addrRemote.sin_port=htons(port); if(szAddr) addrRemote.sin_addr.s_addr = inet_addr(szAddr); else addrRemote.sin_addr.s_addr = ip; if(addrRemote.sin_addr.s_addr==INADDR_NONE) { if(!szAddr) return false; host=gethostbyname(szAddr); if(!host) return false; memcpy(&addrRemote.sin_addr,host->h_addr_list[0],host->h_length); } if(connect(m_socket,(SOCKADDR *)&addrRemote,sizeof(addrRemote)) ==SOCKET_ERROR) { int err = GETERROR; if (err != CONN_INPRROGRESS) { Sys_Log("socket connect error = %d",err); return false; } } return true; }
void Z_DumpMemMap_f(void) { # define WRITECHAR(C) \ Sys_Log("memmap.txt", C, 1, false); \ cur += 1024; \ if ((++counter) % 81 == 0) Sys_Log("memmap.txt", "\n", 1, false); unsigned int cur = (unsigned int)s_PoolBase; unsigned int counter = 0; for (ZoneFreeBlock* fblock = &s_FreeStart; fblock != &s_FreeEnd; fblock = fblock->m_Next) { while (fblock->m_Address > cur + 1024) { WRITECHAR("*"); } if (fblock->m_Address > cur && fblock->m_Address < cur + 1024) { WRITECHAR("+"); } while (fblock->m_Address + fblock->m_Size > cur + 1024) { WRITECHAR("-"); } if (fblock->m_Address + fblock->m_Size > cur && fblock->m_Address + fblock->m_Size < cur + 1024) { WRITECHAR("+"); } } Sys_Log("memmap.txt", "\n"); }
bool CG_NetSocket::Listen() { if(listen(m_socket,SOMAXCONN)==SOCKET_ERROR) { Sys_Log("NetSocket:listen error"); return false; } return true; }
void Z_CompactStats(void) { assert(s_Initialized); //This report is conservative. Divides by 1000 instead of 1024 and //then rounds up. static int printHeader = 1; if (printHeader) { Sys_Log("memory-map.txt", "**Z_CompactStats Start**\n\n"); Sys_Log("memory-map.txt", "Map:\tOV:\tLVL:\tGLM:\tGLA:\tMD3:\tTER:\tSND:\tTEX:\tFMV:\tMSC:\tFrZN:\tFrPH:\n"); printHeader = 0; } MEMORYSTATUS stat; GlobalMemoryStatus(&stat); Sys_Log("memory-map.txt", va("%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", Cvar_VariableString( "mapname" ), (s_Stats.m_OverheadAlloc / 1000) + 1, (Z_GetLevelMemory() / 1000) + 1, (s_Stats.m_SizesPerTag[TAG_MODEL_GLM] / 1000) + 1, (s_Stats.m_SizesPerTag[TAG_MODEL_GLA] / 1000) + 1, (s_Stats.m_SizesPerTag[TAG_MODEL_MD3] / 1000) + 1, (Z_GetTerrainMemory() / 1000) + 1, (s_Stats.m_SizesPerTag[TAG_SND_RAWDATA] / 1000) + 1, (texMemSize / 1000) + 1, (s_Stats.m_SizesPerTag[TAG_BINK] / 1000) + 1, (Z_GetMiscMemory() / 1000) + 1, s_Stats.m_SizeFree, stat.dwAvailPhys)); #ifdef _JK2MP Sys_Log("memory-map.txt", va("HUNK: %d, THUNK: %d\n", (s_Stats.m_SizesPerTag[TAG_HUNKALLOC] / 1000) + 1, (s_Stats.m_SizesPerTag[TAG_TEMP_HUNKALLOC] / 1000) + 1)); #endif //Sys_Log("memory-map.txt", va("Free Zone: %d\n", s_Stats.m_SizeFree)); }
SOCKET CG_NetSocket::Accept() { SOCKADDR_IN addr; int len = sizeof(addr); SOCKET tmp; tmp = accept(m_socket,(SOCKADDR *)&addr,(socklen_t *)&len); if (tmp == INVALID_SOCKET || tmp == NULL) { Sys_Log("accept error"); return NULL; } m_nCount++; return tmp; }
bool CG_NetSocket::BindAddr(char *ip,int port) { SOCKADDR_IN addrLocal; addrLocal.sin_family=AF_INET; addrLocal.sin_port=htons(port); if(ip) { addrLocal.sin_addr.s_addr=inet_addr(ip); } else { addrLocal.sin_addr.s_addr=htonl(INADDR_ANY); } if(bind(m_socket,(SOCKADDR *)&addrLocal,sizeof(addrLocal))==SOCKET_ERROR) { Sys_Log("bind socket error"); return false; } return true; }
static GOBVoid gi_profileread(GOBUInt32 code) { code = LittleLong(code); Sys_Log("gob-prof-mp.dat", &code, sizeof(code), true); }
/* ============== Sys_Log ============== */ void Sys_Log( const char *file, const char *msg ) { Sys_Log(file, msg, strlen(msg), strchr(msg, '\n') ? true : false); }