/* * -- calibrate * * Calibrate the packet timestamps * */ void calibrate(struct _snifferinfo * info) { struct map_area_header * m = info->m; clock_retimer_t ** cr = info->clock_retimers; uint size = info->retimer_size; uint num; uint calibrated; logmsg(V_LOGSNIFFER, "Starting timer calibration\n"); num = calibrated = 0; do { struct timeval now; uint s, t; while (m->k2u_cons >= m->k2u_prod) mb(); t = m->k2u_prod; mb(); gettimeofday(&now, NULL); for (s = m->k2u_cons; s < t; s++) { uint iface; int ind; ind = s % RING_SIZE; iface = m->k2u_pipe[ind].interface; if (iface == (unsigned short)-1) continue; if (iface >= size) { logmsg(V_LOGSNIFFER, "Extend retimer array: %d -> %d\n", size, iface + 1); cr = safe_realloc(cr, (iface + 1) * sizeof(cr[0])); memset(cr + size, 0, sizeof(cr[0]) * (iface + 1 - size)); size = iface + 1; } if (cr[iface] == NULL) { logmsg(V_LOGSNIFFER, "Found interface %d\n", iface); cr[iface] = new_clock_retimer("", 0); num++; } calibrated += doTimer(cr[iface], m->k2u_pipe[ind].tstamp, 0, &now); } discard_packets(m); } while (calibrated != num); info->retimer_size = size; logmsg(V_LOGSNIFFER, "Calibrated %d interfaces\n", calibrated); }
int main(int argc, char *argv[]) { #ifdef PSPSDK pspDebugScreenInit(); SetupCallbacks(); #else // Shut down the server if we get a kill signal. signal( SIGINT, (sighandler_t) shutdownServer ); signal( SIGTERM, (sighandler_t) shutdownServer ); #endif /* Setup Data-Directory */ dataDir = CBuffer(argv[0]).replaceAll("\\", "/"); dataDir = dataDir.copy(0, dataDir.findl('/') + 1); programDir = dataDir; dataDir << "world/"; /* Main Initiating */ adminNames.load( __admin, sizeof(__admin) / sizeof(const char*) ); colourNames.load( __colours, sizeof(__colours) / sizeof(const char*) ); clothCommands.load( __cloths, sizeof(__cloths) / sizeof(const char*) ); defaultFiles.load( __defaultfiles, sizeof(__defaultfiles) / sizeof(const char*) ); playerIds.add(0); playerIds.add(0); npcIds.add(0); srand((int)time(NULL)); /* Load Important Files */ updateFile("rchelp.txt"); updateFile("rcmessage.txt"); updateFile("rules.txt"); updateFile("serverflags.txt"); updateFile("servermessage.html"); updateFile("foldersconfig.txt"); /* Load Settings */ if (!loadSettings("serveroptions.txt")) { errorOut("errorlog.txt", "Unable to load server settings.."); return 1; } /* Load Weapons */ if (!loadWeapons("weapons.txt")) { errorOut("errorlog.txt", "Unable to load weapons from weapons.txt.."); return 1; } /* Initialize Sockets */ serverSock.setType( SOCKET_TYPE_SERVER ); serverSock.setProtocol( SOCKET_PROTOCOL_TCP ); serverSock.setOptions( SOCKET_OPTION_NONBLOCKING ); serverSock.setDescription( "serverSock" ); CString empty; if ( serverSock.init( empty, serverPort ) ) return 1; // Connect server socket. if ( serverSock.connect() ) { errorOut("errorlog.txt", CString() << "SOCK ERROR: Unable to listen on port: " << serverPort); return 1; } /* Server Finished Loading */ printf("GServer 2 by 39ster\nSpecial thanks to Marlon, Agret, Pac300, 39ster and others for porting the \noriginal 1.39 gserver to 2.1\nServer listening on port: %s\nServer version: Build %s\n\n", serverPort.text(), listServerFields[3].text()); errorOut("serverlog.txt", "Server started"); if ( listServerFields[5] == "localhost" ) errorOut("serverlog.txt", "[DEBUG_LOCALHOSTMODE] Localhost mode is activated.\nListserver communication & account authentication are disabled.", true); serverRunning = true; if ( !(listServerFields[5] == "localhost") ) if (!lsConnected) ListServer_Connect(); while (serverRunning) { long long second = time(NULL); while (second == time(NULL)) { acceptNewPlayers(serverSock); for (int i = 0; i < newPlayers.count(); i ++) { CPlayer* player = (CPlayer*)newPlayers[i]; player->main(); if (player->deleteMe) { delete player; i--; } } for(int i = 0; i < playerList.count(); i++) { CPlayer* player = (CPlayer*)playerList[i]; player->main(); if(player->deleteMe) { delete player; i--; } } // Was moved so it can process faster. - Joey ListServer_Main(); wait(10); } doTimer(); gameTime ++; NOLEVEL->reset(); // Every 30 seconds if (gameTime % 30 == 0) { ListServer_Send(CPacket() << (char)SLSPING << "\n"); } // Every 10 seconds if (gameTime % 10 == 0) { CPacket pPacket; CString file; for (int i = 0; i < playerList.count(); i++) { CPlayer *player = (CPlayer *)playerList[i]; file << player->accountName << "," << player->nickName << "," << player->levelName << "," << toString(player->x) << "," << toString(player->y) << "," << toString(player->ap) << "\n"; } file.save("logs/playerlist.txt"); serverFlags.save("serverflags.txt"); } //Every 5 seconds? int current = getNWTime(); if (nwTime != current) { nwTime = current; for (int i = 0; i < playerList.count(); i++) { CPacket out; out << (char)NEWWORLDTIME; out.writeByte4(current); ((CPlayer*)playerList[i])->sendPacket(out); } } } }
int main(int argc, char* argv[]) { /* Initialize varaibles */ initialize(&argc,&argv); /* Time the creation of a file */ t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_open\n",comm_rank)) if (cgp_open("benchmark.cgns", CG_MODE_WRITE, &fn)) cgp_error_exit(); t1 = MPI_Wtime(); doTimer("File Open", t1-t0); /* Time the creation of a base */ t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cg_base_write\n",comm_rank)) if (cg_base_write(fn, "Base 1", 3, 3, &B)) cgp_error_exit(); t1 = MPI_Wtime(); doTimer("Base Write", t1-t0); /* Time the creation of a zone */ t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cg_zone_write\n",comm_rank)) if (cg_zone_write(fn, B, "Zone 1", nijk, CGNS_ENUMV(Structured), &Z)) cgp_error_exit(); t1 = MPI_Wtime(); doTimer("Zone Write", t1-t0); /* Time the creation of coordinates X */ t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_coord_write X\n",comm_rank)) if (cgp_coord_write(fn,B,Z,CGNS_ENUMV(RealDouble),"CoordinateX",&C)) cgp_error_exit(); t1 = MPI_Wtime(); doTimer("Coord X Write", t1-t0); /* Time the write speed of coordinates X */ MPI_Barrier(MPI_COMM_WORLD); t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_coord_write_data X\n",comm_rank)) if (cgp_coord_write_data(fn,B,Z,C,min,max,x)) cgp_error_exit(); t1 = MPI_Wtime(); MPI_Barrier(MPI_COMM_WORLD); ta = MPI_Wtime(); doTimer("Coord X Write Data", t1-t0); doBandwidth("Coord X Write Data", t1-t0); doBandwidthAgg("Coord X Write Data", ta-t0); /* Time the creation of coordinates Y */ t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_coord_write Y\n",comm_rank)) if (cgp_coord_write(fn,B,Z,CGNS_ENUMV(RealDouble),"CoordinateY",&C)) cgp_error_exit(); t1 = MPI_Wtime(); doTimer("Coord Y Write", t1-t0); /* Time the write speed of coordinates Y */ MPI_Barrier(MPI_COMM_WORLD); t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_coord_write_data Y\n",comm_rank)) if (cgp_coord_write_data(fn,B,Z,C,min,max,y)) cgp_error_exit(); t1 = MPI_Wtime(); MPI_Barrier(MPI_COMM_WORLD); ta = MPI_Wtime(); doTimer("Coord Y Write Data", t1-t0); doBandwidth("Coord Y Write Data", t1-t0); doBandwidthAgg("Coord Y Write Data", ta-t0); /* Time the creation of coordinates Z */ t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_coord_write Z\n",comm_rank)) if (cgp_coord_write(fn,B,Z,CGNS_ENUMV(RealDouble),"CoordinateZ",&C)) cgp_error_exit(); t1 = MPI_Wtime(); doTimer("Coord Z Write", t1-t0); /* Time the write speed of coordinates Z */ MPI_Barrier(MPI_COMM_WORLD); t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_coord_write_data Z\n",comm_rank)) if (cgp_coord_write_data(fn,B,Z,C,min,max,z)) cgp_error_exit(); t1 = MPI_Wtime(); MPI_Barrier(MPI_COMM_WORLD); ta = MPI_Wtime(); doTimer("Coord Z Write Data", t1-t0); doBandwidth("Coord Z Write Data", t1-t0); doBandwidthAgg("Coord Z Write Data", ta-t0); /* Time closing of the file */ t0 = MPI_Wtime(); DEBUG_PRINT(("[%d]cgp_close\n",comm_rank)) if (cgp_close(fn)) cgp_error_exit(); t1 = MPI_Wtime(); doTimer("File Close", t1-t0); finalize(); return 0; }
INT_PTR CUIDialog::dialogProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return (INT_PTR)doInitDialog((HWND)wParam); break; case WM_COMMAND: return (INT_PTR)doPrivateCommand(message, wParam, lParam); case WM_DESTROY: if (doDestroy() == 0) { return (INT_PTR)TRUE; } break; case WM_VSCROLL: if (doVScroll((int)(short)LOWORD(wParam), (int)(short)HIWORD(wParam), (HWND)lParam) == 0) { return (INT_PTR)TRUE; } break; case WM_HSCROLL: if (doHScroll((int)(short)LOWORD(wParam), (int)(short)HIWORD(wParam), (HWND)lParam) == 0) { return (INT_PTR)TRUE; } break; case WM_NOTIFY: return (INT_PTR)doPrivateNotify(message, wParam, lParam); case WM_MOVE: if (doMove((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)) == 0) { return (INT_PTR)TRUE; } break; case WM_SIZE: if (doSize(wParam, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)) == 0) { return (INT_PTR)TRUE; } break; case WM_ENTERMENULOOP: if (doEnterMenuLoop(wParam ? true : false) == 0) { return (INT_PTR)TRUE; } break; case WM_EXITMENULOOP: if (doExitMenuLoop(wParam ? true : false) == 0) { return (INT_PTR)TRUE; } break; case WM_INITMENUPOPUP: if (doInitMenuPopup((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)) == 0) { return (INT_PTR)TRUE; } break; case WM_KEYDOWN: if (doKeyDown((int)wParam, lParam) == 0) { return (INT_PTR)TRUE; } break; case WM_KEYUP: if (doKeyUp((int)wParam, lParam) == 0) { return (INT_PTR)TRUE; } break; case WM_CLOSE: if (doClose() == 0) { return (INT_PTR)TRUE; } break; case WM_TIMER: if (doTimer(wParam) == 0) { return (INT_PTR)TRUE; } break; case WM_GETMINMAXINFO: if (doGetMinMaxInfo(hDlg, (LPMINMAXINFO)lParam) == 0) { return (INT_PTR)TRUE; } break; case WM_MOUSEWHEEL: if (doMouseWheel(LOWORD(wParam), HIWORD(wParam), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)) == 0) { return (INT_PTR)TRUE; } break; case WM_CONTEXTMENU: if (doContextMenu((HWND)wParam, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)) == 0) { return (INT_PTR)TRUE; } break; case WM_DRAWITEM: return doPrivateDrawItem(message, wParam, lParam); } return (INT_PTR)FALSE; }