openla/src/dllmain.cpp
/*
*  Reads an section of limits to be changed
*/
Reads an section of limits to be changed
Reads an section of limits to be changed
void AdjustLimits(const std::map<std::string, std::string>& section)
{
	FindHandlers(::limits);
	for (auto it = section.begin(); it != section.end(); ++it)
	{
		auto pair = limits.find(it->first);   
		if (pair != limits.end())
		{
			try
			{
				LimitHandler& handler = pair->second;
				handler.adjuster->ChangeLimit(handler.id, it->second);
			}
			catch (const std::exception& ex)
			{
				char buf[512];
				sprintf(buf, "Failed to change limit for '%s' with value '%s'.\nReason: %s\n",
					it->first.c_str(), it->second.c_str(), ex.what());
				MessageBoxA(0, buf, "Limit Adjuster", MB_ICONERROR);
			}
		}
	}
	std::map<Adjuster*, int> adjz;   
	for (auto it = limits.begin(); it != limits.end(); ++it)
	{
		auto* adj = it->second.adjuster;
		if (adjz[adj]++ == 0) adj->Process();    
	}
}
void AdjustLimits ( const std :: map < std :: string , std :: string > & section ) { FindHandlers ( :: limits ) ; for ( auto it = section . begin ( ) ; it != section . end ( ) ; ++ it ) { auto pair = limits . find ( it -> first ) ; if ( pair != limits . end ( ) ) { try { LimitHandler & handler = pair -> second ; handler . adjuster -> ChangeLimit ( handler . id , it -> second ) ; } catch ( const std :: exception & ex ) { char buf [ 512 ] ; sprintf ( buf , " \n \n " , it -> first . c_str ( ) , it -> second . c_str ( ) , ex . what ( ) ) ; MessageBoxA ( 0 , buf , " " , MB_ICONERROR ) ; } } } std :: map < Adjuster * , int > adjz ; for ( auto it = limits . begin ( ) ; it != limits . end ( ) ; ++ it ) { auto * adj = it -> second . adjuster ; if ( adjz [ adj ] ++ == 0 ) adj -> Process ( ) ; } }
Reads an section of limits to be changed
Reads an section of limits to be changed
// Find the handler for each limit // Parse the section and call the handler for each limit // Find this limit handler // Change the limit // ...ops... something wrong happened at ChangeLimit, failed to convert from string to int? // Dunno, let's report it to the user // Run Process() // list of already processed adjusters (int is dummy, too lazy to use std::set) // Run only once for each Adjuster*