Static Public Member Functions | |
static void | SaveMachines () |
static void | LoadMachines () |
Definition at line 4459 of file nNetwork.cpp.
static void nMachinePersistor::SaveMachines | ( | ) | [inline, static] |
Definition at line 4463 of file nNetwork.cpp.
References nMachine::GetBanReason(), nMachine::IsBanned(), nMachine::kph_, sn_GetMachineMap(), and tDirectories::Var().
04463 { 04464 public: 04465 // save ban info of machines 04466 static void SaveMachines() 04467 { 04468 std::ofstream s; 04469 if (tDirectories::Var().Open( s, sn_machinesFileName ) ) 04470 { 04471 nMachineMap & map = sn_GetMachineMap(); 04472 for( nMachineMap::iterator iter = map.begin(); iter != map.end(); ++iter ) 04473 { 04474 nMachine & machine = *(*iter).second.machine; 04475 // if ( machine.IsBanned() > 0 ) 04476 { 04477 s << (*iter).first << " " << machine.IsBanned() << " " << machine.kph_ << " " << machine.GetBanReason() << "\n"; 04478 }
static void nMachinePersistor::LoadMachines | ( | ) | [inline, static] |
Definition at line 4481 of file nNetwork.cpp.
04485 { 04486 sn_printBans = false; 04487 04488 tTextFileRecorder machines( tDirectories::Var(), sn_machinesFileName ); 04489 while ( !machines.EndOfFile() ) 04490 { 04491 std::stringstream line( machines.GetLine() ); 04492 04493 // address and ban time left 04494 tString address; 04495 REAL banTime; 04496 04497 // read relevant info 04498 line >> address >> banTime; 04499 std::ws(line); 04500 04501 // read kph averager 04502 nAverager kph; 04503 char c; 04504 line.get(c); 04505 line.putback(c); 04506 if ( c == '(' ) 04507 { 04508 line >> kph; 04509 std::ws(line); 04510 } 04511 04512 // read reason 04513 tString reason; 04514 reason.ReadLine( line ); 04515 04516 if ( address.Len() > 2 ) 04517 { 04518 // ban 04519 nMachine & machine = sn_LookupMachine( address ); 04520 machine.Ban( banTime, reason ); 04521 machine.kph_ = kph; 04522 } 04523 }