Update of /cvsroot/planeshift/planeshift/src/server/bulkobjects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30238/src/server/bulkobjects Modified Files: pscharacter.cpp pscharacter.h psglyph.cpp psglyph.h psitem.cpp psitem.h psspell.cpp psspell.h Log Message: new glyph window Index: pscharacter.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharacter.cpp,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** pscharacter.cpp 15 Mar 2004 04:15:08 -0000 1.84 --- pscharacter.cpp 20 Mar 2004 15:36:21 -0000 1.85 *************** *** 121,126 **** trainerInfo = NULL; - glyphList = new psGlyphList(this); - timeconnected=0; startTimeThisSession = 0; --- 121,124 ---- *************** *** 177,181 **** } } - delete glyphList; while (assigned_quests.Length() ) --- 175,178 ---- *************** *** 2014,2031 **** } - psGlyphList * psCharacter::GetGlyphList() - { - return glyphList; - } - - void psCharacter::RemoveFromGlyphList(psGlyph * glyph) - { - glyphList->RemoveFromSlot(glyph->GetGlyphSlot()); - } - - int psCharacter::AddToGlyphList(psGlyph * glyph) - { - return glyphList->Add(glyph); - } --- 2011,2014 ---- Index: pscharacter.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharacter.h,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** pscharacter.h 15 Mar 2004 04:15:08 -0000 1.58 --- pscharacter.h 20 Mar 2004 15:36:21 -0000 1.59 *************** *** 191,195 **** class ExchangeManager; class psSpell; - class psGlyphList; class psGlyph; class psTradeTransformations; --- 191,194 ---- *************** *** 240,244 **** csRef<psGuildInfo> guildinfo; // refcounted to determine when to delete csArray<psSpell*> spellList; - psGlyphList *glyphList; csArray<QuestAssignment*> assigned_quests; SkillSet base_skills; --- 239,242 ---- *************** *** 593,599 **** psSpell * GetSpellByIdx(int index); csString GetXMLSpellList(); - psGlyphList *GetGlyphList(); - void RemoveFromGlyphList(psGlyph * glyph); - int AddToGlyphList(psGlyph * glyph); typedef enum --- 591,594 ---- Index: psglyph.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psglyph.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** psglyph.cpp 13 Mar 2004 18:32:00 -0000 1.9 --- psglyph.cpp 20 Mar 2004 15:36:21 -0000 1.10 *************** *** 29,33 **** psGlyph::psGlyph() - :glyphSlot(0) { } --- 29,32 ---- *************** *** 56,86 **** } - - - csString psGlyph::GlyphToXML() - { - csString defaultSlot; - csString xml; - if (GetValidSlots() & PSITEMSTATS_SLOT_CRYSTAL) defaultSlot = "crystal"; - if (GetValidSlots() & PSITEMSTATS_SLOT_AZURE) defaultSlot = "azure"; - if (GetValidSlots() & PSITEMSTATS_SLOT_RED) defaultSlot = "red"; - if (GetValidSlots() & PSITEMSTATS_SLOT_DARK) defaultSlot = "dark"; - if (GetValidSlots() & PSITEMSTATS_SLOT_BROWN) defaultSlot = "brown"; - if (GetValidSlots() & PSITEMSTATS_SLOT_BLUE) defaultSlot = "blue"; - - int purifyStatus = 0; - if (flags & PSITEM_FLAG_PURIFIED) - { - purifyStatus = 2; - } else if (flags & PSITEM_FLAG_PURIFYING) - { - purifyStatus = 1; - } - - xml.Format("<G IMG=\"%s\" SLT=\"%d\" C=\"%d\" PS=\"%d\" DEF=\"%s\"/>", - GetImageName(),glyphSlot,GetStackCount(),purifyStatus,defaultSlot.GetData()); - return xml; - } - void psGlyph::PurifyingStarted() { --- 55,58 ---- *************** *** 102,112 **** } - - void psGlyph::SetGlyphSlot(int slot) - { - glyphSlot = slot; - } - - void psGlyph::SetOwningCharacter(psCharacter *owner) { --- 74,77 ---- *************** *** 119,134 **** if (oldOwner) { - oldOwner->RemoveFromGlyphList(this); flags &= ~PSITEM_FLAG_PURIFIED; flags &= ~PSITEM_FLAG_PURIFYING; } - if (owner) - { - SetGlyphSlot(owner->AddToGlyphList(this)); - } - psItem::SetOwningCharacter(owner); - } --- 84,92 ---- *************** *** 154,268 **** } ! ! /*-------------------------------------------------------------*/ ! ! ! psGlyphList::psGlyphList(psCharacter * character) ! :character(character) ! { ! for (int i = 0; i < GLYPH_LIST_MAX_SLOTS; i++) ! { ! glyphSlots[i] = NULL; ! } ! } ! ! void psGlyphList::RemoveFromSlot(int slot) ! { ! glyphSlots[slot] = NULL; ! } ! ! int psGlyphList::Add(psGlyph * glyph) ! { ! int startSlot = 0; ! if (glyph->GetValidSlots() & PSITEMSTATS_SLOT_CRYSTAL) startSlot = 0; ! if (glyph->GetValidSlots() & PSITEMSTATS_SLOT_AZURE) startSlot = GLYPH_LIST_SLOTS_IN_WAY; ! if (glyph->GetValidSlots() & PSITEMSTATS_SLOT_BLUE) startSlot = 2*GLYPH_LIST_SLOTS_IN_WAY; ! if (glyph->GetValidSlots() & PSITEMSTATS_SLOT_RED) startSlot = 3*GLYPH_LIST_SLOTS_IN_WAY; ! if (glyph->GetValidSlots() & PSITEMSTATS_SLOT_BROWN) startSlot = 4*GLYPH_LIST_SLOTS_IN_WAY; ! if (glyph->GetValidSlots() & PSITEMSTATS_SLOT_DARK) startSlot = 5*GLYPH_LIST_SLOTS_IN_WAY; ! ! ! for (int i = 0; i < GLYPH_LIST_SLOTS_IN_WAY; i++) ! { ! if (glyphSlots[startSlot+i] == NULL) ! { ! glyphSlots[startSlot+i] = glyph; ! return startSlot+i; ! } ! } ! return -1; ! } ! ! ! ! bool psGlyphList::MoveGlyph( int fromSlot, int toSlot) { ! // TODO: Check range on slots... ! ! if (glyphSlots[toSlot]) ! { ! lastError = "To slot not empty."; ! return false; ! } ! glyphSlots[toSlot] = glyphSlots[fromSlot]; ! glyphSlots[fromSlot] = NULL; ! ! glyphSlots[toSlot]->SetGlyphSlot(toSlot); ! return true; ! } ! psGlyph * psGlyphList::FindInSlot(int slot) ! { ! return glyphSlots[slot]; ! } ! psGlyph * psGlyphList::FindWithUID(uint64_t UID) ! { ! for (int i = 0; i < GLYPH_LIST_MAX_SLOTS; i++) ! { ! psGlyph * glyph = glyphSlots[i]; ! if (glyph) ! { ! if (glyph->GetUID() == UID) return glyph; ! } ! } ! return NULL; } ! bool psGlyphList::GlyphPurified(psGlyph * glyph) { ! glyph->PurifyingFinished(); ! return true; ! } ! csArray<psGlyph*> psGlyphList::GetAssemblyList() ! { ! csArray<psGlyph*> assemblyList; ! ! for (int i = 0; i < GLYPH_LIST_ASSEMBLE_SLOTS; i++) ! { ! psGlyph * glyph = FindInSlot(i + GLYPH_LIST_START_ASSEMBLE_SLOTS); ! if (glyph) assemblyList.Push(glyph); ! } ! ! return assemblyList; } ! ! csString psGlyphList::GlyphListToXML() { ! csString buff = "<L>"; ! for (int i = 0; i < GLYPH_LIST_MAX_SLOTS; i++) ! { ! if (glyphSlots[i] != NULL) ! { ! buff.Append(glyphSlots[i]->GlyphToXML()); ! } ! ! } ! buff.Append("</L>"); ! return buff; } --- 112,150 ---- } ! psGlyph * psGlyph::Copy(unsigned short newstackcount) { ! psGlyph *newitem; ! // Cannot split into a stack of 0 or a stack of the same amount or more than there already are ! if (newstackcount < 1) ! return NULL; ! // Allocate a new item ! newitem=new psGlyph(); ! Copy(newitem); ! newitem->SetStackCount(newstackcount); ! // We cannot save here because the new stack has no location yet. ! // Put the new stack in a container or in the world and then call Save() ! return newitem; } ! void psGlyph::Copy(psGlyph * target) { ! psItem::Copy(target); ! flags &= ~PSITEM_FLAG_PURIFIED; ! flags &= ~PSITEM_FLAG_PURIFYING; } ! int psGlyph::GetPurifyStatus() { ! if (flags & PSITEM_FLAG_PURIFIED) ! return 2; ! else if (flags & PSITEM_FLAG_PURIFYING) ! return 1; ! else ! return 0; } Index: psglyph.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psglyph.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** psglyph.h 10 Jan 2004 00:14:44 -0000 1.10 --- psglyph.h 20 Mar 2004 15:36:21 -0000 1.11 *************** *** 30,41 **** #include "psstdint.h" - class psGlyphList; class psCharacter; /** */ class psGlyph : public psItem { - friend class psGlyphList; public: psGlyph(); --- 30,40 ---- #include "psstdint.h" class psCharacter; + /** */ class psGlyph : public psItem { public: psGlyph(); *************** *** 49,66 **** virtual bool Save(); csString GlyphToXML(); void PurifyingStarted(); void PurifyingFinished(); bool Purified(); - int GetGlyphSlot(){ return glyphSlot; } - void SetGlyphSlot(int slot); - virtual void SetOwningCharacter(psCharacter *owner); virtual psItem* Clone(); - private: - int glyphSlot; public: --- 48,64 ---- virtual bool Save(); + virtual psGlyph *Copy(unsigned short newstackcount); + void Copy(psGlyph * target); + csString GlyphToXML(); + int GetPurifyStatus(); void PurifyingStarted(); void PurifyingFinished(); bool Purified(); virtual void SetOwningCharacter(psCharacter *owner); virtual psItem* Clone(); public: *************** *** 75,101 **** }; - /** - */ - class psGlyphList - { - - public: - psGlyphList(psCharacter * character); - void RemoveFromSlot(int slot); - int Add(psGlyph * glyph); - bool MoveGlyph( int fromSlot, int toSlot); - psGlyph * FindInSlot(int slot); - psGlyph * FindWithUID(uint64_t UID); - bool GlyphPurified(psGlyph * glyph); - csArray<psGlyph*> GetAssemblyList(); - csString& GetLastError(){ return lastError; } - csString GlyphListToXML(); - - private: - psCharacter * character; - csString lastError; - psGlyph* glyphSlots[GLYPH_LIST_MAX_SLOTS]; - }; - - #endif --- 73,75 ---- Index: psitem.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psitem.cpp,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** psitem.cpp 15 Mar 2004 04:15:08 -0000 1.50 --- psitem.cpp 20 Mar 2004 15:36:21 -0000 1.51 *************** *** 1166,1169 **** --- 1166,1170 ---- } + psItem *psItem::Copy(unsigned short newstackcount) { *************** *** 1181,1201 **** newitem=new psItem(); // The location in world is the same ! newitem->SetLocationInWorld(location.loc_sectorinfo,location.loc_x,location.loc_y,location.loc_z,location.loc_yrot); // Base stats are the same ! newitem->SetBaseStats(GetBaseStats()); // The decay is the same. ! newitem->SetDecay(decay); // The flags are the same ! newitem->flags = flags; // The crafter is the same. ! newitem->crafter_id = crafter_id; // The guild_id is the same. ! newitem->guild_id = guild_id; // Current stats are rebuilt; --- 1182,1213 ---- newitem=new psItem(); + Copy(newitem); + + newitem->SetStackCount(newstackcount); + + // We cannot save here because the new stack has no location yet. + // Put the new stack in a container or in the world and then call Save() + return newitem; + } + + void psItem::Copy(psItem * target) + { // The location in world is the same ! target->SetLocationInWorld(location.loc_sectorinfo,location.loc_x,location.loc_y,location.loc_z,location.loc_yrot); // Base stats are the same ! target->SetBaseStats(GetBaseStats()); // The decay is the same. ! target->SetDecay(decay); // The flags are the same ! target->flags = flags; // The crafter is the same. ! target->crafter_id = crafter_id; // The guild_id is the same. ! target->guild_id = guild_id; // Current stats are rebuilt; *************** *** 1204,1215 **** { if (modifiers[i]!=NULL) ! newitem->AddModifier(modifiers[i]); } - - newitem->SetStackCount(newstackcount); - - // We cannot save here because the new stack has no location yet. - // Put the new stack in a container or in the world and then call Save() - return newitem; } --- 1216,1221 ---- { if (modifiers[i]!=NULL) ! target->AddModifier(modifiers[i]); } } Index: psitem.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psitem.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** psitem.h 6 Mar 2004 04:08:02 -0000 1.35 --- psitem.h 20 Mar 2004 15:36:21 -0000 1.36 *************** *** 354,358 **** * on an owning player must be set first, and then Save() called to generate a UID and save to the database. */ ! psItem *Copy(unsigned short newstackcount); /** Splits an item instance representing a stack into two smaller stacks. --- 354,362 ---- * on an owning player must be set first, and then Save() called to generate a UID and save to the database. */ ! virtual psItem *Copy(unsigned short newstackcount); ! ! /** Copies values of its attributes to item 'target'. ! */ ! void Copy(psItem * target); /** Splits an item instance representing a stack into two smaller stacks. *************** *** 521,524 **** --- 525,529 ---- void RecalcCurrentStats(); + PSITEM_FLAGS GetFlags() { return flags; } /* These next two functions provide the means for unique item id numbering. *************** *** 547,552 **** static uint32 GetNextUniqueItemStatsUID(); - - // Interface to itemstats --- 552,555 ---- Index: psspell.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psspell.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** psspell.cpp 13 Mar 2004 08:58:06 -0000 1.26 --- psspell.cpp 20 Mar 2004 15:36:21 -0000 1.27 *************** *** 75,79 **** } } - return true; } --- 75,78 ---- *************** *** 89,102 **** } ! bool psSpell::MatchGlyphs(csArray<psGlyph*> & glyphs) { ! if (glyphs.Length() != glyphList.Length()) return false; for (int i = 0; i < glyphList.Length(); i++) { ! if (glyphs[i]->GetBaseStats() != glyphList[i]) { return false; - } } --- 88,100 ---- } ! bool psSpell::MatchGlyphs(const glyphAssembler_t & assembler) { ! if (assembler.Length() != glyphList.Length()) return false; for (int i = 0; i < glyphList.Length(); i++) { ! if (assembler[i] != glyphList[i]) { return false; } } *************** *** 104,108 **** } ! bool psSpell::HaveGlyphsToCast(psGlyphList * glyphs, bool& notPurified) { notPurified = false; --- 102,106 ---- } ! bool psSpell::HaveGlyphsToCast(psCharacter * character, bool& notPurified) { notPurified = false; *************** *** 111,117 **** int j = 0; bool found = false; ! do { ! psGlyph * glyph = glyphs->FindInSlot(j); if (glyph) { --- 109,115 ---- int j = 0; bool found = false; ! /* do { ! psGlyph * glyph = NULL;//character->FindPurifiedGlyph(j); if (glyph) { *************** *** 129,133 **** } j++; ! } while (!found && j < GLYPH_LIST_MAX_SLOTS); // No glyph found return false --- 127,131 ---- } j++; ! } while (!found && j < GLYPH_LIST_MAX_SLOTS);*/ // No glyph found return false *************** *** 152,156 **** // Check if needed glyphs are available bool notPurified; ! if (!HaveGlyphsToCast(caster->GetCharacterData()->GetGlyphList(),notPurified)) { if (notPurified) --- 150,154 ---- // Check if needed glyphs are available bool notPurified; ! // if (!HaveGlyphsToCast(caster->GetCharacterData()->GetGlyphList(),notPurified)) { if (notPurified) Index: psspell.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/psspell.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** psspell.h 10 Oct 2003 23:37:15 -0000 1.14 --- psspell.h 20 Mar 2004 15:36:21 -0000 1.15 *************** *** 30,34 **** class gemActor; class psGlyph; - class psGlyphList; class psSpellGameEvent; --- 30,33 ---- *************** *** 41,44 **** --- 40,45 ---- + typedef csArray<psItemStats*> glyphAssembler_t; + /** */ *************** *** 59,64 **** PSSKILL GetSkill(); /// Return the needed skill to cast this spell. ! bool MatchGlyphs(csArray<psGlyph*> & glyphs); ! bool HaveGlyphsToCast(psGlyphList * glyphs, bool& notPurified); psSpellGameEvent* Cast(psSpellManager * mgr, Client * caster, csString * castingEffect, csString * castingText); --- 60,65 ---- PSSKILL GetSkill(); /// Return the needed skill to cast this spell. ! bool MatchGlyphs(const glyphAssembler_t & glyphs); ! bool HaveGlyphsToCast(psCharacter * character, bool& notPurified); psSpellGameEvent* Cast(psSpellManager * mgr, Client * caster, csString * castingEffect, csString * castingText); |