Advertisement
Guest User

Untitled

a guest
Jun 6th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.95 KB | None | 0 0
  1. // main.cpp
  2. /* Converter */
  3.  
  4. #include "Precomp.h"
  5. CLog Log;
  6.  
  7. #define TABLE_NUM   5
  8.  
  9. static string table[TABLE_NUM] = {
  10.     "Exit",
  11.     "creature_proto",
  12.     "creature_names",
  13.     "creature_spawns",
  14.     "Mindeeet",
  15. };
  16.  
  17. bool SendMenu()
  18. {
  19.     uint32 num;
  20.     printf("AscNHalf Sql db converter \n");
  21.     printf("Melyiket szeretned konvertalni?? \n\n");
  22.     for(uint32 i = 0; i < TABLE_NUM; i++)
  23.     {
  24.         printf("%u. %s \n", i, table[i]);
  25.     }
  26.     printf("\nValaszott tabla: ");
  27.     cin >> num;
  28.  
  29.     if(num >= TABLE_NUM)
  30.     {
  31.         printf("Hibas szam. \n ");
  32.         return false;
  33.     }
  34.  
  35.  
  36.     Converter* conv = new Converter();
  37.  
  38.     switch(num)
  39.     {
  40.         case 0:
  41.         {
  42.             // semmit se kell tennünk
  43.         }break;
  44.         case 1:
  45.         {
  46.             conv->creature_proto();
  47.         }break;
  48.         case 2:
  49.         {
  50.             conv->creature_names();
  51.         }break;
  52.         case 3:
  53.         {
  54.             conv->creature_spawns();
  55.         }break;
  56.         case 4:
  57.         {
  58.             conv->creature_proto();
  59.             conv->creature_names();
  60.             conv->creature_spawns();
  61.         }break;
  62.     }
  63.    
  64.     if(num != 0)
  65.     {
  66.         printf("\nMit szretnel tenni?\n");
  67.         printf("1. exit. \n2. ujrainditom a konvertert.");
  68.    
  69.         num = 0;
  70.         cin >> num;
  71.         switch(num)
  72.         {
  73.             case 2:
  74.             {
  75.                 delete conv;
  76.                 return false;
  77.             }break;
  78.         }
  79.     }
  80.        
  81.     delete conv;
  82.     return true;
  83. }
  84.  
  85. void main()
  86. {
  87.     bool end = false;
  88.  
  89.     while(!end)
  90.     {
  91.         end = SendMenu();
  92.     }
  93.     return;
  94. }
  95.  
  96. // converter.cpp
  97. /* Converter */
  98.  
  99. #include "Precomp.h"
  100.  
  101. Converter::Converter()
  102. {
  103.     MySQLConnection * mSQLConnTdb = new MySQLConnection("localhost", "root", "");
  104.     mSQLConnTdb->UseDatabase("tdb");
  105.    
  106.     MySQLConnection * mSQLConnYtdb = new MySQLConnection("localhost", "root", "");
  107.     mSQLConnYtdb->UseDatabase("ytdb");
  108.  
  109.     MySQLConnection * mSQLConnAsc = new MySQLConnection("localhost", "root", "");
  110.     mSQLConnAsc->UseDatabase("test");
  111. }
  112.  
  113. Converter::~Converter()
  114. {
  115.     delete mSQLConnTdb;
  116.     delete mSQLConnYtdb;
  117.     delete mSQLConnAsc;
  118. }
  119.  
  120. void Converter::creature_proto()
  121. {
  122.    
  123.     printf("Converting creature_proto... \n");
  124.  
  125.     CreatureProto * cp = new CreatureProto;
  126.  
  127.     QueryResult* db = mSQLConnTdb->Query("SELECT * FROM creature_template");
  128.     QueryResult* t1;
  129.    
  130.     stringstream ss;
  131.    
  132.     if(db)
  133.     {
  134.         do
  135.         {
  136.             cp->AttackTime = 0;
  137.             cp->AttackType = 0;
  138.             cp->aura_string = "''";
  139.             cp->auraimmune_flag = 0;
  140.             cp->boss = 0;
  141.             cp->BoundingRadius = 0.0f;
  142.             cp->CanMove = 7;
  143.             cp->CombatReach = 0.0f;
  144.             cp->death_state = 0;
  145.             cp->extra_a9_flags = 0;
  146.             cp->Faction = 0;
  147.             cp->fly_speed = 14.0f;
  148.             cp->Id = 0;
  149.             cp->invisibility_type = 0;
  150.             cp->Item1 = 0;
  151.             cp->Item2 = 0;
  152.             cp->Item3 = 0;
  153.             cp->MaxDamage = 0.0f;
  154.             cp->MaxHealth = 1;
  155.             cp->MaxLevel = 0;
  156.             cp->maxmoney = 0;
  157.             cp->MinDamage = 0.0f;
  158.             cp->MinHealth = 1;
  159.             cp->MinLevel = 0;
  160.             cp->minmoney = 0;
  161.             //cp->no_xp = false;
  162.             cp->NPCFLags = 0;
  163.             cp->Power = 0;
  164.             cp->Powertype = 0;
  165.             cp->RangedAttackTime = 0;
  166.             cp->RangedMaxDamage = 0.0f;
  167.             cp->RangedMinDamage = 0.0f;
  168.             for(uint32 i = 0; i < 7; i++)
  169.                 cp->Resistances[i] = 0;
  170.             cp->RespawnTime = 360000;
  171.             cp->run_speed = 8.0f;
  172.             cp->Scale = 0.0f;
  173.             cp->SpellClickid = 0;
  174.             cp->vehicle_entry = -1;
  175.             cp->walk_speed = 2.5f;
  176.    
  177.             t1 = mSQLConnTdb->Query("SELECT `equipentry1`,`equipentry2`,`equipentry3` FROM `creature_equip_template` WHERE `entry`=%u", db->Fetch()[79].GetUInt32());
  178.            
  179.             if(t1)
  180.             {
  181.                 cp->Item1 = t1->Fetch()[0].GetUInt32();
  182.                 cp->Item2 = t1->Fetch()[1].GetUInt32();
  183.                 cp->Item3 = t1->Fetch()[2].GetUInt32();
  184.                 delete t1;
  185.             }
  186.            
  187.             t1 = mSQLConnTdb->Query("SELECT `DeathState` FROM `creature` WHERE `id`=%u", db->Fetch()[0].GetUInt32());
  188.            
  189.             if(t1)
  190.             {
  191.                 cp->death_state = t1->Fetch()[0].GetUInt32();
  192.                 delete t1;
  193.             }
  194.            
  195.             t1 = mSQLConnYtdb->("SELECT `minhealth`,`maxhealth`,`minmana`,`maxmana` FROM `creature_template WHERE `entry`=%u", db->Fetch()[0].GetUInt32());
  196.            
  197.             if(t1)
  198.             {
  199.                 cp->MinHealth = t1->Fetch()[0].GetUInt32();
  200.                 cp->MaxHealth = t1->Fetch()[1].GetUInt32();
  201.                 cp->Power = ((t1->Fetch()[2].GetUInt32() + t1->Fetch()[3].GetUInt32()) * 0.5);
  202.                 delete t1;
  203.             }
  204.             /*subq = "";
  205.             ss.clear();
  206.             ss.str ("");
  207.            
  208.             ss << "SELECT `bounding_radius`, `combat_reach` FROM `creature_model_info` WHERE `modelid`=" ;*/
  209.            
  210.             cp->Id = db->Fetch()[0].GetUInt32();
  211.             cp->MinLevel = db->Fetch()[14].GetUInt32();
  212.             cp->MaxLevel = db->Fetch()[15].GetUInt32();
  213.             cp->Faction = db->Fetch()[17].GetUInt32();
  214.             cp->NPCFLags = db->Fetch()[19].GetUInt32();
  215.             cp->walk_speed = db->Fetch()[20].GetFloat();
  216.             cp->run_speed = db->Fetch()[21].GetFloat();
  217.             cp->Scale = db->Fetch()[22].GetFloat();
  218.             cp->MinDamage = db->Fetch()[24].GetFloat();
  219.             cp->MaxDamage = db->Fetch()[25].GetFloat();
  220.             cp->AttackTime = db->Fetch()[29].GetUInt32();
  221.             cp->RangedAttackTime = db->Fetch()[30].GetUInt32();
  222.             cp->RangedMaxDamage = db->Fetch()[40].GetFloat();
  223.             cp->RangedMinDamage = db->Fetch()[39].GetFloat();
  224.             uint32 y = 0;
  225.             for(uint32 i = 47; i < 53; i++)
  226.             {
  227.                 cp->Resistances[y] = db->Fetch()[i].GetUInt32();
  228.                 ++y;
  229.             }
  230.             if(db->Fetch()[61].GetUInt32() != 0)
  231.                 cp->vehicle_entry = db->Fetch()[61].GetUInt32();
  232.             cp->minmoney = db->Fetch()[62].GetUInt32();
  233.             cp->maxmoney = db->Fetch()[63].GetUInt32();
  234.             cp->extra_a9_flags = db->Fetch()[81].GetUInt32();
  235.            
  236.             ss.clear();
  237.             ss.str ("");
  238.            
  239.             ss << "INSERT INTO `creature_proto` (`entry`, `minlevel`, `maxlevel`, `faction`, `minhealth`, `maxhealth`, `powertype`, `power`,";
  240.             ss << "`scale`, `npcflags`, `attacktime`, `attacktype`, `mindamage`, `maxdamage`, `rangedattacktime`, `rangedmindamage`, `rangedmaxdamage`,";
  241.             ss << "`Item1`, `Item2`, `Item3`, `RespawnTime`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`,";
  242.             ss << "`resistance7`, `combat_reach`, `bounding_radius`, `auras`, `boss`, `minmoney`, `maxmoney`, `invisibility_type`, `death_state`,";
  243.             ss << "`walk_speed`, `run_speed`, `fly_speed`, `extra_a9_flags`, `auraimmune_flag`, `vehicle_entry`, `SpellClickId`, `CanMove`) VALUES (";
  244.             ss << cp->Id << "," << cp->MinLevel << "," << cp->MaxLevel << "," << cp->Faction << "," << cp->MinHealth << "," << cp->MaxHealth << ",";
  245.             ss << cp->Powertype << "," << cp->Power << "," << cp->Scale << "," << cp->NPCFLags << "," << cp->AttackTime << "," << cp->AttackType << ",";
  246.             ss << cp->MinDamage << "," << cp->MaxDamage << "," << cp->RangedAttackTime << "," << cp->RangedMinDamage << "," << cp->RangedMaxDamage << ",";
  247.             ss << cp->Item1 << "," << cp->Item2 << "," << cp->Item3 << "," << cp->RespawnTime << ",";
  248.             for(uint32 i = 0; i < 7; i++)
  249.                 ss << cp->Resistances[i] << ",";
  250.             ss << cp->CombatReach << "," << cp->BoundingRadius << "," << cp->aura_string << "," << cp->boss << "," << cp->minmoney << "," << cp->maxmoney << ",";
  251.             ss << cp->invisibility_type << "," << cp->death_state << "," << cp->walk_speed << "," << cp->run_speed << "," << cp->fly_speed << "," << cp->extra_a9_flags << ",";
  252.             ss << cp->auraimmune_flag << "," << cp->vehicle_entry << "," << cp->SpellClickid << "," << cp->CanMove << ")";
  253.  
  254.             mSQLConnAsc->Execute(ss.str());
  255.            
  256.             printf("%u ", db->Fetch()[0].GetUInt32());
  257.         } while(db->NextRow());
  258.         delete db;
  259.     }
  260.    
  261.     delete cp;
  262. }
  263.  
  264. void Converter::creature_names()
  265. {
  266.     printf("Converting creature_names... \n");
  267.  
  268.     CreatureNames * cn = new CreatureNames;
  269.    
  270.     QueryResult* db = mSQLConnTdb->Query("SELECT * FROM creature_template");
  271.    
  272.     stringstream ss;
  273.    
  274.     if(db)
  275.     {
  276.         do
  277.         {
  278.             cn->Civilian = 0;
  279.             cn->Family = 0;
  280.             cn->Female_DisplayID = 0;
  281.             cn->Female_DisplayID2 = 0;
  282.             cn->Flags1 = 0;
  283.             cn->Id = 0;
  284.             cn->info_str = "";
  285.             cn->Leader = 0;
  286.             cn->Male_DisplayID = 0;
  287.             cn->Male_DisplayID2 = 0;
  288.             cn->Name = "";
  289.             cn->Rank = 0;
  290.             cn->SpellDataID = 0;
  291.             cn->SubName = "";
  292.             cn->Type = 0;
  293.             cn->TypeFlags = 0;
  294.             cn->unkfloat1 = 0.0f;
  295.             cn->unkfloat2 = 0.0f;
  296.             cn->Unknown1 = 0;
  297.  
  298.             cn->Id = db->Fetch()[0].GetUInt32();
  299.             cn->Male_DisplayID = db->Fetch()[6].GetUInt32();
  300.             cn->Male_DisplayID2 = db->Fetch()[7].GetUInt32();
  301.             cn->Female_DisplayID = db->Fetch()[8].GetUInt32();
  302.             cn->Female_DisplayID2 = db->Fetch()[9].GetUInt32();
  303.             if(db->Fetch()[10].GetString() != NULL)
  304.                 cn->Name = db->Fetch()[10].GetString();
  305.             if(db->Fetch()[11].GetString() != NULL)
  306.                 cn->SubName = db->Fetch()[11].GetString();
  307.             if(db->Fetch()[12].GetString() != NULL)
  308.                 cn->info_str = db->Fetch()[12].GetString();
  309.             cn->Rank = db->Fetch()[23].GetUInt32();
  310.             cn->Family = db->Fetch()[34].GetUInt32();
  311.             cn->Type = db->Fetch()[42].GetUInt32();
  312.             cn->TypeFlags = db->Fetch()[43].GetUInt32();
  313.             cn->SpellDataID = db->Fetch()[61].GetUInt32();
  314.             cn->Leader = db->Fetch()[71].GetUInt32();
  315.            
  316.             ss.clear();
  317.             ss.str ("");
  318.            
  319.             ss << "INSERT INTO `creature_names` (`entry`,`name`,`subname`,`info_str`,`Flags1`,`type`,`loot_skill_type`,`family`,`rank`,`unk4`,";
  320.             ss << "`spelldataid`,`male_displayid`,`female_displayid`,`male_displayid2`,`female_displayid2`,`unknown_float1`,`unknown_float2`,";
  321.             ss << "`civilian`,`leader`) VALUES (";
  322.             ss << cn->Id << ",'" << mSQLConnAsc->EscapeString(string(cn->Name)) << "','" << mSQLConnAsc->EscapeString(string(cn->SubName)) << "','";
  323.             ss << mSQLConnAsc->EscapeString(string(cn->info_str)) << "'," << cn->Flags1 << "," << cn->Type << "," << cn->TypeFlags << ",";
  324.             ss << cn->Family << "," << cn->Rank << "," << cn->Unknown1 << "," << cn->SpellDataID << "," << cn->Male_DisplayID << "," << cn->Female_DisplayID << ",";
  325.             ss << cn->Male_DisplayID2 << "," << cn->Female_DisplayID2 << "," << cn->unkfloat1 << "," << cn->unkfloat2 << "," << cn->Civilian << "," << cn->Leader << ")";
  326.            
  327.             mSQLConnAsc->Execute(ss.str());
  328.  
  329.             printf("%u ", db->Fetch()[0].GetUInt32());
  330.         } while(db->NextRow());
  331.         delete db;
  332.     }
  333.     delete cn;
  334. }
  335.  
  336. void Converter::creature_spawns()
  337. {
  338.     printf("Converting creature_spawns... \n");
  339.    
  340.     CreatureSpawn * cs = new CreatureSpawn;
  341.    
  342.     QueryResult* db = mSQLConnYtdb->Query("SELECT * FROM creature");
  343.     QueryResult* t1;
  344.    
  345.     stringstream ss;
  346.    
  347.     if(db)
  348.     {
  349.         do
  350.         {
  351.             cs->bytes = 0;
  352.             cs->bytes1 = 0;
  353.             cs->bytes2 = 0;
  354.             cs->channel_spell = 0;
  355.             cs->channel_target_creature = 0;
  356.             cs->channel_target_go = 0;
  357.             cs->displayid = 0;
  358.             cs->emote_state = 0;
  359.             cs->entry = 0;
  360.             cs->eventid = 0;
  361.             cs->factionid = 0;
  362.             cs->flags = 0;
  363.             cs->id = 0;
  364.             cs->MountedDisplayID = 0;
  365.             cs->movetype = 0;
  366.             cs->map = 0;
  367.             cs->x = 0.0f;
  368.             cs->y = 0.0f;
  369.             cs->z = 0.0f;
  370.             cs->o = 0.0f;
  371.             cs->phase = 0;
  372.             cs->stand_state = 0;
  373.             cs->vehicle = 0;
  374.  
  375.             t1 = mSQLConnTdb->Query("SELECT `unit_flags`,`VehicleId`,`faction_A` FROM `creature_template` WHERE `entry`=%u", db->Fetch()[1].GetUInt32());
  376.  
  377.             if(t1)
  378.             {
  379.                 cs->flags = t1->Fetch()[0].GetUInt32();
  380.                 cs->vehicle = t1->Fetch()[1].GetUInt32();
  381.                 cs->factionid = t1->Fetch()[2].GetUInt32();
  382.                 delete t1;
  383.             }
  384.            
  385.             t1 = mSQLConnYtdb->Query("SELECT `bytes1`,`bytes2`,`mount`,`emote` FROM `creature_template_addon` WHERE `entry`=%u", db->Fetch()[1].GetUInt32());
  386.            
  387.             if(t1)
  388.             {
  389.                 cs->bytes1 = t1->Fetch()[0].GetUInt32();
  390.                 cs->bytes2 = t1->Fetch()[1].GetUInt32();
  391.                 cs->MountedDisplayID = t1->Fetch()[2].GetUInt32();
  392.                 cs->emote_state = t1->Fetch()[3].GetUInt32();
  393.                 delete t1;
  394.             }
  395.            
  396.             cs->id = db->Fetch()[0].GetUInt32();
  397.             cs->entry = db->Fetch()[1].GetUInt32();
  398.             cs->map = db->Fetch()[2].GetUInt32();
  399.             cs->displayid = db->Fetch()[5].GetUInt32();
  400.             cs->x = db->Fetch()[7].GetFloat();
  401.             cs->y = db->Fetch()[8].GetFloat();
  402.             cs->z = db->Fetch()[9].GetFloat();
  403.             cs->o = db->Fetch()[10].GetFloat();
  404.             cs->movetype = db->Fetch()[17].GetUInt32();
  405.             cs->phase = db->Fetch()[4].GetInt32();
  406.    
  407.             ss.clear();
  408.             ss.str ("");
  409.            
  410.             ss << "INSERT INTO `creature_spawns` (`id`,`entry`,`map`,`position_x`,`position_y`,`position_z`,`orientation`,`movetype`,`displayid`,`faction`,`flags`,";
  411.             ss << "`bytes`,`bytes1`,`bytes2`,`emote_state`,`channel_spell`,`channel_target_sqlid_go`,`channel_target_sqlid_creature`,`standstate`,";
  412.             ss << "`MountedDisplayID`,`phase`,`vehicle`,`eventid`) VALUES(";
  413.             ss << cs->id << "," << cs->entry << "," << cs->map << "," << cs->x << "," << cs->y << "," << cs->z << "," << cs->o << "," << cs->movetype << ",";
  414.             ss << cs->displayid << "," << cs->factionid << "," << cs->flags << "," << cs->bytes << "," << cs->bytes1 << "," << cs->bytes2 << "," << cs->emote_state;
  415.             ss << "," << cs->channel_spell << "," << cs->channel_target_go << "," << cs->channel_target_creature << "," << cs->stand_state << ",";
  416.             ss << cs->MountedDisplayID << "," << cs->phase << "," << cs->vehicle << "," << cs->eventid << ")";
  417.            
  418.             mSQLConnAsc->Execute(ss.str());
  419.            
  420.             printf("%u ", db->Fetch()[0].GetUInt32());
  421.         } while(db->NextRow());
  422.         delete db;
  423.     }
  424.     delete cs;
  425. }
  426.  
  427. void Converter::creature_waypoints()
  428. {
  429.     CreatureWaypoints * cw = new CreatureWaypoints;
  430.  
  431.     QueryResult* db = mSQLConnYtdb->Query("SELECT * FROM creature_movement");
  432.  
  433.     stringstream ss;
  434.  
  435.     if(db)
  436.     {
  437.         do
  438.         {
  439.             cw->spawnid = 0;
  440.             cw->waypointid = 0;
  441.             cw->x = 0.0f;
  442.             cw->y = 0.0f;
  443.             cw->z = 0.0f;
  444.             cw->o = 0.0f;
  445.             cw->waittimes = 0;
  446.  
  447.         } while(db->NextRow());
  448.         delete db;
  449.     }
  450.     delete cw;
  451. }
  452.  
  453. // mysqlconnectio.cpp
  454. /* Converter */
  455.  
  456. #include "Precomp.h"
  457.  
  458. MySQLConnection::MySQLConnection(string host, string user, string password)
  459. {
  460.     handle = mysql_init(NULL);
  461.     mysql_real_connect(handle, host.c_str(), user.c_str(), password.c_str(), "", 3306, "", 0);
  462.     if(!handle)
  463.     {
  464.         Log.Notice("mySQL", "Error connecting to database on %s", host.c_str());
  465.         return;
  466.     }
  467.  
  468.     mHost = host;
  469.     mUser = user;
  470.     mPassword = password;
  471. }
  472.  
  473. MySQLConnection::~MySQLConnection()
  474. {
  475.     if(handle)
  476.         mysql_close(handle);
  477. }
  478.  
  479. void MySQLConnection::Execute(string query)
  480. {
  481.     //dunno what it does ...leaving untouched
  482.     int result = mysql_query(handle, query.c_str());
  483.  
  484.     if(result > NULL)
  485.     {
  486.         uint32 errnom = mysql_errno(handle);
  487.         const char * reason = mysql_error(handle);
  488.         Log.Notice("MySQL", "Query Failed: %s\nReason: %s", query.c_str(), reason);
  489.  
  490.         // Errors which require us to reconnect.
  491.         if(errnom == 2006 || errnom == 2008 || errnom == 2013 || errnom == 2055)
  492.         {
  493.             handle = mysql_init(NULL);
  494.             mysql_real_connect(handle, mHost.c_str(), mUser.c_str(), mPassword.c_str(), "", 3306, "", 0);
  495.             if(!handle)
  496.                 return;
  497.  
  498.             UseDatabase(mDatabase);
  499.             Execute(query);
  500.         }
  501.     }
  502. }
  503.  
  504. void MySQLConnection::QueryASync(mySQLCallback callback, const char * query, ...)
  505. {
  506.     char* sql = new char[16384];
  507.     va_list vlist;
  508.     va_start(vlist, query);
  509.     vsnprintf(sql, 16384, query, vlist);
  510.     va_end(vlist);
  511.  
  512.     string querystring = string(sql);
  513.     delete[] sql;
  514.  
  515.     ASyncQuery* pQuery = new ASyncQuery;
  516.     pQuery->callback = callback;
  517.     pQuery->query = querystring;
  518.  
  519.     AsynchronousQueries.push_back(pQuery);
  520. }
  521.  
  522. QueryResult* MySQLConnection::Query(const char * query, ...)
  523. {
  524.     char* sql = new char[16384];
  525.     va_list vlist;
  526.     va_start(vlist, query);
  527.     vsnprintf(sql, 16384, query, vlist);
  528.     va_end(vlist);
  529.  
  530.     string querystring = string(sql);
  531.     delete[] sql;
  532.  
  533.     Execute(querystring);
  534.     QueryResult* res;
  535.     MYSQL_RES* pRes = mysql_store_result(handle);
  536.     uint32 uRows = (uint32)mysql_affected_rows(handle);
  537.     uint32 uFields = (uint32)mysql_field_count(handle);
  538.  
  539.     if(uRows == 0 || uFields == 0 || pRes == 0)
  540.     {
  541.         if(pRes != NULL)
  542.             mysql_free_result(pRes);
  543.  
  544.         return NULL;
  545.     }
  546.  
  547.     res = new QueryResult(pRes, uFields, uRows);
  548.     res->NextRow();
  549.  
  550.     return res;
  551. }
  552.  
  553. string MySQLConnection::EscapeString(string Escape)
  554. {
  555.     char a2[16384] = {0};
  556.     const char * ret;
  557.     if(mysql_real_escape_string(handle, a2, Escape.c_str(), (unsigned long)Escape.length()) == 0)
  558.         ret = Escape.c_str();
  559.     else
  560.         ret = a2;
  561.  
  562.     return string(ret);
  563. }
  564.  
  565. void MySQLConnection::UseDatabase(string database)
  566. {
  567.     mysql_select_db(handle, database.c_str());
  568.     mDatabase = database;
  569. }
  570.  
  571. void MySQLConnection::Update()
  572. {
  573.     while(true)
  574.     {
  575.         if(AsynchronousQueries.size() > NULL)
  576.         {
  577.             ASyncQuery* pQuery = AsynchronousQueries.front();
  578.             AsynchronousQueries.pop_front();
  579.  
  580.             QueryResult* pResult = Query(pQuery->query.c_str());
  581.             if(pResult)
  582.                 pQuery->callback(pResult);
  583.         }
  584.  
  585.         Sleep(100);
  586.     }
  587. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement