Skip to content

Commit

Permalink
Merge branch 'develop' into DFN-Item-Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonSlayer62 committed Mar 30, 2024
2 parents 9c8b08b + 69e051c commit ccc85a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
4 changes: 2 additions & 2 deletions source/CPacketReceive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void CPIFirstLogin::Receive( void )
char temp[30];
// Grab our username
memcpy( temp, &tSock->Buffer()[1], 30 );
userId = temp;
userId = oldstrutil::trim( temp );

// Grab our password
memcpy( temp, &tSock->Buffer()[31], 30 );
Expand Down Expand Up @@ -547,7 +547,7 @@ void CPISecondLogin::Receive( void )

// Grab our username
memcpy( temp, &tSock->Buffer()[5], 30 );
sid = temp;
sid = oldstrutil::trim( temp );

// Grab our password
memcpy( temp, &tSock->Buffer()[35], 30 );
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 @@
22/03/2024 - Dragon Slayer/Xuri
Leading/trailing whitespace is now trimmed from account names during login.

21/03/2024 - Dragon Slayer/Xuri
Fixed an issue with onHunger and onThirst event crashing if the npc was not loaded yet.

18/02/2024 - Dragon Slayer/Xuri
Updated set and get commands (set.js, get.js) with additional ways to set/get resistance types on objects using the syntax 'set/set [type] #. Available resistance types:
resistarmor, resistlight, resistwater, resistcold, resistfire, resistenergy, resistpoison
Expand Down
38 changes: 22 additions & 16 deletions source/cChar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,17 +474,20 @@ SI08 CChar::GetHunger( void ) const
}
bool CChar::SetHunger( SI08 newValue )
{
std::vector<UI16> scriptTriggers = GetScriptTriggers();
for( auto i : scriptTriggers )
if( IsValidNPC() )
{
cScript *toExecute = JSMapping->GetScript( i );
if( toExecute != nullptr )
std::vector<UI16> scriptTriggers = GetScriptTriggers();
for( auto i : scriptTriggers )
{
// If script returns false/0/nothing, prevent hunger from changing, and prevent
// other scripts with event from running
if( toExecute->OnHungerChange(( this ), hunger ) == 0 )
cScript *toExecute = JSMapping->GetScript( i );
if( toExecute != nullptr )
{
return false;
// If script returns false/0/nothing, prevent hunger from changing, and prevent
// other scripts with event from running
if( toExecute->OnHungerChange(( this ), hunger ) == 0 )
{
return false;
}
}
}
}
Expand Down Expand Up @@ -649,17 +652,20 @@ SI08 CChar::GetThirst( void ) const

bool CChar::SetThirst( SI08 newValue )
{
std::vector<UI16> scriptTriggers = GetScriptTriggers();
for( auto i : scriptTriggers )
if( IsValidNPC() )
{
cScript* toExecute = JSMapping->GetScript( i );
if( toExecute != nullptr )
std::vector<UI16> scriptTriggers = GetScriptTriggers();
for( auto i : scriptTriggers )
{
// If script returns false/0/nothing, prevent thirst from changing, and prevent
// other scripts with event from running
if( toExecute->OnThirstChange(( this ), thirst ) == 0 )
cScript* toExecute = JSMapping->GetScript( i );
if( toExecute != nullptr )
{
return false;
// If script returns false/0/nothing, prevent thirst from changing, and prevent
// other scripts with event from running
if( toExecute->OnThirstChange(( this ), thirst ) == 0 )
{
return false;
}
}
}
}
Expand Down

0 comments on commit ccc85a0

Please sign in to comment.