From: <wel...@us...> - 2009-05-26 08:49:03
|
Revision: 3782 http://planeshift.svn.sourceforge.net/planeshift/?rev=3782&view=rev Author: weltall2 Date: 2009-05-26 08:48:53 +0000 (Tue, 26 May 2009) Log Message: ----------- merged r3591 from trunk. This is an edited merge as the code was incompatible with stable. Modified Paths: -------------- stable/src/server/bulkobjects/psitem.cpp stable/src/server/cachemanager.cpp stable/src/server/cachemanager.h Property Changed: ---------------- stable/ Property changes on: stable ___________________________________________________________________ Modified: svn:mergeinfo - /personal/Xordan:1745,1812,1894,2270,2272,2283,2330,2333,2336 /trunk:1-2108,2110,2112,2114,2116-2119,2121,2123-2124,2126,2128,2130,2132-2133,2135-2465,2469,2472,2481,2487,2489,2497-2502,2507,2510-2512,2526,2528-2541,2543,2549,2551-2556,2558,2560-2561,2563-2564,2568,2570,2572,2574-2575,2577,2579,2581,2583,2604,2606-2607,2609,2611,2622,2628-2629,2631,2638-2639,2642,2661,2668,2670,2680,2685,2690,2696-2706,2709,2755,2765,2767,2786,2797,2799-2801,2805,2807-2808,2811,2813-2815,2826,2836,2848,2855,2879,2881,2883,2887,2891,2893,2908,2915-2916,2918,2920,2922,2925-2926,2931,2934,2947,3172,3178,3186-3187,3262,3264,3307,3542,3649,3655,3657,3670-3671,3677-3678,3742-3743 + /personal/Xordan:1745,1812,1894,2270,2272,2283,2330,2333,2336 /trunk:1-2108,2110,2112,2114,2116-2119,2121,2123-2124,2126,2128,2130,2132-2133,2135-2465,2469,2472,2481,2487,2489,2497-2502,2507,2510-2512,2526,2528-2541,2543,2549,2551-2556,2558,2560-2561,2563-2564,2568,2570,2572,2574-2575,2577,2579,2581,2583,2604,2606-2607,2609,2611,2622,2628-2629,2631,2638-2639,2642,2661,2668,2670,2680,2685,2690,2696-2706,2709,2755,2765,2767,2786,2797,2799-2801,2805,2807-2808,2811,2813-2815,2826,2836,2848,2855,2879,2881,2883,2887,2891,2893,2908,2915-2916,2918,2920,2922,2925-2926,2931,2934,2947,3172,3178,3186-3187,3262,3264,3307,3542,3591,3649,3655,3657,3670-3671,3677-3678,3742-3743 Modified: stable/src/server/bulkobjects/psitem.cpp =================================================================== --- stable/src/server/bulkobjects/psitem.cpp 2009-05-25 22:51:23 UTC (rev 3781) +++ stable/src/server/bulkobjects/psitem.cpp 2009-05-26 08:48:53 UTC (rev 3782) @@ -2678,37 +2678,43 @@ void psItem::GetComboInfoString(psCharacter* character, uint32 designID, csString & comboString) { - CraftComboInfo* combInfo = CacheManager::GetSingleton().GetTradeComboInfoByItemID(designID); - if (!combInfo) + csArray<CraftComboInfo*>* combInfoArray = CacheManager::GetSingleton().GetTradeComboInfoByItemID(designID); + if (!combInfoArray) return; - // If any skill check fails then do not display this combinations string - csArray<CraftSkills*>* skillArray = combInfo->skillArray; - for ( int count = 0; count<(int)skillArray->GetSize(); count++ ) + csArray<CraftComboInfo*>::Iterator combInfoIter(combInfoArray->GetIterator()); + while(combInfoIter.HasNext()) { - // Check if craft step minimum primary skill level is meet by client - int priSkill = skillArray->Get(count)->priSkillId; - if(priSkill != 0) + CraftComboInfo* combInfo = combInfoIter.Next(); + // If any skill check succeed then display this combinations string. + // that means we have a way to do something with the result of the combine + csArray<CraftSkills*>* skillArray = combInfo->skillArray; + for ( int count = 0; count<(int)skillArray->GetSize(); count++ ) { - if (skillArray->Get(count)->minPriSkill >= (int) character->Skills().GetSkillRank((PSSKILL) priSkill)) + // Check if craft step minimum primary skill level is meet by client + int priSkill = skillArray->Get(count)->priSkillId; + if(priSkill != 0) { - return; + if (skillArray->Get(count)->minPriSkill >= (int)character->Skills().GetSkillRank((PSSKILL) priSkill)) + { + continue; + } } - } - // Check if craft step minimum secondary skill level is meet by client - int secSkill = skillArray->Get(count)->secSkillId; - if(secSkill != 0) - { - if (skillArray->Get(count)->minSecSkill >= (int)character->Skills().GetSkillRank((PSSKILL)priSkill)) + // Check if craft step minimum secondary skill level is meet by client + int secSkill = skillArray->Get(count)->secSkillId; + if(secSkill != 0) { - return; + if (skillArray->Get(count)->minSecSkill >= (int)character->Skills().GetSkillRank((PSSKILL) secSkill)) + { + continue; + } } + // Otherwise send combination string, and go on to next combine + comboString.Append(combInfo->craftCombDescription); + break; } } - - // Otherwise send combination string - comboString.Append(combInfo->craftCombDescription); } void psItem::GetTransInfoString(psCharacter* character, uint32 designID, csString & transString) Modified: stable/src/server/cachemanager.cpp =================================================================== --- stable/src/server/cachemanager.cpp 2009-05-25 22:51:23 UTC (rev 3781) +++ stable/src/server/cachemanager.cpp 2009-05-26 08:48:53 UTC (rev 3782) @@ -278,11 +278,23 @@ } { - csHash<CraftComboInfo*,uint32>::GlobalIterator it(tradeCraftComboInfo_IDHash.GetIterator ()); + csHash<csArray<CraftComboInfo*>*,uint32>::GlobalIterator it(tradeCraftComboInfo_IDHash.GetIterator ()); while (it.HasNext ()) { - CraftComboInfo* newCombo = it.Next (); - delete newCombo; + csArray<CraftComboInfo*>* newComboArray = it.Next (); + csArray<CraftComboInfo*>::Iterator it2(newComboArray->GetIterator ()); + while(it2.HasNext ()) + { + CraftComboInfo* newCombo = it2.Next (); + csArray<CraftSkills*>::Iterator it3(newCombo->skillArray->GetIterator ()); + while (it3.HasNext ()) + { + CraftSkills* newCraftSkill = it3.Next (); + delete newCraftSkill; + } + delete newCombo; + } + delete newComboArray; } tradeCraftComboInfo_IDHash.Empty(); } @@ -901,7 +913,7 @@ lastiid = iid; } - // Finnaly just load the transformation into existing array + // Finally just load the transformation into existing array psTradeTransformations* tran = new psTradeTransformations; if (tran->Load(result[currentrow])) newArray->Push(tran); @@ -1118,21 +1130,24 @@ csPDelArray<CombinationConstruction>* combArray = FindCombinationsList(currentID); if (combArray) { - // Get the combination craft info string - CraftComboInfo* combInfo = new CraftComboInfo; - csArray<CraftSkills*>* craftArray = new csArray<CraftSkills*>; - combInfo->skillArray = craftArray; - combInfo->craftCombDescription = CreateComboCraftDescription(combArray); - + csArray<CraftComboInfo*>* newComboArray = new csArray<CraftComboInfo*>; + // Get the skills array from the transformations for (size_t i=0; i<combArray->GetSize(); i++) { uint32 resultID = combArray->Get(i)->resultItem; csPDelArray<psTradeTransformations>* transArray = FindTransformationsList(currentID, resultID); - if (!transArray) { + if (!transArray) + { Error3("Can not find any transformation data for pattern %d and result %u ",currentID, resultID); continue; } + + // Get the combination craft info string + CraftComboInfo* combInfo = new CraftComboInfo; + combInfo->skillArray = new csArray<CraftSkills*>; + combInfo->craftCombDescription = CreateComboCraftDescription(combArray->Get(i)); + for (size_t j=0; j<transArray->GetSize(); j++) { psTradeTransformations* trans = transArray->Get(j); @@ -1154,32 +1169,36 @@ craftSkill->minPriSkill = proc->GetMinPrimarySkill(); craftSkill->secSkillId = proc->GetSecondarySkillId(); craftSkill->minSecSkill = proc->GetMinSecondarySkill(); - craftArray->Push(craftSkill); + combInfo->skillArray->Push(craftSkill); } } + newComboArray->Push(combInfo); } - tradeCraftComboInfo_IDHash.Put(designItemID,combInfo); + tradeCraftComboInfo_IDHash.Put(designItemID,newComboArray); } // Preload the combination craft string for current group pattern csPDelArray<CombinationConstruction>* combGroupArray = FindCombinationsList(currentGroupID); if (combGroupArray) { - // Get the combination craft info string - CraftComboInfo* combInfo = new CraftComboInfo; - csArray<CraftSkills*>* craftArray = new csArray<CraftSkills*>; - combInfo->skillArray = craftArray; - combInfo->craftCombDescription = CreateComboCraftDescription(combGroupArray); - + csArray<CraftComboInfo*>* newGroupComboArray = new csArray<CraftComboInfo*>; + // Get the skills array from the transformations for (size_t i=0; i<combGroupArray->GetSize(); i++) { uint32 resultID = combGroupArray->Get(i)->resultItem; csPDelArray<psTradeTransformations>* transArray = FindTransformationsList(currentGroupID, resultID); - if (!transArray) { + if (!transArray) + { Error3("Can not find any transformation data for group pattern %d and result %u ",currentGroupID, resultID); continue; } + + // Get the combination craft info string + CraftComboInfo* combInfo = new CraftComboInfo; + combInfo->skillArray = new csArray<CraftSkills*>; + combInfo->craftCombDescription = CreateComboCraftDescription(combGroupArray->Get(i)); + for (size_t j=0; j<transArray->GetSize(); j++) { psTradeTransformations* trans = transArray->Get(j); @@ -1201,11 +1220,12 @@ craftSkill->minPriSkill = proc->GetMinPrimarySkill(); craftSkill->secSkillId = proc->GetSecondarySkillId(); craftSkill->minSecSkill = proc->GetMinSecondarySkill(); - craftArray->Push(craftSkill); + combInfo->skillArray->Push(craftSkill); } } + newGroupComboArray->Push(combInfo); } - tradeCraftComboInfo_IDHash.Put(designItemID,combInfo); + tradeCraftComboInfo_IDHash.Put(designItemID,newGroupComboArray); } // If it is a new design item then create new cache @@ -1387,78 +1407,70 @@ return desc; } -csString CacheManager::CreateComboCraftDescription(csPDelArray<CombinationConstruction>* combArray) +csString CacheManager::CreateComboCraftDescription(CombinationConstruction* currentComb) { csString temp; csString desc(""); - // Go through all of the combinations creating the info description - for (size_t i=0; i<combArray->GetSize(); i++) + // Check for matching lists and create combination info string + // Example: "Combine between 2 and 4 Eggs, Nuts, 5 Milk into Waybread Batter." + + desc.Append("Combine "); + + // Get each of the items + for (size_t j=0; j<currentComb->combinations.GetSize(); j++) { - // Check for matching lists and create combination info string - // Example: "Combine between 2 and 4 Eggs, Nuts, 5 Milk into Waybread Batter." - CombinationConstruction* current = combArray->Get(i); - if (!current) + uint32 combId = currentComb->combinations[j]->GetItemId(); + int combMinQty = currentComb->combinations[j]->GetMinQty(); + int combMaxQty = currentComb->combinations[j]->GetMaxQty(); + psItemStats* itemStats = CacheManager::GetSingleton().GetBasicItemStatsByID( combId ); + if (!itemStats) { - Error2("No combination construction in combination array location %zu", i); + Error2("No item stats for id %u", combId); return desc; } - desc.Append("Combine "); - // Get each of the items - for (size_t j=0; j<current->combinations.GetSize(); j++) + // Check if min and max is same + if(combMinQty == combMaxQty) { - uint32 combId = current->combinations[j]->GetItemId(); - int combMinQty = current->combinations[j]->GetMinQty(); - int combMaxQty = current->combinations[j]->GetMaxQty(); - psItemStats* itemStats = CacheManager::GetSingleton().GetBasicItemStatsByID( combId ); - if (!itemStats) + if (combMinQty == 1) { - Error2("No item stats for id %u", combId); - return desc; + temp.Format("%s, ", itemStats->GetName()); + desc.Append(temp); } - - // Check if min and max is same - if(combMinQty == combMaxQty) - { - if (combMinQty == 1) - { - temp.Format("%s, ", itemStats->GetName()); - desc.Append(temp); - } - else - { - temp.Format("%d %ss, ", combMinQty, itemStats->GetName()); - desc.Append(temp); - } - } else { - temp.Format("between %d and %d %ss, ", combMinQty, combMaxQty, itemStats->GetName()); + temp.Format("%d %ss, ", combMinQty, itemStats->GetName()); desc.Append(temp); } } - - // Get result item names - psItemStats* resultItemStats = CacheManager::GetSingleton().GetBasicItemStatsByID( current->resultItem ); - if (!resultItemStats) - { - Error2("No item stats for id %u", current->resultItem); - return desc; - } - - // Add result part of description - if (current->resultQuantity == 1) - { - temp.Format("into %s.\n", resultItemStats->GetName()); - desc.Append(temp); - } else { - temp.Format("into %d %ss.\n", current->resultQuantity, resultItemStats->GetName()); + temp.Format("between %d and %d %ss, ", combMinQty, combMaxQty, itemStats->GetName()); desc.Append(temp); } } + + // Get result item names + psItemStats* resultItemStats = CacheManager::GetSingleton().GetBasicItemStatsByID( currentComb->resultItem ); + if (!resultItemStats) + { + Error2("No item stats for id %u", currentComb->resultItem); + return desc; + } + + // Add result part of description + if (currentComb->resultQuantity == 1) + { + temp.Format("into %s.\n", resultItemStats->GetName()); + desc.Append(temp); + } + else + { + temp.Format("into %d %ss.\n", currentComb->resultQuantity, resultItemStats->GetName()); + desc.Append(temp); + } + return desc; } @@ -1467,7 +1479,7 @@ return tradeCraftTransInfo_IDHash.Get(id,NULL); } -CraftComboInfo* CacheManager::GetTradeComboInfoByItemID(uint32 id) +csArray<CraftComboInfo*>* CacheManager::GetTradeComboInfoByItemID(uint32 id) { return tradeCraftComboInfo_IDHash.Get(id,NULL); } Modified: stable/src/server/cachemanager.h =================================================================== --- stable/src/server/cachemanager.h 2009-05-25 22:51:23 UTC (rev 3781) +++ stable/src/server/cachemanager.h 2009-05-26 08:48:53 UTC (rev 3782) @@ -281,9 +281,9 @@ psTradePatterns* GetTradePatternByItemID(uint32 id); psTradePatterns* GetTradePatternByName(csString name); csString CreateTransCraftDescription(psTradeTransformations* tran, psTradeProcesses* proc); - csString CreateComboCraftDescription(csPDelArray<CombinationConstruction>* combArray); + csString CreateComboCraftDescription(CombinationConstruction* combArray); csArray<CraftTransInfo*>* GetTradeTransInfoByItemID(uint32 id); - CraftComboInfo* GetTradeComboInfoByItemID(uint32 id); + csArray<CraftComboInfo*>* GetTradeComboInfoByItemID(uint32 id); // Items psItemStats *GetBasicItemStatsByName(csString name); @@ -427,8 +427,8 @@ csHash<CachedObject *, csString> generic_object_cache; csStringHashReversible msg_strings; - csHash<psSectorInfo *> sectorinfo_by_id; /// Sector info list hashed by sector id - csHash<psSectorInfo *> sectorinfo_by_name; /// Sector info list hashed by sector name + csHash<psSectorInfo *> sectorinfo_by_id; ///< Sector info list hashed by sector id + csHash<psSectorInfo *> sectorinfo_by_name; ///< Sector info list hashed by sector name csPDelArray<psTrait > traitlist; csPDelArray<psRaceInfo > raceinfolist; csPDelArray<psSkillInfo > skillinfolist; @@ -451,13 +451,13 @@ csHash<csHash<csPDelArray<psTradeTransformations> *,uint32> *,uint32> tradeTransformations_IDHash; csHash<csArray<uint32> *,uint32> tradeTransUnique_IDHash; csHash<csArray<CraftTransInfo*> *,uint32> tradeCraftTransInfo_IDHash; - csHash<CraftComboInfo*,uint32> tradeCraftComboInfo_IDHash; - csArray<csString> tips_list; /// List for the tips + csHash<csArray<CraftComboInfo*> *,uint32> tradeCraftComboInfo_IDHash; + csArray<csString> tips_list; ///< List for the tips csStringArray bad_names; csPDelArray<ArmorVsWeapon> armor_vs_weapon; csPDelArray<psCharMode> char_modes; csPDelArray<psMovement> movements; - csPDelArray<psCharacterLimitation> limits; /// All the limitations based on scores for characters. + csPDelArray<psCharacterLimitation> limits; ///< All the limitations based on scores for characters. psCommandManager* commandManager; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |