Instructions Jenkins Doxygen

[fixed] quest status db now serializes objects and will sync with 69/2269/1
authordannuic <dannuic@swgemu.com>
Sun, 10 Aug 2014 03:21:08 +0000 (21:21 -0600)
committerdannuic <dannuic@swgemu.com>
Sun, 10 Aug 2014 03:21:08 +0000 (21:21 -0600)
database save. -- BE SURE TO DELETE queststatus.db AFTER BUILDING

Change-Id: I41d704d4cf6f8337282e3871c1d41713e616e7b4

MMOCoreORB/src/server/zone/ZoneServerImplementation.cpp
MMOCoreORB/src/server/zone/managers/director/DirectorManager.cpp
MMOCoreORB/src/server/zone/managers/director/DirectorManager.h
MMOCoreORB/src/server/zone/managers/director/QuestStatus.h [new file with mode: 0644]
MMOCoreORB/src/server/zone/managers/object/ObjectManager.cpp

index 33e6f2e..12371cb 100644 (file)
@@ -297,6 +297,7 @@ void ZoneServerImplementation::startManagers() {
 
        //Start global screen plays
        DirectorManager::instance()->loadPersistentEvents();
+       DirectorManager::instance()->loadPersistentStatus();
        DirectorManager::instance()->startGlobalScreenPlays();
 
        auctionManager->initialize();
index 1c015c4..b34dedf 100644 (file)
@@ -28,6 +28,7 @@
 #include "ScreenPlayTask.h"
 #include "server/zone/managers/director/ScreenPlayObserver.h"
 #include "server/zone/managers/director/PersistentEvent.h"
+#include "server/zone/managers/director/QuestStatus.h"
 #include "server/zone/managers/creature/CreatureManager.h"
 #include "server/zone/managers/creature/PetManager.h"
 #include "server/zone/managers/planet/PlanetManager.h"
@@ -79,6 +80,9 @@ DirectorManager::DirectorManager() : Logger("DirectorManager") {
 
        screenPlays.setNullValue(false);
        screenPlays.setNoDuplicateInsertPlan();
+
+       questStatuses.setNullValue(NULL);
+       questStatuses.setNoDuplicateInsertPlan();
 }
 
 void DirectorManager::loadPersistentEvents() {
@@ -110,36 +114,71 @@ void DirectorManager::loadPersistentEvents() {
        info(String::valueOf(i) + " persistent events loaded.", true);
 }
 
-void DirectorManager::setQuestStatus(String keyString, String valString) {
-       LocalDatabase* questDB = ObjectDatabaseManager::instance()->loadLocalDatabase("queststatus", true);
+void DirectorManager::loadPersistentStatus() {
+       info("Loading persistent quest status from events.db");
+
+       ObjectDatabaseManager* dbManager = ObjectDatabaseManager::instance();
+       ObjectDatabase* statusDatabase = dbManager->loadObjectDatabase("queststatus", true);
+
+       if (statusDatabase == NULL) {
+               error("Could not load the queststatus database.");
+               return;
+       }
+
+       int i = 0;
+
+       try {
+               ObjectDatabaseIterator iterator(statusDatabase);
+
+               uint64 objectID;
+
+               while (iterator.getNextKey(objectID)) {
+                       Reference<QuestStatus*> status = Core::getObjectBroker()->lookUp(objectID).castTo<QuestStatus*>();
+                       if (status != NULL)
+                               questStatuses.put(status->getKey(), status);
 
-       ObjectOutputStream* value = new ObjectOutputStream();
-       valString.toBinaryStream(value);
+                       ++i;
+               }
+       } catch (DatabaseException& e) {
+               error("Database exception in DirectorManager::loadPersistentStatus(): " + e.getMessage());
+       }
 
-       ObjectOutputStream* key = new ObjectOutputStream();
-       keyString.toBinaryStream(key);
+       info(String::valueOf(i) + " persistent statuses loaded.", true);
+}
+
+void DirectorManager::setQuestStatus(String keyString, String valString) {
+       ManagedReference<QuestStatus*> status = questStatuses.get(keyString);
 
-       questDB->putData(key, value);
+       if (status == NULL) {
+               status = new QuestStatus();
+               status->setKey(keyString);
+               questStatuses.put(keyString, status);
 
-       ObjectDatabaseManager::instance()->commitLocalTransaction();
+               ObjectManager::instance()->persistObject(status, 1, "queststatus");
+       }
+
+       status->setStatus(valString);
 }
 
 String DirectorManager::getQuestStatus(String keyString) {
-       LocalDatabase* questDB = ObjectDatabaseManager::instance()->loadLocalDatabase("queststatus", true);
-       ObjectDatabaseManager::instance()->commitLocalTransaction();
-
        String str = "";
 
-       ObjectOutputStream key;
-       keyString.toBinaryStream(&key);
-       ObjectInputStream value;
-
-       if (questDB->getData(&key, &value) == 0)
-               str.parseFromBinaryStream(&value);
+       QuestStatus* status = questStatuses.get(keyString);
+       if (status != NULL)
+               str = status->getStatus();
 
        return str;
 }
 
+void DirectorManager::removeQuestStatus(String key) {
+       ManagedReference<QuestStatus*> status = NULL;
+
+       status = questStatuses.get(key);
+
+       if (status != NULL)
+               ObjectManager::instance()->destroyObjectFromDatabase(status->_getObjectID());
+}
+
 void DirectorManager::startGlobalScreenPlays() {
        for (int i = 0; i < screenPlays.size(); ++i) {
                String screenPlay = screenPlays.elementAt(i).getKey();
index e71d0df..282da63 100755 (executable)
@@ -44,10 +44,12 @@ namespace server {
   namespace managers {
    namespace director {
    class PersistentEvent;
+   class QuestStatus;
 
        class DirectorManager : public Singleton<DirectorManager>, public Object, public Logger, public ReadWriteLock {
                ThreadLocal<Lua*> localLua;
                VectorMap<String, bool> screenPlays;
+               VectorMap<String, QuestStatus*> questStatuses;
 
 #ifdef WITH_STM
                TransactionalReference<DirectorSharedMemory* > sharedMemory;
@@ -64,6 +66,7 @@ namespace server {
                DirectorManager();
 
                void loadPersistentEvents();
+               void loadPersistentStatus();
 
                void startGlobalScreenPlays();
                void startScreenPlay(CreatureObject* creatureObject, const String& screenPlayName);
@@ -73,6 +76,7 @@ namespace server {
 
                void setQuestStatus(String keyString, String valString);
                String getQuestStatus(String keyString);
+               void removeQuestStatus(String key);
 
                virtual Lua* getLuaInstance();
                int runScreenPlays();
diff --git a/MMOCoreORB/src/server/zone/managers/director/QuestStatus.h b/MMOCoreORB/src/server/zone/managers/director/QuestStatus.h
new file mode 100644 (file)
index 0000000..522d2ac
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * QuestStatus.h
+ *
+ *  Created on: Aug 9, 2014
+ *      Author: swgemu
+ */
+
+#ifndef QUESTSTATUS_H_
+#define QUESTSTATUS_H_
+
+#include "engine/engine.h"
+
+namespace server {
+namespace zone {
+namespace managers {
+namespace director {
+
+class QuestStatus : public ManagedObject {
+private:
+       String key;
+       String status;
+
+
+public:
+       QuestStatus() {
+               key = "";
+               status = "";
+       }
+
+       QuestStatus(const QuestStatus& q) {
+               key = q.key;
+               status = q.status;
+       }
+
+       QuestStatus& operator=(const QuestStatus& q) {
+               if (this == &q)
+                       return *this;
+
+               key = q.key;
+               status = q.status;
+
+               return *this;
+       }
+
+       const String& getKey() const {
+               return key;
+       }
+
+       void setKey(const String& key) {
+               this->key = key;
+       }
+
+       const String& getStatus() const {
+               return status;
+       }
+
+       void setStatus(const String& status) {
+               this->status = status;
+       }
+};
+
+}
+}
+}
+}
+
+#endif /* QUESTSTATUS_H_ */
index 6b45b55..69b967f 100644 (file)
@@ -60,6 +60,7 @@ ObjectManager::ObjectManager() : DOBObjectManager() {
        databaseManager->loadObjectDatabase("spawnobservers", true);
        databaseManager->loadObjectDatabase("aiobservers", true);
        databaseManager->loadObjectDatabase("events", true);
+       databaseManager->loadObjectDatabase("queststatus", true);
        databaseManager->loadObjectDatabase("surveys", true);
 
        ObjectDatabaseManager::instance()->commitLocalTransaction();