From: Christian S. <blu...@us...> - 2005-10-26 12:04:50
|
Update of /cvsroot/planeshift/planeshift/src/server/bulkobjects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2302/src/server/bulkobjects Modified Files: pscharacter.cpp Log Message: - Begun on fixing Bug #1021 - Weapons can be used without the required stat level - Return to bug list. If somebody feels brave enough, please continue it Index: pscharacter.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/bulkobjects/pscharacter.cpp,v retrieving revision 1.276 retrieving revision 1.277 diff -C2 -d -r1.276 -r1.277 *** pscharacter.cpp 23 Oct 2005 22:10:13 -0000 1.276 --- pscharacter.cpp 26 Oct 2005 12:04:34 -0000 1.277 *************** *** 144,147 **** --- 144,175 ---- maxAmount = carryAmount->GetValue(); } + + // Todo, need to drop items until the player can carry it if he loses MaxCarry + + // Check requirements of the items equiped + for(int i = 0; i < INVENTORY_EQUIP_COUNT;i++) + { + csString a; + psItem* item = equipment[i].item; + if(!item) + continue; + + if(!item->CheckRequirements(this->owner,a)) + { + RemoveEquipment(item->GetLocInParent()); + + // Try to deequip + if(!PutAnyBulk(item)) + continue; + + // Not any space left there either, drop on ground + owner->DropItem(item); + psserver->GetEntityManager()->CreateItem(item,false); // Remove after a while if the player doesn't pick it up + item->SetOwningCharacter(NULL); + + continue; + } + + } } *************** *** 245,257 **** if (!PutBulk(item->GetLocInParent(),item)) { ! // Could not put the item in the slot. This means the index was out of range or an item is ! // already in the slot. ! // An examination of the player's inventory should show which is the case. ! csString error; ! error.Format("\nCharacter: %s(%d)\nLocation: %s Slot: %d\nItem: %s(%s)\n", ! owner->GetCharName(), owner->GetCharacterID(),loc, item->GetLocInParent(), item->GetName(), item->GetUIDStr()); ! Error1( error ); ! ! return false; } } --- 273,289 ---- if (!PutBulk(item->GetLocInParent(),item)) { ! // An equipped item may have stolen it's slot, so we try any ! if(!PutAnyBulk(item)) ! { ! // Could not put the item in the slot. This means the index was out of range or an item is ! // already in the slot. ! // An examination of the player's inventory should show which is the case. ! csString error; ! error.Format("\nCharacter: %s(%d)\nLocation: %s Slot: %d\nItem: %s(%s)\n", ! owner->GetCharName(), owner->GetCharacterID(),loc, item->GetLocInParent(), item->GetName(), item->GetUIDStr()); ! Error1( error ); ! ! return false; ! } } } *************** *** 322,331 **** if( !owner->GetActor() ) { ! Error4("On loading: NPC %s (%d) tried to equip %s but failed the item Requirements:", ! owner->GetCharFullName(), ! owner->GetCharacterID(), ! item->GetName() ! ); ! Error2("%s", resp.GetData() ); } else --- 354,381 ---- if( !owner->GetActor() ) { ! // If this is a PC, try to preseve the item ! if(!owner->IsNPC()) ! { ! // Loading, try to set in inverntory ! if(!PutAnyBulk(item)) ! return true; ! ! // Not any space left there either, drop on ground ! owner->DropItem(item); ! psserver->GetEntityManager()->CreateItem(item,false); // Remove after a while if the player doesn't pick it up ! item->SetOwningCharacter(NULL); ! ! return true; ! } ! else ! { ! // Inform that NPC failed to equip item ! Error4("On loading: NPC %s (%d) tried to equip %s but failed the item Requirements:", ! owner->GetCharFullName(), ! owner->GetCharacterID(), ! item->GetName() ! ); ! } ! } else |