int AvgChoiceModule::init() {
  std::string config_path = "config.ini";

  CSimpleIniA ini;
  ini.SetMultiKey(true);

  if (ini.LoadFile(config_path.c_str()) < 0) {
    colorPrintf(ConsoleColor(ConsoleColor::red), "Can't load '%s' file!",
                config_path.c_str());
    return 1;
  }

  const char *db_path = ini.GetValue("statisctic", "db_path", NULL);
  if (!db_path) {
    colorPrintf(ConsoleColor(ConsoleColor::red), "Can't read db_path value");
    return 1;
  }

  int rc = sqlite3_open(db_path, &db);
  if (rc) {
    colorPrintf(ConsoleColor(ConsoleColor::red), "Can't open database: %s\n",
                sqlite3_errmsg(db));
    sqlite3_close(db);
    return (1);
  }
  return 0;
}
Ejemplo n.º 2
0
COORD Down (COORD pos, int border)
{
     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    while (1)
    {
        int curColPos;
        if (pos.Y == border)
            break;
        SetConsoleCursorPosition(hConsole, pos);
        curColPos = abs((pos.X - pos.Y) % 3);
        if(pos.Y > pos.X)
            curColPos = 2 - abs((pos.X - pos.Y - 2) % 3);
        ConsoleColor(curColPos);
        printf("*");
        Sleep(10);
        pos.Y++;
    }
    return pos;
}
	void Restore( IRestore *pRestore, bool createPlayers )
	{
		if ( m_fDoLoad )
		{
			pRestore->StartBlock();
 
			size_t	DataLength;
 
			pRestore->ReadData((char*)&DataLength,sizeof(size_t),0);
 
			char*	Data	=	new char[DataLength];
 
			pRestore->ReadData((char*)Data,(int)DataLength,DataLength);
 
			Color ConsoleColor(100,255,100,255);
			ConColorMsg(ConsoleColor,Data);
 
			delete[] Data;
 
			pRestore->EndBlock();
		}
	}