Advertisement
sorvani

instance shutdown diff

Feb 13th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.43 KB | None | 0 0
  1.  common/database.cpp |  0
  2.  zone/command.cpp    |  3 +++
  3.  zone/questmgr.cpp   |  2 ++
  4.  zone/zone.cpp       | 15 ++++++++++++---
  5.  4 files changed, 17 insertions(+), 3 deletions(-)
  6.  
  7. diff --git a/zone/command.cpp b/zone/command.cpp
  8. index 3295841..bf18925 100644
  9. --- a/zone/command.cpp
  10. +++ b/zone/command.cpp
  11. @@ -66,6 +66,7 @@
  12.  // these should be in the headers...
  13.  extern WorldServer worldserver;
  14.  extern TaskManager *taskmanager;
  15. +extern Zone* zone;
  16.  void CatchSignal(int sig_num);
  17.  
  18.  #include "QuestParserCollection.h"
  19. @@ -9161,6 +9162,8 @@ void command_instance(Client *c, const Seperator *sep)
  20.         uint16 id = atoi(sep->arg[2]);
  21.         database.DeleteInstance(id);
  22.         c->Message(0, "Destroyed instance with id %lu.", (unsigned long)id);
  23. +       // start 20 second timer to shut down instance
  24. +       zone->SetInstanceTimer(20000);
  25.     }
  26.     else if(strcasecmp(sep->arg[1], "add") == 0)
  27.     {
  28. diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp
  29. index e018385..1b399bf 100644
  30. --- a/zone/questmgr.cpp
  31. +++ b/zone/questmgr.cpp
  32. @@ -2508,6 +2508,8 @@ uint16 QuestManager::CreateInstance(const char *zone, int16 version, uint32 dura
  33.  void QuestManager::DestroyInstance(uint16 instance_id)
  34.  {
  35.     database.DeleteInstance(instance_id);
  36. +   // start a 20 second shutdown clock for the instance.
  37. +   zone->SetInstanceTimer(20000);
  38.  }
  39.  
  40.  uint16 QuestManager::GetInstanceID(const char *zone, int16 version)
  41. diff --git a/zone/zone.cpp b/zone/zone.cpp
  42. index 487bda5..6b697d5 100644
  43. --- a/zone/zone.cpp
  44. +++ b/zone/zone.cpp
  45. @@ -1505,13 +1505,22 @@ bool Zone::HasWeather()
  46.  }
  47.  
  48.  void Zone::StartShutdownTimer(uint32 set_time) {
  49. -   if (set_time > autoshutdown_timer.GetRemainingTime()) {
  50. -       if (set_time == (RuleI(Zone, AutoShutdownDelay)))
  51. -       {
  52. +   // check if the zone is a non reserved instance
  53. +   if (zone->GetInstanceID() > (RuleI(Zone, ReservedInstances))) {
  54. +       bool is_perma = false;
  55. +       // check if the instance has expired
  56. +       if (database.GetTimeRemainingInstance(zone->GetInstanceID(), is_perma) == 0) {
  57. +           //if it is expired, set the shutdown timer to 5 seconds (database default)
  58. +           set_time = 5000;
  59. +           autoshutdown_timer.Start(set_time, false);
  60. +       }
  61. +   } else if (set_time > autoshutdown_timer.GetRemainingTime()) {
  62. +       if (set_time == (RuleI(Zone, AutoShutdownDelay))) {
  63.             set_time = database.getZoneShutDownDelay(GetZoneID(), GetInstanceVersion());
  64.         }
  65.         autoshutdown_timer.Start(set_time, false);
  66.     }
  67. +  
  68.  }
  69.  
  70.  bool Zone::Depop(bool StartSpawnTimer) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement