Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container updates #274

Merged
merged 7 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion data/uox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ COMBATHITCHANCE=core

[settings]
{
LOOTDECAYSWITHCORPSE=1
LOOTDECAYSWITHPLAYERCORPSE=1
LOOTDECAYSWITHNPCCORPSE=1
GUARDSACTIVE=1
DEATHANIMATION=1
AMBIENTSOUNDS=5
Expand All @@ -162,6 +163,7 @@ POLYDURATION=90
CLIENTFEATURES=1021183
SERVERFEATURES=4584
SPAWNREGIONSFACETS=0
MOONGATEFACETS=7
OVERLOADPACKETS=1
ADVANCEDPATHFINDING=1
LOOTINGISCRIME=1
Expand Down Expand Up @@ -341,6 +343,7 @@ TRAVELSPELLSBETWEENWORLDS=0
TRAVELSPELLSWHILEAGGRESSOR=0
HIDESTATSFORUNKNOWNMAGICITEMS=1
CASTSPELLSWHILEMOVING=0
AUTOUNEQUIPPEDCASTING=0
}

[start locations]
Expand Down
6 changes: 6 additions & 0 deletions source/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
27/04/2024 - Dragon Slayer/Xuri
Fixed an issue where non-corpse containers - including treasure chests in dungeons - would decay and leave all their contents on the ground.
Converted LOOTDECAYSWITHCORPSE ini setting to two new settings, one for player corpses, one for NPC corpses:
LOOTDECAYSWITHPLAYERCORPSE=1/0 // If 1, items on Player corpses decay along with the corpse, if 0 they drop to the ground
LOOTDECAYSWITHNPCCORPSE=1/0 // If 1, items on NPC corpses decay along with the corpse, if 0 they drop to the ground

20/04/2024 - Dragon Slayer/Xuri
Fixed misspeling in shopkeepers ai (js shopkeeper)
Added shopkeeper AI script to basevendor definition to support bonuses/penalties for guild members
Expand Down
7 changes: 5 additions & 2 deletions source/SEFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4141,8 +4141,8 @@ JSBool SE_GetServerSetting( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN
*rval = STRING_TO_JSVAL( tString );
break;
}
case 47: // LOOTDECAYSWITHCORPSE
*rval = BOOLEAN_TO_JSVAL( cwmWorldState->ServerData()->CorpseLootDecay() );
case 47: // LOOTDECAYSWITHPLAYERCORPSE
*rval = BOOLEAN_TO_JSVAL( cwmWorldState->ServerData()->PlayerCorpseLootDecay() );
break;
case 49: // GUARDSACTIVE
*rval = BOOLEAN_TO_JSVAL( cwmWorldState->ServerData()->GuardsStatus() );
Expand Down Expand Up @@ -5083,6 +5083,9 @@ JSBool SE_GetServerSetting( JSContext *cx, [[maybe_unused]] JSObject *obj, uintN
case 348: // AUTOUNEQUIPPEDCASTING
*rval = BOOLEAN_TO_JSVAL( cwmWorldState->ServerData()->AutoUnequippedCasting() );
break;
case 349: // LOOTDECAYSWITHPLAYERCORPSE
*rval = BOOLEAN_TO_JSVAL( cwmWorldState->ServerData()->NpcCorpseLootDecay() );
break;
default:
ScriptError( cx, "GetServerSetting: Invalid server setting name provided" );
return false;
Expand Down
48 changes: 34 additions & 14 deletions source/cServerData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const std::map<std::string, SI32> CServerData::uox3IniCaseValue
{"BACKUPDIRECTORY"s, 44},
{"MSGBOARDDIRECTORY"s, 45},
{"SHAREDDIRECTORY"s, 46},
{"LOOTDECAYSWITHCORPSE"s, 47},
{"LOOTDECAYSWITHPLAYERCORPSE"s, 47},
{"GUARDSACTIVE"s, 49},
{"DEATHANIMATION"s, 27},
{"AMBIENTSOUNDS"s, 50},
Expand Down Expand Up @@ -368,8 +368,8 @@ const std::map<std::string, SI32> CServerData::uox3IniCaseValue
{"YOUNGLOCATION"s, 345},
{"SECRETSHARDKEY"s, 346},
{"MOONGATEFACETS"s, 347},
{"AUTOUNEQUIPPEDCASTING"s, 348}

{"AUTOUNEQUIPPEDCASTING"s, 348},
{"LOOTDECAYSWITHNPCCORPSE"s, 349}
};
constexpr auto MAX_TRACKINGTARGETS = 128;
constexpr auto SKILLTOTALCAP = 7000;
Expand All @@ -381,7 +381,7 @@ constexpr auto BIT_ANNOUNCEJOINPART = UI32( 1 );
constexpr auto BIT_SERVERBACKUP = UI32( 2 );
constexpr auto BIT_SHOOTONANIMALBACK = UI32( 3 );
constexpr auto BIT_NPCTRAINING = UI32( 4 );
constexpr auto BIT_LOOTDECAYSONCORPSE = UI32( 5 );
constexpr auto BIT_LOOTDECAYSONPLAYERCORPSE = UI32( 5 );
constexpr auto BIT_GUARDSENABLED = UI32( 6 );
constexpr auto BIT_PLAYDEATHANIMATION = UI32( 7 );
constexpr auto BIT_AMBIENTFOOTSTEPS = UI32( 8 );
Expand Down Expand Up @@ -480,6 +480,7 @@ constexpr auto BIT_ENABLENPCGUILDPREMIUMS = UI32( 101 );
constexpr auto BIT_SNOOPAWARENESS = UI32( 102 );
constexpr auto BIT_YOUNGPLAYERSYSTEM = UI32( 103 );
constexpr auto BIT_AUTOUNEQUIPPEDCASTING = UI32( 104 );
constexpr auto BIT_LOOTDECAYSONNPCCORPSE = UI32( 105 );


// New uox3.ini format lookup
Expand Down Expand Up @@ -634,7 +635,8 @@ auto CServerData::ResetDefaults() -> void
ServerSkillCap( 1000 );
ServerStatCap( 225 );
StatsAffectSkillChecks( false );
CorpseLootDecay( true );
PlayerCorpseLootDecay( true );
NpcCorpseLootDecay( true );
ServerSavesTimer( 600 );

// Enable login-support only for latest available client by default
Expand Down Expand Up @@ -1969,17 +1971,31 @@ auto CServerData::DumpPaths() -> void
}

//o------------------------------------------------------------------------------------------------o
//| Function - CServerData::CorpseLootDecay()
//| Function - CServerData::PlayerCorpseLootDecay()
//o------------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether loot decays along with player corpses or is left on ground
//o------------------------------------------------------------------------------------------------o
auto CServerData::PlayerCorpseLootDecay() const -> bool
{
return boolVals.test( BIT_LOOTDECAYSONPLAYERCORPSE );
}
auto CServerData::PlayerCorpseLootDecay( bool newVal ) -> void
{
boolVals.set( BIT_LOOTDECAYSONPLAYERCORPSE, newVal );
}

//o------------------------------------------------------------------------------------------------o
//| Function - CServerData::NpcCorpseLootDecay()
//o------------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether loot decays along with corpses or is left on ground
//| Purpose - Gets/Sets whether loot decays along with npc corpses or is left on ground
//o------------------------------------------------------------------------------------------------o
auto CServerData::CorpseLootDecay() const -> bool
auto CServerData::NpcCorpseLootDecay() const -> bool
{
return boolVals.test( BIT_LOOTDECAYSONCORPSE );
return boolVals.test( BIT_LOOTDECAYSONNPCCORPSE );
}
auto CServerData::CorpseLootDecay( bool newVal ) -> void
auto CServerData::NpcCorpseLootDecay( bool newVal ) -> void
{
boolVals.set( BIT_LOOTDECAYSONCORPSE, newVal );
boolVals.set( BIT_LOOTDECAYSONNPCCORPSE, newVal );
}

//o------------------------------------------------------------------------------------------------o
Expand Down Expand Up @@ -4995,7 +5011,8 @@ auto CServerData::SaveIni( const std::string &filename ) -> bool
ofsOutput << "}" << '\n';

ofsOutput << '\n' << "[settings]" << '\n' << "{" << '\n';
ofsOutput << "LOOTDECAYSWITHCORPSE=" << ( CorpseLootDecay() ? 1 : 0 ) << '\n';
ofsOutput << "LOOTDECAYSWITHPLAYERCORPSE=" << ( PlayerCorpseLootDecay() ? 1 : 0 ) << '\n';
ofsOutput << "LOOTDECAYSWITHNPCCORPSE=" << ( NpcCorpseLootDecay() ? 1 : 0 ) << '\n';
ofsOutput << "GUARDSACTIVE=" << ( GuardsStatus() ? 1 : 0 ) << '\n';
ofsOutput << "DEATHANIMATION=" << ( DeathAnimationStatus() ? 1 : 0 ) << '\n';
ofsOutput << "AMBIENTSOUNDS=" << WorldAmbientSounds() << '\n';
Expand Down Expand Up @@ -5656,8 +5673,8 @@ auto CServerData::HandleLine( const std::string& tag, const std::string& value )
Directory( CSDDP_SHARED, value );
break;
}
case 47: // LOOTDECAYSWITHCORPSE
CorpseLootDecay( static_cast<UI16>( std::stoul( value, nullptr, 0 )) != 0 );
case 47: // LOOTDECAYSWITHPLAYERCORPSE
PlayerCorpseLootDecay( static_cast<UI16>( std::stoul( value, nullptr, 0 )) != 0 );
break;
case 49: // GUARDSACTIVE
GuardStatus( static_cast<UI16>( std::stoul( value, nullptr, 0 )) != 0 );
Expand Down Expand Up @@ -6545,6 +6562,9 @@ auto CServerData::HandleLine( const std::string& tag, const std::string& value )
case 348: // AUTOUNEQUIPPEDCASTING
AutoUnequippedCasting(( static_cast<UI16>( std::stoul( value, nullptr, 0 )) >= 1 ? true : false ));
break;
case 349: // LOOTDECAYSWITHNPCCORPSE
NpcCorpseLootDecay( static_cast<UI16>( std::stoul( value, nullptr, 0 )) != 0 );
break;
default:
rValue = false;
break;
Expand Down
8 changes: 5 additions & 3 deletions source/cServerData.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class CServerData

// Once over 62, bitsets are costly. std::vector<bool> has a special exception in the c++ specificaiton, to minimize wasted space for bools
// These should be updated
std::bitset<105> boolVals; // Many values stored this way, rather than using bools.
std::bitset<106> boolVals; // Many values stored this way, rather than using bools.
std::bitset<64> spawnRegionsFacets; // Used to determine which facets to enable spawn regions for, set in UOX>INI
std::bitset<64> moongateFacets; // Used to determine which facets to enable moongates for, set in UOX>INI

Expand Down Expand Up @@ -606,8 +606,10 @@ class CServerData
std::string Directory( CSDDirectoryPaths dp );


auto CorpseLootDecay( bool value ) -> void;
auto CorpseLootDecay() const -> bool;
auto PlayerCorpseLootDecay( bool value ) -> void;
auto PlayerCorpseLootDecay() const -> bool;
auto NpcCorpseLootDecay( bool value ) -> void;
auto NpcCorpseLootDecay() const -> bool;

auto GuardStatus( bool value ) -> void;
auto GuardsStatus() const -> bool;
Expand Down
3 changes: 2 additions & 1 deletion source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,8 @@ auto DecayItem( CItem& toDecay, const UI32 nextDecayItems, UI32 nextDecayItemsIn

if( toDecay.IsContType() )
{
if( !isCorpse || ValidateObject(toDecay.GetOwnerObj() ) || !cwmWorldState->ServerData()->CorpseLootDecay() )
if( isCorpse && (( ValidateObject( toDecay.GetOwnerObj() ) && !cwmWorldState->ServerData()->PlayerCorpseLootDecay() ) // Player corpse
|| ( !ValidateObject( toDecay.GetOwnerObj() ) && !cwmWorldState->ServerData()->NpcCorpseLootDecay() ))) // NPC corpse
{
std::vector<CItem *> corpseItems;
auto iCont = toDecay.GetContainsList();
Expand Down