Advertisement
sorvani

where to fix instance check

Feb 10th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.28 KB | None | 0 0
  1.  common/database.cpp | 74 +++++++++++++++--------------------------------------
  2.  1 file changed, 20 insertions(+), 54 deletions(-)
  3.  
  4. diff --git a/common/database.cpp b/common/database.cpp
  5. index ace5bf4..e94df75 100644
  6. --- a/common/database.cpp
  7. +++ b/common/database.cpp
  8. @@ -2516,68 +2516,34 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id)
  9.     MYSQL_RES *result;
  10.     MYSQL_ROW row;
  11.  
  12. -   if (RunQuery(query, MakeAnyLenString(&query, "SELECT COUNT(*) FROM instance_lockout"), errbuf, &result))
  13. -   {
  14. -       safe_delete_array(query);
  15. -       if (mysql_num_rows(result) != 0)
  16. -       {
  17. -           row = mysql_fetch_row(result);
  18. -           int count = atoi(row[0]);
  19. -           if(count == 0)
  20. -           {
  21. -               mysql_free_result(result);
  22. -               instance_id = RuleI(Zone, ReservedInstances) + 1;
  23. -               return true;
  24. -           }
  25. -       }
  26. -       else
  27. -       {
  28. -           mysql_free_result(result);
  29. -       }
  30. -       mysql_free_result(result);
  31. -   }
  32. -   else
  33. -   {
  34. -       safe_delete_array(query);
  35. -       instance_id = 0;
  36. -       return false;
  37. -   }
  38. -
  39. -   int32 count = RuleI(Zone, ReservedInstances) + 1;
  40. -   int32 max = 65535;
  41. -
  42. -   if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id >= %i ORDER BY id", count), errbuf, &result))
  43. -   {
  44. -       safe_delete_array(query);
  45. -       if (mysql_num_rows(result) != 0)
  46. -       {
  47. -           while((row = mysql_fetch_row(result)))
  48. -           {
  49. -               if(count < atoi(row[0]))
  50. -               {
  51. -                   instance_id = count;
  52. -                   mysql_free_result(result);
  53. -                   return true;
  54. -               }
  55. -               else if(count > max)
  56. -               {
  57. +   uint32 count = RuleI(Zone, ReservedInstances) + 1;
  58. +   uint32 max = 65535;
  59. +
  60. +   if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_lockout where id >= %i ORDER BY id", count), errbuf, &result)) {
  61. +       safe_delete_array(query);
  62. +       if (mysql_num_rows(result) != 0) {
  63. +           while((row = mysql_fetch_row(result))) {
  64. +               if(count < atoi(row[0])) {
  65. +                   if(world_check_for_zone up_returns_true) {
  66. +                       // zone still running this id is not available
  67. +                       count++;
  68. +                   } else {
  69. +                       instance_id = count;
  70. +                       mysql_free_result(result);
  71. +                       return true;
  72. +                   }
  73. +               } else if(count > max) {
  74.                     instance_id = 0;
  75.                     mysql_free_result(result);
  76.                     return false;
  77. -               }
  78. -               else
  79. -               {
  80. +               } else {
  81.                     count++;
  82.                 }
  83.             }
  84. -       }
  85. -       else
  86. -       {
  87. +       } else {
  88.             mysql_free_result(result);
  89.         }
  90. -   }
  91. -   else
  92. -   {
  93. +   } else {
  94.         safe_delete_array(query);
  95.     }
  96.     instance_id = count;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement