THttpResponse TResponseBuilder::FormResponse() { Response.Headers.push_back(MakePair("Content-Length", TString(NStr::TStringBuilder() << Response.Body.size()))); Response.Headers.push_back(MakePair("Connection", "Closed")); Response.Headers.push_back(MakePair("Date", GetDateAndTime())); Response.Headers.push_back(MakePair("Server", "DnnServer")); Response.Headers.push_back(MakePair("LastModified", GetDateAndTime())); return Response; }
//Function to measure FPS. Called once per frame. int GameDebugger::MeasureFPS() { struct tm* myTime = GetDateAndTime(); if(lsecond < 0) { mfps = 0; lsecond = myTime->tm_sec; //measuring_fps = true; //return mfps; } /*if(!measuring_fps && lsecond != myTime->tm_sec) { measuring_fps = true; lsecond = myTime->tm_sec; return mfps; }*/ if(lsecond == myTime->tm_sec) { mfps++; }else{ mfps++; lsecond = -1; pfps = mfps; //measuring_fps = false; } return mfps; }
//Function to add information to the log. Similar to printf. void GameDebugger::Log(const char* message, const char* itype, ...) { struct tm* mytime = GetDateAndTime(); #ifdef _DEBUG //The user is not going to see this unless this is the Debug configuration. printf("%02i:%02i:%02i f %I64u%I64u (%i fps) | %s > ",mytime->tm_hour, mytime->tm_min, mytime->tm_sec, fc1, fc2, pfps, itype); #endif fprintf(OutputFile, "%02i:%02i:%02i f %I64u%I64u (%i fps) | %s > ", mytime->tm_hour, mytime->tm_min, mytime->tm_sec, fc1, fc2, pfps, itype); va_list arguments; va_start (arguments, itype); vprintf(message,arguments); vfprintf(OutputFile,message,arguments); va_end(arguments); #ifdef _DEBUG printf("\n"); #endif fprintf(OutputFile, "\n"); return; }
//Get the system information and print everything on screen (and in the log file) void GameDebugger::GetSystemSpecs(ALLEGRO_DISPLAY* mydisplay) { GetSystemInfo(&SystemInfo); struct tm* mytime = GetDateAndTime(); fprintf(OutputFile, "-- START OF LOG FILE --\nTIMESTAMP: %02i/%02i/%02i - %02i:%02i:%02i\n\n",1+mytime->tm_mday, 1+mytime->tm_mon, 1900+mytime->tm_year, mytime->tm_hour, mytime->tm_min, mytime->tm_sec); GetPhysicallyInstalledSystemMemory(&pMemory); myMemory.dwLength = sizeof(myMemory); GlobalMemoryStatus(&myMemory); fprintf(OutputFile, "-- SYSTEM SPECS --\n\n"); fprintf(OutputFile, "CPU: %s\n", cpuInstInfo.cpusignature); fprintf(OutputFile, "Cores: %i\n", SystemInfo.dwNumberOfProcessors); #ifdef _DEBUG printf("-- SYSTEM SPECS --\n\n"); printf("CPU: %s\n", cpuInstInfo.cpusignature); printf("Cores: %i\n", SystemInfo.dwNumberOfProcessors); #endif if(cpuInstInfo.PFLAGS.PYSICAL_ADDRESS_E) { fprintf(OutputFile, "Physical Address Extension (PAE) Available (x86_64)\n"); #ifdef _DEBUG printf("Physical Address Extension (PAE) Available (x86_64)\n"); #endif } fprintf(OutputFile, "Other processor extensions: "); printf("Other processor extensions: "); if(cpuInstInfo.PFLAGS.LONGMODE) { fprintf(OutputFile, "lm "); #ifdef _DEBUG printf("lm "); #endif } if(cpuInstInfo.PFLAGS.MMX_INSTRUCTIONS) { fprintf(OutputFile, "mmx "); #ifdef _DEBUG printf("mmx "); #endif } if(cpuInstInfo.PFLAGS.EXT_MMX) { fprintf(OutputFile, "mmxext "); #ifdef _DEBUG printf("mmxext "); #endif } if(cpuInstInfo.PFLAGS.B3DNOW) { fprintf(OutputFile, "3dnow "); #ifdef _DEBUG printf("3dnow "); #endif } if(cpuInstInfo.PFLAGS.EXT_3DNOW) { fprintf(OutputFile, "3dnowext "); #ifdef _DEBUG printf("3dnowext "); #endif } if(cpuInstInfo.PFLAGS.MULTIPROCESSOR_CAPABLE) { fprintf(OutputFile, "mp "); #ifdef _DEBUG printf("mp "); #endif } fprintf(OutputFile, "\n\n -- RAM INFORMATION -- \n\n"); fprintf(OutputFile, "Physical RAM: %I64u Mb\n",pMemory/1024); fprintf(OutputFile, "Available RAM: %i Mb\n",myMemory.dwAvailPhys / 1024 / 1024); fprintf(OutputFile, "Total PageFile: %i Mb\n",myMemory.dwTotalPageFile / 1024 / 1024); fprintf(OutputFile, "Available PageFile: %i Mb\n",myMemory.dwAvailPageFile / 1024 / 1024); fprintf(OutputFile, "Total Virtual Memory: %i Mb\n",myMemory.dwTotalVirtual / 1024 / 1024); fprintf(OutputFile, "Available Virtual Memory: %i Mb\n",myMemory.dwAvailVirtual / 1024 / 1024); #ifdef _DEBUG printf("\n\n -- RAM INFORMATION -- \n\n"); printf("Physical RAM: %I64u Mb\n",pMemory/1024); printf("Available RAM: %i Mb\n",myMemory.dwAvailPhys / 1024 / 1024); printf("Total PageFile: %i Mb\n",myMemory.dwTotalPageFile / 1024 / 1024); printf("Available PageFile: %i Mb\n",myMemory.dwAvailPageFile / 1024 / 1024); printf("Total Virtual Memory: %i Mb\n",myMemory.dwTotalVirtual / 1024 / 1024); printf("Available Virtual Memory: %i Mb\n",myMemory.dwAvailVirtual / 1024 / 1024); #endif if(IsD3D(mydisplay)) { #ifdef _DEBUG printf("Using Direct 3D\n"); #endif fprintf(OutputFile, "Using Direct 3D\n"); GetD3DInfo(mydisplay); }else{ #ifdef _DEBUG printf("Using OpenGL 3D\n"); #endif fprintf(OutputFile, "Using OpenGL\n"); GetGLInfo(mydisplay); } return; }