Instructions Jenkins Doxygen

[added] PlayerObject quest journal packet methods 18/1118/5
authorVictor Popovici <theanswer@swgemu.com>
Fri, 15 Nov 2013 19:09:33 +0000 (20:09 +0100)
committerVictor Popovici <theanswer@swgemu.com>
Fri, 15 Nov 2013 19:43:12 +0000 (20:43 +0100)
[added] DeltaBitArray

Change-Id: I301a4d619dd77ba77da977e32f4f24d717f8614e

MMOCoreORB/src/server/zone/objects/player/PlayerObject.idl
MMOCoreORB/src/server/zone/objects/player/PlayerObjectImplementation.cpp
MMOCoreORB/src/server/zone/objects/player/variables/PlayerQuestData.h [new file with mode: 0644]
MMOCoreORB/src/server/zone/objects/scene/variables/DeltaBitArray.h [new file with mode: 0644]
MMOCoreORB/src/server/zone/packets/player/PlayerObjectMessage8.h

index 8bff987..4a5f430 100644 (file)
@@ -82,8 +82,11 @@ include server.zone.objects.player.variables.FriendList;
 include server.zone.objects.player.variables.IgnoreList;
 include server.zone.objects.player.variables.SchematicList;
 include server.zone.objects.player.variables.WaypointList;
+include server.zone.objects.player.variables.PlayerQuestData;
 include server.zone.objects.scene.variables.DeltaVector;
 include server.zone.objects.scene.variables.DeltaVectorMap;
+include server.zone.objects.scene.variables.DeltaBitArray;
+
 
 class PlayerObject extends IntangibleObject {  
        protected unsigned int characterBitmask;
@@ -250,6 +253,20 @@ class PlayerObject extends IntangibleObject {
        @dereferenced
        protected SortedVector<AiAgent> activePets;
        
+       @dereferenced
+       protected DeltaBitArray activeQuests;
+       
+       @dereferenced
+       protected DeltaBitArray completedQuests;
+       
+       
+       /**
+        * the key is the quest.hashCode()
+        */
+       @dereferenced
+       @rawTemplate(value = "uint32, PlayerQuestData")
+       protected DeltaVectorMap playerQuestsData;
+       
        public static final int LFG = 1;
        public static final int NEWBIEHELPER = 2;
        public static final int ROLEPLAYER = 4;
@@ -606,6 +623,37 @@ class PlayerObject extends IntangibleObject {
        
        public native void setJediState(int state, boolean notifyClient = true);
        
+       public native void setActiveQuestsBit(int bitIndex, byte value, boolean notifyClient = true);
+       
+       public void clearActiveQuestsBit(int bitIndex, boolean notifyClient = true) {
+               setActiveQuestsBit(bitIndex, (byte)0, notifyClient);
+       }
+       
+       public boolean hasActiveQuestBitSet(int bitIndex) {
+               return activeQuests.getBitValue(bitIndex);
+       }
+       
+       public boolean hasCompletedQuestsBitSet(int bitIndex) {
+               return completedQuests.getBitValue(bitIndex);
+       }
+       
+       public native void setCompletedQuestsBit(int bitIndex, byte value, boolean notifyClient = true);
+       
+       public void clearCompletedQuestsBit(int bitIndex, boolean notifyClient = true) {
+               setCompletedQuestsBit(bitIndex, (byte)0, notifyClient);
+       }
+       
+       @dereferenced
+       @local
+       public native PlayerQuestData getQuestData(unsigned int questHashCode);
+       
+       public boolean hasQuestData(unsigned int questHashCode) {
+               return playerQuestsData.contains(questHashCode);
+       }
+       
+       @local
+       public native void setPlayerQuestData(unsigned int questHashCode, @dereferenced PlayerQuestData data, boolean notifyClient = true);
+       
        /**
         * Gets the faction point list.
         */
@@ -1058,6 +1106,22 @@ class PlayerObject extends IntangibleObject {
                return experienceList;
        }
        
+       @local
+       @rawTemplate(value = "uint32, PlayerQuestData")
+       public DeltaVectorMap getPlayerQuestsData() {
+               return playerQuestsData;
+       }
+       
+       @local
+       public DeltaBitArray getActiveQuests() {
+               return activeQuests;
+       }
+       
+       @local 
+       public DeltaBitArray getCompletedQuests() {
+               return completedQuests;
+       }
+       
        public int getForcePower() {
                return forcePower;
        }
index c6469d9..ec3e6f6 100644 (file)
@@ -1844,3 +1844,48 @@ void PlayerObjectImplementation::setJediState(int state, bool notifyClient) {
 
        sendMessage(delta);
 }
+
+void PlayerObjectImplementation::setActiveQuestsBit(int bitIndex, byte value, bool notifyClient) {
+       activeQuests.setBit(bitIndex, value);
+
+       if (!notifyClient)
+               return;
+
+       PlayerObjectDeltaMessage8* delta = new PlayerObjectDeltaMessage8(this);
+       delta->startUpdate(4);
+       activeQuests.insertToMessage(delta);
+       delta->close();
+
+       sendMessage(delta);
+}
+
+void PlayerObjectImplementation::setCompletedQuestsBit(int bitIndex, byte value, bool notifyClient) {
+       completedQuests.setBit(bitIndex, value);
+
+       if (!notifyClient)
+               return;
+
+       PlayerObjectDeltaMessage8* delta = new PlayerObjectDeltaMessage8(this);
+       delta->startUpdate(5);
+       completedQuests.insertToMessage(delta);
+       delta->close();
+
+       sendMessage(delta);
+}
+
+void PlayerObjectImplementation::setPlayerQuestData(uint32 questHashCode, PlayerQuestData& data, bool notifyClient) {
+       if (notifyClient) {
+               PlayerObjectDeltaMessage8* dplay8 = new PlayerObjectDeltaMessage8(this);
+               dplay8->startUpdate(6);
+               playerQuestsData.set(questHashCode, data, dplay8, 1);
+               dplay8->close();
+
+               sendMessage(dplay8);
+       } else {
+               playerQuestsData.set(questHashCode, data);
+       }
+}
+
+PlayerQuestData PlayerObjectImplementation::getQuestData(uint32 questHashCode) {
+       return playerQuestsData.get(questHashCode);
+}
diff --git a/MMOCoreORB/src/server/zone/objects/player/variables/PlayerQuestData.h b/MMOCoreORB/src/server/zone/objects/player/variables/PlayerQuestData.h
new file mode 100644 (file)
index 0000000..445edf2
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * PlayerQuestData.h
+ *
+ *  Created on: 15/11/2013
+ *      Author: victor
+ */
+
+#ifndef PLAYERQUESTDATA_H_
+#define PLAYERQUESTDATA_H_
+
+#include "engine/engine.h"
+
+class PlayerQuestData : public Object {
+       uint64 ownerId;
+       uint16 activeStepBitmask;
+       uint16 completedStepBitmask;
+       byte completedFlag;
+       int questCounter;
+public:
+       PlayerQuestData() : Object() {
+               ownerId = 0;
+               activeStepBitmask = 0;
+               completedStepBitmask = 0;
+               completedFlag = 0;
+               questCounter = 0;
+       }
+
+       PlayerQuestData(const PlayerQuestData& data) : Object() {
+               initialize(data);
+       }
+
+       PlayerQuestData& operator=(const PlayerQuestData& data) {
+               if (this == &data)
+                       return *this;
+
+               initialize(data);
+
+               return *this;
+       }
+
+       bool toBinaryStream(ObjectOutputStream* stream) {
+               stream->writeLong(ownerId);
+               stream->writeShort(activeStepBitmask);
+               stream->writeShort(completedStepBitmask);
+               stream->writeByte(completedFlag);
+               stream->writeInt(questCounter);
+
+               return true;
+       }
+
+       bool parseFromBinaryStream(ObjectInputStream* stream) {
+               ownerId = stream->readLong();
+               activeStepBitmask = stream->readShort();
+               completedStepBitmask = stream->readShort();
+               completedFlag = stream->readByte();
+               questCounter = stream->readInt();
+
+               return true;
+       }
+
+       void initialize(const PlayerQuestData& data) {
+               ownerId = data.ownerId;
+               activeStepBitmask = data.activeStepBitmask;
+               completedStepBitmask = data.completedStepBitmask;
+               completedFlag = data.completedFlag;
+               questCounter = data.questCounter;
+       }
+
+       uint16 getActiveStepBitmask() const {
+               return activeStepBitmask;
+       }
+
+       void setActiveStepBitmask(uint16 activeStepBitmask) {
+               this->activeStepBitmask = activeStepBitmask;
+       }
+
+       byte getCompletedFlag() const {
+               return completedFlag;
+       }
+
+       void setCompletedFlag(byte completedFlag) {
+               this->completedFlag = completedFlag;
+       }
+
+       uint16 getCompletedStepBitmask() const {
+               return completedStepBitmask;
+       }
+
+       void setCompletedStepBitmask(uint16 completedStepBitmask) {
+               this->completedStepBitmask = completedStepBitmask;
+       }
+
+       uint64 getOwnerId() const {
+               return ownerId;
+       }
+
+       void setOwnerId(uint64 ownerId) {
+               this->ownerId = ownerId;
+       }
+
+       int getQuestCounter() const {
+               return questCounter;
+       }
+
+       void setQuestCounter(int questCounter) {
+               this->questCounter = questCounter;
+       }
+};
+
+
+#endif /* PLAYERQUESTDATA_H_ */
diff --git a/MMOCoreORB/src/server/zone/objects/scene/variables/DeltaBitArray.h b/MMOCoreORB/src/server/zone/objects/scene/variables/DeltaBitArray.h
new file mode 100644 (file)
index 0000000..b6c6075
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * DeltaBitArray.h
+ *
+ *  Created on: 15/11/2013
+ *      Author: victor
+ */
+
+#ifndef DELTABITARRAY_H_
+#define DELTABITARRAY_H_
+
+#include "DeltaVector.h"
+#include "engine/engine.h"
+
+class DeltaBitArray : public DeltaVector<byte> {
+public:
+       DeltaBitArray() : DeltaVector<byte>(1, 1) {
+       }
+
+       DeltaBitArray(int initsize, int incr) : DeltaVector<byte>(initsize, incr) {
+       }
+
+       DeltaBitArray(const DeltaBitArray& v) : Object(), DeltaVector<byte>(v) {
+       }
+
+       DeltaBitArray& operator=(const DeltaBitArray& v) {
+               if (this == &v)
+                       return *this;
+
+               DeltaVector<byte>::operator =(v);
+
+               return *this;
+       }
+
+       void setBit(int bitIndex, byte value) {
+               int vectorIndex = bitIndex / 8;
+               int vectorBitIndex = 1 << (bitIndex % 8);
+
+               while (size() <= vectorIndex)
+                       add(0);
+
+               byte currentVal = get(vectorIndex);
+
+               if (value) {
+                       if (!currentVal & vectorBitIndex)
+                               currentVal |= vectorBitIndex;
+               } else {
+                       if (currentVal & vectorBitIndex)
+                               currentVal &= ~vectorBitIndex;
+               }
+
+               set(vectorIndex, currentVal);
+       }
+
+       bool getBitValue(int bitIndex) {
+               int vectorIndex = bitIndex / 8;
+               int vectorBitIndex = 1 << (bitIndex % 8);
+
+               if (vectorIndex >= size())
+                       return false;
+
+               byte val = get(vectorIndex);
+
+               return val & vectorBitIndex;
+       }
+
+       void clearBit(int bitIndex) {
+               setBit(bitIndex, 0);
+       }
+
+       int bitCount() {
+               return size() * 8;
+       }
+};
+
+
+#endif /* DELTABITARRAY_H_ */
index 67b9676..e60b2d8 100644 (file)
@@ -67,17 +67,17 @@ public:
                insertInt(play->getForcePower());
                insertInt(play->getForcePowerMax());
 
-               // padawan quests
-               insertInt(0);
-               insertInt(0);
+               // active quests
+               DeltaBitArray* activeQuests = play->getActiveQuests();
+               activeQuests->insertToMessage(this);
 
-               // FS quests
-               insertInt(0);
-               insertInt(0);
+               // completed quests
+               DeltaBitArray* completedQuests = play->getCompletedQuests();
+               completedQuests->insertToMessage(this);
 
                // quests
-               insertInt(0);
-               insertInt(0);
+               DeltaVectorMap<uint32, PlayerQuestData>* quests = play->getPlayerQuestsData();
+               quests->insertToMessage(this);
 
                //
                insertInt(0);